Updated dashboard for Angular

Add new step in the wizard when creating an instance.

Change-Id: Ica78c8a25699b2947942e87b17575d8612b3fec1
This commit is contained in:
Pierre-Alexandre Bardina 2016-04-13 11:11:04 +02:00
parent 9224f2c102
commit ce32d88e85
6 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,6 @@
FEATURE = 'cloudkitty'
ADD_ANGULAR_MODULES = [
'horizon.dashboard.cloudkitty',
]
AUTO_DISCOVER_STATIC_FILES = True

View File

@ -0,0 +1,44 @@
(function () {
'use strict';
angular
.module('horizon.dashboard.cloudkitty')
.controller('CloudkittyStepController', CloudkittyStepController);
CloudkittyStepController.$inject = [
'$scope',
'horizon.framework.widgets.wizard.events',
'$http'
];
function CloudkittyStepController($scope, wizardEvents, $http) {
var onSwitch = $scope.$on(wizardEvents.ON_SWITCH, function(evt, args) {
if(!$scope.model.newInstanceSpec.flavor) return false;
var disk_total = $scope.model.newInstanceSpec.flavor.ephemeral + $scope.model.newInstanceSpec.flavor.disk;
var desc_form = {
'flavor': $scope.model.newInstanceSpec.flavor.name,
'flavor_id': $scope.model.newInstanceSpec.flavor.id,
'vcpus': $scope.model.newInstanceSpec.flavor.vcpus,
'disk': $scope.model.newInstanceSpec.flavor.disk,
'ephemeral': $scope.model.newInstanceSpec.flavor.ephemeral,
'disk_total': disk_total,
'disk_total_display': disk_total,
'ram': $scope.model.newInstanceSpec.flavor.ram,
'source_type': $scope.model.newInstanceSpec.source_type.type,
'source_val': $scope.model.newInstanceSpec.source[0].id,
'image_id': $scope.model.newInstanceSpec.source[0].id,
}
var form_data = [{"service": "compute", "desc": desc_form, "volume": $scope.model.newInstanceSpec.instance_count}];
$http.post('/dashboard/project/rating/quote', form_data).then(function(res, status) {
$scope.price = res.data;
});
});
}
})();

View File

@ -0,0 +1,26 @@
(function () {
'use strict';
var ck = angular.module('horizon.dashboard.cloudkitty', ['horizon.dashboard.project.workflow']).config(config)
config.$inject = [
'$provide',
'$windowProvider'
];
function config($provide, $windowProvider) {
$provide.decorator("horizon.dashboard.project.workflow.launch-instance.workflow", ['$delegate', function ($delegate) {
var workflow = $delegate;
workflow.append({
formName: 'CloudkittyForm',
templateUrl: '/dashboard/static/cloudkitty/templates/cloudkitty-step.html',
helpUrl: '/dashboard/static/cloudkitty/templates/cloudkitty-help.html',
title: 'Price'
});
return workflow;
}]);
}
})();

View File

@ -0,0 +1,10 @@
(function () {
'use strict';
describe('horizon.dashboard.cloudkitty', function () {
it('should be defined', function () {
expect(angular.module('horizon.dashboard.cloudkitty')).toBeDefined();
});
});
})();

View File

@ -0,0 +1,3 @@
<div>
<h1>Price for instance(s)</h1>
</div>

View File

@ -0,0 +1,6 @@
<div class="ck" ng-controller="CloudkittyStepController as ctrl">
<h3>Price</h3>
<p>
<span id="price">{$ price | currency $}</span>
</p>
</div>