From 55efc52edaf5bcd0295069794e4aafdeca86ce72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Schr=C3=B6der?= Date: Wed, 13 May 2015 17:08:04 +0200 Subject: [PATCH] Error notifications --- luciexpress/htdocs/config.json | 5 ++-- luciexpress/htdocs/index.html | 5 ++++ luciexpress/htdocs/js/app.js | 11 +++++++-- luciexpress/htdocs/js/uci.js | 17 +++++++------- luciexpress/htdocs/lib/js/jquery-jsonrpc.js | 4 ++-- luciexpress/htdocs/plugins/core/plugin.json | 1 + .../plugins/core/widgets/luci.errors.html | 5 ++++ .../plugins/core/widgets/luci.errors.js | 16 +++++++++++++ .../htdocs/plugins/core/widgets/luci.login.js | 6 +++-- .../plugins/phone/pages/phone.call_log.js | 2 +- .../status/pages/status.diagnostics.js | 2 +- .../htdocs/plugins/wifi/pages/wifi.wps.js | 7 ++++-- .../widgets/luci.layout.with_sidebar.html | 1 + luciexpress/package.json | 23 +++++++++++-------- 14 files changed, 76 insertions(+), 29 deletions(-) create mode 100644 luciexpress/htdocs/plugins/core/widgets/luci.errors.html create mode 100644 luciexpress/htdocs/plugins/core/widgets/luci.errors.js diff --git a/luciexpress/htdocs/config.json b/luciexpress/htdocs/config.json index a792eee9e..43dd02a1d 100644 --- a/luciexpress/htdocs/config.json +++ b/luciexpress/htdocs/config.json @@ -11,7 +11,8 @@ "settings", "status", "internet", - "wifi", - "juci-mod-dropbear" + "wifi" + //"juci-mod-dropbear", + //"testrunner" ] } diff --git a/luciexpress/htdocs/index.html b/luciexpress/htdocs/index.html index ee71cd075..a81f37468 100644 --- a/luciexpress/htdocs/index.html +++ b/luciexpress/htdocs/index.html @@ -12,6 +12,7 @@ + @@ -39,6 +40,10 @@ + + diff --git a/luciexpress/htdocs/js/app.js b/luciexpress/htdocs/js/app.js index 7cdfba247..5efc7c4aa 100644 --- a/luciexpress/htdocs/js/app.js +++ b/luciexpress/htdocs/js/app.js @@ -68,6 +68,12 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $ .run(function($rootScope, $state, $session, gettextCatalog, $tr, gettext, $rpc, $config, $location, $navigation){ console.log("RUN"); + // TODO: maybe use some other way to gather errors than root scope? + $rootScope.errors = []; + $rootScope.$on("error", function(ev, data){ + $rootScope.errors.push({message: data}); + console.log("ERROR: "+ev.name+": "+JSON.stringify(Object.keys(ev.currentScope))); + }); // set current language gettextCatalog.currentLanguage = "se"; gettextCatalog.debug = true; @@ -81,7 +87,7 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $ // Generate states for all loaded pages Object.keys($juci.plugins).map(function(pname){ var plugin = $juci.plugins[pname]; - Object.keys(plugin.pages).map(function(k){ + Object.keys(plugin.pages||{}).map(function(k){ var page = plugin.pages[k]; if(page.view){ //scripts.push(plugin_root + "/" + page.view); @@ -109,7 +115,8 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $ return deferred.promise; } },*/ - onEnter: function($window){ + onEnter: function($window, $rootScope){ + $rootScope.errors.splice(0, $rootScope.errors.length); document.title = $tr(k+".title")+" - "+$tr(gettext("application.name")); }, }); diff --git a/luciexpress/htdocs/js/uci.js b/luciexpress/htdocs/js/uci.js index 3dd69f1c8..0ab863b5a 100644 --- a/luciexpress/htdocs/js/uci.js +++ b/luciexpress/htdocs/js/uci.js @@ -262,14 +262,15 @@ } }, "network": { - "interface": { dvalue: "", type: String }, - "is_lan": { dvalue: 1, type: Number }, - "ifname": { dvalue: "", type: String }, - "proto": { dvalue: "dhcp", type: String }, - "ipaddr": { dvalue: "", type: String }, - "netmask": { dvalue: "", type: String }, - "peerdns": { dvalue: false, type: String }, - "dns": { dvalue: [], type: Array } + "ineterface": { + "is_lan": { dvalue: 1, type: Number }, + "ifname": { dvalue: "", type: String }, + "proto": { dvalue: "dhcp", type: String }, + "ipaddr": { dvalue: "", type: String }, + "netmask": { dvalue: "", type: String }, + "peerdns": { dvalue: false, type: String }, + "dns": { dvalue: [], type: Array } + } }, "unknown": { "host": { diff --git a/luciexpress/htdocs/lib/js/jquery-jsonrpc.js b/luciexpress/htdocs/lib/js/jquery-jsonrpc.js index 5ae8852ff..acbf07c5b 100644 --- a/luciexpress/htdocs/lib/js/jquery-jsonrpc.js +++ b/luciexpress/htdocs/lib/js/jquery-jsonrpc.js @@ -263,7 +263,7 @@ _response: function(json) { if (json === undefined) { return { - error: 'Internal server error', + error: 'JSONRPC: server returned empty string', version: '2.0' }; } @@ -282,7 +282,7 @@ } catch (e) { return { - error: 'Internal server error: ' + e, + error: 'JSONRPC error: ' + e, version: '2.0' } } diff --git a/luciexpress/htdocs/plugins/core/plugin.json b/luciexpress/htdocs/plugins/core/plugin.json index 1b2ddea0a..5d84112f7 100644 --- a/luciexpress/htdocs/plugins/core/plugin.json +++ b/luciexpress/htdocs/plugins/core/plugin.json @@ -13,6 +13,7 @@ "widgets/luci.nav", "widgets/luci.navbar", "widgets/luci.top_bar", + "widgets/luci.errors", "widgets/core.modal", "widgets/luci.input.port", "widgets/luci.input.port.range", diff --git a/luciexpress/htdocs/plugins/core/widgets/luci.errors.html b/luciexpress/htdocs/plugins/core/widgets/luci.errors.html new file mode 100644 index 000000000..eb5f054ba --- /dev/null +++ b/luciexpress/htdocs/plugins/core/widgets/luci.errors.html @@ -0,0 +1,5 @@ +
+ +
diff --git a/luciexpress/htdocs/plugins/core/widgets/luci.errors.js b/luciexpress/htdocs/plugins/core/widgets/luci.errors.js new file mode 100644 index 000000000..212b64872 --- /dev/null +++ b/luciexpress/htdocs/plugins/core/widgets/luci.errors.js @@ -0,0 +1,16 @@ +JUCI.app +.directive("luciErrors", function(){ + var plugin_root = $juci.module("core").plugin_root; + return { + // accepted parameters for this tag + scope: { + }, + templateUrl: plugin_root+"/widgets/luci.errors.html", + replace: true, + controller: "luciErrors" + }; +}) +.controller("luciErrors", function($scope, $rootScope, $localStorage){ + + $scope.errors = $rootScope.errors; +}); diff --git a/luciexpress/htdocs/plugins/core/widgets/luci.login.js b/luciexpress/htdocs/plugins/core/widgets/luci.login.js index 4075dbe8d..aea0fbfeb 100644 --- a/luciexpress/htdocs/plugins/core/widgets/luci.login.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.login.js @@ -20,8 +20,8 @@ * 02110-1301 USA */ -$juci.module("core") - .directive("luciLogin", function(){ +JUCI.app +.directive("luciLogin", function(){ var plugin_root = $juci.module("core").plugin_root; return { // accepted parameters for this tag @@ -94,4 +94,6 @@ $juci.module("core") alert("Error logging out!"); }); } + }); + diff --git a/luciexpress/htdocs/plugins/phone/pages/phone.call_log.js b/luciexpress/htdocs/plugins/phone/pages/phone.call_log.js index ae5d96b57..129486f3e 100644 --- a/luciexpress/htdocs/plugins/phone/pages/phone.call_log.js +++ b/luciexpress/htdocs/plugins/phone/pages/phone.call_log.js @@ -1,7 +1,7 @@ //! Author: Martin K. Schröder $juci.module("phone") -.controller("PhoneCallLogPageCtrl", function($scope, $uci, gettext, $tr){ +.controller("PhoneCallLogPageCtrl", function($scope, $uci, gettext, $tr, $rpc){ $scope.phoneFilter = ""; $scope.phoneFilterSelected = {}; $scope.phoneList = []; diff --git a/luciexpress/htdocs/plugins/status/pages/status.diagnostics.js b/luciexpress/htdocs/plugins/status/pages/status.diagnostics.js index d0c0ec2ac..80fbda160 100644 --- a/luciexpress/htdocs/plugins/status/pages/status.diagnostics.js +++ b/luciexpress/htdocs/plugins/status/pages/status.diagnostics.js @@ -1,5 +1,5 @@ $juci.module("status") -.controller("StatusDiagnostics", function($scope){ +.controller("StatusDiagnostics", function($scope, $rpc){ $scope.data = {}; $rpc.router.networks().done(function(result){ if(result){ diff --git a/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.js b/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.js index 8771e5901..9078b9239 100644 --- a/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.js +++ b/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.js @@ -1,9 +1,12 @@ $juci.module("wifi") -.controller("WifiWPSPageCtrl", function($scope, $uci){ +.controller("WifiWPSPageCtrl", function($scope, $uci, $rpc){ + console.log("WIFI PAGE CONTROLLER"); $scope.data = { userPIN: "" } - $uci.sync(["wireless"]).done(function(){ + $uci.sync(["wireless", "easybox"]).done(function(){ + if($uci.easybox == undefined) $scope.$emit("error", "Easybox config is not present on this system!"); + else $scope.easybox = $uci.easybox; $scope.wireless = $uci.wireless; $scope.$apply(); }).fail(function(err){ diff --git a/luciexpress/htdocs/themes/vodafone/widgets/luci.layout.with_sidebar.html b/luciexpress/htdocs/themes/vodafone/widgets/luci.layout.with_sidebar.html index b02a71afc..9bc283e6f 100644 --- a/luciexpress/htdocs/themes/vodafone/widgets/luci.layout.with_sidebar.html +++ b/luciexpress/htdocs/themes/vodafone/widgets/luci.layout.with_sidebar.html @@ -16,6 +16,7 @@
+
diff --git a/luciexpress/package.json b/luciexpress/package.json index 1a5f87fa7..a541ac866 100644 --- a/luciexpress/package.json +++ b/luciexpress/package.json @@ -2,17 +2,22 @@ "name": "LuCi", "version": "0.0.1", "dependencies": { - "JSON": "*", - "express": "*", - "body-parser": "*", - "grunt": "*", - "grunt-angular-gettext": "*", - "request": "*", - "glob": "*", - "async": "*" - }, + "JSON": "*", + "express": "*", + "body-parser": "*", + "grunt": "*", + "grunt-angular-gettext": "*", + "request": "*", + "glob": "*", + "async": "*" + }, "engines": { "node": "0.10.x", "npm": "1.2.x" + }, + "devDependencies": { + "jasmine-core": "~2.3.3", + "karma-jasmine": "~0.3.5", + "karma-firefox-launcher": "~0.1.6" } }