From 73f08ac8d8f4d2995cac1eb5f58e9879c36f305f Mon Sep 17 00:00:00 2001 From: Arjun Roychowdhury Date: Wed, 13 Jan 2016 19:30:14 +0530 Subject: cleaned up server add interface - created an add button Former-commit-id: 95e087a6a24c9a54bcfd2f81a0884877d7ec322d --- www/js/DataModel.js | 10 +++++++++- www/js/LoginCtrl.js | 26 +++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'www/js') diff --git a/www/js/DataModel.js b/www/js/DataModel.js index c438e06a..a0ff20d9 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -66,6 +66,8 @@ angular.module('zmApp.controllers') }; + var defaultLoginData = angular.copy(loginData); + var configParams = { @@ -188,7 +190,13 @@ angular.module('zmApp.controllers') // the ZM authors fix this and streamline the access of images // from APIs, I don't have an option - // FIXME: Move all of this into a neat JSON object + + // used when an empty server profile is created + getDefaultLoginObject: function() + { + return defaultLoginData; + }, + init: function () { // console.log("****** DATAMODEL INIT SERVICE CALLED ********"); diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index 61ed53c0..4feb5da7 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -43,7 +43,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r availableServers = Object.keys(ZMDataModel.getServerGroups()); - serverbuttons = []; + serverbuttons = [{text:"Add..."}]; for (var servIter = 0; servIter < availableServers.length; servIter++) { serverbuttons.push({ text: availableServers[servIter] @@ -61,9 +61,20 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r // add cancel code.. }, buttonClicked: function (index) { - // console.log ("YOU WANT " + serverbuttons[index].text + " INDEX " + index); + //console.log ("YOU WANT " + serverbuttons[index].text + " INDEX " + index); + + if (serverbuttons[index].text == 'Add...') + { + + $scope.loginData = angular.copy(ZMDataModel.getDefaultLoginObject()); + return true; + } + var zmServers = ZMDataModel.getServerGroups(); $scope.loginData = zmServers[serverbuttons[index].text]; + + + $scope.check.isUseAuth = ($scope.loginData.isUseAuth == '1') ? true : false; $scope.check.isUseEventServer = ($scope.loginData.isUseEventServer == '1') ? true : false; @@ -80,6 +91,15 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r }, destructiveButtonClicked: function () { + + + if (!$scope.loginData.serverName) + { + ZMDataModel.zmDebug("cannot delete empty entry"); + return true; + + + } var zmServers = ZMDataModel.getServerGroups(); //console.log ("YOU WANT TO DELETE " + $scope.loginData.serverName); //console.log ("LENGTH OF SERVERS IS " + Object.keys(zmServers).length); @@ -94,7 +114,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r ZMDataModel.setLogin($scope.loginData); availableServers = Object.keys(ZMDataModel.getServerGroups()); - serverbuttons = []; + serverbuttons = [{text:'Add...'}]; for (var servIter = 0; servIter < availableServers.length; servIter++) { serverbuttons.push({ text: availableServers[servIter] -- cgit v1.2.3