Merge "Add Create Bay action into BayModel item action"

This commit is contained in:
Jenkins 2016-03-06 08:09:40 +00:00 committed by Gerrit Code Review
commit 9d81ce798e
7 changed files with 39 additions and 10 deletions

View File

@ -30,6 +30,7 @@
'horizon.framework.util.i18n.gettext',
'horizon.dashboard.containers.baymodels.create.service',
'horizon.dashboard.containers.baymodels.delete.service',
'horizon.dashboard.containers.bays.create.service',
'horizon.dashboard.containers.baymodels.resourceType',
];
@ -38,10 +39,18 @@
gettext,
createBayModelService,
deleteBayModelService,
createBayService,
resourceType)
{
var baymodelResourceType = registry.getResourceType(resourceType);
baymodelResourceType.itemActions
.append({
id: 'createBayAction',
service: createBayService,
template: {
text: gettext('Create Bay')
}
})
.append({
id: 'deleteBayModelAction',
service: deleteBayModelService,

View File

@ -28,11 +28,12 @@
'horizon.app.core.openstack-service-api.magnum',
'horizon.app.core.openstack-service-api.glance',
'horizon.dashboard.containers.baymodels.events',
'horizon.dashboard.containers.bays.events',
'horizon.framework.conf.resource-type-registry.service',
'horizon.dashboard.containers.baymodels.resourceType'
];
function BayModelDetailController($scope, $window, $location, $routeParams, magnum, glance, events, registry, baymodelResourceType) {
function BayModelDetailController($scope, $window, $location, $routeParams, magnum, glance, events, bayEvents, registry, baymodelResourceType) {
var ctrl = this;
ctrl.baymodel = {};
ctrl.image_uuid;
@ -41,6 +42,7 @@
var baymodelId = $routeParams.baymodelId;
var deleteWatcher = $scope.$on(events.DELETE_SUCCESS, onDeleteSuccess);
var createBayWatcher = $scope.$on(bayEvents.CREATE_SUCCESS, onCreateBaySuccess);
$scope.$on('$destroy', destroy);
@ -66,13 +68,19 @@
});
}
function onDeleteSuccess(e, removedIds){
$location.path('/project/baymodels');
function onDeleteSuccess(e, removedIds) {
e.stopPropagation();
$location.path("/project/baymodels");
}
function onCreateBaySuccess(e, createdItem) {
e.stopPropagation();
$location.path("/project/bays");
}
function destroy() {
deleteWatcher();
createBayWatcher();
}
}
})();

View File

@ -31,13 +31,15 @@
containersBayModelsTableController.$inject = [
'$scope',
'$location',
'horizon.app.core.openstack-service-api.magnum',
'horizon.dashboard.containers.baymodels.events',
'horizon.dashboard.containers.bays.events',
'horizon.framework.conf.resource-type-registry.service',
'horizon.dashboard.containers.baymodels.resourceType'
];
function containersBayModelsTableController($scope, magnum, events, registry, baymodelResourceType) {
function containersBayModelsTableController($scope, $location, magnum, events, bayEvents, registry, baymodelResourceType) {
var ctrl = this;
ctrl.baymodels = [];
ctrl.baymodelsSrc = [];
@ -66,6 +68,7 @@
];
var createWatcher = $scope.$on(events.CREATE_SUCCESS, onCreateSuccess);
var createBayWatcher = $scope.$on(bayEvents.CREATE_SUCCESS, onCreateBaySuccess);
var deleteWatcher = $scope.$on(events.DELETE_SUCCESS, onDeleteSuccess);
$scope.$on('$destroy', destroy);
@ -86,6 +89,11 @@
ctrl.baymodelsSrc.push(createdItem);
}
function onCreateBaySuccess(e, createdItem) {
e.stopPropagation();
$location.path("/project/bays");
}
function onDeleteSuccess(e, removedIds) {
ctrl.baymodelsSrc = difference(ctrl.baymodelsSrc, removedIds, 'id');
e.stopPropagation();

View File

@ -19,7 +19,7 @@
angular
.module('horizon.dashboard.containers.bays')
.factory('bayModel', bayModel);
.factory('horizon.dashboard.containers.bays.bayModel', bayModel);
bayModel.$inject = [
'horizon.app.core.openstack-service-api.magnum'

View File

@ -25,7 +25,7 @@
.factory('horizon.dashboard.containers.bays.create.service', createService);
createService.$inject = [
'bayModel',
'horizon.dashboard.containers.bays.bayModel',
'horizon.framework.widgets.modal.wizard-modal.service',
'horizon.framework.widgets.toast.service',
'horizon.dashboard.containers.bays.workflow',
@ -63,8 +63,9 @@
});
}
function perform() {
function perform(selected) {
scope.model.init();
scope.selected = selected;
wizardModalService.modal({
scope: scope,
workflow: createWorkflow,
@ -72,7 +73,7 @@
});
}
function allowed() {
function allowed(selected) {
return $qExtensions.booleanAsPromise(true);
}

View File

@ -84,6 +84,10 @@
function onGetBayModels(response) {
Array.prototype.push.apply(ctrl.baymodels, response.items);
if($scope.selected instanceof Object){
$scope.model.newBaySpec.baymodel_id = $scope.selected.id;
$scope.changeBayModel();
}
}
}

View File

@ -80,7 +80,6 @@
}
}
function labelize(count){
return {
title: ngettext('Confirm Delete Bay',