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} events
* @returns {Object} delete service
* @Description
* @description
* Brings up the delete cluster templates confirmation modal dialog.
* On submit, delete selected resources.
* On cancel, do nothing.

View File

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

View File

@ -39,7 +39,8 @@
/**
* @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
*/
function events() {
@ -60,7 +61,7 @@
registry.getResourceType(resourceType)
.setNames(gettext('Cluster'), gettext('Clusters'))
// 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', {

View File

@ -39,7 +39,8 @@
];
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;
@ -79,7 +80,7 @@
return $qExtensions.booleanAsPromise(true);
}
function submit(){
function submit() {
return model.createCluster().then(success);
}
@ -88,9 +89,9 @@
toast.add('success', interpolate(message.success, [response.data.id]));
var result = actionResult.getActionResult()
.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");
}else{
} else {
return result.result;
}
}

View File

@ -41,19 +41,19 @@
ctrl.cluster_templates = [{id:"", name: gettext("Choose a Cluster Template")}];
$scope.model.newClusterSpec.cluster_template_id = "";
$scope.cluster_template_detail = {
name: "",
id: "",
coe: "",
image_id: "",
public: "",
registry_enabled: "",
tls_disabled: "",
apiserver_port: ""
name: "",
id: "",
coe: "",
image_id: "",
public: "",
registry_enabled: "",
tls_disabled: "",
apiserver_port: ""
};
$scope.changeClusterTemplate = function(){
angular.forEach(ctrl.cluster_templates, function(model, idx){
if($scope.model.newClusterSpec.cluster_template_id === model.id){
$scope.changeClusterTemplate = function() {
angular.forEach(ctrl.cluster_templates, function(model) {
if ($scope.model.newClusterSpec.cluster_template_id === model.id) {
$scope.cluster_template_detail.name = model.name;
$scope.cluster_template_detail.id = model.id;
$scope.cluster_template_detail.coe = model.coe;
@ -74,12 +74,10 @@
function onGetClusterTemplates(response) {
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.changeClusterTemplate();
}
}
}
})();

View File

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

View File

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

View File

@ -35,15 +35,27 @@
/**
* @ngDoc factory
* @name horizon.dashboard.container-infra.clusters.delete.service
*
* @Description
* @name clusters.delete.service
* @param {Object} $location
* @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.
* 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,26 +86,26 @@
// 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',
'Confirm Delete Clusters', count),
/* eslint-disable max-len */
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),
/* eslint-enable max-len */
submit: ngettext('Delete Cluster',
'Delete Clusters', count),
success: ngettext('Deleted cluster: %s.',
'Deleted clusters: %s.', count),
error: ngettext('Unable to delete cluster: %s.',
'Unable to delete clusters: %s.', count)
};
title: ngettext('Confirm Delete Cluster',
'Confirm Delete Clusters', count),
/* eslint-disable max-len */
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),
/* eslint-enable max-len */
submit: ngettext('Delete Cluster',
'Delete Clusters', count),
success: ngettext('Deleted cluster: %s.',
'Deleted clusters: %s.', count),
error: ngettext('Unable to delete cluster: %s.',
'Unable to delete clusters: %s.', count)
};
}
// for batch delete
@ -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/clusters");
}else{
} else {
return result.result;
}
}
@ -145,7 +157,7 @@
}
// call delete REST API
function deleteEntity(id){
function deleteEntity(id) {
return magnum.deleteCluster(id, true);
}
}

View File

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

View File

@ -20,18 +20,12 @@
ClusterOverviewController.$inject = [
'$scope',
'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'
'horizon.app.core.openstack-service-api.magnum'
];
function ClusterOverviewController(
$scope,
magnum,
resourceType,
events,
registry
magnum
) {
var ctrl = this;
ctrl.cluster = {};
@ -44,8 +38,8 @@
magnum.getClusterTemplate(ctrl.cluster.cluster_template_id).success(onGetClusterTemplate);
}
function onGetClusterTemplate(cluster_template) {
ctrl.cluster_template = cluster_template;
function onGetClusterTemplate(clusteTemplate) {
ctrl.clusteTemplate = clusteTemplate;
}
}
})();

View File

@ -22,7 +22,9 @@
*/
angular
.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 = [
'horizon.framework.util.q.extensions',
@ -43,7 +45,7 @@
//////////////
function initScope($scope) {
function initScope() {
}
function perform(selected) {

View File

@ -25,7 +25,9 @@
*/
angular
.module('horizon.dashboard.container-infra.clusters')
.controller('horizon.dashboard.container-infra.clusters.signCertificateController', signCertificateController);
.controller(
'horizon.dashboard.container-infra.clusters.signCertificateController',
signCertificateController);
signCertificateController.$inject = [
'horizon.app.core.openstack-service-api.magnum',
@ -49,11 +51,11 @@
// load csr file and set into model
var reader = new FileReader();
reader.readAsText(files[0]);
reader.onload = function(ev){
reader.onload = function() {
model.newCertificateSpec.csr = reader.result;
ctrl.model.csrfile = files[0];
ctrl.form.$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

View File

@ -34,10 +34,10 @@
signCertificate: signCertificate
};
function init(cluster_id) {
function init(clusterId) {
// Reset the new Certificate spec
model.newCertificateSpec = {
cluster_uuid: cluster_id,
cluster_uuid: clusterId,
csr: ""
};
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
.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 = [
'$modal',
@ -41,8 +43,8 @@
) {
var message = {
success: gettext('Certificate %s was successfully signed.')
};
success: gettext('Certificate %s was successfully signed.')
};
var service = {
initScope: initScope,
@ -54,7 +56,7 @@
//////////////
function initScope($scope) {
function initScope() {
}
function signCertificateModal(html, $modal) {
@ -76,7 +78,7 @@
return $qExtensions.booleanAsPromise(true);
}
function submit(){
function submit() {
return model.signCertificate().then(success);
}

View File

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

View File

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