Error notifications

This commit is contained in:
Martin Schröder 2015-05-13 17:08:04 +02:00 committed by Martin Schröder
parent 9fd3c694a9
commit 55efc52eda
14 changed files with 76 additions and 29 deletions

View file

@ -11,7 +11,8 @@
"settings",
"status",
"internet",
"wifi",
"juci-mod-dropbear"
"wifi"
//"juci-mod-dropbear",
//"testrunner"
]
}

View file

@ -12,6 +12,7 @@
<link href="lib/css/select.min.css" rel="stylesheet" type="text/css" />
<link href="lib/css/angular-ui-switch.min.css" rel="stylesheet" type="text/css" />
<link href="lib/css/awesome-bootstrap-checkbox.css" rel="stylesheet" type="text/css" />
<!--<link href="lib/js/jasmine-core/jasmine.css" rel="stylesheet" type="text/css" />-->
<!--<link href="/lib/css/awesome-bootstrap-checkbox.css" rel="stylesheet" type="text/css" />-->
<link href="css/nga.min.css" rel="stylesheet" type="text/css" />
<link href="css/app.css" rel="stylesheet" type="text/css" />
@ -39,6 +40,10 @@
<script src="lib/js/angular-modal-service.min.js"></script>
<script src="lib/js/angular-checklist-model.js"></script>
<!--<script src="lib/js/jasmine-core/jasmine.js"></script>
<script src="lib/js/jasmine-core/jasmine-html.js"></script>
<script src="lib/js/jasmine-core/boot.js"></script>-->
<!-- ###---### -->
<script src="js/rpc.js"></script>
<script src="js/uci.js"></script>

View file

@ -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"));
},
});

View file

@ -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": {

View file

@ -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'
}
}

View file

@ -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",

View file

@ -0,0 +1,5 @@
<div class="alert alert-danger" ng-show="errors.length">
<ul>
<li ng-repeat="err in errors"><button class="btn btn-default pull-right">Hide</button>{{err.message}}<div style="clear: both;"></div></li>
</ul>
</div>

View file

@ -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;
});

View file

@ -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!");
});
}
});

View file

@ -1,7 +1,7 @@
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
$juci.module("phone")
.controller("PhoneCallLogPageCtrl", function($scope, $uci, gettext, $tr){
.controller("PhoneCallLogPageCtrl", function($scope, $uci, gettext, $tr, $rpc){
$scope.phoneFilter = "";
$scope.phoneFilterSelected = {};
$scope.phoneList = [];

View file

@ -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){

View file

@ -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){

View file

@ -16,6 +16,7 @@
<luci-nav></luci-nav>
</div>
<div class="col-md-9">
<luci-errors></luci-errors>
<ng-transclude></ng-transclude>
</div>
</div>

View file

@ -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"
}
}