Base launch instance wizard

- Setting up base launch instance wizard to enable parallel
  development on steps in the work flow.
- Adding business logic related code to openstack_dashboard
  project.
- Using Horizon's well-defined plug-in architecture to hook
  launch instance to Horizon.

Partially Implements: blueprint launch-instance-redesign
Change-Id: Ibbbbfc7f49c58a78b0d1b29e363531d5ae1a9aab
This commit is contained in:
Shaoquan Chen 2015-02-08 19:44:06 -08:00
parent 7bd54ac335
commit 6f1eec9ca7
35 changed files with 339 additions and 1 deletions

View File

@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('hz.widget.wizard', [])
angular.module('hz.widget.wizard', ['ui.bootstrap'])
.constant('wizardLabels', {
cancel: gettext('Cancel'),

View File

@ -1,3 +1,17 @@
# 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.
# The slug of the dashboard to be added to HORIZON['dashboards']. Required.
DASHBOARD = 'project'
# If set to True, this dashboard will be set as the default dashboard.
@ -6,3 +20,27 @@ DEFAULT = True
ADD_EXCEPTIONS = {}
# A list of applications to be added to INSTALLED_APPS.
ADD_INSTALLED_APPS = ['openstack_dashboard.dashboards.project']
ADD_ANGULAR_MODULES = ['hz.dashboard']
LAUNCH_INST = 'dashboard/launch-instance/'
ADD_JS_FILES = [
'dashboard/dashboard.module.js',
LAUNCH_INST + 'launch-instance.js',
LAUNCH_INST + 'source/source.js',
LAUNCH_INST + 'flavor/flavor.js',
LAUNCH_INST + 'network/network.js',
LAUNCH_INST + 'access-and-security/access-and-security.js',
LAUNCH_INST + 'post-creation/post-creation.js',
]
ADD_JS_SPEC_FILES = [
'dashboard/dashboard.module.spec.js',
LAUNCH_INST + 'launch-instance.spec.js',
LAUNCH_INST + 'source/source.spec.js',
LAUNCH_INST + 'flavor/flavor.spec.js',
LAUNCH_INST + 'network/network.spec.js',
LAUNCH_INST + 'access-and-security/access-and-security.spec.js',
LAUNCH_INST + 'post-creation/post-creation.spec.js',
]

View File

@ -0,0 +1,10 @@
(function () {
'use strict';
var module = angular.module('hz.dashboard', [
'hz.dashboard.launch-instance'
]);
module.constant('dashboardBasePath', '/static/dashboard/');
})();

View File

@ -0,0 +1,2 @@
/* jshint globalstrict: true */
'use strict';

View File

@ -0,0 +1,2 @@
@import "./scss/variables";
@import "launch-instance/launch-instance";

View File

@ -0,0 +1,4 @@
<div ng-controller="LaunchInstanceAccessAndSecurityHelpCtrl">
<h1>{$ title $}</h1>
<p></p>
</div>

View File

@ -0,0 +1,3 @@
<div ng-controller="LaunchInstanceAccessAndSecurityCtrl">
<h1>{$ title $}</h1>
</div>

View File

@ -0,0 +1,24 @@
(function () {
'use strict';
var module = angular.module('hz.dashboard.launch-instance');
module.controller('LaunchInstanceAccessAndSecurityCtrl', [
'$scope',
LaunchInstanceAccessAndSecurityCtrl
]);
module.controller('LaunchInstanceAccessAndSecurityHelpCtrl', [
'$scope',
LaunchInstanceAccessAndSecurityHelpCtrl
]);
function LaunchInstanceAccessAndSecurityCtrl($scope) {
$scope.title = gettext('Access and Security');
}
function LaunchInstanceAccessAndSecurityHelpCtrl($scope) {
$scope.title = gettext('Access and Security Help');
}
})();

View File

@ -0,0 +1,2 @@
/* jshint globalstrict: true */
'use strict';

View File

@ -0,0 +1,4 @@
<div ng-controller="LaunchInstanceFlavorHelpCtrl">
<h1>{$ title $}</h1>
<p></p>
</div>

View File

@ -0,0 +1,3 @@
<div ng-controller="LaunchInstanceFlavorCtrl">
<h1>{$ title $}</h1>
</div>

View File

@ -0,0 +1,24 @@
(function () {
'use strict';
var module = angular.module('hz.dashboard.launch-instance');
module.controller('LaunchInstanceFlavorCtrl', [
'$scope',
LaunchInstanceFlavorCtrl
]);
module.controller('LaunchInstanceFlavorHelpCtrl', [
'$scope',
LaunchInstanceFlavorHelpCtrl
]);
function LaunchInstanceFlavorCtrl($scope) {
$scope.title = gettext('Select a Flavor');
}
function LaunchInstanceFlavorHelpCtrl($scope) {
$scope.title = gettext('Flavor Help');
}
})();

View File

@ -0,0 +1,2 @@
/* jshint globalstrict: true */
'use strict';

View File

@ -0,0 +1,103 @@
(function () {
'use strict';
var module = angular.module('hz.dashboard.launch-instance', []);
module.factory('launchInstanceWorkflow', ['dashboardBasePath', function (path) {
return {
title: gettext('Launch Instance'),
steps: [
{
title: gettext('Select Source'),
templateUrl: path + 'launch-instance/source/source.html',
helpUrl: path + 'launch-instance/source/source.help.html',
formName: 'launchInstanceSourceForm'
},
{
title: gettext('Flavor'),
templateUrl: path + 'launch-instance/flavor/flavor.html',
helpUrl: path + 'launch-instance/flavor/flavor.help.html',
formName: 'launchInstanceFlavorForm'
},
{
title: gettext('Network'),
templateUrl: path + 'launch-instance/network/network.html',
helpUrl: path + 'launch-instance/network/network.help.html',
formName: 'launchInstanceNetworkForm'
},
{
title: gettext('Access and Security'),
templateUrl: path + 'launch-instance/access-and-security/access-and-security.html',
helpUrl: path + 'launch-instance/access-and-security/access-and-security.help.html',
formName: 'launchInstanceAccessAndSecurityForm'
},
{
title: gettext('Post Creation'),
templateUrl: path + 'launch-instance/post-creation/post-creation.html',
helpUrl: path + 'launch-instance/post-creation/post-creation.help.html',
formName: 'launchInstancePostCreationForm'
}
],
btnText: {
finish: gettext('Launch Instance')
},
btnIcon: {
finish: 'fa fa-cloud-download'
}
};
}]);
// Using bootstrap-ui modal widget
module.constant('launchInstanceWizardModalSpec', {
backdrop: 'static',
controller: 'ModalContainerCtrl',
template: '<wizard ng-controller="LaunchInstanceWizardCtrl"></wizard>',
windowClass: 'modal-dialog-wizard'
});
module.controller('LaunchInstanceWizardCtrl', [
'$scope',
'$q', // temporary, should call api access services
'launchInstanceWorkflow',
LaunchInstanceWizardCtrl
]);
module.controller('LaunchInstanceModalCtrl', [
'$scope',
'$modal',
'launchInstanceWizardModalSpec',
LaunchInstanceModalCtrl
]);
function LaunchInstanceWizardCtrl($scope, $q, launchInstanceWorkflow) {
$scope.workflow = launchInstanceWorkflow;
$scope.model = {
source: {},
flavor: {},
network: {},
accessAndSecurity: {},
postCreation: {}
};
$scope.submit = function () {
return $q(function (resolve) {
//
// emulating server side process
//
setTimeout(function () {
resolve();
}, 1000);
});
};
}
function LaunchInstanceModalCtrl($scope, $modal, modalSpec) {
$scope.openLaunchInstanceWizard = function () {
$modal.open(modalSpec);
};
}
})();

View File

@ -0,0 +1,5 @@
@import "source/source";
@import "flavor/flavor";
@import "network/network";
@import "access-and-security/access-and-security";
@import "post-creation/post-creation";

View File

@ -0,0 +1,2 @@
/* jshint globalstrict: true */
'use strict';

View File

@ -0,0 +1,4 @@
<div ng-controller="LaunchInstanceNetworkHelpCtrl">
<h1>{$ title $}</h1>
<p></p>
</div>

View File

@ -0,0 +1,3 @@
<div ng-controller="LaunchInstanceNetworkCtrl">
<h1>{$ title $}</h1>
</div>

View File

@ -0,0 +1,24 @@
(function () {
'use strict';
var module = angular.module('hz.dashboard.launch-instance');
module.controller('LaunchInstanceNetworkCtrl', [
'$scope',
LaunchInstanceNetworkCtrl
]);
module.controller('LaunchInstanceNetworkHelpCtrl', [
'$scope',
LaunchInstanceNetworkHelpCtrl
]);
function LaunchInstanceNetworkCtrl($scope) {
$scope.title = gettext('Network');
}
function LaunchInstanceNetworkHelpCtrl($scope) {
$scope.title = gettext('Network Help');
}
})();

View File

@ -0,0 +1,2 @@
/* jshint globalstrict: true */
'use strict';

View File

@ -0,0 +1,4 @@
<div ng-controller="LaunchInstancePostCreationHelpCtrl">
<h1>{$ title $}</h1>
<p></p>
</div>

View File

@ -0,0 +1,3 @@
<div ng-controller="LaunchInstancePostCreationCtrl">
<h1>{$ title $}</h1>
</div>

View File

@ -0,0 +1,23 @@
(function () {
'use strict';
var module = angular.module('hz.dashboard.launch-instance');
module.controller('LaunchInstancePostCreationCtrl', [
'$scope',
LaunchInstancePostCreationCtrl
]);
module.controller('LaunchInstancePostCreationHelpCtrl', [
'$scope',
LaunchInstancePostCreationHelpCtrl
]);
function LaunchInstancePostCreationCtrl($scope) {
$scope.title = gettext('Post Creation');
}
function LaunchInstancePostCreationHelpCtrl($scope) {
$scope.title = gettext('Post Creation Help');
}
})();

View File

@ -0,0 +1,2 @@
/* jshint globalstrict: true */
'use strict';

View File

@ -0,0 +1,4 @@
<div ng-controller="LaunchInstanceSourceHelpCtrl">
<h1>{$ title $}</h1>
<p></p>
</div>

View File

@ -0,0 +1,3 @@
<div ng-controller="LaunchInstanceSourceCtrl">
<h1>{$ title $}</h1>
</div>

View File

@ -0,0 +1,24 @@
(function () {
'use strict';
var module = angular.module('hz.dashboard.launch-instance');
module.controller('LaunchInstanceSourceCtrl', [
'$scope',
LaunchInstanceSourceCtrl
]);
module.controller('LaunchInstanceSourceHelpCtrl', [
'$scope',
LaunchInstanceSourceHelpCtrl
]);
function LaunchInstanceSourceCtrl($scope) {
$scope.title = gettext('Instance Details');
}
function LaunchInstanceSourceHelpCtrl($scope) {
$scope.title = gettext('Instance Details Help');
}
})();

View File

@ -0,0 +1,2 @@
/* jshint globalstrict: true */
'use strict';

View File

@ -1,7 +1,18 @@
{% comment %}
We want to have separate compressed css files for horizon.scss and dashboard.scss.
The reason for it is based on the fact that IE9 has a limit on the number of css rules
that can be parsed in a single css file. The limit is 4095 = (4k - 1). This causes some
css rules getting cut off if one css file to get more than 4k rules inside.
{% endcomment %}
{% load compress %}
{% compress css %}
<link href='{{ STATIC_URL }}dashboard/scss/horizon.scss' type='text/scss' media='screen' rel='stylesheet' />
{% endcompress %}
{% compress css %}
<link href='{{ STATIC_URL }}dashboard/dashboard.scss' type='text/scss' media='screen' rel='stylesheet' />
{% endcompress %}
<link rel="shortcut icon" href="{{ STATIC_URL }}dashboard/img/favicon.ico"/>

View File

@ -158,6 +158,7 @@ function run_jshint {
jshint horizon/static/horizon/js
jshint horizon/static/horizon/tests
jshint horizon/static/angular/
jshint openstack_dashboard/static/dashboard/
}
function warn_on_flake8_without_venv {