From 9966df615382815fb6169c9ecd9e3e696f8fa615 Mon Sep 17 00:00:00 2001
From: Fulup Ar Foll <fulup@iot.bzh>
Date: Mon, 15 Feb 2016 11:22:27 +0100
Subject: Update runnable list after uninstall

---
 .../app/Frontend/pages/Dashboard/DashboardModule.js      |  3 +++
 .../app/Frontend/widgets/ActionButtons/AppliButton.js    | 16 ++++++++--------
 2 files changed, 11 insertions(+), 8 deletions(-)

(limited to 'afm-client/app')

diff --git a/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js
index f4330cf..a52e5b6 100644
--- a/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js
+++ b/afm-client/app/Frontend/pages/Dashboard/DashboardModule.js
@@ -21,6 +21,9 @@ 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() {
diff --git a/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js b/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js
index 7a32873..f717225 100644
--- a/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js
+++ b/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js
@@ -56,17 +56,17 @@
                     scope.runstatus = "stop";
                     scope.clicked = function () {
 
-                        var notifyError = function(api, response) {
-                            Notification.error ({message: "Fail /api/afm-main" + api + "=" + scope.label + " RunID="+ scope.appID, delay: 5000});
+                        var notifyError = function(action, response) {
+                            Notification.error ({message: "Fail /api/afm-main" + action + "=" + scope.label + " RunID="+ scope.appID, delay: 5000});
                             elem.addClass ("fail");
                             elem.removeClass ("success");
-                            scope.callback (scope.appID, api, response);
+                            scope.callback (scope.appID, action, response);
                         };
                         
-                        var notifySuccess = function (api, response) {
+                        var notifySuccess = function (action, response) {
                             elem.removeClass ("fail");
                             scope.runID = response.data.response.runid;
-                            scope.callback (scope.appID, "/api/afm-main/start", response);
+                            scope.callback (scope.appID, action, response);
                         };
                         
                         var closeModal = function() {
@@ -87,7 +87,7 @@
                                             return;
                                         }
                                         scope.runstatus="start";
-                                        notifySuccess ("start", response);
+                                        notifySuccess (action, response);
 					if(response.data.response.uri)
 						$window.open(response.data.response.uri.replace("%h", $location.host()));
                                     });
@@ -102,7 +102,7 @@
                                             return;
                                         }
                                         scope.runstatus="stop";
-                                        notifySuccess ("stop", response);
+                                        notifySuccess (action, response);
                                     });
                                     break;
                                         
@@ -139,7 +139,7 @@
                                             return;
                                         }
                                         
-                                        notifySuccess ("uninstall", response);
+                                        notifySuccess (action, response);
                                     });
                                     break;
 
-- 
cgit