Add support of AutoScalingGroup

Change-Id: Ib0fc88eddb9bb5b02b158d199b729bf4f42f3a11
Task: #19672
Story: #2002031
This commit is contained in:
Xinni Ge 2018-06-21 14:23:49 +09:00
parent 71f627702a
commit 6a260ecd5d
10 changed files with 438 additions and 0 deletions

View File

@ -67,6 +67,7 @@
func = hotgenUtils.extract_list;
break;
case 'resource_def':
case 'resource':
func = hotgenUtils.extract_resource_def;
break;
default:

View File

@ -24,6 +24,7 @@
.constant('horizon.dashboard.project.heat_dashboard.template_generator.validationRules', {
'name': /^[A-Za-z0-9_.-]+$/,
'path': /^\/[a-z0-9/-]+$/,
'integer': /^\d*$/,
'keypair': /^([A-Za-z0-9_.-]{1,255})=([A-Za-z0-9_.-]{1,255})$/,
'ip_address': /^([0-9.]{1,15})|([A-Fa-f0-9:]{1,39})$/,
'domain': /^[A-Za-z0-9_.-]+$/,

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="55" height="55" viewBox="0 0 55 55">
<rect id="backgroundrect" width="100%" height="100%" x="0" y="0" fill="none" stroke="none" class="" style=""/><g class="currentLayer" style=""><title>Layer 1</title><path d="M42.1771287043557,41.60010476176677 v-20.074996256989024 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h20.07495656319317 q0.2398662089352129,0 0.41515305392632923,-0.17528719158216585 t0.17528684499111694,-0.4151538747998659 zm2.3617595956697843,-20.074996256989024 v20.074996256989024 q0,1.2177846994129382 -0.8672086015349999,2.084995015661544 t-2.084990893052231,0.8672103162486069 h-20.07495656319317 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 zm-7.085278787009353,-7.085292796584362 v2.952205331910151 h-2.3617595956697843 v-2.952205331910151 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h2.9521994945872314 v2.3617642655281212 h-2.9521994945872314 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 z" id="svg_1" class="" stroke="#3f51b5" stroke-opacity="1" fill="#3f51b5" fill-opacity="1"/></g><g><title>Layer 2</title><g id="svg_3">
<circle class="frame" r="25" style="fill:none;fill-opacity=0.0;stroke-width:3;stroke:#3f51b5" cy="27.75" cx="27.5" id="svg_2"/>
</g></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="55" height="55" style=""><rect id="backgroundrect" width="100%" height="100%" x="0" y="0" fill="none" stroke="none" class="" style=""/><g class="currentLayer" style=""><title>Layer 1</title><path d="M42.1771287043557,41.60010476176677 v-20.074996256989024 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h20.07495656319317 q0.2398662089352129,0 0.41515305392632923,-0.17528719158216585 t0.17528684499111694,-0.4151538747998659 zm2.3617595956697843,-20.074996256989024 v20.074996256989024 q0,1.2177846994129382 -0.8672086015349999,2.084995015661544 t-2.084990893052231,0.8672103162486069 h-20.07495656319317 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 zm-7.085278787009353,-7.085292796584362 v2.952205331910151 h-2.3617595956697843 v-2.952205331910151 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h2.9521994945872314 v2.3617642655281212 h-2.9521994945872314 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 z" id="svg_1" class="" stroke="#808080" stroke-opacity="1" fill="#808080" fill-opacity="1"/></g><g><title>Layer 2</title><g id="svg_3">
<circle class="frame" r="25" style="fill:none;fill-opacity=0.0;stroke-width:3;stroke:#808080" cy="27.75" cx="27.5" id="svg_2"/>
</g></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="55" height="55" viewBox="0 0 55 55">
<rect id="backgroundrect" width="100%" height="100%" x="0" y="0" fill="none" stroke="none" class="" style=""/><g class="currentLayer" style=""><title>Layer 1</title><path d="M42.1771287043557,41.60010476176677 v-20.074996256989024 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h20.07495656319317 q0.2398662089352129,0 0.41515305392632923,-0.17528719158216585 t0.17528684499111694,-0.4151538747998659 zm2.3617595956697843,-20.074996256989024 v20.074996256989024 q0,1.2177846994129382 -0.8672086015349999,2.084995015661544 t-2.084990893052231,0.8672103162486069 h-20.07495656319317 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 zm-7.085278787009353,-7.085292796584362 v2.952205331910151 h-2.3617595956697843 v-2.952205331910151 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h2.9521994945872314 v2.3617642655281212 h-2.9521994945872314 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 z" id="svg_1" class="" stroke="green" stroke-opacity="1" fill="green" fill-opacity="1"/></g><g><title>Layer 2</title><g id="svg_3">
<circle class="frame" r="25" style="fill:none;fill-opacity=0.0;stroke-width:3;stroke:green" cy="27.75" cx="27.5" id="svg_2"/>
</g></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="55" height="55" viewBox="0 0 55 55">
<rect id="backgroundrect" width="100%" height="100%" x="0" y="0" fill="none" stroke="none" class="" style=""/><g class="currentLayer" style=""><title>Layer 1</title><path d="M42.1771287043557,41.60010476176677 v-20.074996256989024 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h20.07495656319317 q0.2398662089352129,0 0.41515305392632923,-0.17528719158216585 t0.17528684499111694,-0.4151538747998659 zm2.3617595956697843,-20.074996256989024 v20.074996256989024 q0,1.2177846994129382 -0.8672086015349999,2.084995015661544 t-2.084990893052231,0.8672103162486069 h-20.07495656319317 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 zm-7.085278787009353,-7.085292796584362 v2.952205331910151 h-2.3617595956697843 v-2.952205331910151 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h2.9521994945872314 v2.3617642655281212 h-2.9521994945872314 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 z" id="svg_1" class="" stroke="#C82128" stroke-opacity="1" fill="#C82128" fill-opacity="1"/></g><g><title>Layer 2</title><g id="svg_3">
<circle class="frame" r="25" style="fill:none;fill-opacity=0.0;stroke-width:3;stroke:#C82128" cy="27.75" cx="27.5" id="svg_2"/>
</g></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,144 @@
<md-tabs md-dynamic-height md-stretch-tabs="always" md-border-bottom>
<md-tab label="Properties" >
<md-content layout-padding>
<md-input-container class="md-block" flex-gt-xs>
<label>Max Size</label>
<input ng-model="$ctrl.autoscalinggroup.max_size" name="max_size" type="number" min="0" ng-pattern="validate_integer" required/>
<div ng-messages="$ctrl.formReference.max_size.$error" role="alert" multiple>
<div ng-message="number">You did not enter a valid integer.</div>
<div ng-message="min">You did not enter a non-negative number.</div>
<div ng-message="required">You must supply a maximum size.</div>
<div ng-message="pattern">You must supply an integer.</div>
</div>
</md-input-container>
<md-input-container class="md-block" flex-gt-xs>
<label>Min Size</label>
<input ng-model="$ctrl.autoscalinggroup.min_size" name="min_size" type="number" min="0" ng-pattern="validate_integer" required/>
<div ng-messages="$ctrl.formReference.min_size.$error" role="alert" multiple>
<div ng-message="number">You did not enter a valid integer.</div>
<div ng-message="min">You did not enter a non-negative number.</div>
<div ng-message="required">You must supply a minimum size.</div>
<div ng-message="pattern">You must supply an integer.</div>
</div>
</md-input-container>
<md-input-container class="md-block" flex-gt-xs>
<label>Select Resource Type by: </label>
<md-select ng-model="is_upload" aria-label="" required name="is_upload">
<md-option value="false">existing items</md-option>
<md-option value="true">uploading a template file</md-option>
</md-select>
<div ng-messages="$ctrl.formReference.is_upload.$error" role="alert" multiple>
<div ng-message="required" class="my-message">You did not specify Resource Type.</div>
</div>
</md-input-container>
<div ng-if="is_upload == 'false'">
<label>Resource Type</label>
<md-input-container class="md-block" flex-gt-xs>
<md-select ng-model="controller.autoscalinggroup.resource.type" aria-label="Resource Type">
<md-option ng-repeat="resource_type in resource_types" ng-value="resource_type">{$ resource_type $}</md-option>
</md-select>
</md-input-container>
</div>
<div ng-if="is_upload == 'true'">
<div layout-gt-sm="row" style="padding:0">
<md-input-container class="md-block" flex-gt-xs>
<label>Resource Type</label>
<input ng-model="controller.autoscalinggroup.resource.type" name="filename" type="text" readonly/>
</md-input-container>
<md-input-container class="md-block">
<md-button class="md-raised md-accent md-button md-ink-ripple" ng-click="clickUpload()" style="font-size:11px; top:-15px;">
<span class="ng-scope">choose a file</span>
</md-button>
</md-input-container>
</div>
<md-input-container class="md-block" flex-gt-xs>
<label>Resource Type Content</label>
<textarea ng-model="filecontent" readonly rows="10" maxlength="65536" name="filecontent"></textarea>
</md-input-container>
<input ng-show="false" multiple="" ng-model="file" id="resourcetype-file" name="file" type="file" onchange="angular.element(this).scope().file_upload(this)" accept=".yaml"/>
</div>
<label>Resource Properties</label>
<md-button ng-click="$ctrl.add_property()" aria-label="Add" class="md-icon-button">
<i class="fa fa-fw fa-plus"></i>
</md-button>
<div ng-repeat="record in $ctrl.autoscalinggroup.resource.properties" ng-class-odd="'odd'" ng-class-even="'even'">
<div layout-gt-xs="row" >
<md-input-container class="md-block" flex-gt-xs>
<label>Property</label>
<input ng-model="record.key" type="text">
</md-input-container>
<md-input-container class="md-block" flex-gt-xs>
<label>Value</label>
<input ng-model="record.value" type="text">
</md-input-container>
<md-button ng-click="$ctrl.delete_property($index)" aria-label="Delete" class="md-icon-button"><i class="fa fa-fw fa-times"></i></md-button>
</div>
</div>
<md-input-container class="md-block" flex-gt-xs>
<label>Cooldown</label>
<input ng-model="$ctrl.autoscalinggroup.cooldown" name="cooldown" type="number" ng-pattern="validate_integer" min="0"/>
<div ng-messages="$ctrl.formReference.cooldown.$error" role="alert" multiple>
<div ng-message="number">You did not enter a valid integer.</div>
<div ng-message="min">You did not enter a non-negative number.</div>
<div ng-message="pattern">You must supply an integer.</div>
</div>
</md-input-container>
<md-input-container class="md-block" flex-gt-xs>
<label>Desired Capacity</label>
<input ng-model="$ctrl.autoscalinggroup.desired_capacity" name="desired_capacity" type="number" ng-pattern="validate_integer" min="0"/>
<div ng-messages="$ctrl.formReference.desired_capacity.$error" role="alert" multiple>
<div ng-message="number">You did not enter a valid integer.</div>
<div ng-message="min">You did not enter a non-negative number.</div>
<div ng-message="pattern">You must supply an integer.</div>
</div>
</md-input-container>
<label>Rolling Updates</label>
<md-input-container class="md-block" flex-gt-xs>
<label>Min In Service</label>
<input ng-model="$ctrl.autoscalinggroup.rolling_updates.min_in_service" name="min_in_service" type="number" ng-pattern="validate_integer" min="0"/>
<div ng-messages="$ctrl.formReference.min_in_service.$error" role="alert" multiple>
<div ng-message="number">You did not enter a valid integer.</div>
<div ng-message="min">You did not enter a non-negative number.</div>
<div ng-message="pattern">You must supply an integer.</div>
</div>
</md-input-container>
<md-input-container class="md-block" flex-gt-xs>
<label>Pause Time</label>
<input ng-model="$ctrl.autoscalinggroup.rolling_updates.pause_time" name="pause_time" type="number" min="0"/>
<div ng-messages="$ctrl.formReference.pause_time.$error" role="alert" multiple>
<div ng-message="number">You did not enter a valid number.</div>
<div ng-message="min">You did not enter a non-negative number.</div>
</div>
</md-input-container>
<md-input-container class="md-block" flex-gt-xs>
<label>Max Batch Size</label>
<input ng-model="$ctrl.autoscalinggroup.rolling_updates.max_batch_size" name="max_batch_size" type="number" ng-pattern="validate_integer" min="1"/>
<div ng-messages="$ctrl.formReference.max_batch_size.$error" role="alert" multiple>
<div ng-message="number">You did not enter a valid integer.</div>
<div ng-message="min">You did not enter a positive number.</div>
<div ng-message="pattern">You must supply an integer.</div>
</div>
</md-input-container>
</md-content>
</md-tab>
<md-tab label="Depends on">
<md-content layout-padding>
<depends-on dependson='dependson'></depends-on>
</md-content>
</md-tab>
</md-tabs>

View File

@ -0,0 +1,145 @@
(function() {
'use strict';
/* OS::Heat::AutoScalingGroup
*
*/
angular.module('horizon.dashboard.project.heat_dashboard.template_generator')
.value('osHeatAutoScalingGroupSettings',
{
resource_key: "OS__Heat__AutoScalingGroup",
admin: false,
icon: {
class: 'fa-hdd-o',
name: 'OS::Heat::AutoScalingGroup',
code: '\uf0a0',
color: '#0bb238'
},
label: 'name',
modal_component: '<os-heat-autoscalinggroup autoscalinggroup="resource" dependson="dependson" connectedoptions="connectedoptions" form-reference="resourceForm"></os-heat-autoscalinggroup>',
edge_settings: null,
necessary_properties: ['max_size', 'min_size', 'resource']
}
)
// Register the resource to globals
angular.module('horizon.dashboard.project.heat_dashboard.template_generator')
.run(['osHeatAutoScalingGroupSettings','hotgenGlobals', function(osHeatAutoScalingGroupSettings, hotgenGlobals){
hotgenGlobals.update_resource_icons(
osHeatAutoScalingGroupSettings.resource_key ,
osHeatAutoScalingGroupSettings.icon);
hotgenGlobals.update_resource_components(
osHeatAutoScalingGroupSettings.resource_key,
osHeatAutoScalingGroupSettings.modal_component);
hotgenGlobals.update_node_labels(
osHeatAutoScalingGroupSettings.resource_key,
osHeatAutoScalingGroupSettings.label);
}]);
// Define <os-heat-autoscalinggroup> controller
function osHeatAutoScalingGroupController($scope, hotgenGlobals, hotgenNotify, validationRules) {
this.$onInit = function(){
$scope.dependson = this.dependson;
if (typeof this.autoscalinggroup.resource === 'undefined'){
this.autoscalinggroup.resource = {'type': '', 'properties': [{}]};
}
if (typeof this.autoscalinggroup.rolling_updates === 'undefined'){
this.autoscalinggroup.rolling_updates = {};
}
if (this.autoscalinggroup.resource.type){
$scope.filecontent = hotgenGlobals.get_reference_file(this.autoscalinggroup.resource.type);
}
};
$scope.validate_integer = validationRules['integer'];
$scope.controller = this;
$scope.resource_types = [];
var resource_types = hotgenGlobals.get_resource_types();
resource_types.forEach(function(element){
$scope.resource_types.push(element.replace(/_/g, ':'));
});
$scope.options = hotgenGlobals.get_resource_options();
$scope.update_upload = function(){
if ($scope.controller.autoscalinggroup && $scope.controller.autoscalinggroup.resource && $scope.controller.autoscalinggroup.resource.type.indexOf('.yaml') != -1){
return 'true';
}
return 'false';
}
$scope.is_upload = $scope.update_upload();
$scope.$watch('is_upload', function(newValue, oldValue){
if (oldValue === newValue){
return;
}
if (newValue === true || newValue === 'true'){
$scope.controller.autoscalinggroup.resource.properties = [{}];
if (!($scope.filecontent && $scope.filecontent.length >= 0)){
$scope.controller.autoscalinggroup.resource.type = '';
}
} else{
// ;
}
});
$scope.file_upload = function(element){
var file = element.files[0];
if (!file){
return;
}
var textType = /\.yaml$/;
if (file.name.match(textType)) {
var reader = new FileReader();
$scope.controller.autoscalinggroup.resource.type = file.name;
reader.onload = function(e) {
hotgenNotify.show_success('Read file content.');
hotgenGlobals.set_reference_file(file.name, reader.result)
$scope.filecontent = reader.result;
}
reader.readAsText(file);
} else {
hotgenNotify.show_error('File type is not supported.');
}
}
$scope.clickUpload = function(){
setTimeout(function () {
angular.element('#resourcetype-file').trigger('click');
}, 0);
};
this.delete_property = function(index){
this.autoscalinggroup.resource.properties.splice(index, 1);
}
this.add_property = function(){
this.autoscalinggroup.resource.properties.push({});
}
}
function osHeatAutoScalingGroupPath (basePath){
return basePath + 'js/resources/os__heat__autoscalinggroup/os__heat__autoscalinggroup.html';
}
osHeatAutoScalingGroupController.$inject = ['$scope', 'hotgenGlobals', 'hotgenNotify',
'horizon.dashboard.project.heat_dashboard.template_generator.validationRules',
];
osHeatAutoScalingGroupPath.$inject = ['horizon.dashboard.project.heat_dashboard.template_generator.basePath'];
angular.module('horizon.dashboard.project.heat_dashboard.template_generator')
.component('osHeatAutoscalinggroup', {
templateUrl: osHeatAutoScalingGroupPath,
controller: osHeatAutoScalingGroupController,
bindings: {
'autoscalinggroup': '=',
'dependson': '=',
'connectedoptions': '<',
'formReference': '<',
}
});
})();

View File

@ -0,0 +1,128 @@
(function() {
'use strict';
describe('component os-heat-auto-scaling-group', function(){
beforeEach(module('horizon.dashboard.project.heat_dashboard.template_generator'));
beforeEach(module('appTemplates'));
var $scope, $isolateScope, $compile;
var hotgenNotify;
var element;
beforeEach(inject(function($injector) {
$scope = $injector.get('$rootScope').$new();
$compile = $injector.get('$compile');
hotgenNotify = $injector.get('hotgenNotify');
spyOn(hotgenNotify, 'show_success');
spyOn(hotgenNotify, 'show_error');
$scope.resource = {};
$scope.dependson = [];
$scope.connectedoptions = [];
$scope.resourceForm = {};
// element will enable you to test your directive's element on the DOM
element = $compile(angular.element('<os-heat-autoscalinggroup autoscalinggroup="resource"'+
' dependson="dependson" connectedoptions="connectedoptions"'+
' form-reference="resourceForm"></os-heat-autoscalinggroup>'))($scope);
// Digest needs to be called to set any values on the directive's scope
$scope.$digest();
$isolateScope = element.isolateScope();
}));
it('find tab title Properties', function() {
expect(element.find('span').html()).toContain("Properties");
expect($isolateScope.is_upload).toEqual('false');
});
it('find tab title with resource set', function() {
$scope.resource = {resource: {type: 'filepath.yaml'}};
// element will enable you to test your directive's element on the DOM
element = $compile(angular.element('<os-heat-autoscalinggroup autoscalinggroup="resource"'+
' dependson="dependson" connectedoptions="connectedoptions"'+
' form-reference="resourceForm"></os-heat-autoscalinggroup'))($scope);
// Digest needs to be called to set any values on the directive's scope
$scope.$digest();
$isolateScope = element.isolateScope();
expect($isolateScope.is_upload ).toEqual('true');
});
it('$scope.is_upload should be successfully watched', function() {
$isolateScope.is_upload = 'true';
$isolateScope.$digest();
$isolateScope.is_upload = 'false';
$isolateScope.$digest();
$isolateScope.filecontent = 'some thing here';
$isolateScope.is_upload = 'true';
$isolateScope.$digest();
expect($isolateScope.controller.autoscalinggroup.resource.type ).toEqual('');
});
it('file should be successfully uploaded', function() {
var blob = new Blob([''], {type: '', });
blob['name'] = 'filename.yaml'
var upload_element = {files: [blob], }
spyOn(window, 'FileReader').and.returnValue({
readAsText: function(file) {
this.onload({});
},
result: 'file contents.'
});
$isolateScope.file_upload(upload_element);
expect($isolateScope.filecontent).toEqual('file contents.');
expect(hotgenNotify.show_success).toHaveBeenCalled();
});
it('file should be not uploaded return undefined', function() {
var upload_element = {files: []}
var returnValue = $isolateScope.file_upload(upload_element);
expect(returnValue).toEqual(undefined);
});
it('file should be not uploaded show error', function() {
var upload_element = {files: [{name: 'file.txt'}]}
var returnValue = $isolateScope.file_upload(upload_element);
expect(hotgenNotify.show_error).toHaveBeenCalled();
});
it('property should be successfully added', function() {
var $ctrl = $isolateScope.$ctrl;
$ctrl.add_property();
expect($ctrl.autoscalinggroup.resource.properties.length).toEqual(2);
});
it('property should be successfully deleted', function() {
var $ctrl = $isolateScope.$ctrl;
$ctrl.delete_property();
expect($ctrl.autoscalinggroup.resource.properties.length).toEqual(0);
});
it('click upload', function() {
spyOn(window, 'setTimeout').and.callFake(function(){});
$isolateScope.clickUpload();
expect(setTimeout).toHaveBeenCalled();
});
});
})();

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="55" height="55" viewBox="0 0 55 55">
<rect id="backgroundrect" width="100%" height="100%" x="0" y="0" fill="none" stroke="none" class="" style=""/><g class="currentLayer" style=""><title>Layer 1</title><path d="M42.1771287043557,41.60010476176677 v-20.074996256989024 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h20.07495656319317 q0.2398662089352129,0 0.41515305392632923,-0.17528719158216585 t0.17528684499111694,-0.4151538747998659 zm2.3617595956697843,-20.074996256989024 v20.074996256989024 q0,1.2177846994129382 -0.8672086015349999,2.084995015661544 t-2.084990893052231,0.8672103162486069 h-20.07495656319317 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 zm-7.085278787009353,-7.085292796584362 v2.952205331910151 h-2.3617595956697843 v-2.952205331910151 q0,-0.2398666832176999 -0.17528684499111694,-0.4151538747998659 t-0.41515305392632923,-0.17528719158216585 h-20.07495656319317 q-0.2398662089352129,0 -0.41515305392632923,0.17528719158216585 t-0.17528684499111694,0.4151538747998659 v20.074996256989024 q0,0.2398666832176999 0.17528684499111694,0.4151538747998659 t0.41515305392632923,0.17528719158216585 h2.9521994945872314 v2.3617642655281212 h-2.9521994945872314 q-1.2177822915172334,0 -2.084990893052231,-0.8672103162486069 t-0.8672086015349999,-2.084995015661544 v-20.074996256989024 q0,-1.2177846994129382 0.8672086015349999,-2.084995015661544 t2.084990893052231,-0.8672103162486069 h20.07495656319317 q1.2177822915172334,0 2.084990893052231,0.8672103162486069 t0.8672086015349999,2.084995015661544 z" id="svg_1" class="" stroke="#000000" stroke-opacity="1" fill="#000000" fill-opacity="1"/></g><g><title>Layer 2</title><g id="svg_3">
<circle class="frame" r="25" style="fill:none;fill-opacity=0.0;stroke-width:3;stroke:black" cy="27.75" cx="27.5" id="svg_2"/>
</g></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB