diff options
author | Fulup Ar Foll <fulup@iot.bzh> | 2016-05-24 22:08:43 +0200 |
---|---|---|
committer | Fulup Ar Foll <fulup@iot.bzh> | 2016-05-24 22:08:43 +0200 |
commit | c8a7784c665e1571400853c0c91b9c47be3ce86f (patch) | |
tree | 5163d14b5d9dc0f7085d102408146ea2595f6658 /afb-client/app/Frontend/pages | |
parent | 7b8fe1b305a36f925fc2757a2c126c88fb0a5137 (diff) |
Restore basic functionnalities with new API
Diffstat (limited to 'afb-client/app/Frontend/pages')
-rw-r--r-- | afb-client/app/Frontend/pages/Home/Home.html | 10 | ||||
-rw-r--r-- | afb-client/app/Frontend/pages/Home/HomeModule.js | 67 |
2 files changed, 34 insertions, 43 deletions
diff --git a/afb-client/app/Frontend/pages/Home/Home.html b/afb-client/app/Frontend/pages/Home/Home.html index d3c6719..df20ee2 100644 --- a/afb-client/app/Frontend/pages/Home/Home.html +++ b/afb-client/app/Frontend/pages/Home/Home.html @@ -11,15 +11,15 @@ animationIn: slideInRight App Framework Binder Simple Client </h3> -<token-refresh autolog="true"></token-refresh> +<token-refresh autolog="true" callback="ctrl.Initialised"></token-refresh> <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> + <submit-button class="session-button {{ctrl.class.create}}" icon="fi-unlock" label="Open" clicked="ctrl.OpenSession" ></submit-button> + <submit-button class="session-button {{ctrl.class.check}}" icon="fi-checkbox" label="Check" clicked="ctrl.CheckSession" ></submit-button> + <submit-button class="session-button {{ctrl.class.refresh}}" icon="fi-arrows-compress" label="Refresh" clicked="ctrl.RefreshSession" ></submit-button> + <submit-button class="session-button {{ctrl.class.reset}}" icon="fi-lock" label="Close" clicked="ctrl.ResetSession" ></submit-button> </div> <div class="message-box box-content vertical grid-frame"> diff --git a/afb-client/app/Frontend/pages/Home/HomeModule.js b/afb-client/app/Frontend/pages/Home/HomeModule.js index fdbe520..b082ee0 100644 --- a/afb-client/app/Frontend/pages/Home/HomeModule.js +++ b/afb-client/app/Frontend/pages/Home/HomeModule.js @@ -15,26 +15,24 @@ angular.module('HomeModule', ['SubmitButton', 'TokenRefresh','ModalNotification' console.log ("Home Controller"); - scope.ProcessResponse= function(data, errcode, headers, config) { - - if (data.request.status !== "success") { - Notification.error ({message: "Invalid API call:" + data.request.info , delay: 5000}); - return; - } + scope.OnResponse= function(jresp, errcode) { // Update UI response global display zone - scope.status = data.request.status; + scope.status = jresp.request.status; scope.errcode = errcode; - scope.request = data.request; - scope.response = data.response; + scope.request = jresp.request; + scope.response = jresp.response; + + if (jresp.request.status !== "success") { + Notification.error ({message: "Invalid API call:" + jresp.request.info , delay: 5000}); + scope.class [jresp.request.reqid]="fail"; + return; + } - switch (data.request.reqid) { - case 'open': + switch (jresp.request.reqid) { + case 'create': case 'reset': - scope.APIreset =''; - scope.APIcreate =''; - scope.APIrefresh=''; - scope.APIcheck =''; + scope.class={}; break; case 'refresh': @@ -42,56 +40,49 @@ angular.module('HomeModule', ['SubmitButton', 'TokenRefresh','ModalNotification' break; default: - Notification.error ({message: "Invalid RequestID:" + data.request.reqid , delay: 5000}); + Notification.error ({message: "Invalid RequestID:" + jresp.request.reqid , delay: 5000}); return; } - scope[reqid]="success"; - console.log ("OK: "+ JSON.stringify(data)); + // update button classes within home.html + scope.class [jresp.request.reqid]="success"; + console.log ("OK: "+ JSON.stringify(jresp)); }; - scope.ProcessError= function(data, errcode, headers, config) { - Notification.error ({message: "Invalid API:" + data.request.reqid , delay: 5000}); + scope.ProcessError= function(response, errcode, config) { + Notification.error ({message: "Invalid API:" + response.request.reqid , delay: 5000}); scope.status = "err-fx"; scope.errcode = errcode; - scope.request = data.request; + scope.request = response.request; scope.response = ""; - console.log ("FX: "+ JSON.stringify(data)); + console.log ("FX: "+ JSON.stringify(response)); }; scope.OpenSession = function() { console.log ("OpenSession"); - AppCall.get ("token", "create", {reqid:"open"}, scope.ProcessResponse, scope.InvalidApiCall); + AppCall.get ("token", "create", {/*query*/}, scope.OnResponse, scope.InvalidApiCall); }; scope.CheckSession = function() { console.log ("CloseSession"); + AppCall.get ("token", "check", {/*query*/}, scope.OnResponse, scope.InvalidApiCall); - var postdata= {/* any json your application may need */}; - var handler = $http.post(AppConfig.session.check + '?token='+AppConfig.session.token +'?idreq=open', 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(AppConfig.session.refresh + '?token='+AppConfig.session.token, postdata); - - handler.success(scope.ProcessResponse); - handler.error(scope.ProcessError); + AppCall.get ("token", "refresh", {/*query*/}, scope.OnResponse, scope.InvalidApiCall); }; scope.ResetSession = function() { console.log ("ResetSession"); - var postdata= {/* any json your application may need */}; - var handler = $http.post(AppConfig.session.reset + '?token='+AppConfig.session.token, postdata); - - handler.success(scope.ProcessResponse); - handler.error(scope.ProcessError); + AppCall.get ("token", "reset", {/*query*/}, scope.OnResponse, scope.InvalidApiCall); }; + scope.Initialised = function () { + scope.class = {create: "success"}; + } + }); console.log ("SampleControler Loaded"); |