4 // WARNING: make sure than app/frontend/services/AppConfig.js match your server
6 // list all rependencies within the page + controler if needed
7 angular.module('HomeModule', ['SubmitButton', 'TokenRefresh','ModalNotification'])
9 .controller('HomeController', function (AppCall, Notification) {
10 var scope = this; // I hate JavaScript
14 scope.status ="err-no";
16 console.log ("Home Controller");
18 scope.OnResponse= function(jresp, errcode) {
20 // Update UI response global display zone
21 scope.status = jresp.request.status;
22 scope.errcode = errcode;
23 scope.request = jresp.request;
24 scope.response = jresp.response;
26 if (jresp.request.status !== "success") {
27 Notification.error ({message: "Invalid API call:" + jresp.request.info , delay: 5000});
28 scope.class [jresp.request.reqid]="fail";
32 switch (jresp.request.reqid) {
43 Notification.error ({message: "Invalid RequestID:" + jresp.request.reqid , delay: 5000});
47 // update button classes within home.html
48 scope.class [jresp.request.reqid]="success";
49 console.log ("OK: "+ JSON.stringify(jresp));
52 scope.ProcessError= function(response, errcode, config) {
53 Notification.error ({message: "Invalid API:" + response.request.reqid , delay: 5000});
54 scope.status = "err-fx";
55 scope.errcode = errcode;
56 scope.request = response.request;
58 console.log ("FX: "+ JSON.stringify(response));
61 scope.OpenSession = function() {
62 console.log ("OpenSession");
63 AppCall.get ("token", "create", {/*query*/}, scope.OnResponse, scope.InvalidApiCall);
66 scope.CheckSession = function() {
67 console.log ("CloseSession");
68 AppCall.get ("token", "check", {/*query*/}, scope.OnResponse, scope.InvalidApiCall);
72 scope.RefreshSession = function() {
73 console.log ("RefreshSession");
74 AppCall.get ("token", "refresh", {/*query*/}, scope.OnResponse, scope.InvalidApiCall);
77 scope.ResetSession = function() {
78 console.log ("ResetSession");
79 AppCall.get ("token", "reset", {/*query*/}, scope.OnResponse, scope.InvalidApiCall);
82 scope.Initialised = function () {
83 scope.class = {create: "success"};
88 console.log ("SampleControler Loaded");