a lot things (node/qrcode-view ready, bug in passphrase + node-tables)

This commit is contained in:
Martin Geno 2016-07-11 10:06:12 +02:00
parent cd19a507cb
commit 9a0c180b37
6 changed files with 52 additions and 17 deletions

View File

@ -21,6 +21,7 @@ angular.module('ffhb', [
amMoment.changeLocale('de'); amMoment.changeLocale('de');
$rootScope.globals = $cookieStore.get('globals') || {}; $rootScope.globals = $cookieStore.get('globals') || {};
if ($rootScope.globals.currentUser) { if ($rootScope.globals.currentUser) {
$rootScope.passphrase = '*****';
$http.defaults.headers.common['Authorization'] = 'Basic ' + $rootScope.globals.currentUser.authdata; // jshint ignore:line $http.defaults.headers.common['Authorization'] = 'Basic ' + $rootScope.globals.currentUser.authdata; // jshint ignore:line
} }
}); });

View File

@ -3,6 +3,7 @@
table.table.table-striped.table-condensed( ng-table="tableParams") table.table.table-striped.table-condensed( ng-table="tableParams")
tr(ng-repeat='row in $data',demo-tracked-table-row="row") tr(ng-repeat='row in $data',demo-tracked-table-row="row")
td(data-title="'Nodeid'", sortable="'row.nodeid'", filter="{'nodeid': 'text'}") {{row.nodeid}} td(data-title="'Nodeid'", sortable="'row.nodeid'", filter="{'nodeid': 'text'}") {{row.nodeid}}
td(data-title="'Group'", sortable="'row.owner'", filter="{'owner': 'text'}") {{row.owner}}
td(data-title="'Hostname'", sortable="'row.hostname'", filter="{'hostname': 'text'}") {{row.hostname}} td(data-title="'Hostname'", sortable="'row.hostname'", filter="{'hostname': 'text'}") {{row.hostname}}
td.split.text-right(data-title="'Freq'") td.split.text-right(data-title="'Freq'")
span 2.4 Ghz span 2.4 Ghz

View File

@ -1,11 +1,13 @@
'use strict'; 'use strict';
angular.module('ffhb') angular.module('ffhb')
.controller('MainCtrl',function($scope,$interval,store,$state,AuthenticationService){ .controller('MainCtrl',function($rootScope,$scope,$interval,store,$state,AuthenticationService){
$scope.isOpen = false; $scope.isOpen = false;
$scope.$state = $state; $scope.$state = $state;
$scope.refresh = store.refresh; $scope.refresh = store.refresh;
$scope.passphrase = ''; if($rootScope.passphrase === undefined){
$rootScope.passphrase = '';
}
var timediff = new Date(1970,1,1); var timediff = new Date(1970,1,1);
function render(prom){ function render(prom){
@ -28,6 +30,9 @@ angular.module('ffhb')
$scope.passphraseUpdate = function(){ $scope.passphraseUpdate = function(){
AuthenticationService.SetCredentials('client',$scope.passphrase); if($rootScope.passphrase !== undefined && $rootScope.passphrase !== '' && $rootScope.passphrase !== '*****'){
console.log("set new basicauth");
AuthenticationService.SetCredentials('client',$rootScope.passphrase);
}
}; };
}); });

View File

@ -29,6 +29,10 @@ angular.module('ffhb')
function render(prom){ function render(prom){
prom.then(function(data){ prom.then(function(data){
$scope.node = data.merged[$stateParams.nodeid]; $scope.node = data.merged[$stateParams.nodeid];
if($scope.node !== undefined && $scope.node.nodeinfo !== undefined){
$scope.markers.node.lat = $scope.node.nodeinfo.location.latitude;
$scope.markers.node.lng = $scope.node.nodeinfo.location.longitude;
}
}); });
} }
render(store.getData); render(store.getData);
@ -37,22 +41,27 @@ angular.module('ffhb')
}); });
$scope.$on('leafletDirectiveMarker.dragend', function(event, args){ $scope.$on('leafletDirectiveMarker.dragend', function(event, args){
if($scope.node !== undefined && $scope.node.nodeinfo !== undefined && $scope.node.nodeinfo.location !== undefined){ if($scope.node !== undefined && $scope.node.nodeinfo !== undefined){
$scope.node.nodeinfo.location.latitude = args.model.lat; $scope.node.nodeinfo.location = {
$scope.node.nodeinfo.location.latitude = args.model.lng; 'latitude': args.model.lat,
'longitude': args.model.lng
};
store.saveNode($stateParams.nodeid); store.saveNode($stateParams.nodeid);
} }
}); });
var setToGps = function(position){ var setToGps = function(position){
var pos = [position.coords.latitude,position.coords.longitude]; var pos = [position.coords.latitude,position.coords.longitude];
console.log('gps',pos); if($scope.node !== undefined && $scope.node.nodeinfo !== undefined){
if($scope.node !== undefined && $scope.node.nodeinfo !== undefined && $scope.node.nodeinfo.location !== undefined){ $scope.node.nodeinfo.location = {
$scope.node.nodeinfo.location.latitude = position.coords.latitude; 'latitude': position.coords.latitude,
$scope.node.nodeinfo.location.longitude = position.coords.longitude; 'longitude': position.coords.longitude
};
leafletData.getMap().then(function(map) { leafletData.getMap().then(function(map) {
map.setView(pos); map.setView(pos);
}); });
store.saveNode($stateParams.nodeid); store.saveNode($stateParams.nodeid);
$scope.markers.node.lat = position.coords.latitude;
$scope.markers.node.lng = position.coords.longitude;
} }
}; };
$scope.gps = function() { $scope.gps = function() {

View File

@ -28,7 +28,7 @@ table.table.table-striped.table-condensed( ng-table="tableParams")
span(ng-switch-default) {{row.nodeinfo.wireless.txpower24}} span(ng-switch-default) {{row.nodeinfo.wireless.txpower24}}
div.controls(ng-switch-when="true",ng-class="rowForm.txpower24.$invalid ? 'has-error' : ''") div.controls(ng-switch-when="true",ng-class="rowForm.txpower24.$invalid ? 'has-error' : ''")
input.editable-input.form-control.input-sm(type="text" name="txpower24",ng-model='row.nodeinfo.wireless.txpower24',required) input.editable-input.form-control.input-sm(type="text" name="txpower24",ng-model='row.nodeinfo.wireless.txpower24',required)
span(ng-switch-default) {{row.nodeinfo.wireless.channel5}} span(ng-switch-default) {{row.nodeinfo.wireless.txpower5}}
div.controls(ng-switch-when="true",ng-class="rowForm.txpower5.$invalid ? 'has-error' : ''") div.controls(ng-switch-when="true",ng-class="rowForm.txpower5.$invalid ? 'has-error' : ''")
input.editable-input.form-control.input-sm(type="text" name="txpower5",ng-model='row.nodeinfo.wireless.txpower5',required) input.editable-input.form-control.input-sm(type="text" name="txpower5",ng-model='row.nodeinfo.wireless.txpower5',required)
td(data-title="'Options'") td(data-title="'Options'")

View File

@ -52,7 +52,7 @@ angular.module('ffhb')
} }
angular.copy(nodes, myservice._data.merged); angular.copy(nodes, myservice._data.merged);
Object.keys(aliases).map(function(key){ Object.keys(aliases).map(function(key){
var node = myservice._data.nodes[key], var node = myservice._data.merged[key],
alias = aliases[key]; alias = aliases[key];
node.nodeinfo.hostname = alias.hostname; node.nodeinfo.hostname = alias.hostname;
if(!node.nodeinfo.owner){ if(!node.nodeinfo.owner){
@ -108,13 +108,32 @@ angular.module('ffhb')
myservice.saveNode = function(nodeid){ myservice.saveNode = function(nodeid){
var result = $q.defer(); var result = $q.defer();
if(myservice._data.merged && myservice._data.merged[nodeid]){ if(myservice._data.merged && myservice._data.merged[nodeid]){
var node = myservice._data.merged[nodeid]; var node = myservice._data.merged[nodeid],
$http.post(config.api+'/aliases/alias/'+nodeid,{ obj = {
'hostname':node.nodeinfo.hostname, 'hostname':node.nodeinfo.hostname,
'owner':node.owner.contact 'owner':node.nodeinfo.owner.contact||'',
}).then(function(){ 'location': {},
'wireless': {}
};
if(node.nodeinfo.location){
obj.location = {
'latitude': node.nodeinfo.location.latitude||0,
'longitude': node.nodeinfo.location.longitude||0
};
}
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
};
}
$http.post(config.api+'/aliases/alias/'+nodeid,obj).then(function(){
result.resolve(true); result.resolve(true);
myservice.refresh(true); myservice.refresh(true);
},function(){
$rootScope.passphrase = '';
}); });
}else{ }else{
result.resolve(false); result.resolve(false);