diff --git a/assets/css/other.css b/assets/css/other.css new file mode 100644 index 0000000..92d14c5 --- /dev/null +++ b/assets/css/other.css @@ -0,0 +1,9 @@ +/* +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#card-box .col { + padding: 15px; +} \ No newline at end of file diff --git a/cards/js/qwikclock_punchinout.js b/cards/js/qwikclock_punchinout.js new file mode 100644 index 0000000..26f3aea --- /dev/null +++ b/cards/js/qwikclock_punchinout.js @@ -0,0 +1,39 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +$(".card_qwikclock_punchinout").on("click", ".start_btn", function () { + var parent = $(this).parents(".card_app"); + var url = parent.data("apiurl"); + console.log(url + " " + getuser()); + $.post(url, { + username: getuser(), + password: getAPIKey(), + action: "punchin" + }, function (resp) { + if (resp.status == "OK") { + showmsg(resp.msg, "success"); + } else { + showmsg(resp.msg, "danger"); + } + }, "json"); +}); + +$(".card_qwikclock_punchinout").on("click", ".stop_btn", function () { + var parent = $(this).parents(".card_app"); + var url = parent.data("apiurl"); + console.log(url + " " + getuser()); + $.post(url, { + username: getuser(), + password: getAPIKey(), + action: "punchout" + }, function (resp) { + if (resp.status == "OK") { + showmsg(resp.msg, "success"); + } else { + showmsg(resp.msg, "danger"); + } + }, "json"); +}); \ No newline at end of file diff --git a/cards/js/taskfloor_viewmessages.js b/cards/js/taskfloor_viewmessages.js new file mode 100644 index 0000000..66549fe --- /dev/null +++ b/cards/js/taskfloor_viewmessages.js @@ -0,0 +1,31 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + + +$(".card_taskfloor_viewmessages").each(function () { + $(this).find(".card_title").append(" Messages"); + var msglist = $(this).find(".message-list"); + var url = $(this).data("apiurl"); + $.post(url, { + username: getuser(), + password: getAPIKey(), + action: "getmsgs" + }, function (resp) { + if (resp.status == "OK") { + var msgs = resp.messages; + for (var msg in msgs) { + msglist.append( + '
' + + '' + msgs[msg]['from']['name'] + ' ' + msgs[msg]['to']['name'] + '' + + '

' + msgs[msg]['text'] + '

' + + '' + msgs[msg]['sent'] + '' + + '
'); + } + } else { + showmsg(resp.msg, "danger"); + } + }, "json"); +}); \ No newline at end of file diff --git a/cards/js/taskfloor_viewtasks.js b/cards/js/taskfloor_viewtasks.js new file mode 100644 index 0000000..73354b5 --- /dev/null +++ b/cards/js/taskfloor_viewtasks.js @@ -0,0 +1,32 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + + +$(".card_taskfloor_viewtasks").each(function () { + $(this).find(".card_title").append(" Tasks"); + var tasklist = $(this).find(".task-list"); + var url = $(this).data("apiurl"); + $.post(url, { + username: getuser(), + password: getAPIKey(), + action: "gettasks" + }, function (resp) { + if (resp.status == "OK") { + var tasks = resp.tasks; + for (var i = 0; i < tasks.length; i++) { + tasklist.append( + '
' + + '
' + + '
' + tasks[i]['title'] + '
' + + '
' + + '

' + tasks[i]['description'] + '

' + + '
'); + } + } else { + showmsg(resp.msg, "danger"); + } + }, "json"); +}); \ No newline at end of file diff --git a/cards/qwikclock_punchinout.html b/cards/qwikclock_punchinout.html new file mode 100644 index 0000000..964f966 --- /dev/null +++ b/cards/qwikclock_punchinout.html @@ -0,0 +1,10 @@ + +

QwikClock

+
+ + +
\ No newline at end of file diff --git a/cards/taskfloor_viewmessages.html b/cards/taskfloor_viewmessages.html new file mode 100644 index 0000000..f5b68dd --- /dev/null +++ b/cards/taskfloor_viewmessages.html @@ -0,0 +1,10 @@ + +

TaskFloor Messages

+
+
+
+
\ No newline at end of file diff --git a/cards/taskfloor_viewtasks.html b/cards/taskfloor_viewtasks.html new file mode 100644 index 0000000..a519452 --- /dev/null +++ b/cards/taskfloor_viewtasks.html @@ -0,0 +1,10 @@ + +

TaskFloor Tasks

+
+
+
+
\ No newline at end of file diff --git a/index.html b/index.html index 7515bb3..b92d882 100644 --- a/index.html +++ b/index.html @@ -9,9 +9,22 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. + -
+
+ +
+ +
+
+ +
+ +
+ +
+
@@ -22,5 +35,5 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. \ No newline at end of file diff --git a/js/functions.js b/js/functions.js index cfce340..ce93f14 100644 --- a/js/functions.js +++ b/js/functions.js @@ -7,10 +7,49 @@ function openScreen(id) { $('#content-frame').fadeOut('fast', function () { - $('#content-frame').load("pages/" + id + ".html", function () { - $('#content-frame').fadeIn('fast', function () { - - }); - }); + $('#content-frame').load("pages/" + id + ".html", function () { + $('#content-frame').fadeIn('fast', function () { + + }); + }); }); +} + +function getApps(callback) { + $.post(accounthubapi, { + key: apikey, + action: "listapps" + }, function (resp) { + if (resp.status == "OK") { + callback(resp.apps); + } else { + alert(resp.msg); + } + }, "json"); +} + +var msgtimeout = null; + +function showmsg(text, style, details, timeout) { + if (timeout == null) { + timeout = 5 * 1000; + } + if (details == null) { + details = ""; + } else { + details = "

" + details + "

"; + } + if (style == null) { + style = "info"; + } + $("#alert-box") + .hide() + .html('') + .fadeIn("fast"); + clearTimeout(msgtimeout); + if (timeout !== false) { + msgtimeout = setTimeout(function () { + $("#alert-box").fadeOut("fast"); + }, timeout); + } } \ No newline at end of file diff --git a/js/home.js b/js/home.js new file mode 100644 index 0000000..1a1f625 --- /dev/null +++ b/js/home.js @@ -0,0 +1,72 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +var loadedCardTypes = []; + +var totalCardTypes = []; + +function loadCard(type, apiurl, title) { + $.get("cards/" + type + ".html", {}, function (html) { + console.log(type + " " + apiurl + " " + title); + var box = $('
'); + var card = $('
'); + $(card).html(html); + $(box).html(card); + $("#card-box").append(box); + if (loadedCardTypes.indexOf(type) == -1) { + loadedCardTypes.push(type); + } + }); +} + +function applyCardTitles() { + $(".card_app").each(function () { + var title = $(this).data("title"); + $(this).find(".card_title").text(title); + }); +} + +function waitForCardsToLoadThenInjectScripts() { + // How's *that* for self-documenting code? + for (var i = 0; i < totalCardTypes.length; i++) { + if (loadedCardTypes.indexOf(totalCardTypes[i]) == -1) { + setTimeout(waitForCardsToLoadThenInjectScripts, 50); + return; + } + } + applyCardTitles(); + for (var i = 0; i < loadedCardTypes.length; i++) { + $.getScript('cards/js/' + loadedCardTypes[i] + '.js'); + } +} + + +getApps(function (apps) { + console.log(apps); + for (var appname in apps) { + if (!apps.hasOwnProperty(appname)) { + continue; + } + var app = apps[appname]; + console.log(app); + console.log(" " + app.url); + console.log(" " + app.title); + if (typeof app.station_features !== "undefined" && app.station_features.length > 0) { + for (var type in app.station_features) { + if (!app.station_features.hasOwnProperty(type)) { + continue; + } + totalCardTypes.push(app.station_features[type]); + loadCard(app.station_features[type], app.url + "/api.php", app.title); + } + } + } + waitForCardsToLoadThenInjectScripts(); +}); + +startSessionTimeout(); + +$("#sign-out-btn").css("display", "inline-block"); \ No newline at end of file diff --git a/js/login.js b/js/login.js index 06c628c..50b5022 100644 --- a/js/login.js +++ b/js/login.js @@ -24,11 +24,11 @@ function userpasslogin(username, password) { setuid(resp.data.uid); openScreen("home"); } else { - alert(resp.msg); + showmsg(resp.msg, "danger"); } }, "json"); } else { - alert(resp.msg); + showmsg(resp.msg, "danger"); } }, "json"); } @@ -45,7 +45,7 @@ function codelogin(code) { setuid(resp.user.uid); openScreen("home"); } else { - alert(resp.msg); + showmsg(resp.msg, "danger"); } }, "json"); } diff --git a/js/session.js b/js/session.js index ab46a50..2d30cbd 100644 --- a/js/session.js +++ b/js/session.js @@ -7,14 +7,43 @@ var userdata = []; +var timeout = 120; + function setuser(username) { userdata["username"] = username; } +function getuser() { + return userdata["username"]; +} + function setname(realname) { userdata["name"] = realname; } function setuid(uid) { userdata["uid"] = uid; +} + +/** + * Start a timer to reset the application when the user is idle. + * @returns {undefined} + */ +function startSessionTimeout() { + var maxtime = 120; + timeout = maxtime; + $('*').bind('mousemove keydown scroll', function () { + timeout = maxtime; + }); + setInterval(function () { + timeout--; + if (timeout <= 100) { + $("#timeout-bar").animate({width: Math.round((timeout / 100) * 100) + "%"}, 1000, "linear"); + } else { + $("#timeout-bar").css("width", "100%"); + } + if (timeout == 0) { + document.location.href = "index.html"; + } + }, 1000); } \ No newline at end of file diff --git a/js/settings.js b/js/settings.js index dd88398..6dd7111 100644 --- a/js/settings.js +++ b/js/settings.js @@ -6,4 +6,8 @@ var accounthubapi = "http://localhost/accounthub/api.php"; -var apikey = "123"; \ No newline at end of file +var apikey = "123"; + +function getAPIKey() { + return apikey; +} \ No newline at end of file diff --git a/nbproject/project.properties b/nbproject/project.properties index 34151e8..f26fd4c 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,6 +1,20 @@ +auxiliary.org-netbeans-modules-css-prep.less_2e_compiler_2e_options= +auxiliary.org-netbeans-modules-css-prep.less_2e_enabled=false +auxiliary.org-netbeans-modules-css-prep.less_2e_mappings=/less:/css +auxiliary.org-netbeans-modules-css-prep.sass_2e_compiler_2e_options= +auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=false +auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss:/css +auxiliary.org-netbeans-modules-html-editor-lib.default-html-public-id=HTML5 +auxiliary.org-netbeans-modules-javascript-nodejs.enabled=false +auxiliary.org-netbeans-modules-javascript-nodejs.node_2e_default=true +auxiliary.org-netbeans-modules-javascript-nodejs.run_2e_enabled=false +auxiliary.org-netbeans-modules-javascript-nodejs.sync_2e_enabled=true +browser.run=true file.reference.BizApps-Station=. file.reference.Station-public_html=public_html file.reference.Station-test=test files.encoding=UTF-8 project.licensePath=./nbproject/mplheader.txt site.root.folder=${file.reference.BizApps-Station} +start.file=index.html +web.context.root=/Station diff --git a/pages/home.html b/pages/home.html new file mode 100644 index 0000000..f609179 --- /dev/null +++ b/pages/home.html @@ -0,0 +1,11 @@ + +
+
+ +
+
+ \ No newline at end of file