horizon/openstack_dashboard/static/dashboard/launch-instance/launch-instance.js
Shaoquan Chen 6f1eec9ca7 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
2015-02-19 14:39:52 -08:00

104 lines
2.9 KiB
JavaScript

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