JSCS cleanup - openstack_dashboard/static/dashboard/workflow
This patch breaks up workflow.js into small pieces according to Horizon code style. Change-Id: I2358020f29de4a235dd35553621b007da70d47fa Partially-Implements: blueprint jscs-cleanup
This commit is contained in:
parent
28d4339241
commit
bd6fec1400
@ -27,7 +27,9 @@ LAUNCH_INST = 'dashboard/launch-instance/'
|
|||||||
|
|
||||||
ADD_JS_FILES = [
|
ADD_JS_FILES = [
|
||||||
'dashboard/dashboard.module.js',
|
'dashboard/dashboard.module.js',
|
||||||
'dashboard/workflow/workflow.js',
|
'dashboard/workflow/workflow.module.js',
|
||||||
|
'dashboard/workflow/decorator.service.js',
|
||||||
|
'dashboard/workflow/workflow.service.js',
|
||||||
'dashboard/cloud-services/cloud-services.js',
|
'dashboard/cloud-services/cloud-services.js',
|
||||||
LAUNCH_INST + 'launch-instance.js',
|
LAUNCH_INST + 'launch-instance.js',
|
||||||
LAUNCH_INST + 'launch-instance.model.js',
|
LAUNCH_INST + 'launch-instance.model.js',
|
||||||
@ -48,7 +50,7 @@ ADD_JS_FILES = [
|
|||||||
|
|
||||||
ADD_JS_SPEC_FILES = [
|
ADD_JS_SPEC_FILES = [
|
||||||
'dashboard/dashboard.module.spec.js',
|
'dashboard/dashboard.module.spec.js',
|
||||||
'dashboard/workflow/workflow.spec.js',
|
'dashboard/workflow/workflow.module.spec.js',
|
||||||
'dashboard/cloud-services/cloud-services.spec.js',
|
'dashboard/cloud-services/cloud-services.spec.js',
|
||||||
LAUNCH_INST + 'launch-instance.spec.js',
|
LAUNCH_INST + 'launch-instance.spec.js',
|
||||||
LAUNCH_INST + 'launch-instance.model.spec.js',
|
LAUNCH_INST + 'launch-instance.model.spec.js',
|
||||||
|
@ -91,7 +91,6 @@ module.exports = function (config) {
|
|||||||
* not significant.
|
* not significant.
|
||||||
*/
|
*/
|
||||||
'**/*.module.js',
|
'**/*.module.js',
|
||||||
'**/workflow.js',
|
|
||||||
'**/launch-instance.js',
|
'**/launch-instance.js',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
module.factory('launchInstanceWorkflow', [
|
module.factory('launchInstanceWorkflow', [
|
||||||
'dashboardBasePath',
|
'dashboardBasePath',
|
||||||
'dashboardWorkflow',
|
'hz.dashboard.workflow.factory',
|
||||||
|
|
||||||
function (path, dashboardWorkflow) {
|
function (path, dashboardWorkflow) {
|
||||||
|
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
*
|
||||||
|
* 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';
|
||||||
|
|
||||||
|
var forEach = angular.forEach;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc factory
|
||||||
|
* @name hz.dashboard.workflow.factory:hz.dashboard.workflow.decorator
|
||||||
|
* @module hz.dashboard.workflow
|
||||||
|
* @kind function
|
||||||
|
* @description
|
||||||
|
*
|
||||||
|
* A workflow decorator function that adds checkReadiness method to step in
|
||||||
|
* the work flow. checkReadiness function will check if a bunch of certain
|
||||||
|
* types of OpenStack services is enabled in the cloud for that step to show
|
||||||
|
* on the user interface.
|
||||||
|
*
|
||||||
|
* Injected dependencies:
|
||||||
|
* - $q
|
||||||
|
* - serviceCatalog horizon.openstack-service-api.serviceCatalog
|
||||||
|
*
|
||||||
|
* @param {Object} spec The input workflow specification object.
|
||||||
|
* @returns {Object} The decorated workflow specification object, the same
|
||||||
|
* reference to the input spec object.
|
||||||
|
*
|
||||||
|
* | Factories |
|
||||||
|
* |----------------------------------------------------------------------------------------------------------|
|
||||||
|
* | {@link hz.dashboard.workflow.factory:hz.dashboard.workflow.decorator `hz.dashboard.workflow.decorator`} |
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
angular
|
||||||
|
.module('hz.dashboard.workflow')
|
||||||
|
.factory('hz.dashboard.workflow.decorator', dashboardWorkflowDecorator);
|
||||||
|
|
||||||
|
dashboardWorkflowDecorator.$inject = [
|
||||||
|
'$q',
|
||||||
|
'horizon.openstack-service-api.serviceCatalog'
|
||||||
|
];
|
||||||
|
|
||||||
|
/////////////
|
||||||
|
|
||||||
|
function dashboardWorkflowDecorator($q, serviceCatalog) {
|
||||||
|
return decorator;
|
||||||
|
|
||||||
|
function decorator(spec) {
|
||||||
|
decorate(spec);
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
function decorate(spec) {
|
||||||
|
forEach(spec.steps, decorateStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
function decorateStep(step) {
|
||||||
|
var types = step.requiredServiceTypes;
|
||||||
|
if (types && types.length > 0) {
|
||||||
|
step.checkReadiness = function () {
|
||||||
|
return $q.all(types.map(function (type) {
|
||||||
|
return serviceCatalog.ifTypeEnabled(type);
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
@ -1,107 +0,0 @@
|
|||||||
(function () {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var forEach = angular.forEach;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc overview
|
|
||||||
* @name hz.dashboard.workflow
|
|
||||||
* @description
|
|
||||||
*
|
|
||||||
* # hz.dashboard.workflow
|
|
||||||
*
|
|
||||||
* This module provides utility function factory `dashboardWorkflow` and
|
|
||||||
* `dashboardWorkflowDecorator`.
|
|
||||||
*
|
|
||||||
* | Factories |
|
|
||||||
* |------------------------------------------------------------------------------------------------|
|
|
||||||
* | {@link hz.dashboard.workflow.factory:dashboardWorkflowDecorator `dashboardWorkflowDecorator`} |
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
angular.module('hz.dashboard.workflow', [])
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc factory
|
|
||||||
* @name hz.dashboard.workflow.factory:dashboardWorkflowDecorator
|
|
||||||
* @module hz.dashboard.workflow
|
|
||||||
* @kind function
|
|
||||||
* @description
|
|
||||||
*
|
|
||||||
* A workflow decorator function that adds checkReadiness method to step in
|
|
||||||
* the work flow. checkReadiness function will check is a bunch of certain
|
|
||||||
* types of OpenStack services is enabled in the cloud for that step to show
|
|
||||||
* on the user interface.
|
|
||||||
*
|
|
||||||
* Injected dependencies:
|
|
||||||
* - $q
|
|
||||||
* - serviceCatalog horizon.openstack-service-api.serviceCatalog
|
|
||||||
*
|
|
||||||
* @param {Object} spec The input workflow specification object.
|
|
||||||
* @returns {Object} The decorated workflow specification object, the same
|
|
||||||
* reference to the input spec object.
|
|
||||||
*
|
|
||||||
* | Factories |
|
|
||||||
* |------------------------------------------------------------------------------------------------|
|
|
||||||
* | {@link hz.dashboard.workflow.factory:dashboardWorkflowDecorator `dashboardWorkflowDecorator`} |
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
.factory('dashboardWorkflowDecorator', ['$q', 'horizon.openstack-service-api.serviceCatalog',
|
|
||||||
|
|
||||||
function ($q, serviceCatalog) {
|
|
||||||
|
|
||||||
function decorate(spec) {
|
|
||||||
forEach(spec.steps, function (step) {
|
|
||||||
var types = step.requiredServiceTypes;
|
|
||||||
if (types && types.length > 0) {
|
|
||||||
step.checkReadiness = function () {
|
|
||||||
return $q.all(types.map(function (type) {
|
|
||||||
return serviceCatalog.ifTypeEnabled(type);
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return function (spec) {
|
|
||||||
decorate(spec);
|
|
||||||
return spec;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
])
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc factory
|
|
||||||
* @name hz.dashboard.workflow.factory:dashboardWorkflow
|
|
||||||
* @module hz.dashboard.workflow
|
|
||||||
* @kind function
|
|
||||||
* @description
|
|
||||||
*
|
|
||||||
* Injected dependencies:
|
|
||||||
* - workflow {@link horizon.framework.util.workflow.factory:workflow `workflow`}
|
|
||||||
* - dashboardWorkflowDecorator {@link hz.dashboard.workflow.factory
|
|
||||||
* :dashboardWorkflowDecorator `dashboardWorkflowDecorator`}
|
|
||||||
*
|
|
||||||
* @param {Object} The input workflow specification object
|
|
||||||
*
|
|
||||||
* @returns {Object} The decorated workflow specification object, the same
|
|
||||||
* reference to the input spec object.
|
|
||||||
*
|
|
||||||
* | Factories |
|
|
||||||
* |------------------------------------------------------------------------------|
|
|
||||||
* | {@link hz.dashboard.workflow.factory:dashboardWorkflow `dashboardWorkflow`} |
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
.factory('dashboardWorkflow', [
|
|
||||||
'horizon.framework.util.workflow.service',
|
|
||||||
'dashboardWorkflowDecorator',
|
|
||||||
function (workflow, dashboardWorkflowDecorator) {
|
|
||||||
var decorators = [dashboardWorkflowDecorator];
|
|
||||||
return function (spec) {
|
|
||||||
return workflow(spec, decorators);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
})();
|
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
*
|
||||||
|
* 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';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc overview
|
||||||
|
* @name hz.dashboard.workflow
|
||||||
|
* @description
|
||||||
|
*
|
||||||
|
* # hz.dashboard.workflow
|
||||||
|
*
|
||||||
|
* This module provides utility function factory `dashboardWorkflow` and
|
||||||
|
* `dashboardWorkflowDecorator`.
|
||||||
|
*
|
||||||
|
* | Factories |
|
||||||
|
* |------------------------------------------------------------------------------------------------|
|
||||||
|
* | {@link hz.dashboard.workflow.factory:dashboardWorkflowDecorator `dashboardWorkflowDecorator`} |
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
angular.module('hz.dashboard.workflow', []);
|
||||||
|
|
||||||
|
})();
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
*
|
||||||
|
* 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';
|
||||||
|
|
||||||
|
describe('hz.dashboard.workflow module', function () {
|
||||||
|
it('should have been defined', function () {
|
||||||
|
expect(angular.module('hz.dashboard.workflow')).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
*
|
||||||
|
* 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';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc factory
|
||||||
|
* @name hz.dashboard.workflow.factory:hz.dashboard.workflow.factory
|
||||||
|
* @module hz.dashboard.workflow
|
||||||
|
* @kind function
|
||||||
|
* @description
|
||||||
|
*
|
||||||
|
* Injected dependencies:
|
||||||
|
* - workflow {@link horizon.framework.util.workflow.service:workflow `workflow`}
|
||||||
|
* - dashboardWorkflowDecorator {@link hz.dashboard.workflow.factory
|
||||||
|
* :hz.dashboard.workflow.decorator `dashboardWorkflowDecorator`}
|
||||||
|
*
|
||||||
|
* @param {Object} The input workflow specification object
|
||||||
|
* @returns {Object} The decorated workflow specification object, the same
|
||||||
|
* reference to the input spec object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
angular
|
||||||
|
.module('hz.dashboard.workflow')
|
||||||
|
.factory('hz.dashboard.workflow.factory', dashboardWorkflow);
|
||||||
|
|
||||||
|
dashboardWorkflow.$inject = [
|
||||||
|
'horizon.framework.util.workflow.service',
|
||||||
|
'hz.dashboard.workflow.decorator'
|
||||||
|
];
|
||||||
|
|
||||||
|
/////////////
|
||||||
|
|
||||||
|
function dashboardWorkflow(workflow, dashboardWorkflowDecorator) {
|
||||||
|
var decorators = [dashboardWorkflowDecorator];
|
||||||
|
return function (spec) {
|
||||||
|
return workflow(spec, decorators);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
@ -1,10 +0,0 @@
|
|||||||
(function () {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
describe('hz.dashboard.workflow module', function () {
|
|
||||||
it('should have been defined', function () {
|
|
||||||
expect(angular.module('hz.dashboard.workflow')).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
})();
|
|
Loading…
Reference in New Issue
Block a user