Fix eslint errors on Cluster Templates

This patch fixes eslint errors on Cluster Templates namespace.

Change-Id: Ie1bc94a588a0ddeb4925f4cf43c4d3cd2219beab
Partial-Bug: #1622475
This commit is contained in:
Shu Muto 2016-09-12 18:19:51 +09:00
parent 22dc448cf3
commit 04d0257d71
12 changed files with 88 additions and 82 deletions

View File

@ -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 @@
}
});
}
})();

View File

@ -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/';

View File

@ -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];
}
}

View File

@ -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',

View File

@ -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);
}

View File

@ -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;
}
};
}
})();

View File

@ -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() {
}
})();

View File

@ -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() {
}
})();

View File

@ -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});
});
}
};
}
})();

View File

@ -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);
}
}

View File

@ -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() {
}
})();

View File

@ -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);