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('DashboardModule', ['SubmitButton', 'TokenRefresh', 'AppliButton'])
9 .controller('DashboardController', function (AppCall, Notification) {
10 var scope = this; // I hate JavaScript
14 scope.status ="err-no";
15 scope.appliIDs =[]; // array to hold applications ID
16 scope.appliStore={}; // array to hold applications json description
19 scope.AppliCB = function(appliID, action, response) {
20 // Action is done within Widget Controller only update debug UI zone
21 scope.request = action;
22 scope.errcode = response.status;
23 if (response.data) scope.response = response.data;
25 // On app was removed let's update runnable list
26 if (action === "uninstall") scope.GetRunnables();
29 scope.GetRunnables = function() {
30 console.log ("Dashboard GetRunnables");
32 AppCall.get ("afm-main", "runnables", {/*query*/}, function(jresp, errcode) {
34 // update debug UI zone
35 scope.request = "/api/afm-main/runnable";
36 scope.response = jresp.response;
37 scope.errcode = jresp.request.status;
39 // Check if this is a response from AGL application framework binder
40 if (jresp.jtype !== "afb-reply") {
41 Notification.error ({message: "Invalid Respond to /opa/afm-main/runnable response.data="+response.data, delay: 5000});
46 if (jresp.request.status !== "success") {
47 Notification.error ({message: "afm-main/runnable" + jresp.request.info, delay: 5000});
52 // loop on runnable application to prepare for display
54 var runnables = jresp.response.runnables;
55 for (var idx=0; idx < runnables.length; idx ++) {
56 appliIDs[idx] = runnables [idx].id;
57 scope.appliStore [runnables [idx].id] = runnables [idx];
59 scope.appliIDs = appliIDs; // avoid partial update to limit UI refresh
64 scope.FileUploaded = function (response) {
65 console.log ("file Uploaded");
66 // Cannot display post results as GetRunnable will overload them aynchronously
67 scope.request = "/api/afm-main/install";
68 scope.response = response.headers;
69 scope.errcode = response.status;
71 // everything looks OK update app list
75 scope.AutoStart = function () {
76 console.log ("AutoStart requesting Apps list");
82 console.log ("Dashboard Controller Loaded");