fix tables

This commit is contained in:
Martin Geno 2016-07-12 08:44:38 +02:00
parent 5f10149b2a
commit b768f442cb
4 changed files with 26 additions and 29 deletions

View File

@ -3,7 +3,13 @@
.page-header
h1 {{node.nodeinfo.hostname}}
small {{nodeid}}
form(name="rowForm",ng-submit="save()")
.form-group
label Online
p.form-control-static
span.glyphicon(ng-class="{'glyphicon-ok':node.flags.online,'glyphicon-remove':!node.flags.online}")
span(am-time-ago="node.lastseen")
.form-group(ng-class="rowForm.group.$invalid ? 'has-error' : ''")
label(for="formGroup") Group
input.form-control(id="formGroup",placeholder="Group",type="text",name="group",pattern="[a-zA-Z0-9-]*",ng-model='node.nodeinfo.owner.contact')

View File

@ -11,24 +11,17 @@ angular.module('ffhb')
dataset: []
});
var originalData = {};
function resetRow(row, rowForm){
row.isEditing = false;
rowForm.$setPristine();
return _.findWhere(originalData, function(r){
return r.id === row.id;
});
}
$scope.cancel = function(row, rowForm) {
console.log('cancel',row,rowForm);
row.isEditing = false;
var originalRow = resetRow(row, rowForm);
angular.extend(row, originalRow);
rowForm.$setPristine();
originalData[row.nodeid] = angular.copy(row);
};
$scope.save = function(row, rowForm) {
console.log('save',row,rowForm);
row.isEditing = false;
var originalRow = resetRow(row, rowForm);
angular.extend(originalRow, row);
rowForm.$setPristine();
row = angular.copy(originalData[row.nodeid]);
store.saveNode(row.nodeid);
};

View File

@ -10,35 +10,33 @@ angular.module('ffhb')
dataset: []
});
var originalData = {};
function resetRow(row, rowForm){
row.isEditing = false;
rowForm.$setPristine();
return _.findWhere(originalData, function(r){
return r.id === row.id;
function find(nodeid){
var node = originalData.filter(function(row){
return row.nodeid === nodeid;
});
return node[0];
}
$scope.cancel = function(row, rowForm) {
console.log('cancel',row,rowForm);
console.log('cancel',row);
row.isEditing = false;
var originalRow = resetRow(row, rowForm);
angular.extend(row, originalRow);
rowForm.$setPristine();
angular.copy(find(row.nodeid),row);
};
$scope.save = function(row, rowForm) {
console.log('save',row,rowForm);
console.log('save',row);
row.isEditing = false;
var originalRow = resetRow(row, rowForm);
angular.extend(originalRow, row);
rowForm.$setPristine();
angular.copy(row,find(row.nodeid));
store.saveNode(row.nodeid);
};
function render(prom){
prom.then(function(data){
var result = Object.keys(data.merged).map(function(nodeid){
originalData = Object.keys(data.merged).map(function(nodeid){
data.merged[nodeid].nodeid = nodeid;
return data.merged[nodeid];
});
originalData = result;
$scope.tableParams.settings({dataset: angular.copy(result),total: data.nodesCount});
$scope.tableParams.settings({dataset: angular.copy(originalData),total: data.nodesCount});
});
}
render(store.getData);

View File

@ -123,10 +123,10 @@ angular.module('ffhb')
}
if(node.nodeinfo.wireless){
obj.wireless = {
'channel24': node.nodeinfo.wireless.channel24||0,
'channel5': node.nodeinfo.wireless.channel5||0,
'txpower24': node.nodeinfo.wireless.txpower24||0,
'txpower5': node.nodeinfo.wireless.txpower5||0
'channel24': parseInt(node.nodeinfo.wireless.channel24)||0,
'channel5': parseInt(node.nodeinfo.wireless.channel5)||0,
'txpower24': parseInt(node.nodeinfo.wireless.txpower24)||0,
'txpower5': parseInt(node.nodeinfo.wireless.txpower5)||0
};
}
$http.post(config.api+'/aliases/alias/'+nodeid,obj).then(function(){