summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-10-07 10:09:09 +0200
committerJo-Philipp Wich <jo@mein.io>2019-10-07 11:53:39 +0200
commit29ccea14f1594c3b00944c3fa3e74ba925f32ec2 (patch)
tree50bbf06e84c105ed36e27d2c795975704de5f7a9 /modules
parentf3ef2ca2eb887079328d53225fe4336c05d87697 (diff)
luci-mod-system: use awaitReconnect() from ui.js
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js43
1 files changed, 3 insertions, 40 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js
index 711c605283..915c3c7fa0 100644
--- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js
+++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js
@@ -10,43 +10,6 @@ var callSystemValidateFirmwareImage = rpc.declare({
expect: { '': { valid: false, forcable: true } }
});
-function pingDevice(proto, ipaddr) {
- var target = '%s://%s%s?%s'.format(proto || 'http', ipaddr || window.location.host, L.resource('icons/loading.gif'), Math.random());
-
- return new Promise(function(resolveFn, rejectFn) {
- var img = new Image();
-
- img.onload = resolveFn;
- img.onerror = rejectFn;
-
- window.setTimeout(rejectFn, 1000);
-
- img.src = target;
- });
-}
-
-function awaitReconnect(/* ... */) {
- var ipaddrs = arguments.length ? arguments : [ window.location.host ];
-
- window.setTimeout(function() {
- L.Poll.add(function() {
- var tasks = [], reachable = false;
-
- for (var i = 0; i < 2; i++)
- for (var j = 0; j < ipaddrs.length; j++)
- tasks.push(pingDevice(i ? 'https' : 'http', ipaddrs[j])
- .then(function(ev) { reachable = ev.target.src.replace(/^(https?:\/\/[^\/]+).*$/, '$1/') }, function() {}));
-
- return Promise.all(tasks).then(function() {
- if (reachable) {
- L.Poll.stop();
- window.location = reachable;
- }
- });
- })
- }, 5000);
-}
-
function fileUpload(node, path) {
return new Promise(function(resolveFn, rejectFn) {
L.ui.showModal(_('Uploading fileā€¦'), [
@@ -220,7 +183,7 @@ return L.view.extend({
E('p', { 'class': 'spinning' }, _('The system is erasing the configuration partition now and will reboot itself when finished.'))
]);
- awaitReconnect('192.168.1.1', 'openwrt.lan');
+ L.ui.awaitReconnect('192.168.1.1', 'openwrt.lan');
}).catch(function(e) { L.ui.addNotification(null, E('p', e.message)) });
},
@@ -283,7 +246,7 @@ return L.view.extend({
E('p', { 'class': 'spinning' }, _('The system is rebooting now. If the restored configuration changed the current LAN IP address, you might need to reconnect manually.'))
]);
- awaitReconnect(window.location.host, '192.168.1.1', 'openwrt.lan');
+ L.ui.awaitReconnect(window.location.host, '192.168.1.1', 'openwrt.lan');
}, this))
.catch(function(e) { L.ui.addNotification(null, E('p', e.message)) })
.finally(function() { btn.firstChild.data = _('Upload archive...') });
@@ -424,7 +387,7 @@ return L.view.extend({
/* Currently the sysupgrade rpc call will not return, hence no promise handling */
fs.exec('/sbin/sysupgrade', opts);
- awaitReconnect(window.location.host, '192.168.1.1', 'openwrt.lan');
+ L.ui.awaitReconnect(window.location.host, '192.168.1.1', 'openwrt.lan');
},
handleBackupList: function(ev) {