Code Review
/
src
/
app-framework-demo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Implement closing windows of remote launchs
[src/app-framework-demo.git]
/
afm-client
/
app
/
Frontend
/
widgets
/
ActionButtons
/
AppliButton.js
diff --git
a/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js
b/afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js
index
e51b3b6
..
b7acb6b
100644
(file)
--- a/
afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js
+++ b/
afm-client/app/Frontend/widgets/ActionButtons/AppliButton.js
@@
-31,10
+31,10
@@
'<img ng-src="{{icon}}">' +
'<span class="modal-text">Application <b>{{label}}</b></span>' +
'<ul class="vertical icon-left primary menu-bar">' +
'<img ng-src="{{icon}}">' +
'<span class="modal-text">Application <b>{{label}}</b></span>' +
'<ul class="vertical icon-left primary menu-bar">' +
- '<li><a ng-click=action("start")><i class="fi-check"> Start</i></a></li>' +
- '<li><a ng-click=action("stop")><i class="fi-x"> Stop</i></a></li>' +
+ '<li
class=start-{{runstatus}}
><a ng-click=action("start")><i class="fi-check"> Start</i></a></li>' +
+ '<li
class=stop-{{runstatus}}
><a ng-click=action("stop")><i class="fi-x"> Stop</i></a></li>' +
'<li><a ng-click=action("info")><i class="fi-info"> Info</i></a></li>' +
'<li><a ng-click=action("info")><i class="fi-info"> Info</i></a></li>' +
- '<li><a ng-click=action("uninstall")><i class="fi-x"> Uninstall</i></a></li>' +
+ '<li
class=start-{{runstatus}}
><a ng-click=action("uninstall")><i class="fi-x"> Uninstall</i></a></li>' +
'</ul>' +
'';
'</ul>' +
'';
@@
-50,22
+50,24
@@
'';
angular.module('AppliButton', [])
'';
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) {
function mymethods(scope, elem, attrs) {
+ scope.runstatus = "stop";
+ scope.runmode = urlquery.runmode || "auto";
scope.clicked = function () {
scope.clicked = function () {
- var notifyError = function(a
pi
, response) {
- Notification.error ({message: "Fail /api/afm-main" + a
pi
+ "=" + scope.label + " RunID="+ scope.appID, delay: 5000});
+ var notifyError = function(a
ction
, response) {
+ Notification.error ({message: "Fail /api/afm-main" + a
ction
+ "=" + scope.label + " RunID="+ scope.appID, delay: 5000});
elem.addClass ("fail");
elem.removeClass ("success");
elem.addClass ("fail");
elem.removeClass ("success");
- scope.callback (scope.appID, a
pi
, response);
+ scope.callback (scope.appID, a
ction
, response);
};
};
- var notifySuccess = function (a
pi
, response) {
+ var notifySuccess = function (a
ction
, response) {
elem.removeClass ("fail");
scope.runID = response.data.response.runid;
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() {
};
var closeModal = function() {
@@
-79,24
+81,36
@@
switch (action) {
case "start":
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: scope.runmode}, function(response) {
if (response.status !== 200 || response.data.jtype !== "AJB_reply") {
notifyError ("start", response);
return;
}
if (response.status !== 200 || response.data.jtype !== "AJB_reply") {
notifyError ("start", response);
return;
}
-
- notifySuccess ("start", response);
+ scope.runstatus="start";
+ notifySuccess (action, response);
+ if(response.data.response.uri)
+ scope.winapp= $window.open(response.data.response.uri.replace("%h", $location.host()));
});
break;
case "stop":
});
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;
}
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);
+ // 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;
});
break;
@@
-109,6
+123,7
@@
// reference http://foundation.zurb.com/apps/docs/#!/angular-modules
var config = {
// reference http://foundation.zurb.com/apps/docs/#!/angular-modules
var config = {
+ id: 'appliInfoMenu',
animationIn: 'slideInFromTop',
contentScope: {
close : closeModal,
animationIn: 'slideInFromTop',
contentScope: {
close : closeModal,
@@
-125,13
+140,14
@@
break;
case "uninstall":
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);
return;
}
AppCall.get ("afm-main", "uninstall", {id: scope.appID}, function(response) {
if (response.status !== 200 || response.data.jtype !== "AJB_reply") {
notifyError ("uninstall", response);
return;
}
- notifySuccess (
"uninstall"
, response);
+ notifySuccess (
action
, response);
});
break;
});
break;
@@
-145,13
+161,15
@@
// reference http://foundation.zurb.com/apps/docs/#!/angular-modules
var config = {
// reference http://foundation.zurb.com/apps/docs/#!/angular-modules
var config = {
+ id: 'appliActionMenu',
animationIn: 'slideInFromTop',
contentScope: {
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);
};
// Popup Modal to render application data
scope.modal = new ModalFactory(config);