diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-blue.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-blue.svg new file mode 100644 index 00000000..647590f5 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-blue.svg @@ -0,0 +1,6 @@ + +Layer 1Layer 2 +P + + + diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-gray.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-gray.svg new file mode 100644 index 00000000..97738da3 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-gray.svg @@ -0,0 +1,6 @@ + +Layer 1Layer 2 +P + + + \ No newline at end of file diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-green.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-green.svg new file mode 100644 index 00000000..606e746a --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-green.svg @@ -0,0 +1,6 @@ + +Layer 1Layer 2 +P + + + diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-red.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-red.svg new file mode 100644 index 00000000..e74d72b6 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy-red.svg @@ -0,0 +1,6 @@ + +Layer 1Layer 2 +P + + + diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.html b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.html new file mode 100644 index 00000000..f1eebc72 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.html @@ -0,0 +1,58 @@ + + + + + + + + {$ at.name $} + + + + + + +
+
You did not enter a valid number.
+
You must supply a scaling adjustment size.
+
+
+ + + + +
+
You must supply a valid ID.
+
You must supply a auto scaling group ID.
+
+
+ + + + +
+
You did not enter a valid number.
+
You did not enter a positive number.
+
+
+ + + + +
+
You did not enter a valid integer.
+
You did not enter a positive number.
+
You must supply an integer.
+
+
+ +
+
+ + + + + + + +
\ No newline at end of file diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.js new file mode 100644 index 00000000..1ecc8e2b --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.js @@ -0,0 +1,130 @@ +(function() { + 'use strict'; + + /* OS::Heat::ScalingPolicy + * + */ + + angular.module('horizon.dashboard.project.heat_dashboard.template_generator') + .value('osHeatScalingPolicySettings', + { + resource_key: "OS__Heat__ScalingPolicy", + admin: false, + icon: { + class: 'fa-clone', + name: 'OS::Heat::ScalingPolicy', + code: '\uf24d', + color: '#0bb238' + }, + label: 'name', + modal_component: '', + edge_settings: { + 'OS__Heat__AutoScalingGroup': { + 'type': 'property', + 'property': 'auto_scaling_group_id', + 'limit': 1, + 'occupied': false, //* whether can be connected to any other resource */ + 'lonely': false, //* whether can be connected to one more other resource */ + 'modal': null + } + }, + necessary_properties: ['adjustment_type', 'scaling_adjustment', 'auto_scaling_group_id'] + } + ) + + // Register the resource to globals + angular.module('horizon.dashboard.project.heat_dashboard.template_generator') + .run(['osHeatScalingPolicySettings','hotgenGlobals', function(osHeatScalingPolicySettings, hotgenGlobals){ + hotgenGlobals.update_resource_icons( + osHeatScalingPolicySettings.resource_key , + osHeatScalingPolicySettings.icon); + + hotgenGlobals.update_resource_components( + osHeatScalingPolicySettings.resource_key, + osHeatScalingPolicySettings.modal_component); + + hotgenGlobals.update_node_labels( + osHeatScalingPolicySettings.resource_key, + osHeatScalingPolicySettings.label); + + hotgenGlobals.update_edge_directions( + osHeatScalingPolicySettings.resource_key, + osHeatScalingPolicySettings.edge_settings); + }]); + + + // Define controller + function osHeatScalingPolicyController($scope, hotgenGlobals, hotgenNotify, validationRules) { + this.$onInit = function(){ + $scope.dependson = this.dependson; + $scope.min_adj_step_disabled = false; + if (this.scalingpolicy.adjustment_type !=='percent_change_in_capacity'){ + this.scalingpolicy.min_adjustment_step = ''; + $scope.min_adj_step_disabled = true; + } + $scope.auto_scaling_group_id_disabled = false; + $scope.auto_scaling_group_id_pattern = $scope.validate_uuid4; + if (this.connectedoptions.auto_scaling_group_id){ + for (var idx in this.connectedoptions.auto_scaling_group_id){ + this.scalingpolicy.auto_scaling_group_id = this.connectedoptions.auto_scaling_group_id[idx].value; + break; + } + $scope.auto_scaling_group_id_disabled = true; + $scope.auto_scaling_group_id_pattern = ""; + } else{ + if (this.scalingpolicy.auto_scaling_group_id && this.scalingpolicy.auto_scaling_group_id.indexOf('get_resource') >= 0){ + // no edge with AutoScalingGroup but still holding get_resource dependency, + // consider edge is removed and empty auto_scaling_group_id + this.scalingpolicy.auto_scaling_group_id = ""; + } + + $scope.auto_scaling_group_id_disabled = false; + } + }; + + $scope.validate_integer = validationRules['integer']; + $scope.validate_uuid4= validationRules['uuid4']; + $scope.controller = this; + $scope.adjustment_types = [ + {'value': 'change_in_capacity', 'name': 'Change in Capacity'}, + {'value': 'exact_capacity', 'name': 'Exact Capacity'}, + {'value': 'percent_change_in_capacity', 'name': 'Percent Change in Capacity'}, + ]; + + $scope.$watch('controller.scalingpolicy.adjustment_type', function(newValue, oldValue){ + if (oldValue === newValue){ + return; + } + if (newValue === 'percent_change_in_capacity'){ + $scope.min_adj_step_disabled = false; + } else{ + $scope.controller.scalingpolicy.min_adjustment_step = ''; + $scope.min_adj_step_disabled = true; + } + }); + } + + function osHeatScalingPolicyPath (basePath){ + return basePath + 'js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.html'; + } + + osHeatScalingPolicyController.$inject = ['$scope', 'hotgenGlobals', 'hotgenNotify', + 'horizon.dashboard.project.heat_dashboard.template_generator.validationRules', + ]; + + osHeatScalingPolicyPath.$inject = ['horizon.dashboard.project.heat_dashboard.template_generator.basePath']; + + angular.module('horizon.dashboard.project.heat_dashboard.template_generator') + .component('osHeatScalingpolicy', { + templateUrl: osHeatScalingPolicyPath, + controller: osHeatScalingPolicyController, + bindings: { + 'scalingpolicy': '=', + 'dependson': '=', + 'connectedoptions': '<', + 'formReference': '<', + } + }); + + +})(); \ No newline at end of file diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.spec.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.spec.js new file mode 100644 index 00000000..044cc240 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.spec.js @@ -0,0 +1,93 @@ +(function() { + 'use strict'; + + describe('component os-heat-scalingpolicy', function(){ + + beforeEach(module('horizon.dashboard.project.heat_dashboard.template_generator')); + + beforeEach(module('appTemplates')); + + var $scope, $isolateScope, $compile; + var hotgenGlobals; + var element; + + beforeEach(inject(function($injector) { + $scope = $injector.get('$rootScope').$new(); + $compile = $injector.get('$compile'); + + $scope.resource = {}; + $scope.dependson = []; + $scope.resourceForm = {}; + $scope.connectedoptions = []; + + // element will enable you to test your directive's element on the DOM + element = $compile(angular.element(''+ + ''))($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"); + }); + + it('find tab title with connectedoptions set', function() { + $scope.resource = {auto_scaling_group_id: 'auto-scaling-group-uuid'} + $scope.connectedoptions = {auto_scaling_group_id: [{value: 'auto-scaling-group-uuid'}], + }; + + element = $compile(angular.element(''+ + ''))($scope); + + $scope.$digest(); + + $isolateScope = element.isolateScope(); + + expect(element.find('span').html()).toContain("Properties"); + expect($isolateScope.$ctrl.scalingpolicy.auto_scaling_group_id).toEqual('auto-scaling-group-uuid'); + }); + + it('find tab title with auto_scaling_group_id set', function() { + $scope.resource = {auto_scaling_group_id: '{ get_resource: AutoScalingGroup_1 }'} + + element = $compile(angular.element(''+ + ''))($scope); + + $scope.$digest(); + $isolateScope = element.isolateScope(); + expect(element.find('span').html()).toContain("Properties"); + expect($isolateScope.$ctrl.scalingpolicy.auto_scaling_group_id).toEqual(''); + }); + + it('find tab title with adjustment type set', function() { + $scope.resource = {adjustment_type: 'percent_change_in_capacity'} + element = $compile(angular.element(''+ + ''))($scope); + $scope.$digest(); + $isolateScope = element.isolateScope(); + expect(element.find('span').html()).toContain("Properties"); + + $scope.resource = {adjustment_type: 'change_in_capacity'} + element = $compile(angular.element(''+ + ''))($scope); + $scope.$digest(); + $isolateScope = element.isolateScope(); + expect(element.find('span').html()).toContain("Properties"); + + }); + }); + +})(); diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.svg new file mode 100644 index 00000000..3a92d100 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__heat__scalingpolicy/os__heat__scalingpolicy.svg @@ -0,0 +1,6 @@ + +Layer 1Layer 2 +P + + +