summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorArjun Roychowdhury <pliablepixels@gmail.com>2016-01-13 19:30:14 +0530
committerArjun Roychowdhury <pliablepixels@gmail.com>2016-01-13 19:30:14 +0530
commit73f08ac8d8f4d2995cac1eb5f58e9879c36f305f (patch)
tree017c14a516317389b8840f07af9860aab9f914b1 /www/js
parent9492a9d0fe53708ff39ed7c314a955591a2db888 (diff)
cleaned up server add interface - created an add button
Former-commit-id: 95e087a6a24c9a54bcfd2f81a0884877d7ec322d
Diffstat (limited to 'www/js')
-rw-r--r--www/js/DataModel.js10
-rw-r--r--www/js/LoginCtrl.js26
2 files changed, 32 insertions, 4 deletions
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]