X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=afm-client%2Fapp%2FFrontend%2Fpages%2FDashboard%2FDashboardModule.js;fp=afm-client%2Fapp%2FFrontend%2Fpages%2FDashboard%2FDashboardModule.js;h=c0753720be816ab49eac2154a3c9e86a4b19641e;hb=3ebdce373e134b70b129154d8033c1c628847a6c;hp=0000000000000000000000000000000000000000;hpb=8d03b8c581ce64192e9d265597d262b59826cffd;p=src%2Fapp-framework-demo.git diff --git a/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js new file mode 100644 index 0000000..c075372 --- /dev/null +++ b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js @@ -0,0 +1,75 @@ +(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('DashboardModule', ['SubmitButton', 'TokenRefresh', 'AppliButton']) + + .controller('DashboardController', function (AppCall, Notification) { + var scope = this; // I hate JavaScript + scope.uuid ="none"; + scope.token ="none"; + scope.session="none"; + scope.status ="err-no"; + scope.appliIDs =[]; // array to hold applications ID + scope.appliStore={}; // array to hold applications json description + + scope.AppliCB = function (appliID) { + console.log ("Application Clicked ID=[%s]", appliID); + + }; + + scope.AppliCB = function(appliID, action, response) { + // Action is done within Widget Controller only update debug UI zone + scope.request = action; + scope.errcode = response.status; + if (response.data) scope.response = response.data; + }; + + scope.GetRunnables = function() { + console.log ("Dashboard GetRunnables"); + + AppCall.get ("afm-main", "runnables", {/*query*/}, function(response) { + + // update debug UI zone + scope.request = "/api/afm-main/runnable"; + scope.response = response.data; + scope.errcode = response.status; + + if (response.status !== 200) { + console.log ("Hoop GetRunnable failed"); + return; + } + + // Check this is a valid response from Binder + if (response.data.request.jtype !== "AJB_reply" && response.data.request.api !== "runnables") { + Notification.error ({message: "Invalid Respond to /opa/afm-main/runnable response.data="+response.data, delay: 5000}); + return; + } + + // loop on runnable application to prepare for display + var appliIDs=[]; + for (var idx=0; idx < response.data.response.length; idx ++) { + appliIDs[idx] = response.data.response [idx].id; + scope.appliStore [response.data.response [idx].id] = response.data.response [idx]; + } + scope.appliIDs = appliIDs; // avoid partial update to limit UI refresh + + }); + }; + + scope.FileUploaded = function (status) { + console.log ("file Uploaded"); + scope.GetRunnables(); + }; + + scope.AutoStart = function () { + console.log ("AutoStart requesting Apps list"); + scope.GetRunnables(); + }; + + }); + +console.log ("Dashboard Controller Loaded"); +})(); \ No newline at end of file