diff --git a/zun_ui/static/dashboard/container/containers/actions.module.js b/zun_ui/static/dashboard/container/containers/actions.module.js index 48f83f2..73bea63 100644 --- a/zun_ui/static/dashboard/container/containers/actions.module.js +++ b/zun_ui/static/dashboard/container/containers/actions.module.js @@ -42,6 +42,7 @@ 'horizon.dashboard.container.containers.unpause.service', 'horizon.dashboard.container.containers.execute.service', 'horizon.dashboard.container.containers.kill.service', + 'horizon.dashboard.container.containers.refresh.service', 'horizon.dashboard.container.containers.resourceType' ]; @@ -58,6 +59,7 @@ unpauseContainerService, executeContainerService, killContainerService, + refreshContainerService, resourceType ) { var containersResourceType = registry.getResourceType(resourceType); @@ -83,6 +85,13 @@ }); containersResourceType.itemActions + .append({ + id: 'refreshContainerAction', + service: refreshContainerService, + template: { + text: gettext('Refresh') + } + }) .append({ id: 'startContainerAction', service: startContainerService, diff --git a/zun_ui/static/dashboard/container/containers/containers.service.js b/zun_ui/static/dashboard/container/containers/containers.service.js index c81b8ad..020291e 100644 --- a/zun_ui/static/dashboard/container/containers/containers.service.js +++ b/zun_ui/static/dashboard/container/containers/containers.service.js @@ -74,8 +74,6 @@ return {data: {items: response.data.items.map(modifyItem)}}; function modifyItem(item) { - // we should set 'trackBy' as follows ideally. - // var timestamp = item.updated_at ? item.updated_at : item.created_at; var timestamp = new Date(); item.trackBy = item.id.concat(timestamp.getTime()); return item; diff --git a/zun_ui/static/dashboard/container/containers/details/overview.controller.js b/zun_ui/static/dashboard/container/containers/details/overview.controller.js index f59cc96..eb6aab7 100644 --- a/zun_ui/static/dashboard/container/containers/details/overview.controller.js +++ b/zun_ui/static/dashboard/container/containers/details/overview.controller.js @@ -26,6 +26,7 @@ $scope ) { var ctrl = this; + $scope.context.loadPromise.then(onGetContainer); function onGetContainer(container) { diff --git a/zun_ui/static/dashboard/container/containers/operations/execute.service.js b/zun_ui/static/dashboard/container/containers/operations/execute.service.js index 723d3dc..adc18b8 100644 --- a/zun_ui/static/dashboard/container/containers/operations/execute.service.js +++ b/zun_ui/static/dashboard/container/containers/operations/execute.service.js @@ -29,6 +29,8 @@ executeContainerService.$inject = [ 'horizon.app.core.openstack-service-api.zun', + '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', @@ -36,7 +38,7 @@ ]; function executeContainerService( - zun, gettext, $qExtensions, modal, toast + zun, resourceType, actionResult, gettext, $qExtensions, modal, toast ) { // schema var schema = { @@ -112,6 +114,8 @@ delete context.model.name; return zun.executeContainer(id, context.model).then(function() { toast.add('success', interpolate(message.success, [name])); + var result = actionResult.getActionResult().updated(resourceType, id); + return result.result; }); } } diff --git a/zun_ui/static/dashboard/container/containers/operations/kill.service.js b/zun_ui/static/dashboard/container/containers/operations/kill.service.js index edaaa8d..f1c8919 100644 --- a/zun_ui/static/dashboard/container/containers/operations/kill.service.js +++ b/zun_ui/static/dashboard/container/containers/operations/kill.service.js @@ -30,6 +30,8 @@ killContainerService.$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', @@ -37,7 +39,7 @@ ]; function killContainerService( - zun, basePath, gettext, $qExtensions, modal, toast + zun, basePath, resourceType, actionResult, gettext, $qExtensions, modal, toast ) { // schema var schema = { @@ -122,6 +124,8 @@ delete context.model.name; return zun.killContainer(id, context.model).then(function() { toast.add('success', interpolate(message.success, [name])); + var result = actionResult.getActionResult().updated(resourceType, id); + return result.result; }); } } diff --git a/zun_ui/static/dashboard/container/containers/operations/pause.service.js b/zun_ui/static/dashboard/container/containers/operations/pause.service.js index bb1d78c..7fa67c4 100644 --- a/zun_ui/static/dashboard/container/containers/operations/pause.service.js +++ b/zun_ui/static/dashboard/container/containers/operations/pause.service.js @@ -26,12 +26,16 @@ .factory('horizon.dashboard.container.containers.pause.service', pauseService); pauseService.$inject = [ + 'horizon.app.core.openstack-service-api.zun', + 'horizon.dashboard.container.containers.resourceType', + 'horizon.framework.util.actions.action-result.service', 'horizon.framework.util.q.extensions', - 'horizon.framework.widgets.toast.service', - 'horizon.app.core.openstack-service-api.zun' + 'horizon.framework.widgets.toast.service' ]; - function pauseService($qExtensions, toast, zun) { + function pauseService( + zun, resourceType, actionResult, $qExtensions, toast + ) { var message = { success: gettext('Container %s was successfully paused.') @@ -62,6 +66,8 @@ function success() { toast.add('success', interpolate(message.success, [selected.name])); + var result = actionResult.getActionResult().updated(resourceType, selected.id); + return result.result; } } } diff --git a/zun_ui/static/dashboard/container/containers/operations/reboot.service.js b/zun_ui/static/dashboard/container/containers/operations/reboot.service.js index 8f87e31..9cd0c20 100644 --- a/zun_ui/static/dashboard/container/containers/operations/reboot.service.js +++ b/zun_ui/static/dashboard/container/containers/operations/reboot.service.js @@ -26,13 +26,15 @@ .factory('horizon.dashboard.container.containers.reboot.service', rebootService); rebootService.$inject = [ + 'horizon.app.core.openstack-service-api.zun', + 'horizon.dashboard.container.containers.resourceType', + 'horizon.framework.util.actions.action-result.service', 'horizon.framework.util.q.extensions', - 'horizon.framework.widgets.toast.service', - 'horizon.app.core.openstack-service-api.zun' + 'horizon.framework.widgets.toast.service' ]; function rebootService( - $qExtensions, toast, zun + zun, resourceType, actionResult, $qExtensions, toast ) { var message = { @@ -60,8 +62,10 @@ function perform(selected) { // reboot selected container - return zun.rebootContainer(selected.id).success(function() { + 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; }); } } diff --git a/zun_ui/static/dashboard/container/containers/operations/refresh.service.js b/zun_ui/static/dashboard/container/containers/operations/refresh.service.js new file mode 100644 index 0000000..8af0f6d --- /dev/null +++ b/zun_ui/static/dashboard/container/containers/operations/refresh.service.js @@ -0,0 +1,68 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use self file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngDoc factory + * @name horizon.dashboard.container.containers.refresh.service + * @Description + * refresh container. + */ + angular + .module('horizon.dashboard.container.containers') + .factory('horizon.dashboard.container.containers.refresh.service', refreshService); + + refreshService.$inject = [ + 'horizon.app.core.openstack-service-api.zun', + 'horizon.dashboard.container.containers.resourceType', + 'horizon.framework.util.actions.action-result.service', + 'horizon.framework.util.q.extensions' + ]; + + function refreshService( + zun, resourceType, actionResult, $qExtensions + ) { + + var service = { + initAction: initAction, + allowed: allowed, + perform: perform + }; + + return service; + + ////////////// + + // include this function in your service + // if you plan to emit events to the parent controller + function initAction() { + } + + function allowed() { + return $qExtensions.booleanAsPromise(true); + } + + function perform(selected) { + // refresh selected container + return $qExtensions.booleanAsPromise(true).then(success); + + function success() { + var result = actionResult.getActionResult().updated(resourceType, selected.id); + return result.result; + } + } + } +})(); diff --git a/zun_ui/static/dashboard/container/containers/operations/start.service.js b/zun_ui/static/dashboard/container/containers/operations/start.service.js index d24342f..5e8a804 100644 --- a/zun_ui/static/dashboard/container/containers/operations/start.service.js +++ b/zun_ui/static/dashboard/container/containers/operations/start.service.js @@ -26,13 +26,15 @@ .factory('horizon.dashboard.container.containers.start.service', startService); startService.$inject = [ + 'horizon.app.core.openstack-service-api.zun', + 'horizon.dashboard.container.containers.resourceType', + 'horizon.framework.util.actions.action-result.service', 'horizon.framework.util.q.extensions', - 'horizon.framework.widgets.toast.service', - 'horizon.app.core.openstack-service-api.zun' + 'horizon.framework.widgets.toast.service' ]; function startService( - $qExtensions, toast, zun + zun, resourceType, actionResult, $qExtensions, toast ) { var message = { @@ -60,8 +62,10 @@ function perform(selected) { // start selected container - return zun.startContainer(selected.id).success(function() { + return zun.startContainer(selected.id).then(function() { toast.add('success', interpolate(message.success, [selected.name])); + var result = actionResult.getActionResult().updated(resourceType, selected.id); + return result.result; }); } } diff --git a/zun_ui/static/dashboard/container/containers/operations/stop.service.js b/zun_ui/static/dashboard/container/containers/operations/stop.service.js index 43db7fd..9dbe154 100644 --- a/zun_ui/static/dashboard/container/containers/operations/stop.service.js +++ b/zun_ui/static/dashboard/container/containers/operations/stop.service.js @@ -26,13 +26,15 @@ .factory('horizon.dashboard.container.containers.stop.service', stopService); stopService.$inject = [ + 'horizon.app.core.openstack-service-api.zun', + 'horizon.dashboard.container.containers.resourceType', + 'horizon.framework.util.actions.action-result.service', 'horizon.framework.util.q.extensions', - 'horizon.framework.widgets.toast.service', - 'horizon.app.core.openstack-service-api.zun' + 'horizon.framework.widgets.toast.service' ]; function stopService( - $qExtensions, toast, zun + zun, resourceType, actionResult, $qExtensions, toast ) { var message = { @@ -60,8 +62,10 @@ function perform(selected) { // start selected container - return zun.stopContainer(selected.id).success(function() { + 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; }); } } diff --git a/zun_ui/static/dashboard/container/containers/operations/unpause.service.js b/zun_ui/static/dashboard/container/containers/operations/unpause.service.js index 1f84f93..6b7c7a6 100644 --- a/zun_ui/static/dashboard/container/containers/operations/unpause.service.js +++ b/zun_ui/static/dashboard/container/containers/operations/unpause.service.js @@ -26,13 +26,15 @@ .factory('horizon.dashboard.container.containers.unpause.service', unpauseService); unpauseService.$inject = [ + 'horizon.app.core.openstack-service-api.zun', + 'horizon.dashboard.container.containers.resourceType', + 'horizon.framework.util.actions.action-result.service', 'horizon.framework.util.q.extensions', - 'horizon.framework.widgets.toast.service', - 'horizon.app.core.openstack-service-api.zun' + 'horizon.framework.widgets.toast.service' ]; function unpauseService( - $qExtensions, toast, zun + zun, resourceType, actionResult, $qExtensions, toast ) { var message = { @@ -60,9 +62,13 @@ function perform(selected) { // unpause selected container - return zun.unpauseContainer(selected.id).success(function() { + return zun.unpauseContainer(selected.id).then(success); + + function success() { toast.add('success', interpolate(message.success, [selected.name])); - }); + var result = actionResult.getActionResult().updated(resourceType, selected.id); + return result.result; + } } } })();