From e45ac0ac7ff66f6e832eaee2403760fa191898db Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 2 Oct 2013 17:09:58 +0000 Subject: [PATCH 1/1] luci2: implement initial backup / restore / flash view. Actual firmware flashing and resetting is stubbed yet --- luci2/htdocs/luci2/luci2.js | 12 ++ luci2/htdocs/luci2/template/system.upgrade.htm | 39 +++++ luci2/htdocs/luci2/view/system.upgrade.js | 234 +++++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 luci2/htdocs/luci2/template/system.upgrade.htm create mode 100644 luci2/htdocs/luci2/view/system.upgrade.js diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js index dfd734b..02b0015 100644 --- a/luci2/htdocs/luci2/luci2.js +++ b/luci2/htdocs/luci2/luci2.js @@ -1292,6 +1292,18 @@ function LuCI2() }), + testReset: _luci2.rpc.declare({ + object: 'luci2.system', + method: 'reset_test', + expect: { supported: false } + }), + + startReset: _luci2.rpc.declare({ + object: 'luci2.system', + method: 'reset_start' + }), + + performReboot: _luci2.rpc.declare({ object: 'luci2.system', method: 'reboot' diff --git a/luci2/htdocs/luci2/template/system.upgrade.htm b/luci2/htdocs/luci2/template/system.upgrade.htm new file mode 100644 index 0000000..6541c22 --- /dev/null +++ b/luci2/htdocs/luci2/template/system.upgrade.htm @@ -0,0 +1,39 @@ + diff --git a/luci2/htdocs/luci2/view/system.upgrade.js b/luci2/htdocs/luci2/view/system.upgrade.js new file mode 100644 index 0000000..2df7f83 --- /dev/null +++ b/luci2/htdocs/luci2/view/system.upgrade.js @@ -0,0 +1,234 @@ +L.ui.view.extend({ + title: L.tr('Flash operations'), + + handle_flash_upload: function() { + var self = this; + L.ui.upload( + L.tr('Firmware upload'), + L.tr('Select the sysupgrade image to flash and click "%s" to proceed.').format(L.tr('Ok')), { + filename: '/tmp/firmware.bin', + success: function(info) { + self.handle_flash_verify(info); + } + } + ); + }, + + handle_flash_verify: function(info) { + var self = this; + L.system.testUpgrade().then(function(res) { + if (res.code == 0) + { + L.ui.dialog( + L.tr('Verify firmware'), [ + $('

').text(L.tr('The firmware image was uploaded completely. Please verify the checksum and file size below, then click "%s" to start the flash procedure.').format(L.tr('Ok'))), + $('