X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=afm-client%2Fapp%2FFrontend%2Fwidgets%2FActionButtons%2FAppliButton.js;h=b7acb6b6c0ccded451d2a1cdf42b3f99f9e39a95;hb=d47fd84a6a16b1c9c4b4ce5a3279b9ecaea54c1b;hp=69e61b6fea3aac750f7b9076e9c2c006ab1c9838;hpb=a79d1fc845f31cda41b55b0ffb9aa807732bbcd0;p=src%2Fapp-framework-demo.git diff --git a/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js b/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js index 69e61b6..b7acb6b 100644 --- a/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js +++ b/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js @@ -50,23 +50,24 @@ ''; angular.module('AppliButton', []) - .directive('appliButton', function (AppConfig, AppCall, ModalFactory, Notification, $timeout) { + .directive('appliButton', function (AppConfig, AppCall, ModalFactory, Notification, $timeout, $window, $location, urlquery) { function mymethods(scope, elem, attrs) { - scope.runstatus = "stop" + scope.runstatus = "stop"; + scope.runmode = urlquery.runmode || "auto"; 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() { @@ -81,13 +82,15 @@ case "start": if (scope.runstatus !== "stop") return; - AppCall.get ("afm-main", "start", {id: scope.appID}, function(response) { + AppCall.get ("afm-main", "start", {id: scope.appID, mode: scope.runmode}, function(response) { if (response.status !== 200 || response.data.jtype !== "AJB_reply") { notifyError ("start", response); return; } scope.runstatus="start"; - notifySuccess ("start", response); + notifySuccess (action, response); + if(response.data.response.uri) + scope.winapp= $window.open(response.data.response.uri.replace("%h", $location.host())); }); break; @@ -100,7 +103,14 @@ return; } scope.runstatus="stop"; - notifySuccess ("stop", response); + + // if a remote window app was open let's close it + if (scope.winapp) { + console.log ("Closing Application Window label=%s id=%s", scope.label, scope.appID); + scope.winapp.close(); + scope.winapp=false; + } + notifySuccess (action, response); }); break; @@ -137,7 +147,7 @@ return; } - notifySuccess ("uninstall", response); + notifySuccess (action, response); }); break;