Add dialogs for stop/reboot actions
This patch adds dialogs for stop and reboot actions to specify timeout attribute. Change-Id: I4d7e92441dd976d6974c7b8ad84a5338b420c9d6
This commit is contained in:
parent
5160eaddf4
commit
9d61096c2c
@ -64,10 +64,10 @@ class ContainerActions(generic.View):
|
||||
if action == 'start':
|
||||
return client.container_start(request, id)
|
||||
elif action == 'stop':
|
||||
timeout = 10
|
||||
timeout = request.DATA.get("timeout") or 10
|
||||
return client.container_stop(request, id, timeout)
|
||||
elif action == 'reboot':
|
||||
timeout = 10
|
||||
timeout = request.DATA.get("timeout") or 10
|
||||
return client.container_reboot(request, id, timeout)
|
||||
elif action == 'pause':
|
||||
return client.container_pause(request, id)
|
||||
|
@ -27,15 +27,52 @@
|
||||
|
||||
rebootService.$inject = [
|
||||
'horizon.app.core.openstack-service-api.zun',
|
||||
'horizon.dashboard.container.containers.basePath',
|
||||
'horizon.dashboard.container.containers.resourceType',
|
||||
'horizon.framework.util.actions.action-result.service',
|
||||
'horizon.framework.util.i18n.gettext',
|
||||
'horizon.framework.util.q.extensions',
|
||||
'horizon.framework.widgets.form.ModalFormService',
|
||||
'horizon.framework.widgets.toast.service'
|
||||
];
|
||||
|
||||
function rebootService(
|
||||
zun, resourceType, actionResult, $qExtensions, toast
|
||||
zun, basePath, resourceType, actionResult, gettext, $qExtensions, modal, toast
|
||||
) {
|
||||
// schema
|
||||
var schema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
timeout: {
|
||||
title: gettext("Reboot Container"),
|
||||
type: "number",
|
||||
minimum: 1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// form
|
||||
var form = [
|
||||
{
|
||||
type: 'section',
|
||||
htmlClass: 'row',
|
||||
items: [
|
||||
{
|
||||
type: 'section',
|
||||
htmlClass: 'col-sm-12',
|
||||
items: [
|
||||
{
|
||||
"key": "timeout",
|
||||
"placeholder": gettext("Specify a shutdown timeout in seconds. (default: 10)")
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// model
|
||||
var model;
|
||||
|
||||
var message = {
|
||||
success: gettext('Container %s was successfully rebooted.')
|
||||
@ -61,12 +98,32 @@
|
||||
}
|
||||
|
||||
function perform(selected) {
|
||||
// reboot selected container
|
||||
return zun.rebootContainer(selected.id).then(function() {
|
||||
toast.add('success', interpolate(message.success, [selected.name]));
|
||||
var result = actionResult.getActionResult().updated(resourceType, selected.id);
|
||||
return result.result;
|
||||
});
|
||||
model = {
|
||||
id: selected.id,
|
||||
name: selected.name,
|
||||
timeout: null
|
||||
};
|
||||
// modal config
|
||||
var config = {
|
||||
"title": gettext('Reboot Container'),
|
||||
"submitText": gettext('Reboot'),
|
||||
"schema": schema,
|
||||
"form": form,
|
||||
"model": model
|
||||
};
|
||||
return modal.open(config).then(submit);
|
||||
|
||||
function submit(context) {
|
||||
var id = context.model.id;
|
||||
var name = context.model.name;
|
||||
delete context.model.id;
|
||||
delete context.model.name;
|
||||
return zun.rebootContainer(id, context.model).then(function() {
|
||||
toast.add('success', interpolate(message.success, [name]));
|
||||
var result = actionResult.getActionResult().updated(resourceType, id);
|
||||
return result.result;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
@ -27,15 +27,52 @@
|
||||
|
||||
stopService.$inject = [
|
||||
'horizon.app.core.openstack-service-api.zun',
|
||||
'horizon.dashboard.container.containers.basePath',
|
||||
'horizon.dashboard.container.containers.resourceType',
|
||||
'horizon.framework.util.actions.action-result.service',
|
||||
'horizon.framework.util.i18n.gettext',
|
||||
'horizon.framework.util.q.extensions',
|
||||
'horizon.framework.widgets.form.ModalFormService',
|
||||
'horizon.framework.widgets.toast.service'
|
||||
];
|
||||
|
||||
function stopService(
|
||||
zun, resourceType, actionResult, $qExtensions, toast
|
||||
zun, basePath, resourceType, actionResult, gettext, $qExtensions, modal, toast
|
||||
) {
|
||||
// schema
|
||||
var schema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
timeout: {
|
||||
title: gettext("Stop Container"),
|
||||
type: "number",
|
||||
minimum: 1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// form
|
||||
var form = [
|
||||
{
|
||||
type: 'section',
|
||||
htmlClass: 'row',
|
||||
items: [
|
||||
{
|
||||
type: 'section',
|
||||
htmlClass: 'col-sm-12',
|
||||
items: [
|
||||
{
|
||||
"key": "timeout",
|
||||
"placeholder": gettext("Specify a shutdown timeout in seconds. (default: 10)")
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// model
|
||||
var model;
|
||||
|
||||
var message = {
|
||||
success: gettext('Container %s was successfully stoped.')
|
||||
@ -61,12 +98,32 @@
|
||||
}
|
||||
|
||||
function perform(selected) {
|
||||
// start selected container
|
||||
return zun.stopContainer(selected.id).then(function() {
|
||||
toast.add('success', interpolate(message.success, [selected.name]));
|
||||
var result = actionResult.getActionResult().updated(resourceType, selected.id);
|
||||
return result.result;
|
||||
});
|
||||
model = {
|
||||
id: selected.id,
|
||||
name: selected.name,
|
||||
timeout: null
|
||||
};
|
||||
// modal config
|
||||
var config = {
|
||||
"title": gettext('Stop Container'),
|
||||
"submitText": gettext('Stop'),
|
||||
"schema": schema,
|
||||
"form": form,
|
||||
"model": model
|
||||
};
|
||||
return modal.open(config).then(submit);
|
||||
|
||||
function submit(context) {
|
||||
var id = context.model.id;
|
||||
var name = context.model.name;
|
||||
delete context.model.id;
|
||||
delete context.model.name;
|
||||
return zun.stopContainer(id, context.model).then(function() {
|
||||
toast.add('success', interpolate(message.success, [name]));
|
||||
var result = actionResult.getActionResult().updated(resourceType, id);
|
||||
return result.result;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
@ -91,9 +91,9 @@
|
||||
return apiService.post(containersPath + id + '/start').error(error(msg));
|
||||
}
|
||||
|
||||
function stopContainer(id) {
|
||||
function stopContainer(id, params) {
|
||||
var msg = gettext('Unable to stop Container.');
|
||||
return apiService.post(containersPath + id + '/stop').error(error(msg));
|
||||
return apiService.post(containersPath + id + '/stop', params).error(error(msg));
|
||||
}
|
||||
|
||||
function logsContainer(id) {
|
||||
@ -101,9 +101,9 @@
|
||||
return apiService.get(containersPath + id + '/logs').error(error(msg));
|
||||
}
|
||||
|
||||
function rebootContainer(id) {
|
||||
function rebootContainer(id, params) {
|
||||
var msg = gettext('Unable to reboot Container.');
|
||||
return apiService.post(containersPath + id + '/reboot').error(error(msg));
|
||||
return apiService.post(containersPath + id + '/reboot', params).error(error(msg));
|
||||
}
|
||||
|
||||
function pauseContainer(id) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user