summaryrefslogtreecommitdiffstats
path: root/afm-client/app/Frontend/pages
diff options
context:
space:
mode:
Diffstat (limited to 'afm-client/app/Frontend/pages')
-rw-r--r--afm-client/app/Frontend/pages/Dashboard/Dashboard.html33
-rw-r--r--afm-client/app/Frontend/pages/Dashboard/DashboardModule.js83
-rw-r--r--afm-client/app/Frontend/pages/Dashboard/DashboardModule.scss71
3 files changed, 187 insertions, 0 deletions
diff --git a/afm-client/app/Frontend/pages/Dashboard/Dashboard.html b/afm-client/app/Frontend/pages/Dashboard/Dashboard.html
new file mode 100644
index 0000000..b5a9089
--- /dev/null
+++ b/afm-client/app/Frontend/pages/Dashboard/Dashboard.html
@@ -0,0 +1,33 @@
+<!-- Foundation Annotations generate tmp/route.js -->
+---
+name: Dashboard
+url: /dashboard
+controller: DashboardController as ctrl
+animationIn: slideInRight
+---
+
+<h3>
+<img class="logo" src="images/logo/triskel_iot_bzhx250.png" alt="IoT.bzh Logo" style="height:150px;">
+ Application Framework Manager Simple Client
+</h3>
+
+
+
+<div class="button-box box-content ">
+ <appli-button ng-repeat="appliID in ctrl.appliIDs" store="ctrl.appliStore" handle="{{appliID}}" callback="ctrl.AppliCB"> </appli-button>
+ <upload-appli class="ibz-right" label="Upload" name="widget" icon="fi-upload" posturl="/api/afm-main/install" callback="ctrl.FileUploaded" title="Upload AGL App"></upload-appli>
+</div>
+
+
+<div class="message-box box-content vertical grid-frame">
+ <div class="response">
+ <span class="grid-content noscroll req {{ctrl.status}} ">req= {{ctrl.request}}</span>
+ <span class="grid-content noscroll res {{ctrl.status}} ">res= {{ctrl.response}}</span>
+ <span class="grid-content noscroll status {{ctrl.status}}">status= {{ctrl.errcode}}</span>
+ </div>
+</div>
+
+
+<!--<link-button href="sample" icon="fi-home" label="sample"></link-button>-->
+<token-refresh autolog="true" callback="ctrl.AutoStart"></token-refresh>
+
diff --git a/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js
new file mode 100644
index 0000000..3bde5a9
--- /dev/null
+++ b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js
@@ -0,0 +1,83 @@
+(function() {
+'use strict';
+
+// WARNING: make sure than app/frontend/services/AppConfig.js match your server
+
+// list all rependencies within the page + controler if needed
+angular.module('DashboardModule', ['SubmitButton', 'TokenRefresh', 'AppliButton'])
+
+ .controller('DashboardController', function (AppCall, Notification) {
+ var scope = this; // I hate JavaScript
+ scope.uuid ="none";
+ scope.token ="none";
+ scope.session="none";
+ scope.status ="err-no";
+ scope.appliIDs =[]; // array to hold applications ID
+ scope.appliStore={}; // array to hold applications json description
+
+
+ scope.AppliCB = function(appliID, action, response) {
+ // Action is done within Widget Controller only update debug UI zone
+ scope.request = action;
+ scope.errcode = response.status;
+ if (response.data) scope.response = response.data;
+
+ // On app was removed let's update runnable list
+ if (action === "uninstall") scope.GetRunnables();
+ };
+
+ scope.GetRunnables = function() {
+ console.log ("Dashboard GetRunnables");
+
+ AppCall.get ("afm-main", "runnables", {/*query*/}, function(jresp, errcode) {
+
+ // update debug UI zone
+ scope.request = "/api/afm-main/runnable";
+ scope.response = jresp.response;
+ scope.errcode = jresp.request.status;
+
+ // Check if this is a response from AGL application framework binder
+ if (jresp.jtype !== "afb-reply") {
+ Notification.error ({message: "Invalid Respond to /opa/afm-main/runnable response.data="+response.data, delay: 5000});
+ return;
+ }
+
+ // Check for success
+ if (jresp.request.status !== "success") {
+ Notification.error ({message: "afm-main/runnable" + jresp.request.info, delay: 5000});
+ return;
+ }
+
+
+ // loop on runnable application to prepare for display
+ var appliIDs=[];
+ var runnables = jresp.response.runnables;
+ for (var idx=0; idx < runnables.length; idx ++) {
+ appliIDs[idx] = runnables [idx].id;
+ scope.appliStore [runnables [idx].id] = runnables [idx];
+ }
+ scope.appliIDs = appliIDs; // avoid partial update to limit UI refresh
+
+ });
+ };
+
+ scope.FileUploaded = function (response) {
+ console.log ("file Uploaded");
+ // Cannot display post results as GetRunnable will overload them aynchronously
+ scope.request = "/api/afm-main/install";
+ scope.response = response.headers;
+ scope.errcode = response.status;
+
+ // everything looks OK update app list
+ scope.GetRunnables();
+ };
+
+ scope.AutoStart = function () {
+ console.log ("AutoStart requesting Apps list");
+ scope.GetRunnables();
+ };
+
+ });
+
+console.log ("Dashboard Controller Loaded");
+})();
diff --git a/afm-client/app/Frontend/pages/Dashboard/DashboardModule.scss b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.scss
new file mode 100644
index 0000000..8bf04a1
--- /dev/null
+++ b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.scss
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2015 "IoT.bzh"
+ * Author "Fulup Ar Foll"
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+@import "app/ibz-mixins";
+
+$COLOR_SUCCESS: green;
+$COLOR_FAIL: red;
+
+token-refresh {
+ display: block;
+ float: right;
+ margin: .5rem 1rem 0 0;
+}
+
+.button-box {
+ height : 4.5rem;
+
+ .session-button {
+ float: left;
+ width: 5rem;
+ };
+
+ .response > span{
+ display: block;
+ margin: .3rem .5rem .3rem .5rem;
+ }
+
+ .fail {
+ color:$COLOR_FAIL;
+ border: 1px solid darken($COLOR_FAIL,10%);
+ }
+ .success {
+ color:$COLOR_SUCCESS;
+ border: 1px solid darken($COLOR_SUCCESS,10%);
+ }
+
+};
+
+.message-box {
+ height : auto;
+ width: 100%;
+ font-size: .75rem;
+
+ .response {
+ .err-no { color:grey; }
+ .res.err-ok { color: blue; }
+ .req.err-ok { color:blueviolet; }
+ .status.err-ok { color:green; }
+ .status.err-fx { color:red; }
+ }
+
+
+};
+
+
+