1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-19 06:50:07 +03:00

B #5405: Redirect delete flow (#1232)

Co-authored-by: Jorge Lobo <jlobo@opennebula.systems>
(cherry picked from commit c9442943870802f3ea0b6acda5f983eefe9c97d5)
This commit is contained in:
Jorge Miguel Lobo Escalona 2021-05-19 14:06:51 +02:00 committed by Tino Vazquez
parent 909775dd9b
commit a54ede378b
3 changed files with 80 additions and 48 deletions

View File

@ -948,7 +948,6 @@ define(function(require) {
var actionCfg = actions[action];
var notify = actionCfg.notify;
var condition = actionCfg["condition"];
//Is the condition to run the action met?
@ -965,67 +964,78 @@ define(function(require) {
var err = actionCfg["error"];
switch (actionCfg.type){
case "create":
case "register":
call({data:dataArg, success: callback, error:err});
case "create":
case "register":
call({data:dataArg, success: callback, error:err});
break;
case "single":
if (extraParam !== undefined) {
case "single":
if (extraParam !== undefined) {
call({
data:{
id:dataArg,
extra_param: extraParam
},
success: callback,
error: err
});
} else {
call({
data:{
id:dataArg
},
success: callback,
error:err
});
};
break;
case "list":
call({success: callback, error:err, options:dataArg});
break;
case "monitor_global":
call({
data:{
id:dataArg,
extra_param: extraParam
},
success: callback, error:err
});
} else {
call({data:{id:dataArg}, success: callback, error:err});
};
break;
case "list":
call({success: callback, error:err, options:dataArg});
break;
case "monitor_global":
call({
timeout: true,
success: callback,
error:err,
data: {monitor: dataArg}});
break;
case "monitor":
case "monitor_single":
call({
case "monitor":
case "monitor_single":
call({
timeout: true,
success: callback,
error:err,
data: {id:dataArg, monitor: extraParam}});
break;
case "multiple":
$.each(dataArg, function() {
if (extraParam) {
call({
data:{
id:this,
extra_param:extraParam
},
success: callback,
error: err});
case "multiple":
$.each(dataArg, function() {
if (extraParam) {
call({
data:{
id:this,
extra_param:extraParam
},
success: callback,
error: err
});
} else {
call({
data:{id:this},
success: callback,
error:err});
data:{
id:this
},
success: callback,
error: err
});
}
});
break;
default:
if (dataArg && extraParam) {
call(dataArg, extraParam);
} else if (dataArg) {
call(dataArg);
} else {
call();
}
default:
if (dataArg && extraParam) {
call(dataArg, extraParam);
} else if (dataArg) {
call(dataArg);
} else {
call();
}
}
if (notify) {

View File

@ -40,7 +40,7 @@ define(function(require) {
"ServiceTemplate.create" : _commonActions.create(CREATE_DIALOG_ID),
"ServiceTemplate.show" : _commonActions.show(),
"ServiceTemplate.refresh" : _commonActions.refresh(),
"ServiceTemplate.delete" : _commonActions.del(),
"ServiceTemplate.delete" : _commonActions.delWithoutRedirect(),
"ServiceTemplate.chown": _commonActions.multipleAction("chown"),
"ServiceTemplate.chgrp": _commonActions.multipleAction("chgrp"),
"ServiceTemplate.chmod": _commonActions.singleAction("chmod"),

View File

@ -34,6 +34,7 @@ define(function(require) {
CommonActions.prototype.list = _list;
CommonActions.prototype.show = _show;
CommonActions.prototype.refresh = _refresh;
CommonActions.prototype.delWithoutRedirect = _delWithoutRedirect;
CommonActions.prototype.del = _del;
CommonActions.prototype.multipleAction = _multipleAction;
CommonActions.prototype.singleAction = _singleAction;
@ -115,6 +116,27 @@ define(function(require) {
};
}
function _delWithoutRedirect() {
var that = this;
return {
type: "multiple",
call : that.openNebulaResource.del,
callback : function(request, response) {
var tab = $("#" + that.tabId);
if (Sunstone.getTab() == that.tabId) {
Sunstone.showTab(that.tabId);
}
},
elements: function(opts) {
return Sunstone.getDataTable(that.tabId).elements(opts);
},
error: function(req, res){
Notifier.notifyError(res && res.error && res.error.message);
},
notify: true
};
}
function _multipleAction(actionStr, notify) {
notify_bool = true;
if(notify != undefined){
@ -214,7 +236,7 @@ define(function(require) {
call: function() {
var selectedNodes = Sunstone.getDataTable(that.tabId).elements();
if (selectedNodes.length != 1) {
Notifier.notifyMessage("Please select one (and just one) resource to update.");
Notifier.notifyMessage(Locale.tr("Please select one (and just one) resource to update."));
return false;
}
@ -232,7 +254,7 @@ define(function(require) {
call: function() {
var selectedNodes = Sunstone.getDataTable(that.tabId).elements();
if (selectedNodes.length != 1) {
Notifier.notifyMessage("Please select one (and just one) resource to update.");
Notifier.notifyMessage(Locale.tr("Please select one (and just one) resource to update."));
return false;
}