X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=afm-client%2Fapp%2FFrontend%2Fwidgets%2FActionButtons%2FAppliButton.js;h=7a32873c118b7434618729f663674bcf745b2d83;hb=9bd23d89edbc2dad7f5da8088fa788a7632eade2;hp=e51b3b6bfa94c3424acbb50a7350b74637a242ea;hpb=eac68b18429b5e8bfb2aa8823d4f9a93f4e2ef5d;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 e51b3b6..7a32873 100644 --- a/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js +++ b/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js @@ -31,10 +31,10 @@ '' + 'Application {{label}}' + '' + ''; @@ -50,9 +50,10 @@ ''; angular.module('AppliButton', []) - .directive('appliButton', function (AppConfig, AppCall, ModalFactory, Notification, $timeout) { + .directive('appliButton', function (AppConfig, AppCall, ModalFactory, Notification, $timeout, $window, $location) { function mymethods(scope, elem, attrs) { + scope.runstatus = "stop"; scope.clicked = function () { var notifyError = function(api, response) { @@ -79,23 +80,28 @@ switch (action) { case "start": - AppCall.get ("afm-main", "start", {id: scope.appID}, function(response) { + if (scope.runstatus !== "stop") return; + AppCall.get ("afm-main", "start", {id: scope.appID, mode: "remote"}, function(response) { if (response.status !== 200 || response.data.jtype !== "AJB_reply") { notifyError ("start", response); return; } - + scope.runstatus="start"; notifySuccess ("start", response); + if(response.data.response.uri) + $window.open(response.data.response.uri.replace("%h", $location.host())); }); break; case "stop": + if (scope.runstatus !== "start") return; + AppCall.get ("afm-main", "terminate", {runid: scope.runID}, function(response) { if (response.status !== 200 || response.data.jtype !== "AJB_reply") { notifyError ("stop", response); return; } - + scope.runstatus="stop"; notifySuccess ("stop", response); }); break; @@ -109,6 +115,7 @@ // reference http://foundation.zurb.com/apps/docs/#!/angular-modules var config = { + id: 'appliInfoMenu', animationIn: 'slideInFromTop', contentScope: { close : closeModal, @@ -125,6 +132,7 @@ break; case "uninstall": + if (scope.runstatus !== "stop") return; AppCall.get ("afm-main", "uninstall", {id: scope.appID}, function(response) { if (response.status !== 200 || response.data.jtype !== "AJB_reply") { notifyError ("uninstall", response); @@ -145,13 +153,15 @@ // reference http://foundation.zurb.com/apps/docs/#!/angular-modules var config = { + id: 'appliActionMenu', animationIn: 'slideInFromTop', contentScope: { - action : actionModal, - close : closeModal, - icon : scope.icon, - label : scope.label - }, template : tmplModal + action : actionModal, + runstatus: scope.runstatus, + close : closeModal, + icon : scope.icon, + label : scope.label + }, template : tmplModal }; // Popup Modal to render application data scope.modal = new ModalFactory(config);