diff options
author | Fulup Ar Foll <fulup@iot.bzh> | 2015-12-16 17:15:43 +0100 |
---|---|---|
committer | Fulup Ar Foll <fulup@iot.bzh> | 2015-12-16 17:15:43 +0100 |
commit | 475508baa9f0b21087eb85048d51af342aa09692 (patch) | |
tree | f3e944401efc59c68110f54fcea7f569e928a42f /afb-client/app/Frontend/pages/Home | |
parent | f7e443f996dceb928a047d06e45f59579f1fbc0e (diff) |
Add the app!!!
Diffstat (limited to 'afb-client/app/Frontend/pages/Home')
-rw-r--r-- | afb-client/app/Frontend/pages/Home/Home.html | 33 | ||||
-rw-r--r-- | afb-client/app/Frontend/pages/Home/HomeModule.js | 90 | ||||
-rw-r--r-- | afb-client/app/Frontend/pages/Home/HomeModule.scss | 65 |
3 files changed, 188 insertions, 0 deletions
diff --git a/afb-client/app/Frontend/pages/Home/Home.html b/afb-client/app/Frontend/pages/Home/Home.html new file mode 100644 index 0000000..9803b63 --- /dev/null +++ b/afb-client/app/Frontend/pages/Home/Home.html @@ -0,0 +1,33 @@ +<!-- comment --> + +--- +name: myhome +url: /home +controller: HomeController as ctrl +animationIn: slideInRight +--- + +<h3> +<img class="logo" src="images/logo/triskel_iot_bzhx250.png" alt="IoT.bzh Logo" style="height:150px;"> + App Framework Binder Simple Client +</h3> + + + +<div class="button-box box-content "> + + <submit-button class="session-button {{ctrl.APIcreate}}" icon="fi-unlock" label="Open" clicked="ctrl.OpenSession" ></submit-button> + <submit-button class="session-button {{ctrl.APIcheck}}" icon="fi-checkbox" label="Check" clicked="ctrl.CheckSession" ></submit-button> + <submit-button class="session-button {{ctrl.APIrefresh}}" icon="fi-arrows-compress" label="Refresh" clicked="ctrl.RefreshSession" ></submit-button> + <submit-button class="session-button {{ctrl.APIreset}}" icon="fi-lock" label="Close" clicked="ctrl.ResetSession" ></submit-button> + +</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> diff --git a/afb-client/app/Frontend/pages/Home/HomeModule.js b/afb-client/app/Frontend/pages/Home/HomeModule.js new file mode 100644 index 0000000..11b3882 --- /dev/null +++ b/afb-client/app/Frontend/pages/Home/HomeModule.js @@ -0,0 +1,90 @@ +(function() { +'use strict'; + + var INITIAL_TOKEN=123456789; // should match with --token=xxxx binder command line + +// list all rependencies within the page + controler if needed +angular.module('HomeModule', ['SubmitButton']) + + .controller('HomeController', function ($http, ConfigApp) { + var scope = this; // I hate JavaScript + scope.uuid ="none"; + scope.token ="none"; + scope.session="none"; + scope.status ="err-no"; + + console.log ("Home Controller"); + + 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; + + // 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 postdata= {/* any json your application may need */}; + var handler = $http.post(ConfigApp.api.token + 'create?token='+INITIAL_TOKEN, postdata); + + handler.success(scope.ProcessResponse); + handler.error(scope.ProcessError); + }; + + scope.CheckSession = function() { + console.log ("CloseSession"); + var postdata= {/* any json your application may need */}; + var handler = $http.post(ConfigApp.api.token + 'check?token='+scope.token, postdata); + + handler.success(scope.ProcessResponse); + handler.error(scope.ProcessError); + }; + + scope.RefreshSession = function() { + console.log ("RefreshSession"); + var postdata= {/* any json your application may need */}; + var handler = $http.post(ConfigApp.api.token + 'refresh?token='+scope.token, postdata); + + handler.success(scope.ProcessResponse); + handler.error(scope.ProcessError); + }; + + scope.ResetSession = function() { + console.log ("ResetSession"); + var postdata= {/* any json your application may need */}; + var handler = $http.post(ConfigApp.api.token + 'reset?token='+scope.token, postdata); + + handler.success(scope.ProcessResponse); + handler.error(scope.ProcessError); + }; + + }); + +console.log ("SampleControler Loaded"); +})();
\ No newline at end of file diff --git a/afb-client/app/Frontend/pages/Home/HomeModule.scss b/afb-client/app/Frontend/pages/Home/HomeModule.scss new file mode 100644 index 0000000..34e1181 --- /dev/null +++ b/afb-client/app/Frontend/pages/Home/HomeModule.scss @@ -0,0 +1,65 @@ +/* + * 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; + +.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; } + } + + +}; + + + |