2016-07-06 22:52:31 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('ffhb')
|
|
|
|
.controller('NodesGroupCtrl',function(NgTableParams,$scope,store){
|
2016-07-13 20:47:26 +02:00
|
|
|
$scope.sum = {
|
|
|
|
all: 0,
|
|
|
|
online: 0,
|
|
|
|
client24: 0,
|
|
|
|
client5: 0
|
|
|
|
};
|
2016-07-06 22:52:31 +02:00
|
|
|
$scope.tableParams = new NgTableParams({
|
2016-07-12 18:29:02 +02:00
|
|
|
sorting: { 'nodeinfo.hostname': 'asc' },
|
2016-07-06 22:52:31 +02:00
|
|
|
group: 'nodeinfo.owner.contact',
|
|
|
|
total: 0,
|
2016-07-12 18:29:02 +02:00
|
|
|
count: 100
|
2016-07-06 22:52:31 +02:00
|
|
|
}, {
|
2016-07-13 11:43:27 +02:00
|
|
|
dataset: [{}]
|
2016-07-06 22:52:31 +02:00
|
|
|
});
|
2016-07-09 10:15:03 +02:00
|
|
|
var originalData = {};
|
|
|
|
$scope.cancel = function(row, rowForm) {
|
|
|
|
console.log('cancel',row,rowForm);
|
|
|
|
row.isEditing = false;
|
2016-07-12 08:44:38 +02:00
|
|
|
rowForm.$setPristine();
|
|
|
|
originalData[row.nodeid] = angular.copy(row);
|
2016-07-09 10:15:03 +02:00
|
|
|
};
|
|
|
|
$scope.save = function(row, rowForm) {
|
|
|
|
console.log('save',row,rowForm);
|
|
|
|
row.isEditing = false;
|
2016-07-12 08:44:38 +02:00
|
|
|
rowForm.$setPristine();
|
|
|
|
row = angular.copy(originalData[row.nodeid]);
|
2016-07-09 10:15:03 +02:00
|
|
|
store.saveNode(row.nodeid);
|
|
|
|
};
|
|
|
|
|
2016-07-06 22:52:31 +02:00
|
|
|
function render(prom){
|
|
|
|
prom.then(function(data){
|
2016-07-13 20:47:26 +02:00
|
|
|
$scope.sum = {
|
|
|
|
all: data.nodesCount,
|
|
|
|
online: 0,
|
|
|
|
client24: 0,
|
|
|
|
client5: 0
|
|
|
|
};
|
|
|
|
originalData = Object.keys(data.merged).map(function(nodeid){
|
|
|
|
var merg = data.merged[nodeid];
|
|
|
|
merg.nodeid = nodeid;
|
|
|
|
if(merg.flags.online){
|
|
|
|
$scope.sum.online++;
|
|
|
|
}
|
|
|
|
if(merg.statistics !== undefined && merg.statistics.clients !== undefined){
|
|
|
|
$scope.sum.client24 += merg.statistics.clients.wifi24;
|
|
|
|
$scope.sum.client5 += merg.statistics.clients.wifi5;
|
|
|
|
}
|
|
|
|
return merg;
|
2016-07-06 22:52:31 +02:00
|
|
|
});
|
2016-07-13 20:47:26 +02:00
|
|
|
$scope.tableParams.settings({dataset: angular.copy(originalData),total: data.nodesCount});
|
2016-07-06 22:52:31 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
render(store.getData);
|
|
|
|
$scope.$on('store', function(ev, prom) {
|
|
|
|
render(prom);
|
|
|
|
});
|
|
|
|
});
|