appli: integrates mode local/remote
[src/app-framework-demo.git] / afm-client / app / Frontend / widgets / ActionButtons / AppliButton.js
index 69e61b6..7a32873 100644 (file)
             '';
 
     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.runstatus = "stop";
                     scope.clicked = function () {
 
                         var notifyError = function(api, response) {
                                 
                                 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: "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;