X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=afm-client%2Fapp%2FFrontend%2Fpages%2FDashboard%2FDashboardModule.js;h=3bde5a94f595a527938356803fa4f588ed0b845f;hb=96190f9cd583d9182c692c88d3342109bad81157;hp=83408a5610efbe2775358536a4288bc495bb438a;hpb=3d6f539592cb2171ed67b3c2b0246fd72ddfaa0d;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 index 83408a5..3bde5a9 100644 --- a/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js +++ b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js @@ -21,34 +21,40 @@ angular.module('DashboardModule', ['SubmitButton', 'TokenRefresh', 'AppliButton' scope.request = action; scope.errcode = response.status; if (response.data) scope.response = response.data; + + // On app was removed let's update runnable list + if (action === "uninstall") scope.GetRunnables(); }; scope.GetRunnables = function() { console.log ("Dashboard GetRunnables"); - AppCall.get ("afm-main", "runnables", {/*query*/}, function(response) { + AppCall.get ("afm-main", "runnables", {/*query*/}, function(jresp, errcode) { // 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") { + scope.response = jresp.response; + scope.errcode = jresp.request.status; + + // Check if this is a response from AGL application framework binder + if (jresp.jtype !== "afb-reply") { Notification.error ({message: "Invalid Respond to /opa/afm-main/runnable response.data="+response.data, delay: 5000}); return; } + + // Check for success + if (jresp.request.status !== "success") { + Notification.error ({message: "afm-main/runnable" + jresp.request.info, 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]; + var runnables = jresp.response.runnables; + for (var idx=0; idx < runnables.length; idx ++) { + appliIDs[idx] = runnables [idx].id; + scope.appliStore [runnables [idx].id] = runnables [idx]; } scope.appliIDs = appliIDs; // avoid partial update to limit UI refresh @@ -57,8 +63,8 @@ angular.module('DashboardModule', ['SubmitButton', 'TokenRefresh', 'AppliButton' scope.FileUploaded = function (response) { console.log ("file Uploaded"); - // Cannot display post results as GetRunnable will overload them - scope.request = "/api/afm-main/runnable"; + // Cannot display post results as GetRunnable will overload them aynchronously + scope.request = "/api/afm-main/install"; scope.response = response.headers; scope.errcode = response.status; @@ -74,4 +80,4 @@ angular.module('DashboardModule', ['SubmitButton', 'TokenRefresh', 'AppliButton' }); console.log ("Dashboard Controller Loaded"); -})(); \ No newline at end of file +})();