Fix eslint errors on Clusters and the others

This patch fixes eslint errors on Clusters and the other namespace.

Change-Id: I3a29fc4e3b3de3a5aa3fd9a1757314e60750980c
Closes-Bug: #1622475
This commit is contained in:
Shu Muto 2016-09-13 16:44:49 +09:00
parent 9288e0074a
commit 850dfcee42
17 changed files with 102 additions and 157 deletions

View File

@ -48,7 +48,7 @@
* @param {Object} resourceType * @param {Object} resourceType
* @param {Object} events * @param {Object} events
* @returns {Object} delete service * @returns {Object} delete service
* @Description * @description
* Brings up the delete cluster templates confirmation modal dialog. * Brings up the delete cluster templates confirmation modal dialog.
* On submit, delete selected resources. * On submit, delete selected resources.
* On cancel, do nothing. * On cancel, do nothing.

View File

@ -22,8 +22,12 @@
* @description * @description
* Provides all of the actions for clusters. * Provides all of the actions for clusters.
*/ */
angular.module('horizon.dashboard.container-infra.clusters.actions', ['horizon.framework', 'horizon.dashboard.container-infra']) angular.module('horizon.dashboard.container-infra.clusters.actions',
.run(registerClusterActions); [
'horizon.framework',
'horizon.dashboard.container-infra'
])
.run(registerClusterActions);
registerClusterActions.$inject = [ registerClusterActions.$inject = [
'horizon.framework.conf.resource-type-registry.service', 'horizon.framework.conf.resource-type-registry.service',
@ -32,18 +36,18 @@
'horizon.dashboard.container-infra.clusters.delete.service', 'horizon.dashboard.container-infra.clusters.delete.service',
'horizon.dashboard.container-infra.clusters.show-certificate.service', 'horizon.dashboard.container-infra.clusters.show-certificate.service',
'horizon.dashboard.container-infra.clusters.sign-certificate.service', 'horizon.dashboard.container-infra.clusters.sign-certificate.service',
'horizon.dashboard.container-infra.clusters.resourceType', 'horizon.dashboard.container-infra.clusters.resourceType'
]; ];
function registerClusterActions( function registerClusterActions (
registry, registry,
gettext, gettext,
createClusterService, createClusterService,
deleteClusterService, deleteClusterService,
showCertificateService, showCertificateService,
signCertificateService, signCertificateService,
resourceType) resourceType) {
{
var clusterResourceType = registry.getResourceType(resourceType); var clusterResourceType = registry.getResourceType(resourceType);
clusterResourceType.itemActions clusterResourceType.itemActions
.append({ .append({

View File

@ -39,7 +39,8 @@
/** /**
* @ngdoc constant * @ngdoc constant
* @name horizon.dashboard.container-infra.clusters.events * @name clusters.events
* @returns {Object} The event object
* @description A list of events used by Clusters * @description A list of events used by Clusters
*/ */
function events() { function events() {
@ -60,7 +61,7 @@
registry.getResourceType(resourceType) registry.getResourceType(resourceType)
.setNames(gettext('Cluster'), gettext('Clusters')) .setNames(gettext('Cluster'), gettext('Clusters'))
// for detail summary view on table row // for detail summary view on table row.
.setSummaryTemplateUrl(basePath + 'details/drawer.html') .setSummaryTemplateUrl(basePath + 'details/drawer.html')
// for table row items and detail summary view. // for table row items and detail summary view.
.setProperty('name', { .setProperty('name', {

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;
@ -79,7 +80,7 @@
return $qExtensions.booleanAsPromise(true); return $qExtensions.booleanAsPromise(true);
} }
function submit(){ function submit() {
return model.createCluster().then(success); return model.createCluster().then(success);
} }
@ -88,9 +89,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/clusters"); $location.path("/project/clusters");
}else{ } else {
return result.result; return result.result;
} }
} }

View File

@ -41,19 +41,19 @@
ctrl.cluster_templates = [{id:"", name: gettext("Choose a Cluster Template")}]; ctrl.cluster_templates = [{id:"", name: gettext("Choose a Cluster Template")}];
$scope.model.newClusterSpec.cluster_template_id = ""; $scope.model.newClusterSpec.cluster_template_id = "";
$scope.cluster_template_detail = { $scope.cluster_template_detail = {
name: "", name: "",
id: "", id: "",
coe: "", coe: "",
image_id: "", image_id: "",
public: "", public: "",
registry_enabled: "", registry_enabled: "",
tls_disabled: "", tls_disabled: "",
apiserver_port: "" apiserver_port: ""
}; };
$scope.changeClusterTemplate = function(){ $scope.changeClusterTemplate = function() {
angular.forEach(ctrl.cluster_templates, function(model, idx){ angular.forEach(ctrl.cluster_templates, function(model) {
if($scope.model.newClusterSpec.cluster_template_id === model.id){ if ($scope.model.newClusterSpec.cluster_template_id === model.id) {
$scope.cluster_template_detail.name = model.name; $scope.cluster_template_detail.name = model.name;
$scope.cluster_template_detail.id = model.id; $scope.cluster_template_detail.id = model.id;
$scope.cluster_template_detail.coe = model.coe; $scope.cluster_template_detail.coe = model.coe;
@ -74,12 +74,10 @@
function onGetClusterTemplates(response) { function onGetClusterTemplates(response) {
Array.prototype.push.apply(ctrl.cluster_templates, response.items); Array.prototype.push.apply(ctrl.cluster_templates, response.items);
if($scope.selected instanceof Object){ if ($scope.selected instanceof Object) {
$scope.model.newClusterSpec.cluster_template_id = $scope.selected.id; $scope.model.newClusterSpec.cluster_template_id = $scope.selected.id;
$scope.changeClusterTemplate(); $scope.changeClusterTemplate();
} }
} }
} }
})(); })();

View File

@ -30,14 +30,9 @@
.controller('createClusterMiscController', createClusterMiscController); .controller('createClusterMiscController', createClusterMiscController);
createClusterMiscController.$inject = [ createClusterMiscController.$inject = [
'$scope',
'horizon.dashboard.container-infra.basePath',
'horizon.app.core.openstack-service-api.magnum'
]; ];
function createClusterMiscController($scope, basePath, magnum) { function createClusterMiscController() {
var ctrl = this;
} }
})(); })();

View File

@ -30,14 +30,9 @@
.controller('createClusterSizeController', createClusterSizeController); .controller('createClusterSizeController', createClusterSizeController);
createClusterSizeController.$inject = [ createClusterSizeController.$inject = [
'$scope',
'horizon.dashboard.container-infra.basePath',
'horizon.app.core.openstack-service-api.magnum'
]; ];
function createClusterSizeController($scope, basePath, magnum) { function createClusterSizeController() {
var ctrl = this;
} }
})(); })();

View File

@ -35,15 +35,27 @@
/** /**
* @ngDoc factory * @ngDoc factory
* @name horizon.dashboard.container-infra.clusters.delete.service * @name clusters.delete.service
* * @param {Object} $location
* @Description * @param {Object} $q
* @param {Object} magnum
* @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 clusters confirmation modal dialog. * Brings up the delete clusters confirmation modal dialog.
* On submit, delete selected resources. * On submit, delete selected resources.
* On cancel, do nothing. * On cancel, do nothing.
*/ */
function deleteService( 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 scope;
var context = { var context = {
@ -74,26 +86,26 @@
// delete selected resource objects // delete selected resource objects
function perform(selected) { function perform(selected) {
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 Cluster', title: ngettext('Confirm Delete Cluster',
'Confirm Delete Clusters', count), 'Confirm Delete Clusters', count),
/* eslint-disable max-len */ /* eslint-disable max-len */
message: ngettext('You have selected "%s". Please confirm your selection. Deleted cluster is not recoverable.', message: ngettext('You have selected "%s". Please confirm your selection. Deleted cluster is not recoverable.',
'You have selected "%s". Please confirm your selection. Deleted clusters are not recoverable.', count), 'You have selected "%s". Please confirm your selection. Deleted clusters are not recoverable.', count),
/* eslint-enable max-len */ /* eslint-enable max-len */
submit: ngettext('Delete Cluster', submit: ngettext('Delete Cluster',
'Delete Clusters', count), 'Delete Clusters', count),
success: ngettext('Deleted cluster: %s.', success: ngettext('Deleted cluster: %s.',
'Deleted clusters: %s.', count), 'Deleted clusters: %s.', count),
error: ngettext('Unable to delete cluster: %s.', error: ngettext('Unable to delete cluster: %s.',
'Unable to delete clusters: %s.', count) 'Unable to delete clusters: %s.', count)
}; };
} }
// for batch delete // for batch delete
@ -102,7 +114,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));
@ -124,9 +136,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/clusters"); $location.path("/project/clusters");
}else{ } else {
return result.result; return result.result;
} }
} }
@ -145,7 +157,7 @@
} }
// call delete REST API // call delete REST API
function deleteEntity(id){ function deleteEntity(id) {
return magnum.deleteCluster(id, true); return magnum.deleteCluster(id, true);
} }
} }

View File

@ -28,12 +28,9 @@
.controller('horizon.dashboard.container-infra.clusters.DrawerController', controller); .controller('horizon.dashboard.container-infra.clusters.DrawerController', controller);
controller.$inject = [ controller.$inject = [
'horizon.app.core.openstack-service-api.magnum',
'horizon.dashboard.container-infra.clusters.resourceType'
]; ];
function controller(magnum, resourceType) { function controller() {
var ctrl = this;
} }
})(); })();

View File

@ -20,18 +20,12 @@
ClusterOverviewController.$inject = [ ClusterOverviewController.$inject = [
'$scope', '$scope',
'horizon.app.core.openstack-service-api.magnum', 'horizon.app.core.openstack-service-api.magnum'
'horizon.dashboard.container-infra.clusters.resourceType',
'horizon.dashboard.container-infra.clusters.events',
'horizon.framework.conf.resource-type-registry.service'
]; ];
function ClusterOverviewController( function ClusterOverviewController(
$scope, $scope,
magnum, magnum
resourceType,
events,
registry
) { ) {
var ctrl = this; var ctrl = this;
ctrl.cluster = {}; ctrl.cluster = {};
@ -44,8 +38,8 @@
magnum.getClusterTemplate(ctrl.cluster.cluster_template_id).success(onGetClusterTemplate); magnum.getClusterTemplate(ctrl.cluster.cluster_template_id).success(onGetClusterTemplate);
} }
function onGetClusterTemplate(cluster_template) { function onGetClusterTemplate(clusteTemplate) {
ctrl.cluster_template = cluster_template; ctrl.clusteTemplate = clusteTemplate;
} }
} }
})(); })();

View File

@ -22,7 +22,9 @@
*/ */
angular angular
.module('horizon.dashboard.container-infra.clusters') .module('horizon.dashboard.container-infra.clusters')
.factory('horizon.dashboard.container-infra.clusters.show-certificate.service', showCertificateService); .factory(
'horizon.dashboard.container-infra.clusters.show-certificate.service',
showCertificateService);
showCertificateService.$inject = [ showCertificateService.$inject = [
'horizon.framework.util.q.extensions', 'horizon.framework.util.q.extensions',
@ -43,7 +45,7 @@
////////////// //////////////
function initScope($scope) { function initScope() {
} }
function perform(selected) { function perform(selected) {

View File

@ -25,7 +25,9 @@
*/ */
angular angular
.module('horizon.dashboard.container-infra.clusters') .module('horizon.dashboard.container-infra.clusters')
.controller('horizon.dashboard.container-infra.clusters.signCertificateController', signCertificateController); .controller(
'horizon.dashboard.container-infra.clusters.signCertificateController',
signCertificateController);
signCertificateController.$inject = [ signCertificateController.$inject = [
'horizon.app.core.openstack-service-api.magnum', 'horizon.app.core.openstack-service-api.magnum',
@ -49,11 +51,11 @@
// load csr file and set into model // load csr file and set into model
var reader = new FileReader(); var reader = new FileReader();
reader.readAsText(files[0]); reader.readAsText(files[0]);
reader.onload = function(ev){ reader.onload = function() {
model.newCertificateSpec.csr = reader.result; model.newCertificateSpec.csr = reader.result;
ctrl.model.csrfile = files[0]; ctrl.model.csrfile = files[0];
ctrl.form.$setDirty(); ctrl.form.$setDirty();
} };
// Note that a $scope.$digest() is now needed for the change to the ngModel to be // Note that a $scope.$digest() is now needed for the change to the ngModel to be
// reflected in the page (since this callback is fired from inside a DOM event) // reflected in the page (since this callback is fired from inside a DOM event)
// but the on-file-changed directive currently does a digest after this callback // but the on-file-changed directive currently does a digest after this callback

View File

@ -34,10 +34,10 @@
signCertificate: signCertificate signCertificate: signCertificate
}; };
function init(cluster_id) { function init(clusterId) {
// Reset the new Certificate spec // Reset the new Certificate spec
model.newCertificateSpec = { model.newCertificateSpec = {
cluster_uuid: cluster_id, cluster_uuid: clusterId,
csr: "" csr: ""
}; };
model.cluster_name = ""; model.cluster_name = "";

View File

@ -1,58 +0,0 @@
/**
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
(function() {
'use strict';
angular
.module('horizon.dashboard.container-infra.clusters')
.controller('horizon.dashboard.container-infra.clusters.sign-certificate-modal', SignCertificateModal);
SignCertificateModal.$inject = [
'$modal',
'horizon.app.core.workflow.factory',
'horizon.framework.util.i18n.gettext',
'horizon.framework.widgets.modal-wait-spinner.service',
'horizon.framework.widgets.toast.service',
'horizon.dashboard.container-infra.basePath'
];
function SignCertificateModal(modal, gettext, spinner, toast, basePath) {
var ctrl = this;
ctrl.model = {
cluster: model.cluster_id,
view_file: null, // file object managed by angular form ngModel
upload_file: null, // file object from the DOM element with the actual upload
DELIMETER: model.DELIMETER
};
ctrl.form = null; // set by the HTML
ctrl.changeFile = changeFile;
///////////
function changeFile(files) {
if (files.length) {
// update the upload file & its name
ctrl.model.upload_file = files[0];
ctrl.model.name = files[0].name;
ctrl.form.name.$setDirty();
// Note that a $scope.$digest() is now needed for the change to the ngModel to be
// reflected in the page (since this callback is fired from inside a DOM event)
// but the on-file-changed directive currently does a digest after this callback
// is invoked.
}
} }
})();

View File

@ -22,7 +22,9 @@
*/ */
angular angular
.module('horizon.dashboard.container-infra.clusters') .module('horizon.dashboard.container-infra.clusters')
.factory('horizon.dashboard.container-infra.clusters.sign-certificate.service', signCertificateService); .factory(
'horizon.dashboard.container-infra.clusters.sign-certificate.service',
signCertificateService);
signCertificateService.$inject = [ signCertificateService.$inject = [
'$modal', '$modal',
@ -41,8 +43,8 @@
) { ) {
var message = { var message = {
success: gettext('Certificate %s was successfully signed.') success: gettext('Certificate %s was successfully signed.')
}; };
var service = { var service = {
initScope: initScope, initScope: initScope,
@ -54,7 +56,7 @@
////////////// //////////////
function initScope($scope) { function initScope() {
} }
function signCertificateModal(html, $modal) { function signCertificateModal(html, $modal) {
@ -76,7 +78,7 @@
return $qExtensions.booleanAsPromise(true); return $qExtensions.booleanAsPromise(true);
} }
function submit(){ function submit() {
return model.signCertificate().then(success); return model.signCertificate().then(success);
} }

View File

@ -30,11 +30,11 @@
'horizon.dashboard.container-infra.cluster-templates', 'horizon.dashboard.container-infra.cluster-templates',
'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-infra/'; var path = $windowProvider.$get().STATIC_URL + 'dashboard/container-infra/';
$provide.constant('horizon.dashboard.container-infra.basePath', path); $provide.constant('horizon.dashboard.container-infra.basePath', path);
} }

View File

@ -41,7 +41,7 @@
deleteClusterTemplates: deleteClusterTemplates, deleteClusterTemplates: deleteClusterTemplates,
showCertificate: showCertificate, showCertificate: showCertificate,
signCertificate: signCertificate, signCertificate: signCertificate,
downloadTextAsFile: downloadTextAsFile, downloadTextAsFile: downloadTextAsFile
}; };
return service; return service;
@ -51,11 +51,11 @@
////////////// //////////////
function createCluster(params) { function createCluster(params) {
return apiService.post('/api/container_infra/clusters/', params) return apiService.post('/api/container_infra/clusters/', params)
.error(function() { .error(function() {
toastService.add('error', gettext('Unable to create cluster.')); toastService.add('error', gettext('Unable to create cluster.'));
}); });
} }
function getCluster(id) { function getCluster(id) {
return apiService.get('/api/container_infra/clusters/' + id) return apiService.get('/api/container_infra/clusters/' + id)
@ -125,7 +125,7 @@
return apiService.delete('/api/container_infra/cluster_templates/', ids) return apiService.delete('/api/container_infra/cluster_templates/', ids)
.error(function() { .error(function() {
toastService.add('error', gettext('Unable to delete the cluster templates.')); toastService.add('error', gettext('Unable to delete the cluster templates.'));
}) });
} }
////////////////// //////////////////
@ -146,7 +146,7 @@
}); });
} }
function downloadTextAsFile(text, filename){ function downloadTextAsFile(text, filename) {
// create text file as object url // create text file as object url
var blob = new Blob([ text ], { "type" : "text/plain" }); var blob = new Blob([ text ], { "type" : "text/plain" });
window.URL = window.URL || window.webkitURL; window.URL = window.URL || window.webkitURL;