From 04d0257d71a660713d70b2699c967644c33b2395 Mon Sep 17 00:00:00 2001 From: Shu Muto Date: Mon, 12 Sep 2016 18:19:51 +0900 Subject: [PATCH] Fix eslint errors on Cluster Templates This patch fixes eslint errors on Cluster Templates namespace. Change-Id: Ie1bc94a588a0ddeb4925f4cf43c4d3cd2219beab Partial-Bug: #1622475 --- .../cluster-templates/actions.module.js | 15 +++++---- .../cluster-templates.module.js | 25 ++++++++------- .../create/cluster-template-model.js | 5 +-- .../create/create-workflow.service.js | 4 ++- .../create/create.service.js | 5 +-- .../info/cluster-template.info.controller.js | 31 ++++++++++++------- .../cluster-template.labels.controller.js | 7 +---- .../cluster-template.network.controller.js | 9 ++---- .../spec/cluster-template.spec.controller.js | 20 ++++++------ .../delete/delete.service.js | 30 ++++++++++++------ .../details/drawer.controller.js | 5 +-- .../details/overview.controller.js | 14 ++------- 12 files changed, 88 insertions(+), 82 deletions(-) diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/actions.module.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/actions.module.js index 9b337cb6..a9c1d3ee 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/actions.module.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/actions.module.js @@ -22,8 +22,12 @@ * @description * Provides all of the actions for cluster templates. */ - angular.module('horizon.dashboard.container-infra.cluster-templates.actions', ['horizon.framework', 'horizon.dashboard.container-infra']) - .run(registerClusterTemplateActions); + angular.module('horizon.dashboard.container-infra.cluster-templates.actions', + [ + 'horizon.framework', + 'horizon.dashboard.container-infra' + ]) + .run(registerClusterTemplateActions); registerClusterTemplateActions.$inject = [ 'horizon.framework.conf.resource-type-registry.service', @@ -31,7 +35,7 @@ 'horizon.dashboard.container-infra.cluster-templates.create.service', 'horizon.dashboard.container-infra.cluster-templates.delete.service', 'horizon.dashboard.container-infra.clusters.create.service', - 'horizon.dashboard.container-infra.cluster-templates.resourceType', + 'horizon.dashboard.container-infra.cluster-templates.resourceType' ]; function registerClusterTemplateActions( @@ -40,8 +44,8 @@ createClusterTemplateService, deleteClusterTemplateService, createClusterService, - resourceType) - { + resourceType) { + var templateResourceType = registry.getResourceType(resourceType); templateResourceType.itemActions .append({ @@ -78,5 +82,4 @@ } }); } - })(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/cluster-templates.module.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/cluster-templates.module.js index 85459b59..f9ea8df4 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/cluster-templates.module.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/cluster-templates.module.js @@ -21,26 +21,29 @@ * @ngdoc overview * @name horizon.dashboard.container-infra.cluster-templates * @ngModule - * * @description * Provides all the services and widgets require to display the cluster template * panel */ angular - .module('horizon.dashboard.container-infra.cluster-templates', [ + .module('horizon.dashboard.container-infra.cluster-templates', + [ 'ngRoute', 'horizon.dashboard.container-infra.cluster-templates.actions', 'horizon.dashboard.container-infra.cluster-templates.details' ]) .constant('horizon.dashboard.container-infra.cluster-templates.events', events()) - .constant('horizon.dashboard.container-infra.cluster-templates.resourceType', 'OS::Magnum::ClusterTemplate') + .constant( + 'horizon.dashboard.container-infra.cluster-templates.resourceType', + 'OS::Magnum::ClusterTemplate') .run(run) .config(config); /** * @ngdoc constant - * @name horizon.dashboard.container-infra.cluster-templates.events - * @description A list of events used by cluster templates + * @name events + * @returns {Object} The event object + * @description A list of events for cluster templates */ function events() { return { @@ -60,7 +63,7 @@ registry.getResourceType(resourceType) .setNames(gettext('Cluster Template'), gettext('Cluster Templates')) - // for detail summary view on table row + // for detail summary view on table row .setSummaryTemplateUrl(basePath + 'details/drawer.html') // for table row items and detail summary view. .setProperty('name', { @@ -118,7 +121,7 @@ {label: gettext('Kubernetes'), key: 'kubernetes'}, {label: gettext('Mesos'), key: 'mesos'} ] - }) + }); function listFunction(params) { return magnum.getClusterTemplates(params).then(modifyResponse); @@ -126,9 +129,9 @@ function modifyResponse(response) { return {data: {items: response.data.items.map(addTrackBy)}}; - function addTrackBy(cluster_template) { - cluster_template.trackBy = cluster_template.id; - return cluster_template; + function addTrackBy(clusterTemplate) { + clusterTemplate.trackBy = clusterTemplate.id; + return clusterTemplate; } } } @@ -149,8 +152,8 @@ * @param {Object} $provide * @param {Object} $windowProvider * @param {Object} $routeProvider - * @description Routes used by this module. * @returns {undefined} Returns nothing + * @description Routes used by this module. */ function config($provide, $windowProvider, $routeProvider) { var path = $windowProvider.$get().STATIC_URL + 'dashboard/container-infra/cluster-templates/'; diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/cluster-template-model.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/cluster-template-model.js index 574a3e1d..a5a04e53 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/cluster-template-model.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/cluster-template-model.js @@ -89,8 +89,9 @@ // "network_drivers" and "volume_drivers" are used for pull-down options. // These are not for submittion. for (var key in finalSpec) { - if (finalSpec.hasOwnProperty(key) && finalSpec[key] === null || finalSpec[key] === "" - || key === "network_drivers" || key === "volume_drivers" || key === "docker_storage_drivers") { + if (finalSpec.hasOwnProperty(key) && finalSpec[key] === null || finalSpec[key] === "" || + key === "network_drivers" || key === "volume_drivers" || + key === "docker_storage_drivers") { delete finalSpec[key]; } } diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create-workflow.service.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create-workflow.service.js index 51f447db..75af6d47 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create-workflow.service.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create-workflow.service.js @@ -19,7 +19,9 @@ angular .module('horizon.dashboard.container-infra.cluster-templates') - .factory('horizon.dashboard.container-infra.cluster-templates.workflow', ClusterTemplateWorkflow); + .factory( + 'horizon.dashboard.container-infra.cluster-templates.workflow', + ClusterTemplateWorkflow); ClusterTemplateWorkflow.$inject = [ 'horizon.dashboard.container-infra.basePath', diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.js index 3009926c..910e624c 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/create.service.js @@ -40,7 +40,8 @@ ]; function createService( - policy, actionResult, gettext, $qExtensions, wizardModalService, toast, model, events, resourceType, createWorkflow + policy, actionResult, gettext, $qExtensions, wizardModalService, + toast, model, events, resourceType, createWorkflow ) { var scope; @@ -79,7 +80,7 @@ return $qExtensions.booleanAsPromise(true); } - function submit(){ + function submit() { return model.createClusterTemplate().then(success); } diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/info/cluster-template.info.controller.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/info/cluster-template.info.controller.js index 5300eadd..a1d2ff0e 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/info/cluster-template.info.controller.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/info/cluster-template.info.controller.js @@ -63,19 +63,26 @@ mesos: [{name:"", label: gettext("Choose a Volume Driver")}, {name:"rexray", label: gettext("Rexray")}]}; - $scope.changeCoes = function(){ - if($scope.model.newClusterTemplateSpec.coe){ - $scope.model.newClusterTemplateSpec.network_drivers = ctrl.supportedNetworkDrivers[$scope.model.newClusterTemplateSpec.coe]; - $scope.model.newClusterTemplateSpec.network_driver = ctrl.supportedNetworkDrivers[$scope.model.newClusterTemplateSpec.coe][0].name; - $scope.model.newClusterTemplateSpec.volume_drivers = ctrl.supportedVolumeDrivers[$scope.model.newClusterTemplateSpec.coe]; - $scope.model.newClusterTemplateSpec.volume_driver = ctrl.supportedVolumeDrivers[$scope.model.newClusterTemplateSpec.coe][0].name; - }else{ - $scope.model.newClusterTemplateSpec.network_drivers = ctrl.supportedNetworkDrivers.initial; - $scope.model.newClusterTemplateSpec.network_driver = ctrl.supportedNetworkDrivers.initial[0].name; - $scope.model.newClusterTemplateSpec.volume_drivers = ctrl.supportedVolumeDrivers.initial; - $scope.model.newClusterTemplateSpec.volume_driver = ctrl.supportedVolumeDrivers.initial[0].name; + $scope.changeCoes = function() { + if ($scope.model.newClusterTemplateSpec.coe) { + $scope.model.newClusterTemplateSpec.network_drivers = + ctrl.supportedNetworkDrivers[$scope.model.newClusterTemplateSpec.coe]; + $scope.model.newClusterTemplateSpec.network_driver = + ctrl.supportedNetworkDrivers[$scope.model.newClusterTemplateSpec.coe][0].name; + $scope.model.newClusterTemplateSpec.volume_drivers = + ctrl.supportedVolumeDrivers[$scope.model.newClusterTemplateSpec.coe]; + $scope.model.newClusterTemplateSpec.volume_driver = + ctrl.supportedVolumeDrivers[$scope.model.newClusterTemplateSpec.coe][0].name; + } else { + $scope.model.newClusterTemplateSpec.network_drivers = + ctrl.supportedNetworkDrivers.initial; + $scope.model.newClusterTemplateSpec.network_driver = + ctrl.supportedNetworkDrivers.initial[0].name; + $scope.model.newClusterTemplateSpec.volume_drivers = + ctrl.supportedVolumeDrivers.initial; + $scope.model.newClusterTemplateSpec.volume_driver = + ctrl.supportedVolumeDrivers.initial[0].name; } }; } - })(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/labels/cluster-template.labels.controller.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/labels/cluster-template.labels.controller.js index cec700a6..4311b394 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/labels/cluster-template.labels.controller.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/labels/cluster-template.labels.controller.js @@ -30,14 +30,9 @@ .controller('createClusterTemplateLabelsController', createClusterTemplateLabelsController); createClusterTemplateLabelsController.$inject = [ - '$q', - '$scope', - 'horizon.dashboard.container-infra.basePath', - 'horizon.app.core.openstack-service-api.magnum' ]; - function createClusterTemplateLabelsController($q, $scope, basePath, magnum) { - var ctrl = this; + function createClusterTemplateLabelsController() { } })(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/network/cluster-template.network.controller.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/network/cluster-template.network.controller.js index 0c687033..4ac92023 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/network/cluster-template.network.controller.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/network/cluster-template.network.controller.js @@ -30,14 +30,9 @@ .controller('createClusterTemplateNetworkController', createClusterTemplateNetworkController); createClusterTemplateNetworkController.$inject = [ - '$q', - '$scope', - 'horizon.dashboard.container-infra.basePath', - 'horizon.app.core.openstack-service-api.magnum' ]; - function createClusterTemplateNetworkController($q, $scope, basePath, magnum) { - var ctrl = this; - }; + function createClusterTemplateNetworkController() { + } })(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/spec/cluster-template.spec.controller.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/spec/cluster-template.spec.controller.js index b8fafcfe..5bf242e3 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/spec/cluster-template.spec.controller.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/spec/cluster-template.spec.controller.js @@ -55,25 +55,23 @@ function onGetImages(response) { angular.forEach(response.items, function(item) { - this.push({id: item.name, name: item.name}); - }, ctrl.images); + ctrl.images.push({id: item.name, name: item.name}); + }); } function onGetFlavors(response) { angular.forEach(response.items, function(item) { - this.push({id: item.name, name: item.name}); - }, ctrl.nflavors); + ctrl.nflavors.push({id: item.name, name: item.name}); + }); angular.forEach(response.items, function(item) { - this.push({id: item.name, name: item.name}); - }, ctrl.mflavors); + ctrl.mflavors.push({id: item.name, name: item.name}); + }); } function onGetKeypairs(response) { angular.forEach(response.items, function(item) { - this.push({id: item.keypair.name, name: item.keypair.name}); - }, ctrl.keypairs); + ctrl.keypairs.push({id: item.keypair.name, name: item.keypair.name}); + }); } - - }; - + } })(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.js index 96ccfbaa..1be5846c 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/delete/delete.service.js @@ -35,15 +35,27 @@ /** * @ngDoc factory - * @name horizon.dashboard.container-infra.cluster-templates.delete.service - * + * @name delete.service + * @param {Object} $location + * @param {Object} $q + * @param {Object} magnum service + * @param {Object} policy + * @param {Object} actionResult + * @param {Object} gettext + * @param {Object} $qExtensions + * @param {Object} deleteModal + * @param {Object} toast + * @param {Object} resourceType + * @param {Object} events + * @returns {Object} delete service * @Description * Brings up the delete cluster templates confirmation modal dialog. * On submit, delete selected resources. * On cancel, do nothing. */ function deleteService( - $location, $q, magnum, policy, actionResult, gettext, $qExtensions, deleteModal, toast, resourceType, events + $location, $q, magnum, policy, actionResult, gettext, $qExtensions, deleteModal, toast, + resourceType, events ) { var scope; var context = { @@ -74,12 +86,12 @@ // delete selected resource objects function perform(selected) { - var selected = angular.isArray(selected) ? selected : [selected]; + selected = angular.isArray(selected) ? selected : [selected]; context.labels = labelize(selected.length); return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck); } - function labelize(count){ + function labelize(count) { return { title: ngettext('Confirm Delete Cluster Template', 'Confirm Delete Cluster Templates', count), @@ -102,7 +114,7 @@ } // for batch delete - function afterCheck(result){ + function afterCheck(result) { var outcome = $q.reject(); // Reject the promise by default if (result.fail.length > 0) { toast.add('error', getMessage(notAllowedMessage, result.fail)); @@ -124,9 +136,9 @@ deleteModalResult.fail.forEach(function markFailed(item) { 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/cluster_templates"); - }else{ + } else { return result.result; } } @@ -145,7 +157,7 @@ } // call delete REST API - function deleteEntity(id){ + function deleteEntity(id) { return magnum.deleteClusterTemplate(id, true); } } diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/details/drawer.controller.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/details/drawer.controller.js index 4b1cfb9e..970a11f2 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/details/drawer.controller.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/details/drawer.controller.js @@ -28,12 +28,9 @@ .controller('horizon.dashboard.container-infra.cluster-templates.DrawerController', controller); controller.$inject = [ - 'horizon.app.core.openstack-service-api.magnum', - 'horizon.dashboard.container-infra.cluster-templates.resourceType' ]; - function controller(magnum, resourceType) { - var ctrl = this; + function controller() { } })(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/details/overview.controller.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/details/overview.controller.js index 8fb33d89..dda5f700 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/details/overview.controller.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/details/overview.controller.js @@ -20,24 +20,16 @@ ClusterTemplateOverviewController.$inject = [ '$scope', - 'horizon.app.core.openstack-service-api.glance', - 'horizon.dashboard.container-infra.cluster-templates.resourceType', - 'horizon.dashboard.container-infra.cluster-templates.events', - 'horizon.dashboard.container-infra.clusters.events', - 'horizon.framework.conf.resource-type-registry.service' + 'horizon.app.core.openstack-service-api.glance' ]; function ClusterTemplateOverviewController( $scope, - glance, - resourceType, - events, - clusterEvents, - registry + glance ) { var ctrl = this; ctrl.cluster_template = {}; - ctrl.image_uuid; + ctrl.image_uuid = ""; $scope.context.loadPromise.then(onGetClusterTemplate);