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(response) {
34 // update debug UI zone
35 scope.request = "/api/afm-main/runnable";
36 scope.response = response.data;
37 scope.errcode = response.status;
39 if (response.status !== 200) {
40 console.log ("Hoop GetRunnable failed");
44 // Check this is a valid response from Binder
45 if (response.data.request.jtype !== "AJB_reply" && response.data.request.api !== "runnables") {
46 Notification.error ({message: "Invalid Respond to /opa/afm-main/runnable response.data="+response.data, delay: 5000});
50 // loop on runnable application to prepare for display
52 var runnables = response.data.response.runnables;
53 for (var idx=0; idx < runnables.length; idx ++) {
54 appliIDs[idx] = runnables [idx].id;
55 scope.appliStore [runnables [idx].id] = runnables [idx];
57 scope.appliIDs = appliIDs; // avoid partial update to limit UI refresh
62 scope.FileUploaded = function (response) {
63 console.log ("file Uploaded");
64 // Cannot display post results as GetRunnable will overload them aynchronously
65 scope.request = "/api/afm-main/install";
66 scope.response = response.headers;
67 scope.errcode = response.status;
69 // everything looks OK update app list
73 scope.AutoStart = function () {
74 console.log ("AutoStart requesting Apps list");
80 console.log ("Dashboard Controller Loaded");