summaryrefslogtreecommitdiffstats
path: root/templates/hybrid-html5/app/Frontend/pages/SampleHome/SampleHome.js
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-04 13:59:00 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-10-15 18:21:42 +0200
commite3d26a820db76f006ec364c90dc54a689446d998 (patch)
treeae7a80f266445fd6a3bb29abb25ac231d18e7516 /templates/hybrid-html5/app/Frontend/pages/SampleHome/SampleHome.js
parent02075924e861edb74935266cc722d362af87a9f0 (diff)
Rename to more meaningful name directories
Change-Id: Ib3990308c1f2358b3e330cd0068719098c4dab56 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'templates/hybrid-html5/app/Frontend/pages/SampleHome/SampleHome.js')
-rw-r--r--templates/hybrid-html5/app/Frontend/pages/SampleHome/SampleHome.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/templates/hybrid-html5/app/Frontend/pages/SampleHome/SampleHome.js b/templates/hybrid-html5/app/Frontend/pages/SampleHome/SampleHome.js
new file mode 100644
index 0000000..b037773
--- /dev/null
+++ b/templates/hybrid-html5/app/Frontend/pages/SampleHome/SampleHome.js
@@ -0,0 +1,63 @@
+(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('SampleHomeModule', ['SubmitButton', 'TokenRefresh','ModalNotification'])
+
+ .controller('SampleHomeController', function (AppCall, Notification) {
+ var scope = this; // I hate JavaScript
+ scope.uuid ="none";
+ scope.token ="none";
+ scope.session="none";
+ scope.status ="err-no";
+
+ console.log ("Home Controller");
+
+ scope.OnResponse= function(jresp, errcode) {
+
+ // Update UI response global display zone
+ scope.status = jresp.request.status;
+ scope.errcode = errcode;
+ scope.request = jresp.request;
+ scope.response = jresp.response;
+
+ var action=jresp.request.reqid.toUpperCase();
+
+ switch (action) {
+ case 'PING':
+ break;
+
+ default:
+ Notification.error ({message: "Invalid RequestID:" + jresp.request.reqid , delay: 5000});
+ return;
+ }
+
+ // update button classes within home.html
+ scope.class [jresp.request.reqid]="success";
+ console.log ("OK: "+ JSON.stringify(jresp));
+ };
+
+ 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 = response.request;
+ scope.response = "";
+ console.log ("FX: "+ JSON.stringify(response));
+ };
+
+ scope.RefreshSession = function() {
+ console.log ("RefreshSession");
+ AppCall.get ("xxxxxx", "ping", {/*query*/}, scope.OnResponse, scope.InvalidApiCall);
+ };
+
+ scope.Initialised = function () {
+ scope.class = {connect: "success"};
+ };
+
+ });
+
+console.log ("SampleControler Loaded");
+})();