diff options
| author | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-11-14 18:47:12 -0500 |
|---|---|---|
| committer | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-11-14 18:47:12 -0500 |
| commit | 0fd6a9966ae83fb9b5f08f8a398e786615ecd9d3 (patch) | |
| tree | 3d8dc35de0ee7dbdd1fae4541bfde125a42c2dc5 /www | |
| parent | a7240a7cbcdddacbd7d865d9ba10042a0acb886b (diff) | |
#83 - stuff mostly working - data switching is in place
Former-commit-id: b580fe5785166f667ca03193630516158f6a7f0f
Diffstat (limited to 'www')
| -rw-r--r-- | www/js/DataModel.js | 17 | ||||
| -rw-r--r-- | www/js/LoginCtrl.js | 71 | ||||
| -rw-r--r-- | www/templates/login.html | 2 |
3 files changed, 47 insertions, 43 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 024d5b55..e3333d43 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -103,16 +103,23 @@ angular.module('zmApp.controllers') loginData = newLogin; + + zmLog("Saving all parameters to storage"); zmDebug ("DataModel/setLogin: writing " + JSON.stringify(newLogin)); //$localstorage.setObject($rootScope.currentServerGroup, loginData); - serverGroupList[loginData.serverName]=loginData; - console.log (JSON.stringify(serverGroupList)); + console.log ("Saving For " + loginData.serverName); + console.log ("SERVER GROUP BEFORE IS " + JSON.stringify(serverGroupList)); + serverGroupList[loginData.serverName]=angular.copy(loginData); + + console.log ("SERVER GROUP AFTER IS " + JSON.stringify(serverGroupList)); + //console.log (JSON.stringify(serverGroupList)); $localstorage.setObject("serverGroupList", serverGroupList); $localstorage.set("defaultServerName",loginData.serverName); - + // console.log ("SAVING " + loginData.serverName); + // console.log ("DATA IS " + JSON.stringify(loginData)); } @@ -433,6 +440,10 @@ angular.module('zmApp.controllers') return loginData; }, + + getServerGroups: function() { + return serverGroupList; + }, getKeepAwake: function () { return (loginData.keepAwake == '1') ? true:false; diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index c5ba53c9..ec0c3939 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -7,6 +7,10 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r $ionicSideMenuDelegate.toggleLeft(); }; + + var serverbuttons = []; + var availableServers; + //---------------------------------------------------------------- // Alarm notification handling //---------------------------------------------------------------- @@ -27,50 +31,24 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r isUseAuth: "", isUseEventServer: "" }; + $scope.check.isUseAuth = ($scope.loginData.isUseAuth == '1') ? true : false; $scope.check.isUseEventServer = ($scope.loginData.isUseEventServer == '1') ? true : false; - + + console.log ("*************************************************"); + + + availableServers = Object.keys(ZMDataModel.getServerGroups()); + serverbuttons = []; + for (var servIter=0; servIter<availableServers.length; servIter++) + { + serverbuttons.push({text: availableServers[servIter]}); + console.log ("ADDING : "+availableServers[servIter]); + } $scope.serverActionSheet = function () { var hideSheet = $ionicActionSheet.show({ - buttons: [ - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - { - text: 'New Group...' - }, - - { - text: 'Rename' - }, - - - ], + buttons: serverbuttons, destructiveText: 'Delete', titleText: 'Manage Server Groups', cancelText: 'Cancel', @@ -78,6 +56,10 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r // add cancel code.. }, buttonClicked: function (index) { + console.log ("YOU WANT " + serverbuttons[index].text + " INDEX " + index); + var zmServers = ZMDataModel.getServerGroups(); + $scope.loginData = zmServers[serverbuttons[index].text]; + return true; } }); @@ -107,6 +89,9 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r $scope.$on('$ionicView.enter', function () { console.log("**VIEW ** LoginCtrl Entered"); ZMDataModel.setAwake(false); + + + }); @@ -366,6 +351,14 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r else { saveItems(); + availableServers = Object.keys(ZMDataModel.getServerGroups()); + serverbuttons = []; + for (var servIter=0; servIter<availableServers.length; servIter++) + { + serverbuttons.push({text: availableServers[servIter]}); + console.log ("ADDING : "+availableServers[servIter]); + } + } diff --git a/www/templates/login.html b/www/templates/login.html index 533f68f1..44fa57e7 100644 --- a/www/templates/login.html +++ b/www/templates/login.html @@ -1,4 +1,4 @@ -<ion-view view-title="Settings"> +<ion-view view-title="Settings" cache-view="false"> <ion-nav-buttons side="left"> <button class="button button-icon button-clear ion-navicon" ng-click="openMenu()"></button> |
