fix tables
This commit is contained in:
parent
5f10149b2a
commit
b768f442cb
|
@ -3,7 +3,13 @@
|
||||||
.page-header
|
.page-header
|
||||||
h1 {{node.nodeinfo.hostname}}
|
h1 {{node.nodeinfo.hostname}}
|
||||||
small {{nodeid}}
|
small {{nodeid}}
|
||||||
|
|
||||||
form(name="rowForm",ng-submit="save()")
|
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' : ''")
|
.form-group(ng-class="rowForm.group.$invalid ? 'has-error' : ''")
|
||||||
label(for="formGroup") Group
|
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')
|
input.form-control(id="formGroup",placeholder="Group",type="text",name="group",pattern="[a-zA-Z0-9-]*",ng-model='node.nodeinfo.owner.contact')
|
||||||
|
|
|
@ -11,24 +11,17 @@ angular.module('ffhb')
|
||||||
dataset: []
|
dataset: []
|
||||||
});
|
});
|
||||||
var originalData = {};
|
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) {
|
$scope.cancel = function(row, rowForm) {
|
||||||
console.log('cancel',row,rowForm);
|
console.log('cancel',row,rowForm);
|
||||||
row.isEditing = false;
|
row.isEditing = false;
|
||||||
var originalRow = resetRow(row, rowForm);
|
rowForm.$setPristine();
|
||||||
angular.extend(row, originalRow);
|
originalData[row.nodeid] = angular.copy(row);
|
||||||
};
|
};
|
||||||
$scope.save = function(row, rowForm) {
|
$scope.save = function(row, rowForm) {
|
||||||
console.log('save',row,rowForm);
|
console.log('save',row,rowForm);
|
||||||
row.isEditing = false;
|
row.isEditing = false;
|
||||||
var originalRow = resetRow(row, rowForm);
|
rowForm.$setPristine();
|
||||||
angular.extend(originalRow, row);
|
row = angular.copy(originalData[row.nodeid]);
|
||||||
store.saveNode(row.nodeid);
|
store.saveNode(row.nodeid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,35 +10,33 @@ angular.module('ffhb')
|
||||||
dataset: []
|
dataset: []
|
||||||
});
|
});
|
||||||
var originalData = {};
|
var originalData = {};
|
||||||
function resetRow(row, rowForm){
|
function find(nodeid){
|
||||||
row.isEditing = false;
|
var node = originalData.filter(function(row){
|
||||||
rowForm.$setPristine();
|
return row.nodeid === nodeid;
|
||||||
return _.findWhere(originalData, function(r){
|
|
||||||
return r.id === row.id;
|
|
||||||
});
|
});
|
||||||
|
return node[0];
|
||||||
}
|
}
|
||||||
$scope.cancel = function(row, rowForm) {
|
$scope.cancel = function(row, rowForm) {
|
||||||
console.log('cancel',row,rowForm);
|
console.log('cancel',row);
|
||||||
row.isEditing = false;
|
row.isEditing = false;
|
||||||
var originalRow = resetRow(row, rowForm);
|
rowForm.$setPristine();
|
||||||
angular.extend(row, originalRow);
|
angular.copy(find(row.nodeid),row);
|
||||||
};
|
};
|
||||||
$scope.save = function(row, rowForm) {
|
$scope.save = function(row, rowForm) {
|
||||||
console.log('save',row,rowForm);
|
console.log('save',row);
|
||||||
row.isEditing = false;
|
row.isEditing = false;
|
||||||
var originalRow = resetRow(row, rowForm);
|
rowForm.$setPristine();
|
||||||
angular.extend(originalRow, row);
|
angular.copy(row,find(row.nodeid));
|
||||||
store.saveNode(row.nodeid);
|
store.saveNode(row.nodeid);
|
||||||
};
|
};
|
||||||
|
|
||||||
function render(prom){
|
function render(prom){
|
||||||
prom.then(function(data){
|
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;
|
data.merged[nodeid].nodeid = nodeid;
|
||||||
return data.merged[nodeid];
|
return data.merged[nodeid];
|
||||||
});
|
});
|
||||||
originalData = result;
|
$scope.tableParams.settings({dataset: angular.copy(originalData),total: data.nodesCount});
|
||||||
$scope.tableParams.settings({dataset: angular.copy(result),total: data.nodesCount});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
render(store.getData);
|
render(store.getData);
|
||||||
|
|
|
@ -123,10 +123,10 @@ angular.module('ffhb')
|
||||||
}
|
}
|
||||||
if(node.nodeinfo.wireless){
|
if(node.nodeinfo.wireless){
|
||||||
obj.wireless = {
|
obj.wireless = {
|
||||||
'channel24': node.nodeinfo.wireless.channel24||0,
|
'channel24': parseInt(node.nodeinfo.wireless.channel24)||0,
|
||||||
'channel5': node.nodeinfo.wireless.channel5||0,
|
'channel5': parseInt(node.nodeinfo.wireless.channel5)||0,
|
||||||
'txpower24': node.nodeinfo.wireless.txpower24||0,
|
'txpower24': parseInt(node.nodeinfo.wireless.txpower24)||0,
|
||||||
'txpower5': node.nodeinfo.wireless.txpower5||0
|
'txpower5': parseInt(node.nodeinfo.wireless.txpower5)||0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
$http.post(config.api+'/aliases/alias/'+nodeid,obj).then(function(){
|
$http.post(config.api+'/aliases/alias/'+nodeid,obj).then(function(){
|
||||||
|
|
Loading…
Reference in New Issue