From 0cbc9dffbb56871a951d4cf63181867695c8f550 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Tue, 14 Mar 2017 22:40:28 +0000 Subject: [PATCH] index on AddUserGroups-#59: 1e01271 add doctype tag. --- .../WindowsDataCenter/www/Admin.html | 76 +++++++++++++++++++ .../WindowsDataCenter/www/Helpers.js | 35 +++++++++ .../WindowsDataCenter/www/admin.js | 58 ++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Admin.html create mode 100644 DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Helpers.js create mode 100644 DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/admin.js diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Admin.html b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Admin.html new file mode 100644 index 0000000..652d594 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Admin.html @@ -0,0 +1,76 @@ + + + + + + Flexitime Admin page + + + + + + + + + + +
+

Groups

+
+
+ + + + + + + + + + + + + + +
NameUser Count
+
+
+ +
+ + +
+ + + +
+
+
+ + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Helpers.js b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Helpers.js new file mode 100644 index 0000000..1a5df4b --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Helpers.js @@ -0,0 +1,35 @@ +function Helpers() { + var self = this; + /** + * Create a request URL - references apiEndpoints object to construct url with args, and optional callback url. + * @param {string} routePath + * @param {Array} params - Key, Value object detailing the param name (key) and value (value). + * @param {boolean} requiresCallback - True - add callback function for JSONP/CORS. + * @param {boolean} isAbsolutePath - True, create a relative URL (without root). + * @returns {string} the url generated + * @example + * createRequestUrl("/api/endpoint", [{key:"param", value:"value"}], true, false); + * returns: "http://192.168.2.2/api/endpoint?param=value&callback=?" + */ + self.createRequestUrl = function (routePath, params, requiresCallback, isAbsoluteUrl) { + var appender = "?"; + var url = ""; + if (isAbsoluteUrl) { + url = self.apiEndpoints.root; + } + url = url + routePath; + if (params !== undefined + && params !== null) { + if (params.length > 0) { + for (var i = 0; i < params.length; i++) { + url += appender + params[i].key + "=" + params[i].value; + appender = "&"; + } + } + } + if (requiresCallback) { + url += appender + "callback=?"; + } + return url; + }; +}; \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/admin.js b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/admin.js new file mode 100644 index 0000000..9a5eeb0 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/admin.js @@ -0,0 +1,58 @@ +function AdminVM() { + var self = this; + self.groupsList = ko.observable(null); + self.groupEditItem = ko.observable({Id:-1,Name:""}); + self.helpers = new Helpers(); + self.uiPages = { + overview: "overview", + home: function () { return this.overview; } + }; + self.apiEndpoints = { + getGroups:"/api/groups" + }; + self.clearGroupForm = function(data, event) { + self.groupEditItem({ Id: -1, Name: "" }); + }; + self.editGroupClick = function(data, event) { + self.groupEditItem(data); + }; + self.getGroups = function () { + var url = self.helpers.createRequestUrl(self.apiEndpoints.getGroups, null, false); + $.getJSON(url, function (res) { + self.groupsList(res); + console.log(res); + }).fail(function (resp, status, error) { + console.log("error - getGroups"); + //var errObj = self.processRequestFailure(resp, status, error); + //self.assignErrorObject(errObj.errorCode, errObj.errorMessage, "getGroups"); + //self.goToMenuOption(self.uiPages.home()); + }); + }; + Sammy(function () { + this.get("#overview", function () { + self.getGroups(); + }); + this.post("#editgroup", function () { + + return false; + }); + this.post("#edituser", function () { + $.each(self.chosenUserDetails().AssociatedIdentifiers, + function (k, v) { + if (v.IsAssociatedToUser !== true) { + self.chosenUserDetails().AssociatedIdentifiers.splice(k, 1); + } + }); + $.each(self.unassignedCardData().data, function (k, v) { + if (v.IsAssociatedToUser === true) { + self.chosenUserDetails().AssociatedIdentifiers.push(v); + } + }); + self.submitChangedUser(self.chosenUserDetails()); + return false; + }); + //default route (home page) + this.get("", function () { this.app.runRoute("get", "#" + self.uiPages.home()) }); + }).run(); +}; +ko.applyBindings(new AdminVM()); \ No newline at end of file