Merge "Remove node-action deleteNodes/deletePorts functions"

This commit is contained in:
Jenkins 2017-02-03 09:27:53 +00:00 committed by Gerrit Code Review
commit 1e879996ff
4 changed files with 49 additions and 104 deletions

View File

@ -20,34 +20,6 @@
var POWER_STATE_ON = 'power on';
var POWER_STATE_OFF = 'power off';
var DELETE_NODE_TITLE = gettext("Delete Node");
var DELETE_NODE_MSG =
gettext('Are you sure you want to delete node "%s"? ' +
'This action cannot be undone.');
var DELETE_NODE_SUCCESS = gettext('Successfully deleted node "%s"');
var DELETE_NODE_ERROR = gettext('Unable to delete node "%s"');
var DELETE_NODES_TITLE = gettext("Delete Nodes");
var DELETE_NODES_MSG =
gettext('Are you sure you want to delete nodes "%s"? ' +
'This action cannot be undone.');
var DELETE_NODES_SUCCESS = gettext('Successfully deleted nodes "%s"');
var DELETE_NODES_ERROR = gettext('Error deleting nodes "%s"');
var DELETE_PORT_TITLE = gettext("Delete Port");
var DELETE_PORT_MSG =
gettext('Are you sure you want to delete port "%s"? ' +
'This action cannot be undone.');
var DELETE_PORT_SUCCESS = gettext('Successfully deleted port "%s"');
var DELETE_PORT_ERROR = gettext('Unable to delete port "%s"');
var DELETE_PORTS_TITLE = gettext("Delete Ports");
var DELETE_PORTS_MSG =
gettext('Are you sure you want to delete ports "%s"? ' +
'This action cannot be undone.');
var DELETE_PORTS_SUCCESS = gettext('Successfully deleted ports "%s"');
var DELETE_PORTS_ERROR = gettext('Error deleting ports "%s"');
angular
.module('horizon.dashboard.admin.ironic')
.factory('horizon.dashboard.admin.ironic.actions', actions);
@ -72,9 +44,7 @@
var service = {
createPort: createPort,
deleteNode: deleteNode,
deleteNodes: deleteNodes,
deletePort: deletePort,
deletePorts: deletePorts,
powerOn: powerOn,
powerOff: powerOff,
powerOnAll: powerOnNodes,
@ -88,32 +58,27 @@
return service;
function deleteNode(node) {
var labels = {
title: DELETE_NODE_TITLE,
message: DELETE_NODE_MSG,
submit: DELETE_NODE_TITLE,
success: DELETE_NODE_SUCCESS,
error: DELETE_NODE_ERROR
};
function deleteNode(nodes) {
var context = {
labels: labels,
deleteEntity: ironic.deleteNode,
successEvent: ironicEvents.DELETE_NODE_SUCCESS
};
return deleteModalService.open($rootScope, [node], context);
}
function deleteNodes(nodes) {
var labels = {
title: DELETE_NODES_TITLE,
message: DELETE_NODES_MSG,
submit: DELETE_NODES_TITLE,
success: DELETE_NODES_SUCCESS,
error: DELETE_NODES_ERROR
};
var context = {
labels: labels,
labels: {
title: ngettext("Delete Node",
"Delete Nodes",
nodes.length),
message: ngettext('Are you sure you want to delete node "%s"? ' +
'This action cannot be undone.',
'Are you sure you want to delete nodes "%s"? ' +
'This action cannot be undone.',
nodes.length),
submit: ngettext("Delete Node",
"Delete Nodes",
nodes.length),
success: ngettext('Successfully deleted node "%s"',
'Successfully deleted nodes "%s"',
nodes.length),
error: ngettext('Unable to delete node "%s"',
'Unable to delete nodes "%s"',
nodes.length)
},
deleteEntity: ironic.deleteNode,
successEvent: ironicEvents.DELETE_NODE_SUCCESS
};
@ -210,32 +175,27 @@
return createPortService.modal(node);
}
function deletePort(port) {
var labels = {
title: DELETE_PORT_TITLE,
message: DELETE_PORT_MSG,
submit: DELETE_PORT_TITLE,
success: DELETE_PORT_SUCCESS,
error: DELETE_PORT_ERROR
};
function deletePort(ports) {
var context = {
labels: labels,
deleteEntity: ironic.deletePort,
successEvent: ironicEvents.DELETE_PORT_SUCCESS
};
return deleteModalService.open($rootScope, [port], context);
}
function deletePorts(ports) {
var labels = {
title: DELETE_PORTS_TITLE,
message: DELETE_PORTS_MSG,
submit: DELETE_PORTS_TITLE,
success: DELETE_PORTS_SUCCESS,
error: DELETE_PORTS_ERROR
};
var context = {
labels: labels,
labels: {
title: ngettext("Delete Port",
"Delete Ports",
ports.length),
message: ngettext('Are you sure you want to delete port "%s"? ' +
'This action cannot be undone.',
'Are you sure you want to delete ports "%s"? ' +
'This action cannot be undone.',
ports.length),
submit: ngettext("Delete Port",
"Delete Ports",
ports.length),
success: ngettext('Successfully deleted port "%s"',
'Successfully deleted ports "%s"',
ports.length),
error: ngettext('Unable to delete port "%s"',
'Unable to delete portss "%s"',
ports.length)
},
deleteEntity: ironic.deletePort,
successEvent: ironicEvents.DELETE_PORT_SUCCESS
};

View File

@ -81,7 +81,6 @@
ctrl.editNode = editNode;
ctrl.createPort = createPort;
ctrl.deletePort = deletePort;
ctrl.deletePorts = deletePorts;
ctrl.refresh = refresh;
var editNodeHandler =
@ -161,6 +160,7 @@
ctrl.portsSrc = response.data.items;
ctrl.portsSrc.forEach(function(port) {
port.id = port.uuid;
port.name = port.address;
});
});
}
@ -216,28 +216,13 @@
/**
* @name horizon.dashboard.admin.ironic.NodeDetailsController.deletePort
* @description Delete a specified port
* @description Delete a list of ports
*
* @param {port []} port port to be deleted
* @param {port []} ports ports to be deleted
* @return {void}
*/
function deletePort(port) {
ctrl.actions.deletePort({id: port.uuid, name: port.address});
}
/**
* @name horizon.dashboard.admin.ironic.NodeDetailsController.deletePorts
* @description Delete a specified list of ports
*
* @param {port []} ports list of ports to be deleted
* @return {void}
*/
function deletePorts(ports) {
var selectedPorts = [];
angular.forEach(ports, function(port) {
selectedPorts.push({id: port.uuid, name: port.address});
});
ctrl.actions.deletePorts(selectedPorts);
function deletePort(ports) {
actions.deletePort(ports);
}
/**

View File

@ -33,7 +33,7 @@
</action>
<menu>
<action button-type="menu-item"
callback="ctrl.deletePorts"
callback="ctrl.deletePort"
item="tCtrl.selected"
disabled="tCtrl.selected.length === 0">
<span class="fa fa-trash"></span>
@ -88,7 +88,7 @@
<action-list>
<action action-classes="'btn btn-default btn-sm'"
callback="ctrl.deletePort"
item="port">
item="[port]">
<span class="fa fa-trash"></span>
</action>
</action-list>

View File

@ -57,7 +57,7 @@
{$ 'Maintenance off' | translate $}
</action>
<action button-type="menu-item"
callback="table.actions.deleteNodes"
callback="table.actions.deleteNode"
item="tCtrl.selected"
disabled="tCtrl.selected.length === 0">
<span class="fa fa-trash"></span>
@ -163,7 +163,7 @@
<action button-type="menu-item"
callback="table.actions.deleteNode"
disabled="!(node.provision_state === 'available' || node.provision_state === 'nostate' || node.provision_state === 'manageable' || node.provision_state === 'enroll')"
item="node">
item="[node]">
<span class="fa fa-trash"></span>
{$ 'Delete node' | translate $}
</action>