luci-app-attendedsysupgrade: show position in queue
authorPaul Spooren <mail@aparcar.org>
Mon, 16 Aug 2021 04:50:49 +0000 (18:50 -1000)
committerPaul Spooren <mail@aparcar.org>
Tue, 17 Aug 2021 00:58:03 +0000 (14:58 -1000)
The server provides a queue_position argument, show it.

Signed-off-by: Paul Spooren <mail@aparcar.org>
applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js

index 802868ad0d00b7e93a24dc4062b1227e46874014..5d5d4bd9ba8f01dd171f06359f35f741a682e1f7 100644 (file)
@@ -170,14 +170,12 @@ function request_sysupgrade(server_url, data) {
                        case 202:
                                res = response.json()
                                data.request_hash = res.request_hash;
-                               switch (res.status) {
-                                       case "queued":
-                                               displayStatus("notice spinning", E('p', _('Request in build queue')));
-                                               break;
-                                       case "started":
-                                               displayStatus("notice spinning", E('p', _('Building the sysupgrade image')));
-                                               break;
-                               }
+
+                               if ("queue_position" in res)
+                                       displayStatus("notice spinning", E('p', _('Request in build queue position %d'.format(res.queue_position))));
+                               else
+                                       displayStatus("notice spinning", E('p', _('Building firmware sysupgrade image')));
+
                                setTimeout(function() {
                                        request_sysupgrade(server_url, data);
                                }, 5000);