Fix eslint errors

This patch fixes lint errors for JavaScript except "FIXME" warnings.

Change-Id: Iefa0868365eb08c3a5383885dc1a747808751318
Needed-By: Idb8b9064c1e465db8284e287bcf56949ab1de5e6
This commit is contained in:
Shu Muto 2017-03-14 19:35:47 +09:00
parent b56de185aa
commit c2042f873a
19 changed files with 114 additions and 124 deletions

View File

@ -26,11 +26,11 @@
'horizon.dashboard.container.containers', 'horizon.dashboard.container.containers',
'ngRoute' 'ngRoute'
]) ])
.config(config) .config(config);
config.$inject = ['$provide', '$windowProvider', '$routeProvider']; config.$inject = ['$provide', '$windowProvider'];
function config($provide, $windowProvider, $routeProvider) { function config($provide, $windowProvider) {
var path = $windowProvider.$get().STATIC_URL + 'dashboard/container/'; var path = $windowProvider.$get().STATIC_URL + 'dashboard/container/';
$provide.constant('horizon.dashboard.container.basePath', path); $provide.constant('horizon.dashboard.container.basePath', path);
} }

View File

@ -22,8 +22,12 @@
* @description * @description
* Provides all of the actions for containers. * Provides all of the actions for containers.
*/ */
angular.module('horizon.dashboard.container.containers.actions', ['horizon.framework', 'horizon.dashboard.container']) angular.module('horizon.dashboard.container.containers.actions',
.run(registerContainerActions); [
'horizon.framework',
'horizon.dashboard.container'
])
.run(registerContainerActions);
registerContainerActions.$inject = [ registerContainerActions.$inject = [
'horizon.framework.conf.resource-type-registry.service', 'horizon.framework.conf.resource-type-registry.service',
@ -38,7 +42,7 @@
'horizon.dashboard.container.containers.unpause.service', 'horizon.dashboard.container.containers.unpause.service',
'horizon.dashboard.container.containers.execute.service', 'horizon.dashboard.container.containers.execute.service',
'horizon.dashboard.container.containers.kill.service', 'horizon.dashboard.container.containers.kill.service',
'horizon.dashboard.container.containers.resourceType', 'horizon.dashboard.container.containers.resourceType'
]; ];
function registerContainerActions( function registerContainerActions(
@ -54,8 +58,8 @@
unpauseContainerService, unpauseContainerService,
executeContainerService, executeContainerService,
killContainerService, killContainerService,
resourceType) resourceType
{ ) {
var containersResourceType = registry.getResourceType(resourceType); var containersResourceType = registry.getResourceType(resourceType);
containersResourceType.globalActions containersResourceType.globalActions

View File

@ -38,6 +38,7 @@
* @ngdoc constant * @ngdoc constant
* @name horizon.dashboard.container.containers.events * @name horizon.dashboard.container.containers.events
* @description A list of events used by Container * @description A list of events used by Container
* @returns {Object} Event constants
*/ */
function events() { function events() {
return { return {

View File

@ -40,8 +40,6 @@
command: null, command: null,
cpu: null, cpu: null,
memory: null, memory: null,
memory_size: null,
memory_unit: "m",
environment: null, environment: null,
workdir: null, workdir: null,
labels: null labels: null
@ -65,9 +63,8 @@
// Initially clean fields that don't have any value. // Initially clean fields that don't have any value.
// Not only "null", blank too. // Not only "null", blank too.
for (var key in finalSpec) { for (var key in finalSpec) {
if (finalSpec.hasOwnProperty(key) && finalSpec[key] === null if (finalSpec.hasOwnProperty(key) && finalSpec[key] === null ||
|| finalSpec[key] === "" finalSpec[key] === "") {
|| key === "memory_size" || key === "memory_unit") {
delete finalSpec[key]; delete finalSpec[key];
} }
} }

View File

@ -28,7 +28,6 @@
function containerWorkflow(basePath, dashboardWorkflow, gettext) { function containerWorkflow(basePath, dashboardWorkflow, gettext) {
return dashboardWorkflow({ return dashboardWorkflow({
title: gettext('Create Container'), title: gettext('Create Container'),
steps: [ steps: [
{ {
title: gettext('Info'), title: gettext('Info'),
@ -53,13 +52,11 @@
templateUrl: basePath + 'containers/create/labels/labels.html', templateUrl: basePath + 'containers/create/labels/labels.html',
helpUrl: basePath + 'containers/create/labels/labels.help.html', helpUrl: basePath + 'containers/create/labels/labels.help.html',
formName: 'containerLabelsForm' formName: 'containerLabelsForm'
}, }
], ],
btnText: { btnText: {
finish: gettext('Create') finish: gettext('Create')
}, },
btnIcon: { btnIcon: {
finish: 'fa fa-check' finish: 'fa fa-check'
} }

View File

@ -39,7 +39,8 @@
]; ];
function createService( function createService(
$location, policy, actionResult, gettext, $qExtensions, wizardModalService, toast, model, events, resourceType, createWorkflow $location, policy, actionResult, gettext, $qExtensions, wizardModalService,
toast, model, events, resourceType, createWorkflow
) { ) {
var scope; var scope;
var message = { var message = {
@ -78,7 +79,7 @@
//return policy.ifAllowed({ rules: [['container', 'add_container']] }); //return policy.ifAllowed({ rules: [['container', 'add_container']] });
} }
function submit(){ function submit() {
return model.createContainer().then(success); return model.createContainer().then(success);
} }
@ -87,9 +88,9 @@
toast.add('success', interpolate(message.success, [response.data.id])); toast.add('success', interpolate(message.success, [response.data.id]));
var result = actionResult.getActionResult() var result = actionResult.getActionResult()
.created(resourceType, response.data.id); .created(resourceType, response.data.id);
if(result.result.failed.length == 0 && result.result.created.length > 0){ if (result.result.failed.length === 0 && result.result.created.length > 0) {
$location.path('/project/container/containers'); $location.path('/project/container/containers');
}else{ } else {
return result.result; return result.result;
} }
} }

View File

@ -27,11 +27,8 @@
.controller('createContainerSpecController', createContainerSpecController); .controller('createContainerSpecController', createContainerSpecController);
createContainerSpecController.$inject = [ createContainerSpecController.$inject = [
'$scope',
'horizon.framework.util.i18n.gettext'
]; ];
function createContainerSpecController($scope, gettext) { function createContainerSpecController() {
var ctrl = this;
} }
})(); })();

View File

@ -10,11 +10,11 @@
</div> </div>
<div class="col-xs-12"> <div class="col-xs-12">
<div class="form-group"> <div class="form-group">
<label class="control-label" for="container-memory-size" translate>Memory Size</label> <label class="control-label" for="container-memory" translate>Memory Size</label>
<input name="container-memory-size" type="number" min="1" <input name="container-memory" type="number" min="1"
class="form-control" ng-model="model.newContainerSpec.memory_size" class="form-control" ng-model="model.newContainerSpec.memory"
placeholder="{$ 'The container memory size in MiB.'|translate $}" placeholder="{$ 'The container memory size in MiB.'|translate $}"
id="container-memory-size"> id="container-memory">
</div> </div>
</div> </div>
</div> </div>

View File

@ -15,6 +15,14 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.delete-force.service
* @Description
* Brings up the delete container forcely confirmation modal dialog.
* On submit, delete selected resources.
* On cancel, do nothing.
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory('horizon.dashboard.container.containers.delete-force.service', deleteForceService); .factory('horizon.dashboard.container.containers.delete-force.service', deleteForceService);
@ -33,16 +41,9 @@
'horizon.dashboard.container.containers.events' 'horizon.dashboard.container.containers.events'
]; ];
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.delete-force.service
* @Description
* Brings up the delete container forcely confirmation modal dialog.
* On submit, delete selected resources.
* On cancel, do nothing.
*/
function deleteForceService( function deleteForceService(
$location, $q, zun, policy, actionResult, gettext, $qExtensions, deleteModal, toast, resourceType, events $location, $q, zun, policy, actionResult, gettext, $qExtensions, deleteModal,
toast, resourceType, events
) { ) {
var scope; var scope;
var context = { var context = {
@ -71,12 +72,12 @@
// delete selected resource objects // delete selected resource objects
function perform(selected, newScope) { function perform(selected, newScope) {
scope = newScope; scope = newScope;
var selected = angular.isArray(selected) ? selected : [selected]; selected = angular.isArray(selected) ? selected : [selected];
context.labels = labelize(selected.length); context.labels = labelize(selected.length);
return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck); return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck);
} }
function labelize(count){ function labelize(count) {
return { return {
title: ngettext('Confirm Delete Container Forcely', title: ngettext('Confirm Delete Container Forcely',
'Confirm Delete Containers Forcely', count), 'Confirm Delete Containers Forcely', count),
@ -99,7 +100,7 @@
} }
// for batch delete // for batch delete
function afterCheck(result){ function afterCheck(result) {
var outcome = $q.reject(); // Reject the promise by default var outcome = $q.reject(); // Reject the promise by default
if (result.fail.length > 0) { if (result.fail.length > 0) {
toast.add('error', getMessage(notAllowedMessage, result.fail)); toast.add('error', getMessage(notAllowedMessage, result.fail));
@ -121,9 +122,9 @@
deleteModalResult.fail.forEach(function markFailed(item) { deleteModalResult.fail.forEach(function markFailed(item) {
result.failed(resourceType, getEntity(item).id); result.failed(resourceType, getEntity(item).id);
}); });
if(result.result.failed.length == 0 && result.result.deleted.length > 0){ if (result.result.failed.length === 0 && result.result.deleted.length > 0) {
$location.path('/project/container/containers'); $location.path('/project/container/containers');
}else{ } else {
return result.result; return result.result;
} }
} }
@ -142,7 +143,7 @@
} }
// call delete REST API // call delete REST API
function deleteEntity(id){ function deleteEntity(id) {
return zun.deleteContainerForce(id, true); return zun.deleteContainerForce(id, true);
} }
} }

View File

@ -15,6 +15,14 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.delete.service
* @Description
* Brings up the delete containers confirmation modal dialog.
* On submit, delete selected resources.
* On cancel, do nothing.
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory('horizon.dashboard.container.containers.delete.service', deleteService); .factory('horizon.dashboard.container.containers.delete.service', deleteService);
@ -33,16 +41,9 @@
'horizon.dashboard.container.containers.events' 'horizon.dashboard.container.containers.events'
]; ];
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.delete.service
* @Description
* Brings up the delete containers confirmation modal dialog.
* On submit, delete selected resources.
* On cancel, do nothing.
*/
function deleteService( function deleteService(
$location, $q, zun, policy, actionResult, gettext, $qExtensions, deleteModal, toast, resourceType, events $location, $q, zun, policy, actionResult, gettext, $qExtensions, deleteModal,
toast, resourceType, events
) { ) {
var scope; var scope;
var context = { var context = {
@ -71,12 +72,12 @@
// delete selected resource objects // delete selected resource objects
function perform(selected, newScope) { function perform(selected, newScope) {
scope = newScope; scope = newScope;
var selected = angular.isArray(selected) ? selected : [selected]; selected = angular.isArray(selected) ? selected : [selected];
context.labels = labelize(selected.length); context.labels = labelize(selected.length);
return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck); return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck);
} }
function labelize(count){ function labelize(count) {
return { return {
title: ngettext('Confirm Delete Container', title: ngettext('Confirm Delete Container',
'Confirm Delete Containers', count), 'Confirm Delete Containers', count),
@ -99,7 +100,7 @@
} }
// for batch delete // for batch delete
function afterCheck(result){ function afterCheck(result) {
var outcome = $q.reject(); // Reject the promise by default var outcome = $q.reject(); // Reject the promise by default
if (result.fail.length > 0) { if (result.fail.length > 0) {
toast.add('error', getMessage(notAllowedMessage, result.fail)); toast.add('error', getMessage(notAllowedMessage, result.fail));
@ -121,9 +122,9 @@
deleteModalResult.fail.forEach(function markFailed(item) { deleteModalResult.fail.forEach(function markFailed(item) {
result.failed(resourceType, getEntity(item).id); result.failed(resourceType, getEntity(item).id);
}); });
if(result.result.failed.length == 0 && result.result.deleted.length > 0){ if (result.result.failed.length === 0 && result.result.deleted.length > 0) {
$location.path('/project/container/containers'); $location.path('/project/container/containers');
}else{ } else {
return result.result; return result.result;
} }
} }
@ -142,7 +143,7 @@
} }
// call delete REST API // call delete REST API
function deleteEntity(id){ function deleteEntity(id) {
return zun.deleteContainer(id, true); return zun.deleteContainer(id, true);
} }
} }

View File

@ -20,18 +20,11 @@
controller.$inject = [ controller.$inject = [
'$scope', '$scope',
'horizon.app.core.openstack-service-api.zun', 'horizon.app.core.openstack-service-api.zun'
'horizon.dashboard.container.containers.resourceType',
'horizon.dashboard.container.containers.events',
'horizon.framework.conf.resource-type-registry.service'
]; ];
function controller( function controller(
$scope, $scope, zun
zun,
resourceType,
events,
registry
) { ) {
var ctrl = this; var ctrl = this;
ctrl.container = {}; ctrl.container = {};

View File

@ -15,6 +15,12 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngdoc factory
* @name horizon.dashboard.container.containers.execute.service
* @description
* Service for the command execution in the container
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory( .factory(
@ -29,12 +35,6 @@
'horizon.framework.widgets.toast.service' 'horizon.framework.widgets.toast.service'
]; ];
/**
* @ngdoc factory
* @name horizon.dashboard.container.containers.execute.service
* @description
* Service for the command execution in the container
*/
function executeContainerService( function executeContainerService(
zun, gettext, $qExtensions, modal, toast zun, gettext, $qExtensions, modal, toast
) { ) {
@ -110,7 +110,7 @@
var name = context.model.name; var name = context.model.name;
delete context.model.id; delete context.model.id;
delete context.model.name; delete context.model.name;
return zun.executeContainer(id, context.model).then(function(response) { return zun.executeContainer(id, context.model).then(function() {
toast.add('success', interpolate(message.success, [name])); toast.add('success', interpolate(message.success, [name]));
}); });
} }

View File

@ -15,6 +15,12 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngdoc factory
* @name horizon.dashboard.container.containers.kill.service
* @description
* Service to send kill signals to the container
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory( .factory(
@ -30,12 +36,6 @@
'horizon.framework.widgets.toast.service' 'horizon.framework.widgets.toast.service'
]; ];
/**
* @ngdoc factory
* @name horizon.dashboard.container.containers.kill.service
* @description
* Service to send kill signals to the container
*/
function killContainerService( function killContainerService(
zun, basePath, gettext, $qExtensions, modal, toast zun, basePath, gettext, $qExtensions, modal, toast
) { ) {
@ -95,8 +95,8 @@
} }
function allowed() { function allowed() {
return $qExtensions.booleanAsPromise(true); return $qExtensions.booleanAsPromise(true);
} }
function perform(selected) { function perform(selected) {
model = { model = {
@ -120,7 +120,7 @@
var name = context.model.name; var name = context.model.name;
delete context.model.id; delete context.model.id;
delete context.model.name; delete context.model.name;
return zun.killContainer(id, context.model).then(function(response) { return zun.killContainer(id, context.model).then(function() {
toast.add('success', interpolate(message.success, [name])); toast.add('success', interpolate(message.success, [name]));
}); });
} }

View File

@ -15,6 +15,12 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.pause.service
* @Description
* pause container.
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory('horizon.dashboard.container.containers.pause.service', pauseService); .factory('horizon.dashboard.container.containers.pause.service', pauseService);
@ -22,17 +28,10 @@
pauseService.$inject = [ pauseService.$inject = [
'horizon.framework.util.q.extensions', 'horizon.framework.util.q.extensions',
'horizon.framework.widgets.toast.service', 'horizon.framework.widgets.toast.service',
'horizon.app.core.openstack-service-api.zun', 'horizon.app.core.openstack-service-api.zun'
'horizon.framework.widgets.modal-wait-spinner.service'
]; ];
/** function pauseService($qExtensions, toast, zun) {
* @ngDoc factory
* @name horizon.dashboard.container.containers.pause.service
* @Description
* pause container.
*/
function pauseService($qExtensions, toast, zun, modalWaitSpinnerService) {
var message = { var message = {
success: gettext('Container %s was successfully paused.') success: gettext('Container %s was successfully paused.')
@ -61,9 +60,9 @@
// pause selected container // pause selected container
return zun.pauseContainer(selected.id).then(success); return zun.pauseContainer(selected.id).then(success);
function success(response) { function success() {
toast.add('success', interpolate(message.success, [selected.name])); toast.add('success', interpolate(message.success, [selected.name]));
}; }
} }
} }
})(); })();

View File

@ -15,6 +15,12 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.reboot.service
* @Description
* reboot container.
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory('horizon.dashboard.container.containers.reboot.service', rebootService); .factory('horizon.dashboard.container.containers.reboot.service', rebootService);
@ -25,12 +31,6 @@
'horizon.app.core.openstack-service-api.zun' 'horizon.app.core.openstack-service-api.zun'
]; ];
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.reboot.service
* @Description
* reboot container.
*/
function rebootService( function rebootService(
$qExtensions, toast, zun $qExtensions, toast, zun
) { ) {
@ -60,7 +60,7 @@
function perform(selected) { function perform(selected) {
// reboot selected container // reboot selected container
return zun.rebootContainer(selected.id).success(function(response) { return zun.rebootContainer(selected.id).success(function() {
toast.add('success', interpolate(message.success, [selected.name])); toast.add('success', interpolate(message.success, [selected.name]));
}); });
} }

View File

@ -15,6 +15,12 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.start.service
* @Description
* Start container.
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory('horizon.dashboard.container.containers.start.service', startService); .factory('horizon.dashboard.container.containers.start.service', startService);
@ -25,12 +31,6 @@
'horizon.app.core.openstack-service-api.zun' 'horizon.app.core.openstack-service-api.zun'
]; ];
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.start.service
* @Description
* Start container.
*/
function startService( function startService(
$qExtensions, toast, zun $qExtensions, toast, zun
) { ) {
@ -60,7 +60,7 @@
function perform(selected) { function perform(selected) {
// start selected container // start selected container
return zun.startContainer(selected.id).success(function(response) { return zun.startContainer(selected.id).success(function() {
toast.add('success', interpolate(message.success, [selected.name])); toast.add('success', interpolate(message.success, [selected.name]));
}); });
} }

View File

@ -15,6 +15,12 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.stop.service
* @Description
* Stop container.
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory('horizon.dashboard.container.containers.stop.service', stopService); .factory('horizon.dashboard.container.containers.stop.service', stopService);
@ -25,12 +31,6 @@
'horizon.app.core.openstack-service-api.zun' 'horizon.app.core.openstack-service-api.zun'
]; ];
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.stop.service
* @Description
* Stop container.
*/
function stopService( function stopService(
$qExtensions, toast, zun $qExtensions, toast, zun
) { ) {
@ -60,7 +60,7 @@
function perform(selected) { function perform(selected) {
// start selected container // start selected container
return zun.stopContainer(selected.id).success(function(response) { return zun.stopContainer(selected.id).success(function() {
toast.add('success', interpolate(message.success, [selected.name])); toast.add('success', interpolate(message.success, [selected.name]));
}); });
} }

View File

@ -15,6 +15,12 @@
(function() { (function() {
'use strict'; 'use strict';
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.unpause.service
* @Description
* unpause container.
*/
angular angular
.module('horizon.dashboard.container.containers') .module('horizon.dashboard.container.containers')
.factory('horizon.dashboard.container.containers.unpause.service', unpauseService); .factory('horizon.dashboard.container.containers.unpause.service', unpauseService);
@ -25,12 +31,6 @@
'horizon.app.core.openstack-service-api.zun' 'horizon.app.core.openstack-service-api.zun'
]; ];
/**
* @ngDoc factory
* @name horizon.dashboard.container.containers.unpause.service
* @Description
* unpause container.
*/
function unpauseService( function unpauseService(
$qExtensions, toast, zun $qExtensions, toast, zun
) { ) {
@ -60,7 +60,7 @@
function perform(selected) { function perform(selected) {
// unpause selected container // unpause selected container
return zun.unpauseContainer(selected.id).success(function(response) { return zun.unpauseContainer(selected.id).success(function() {
toast.add('success', interpolate(message.success, [selected.name])); toast.add('success', interpolate(message.success, [selected.name]));
}); });
} }

View File

@ -26,7 +26,6 @@
function ZunAPI(apiService, toast, gettext) { function ZunAPI(apiService, toast, gettext) {
var containersPath = '/api/zun/containers/'; var containersPath = '/api/zun/containers/';
var imagesPath = '/api/zun/images/';
var service = { var service = {
createContainer: createContainer, createContainer: createContainer,
getContainer: getContainer, getContainer: getContainer,