Handle 400/500 error on execute dialog
If a 'exec' request returned 400/500, the UI doesn't handle it. This causes spinner remaining. This patch fixes the issue. Also, to ease to see status of exit code for command, change its container from readonly input text box to label. Change-Id: I833d5f448f5294ae8b537476e53643e35f25e7a2 Closes-Bug: #1682173
This commit is contained in:
parent
6644b6be77
commit
daa20b5483
@ -34,11 +34,12 @@
|
|||||||
'horizon.framework.util.i18n.gettext',
|
'horizon.framework.util.i18n.gettext',
|
||||||
'horizon.framework.util.q.extensions',
|
'horizon.framework.util.q.extensions',
|
||||||
'horizon.framework.widgets.form.ModalFormService',
|
'horizon.framework.widgets.form.ModalFormService',
|
||||||
'horizon.framework.widgets.modal-wait-spinner.service'
|
'horizon.framework.widgets.modal-wait-spinner.service',
|
||||||
|
'horizon.framework.widgets.toast.service'
|
||||||
];
|
];
|
||||||
|
|
||||||
function executeContainerService(
|
function executeContainerService(
|
||||||
zun, resourceType, actionResult, gettext, $qExtensions, modal, waitSpinner
|
zun, resourceType, actionResult, gettext, $qExtensions, modal, waitSpinner, toast
|
||||||
) {
|
) {
|
||||||
// schema
|
// schema
|
||||||
var schema = {
|
var schema = {
|
||||||
@ -48,10 +49,6 @@
|
|||||||
title: gettext("Command"),
|
title: gettext("Command"),
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
exit_code: {
|
|
||||||
title: gettext("Exit Code"),
|
|
||||||
type: "string"
|
|
||||||
},
|
|
||||||
output: {
|
output: {
|
||||||
title: gettext("Output"),
|
title: gettext("Output"),
|
||||||
type: "string"
|
type: "string"
|
||||||
@ -75,9 +72,9 @@
|
|||||||
placeholder: gettext("The command to execute."),
|
placeholder: gettext("The command to execute."),
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{ // for exit code
|
||||||
key: "exit_code",
|
type: "help",
|
||||||
readonly: true,
|
helpvalue: "",
|
||||||
condition: true
|
condition: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -94,9 +91,7 @@
|
|||||||
var model = {
|
var model = {
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
command: '',
|
command: ''
|
||||||
exit_code: '',
|
|
||||||
output: ''
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// modal config
|
// modal config
|
||||||
@ -109,7 +104,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
success: gettext("Command was successfully executed at container %s.")
|
success: gettext("Command was successfully executed at container %s."),
|
||||||
|
exit_code: gettext("Exit Code")
|
||||||
};
|
};
|
||||||
|
|
||||||
var service = {
|
var service = {
|
||||||
@ -133,7 +129,6 @@
|
|||||||
config.model.id = selected.id;
|
config.model.id = selected.id;
|
||||||
config.model.name = selected.name;
|
config.model.name = selected.name;
|
||||||
config.model.command = '';
|
config.model.command = '';
|
||||||
config.model.exit_code = '';
|
|
||||||
config.model.output = '';
|
config.model.output = '';
|
||||||
config.form = angular.copy(form);
|
config.form = angular.copy(form);
|
||||||
modal.open(config).then(submit);
|
modal.open(config).then(submit);
|
||||||
@ -144,7 +139,6 @@
|
|||||||
var name = context.model.name;
|
var name = context.model.name;
|
||||||
delete context.model.id;
|
delete context.model.id;
|
||||||
delete context.model.name;
|
delete context.model.name;
|
||||||
delete context.model.exit_code;
|
|
||||||
delete context.model.output;
|
delete context.model.output;
|
||||||
waitSpinner.showModalSpinner(gettext('Executing'));
|
waitSpinner.showModalSpinner(gettext('Executing'));
|
||||||
return zun.executeContainer(id, context.model).then(function(response) {
|
return zun.executeContainer(id, context.model).then(function(response) {
|
||||||
@ -152,7 +146,6 @@
|
|||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
command: context.model.command,
|
command: context.model.command,
|
||||||
exit_code: String(response.data.exit_code),
|
|
||||||
output: response.data.output
|
output: response.data.output
|
||||||
};
|
};
|
||||||
config.form = angular.copy(form);
|
config.form = angular.copy(form);
|
||||||
@ -168,7 +161,8 @@
|
|||||||
resClass = 'danger';
|
resClass = 'danger';
|
||||||
}
|
}
|
||||||
config.form[0].items[2].condition = false;
|
config.form[0].items[2].condition = false;
|
||||||
config.form[0].items[2].fieldHtmlClass = 'alert alert-' + resClass;
|
config.form[0].items[2].helpvalue = "<div class='alert alert-" + resClass + "'>" +
|
||||||
|
message.exit_code + " : " + String(response.data.exit_code) + "</div>";
|
||||||
|
|
||||||
// for output
|
// for output
|
||||||
config.form[0].items[3].condition = false;
|
config.form[0].items[3].condition = false;
|
||||||
@ -179,6 +173,12 @@
|
|||||||
|
|
||||||
var result = actionResult.getActionResult().updated(resourceType, id);
|
var result = actionResult.getActionResult().updated(resourceType, id);
|
||||||
return result.results;
|
return result.results;
|
||||||
|
}, function(response) {
|
||||||
|
// close spinner and dispaly toast
|
||||||
|
waitSpinner.hideModalSpinner();
|
||||||
|
toast.add('error', response.data.split("(")[0].trim() + ".");
|
||||||
|
var result = actionResult.getActionResult().failed(resourceType, id);
|
||||||
|
return result.results;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user