Added eslint config to ironic-ui
Set up package to use eslint-openstack-config for linting. Amended existing files to ensure they pass linting tests. Change-Id: I55dfe4cd9cdee99f19b80147df73f66951ca1372
This commit is contained in:
parent
429d56049f
commit
a4c47b80f7
2
.eslintignore
Normal file
2
.eslintignore
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
dist
|
23
.eslintrc
Normal file
23
.eslintrc
Normal file
@ -0,0 +1,23 @@
|
||||
# Enable eslint-plugin-angular
|
||||
plugins:
|
||||
- angular
|
||||
|
||||
extends: openstack
|
||||
|
||||
# Set up globals
|
||||
globals:
|
||||
angular: false
|
||||
module: false
|
||||
|
||||
env:
|
||||
browser: true
|
||||
jasmine: true
|
||||
|
||||
rules:
|
||||
angular/no-private-call: 0
|
||||
angular/no-services:
|
||||
- 2
|
||||
- - $http
|
||||
- $resource
|
||||
- Restangular
|
||||
angular/no-service-method: 0
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -55,3 +55,8 @@ ChangeLog
|
||||
|
||||
.secret_key_store
|
||||
*.lock
|
||||
|
||||
# Node generated files
|
||||
package/
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
@ -61,7 +61,7 @@
|
||||
return apiService.get('/api/ironic/nodes/')
|
||||
.error(function() {
|
||||
toastService.add('error', gettext('Unable to retrieve Ironic nodes.'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +90,7 @@
|
||||
|
||||
function getPortsWithNode(uuid) {
|
||||
var config = {
|
||||
'params' : {
|
||||
params : {
|
||||
node_id: uuid
|
||||
}
|
||||
};
|
||||
@ -103,14 +103,15 @@
|
||||
* @name horizon.app.core.openstack-service-api.ironic.putNodeInMaintenanceMode
|
||||
* @description Put the node in maintenance mode.
|
||||
*
|
||||
* http://docs.openstack.org/developer/ironic/webapi/v1.html#put--v1-nodes-(node_ident)-maintenance
|
||||
* \href{http://docs.openstack.org/developer/ironic/webapi/v1.html#
|
||||
* put--v1-nodes-(node_ident)-maintenance}
|
||||
*
|
||||
* @param {string} uuid – UUID or logical name of a node.
|
||||
*/
|
||||
|
||||
function putNodeInMaintenanceMode(uuid, reason) {
|
||||
var data = {
|
||||
maint_reason: (reason ? reason : gettext("No maintenance reason given."))
|
||||
maint_reason: reason ? reason : gettext("No maintenance reason given.")
|
||||
};
|
||||
return apiService.patch('/api/ironic/nodes/' + uuid + '/maintenance', data).error(function() {
|
||||
toastService.add('error',
|
||||
@ -122,7 +123,8 @@
|
||||
* @name horizon.app.core.openstack-service-api.ironic.removeNodeFromMaintenanceMode
|
||||
* @description Remove the node from maintenance mode.
|
||||
*
|
||||
* http://docs.openstack.org/developer/ironic/webapi/v1.html#delete--v1-nodes-(node_ident)-maintenance
|
||||
* \href{http://docs.openstack.org/developer/ironic/webapi/v1.html#
|
||||
* delete--v1-nodes-(node_ident)-maintenance}
|
||||
*
|
||||
* @param {string} uuid – UUID or logical name of a node.
|
||||
*/
|
||||
@ -138,7 +140,8 @@
|
||||
* @name horizon.app.core.openstack-service-api.ironic.powerOnNode
|
||||
* @description Set the power state of the node.
|
||||
*
|
||||
* http://docs.openstack.org/developer/ironic/webapi/v1.html#put--v1-nodes-(node_ident)-states-power
|
||||
* \href{http://docs.openstack.org/developer/ironic/webapi/v1.html#
|
||||
* put--v1-nodes-(node_ident)-states-power}
|
||||
*
|
||||
* @param {string} uuid – UUID or logical name of a node.
|
||||
*/
|
||||
@ -160,7 +163,8 @@
|
||||
* @name horizon.app.core.openstack-service-api.ironic.powerOffNode
|
||||
* @description Set the power state of the node.
|
||||
*
|
||||
* http://docs.openstack.org/developer/ironic/webapi/v1.html#put--v1-nodes-(node_ident)-states-power
|
||||
* \href{http://docs.openstack.org/developer/ironic/webapi/v1.html#
|
||||
* put--v1-nodes-(node_ident)-states-power}
|
||||
*
|
||||
* @param {string} uuid – UUID or logical name of a node.
|
||||
*/
|
||||
|
@ -16,8 +16,8 @@
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var POWER_STATE_ON ='power on';
|
||||
|
||||
var POWER_STATE_ON = 'power on';
|
||||
var POWER_STATE_OFF = 'power off';
|
||||
|
||||
angular
|
||||
@ -51,7 +51,7 @@
|
||||
return $q.reject(gettext("Node is not powered off."));
|
||||
}
|
||||
return ironic.powerOnNode(node.uuid).then(
|
||||
function(response) {
|
||||
function() {
|
||||
// Set power state to be indeterminate
|
||||
node.power_state = null;
|
||||
},
|
||||
@ -65,7 +65,7 @@
|
||||
return $q.reject(gettext("Node is not powered on."));
|
||||
}
|
||||
return ironic.powerOffNode(node.uuid).then(
|
||||
function(response) {
|
||||
function() {
|
||||
// Set power state to be indeterminate
|
||||
node.power_state = null;
|
||||
},
|
||||
|
@ -52,7 +52,7 @@
|
||||
ctrl.getVifPortId = getVifPortId;
|
||||
|
||||
init();
|
||||
|
||||
|
||||
/**
|
||||
* @name horizon.dashboard.admin.ironic.NodeDetailsController.init
|
||||
* @description Initialize the controller instance based on the current page url.
|
||||
@ -88,11 +88,11 @@
|
||||
* @description Retrieve the ports associated with a specified node, and store
|
||||
* them in the controller instance.
|
||||
*
|
||||
* @param {string} node_id – Node name or UUID
|
||||
* @param {string} nodeId – Node name or UUID
|
||||
* @return {void}
|
||||
*/
|
||||
function retrievePorts(node_id) {
|
||||
ironic.getPortsWithNode(node_id).then(function (response) {
|
||||
function retrievePorts(nodeId) {
|
||||
ironic.getPortsWithNode(nodeId).then(function (response) {
|
||||
ctrl.ports = response.data.items;
|
||||
});
|
||||
}
|
||||
@ -105,7 +105,7 @@
|
||||
* @return {boolean} True if the string is an OpenStack UUID, otherwise false
|
||||
*/
|
||||
function isUuid(str) {
|
||||
return str.match(ctrl.re_uuid) ? true : false;
|
||||
return !!str.match(ctrl.re_uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,9 +116,9 @@
|
||||
* @return {string} Value of vif_port_id property or "" if the property does not exist
|
||||
*/
|
||||
function getVifPortId(port) {
|
||||
return (angular.isDefined(port.extra) &&
|
||||
angular.isDefined(port.extra.vif_port_id)) ?
|
||||
port.extra.vif_port_id : "";
|
||||
return angular.isDefined(port.extra) &&
|
||||
angular.isDefined(port.extra.vif_port_id)
|
||||
? port.extra.vif_port_id : "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,5 +118,5 @@
|
||||
expect(ctrl.getVifPortId(createPort(ctrl.node.uuid, 1, extra))).
|
||||
toEqual("port_uuid");
|
||||
});
|
||||
})
|
||||
});
|
||||
})();
|
||||
|
@ -42,34 +42,34 @@
|
||||
*/
|
||||
ctrl.nodeFacets = [
|
||||
{
|
||||
'label': gettext('Name'),
|
||||
'name': 'name',
|
||||
'singleton': true
|
||||
label: gettext('Name'),
|
||||
name: 'name',
|
||||
singleton: true
|
||||
},
|
||||
{
|
||||
'label': gettext('UUID'),
|
||||
'name': 'uuid',
|
||||
'singleton': true
|
||||
label: gettext('UUID'),
|
||||
name: 'uuid',
|
||||
singleton: true
|
||||
},
|
||||
{
|
||||
'label': gettext('Power State'),
|
||||
'name': 'power_state',
|
||||
'singleton': true
|
||||
label: gettext('Power State'),
|
||||
name: 'power_state',
|
||||
singleton: true
|
||||
},
|
||||
{
|
||||
'label': gettext('Provisioning State'),
|
||||
'name': 'provision_state',
|
||||
'singleton': true
|
||||
label: gettext('Provisioning State'),
|
||||
name: 'provision_state',
|
||||
singleton: true
|
||||
},
|
||||
{
|
||||
'label': gettext('Maintenance'),
|
||||
'name': 'maintenance',
|
||||
'singleton': true
|
||||
label: gettext('Maintenance'),
|
||||
name: 'maintenance',
|
||||
singleton: true
|
||||
},
|
||||
{
|
||||
'label': gettext('Driver'),
|
||||
'name': 'driver',
|
||||
'singleton': true
|
||||
label: gettext('Driver'),
|
||||
name: 'driver',
|
||||
singleton: true
|
||||
}
|
||||
];
|
||||
|
||||
@ -103,4 +103,3 @@
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
"name": "ironic-ui",
|
||||
"version": "1.0.0",
|
||||
"description": "Horizon plugin for OpenStack Ironic.",
|
||||
"main": "index.html",
|
||||
"scripts": {
|
||||
"lint": "eslint ./"
|
||||
},
|
||||
@ -13,8 +12,8 @@
|
||||
"author": "Openstack <openstack-dev@lists.openstack.org>",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"eslint": "1.9.0",
|
||||
"eslint-config-openstack": "1.2.3",
|
||||
"eslint-plugin-angular": "0.4.0"
|
||||
"eslint": "^1.10.3",
|
||||
"eslint-config-openstack": "^1.2.4",
|
||||
"eslint-plugin-angular": "1.0.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user