Added many new features

This commit is contained in:
Martin Schröder 2015-05-07 12:07:15 +02:00 committed by Martin Schröder
parent 3fd42ea42b
commit 4411d183e7
38 changed files with 413 additions and 429 deletions

View file

@ -90,7 +90,11 @@ The menu system in the gui is actually created on the router side and retreived
License Notice
--------------
Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
Contributors:
- Noel Wuyts <skype: noel.wuyts>: angular, widgets, development
- Feten Besbes <skype: feten_besbes>: css
Project lead: Martin K. Schröder <mkschreder.uk@gmail.com>
Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.

View file

@ -1,25 +1,5 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
$.jsonRPC.setup({
endPoint: '/ubus',
namespace: 'luci'

View file

@ -1,25 +1,5 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
angular.module("luci")
.factory('$config', function(){
return {
@ -80,8 +60,17 @@ angular.module("luci")
"asterisk.status",
"luci2.system.password_set",
"luci2.system.backup_restore",
"luci2.system.upgrade_test",
"luci2.system.upgrade_clean",
"luci2.system.upgrade_start",
"luci2.system.reset_test",
"luci2.system.reset_start",
"luci2.system.reboot",
"luci2.system.ping",
"luci2.network.ping",
"luci2.network.traceroute",
"network.interface.dump",
"router.networks",
// local stuff for the node server.
"local.features",
"local.set_rpc_host"

View file

@ -1,3 +1,5 @@
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
angular.module("luci")
.controller("InitPageController", function($scope, $tr,
$state, $stateParams, $config, $session, $localStorage,
@ -41,6 +43,7 @@ angular.module("luci")
if(page.view){
//scripts.push(plugin_root + "/" + page.view);
//console.log("Registering state "+k.replace(/\./g, "_"));
// TODO: there is still a problem with state changes where template gets loaded before the dependencies so controller is not found
$juci.$stateProvider.state(k.replace(/\./g, "_"), {
url: "/"+k,
views: {

View file

@ -1,25 +1,5 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
// service for managing session data
angular.module("luci")
.factory('$localStorage', function() {

View file

@ -1,25 +1,4 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
// provides a service for managing all pages
// pages register with this service, and menus can query it to get the navigation tree

View file

@ -1,25 +1,5 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
// luci rpc module for communicating with the server
angular.module("luci")
.factory('$rpc', function($rootScope, $config, gettext){
@ -71,7 +51,7 @@ angular.module("luci")
}
},
error: function(result){
console.error("RPC error: "+JSON.stringify(result));
console.error("RPC error ("+namespace+"."+method+"): "+JSON.stringify(result));
if(result && result.error){
deferred.reject(result.error);
$rootScope.$broadcast("error", result.error.message);

View file

@ -1,25 +1,5 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
// service for managing session data
angular.module("luci")
.factory('$session', function($rpc, $rootScope, $localStorage, $rpc) {

View file

@ -1,3 +1,5 @@
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
angular.module("luci")
.factory('$status', function($rpc) {
var updates = {

View file

@ -1,25 +1,5 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
// luci rpc module for communicating with the server
angular.module("luci")
.factory('$theme', function($rootScope, $config, $localStorage, $http){

View file

@ -1,25 +1,5 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
// service for managing session data
angular.module("luci")
.factory('$tr', function(gettextCatalog) {

View file

@ -1,3 +1,5 @@
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
angular.module("luci")
.provider('$uci', function($rpcProvider){
$rpc = $rpcProvider.$get();
@ -53,6 +55,55 @@ angular.module("luci")
"disabled": { dvalue: false, type: Boolean },
"ping_wan": { dvalue: false, type: Boolean }
},
"voice_client-brcm_line": {
"extension": { dvalue: '', type: String },
"sip_account": { dvalue: '', type: String },
"noise": { dvalue: false, type: Boolean },
"vad": { dvalue: false, type: Boolean },
"txgain": { dvalue: false, type: Boolean },
"rxgain": { dvalue: false, type: Boolean },
"echo_cancel": { dvalue: true, type: Boolean },
"callwaiting": { dvalue: false, type: Boolean },
"clir": { dvalue: false, type: Boolean },
"name": { dvalue: '', type: String },
"instance": { dvalue: '', type: String }
},
"voice_client-sip_service_provider": {
"name": { dvalue: "Account 1", type: String },
"codec0": { dvalue: "alaw", type: String },
"codec1": { dvalue: "ulaw", type: String },
"codec2": { dvalue: "g729", type: String },
"codec3": { dvalue: "g726", type: String },
"autoframing": { dvalue: false, type: Boolean },
"cfim_on": { dvalue: "*21*", type: String },
"cfim_off": { dvalue: "#21#", type: String },
"cfbs_on": { dvalue: "*61*", type: String },
"cfbs_off": { dvalue: "#61#", type: String },
"call_return": { dvalue: "*69", type: String },
"redial": { dvalue: "*66", type: String },
"is_fax": { dvalue: false, type: Boolean },
"transport": { dvalue: "udp", type: String },
"priority_ulaw": { dvalue: 0, type: Number },
"priority_alaw": { dvalue: 0, type: Number },
"priority_g729": { dvalue: 0, type: Number },
"priority_g723": { dvalue: 0, type: Number },
"priority_g726": { dvalue: 0, type: Number },
"enabled": { dvalue: true, type: Boolean },
"target": { dvalue: "direct", type: String },
"call_lines": { dvalue: "BRCM/4", type: String },
"mailbox": { dvalue: "-", type: String },
"call_filter": { dvalue: "-", type: String },
"domain": { dvalue: "217.27.161.62", type: String },
"user": { dvalue: "0854601910", type: String },
"authuser": { dvalue: "0854601910", type: String },
"displayname": { dvalue: "TEST", type: String },
"ptime_ulaw": { dvalue: 20, type: Number },
"ptime_g726": { dvalue: 20, type: Number },
"ptime_g729": { dvalue: 20, type: Number },
"ptime_alaw": { dvalue: 20, type: Number },
"host": { dvalue: "217.27.161.62", type: String },
"outboundproxy": { dvalue: "217.27.161.62", type: String }
},
"wifi-status": {
"wlan": { dvalue: true, type: Boolean },
"wps": { dvalue: true, type: Boolean },
@ -80,8 +131,8 @@ angular.module("luci")
"dtim_period":{ dvalue: 0, type: Number },
"beacon_int": { dvalue: 0, type: Number },
"rxchainps": { dvalue: false, type: Boolean },
"rxchainps_qt":{dvalue: 0, type: Number },
"rxchainps_pps":{dvalue: 0, type: Number },
"rxchainps_qt":{ dvalue: 0, type: Number },
"rxchainps_pps":{ dvalue: 0, type: Number },
"rifs": { dvalue: false, type: Boolean },
"rifs_advert":{ dvalue: false, type: Boolean },
"maxassoc": { dvalue: 0, type: Number },
@ -366,12 +417,18 @@ angular.module("luci")
if(!(configs instanceof Array)) configs = [configs];
if(!configs || configs.length == 0) { next(); return; };
async.eachSeries(configs, function(cf, next){
if(!(cf in self)) { next("invalid config name "+cf); return; };
if(!(cf in self)) {
console.error("invalid config name "+cf);
next();
return;
};
self[cf].$sync().done(function(){
console.log("Synched config "+cf);
next();
}).fail(function(){
next("Could not sync config "+cf);
console.error("Could not sync config "+cf);
next(); // continue because we want to sync as many as we can!
//next("Could not sync config "+cf);
});
}, function(err){
next(err);

View file

@ -21,7 +21,7 @@
<img ng-src="themes/vodafone/img/overview/overview-background-bot.jpg" id="Image-Maps-Com-image-maps-2015-04-08-032815" usemap="#image-maps-2015-04-08-032815" alt="Router">
<div style="position: absolute; top: 70px; left: 100px; text-align: center; width: 60px;">{{wireless.clients.length}}</div>
<div style="position: absolute; top: 70px; left: 450px; text-align: center; width: 60px;">{{network.clients.length}}</div>
<div style="position: absolute; top: 70px; left: 795px; text-align: center; width: 60px;">{{sipAccounts.length}}</div>
<div style="position: absolute; top: 70px; left: 795px; text-align: center; width: 60px;">{{sipAccounts.length||0}}</div>
</center>
</div>
</div>
@ -90,7 +90,7 @@
<tr ng-repeat="sip in sipAccounts track by $index">
<td>
<div class="col-md-2"><strong style="font-size: 1.2em">U{{$index}}</strong></div>
<div class="col-md-8"><strong>{{sip.username}}</strong></div>
<div class="col-md-8"><strong>{{sip.user.value}}</strong></div>
</td>
</tr>
</table>

View file

@ -13,52 +13,68 @@ $juci.module("core")
};
function refresh() {
$uci.sync(["wireless", "easybox"]).done(function(){
//var sections = result.values;
//var cfgs = Object.keys(sections).filter(function(x) { return x.indexOf("cfg") == 0; });
//$scope.wireless.wps = cfgs.filter(function(x) { return cfgs["wps_pbc"] == 1; }).length != 0;
$scope.wifi = $uci.wireless;
$scope.easybox = $uci.easybox;
$scope.wifiSchedStatus = (($scope.wifi.status.schedule.value)?gettext("on"):gettext("off"));
$scope.wifiWPSStatus = (($scope.easybox.settings.wpsbutton.value)?gettext("on"):gettext("off"));
$scope.defaultHostName = $tr(gettext("Unknown"));
async.series([
function(next){
$rpc.router.clients().done(function(clients){
//alert(JSON.stringify(Object.keys(clients).map(function(x) { return clients[x]; })));
var all = Object.keys(clients).map(function(x) { return clients[x]; });
$scope.wireless.clients = all.filter(function(x){
return x.connected && x.wireless == true;
});
$scope.network.clients = all.filter(function(x){
return x.connected && x.wireless == false;
});
next();
//var sections = result.values;
//var cfgs = Object.keys(sections).filter(function(x) { return x.indexOf("cfg") == 0; });
//$scope.wireless.wps = cfgs.filter(function(x) { return cfgs["wps_pbc"] == 1; }).length != 0;
$scope.defaultHostName = $tr(gettext("Unknown"));
$scope.sipAccounts = [];
$scope.wifiSchedStatus = gettext("off");
$scope.wifiWPSStatus = gettext("off");
async.series([
function(next){
$uci.sync(["wireless", "easybox", "voice_client"]).done(function(){
$scope.wifi = $uci.wireless;
$scope.easybox = $uci.easybox;
$scope.voice_client = $uci.voice_client;
if($uci.wireless && $uci.wireless.status)
$scope.wifiSchedStatus = (($uci.wireless.status.schedule.value)?gettext("on"):gettext("off"));
if($uci.wireless && $uci.wireless.wps)
$scope.wifiWPSStatus = (($scope.easybox.settings.wpsbutton.value)?gettext("on"):gettext("off"));
if($uci.voice_client && $uci.voice_client["@sip_service_provider"]){
$scope.sipAccounts = $uci.voice_client["@sip_service_provider"];
}
}).always(function(){ next(); });
},
function(next){
$rpc.router.clients().done(function(clients){
//alert(JSON.stringify(Object.keys(clients).map(function(x) { return clients[x]; })));
var all = Object.keys(clients).map(function(x) { return clients[x]; });
$scope.wireless.clients = all.filter(function(x){
return x.connected && x.wireless == true;
});
},
function(next){
$rpc.asterisk.status().done(function(data){
if(data && data.sip){
var accounts = [];
Object.keys(data.sip).map(function(k){
if(data.sip[k].ip) accounts.push(data.sip[k]);
});
$scope.sipAccounts = accounts;
}
}).always(function(){ next(); });
},
function(next){
$rpc.router.dslstats().done(function(dslstats){
var stats = dslstats.dslstats;
if(stats && stats.bearers && stats.bearers.length > 0){
$scope.dsl.max_rate_up = Math.round(stats.bearers[0].max_rate_up / 1000);
$scope.dsl.max_rate_down = Math.round(stats.bearers[0].max_rate_down / 1000);
}
}).always(function(){ next(); });
}
], function(){
$scope.$apply();
});
$scope.network.clients = all.filter(function(x){
return x.connected && x.wireless == false;
});
next();
}).fail(function(){
next();
});;
},
function(next){
/*$rpc.asterisk.status().done(function(data){
if(data && data.sip){
var accounts = [];
Object.keys(data.sip).map(function(k){
if(data.sip[k].ip) accounts.push(data.sip[k]);
});
$scope.sipAccounts = accounts;
}
}).always(function(){ next(); }); */
// just fall through
next();
},
function(next){
$rpc.router.dslstats().done(function(dslstats){
var stats = dslstats.dslstats;
if(stats && stats.bearers && stats.bearers.length > 0){
$scope.dsl.max_rate_up = Math.round(stats.bearers[0].max_rate_up / 1000);
$scope.dsl.max_rate_down = Math.round(stats.bearers[0].max_rate_down / 1000);
}
}).always(function(){ next(); });
}
], function(){
$scope.$apply();
});
} refresh();
//setInterval(refresh, 5000);

View file

@ -5,6 +5,7 @@
"widgets/luci.progress",
"widgets/luci.table",
"widgets/luci.config",
"widgets/luci.dropdown",
"widgets/luci.layout.naked",
"widgets/luci.layout.single_column",
"widgets/luci.layout.with_sidebar",

View file

@ -0,0 +1,50 @@
$juci.module("core")
.directive('luciDropdown', function ($compile) {
return {
restrict: 'E',
scope: {
items: '=ngModel',
doSelect: '&onChange',
selectedItem: '=ngSelected',
placeholder: '@placeholder'
},
link: function (scope, element, attrs) {
var html = '';
switch (attrs.type) {
case "button":
html += '<div class="btn-group"><button class="btn btn-default button-label">{{placeholder}}</button><button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>';
break;
default:
html += '<div class="dropdown"><a class="dropdown-toggle" role="button" data-toggle="dropdown" href="javascript:;">Dropdown<b class="caret"></b></a>';
break;
}
html += '<ul class="dropdown-menu"><li ng-repeat="item in items"><a tabindex="-1" data-ng-click="selectVal(item)" href="">{{item.label}}</a></li></ul></div>';
element.append($compile(html)(scope));
scope.$watch("items", function(){
if(scope.items){
if(scope.items.length) scope.bSelectedItem = scope.items[0];
for (var i = 0; i < scope.items.length; i++) {
if (scope.items[i].id === scope.selectedItem) {
scope.bSelectedItem = scope.items[i];
break;
}
}
}
});
scope.selectVal = function (item) {
if(!item) return;
switch (attrs.type) {
case "button":
$('button.button-label', element).html(item.label);
break;
default:
$('a.dropdown-toggle', element).html('<b class="caret"></b> ' + item.label);
break;
}
scope.selectedItem = item;
scope.doSelect(item);
};
scope.selectVal(scope.bSelectedItem);
}
};
});

View file

@ -15,6 +15,8 @@ $juci.module("core")
};
});
$scope.onChangeTheme = function(item){
$theme.changeTheme(item.id);
$theme.changeTheme(item.id).done(function(){
window.location.reload();
});
}
});

View file

@ -11,14 +11,14 @@ $juci.module("core")
require: "^ngModel"
};
}).controller("wifiSignalIndicator", function($scope, $uci, $rpc){
var step = 100 / 4;
$scope.bars = [false, false, false, false];
$scope.$watch("value", function(value){
$scope.bars[0] = true;
$scope.bars[1] = $scope.bars[2] = $scope.bars[3] = false;
if(value > step) $scope.bars[1] = true;
if(value > (step * 2)) $scope.bars[2] = true;
if(value > (step * 3)) $scope.bars[3] = true;
var q = value / 5;
$scope.bars[0] = $scope.bars[1] = $scope.bars[2] = $scope.bars[3] = false;
if(value > 1) $scope.bars[0] = true;
if(value > 2) $scope.bars[1] = true;
if(value > 3) $scope.bars[2] = true;
if(value > 4) $scope.bars[3] = true;
});
$scope.barStyle = function(idx, active){
var height = 5 + ((idx) * 5);

View file

@ -1,5 +1,4 @@
<luci-layout-with-sidebar>
<test-directive></test-directive>
<div ng-controller="PhoneCallLogPageCtrl">
<luci-config-section>
<luci-config-heading>{{ 'Call Log' | translate }}</luci-config-heading>
@ -34,11 +33,5 @@
</tr>
</table>
</luci-config-section>
<!--<luci-table
noequalize="on"
columns="['', 'Date', 'Time', 'External Number', 'Your Number', 'Duration', '']"
data="callListTbl">
</luci-table>-->
</div>
</luci-layout-with-sidebar>

View file

@ -1,30 +1,11 @@
/*
* juci - javascript universal client interface
*
* Project Author: Martin K. Schröder <mkschreder.uk@gmail.com>
*
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
$juci.module("phone")
.controller("PhoneCallLogPageCtrl", function($scope, $uci, gettext, $tr){
$scope.phoneFilter = "";
$scope.uniquePhones = [];
/*$scope.phoneFilter = "";
$scope.phoneFilterSelected = {};
$scope.phoneList = [];
$scope.call_log = [];
$rpc.asterisk.call_log.list().done(function(res){
var unique_phones = {};
$scope.call_log = res.call_log.map(function(log){
@ -44,5 +25,5 @@ $juci.module("phone")
});
$scope.onChangeFilter = function(item, model){
$scope.phoneFilter = model.from;
}
}*/
});

View file

@ -46,7 +46,7 @@ $juci.module("settings")
$("form[name='restoreForm']").submit();
}
$scope.onUploadComplete = function(result){
console.log("Result: "+JSON.stringify(result)+": "+$scope.restore.password);
console.log("Uploaded: "+JSON.stringify(result)+": "+$scope.restore.password);
$rpc.luci2.system.backup_restore({
password: $scope.restore.password
}).done(function(result){
@ -54,7 +54,10 @@ $juci.module("settings")
alert(result.stderr);
} else {
$scope.showUploadModal = 0;
$scope.$apply();
}
}).fail(function(err){
console.error("Filed: "+JSON.stringify(err));
});
}
$scope.onAcceptModal = function(){

View file

@ -11,7 +11,7 @@
<h3>{{'Manual Firmware Upgrade'|translate}}</h3>
<p>{{'settings.upgrade.manual.info'|translate}}</p>
<iframe name="postiframe" id="postiframe" style="display: none;" ></iframe>
<form target="postiframe" action="/cgi-bin/luci-upload" method="post" enctype="multipart/form-data">
<form target="postiframe" name="uploadForm" action="/cgi-bin/luci-upload" method="post" enctype="multipart/form-data" >
<input type="hidden" name="sessionid" value="{{sessionID}}" />
<input type="hidden" name="filename" value="{{uploadFilename}}" />
<luci-config-lines>
@ -19,7 +19,7 @@
<input type="file" class="btn btn-default btn-file" name="filedata" />
</luci-config-line>
<luci-config-line title="{{'Start upgrade'|translate}}">
<input type="submit" class="btn btn-lg btn-default" value="{{'Upgrade'|translate}}"/>
<button ng-click="onUploadUpgrade()" class="btn btn-lg btn-default">{{'Upgrade'|translate}}</button>
</luci-config-line>
</luci-config-lines>
</form>

View file

@ -109,7 +109,7 @@
})( jQuery);
$juci.module("settings")
.controller("SettingsUpgradeCtrl", function($scope, $uci, $session){
.controller("SettingsUpgradeCtrl", function($scope, $uci, $rpc, $session){
$scope.sessionID = $session.sid;
$scope.uploadFilename = "/tmp/firmware.bin";
$scope.usbFileName = "()";
@ -125,53 +125,24 @@ $juci.module("settings")
$scope.onUploadComplete = function(result){
console.log("Upload completed: "+JSON.stringify(result));
}
setInterval(function checkUpload(){
var iframe = $("#postiframe");
var json = iframe.contents().text();
if(json.length) {
$scope.onUploadComplete(JSON.parse(json));
iframe.contents().html("");
}
}, 500);
$scope.onUploadUpgrade = function(){
var formData = new FormData($('uploadForm')[0]);
/*$.upload( "/cgi-bin/luci-upload", new FormData($('*uploadForm*')[0]))
.progress( function( progressEvent, upload) {
if( progressEvent.lengthComputable) {
var percent = Math.round( progressEvent.loaded * 100 / progressEvent.total) + '%';
if( upload) {
console.log( percent + ' uploaded');
} else {
console.log( percent + ' downloaded');
}
}
})
.done( function() {
console.log( 'Finished upload');
});*/
$.ajax({
type : 'POST',
url : 'http://192.168.1.4/cgi-bin/luci-upload',
data: formData,
cache: false,
contentType: false,
processData: false,
xhr: function() { // custom xhr
myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ // if upload property exists
myXhr.upload.addEventListener('progress', function(){
console.log("Progress");
}, false); // progressbar
}
return myXhr;
},
success : function(data) {
console.log("Upload completed!");
},
error: function(data){
console.log("Error: "+JSON.stringify(data));
}
}, "json");
$("#postiframe").bind("load", function(){
var json = $(this).contents().text();
var obj = {};
try {
obj = JSON.parse(json);
} catch(e){ alert("The server returned an error!"); }
$rpc.luci2.system.upgrade_test().done(function(result){
console.log(JSON.stringify(result));
$rpc.luci2.system.upgrade_start().done(function(result){
console.log(JSON.stringify(result));
});
});
$(this).unbind("load");
});
$("form[name='uploadForm']").submit();
}
});

View file

@ -1,5 +1,23 @@
<luci-layout-with-sidebar>
<div ng-controller="StatusAbout">
About
<h1 translate>About</h1>
<pre>
Copyright (C) 2012-2013 Inteno Broadband Technology AB.
All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
</pre>
</div>
</luci-layout-with-sidebar>

View file

@ -12,38 +12,29 @@
</luci-config-lines>
<h3>{{'Ping Test'|translate}}</h3>
<p>{{'status.diagnostics.ping.info'|translate}}</p>
<luci-config-lines>
<luci-config-line title="">
<div class="row">
<div class="col-xs-6">
<input type="text" class="form-control"></input>
</div>
<div class="col-xs-6">
<button class="btn btn-lg btn-default">{{'Ping'|translate}}</button>
</div>
</div>
</luci-config-line>
</luci-config-lines>
<div class="row">
<form class="form-inline form-group pull-right">
<input type="text" class="form-control input-lg" placeholder="{{'Host to ping'|translate}}" ng-model="data.pingHost"></input>
<button type="submit" class="btn btn-lg btn-default" ng-click="onPingTest()">{{'Ping'|translate}}</button>
</form>
</div>
<div class="alert alert-default" ng-show="data.pingResults">{{'Ping results'|translate}}: <br/><pre>{{data.pingResults}}</pre></div>
<div class="alert alert-danger" ng-show="data.pingError">{{'Error'|translate}}: <br/><pre>{{data.pingError}}</pre></div>
<h3>{{'Tracing Tool'|translate}}</h3>
<p>{{'status.diagnostics.trace.info'|translate}}</p>
<luci-config-lines>
<luci-config-line title="{{'Connection Type'|translate}}">
<div class="btn-group">
<button type="button" class="btn btn-lg btn-default">WAN/Data</button>
<button type="button" class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
<luci-config-line title="{{'Interface to use'|translate}}">
<luci-dropdown type="button" placeholder="{{'Pick interface'|translate}}" ng-model="data.allInterfaces" ng-selected="data.traceInterface"/>
</luci-config-line>
</luci-config-lines>
<div class="row">
<form class="form-inline form-group pull-right">
<button type="submit" class="btn btn-lg btn-default" ng-click="onTraceTest()">{{'Trace'|translate}}</button>
</form>
</div>
<div class="alert alert-default" ng-show="data.traceResults">{{'Trace results'|translate}}: <br/><pre>{{data.traceResults}}</pre></div>
<div class="alert alert-danger" ng-show="data.traceError">{{'Error'|translate}}: <br/><pre>{{data.traceError}}</pre></div>
</luci-config-section>
</div>
</luci-layout-with-sidebar>

View file

@ -1,4 +1,38 @@
$juci.module("status")
.controller("StatusDiagnostics", function($scope){
$scope.data = {};
$rpc.router.networks().done(function(result){
if(result){
$scope.data.allInterfaces = Object.keys(result).map(function(x){return {label: x, id: x};});
$scope.$apply();
}
});
$scope.onTraceTest = function(){
var item = $scope.data.traceInterface;
if(item && item.id){
console.log("Performing trace on interface "+item.id);
$rpc.luci2.network.traceroute({ data: "google.com" }).done(function(result){
if(result.stderr) $scope.data.traceError = result.stderr;
$scope.data.traceResults = result.stdout;
$scope.$apply();
}).fail(function(error){
$scope.data.traceResults = "";
$scope.data.traceError = JSON.stringify(error);
$scope.$apply();
});
}
}
$scope.onPingTest = function(){
$scope.data.pingResults = "...";
$scope.data.error = "";
$rpc.luci2.network.ping({ data: $scope.data.pingHost }).done(function(result){
if(result.stderr) $scope.data.pingError = result.stderr;
$scope.data.pingResults = result.stdout;
$scope.$apply();
}).fail(function(error){
$scope.data.pingResults = "";
$scope.data.pingError = JSON.stringify(error);
$scope.$apply();
});
}
});

View file

@ -1,5 +1,12 @@
<luci-layout-with-sidebar>
<div ng-controller="StatusRestartPageCtrl">
Restart
<luci-config-section>
<luci-config-heading>{{ 'EasyBox' | translate }}</luci-config-heading>
<luci-config-lines>
<luci-config-line title="{{'Click here to restart your device'|translate}}">
<button class="btn btn-lg btn-default" ng-click="onRestart()">Restart</button>
</luci-config-line>
</luci-config-lines>
</luci-config-section>
</div>
</luci-layout-with-sidebar>

View file

@ -1,4 +1,8 @@
$juci.module("status")
.controller("StatusRestartPageCtrl", function($scope){
.controller("StatusRestartPageCtrl", function($scope, $rpc){
$scope.onRestart = function(){
$rpc.luci2.system.reboot().done(function(){
console.log("Restarting the system...");
});
}
});

View file

@ -1,11 +1,7 @@
$juci.module("status")
.controller("StatsCtrl", function($scope, $rpc, $session, gettextCatalog){
.controller("StatsCtrl", function($scope, $rpc, $session, gettext, $tr){
$scope.dslstats = {};
function $tr(str){
return gettextCatalog.getString(str);
}
$scope.dslConnectionInfo = {
title: "test",
rows: [[$tr("None"), $tr("None")]]
@ -75,12 +71,23 @@ $juci.module("status")
[ dslstats.mode, dslstats.mode_details ]
];
$scope.dslStatusInfo.rows = [
[ $tr('Line Status'), dslstats.line_status_configured, dslstats.line_status ],
[ $tr('Line Type'), dslstats.line_type_configured, dslstats.line_type ]
]
$scope.dslStatusInfo.rows = [
[ $tr('Actual Data Rate'), dslstats.bearers[0].rate_down, dslstats.bearers[0].rate_up ]
]
[ $tr(gettext('Line Status')), dslstats.line_status_configured, dslstats.line_status ],
[ $tr(gettext('Line Type')), dslstats.line_type_configured, dslstats.line_type ]
];
$scope.dslRateInfo.rows = [
[ $tr(gettext('Actual Data Rate')), dslstats.bearers[0].rate_down, dslstats.bearers[0].rate_up ]
];
$scope.dslOpInfo.rows = [
[ $tr(gettext('SNR Margin')), dslstats.snr_down, dslstats.snr_up ],
[ $tr(gettext('Loop Attenuation')), dslstats.attn_down, dslstats.attn_up ]
];
$scope.dslErrorInfo.rows = [
[ $tr(gettext('FEC Corrections')), dslstats.counters.totals.fec_down, dslstats.counters.totals.fec_up ],
[ $tr(gettext('CRC Errors')), dslstats.counters.totals.crc_down, dslstats.counters.totals.crc_up ]
];
$scope.dslCellInfo.rows = [
[ $tr(gettext('Cell Counter')), dslstats.bearers[0].total_cells_down, dslstats.bearers[0].total_cells_up ]
];
$scope.dslstats = dslstats;
$scope.$apply();
});

View file

@ -7,6 +7,7 @@ $juci.module("status")
if(data.sip[k].ip) accounts.push(data.sip[k]);
});
$scope.sipAccounts = accounts;
$scope.$apply();
}
});
});

View file

@ -27,7 +27,8 @@ $juci.module("wifi")
window.uci = $uci;
$scope.interfaces = $uci.wireless['@wifi-iface'];
$scope.status = $uci.wireless.status;
$scope.easybox = $uci.easybox.settings;
if($uci.easybox)
$scope.easybox = $uci.easybox.settings;
$scope.$apply();
next();

View file

@ -21,7 +21,7 @@
<switch id="enabled" name="enabled" ng-model="easybox.settings.wifibutton.value" class="green" ></switch>
</luci-config-line>
<luci-config-line title="{{'Pair (within 2 minutes)'|translate}}">
<button class="btn btn-default" ng-click="onPairPBC()" translate>Pair</button>
<button class="btn btn-default col-xs-12" ng-click="onPairPBC()" translate>Pair</button>
</luci-config-line>
</luci-config-lines>
<h2 translate>WPS with own PIN</h2>

View file

@ -153,7 +153,19 @@ h1, h2 {
}
.footer {
margin-top: 1000px;
margin-top: 0px;
}
@media screen and ( min-width: 600px ){
.dynheight {
min-height: 768px;
}
}
@media screen and ( max-width: 600px ){
.footer {
margin-top: 100px;
}
}
.animate-show {

View file

@ -1,6 +1,6 @@
<luci-top-bar></luci-top-bar>
<div>
<div class="container" role="main" style="min-height: 1000px;">
<div class="container dynheight" role="main" >
<div class="row">
<div class="col-xs-1"></div>
<div class="col-xs-10">
@ -20,11 +20,5 @@
<div class="col-xs-1"></div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12">
<luci-footer></luci-footer>
</div>
</div>
</div>
<luci-footer></luci-footer>
</div>

View file

@ -1,6 +1,6 @@
<luci-top-bar></luci-top-bar>
<div>
<div class="luci-content container" role="main" style="min-height: 1000px;">
<div class="luci-content container dynheight" role="main" >
<div class="row">
<div class="col-xs-1"></div>
<div class="col-xs-10">
@ -36,11 +36,5 @@
</div>
</div>-->
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<luci-footer></luci-footer>
</div>
</div>
</div>
<luci-footer></luci-footer>
</div>

View file

@ -108,7 +108,17 @@
"read": {
"ubus": {
"luci2.system": [
"sshkeys_get"
"sshkeys_get",
"upgrade_test",
"upgrade_clean",
"upgrade_start"
],
"asterisk": [
"status"
],
"asterisk.call_log": [
"list"
],
"wps": [
"genpin",
@ -116,12 +126,19 @@
"pbc",
"showpin",
"stapin"
],
"router": [
"networks"
],
"network.interface": [
"dump"
]
},
"uci": [
"dropbear",
"easybox",
"hosts"
"hosts",
"voice_client"
]
},
"write": {
@ -130,6 +147,9 @@
"sshkeys_set",
"password_set"
],
"asterisk.call_log": [
"list"
],
"wps": [
"genpin",
"setpin",

View file

@ -1065,55 +1065,24 @@ rpc_luci2_upgrade_start(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
const char *fwpath = "/tmp/firmware.bin";
//const char *keep = "";
bool found = false;
struct blob_attr *tb[__RPC_BACKUP_MAX];
blobmsg_parse(rpc_backup_policy, __RPC_BACKUP_MAX, tb,
blob_data(msg), blob_len(msg));
struct blob_attr *filename = tb[RPC_BACKUP_PASSWORD];
if (filename && blobmsg_data_len(filename) > 0 && blobmsg_data(filename) && strlen(blobmsg_data(filename)) > 0){
const char *cmd[] = { "sysupgrade", blobmsg_data(filename), NULL };
struct blob_attr *tb[__RPC_UPGRADE_MAX];
blobmsg_parse(rpc_upgrade_policy, __RPC_UPGRADE_MAX, tb, blob_data(msg), blob_len(msg));
return ops->exec(cmd, NULL, NULL, NULL, NULL, NULL, ctx, req);
}
const char *cmd[] = { "sysupgrade", "/tmp/firmware.bin", NULL };
if (tb[RPC_UPGRADE_PATH] && strlen(blobmsg_data(tb[RPC_UPGRADE_PATH]))) {
fwpath = strdup(blobmsg_data(tb[RPC_UPGRADE_PATH]));
found = true;
}
/* if (tb[RPC_UPGRADE_KEEP] && !blobmsg_data(tb[RPC_UPGRADE_KEEP]))*/
/* keep = "-n";*/
struct uci_package *p;
struct uci_element *e;
struct uci_section *s;
struct uci_ptr ptr = { .package = "system" };
if (!found)
uci_load(cursor, ptr.package, &p);
if (p)
{
uci_foreach_element(&p->sections, e)
{
s = uci_to_section(e);
if (strcmp(s->type, "upgrade"))
continue;
ptr.o = NULL;
ptr.option = "fw_upload_path";
ptr.section = e->name;
uci_lookup_ptr(cursor, &ptr, NULL, true);
break;
}
if (ptr.o && ptr.o->type == UCI_TYPE_STRING)
{
fwpath = strdup(ptr.o->v.string);
}
uci_unload(cursor, p);
}
const char *cmd[3] = { "sysupgrade", fwpath, NULL };
return ops->exec(cmd, NULL, NULL, NULL, NULL, NULL, ctx, req);
return 0;
}
static int

View file

@ -42,7 +42,8 @@ int igmp_rpc(struct ubus_context *ctx, struct ubus_object *obj,
void *object, *array;
blob_buf_init(&bb, 0);
if (!(in = fopen("/proc/net/igmp_snooping", "r")))
// /proc/net/
if (!(in = fopen("/tmp/igmp_snooping", "r")))
return 1;
array = blobmsg_open_array(&bb, "tables");