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':
|
if action == 'start':
|
||||||
return client.container_start(request, id)
|
return client.container_start(request, id)
|
||||||
elif action == 'stop':
|
elif action == 'stop':
|
||||||
timeout = 10
|
timeout = request.DATA.get("timeout") or 10
|
||||||
return client.container_stop(request, id, timeout)
|
return client.container_stop(request, id, timeout)
|
||||||
elif action == 'reboot':
|
elif action == 'reboot':
|
||||||
timeout = 10
|
timeout = request.DATA.get("timeout") or 10
|
||||||
return client.container_reboot(request, id, timeout)
|
return client.container_reboot(request, id, timeout)
|
||||||
elif action == 'pause':
|
elif action == 'pause':
|
||||||
return client.container_pause(request, id)
|
return client.container_pause(request, id)
|
||||||
|
@ -27,15 +27,52 @@
|
|||||||
|
|
||||||
rebootService.$inject = [
|
rebootService.$inject = [
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.basePath',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.framework.util.actions.action-result.service',
|
'horizon.framework.util.actions.action-result.service',
|
||||||
|
'horizon.framework.util.i18n.gettext',
|
||||||
'horizon.framework.util.q.extensions',
|
'horizon.framework.util.q.extensions',
|
||||||
|
'horizon.framework.widgets.form.ModalFormService',
|
||||||
'horizon.framework.widgets.toast.service'
|
'horizon.framework.widgets.toast.service'
|
||||||
];
|
];
|
||||||
|
|
||||||
function rebootService(
|
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 = {
|
var message = {
|
||||||
success: gettext('Container %s was successfully rebooted.')
|
success: gettext('Container %s was successfully rebooted.')
|
||||||
@ -61,12 +98,32 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
// reboot selected container
|
model = {
|
||||||
return zun.rebootContainer(selected.id).then(function() {
|
id: selected.id,
|
||||||
toast.add('success', interpolate(message.success, [selected.name]));
|
name: selected.name,
|
||||||
var result = actionResult.getActionResult().updated(resourceType, selected.id);
|
timeout: null
|
||||||
return result.result;
|
};
|
||||||
});
|
// 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 = [
|
stopService.$inject = [
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.basePath',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.framework.util.actions.action-result.service',
|
'horizon.framework.util.actions.action-result.service',
|
||||||
|
'horizon.framework.util.i18n.gettext',
|
||||||
'horizon.framework.util.q.extensions',
|
'horizon.framework.util.q.extensions',
|
||||||
|
'horizon.framework.widgets.form.ModalFormService',
|
||||||
'horizon.framework.widgets.toast.service'
|
'horizon.framework.widgets.toast.service'
|
||||||
];
|
];
|
||||||
|
|
||||||
function stopService(
|
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 = {
|
var message = {
|
||||||
success: gettext('Container %s was successfully stoped.')
|
success: gettext('Container %s was successfully stoped.')
|
||||||
@ -61,12 +98,32 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
// start selected container
|
model = {
|
||||||
return zun.stopContainer(selected.id).then(function() {
|
id: selected.id,
|
||||||
toast.add('success', interpolate(message.success, [selected.name]));
|
name: selected.name,
|
||||||
var result = actionResult.getActionResult().updated(resourceType, selected.id);
|
timeout: null
|
||||||
return result.result;
|
};
|
||||||
});
|
// 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));
|
return apiService.post(containersPath + id + '/start').error(error(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopContainer(id) {
|
function stopContainer(id, params) {
|
||||||
var msg = gettext('Unable to stop Container.');
|
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) {
|
function logsContainer(id) {
|
||||||
@ -101,9 +101,9 @@
|
|||||||
return apiService.get(containersPath + id + '/logs').error(error(msg));
|
return apiService.get(containersPath + id + '/logs').error(error(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
function rebootContainer(id) {
|
function rebootContainer(id, params) {
|
||||||
var msg = gettext('Unable to reboot Container.');
|
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) {
|
function pauseContainer(id) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user