Browse Source

Add support of ScalingPolicy

Change-Id: I9cc4e8097e0be5ae9d6420cd60eeb4e4b7be2f1c
Story: #2002028
Task: #19669
Xinni Ge 10 months ago
parent
commit
4b0fcd3016

+ 6
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-blue.svg View File

@@ -0,0 +1,6 @@
1
+<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">
2
+<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>
3
+<g><text x="25" y="40" style="fill: #3f51b5; stroke: #3f51b5; font-size: 20px;font-family:Helvetica;" id="svg_1" class="">P</text></g>
4
+<g id="svg_3">
5
+<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"/>
6
+</g></g></svg>

+ 6
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-gray.svg View File

@@ -0,0 +1,6 @@
1
+<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">
2
+<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>
3
+<g><text x="25" y="40" style="fill: #808080; stroke: #808080; font-size: 20px;font-family:Helvetica;" id="svg_1" class="">P</text></g>
4
+<g id="svg_3">    
5
+    <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"/>
6
+</g></g></svg>

+ 6
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-green.svg View File

@@ -0,0 +1,6 @@
1
+<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">
2
+<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>
3
+<g><text x="25" y="40" style="fill: green; stroke: green; font-size: 20px;font-family:Helvetica;" id="svg_1" class="">P</text></g>
4
+<g id="svg_3">
5
+<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"/>
6
+</g></g></svg>

+ 6
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-red.svg View File

@@ -0,0 +1,6 @@
1
+<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">
2
+<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>
3
+<g><text x="25" y="40" style="fill: #C82128; stroke: #C82128; font-size: 20px;font-family:Helvetica;" id="svg_1" class="">P</text></g>
4
+<g id="svg_3">
5
+<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"/>
6
+</g></g></svg>

+ 58
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.html View File

@@ -0,0 +1,58 @@
1
+<md-tabs md-dynamic-height md-stretch-tabs="always" md-border-bottom>
2
+    <md-tab label="Properties" >
3
+        <md-content layout-padding>
4
+
5
+            <md-input-container class="md-block" flex-gt-xs>
6
+                <label>Adjustment Type</label>
7
+                <md-select ng-model="$ctrl.scalingpolicy.adjustment_type" name="adjustment_type" aria-label="Adjustment Type" required>
8
+                    <md-option ng-repeat="at in adjustment_types" ng-value="at.value">{$ at.name $}</md-option>
9
+                </md-select>
10
+            </md-input-container>
11
+
12
+            <md-input-container class="md-block" flex-gt-xs>
13
+                <label>Scaling Adjustment</label>
14
+                <input ng-model="$ctrl.scalingpolicy.scaling_adjustment" name="scaling_adjustment" type="number" required/>
15
+                <div ng-messages="$ctrl.formReference.scaling_adjustment.$error" role="alert" multiple>
16
+                    <div ng-message="number">You did not enter a valid number.</div>
17
+                    <div ng-message="required">You must supply a scaling adjustment size.</div>
18
+                </div>
19
+            </md-input-container>
20
+
21
+            <md-input-container class="md-block" flex-gt-xs>
22
+                <label>Auto Scaling Group</label>
23
+                <input ng-model="$ctrl.scalingpolicy.auto_scaling_group_id" name="auto_scaling_group_id" type="text" ng-pattern="auto_scaling_group_id_pattern" ng-disabled="auto_scaling_group_id_disabled" required/>
24
+                <div ng-messages="$ctrl.formReference.auto_scaling_group_id.$error" role="alert" multiple>
25
+                    <div ng-message="pattern">You must supply a valid ID.</div>
26
+                    <div ng-message="required">You must supply a auto scaling group ID.</div>
27
+                </div>
28
+            </md-input-container>
29
+
30
+            <md-input-container class="md-block" flex-gt-xs>
31
+                <label>Cooldown</label>
32
+                <input ng-model="$ctrl.scalingpolicy.cooldown" name="cooldown" type="number" min="0"/>
33
+                <div ng-messages="$ctrl.formReference.cooldown.$error" role="alert" multiple>
34
+                    <div ng-message="number">You did not enter a valid number.</div>
35
+                    <div ng-message="min">You did not enter a positive number.</div>
36
+                </div>
37
+            </md-input-container>
38
+
39
+            <md-input-container class="md-block" flex-gt-xs>
40
+                <label>Min Adjustment Step</label>
41
+                <input ng-model="$ctrl.scalingpolicy.min_adjustment_step" name="min_adjustment_step" type="number" ng-pattern="validate_integer" min="0" ng-disabled="min_adj_step_disabled"/>
42
+                <div ng-messages="$ctrl.formReference.min_adjustment_step.$error" role="alert" multiple>
43
+                    <div ng-message="number">You did not enter a valid integer.</div>
44
+                    <div ng-message="min">You did not enter a positive number.</div>
45
+                    <div ng-message="pattern">You must supply an integer.</div>
46
+                </div>
47
+            </md-input-container>
48
+
49
+        </md-content>
50
+    </md-tab>
51
+
52
+    <md-tab label="Depends on">
53
+        <md-content layout-padding>
54
+            <depends-on dependson='dependson'></depends-on>
55
+        </md-content>
56
+    </md-tab>
57
+
58
+</md-tabs>

+ 130
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.js View File

@@ -0,0 +1,130 @@
1
+(function() {
2
+    'use strict';
3
+
4
+    /* OS::Heat::ScalingPolicy
5
+     *
6
+     */
7
+
8
+    angular.module('horizon.dashboard.project.heat_dashboard.template_generator')
9
+      .value('osHeatScalingPolicySettings',
10
+        {
11
+            resource_key: "OS__Heat__ScalingPolicy",
12
+            admin: false,
13
+            icon: {
14
+                class: 'fa-clone',
15
+                name: 'OS::Heat::ScalingPolicy',
16
+                code: '\uf24d',
17
+                color: '#0bb238'
18
+            },
19
+            label: 'name',
20
+            modal_component: '<os-heat-scalingpolicy scalingpolicy="resource" dependson="dependson" connectedoptions="connectedoptions" form-reference="resourceForm"></os-heat-scalingpolicy>',
21
+            edge_settings:  {
22
+                'OS__Heat__AutoScalingGroup': {
23
+                    'type': 'property',
24
+                    'property': 'auto_scaling_group_id',
25
+                    'limit': 1,
26
+                    'occupied': false, //* whether can be connected to any other resource */
27
+                    'lonely': false,  //* whether can be connected to one more other resource */
28
+                    'modal': null
29
+                }
30
+            },
31
+            necessary_properties: ['adjustment_type', 'scaling_adjustment', 'auto_scaling_group_id']
32
+        }
33
+    )
34
+
35
+    // Register the resource to globals
36
+    angular.module('horizon.dashboard.project.heat_dashboard.template_generator')
37
+      .run(['osHeatScalingPolicySettings','hotgenGlobals', function(osHeatScalingPolicySettings, hotgenGlobals){
38
+        hotgenGlobals.update_resource_icons(
39
+            osHeatScalingPolicySettings.resource_key ,
40
+            osHeatScalingPolicySettings.icon);
41
+
42
+        hotgenGlobals.update_resource_components(
43
+            osHeatScalingPolicySettings.resource_key,
44
+            osHeatScalingPolicySettings.modal_component);
45
+
46
+        hotgenGlobals.update_node_labels(
47
+            osHeatScalingPolicySettings.resource_key,
48
+            osHeatScalingPolicySettings.label);
49
+
50
+        hotgenGlobals.update_edge_directions(
51
+            osHeatScalingPolicySettings.resource_key,
52
+            osHeatScalingPolicySettings.edge_settings);
53
+    }]);
54
+
55
+
56
+    // Define  <os-heat-scalingpolicy> controller
57
+    function osHeatScalingPolicyController($scope, hotgenGlobals, hotgenNotify, validationRules) {
58
+        this.$onInit = function(){
59
+            $scope.dependson = this.dependson;
60
+            $scope.min_adj_step_disabled = false;
61
+            if (this.scalingpolicy.adjustment_type !=='percent_change_in_capacity'){
62
+                this.scalingpolicy.min_adjustment_step = '';
63
+                $scope.min_adj_step_disabled = true;
64
+            }
65
+            $scope.auto_scaling_group_id_disabled = false;
66
+            $scope.auto_scaling_group_id_pattern = $scope.validate_uuid4;
67
+            if (this.connectedoptions.auto_scaling_group_id){
68
+                for (var idx in this.connectedoptions.auto_scaling_group_id){
69
+                    this.scalingpolicy.auto_scaling_group_id = this.connectedoptions.auto_scaling_group_id[idx].value;
70
+                    break;
71
+                }
72
+                $scope.auto_scaling_group_id_disabled = true;
73
+                $scope.auto_scaling_group_id_pattern = "";
74
+            } else{
75
+                if (this.scalingpolicy.auto_scaling_group_id && this.scalingpolicy.auto_scaling_group_id.indexOf('get_resource') >= 0){
76
+                    // no edge with AutoScalingGroup but still holding get_resource dependency,
77
+                    // consider edge is removed and empty auto_scaling_group_id
78
+                    this.scalingpolicy.auto_scaling_group_id = "";
79
+                }
80
+
81
+                $scope.auto_scaling_group_id_disabled = false;
82
+            }
83
+        };
84
+
85
+        $scope.validate_integer = validationRules['integer'];
86
+        $scope.validate_uuid4= validationRules['uuid4'];
87
+        $scope.controller = this;
88
+        $scope.adjustment_types = [
89
+            {'value': 'change_in_capacity', 'name': 'Change in Capacity'},
90
+            {'value': 'exact_capacity', 'name': 'Exact Capacity'},
91
+            {'value': 'percent_change_in_capacity', 'name': 'Percent Change in Capacity'},
92
+        ];
93
+
94
+        $scope.$watch('controller.scalingpolicy.adjustment_type', function(newValue, oldValue){
95
+            if (oldValue === newValue){
96
+                return;
97
+            }
98
+            if (newValue === 'percent_change_in_capacity'){
99
+                $scope.min_adj_step_disabled = false;
100
+            } else{
101
+                $scope.controller.scalingpolicy.min_adjustment_step = '';
102
+                $scope.min_adj_step_disabled = true;
103
+            }
104
+        });
105
+    }
106
+
107
+    function osHeatScalingPolicyPath (basePath){
108
+        return  basePath + 'js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.html';
109
+    }
110
+
111
+    osHeatScalingPolicyController.$inject = ['$scope', 'hotgenGlobals', 'hotgenNotify',
112
+        'horizon.dashboard.project.heat_dashboard.template_generator.validationRules',
113
+    ];
114
+
115
+    osHeatScalingPolicyPath.$inject = ['horizon.dashboard.project.heat_dashboard.template_generator.basePath'];
116
+
117
+    angular.module('horizon.dashboard.project.heat_dashboard.template_generator')
118
+      .component('osHeatScalingpolicy', {
119
+        templateUrl: osHeatScalingPolicyPath,
120
+        controller: osHeatScalingPolicyController,
121
+        bindings: {
122
+          'scalingpolicy': '=',
123
+          'dependson': '=',
124
+          'connectedoptions': '<',
125
+          'formReference': '<',
126
+        }
127
+    });
128
+
129
+
130
+})();

+ 93
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.spec.js View File

@@ -0,0 +1,93 @@
1
+(function() {
2
+    'use strict';
3
+
4
+    describe('component os-heat-scalingpolicy', function(){
5
+
6
+        beforeEach(module('horizon.dashboard.project.heat_dashboard.template_generator'));
7
+
8
+        beforeEach(module('appTemplates'));
9
+
10
+        var $scope, $isolateScope, $compile;
11
+        var hotgenGlobals;
12
+        var element;
13
+
14
+        beforeEach(inject(function($injector) {
15
+            $scope = $injector.get('$rootScope').$new();
16
+            $compile = $injector.get('$compile');
17
+
18
+            $scope.resource = {};
19
+            $scope.dependson = [];
20
+            $scope.resourceForm = {};
21
+            $scope.connectedoptions = [];
22
+
23
+            // element will enable you to test your directive's element on the DOM
24
+            element = $compile(angular.element('<os-heat-scalingpolicy scalingpolicy="resource" '+
25
+                    'dependson="dependson" connectedoptions="connectedoptions" '+
26
+                    'form-reference="resourceForm">'+
27
+                    '</os-heat-scalingpolicy>'))($scope);
28
+
29
+            // Digest needs to be called to set any values on the directive's scope
30
+            $scope.$digest();
31
+
32
+            $isolateScope = element.isolateScope();
33
+        }));
34
+
35
+        it('find tab title Properties',  function() {
36
+            expect(element.find('span').html()).toContain("Properties");
37
+        });
38
+
39
+        it('find tab title with connectedoptions set',  function() {
40
+            $scope.resource = {auto_scaling_group_id: 'auto-scaling-group-uuid'}
41
+            $scope.connectedoptions = {auto_scaling_group_id: [{value: 'auto-scaling-group-uuid'}],
42
+                                       };
43
+
44
+            element = $compile(angular.element('<os-heat-scalingpolicy scalingpolicy="resource" '+
45
+                    'dependson="dependson" connectedoptions="connectedoptions" '+
46
+                    'form-reference="resourceForm">'+
47
+                    '</os-heat-scalingpolicy>'))($scope);
48
+
49
+            $scope.$digest();
50
+
51
+            $isolateScope = element.isolateScope();
52
+
53
+            expect(element.find('span').html()).toContain("Properties");
54
+            expect($isolateScope.$ctrl.scalingpolicy.auto_scaling_group_id).toEqual('auto-scaling-group-uuid');
55
+        });
56
+
57
+        it('find tab title with auto_scaling_group_id set',  function() {
58
+            $scope.resource = {auto_scaling_group_id: '{ get_resource: AutoScalingGroup_1 }'}
59
+
60
+            element = $compile(angular.element('<os-heat-scalingpolicy scalingpolicy="resource" '+
61
+                    'dependson="dependson" connectedoptions="connectedoptions" '+
62
+                    'form-reference="resourceForm">'+
63
+                    '</os-heat-scalingpolicy>'))($scope);
64
+
65
+            $scope.$digest();
66
+            $isolateScope = element.isolateScope();
67
+            expect(element.find('span').html()).toContain("Properties");
68
+            expect($isolateScope.$ctrl.scalingpolicy.auto_scaling_group_id).toEqual('');
69
+        });
70
+
71
+        it('find tab title with adjustment type set',  function() {
72
+            $scope.resource = {adjustment_type: 'percent_change_in_capacity'}
73
+            element = $compile(angular.element('<os-heat-scalingpolicy scalingpolicy="resource" '+
74
+                    'dependson="dependson" connectedoptions="connectedoptions" '+
75
+                    'form-reference="resourceForm">'+
76
+                    '</os-heat-scalingpolicy>'))($scope);
77
+            $scope.$digest();
78
+            $isolateScope = element.isolateScope();
79
+            expect(element.find('span').html()).toContain("Properties");
80
+
81
+            $scope.resource = {adjustment_type: 'change_in_capacity'}
82
+            element = $compile(angular.element('<os-heat-scalingpolicy scalingpolicy="resource" '+
83
+                    'dependson="dependson" connectedoptions="connectedoptions" '+
84
+                    'form-reference="resourceForm">'+
85
+                    '</os-heat-scalingpolicy>'))($scope);
86
+            $scope.$digest();
87
+            $isolateScope = element.isolateScope();
88
+            expect(element.find('span').html()).toContain("Properties");
89
+
90
+        });
91
+    });
92
+
93
+})();

+ 6
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.svg View File

@@ -0,0 +1,6 @@
1
+<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">
2
+<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>
3
+<g><text x="25" y="40" style="fill: #000000; stroke: #000; font-size: 20px;font-family:Helvetica;" id="svg_1" class="">P</text></g>
4
+<g id="svg_3">
5
+<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"/>
6
+</g></g></svg>

Loading…
Cancel
Save