From 3ebdce373e134b70b129154d8033c1c628847a6c Mon Sep 17 00:00:00 2001 From: Fulup Ar Foll Date: Mon, 25 Jan 2016 14:37:32 +0100 Subject: First version --- .../app/Frontend/pages/Dashboard/Dashboard.html | 33 ++++++ .../Frontend/pages/Dashboard/DashboardModule.js | 75 +++++++++++++ .../Frontend/pages/Dashboard/DashboardModule.scss | 71 +++++++++++++ afm-client/app/Frontend/pages/Home/Dashboard.html | 40 +++++++ .../app/Frontend/pages/Home/DashboardModule.js | 118 +++++++++++++++++++++ .../app/Frontend/pages/Home/DashboardModule.scss | 71 +++++++++++++ afm-client/app/Frontend/pages/Sample/Sample.html | 35 ++++++ .../app/Frontend/pages/Sample/SampleModule.js | 18 ++++ .../app/Frontend/pages/Sample/SampleModule.scss | 41 +++++++ 9 files changed, 502 insertions(+) create mode 100644 afm-client/app/Frontend/pages/Dashboard/Dashboard.html create mode 100644 afm-client/app/Frontend/pages/Dashboard/DashboardModule.js create mode 100644 afm-client/app/Frontend/pages/Dashboard/DashboardModule.scss create mode 100644 afm-client/app/Frontend/pages/Home/Dashboard.html create mode 100644 afm-client/app/Frontend/pages/Home/DashboardModule.js create mode 100644 afm-client/app/Frontend/pages/Home/DashboardModule.scss create mode 100644 afm-client/app/Frontend/pages/Sample/Sample.html create mode 100644 afm-client/app/Frontend/pages/Sample/SampleModule.js create mode 100644 afm-client/app/Frontend/pages/Sample/SampleModule.scss (limited to 'afm-client/app/Frontend/pages') 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..c393271 --- /dev/null +++ b/afm-client/app/Frontend/pages/Dashboard/Dashboard.html @@ -0,0 +1,33 @@ + +--- +name: Dashboard +url: /dashboard +controller: DashboardController as ctrl +animationIn: slideInRight +--- + +

+ + Application Framework Manager Simple Client +

+ + + +
+ + +
+ + +
+
+ req= {{ctrl.request}} + res= {{ctrl.response}} + status= {{ctrl.errcode}} +
+
+ + + + + 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..c075372 --- /dev/null +++ b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js @@ -0,0 +1,75 @@ +(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) { + console.log ("Application Clicked ID=[%s]", appliID); + + }; + + 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; + }; + + scope.GetRunnables = function() { + console.log ("Dashboard GetRunnables"); + + AppCall.get ("afm-main", "runnables", {/*query*/}, function(response) { + + // update debug UI zone + scope.request = "/api/afm-main/runnable"; + scope.response = response.data; + scope.errcode = response.status; + + if (response.status !== 200) { + console.log ("Hoop GetRunnable failed"); + return; + } + + // Check this is a valid response from Binder + if (response.data.request.jtype !== "AJB_reply" && response.data.request.api !== "runnables") { + Notification.error ({message: "Invalid Respond to /opa/afm-main/runnable response.data="+response.data, delay: 5000}); + return; + } + + // loop on runnable application to prepare for display + var appliIDs=[]; + for (var idx=0; idx < response.data.response.length; idx ++) { + appliIDs[idx] = response.data.response [idx].id; + scope.appliStore [response.data.response [idx].id] = response.data.response [idx]; + } + scope.appliIDs = appliIDs; // avoid partial update to limit UI refresh + + }); + }; + + scope.FileUploaded = function (status) { + console.log ("file Uploaded"); + scope.GetRunnables(); + }; + + scope.AutoStart = function () { + console.log ("AutoStart requesting Apps list"); + scope.GetRunnables(); + }; + + }); + +console.log ("Dashboard Controller Loaded"); +})(); \ No newline at end of file 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 . + */ + +@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; } + } + + +}; + + + diff --git a/afm-client/app/Frontend/pages/Home/Dashboard.html b/afm-client/app/Frontend/pages/Home/Dashboard.html new file mode 100644 index 0000000..036148a --- /dev/null +++ b/afm-client/app/Frontend/pages/Home/Dashboard.html @@ -0,0 +1,40 @@ + +--- +name: dashboard +url: /dashboard +controller: DashboardController as ctrl +animationIn: slideInRight +--- + +

+ + Application Framework Manager Simple Client +

+ + + +
+ + +
+ + +
+ + + + + +
+
+
+ req= {{ctrl.request}} + res= {{ctrl.response}} + status= {{ctrl.errcode}} +
+
+ + + + + diff --git a/afm-client/app/Frontend/pages/Home/DashboardModule.js b/afm-client/app/Frontend/pages/Home/DashboardModule.js new file mode 100644 index 0000000..f843df1 --- /dev/null +++ b/afm-client/app/Frontend/pages/Home/DashboardModule.js @@ -0,0 +1,118 @@ +(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 ($http, AppConfig, 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.ProcessResponse= function(data, errcode, headers, config) { + var apiname= 'API'+ data.request.api.replace('-','_'); + scope.status = "err-ok"; + scope.errcode= errcode; + scope.request = data.request; + scope.response = data.response; + + // if token was refresh let's update AppConfig + if (data.request.token) AppConfig.session.token = data.request.token; + if (data.request.uuid) AppConfig.session.uuid = data.request.uuid; + if (data.request.timeout) AppConfig.session.timeout = data.request.timeout; + + // Make sure we clean everything when Open/Close is called + if (apiname === "APIcreate" || apiname === "APIreset") { + scope.APIreset =''; + scope.APIcreate =''; + scope.APIrefresh=''; + scope.APIcheck =''; + } + scope[apiname]="success"; + + // If we have a new token let's update it + if (data.request.token) scope.token=data.request.token; + + console.log ("OK: "+ JSON.stringify(data)); + }; + + scope.ProcessError= function(data, errcode, headers, config) { + var apiname= 'API'+data.request.api.replace('-','_'); + scope.status = "err-fx"; + scope.errcode = errcode; + scope.request = data.request; + scope.response = ""; + scope[apiname]="fail"; + + console.log ("FX: "+ JSON.stringify(data)); + }; + + scope.OpenSession = function() { + console.log ("OpenSession"); + var handler = $http.get(AppConfig.session.create + '?token='+AppConfig.session.initial); + + handler.success(scope.ProcessResponse); + handler.error(scope.ProcessError); + }; + + scope.CheckSession = function() { + console.log ("CloseSession"); + var handler = $http.get(AppConfig.session.check + '?token='+AppConfig.session.token); + + handler.success(scope.ProcessResponse); + handler.error(scope.ProcessError); + }; + + scope.RefreshSession = function() { + console.log ("RefreshSession"); + var handler = $http.get(AppConfig.session.refresh + '?token='+AppConfig.session.token); + + handler.success(scope.ProcessResponse); + handler.error(scope.ProcessError); + }; + + scope.ResetSession = function() { + console.log ("ResetSession"); + var handler = $http.get(AppConfig.session.reset + '?token='+AppConfig.session.token); + + handler.success(scope.ProcessResponse); + handler.error(scope.ProcessError); + }; + + scope.AppliCB = function (appliID) { + console.log ("Application Clicked ID=[%s]", appliID); + + }; + + scope.AutoStart = function () { + console.log ("AutoStart requesting Apps list"); + var handler = $http.get('/api/afm-main/runnables' + '?token='+AppConfig.session.token); + handler.success(function(result) { + + // Check this is a valid response from Binder + if (result.request.jtype !== "AJB_reply" && result.request.api !== "runnables") { + Notification.error ({message: "Invalid Respond to /opa/afm-main/runnable result="+result, delay: 5000}); + return; + } + + // loop on runnable application to prepare for display + var appliIDs=[]; + for (var idx=0; idx < result.response.length; idx ++) { + appliIDs[idx] = result.response [idx].id; + scope.appliStore [result.response [idx].id] = result.response [idx]; + } + scope.appliIDs = appliIDs; // avoid partial update to limit UI refresh + + }); + }; + + }); + +console.log ("Dashboard Controller Loaded"); +})(); \ No newline at end of file diff --git a/afm-client/app/Frontend/pages/Home/DashboardModule.scss b/afm-client/app/Frontend/pages/Home/DashboardModule.scss new file mode 100644 index 0000000..8bf04a1 --- /dev/null +++ b/afm-client/app/Frontend/pages/Home/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 . + */ + +@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; } + } + + +}; + + + diff --git a/afm-client/app/Frontend/pages/Sample/Sample.html b/afm-client/app/Frontend/pages/Sample/Sample.html new file mode 100644 index 0000000..03a4558 --- /dev/null +++ b/afm-client/app/Frontend/pages/Sample/Sample.html @@ -0,0 +1,35 @@ + +--- +name: mysample +url: /sample +controller: SampleController as ctrl +animationIn: slideInRight +--- + +

+ Post File Upload +

+ +
+ + + + + + + + + + + +
+ + diff --git a/afm-client/app/Frontend/pages/Sample/SampleModule.js b/afm-client/app/Frontend/pages/Sample/SampleModule.js new file mode 100644 index 0000000..8ae82ea --- /dev/null +++ b/afm-client/app/Frontend/pages/Sample/SampleModule.js @@ -0,0 +1,18 @@ +(function() { +'use strict'; + +// list all rependencies within the page + controler if needed +angular.module('SampleModule', ['SubmitButton','UploadFiles']) + + .controller('SampleController', function ($http) { + var scope = this; // I hate JavaScript + + console.log ("sample Init"); + + scope.FileUploaded = function (response) { + console.log ("FileUploaded response=%s", JSON.stringify(response)); + }; + }); + +console.log ("SampleControler Loaded"); +})(); \ No newline at end of file diff --git a/afm-client/app/Frontend/pages/Sample/SampleModule.scss b/afm-client/app/Frontend/pages/Sample/SampleModule.scss new file mode 100644 index 0000000..7654424 --- /dev/null +++ b/afm-client/app/Frontend/pages/Sample/SampleModule.scss @@ -0,0 +1,41 @@ +/* + * 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 . + */ + +@import "app/ibz-mixins"; + + +.sample-box { + display: block; + height : 4.5rem; + + .sample-button { + float: right; + width: 5rem; + }; + + .muted-on-on,.muted-off-off{ + background: blueviolet; + }; + + .muted-error{ + background: red; + }; +}; + + + -- cgit 1.2.3-korg