try sorting + cookie to localstorage

This commit is contained in:
Martin Geno 2016-07-13 11:43:27 +02:00
parent 62c2c86868
commit eaac3aab9c
8 changed files with 60 additions and 13 deletions

View File

@ -25,6 +25,7 @@
"ui-leaflet": "^1.0.1",
"angular-cookies": "^1.5.7",
"Leaflet.label": "^0.2.1",
"lodash": "^4.13.1"
"lodash": "^4.13.1",
"angularLocalStorage": "^0.3.2"
}
}

View File

@ -3,7 +3,7 @@
angular.module('ffhb', [
'ngTable',
'ngResource',
'ngCookies',
'angularLocalStorage',
'ui.router',
'ui.bootstrap',
'ui-leaflet',

View File

@ -2,7 +2,7 @@
angular.module('ffhb')
.controller('NodeCtrl',function($stateParams,$scope,store,config,leafletData){
$scope.nodeid = $stateParams.nodeid;
$scope.nodeid = $stateParams.nodeid.toLowerCase();
$scope.loadingGPS = false;
$scope.node = {};
angular.extend($scope, {
@ -14,7 +14,7 @@ angular.module('ffhb')
title: 'Marker',
draggable: true,
label: {
message: 'Node:'+$stateParams.nodeid,
message: 'Node:'+$scope.nodeid,
options: {
noHide: true
}
@ -29,7 +29,7 @@ angular.module('ffhb')
});
function render(prom){
prom.then(function(data){
$scope.node = data.merged[$stateParams.nodeid];
$scope.node = data.merged[$scope.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;
@ -47,7 +47,7 @@ angular.module('ffhb')
'latitude': args.model.lat,
'longitude': args.model.lng
};
store.saveNode($stateParams.nodeid);
store.saveNode($scope.nodeid);
}
});
var setToGps = function(position){
@ -61,7 +61,7 @@ angular.module('ffhb')
leafletData.getMap().then(function(map) {
map.setView(pos);
});
store.saveNode($stateParams.nodeid);
store.saveNode($scope.nodeid);
$scope.markers.node.lat = position.coords.latitude;
$scope.markers.node.lng = position.coords.longitude;
}

View File

@ -34,7 +34,7 @@ table.table.table-striped.table-condensed( ng-table="tableParams")
span(ng-switch-default) {{row.nodeinfo.wireless.txpower24}}
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)
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' : ''")
input.editable-input.form-control.input-sm(type="text" name="txpower5",ng-model='row.nodeinfo.wireless.txpower5',required)
td(data-title="'Options'")

View File

@ -8,7 +8,7 @@ angular.module('ffhb')
total: 0,
count: 100
}, {
dataset: []
dataset: [{}]
});
var originalData = {};
$scope.cancel = function(row, rowForm) {

View File

@ -7,7 +7,52 @@ angular.module('ffhb')
total: 0,
count: 100
}, {
dataset: []
dataset: [{
lastseen: new Date(),
firstseen: new Date(),
nodeid: 'loading',
nodeinfo: {
hostname: 'loading',
owner: {
contact: 'loading'
},
wireless: {
channel24: 0,
channel5: 0,
txpower24: 0,
txpower5: 0
}
},
statistics: {
clients: {
wifi24: 0,
wifi5: 0
}
}
},
{
lastseen: new Date(),
firstseen: new Date(),
nodeid: 'loading',
nodeinfo: {
hostname: 'loading',
owner: {
contact: 'loading'
},
wireless: {
channel24: 0,
channel5: 0,
txpower24: 0,
txpower5: 0
}
},
statistics: {
clients: {
wifi24: 0,
wifi5: 0
}
}
}]
});
var originalData = {};
function find(nodeid){

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('ffhb')
.factory('store', function($state, $q, $http, $rootScope,config,$interval,$cookieStore,webNotification) {
.factory('store', function($state, $q, $http, $rootScope,config,$interval,storage,webNotification) {
function notifyNew(nodeid){
webNotification.showNotification('New Node',{
body: '"'+nodeid+'"',
@ -22,7 +22,7 @@ angular.module('ffhb')
var myservice = {};
myservice._initialized = false;
myservice._data = $cookieStore.get('data') ||{
myservice._data = storage.get('data') ||{
nodes: {},nodesCount:0,
merged: {},
aliases: {},aliasesCount:0
@ -96,7 +96,7 @@ angular.module('ffhb')
if (myservice._initialized) {
$rootScope.$broadcast('store', dataDeferred.promise);
}
$cookieStore.put('data',myservice._data);
storage.set('data',myservice._data);
myservice._initialized = true;
});
});

View File

@ -52,6 +52,7 @@
<script src="bower_components/ui-leaflet/dist/ui-leaflet.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/lodash/lodash.js"></script>
<script src="bower_components/angularLocalStorage/dist/angularLocalStorage.min.js"></script>
<!-- endbower -->
<script src="bower_components/Leaflet.label/dist/leaflet.label.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap.min.js"></script>