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.ProcessResponse= function(data, errcode, headers, config) {
20 if (data.request.status !== "success") {
21 Notification.error ({message: "Invalid API call:" + data.request.info , delay: 5000});
25 // Update UI response global display zone
26 scope.status = data.request.status;
27 scope.errcode = errcode;
28 scope.request = data.request;
29 scope.response = data.response;
31 switch (data.request.reqid) {
45 Notification.error ({message: "Invalid RequestID:" + data.request.reqid , delay: 5000});
49 scope[reqid]="success";
50 console.log ("OK: "+ JSON.stringify(data));
53 scope.ProcessError= function(data, errcode, headers, config) {
54 Notification.error ({message: "Invalid API:" + data.request.reqid , delay: 5000});
55 scope.status = "err-fx";
56 scope.errcode = errcode;
57 scope.request = data.request;
59 console.log ("FX: "+ JSON.stringify(data));
62 scope.OpenSession = function() {
63 console.log ("OpenSession");
64 AppCall.get ("token", "create", {reqid:"open"}, scope.ProcessResponse, scope.InvalidApiCall);
67 scope.CheckSession = function() {
68 console.log ("CloseSession");
70 var postdata= {/* any json your application may need */};
71 var handler = $http.post(AppConfig.session.check + '?token='+AppConfig.session.token +'?idreq=open', postdata);
73 handler.success(scope.ProcessResponse);
74 handler.error(scope.ProcessError);
77 scope.RefreshSession = function() {
78 console.log ("RefreshSession");
79 var postdata= {/* any json your application may need */};
80 var handler = $http.post(AppConfig.session.refresh + '?token='+AppConfig.session.token, postdata);
82 handler.success(scope.ProcessResponse);
83 handler.error(scope.ProcessError);
86 scope.ResetSession = function() {
87 console.log ("ResetSession");
88 var postdata= {/* any json your application may need */};
89 var handler = $http.post(AppConfig.session.reset + '?token='+AppConfig.session.token, postdata);
91 handler.success(scope.ProcessResponse);
92 handler.error(scope.ProcessError);
97 console.log ("SampleControler Loaded");