Browse Source

TemplateGenerator: Add Designate::Recordset support

Add support for OS::Designate::Recordset as a new resource,
which you can use from Template Generator.

Change-Id: I08bf9dacd35cb1d28e929d5e4763f7586d481606
Task: #19674
Story: #2002033
JiyeYu 10 months ago
parent
commit
3f08ce4cf7

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

@@ -0,0 +1,3 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
2
+<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke: #3f51b5" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="black" stroke="none" id="svg_1" class="selected">
3
+</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.8037456780144" y="26.947444905433" style="fill: #3f51b5; stroke: #3f51b5; font-size: 12px;font-family:Helvetica;" id="svg_1" class="" transform="matrix(0.8689477029051922,0,0,0.8383460251007016,2.074099908632737,2.043217027694234) ">DNS</text><text x="6.2547533214092255" y="38.90199057917994" style="fill: #3f51b5; stroke: #3f51b5; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(0.9034689664840698,0,0,0.8999947905540465,2.8846876919269557,2.8923381669446826) ">RECORD</text></g></svg>

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

@@ -0,0 +1,3 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
2
+<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke: #808080" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="black" stroke="none" id="svg_1" class="selected">
3
+</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.8037456780144" y="26.947444905433" style="fill: #808080; stroke: #808080; font-size: 12px;font-family:Helvetica;" id="svg_1" class="" transform="matrix(0.8689477029051922,0,0,0.8383460251007016,2.074099908632737,2.043217027694234) ">DNS</text><text x="6.2547533214092255" y="38.90199057917994" style="fill: #808080; stroke: #808080; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(0.9034689664840698,0,0,0.8999947905540465,2.8846876919269557,2.8923381669446826) ">RECORD</text></g></svg>

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

@@ -0,0 +1,3 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
2
+<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke:green" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="black" stroke="none" id="svg_1" class="selected">
3
+</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.8037456780144" y="26.947444905433" style="fill: green; stroke: green; font-size: 12px;font-family:Helvetica;" id="svg_1" class="" transform="matrix(0.8689477029051922,0,0,0.8383460251007016,2.074099908632737,2.043217027694234) ">DNS</text><text x="6.2547533214092255" y="38.90199057917994" style="fill: green; stroke: green; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(0.9034689664840698,0,0,0.8999947905540465,2.8846876919269557,2.8923381669446826) ">RECORD</text></g></svg>

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

@@ -0,0 +1,3 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
2
+<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke: #C82128" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="black" stroke="none" id="svg_1" class="selected">
3
+</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.8037456780144" y="26.947444905433" style="fill: #C82128; stroke: #C82128; font-size: 12px;font-family:Helvetica;" id="svg_1" class="" transform="matrix(0.8689477029051922,0,0,0.8383460251007016,2.074099908632737,2.043217027694234) ">DNS</text><text x="6.2547533214092255" y="38.90199057917994" style="fill: #C82128; stroke: #C82128; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(0.9034689664840698,0,0,0.8999947905540465,2.8846876919269557,2.8923381669446826) ">RECORD</text></g></svg>

+ 76
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.html View File

@@ -0,0 +1,76 @@
1
+<md-tabs md-dynamic-height md-stretch-tabs="always" md-border-bottom>
2
+    <md-tab label="Properties" >
3
+        <md-content layout-padding>
4
+            <md-input-container class="md-block">
5
+                <label>Name</label>
6
+                <input ng-model="$ctrl.recordset.name" name="name" type="text" required ng-pattern="validate_name" md-maxlength="255">
7
+                <div ng-messages="$ctrl.formReference.name.$error" role="alert" multiple>
8
+                    <div ng-message="required" class="my-message">You must supply a name.</div>
9
+                    <div ng-message="pattern" class="my-message">That doesn't look like a valid name.
10
+                    </div>
11
+                    <div ng-message="md-maxlength" class="my-message">
12
+                      Too long name.
13
+                    </div>
14
+                </div>
15
+            </md-input-container>
16
+
17
+            <md-input-container class="md-block">
18
+                <label>Zone</label>
19
+                <input ng-model="$ctrl.recordset.zone" name="zone" type="text" ng-disabled="$ctrl.disable.zone" required>
20
+                <div ng-messages="$ctrl.formReference.zone.$error" role="alert" multiple>
21
+                    <div ng-message="required" class="my-message">You must supply a zone.</div>
22
+                    <div ng-message="pattern" class="my-message">That doesn't look like a valid id of zone.
23
+                    </div>
24
+                </div>
25
+            </md-input-container>
26
+
27
+            <md-input-container class="md-block" flex-gt-xs>
28
+                <label>Type</label>
29
+                <md-select ng-model="$ctrl.recordset.type" required>
30
+                    <md-option ng-repeat="type in options.types" ng-value="type.id">
31
+                        {$ type.name $}
32
+                    </md-option>
33
+                </md-select>
34
+            </md-input-container>
35
+
36
+            <md-input-container class="md-block">
37
+                <label>Records</label>
38
+                <md-chips ng-model="$ctrl.recordset.records" ng-required="true" placeholder="+ record"></md-chips>
39
+                <div class="md-chips-messages" ng-messages="$ctrl.formReference.records.$error">
40
+                    <div ng-message="required">At least one record is required.</div>
41
+                </div>
42
+            </md-input-container>
43
+        </md-content>
44
+
45
+        <md-switch class="md-primary" name="show_more" ng-model="show_more">
46
+          {$ 'Show More Properties' | translate $}
47
+        </md-switch>
48
+    </md-tab>
49
+
50
+    <md-tab label="Optional Properties" ng-if="show_more">
51
+        <md-content layout-padding>
52
+
53
+            <md-input-container class="md-block">
54
+                <label>TTL</label>
55
+                <input ng-model="$ctrl.recordset.ttl" name="ttl" type="number" step="1" min="1" max="2147483647">
56
+            </md-input-container>
57
+
58
+            <md-input-container class="md-block">
59
+                <label>Description</label>
60
+                <input ng-model="$ctrl.recordset.description" name="description" type="text" md-maxlength="255">
61
+                <div ng-messages="$ctrl.formReference.description.$error" role="alert" multiple>
62
+                    <div ng-message="md-maxlength" class="my-message">
63
+                      Too long description.
64
+                    </div>
65
+                </div>
66
+            </md-input-container>
67
+
68
+        </md-content>
69
+    </md-tab>
70
+
71
+    <md-tab label="Depends on">
72
+        <md-content layout-padding>
73
+            <depends-on dependson='dependson'></depends-on>
74
+        </md-content>
75
+    </md-tab>
76
+</md-tabs>

+ 113
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.js View File

@@ -0,0 +1,113 @@
1
+(function(angular) {
2
+    'use strict';
3
+
4
+    // OS::Designate::RecordSet
5
+    angular.module('horizon.dashboard.project.heat_dashboard.template_generator').value('osDesignateRecordsetSettings',
6
+        {
7
+            resource_key: "OS__Designate__RecordSet",
8
+            admin: false,
9
+            icon: {
10
+                class: 'fa-key ',
11
+                name: 'OS::Designate::RecordSet',
12
+                code: '\uf084',
13
+                color: '#483dff'
14
+            },
15
+            label: 'name',
16
+            modal_component: '<os-designate-recordset recordset="resource" dependson="dependson" connectedoptions="connectedoptions" form-reference="resourceForm"></os-designate-recordset>',
17
+            edge_settings: {
18
+                'OS__Designate__Zone': {
19
+                    'type': 'property',
20
+                    'property': 'zone',
21
+                    'limit': 1,
22
+                },
23
+            },
24
+            necessary_properties: {
25
+                'name': null,
26
+                'zone': ['OS__Designate__Zone'],
27
+                'type': null,
28
+                'records': null,
29
+            },
30
+        }
31
+    );
32
+
33
+    angular.module('horizon.dashboard.project.heat_dashboard.template_generator')
34
+    .run(['osDesignateRecordsetSettings', 'hotgenGlobals', function( osDesignateRecordsetSettings, hotgenGlobals){
35
+        hotgenGlobals.update_resource_icons(
36
+            osDesignateRecordsetSettings.resource_key,
37
+            osDesignateRecordsetSettings.icon);
38
+
39
+        hotgenGlobals.update_resource_components(
40
+            osDesignateRecordsetSettings.resource_key,
41
+            osDesignateRecordsetSettings.modal_component);
42
+
43
+        hotgenGlobals.update_edge_directions(
44
+            osDesignateRecordsetSettings.resource_key,
45
+            osDesignateRecordsetSettings.edge_settings);
46
+
47
+        hotgenGlobals.update_node_labels(
48
+            osDesignateRecordsetSettings.resource_key,
49
+            osDesignateRecordsetSettings.label);
50
+    }]);
51
+
52
+
53
+    function osDesignateRecordsetController($scope, hotgenGlobals, validationRules){
54
+        $scope.options = hotgenGlobals.get_resource_options();
55
+
56
+        $scope.options.types = [
57
+            {'id': 'A', 'name': 'A'},
58
+            {'id': 'AAAA', 'name': 'AAAA'},
59
+            {'id': 'MX', 'name': 'MX'},
60
+            {'id': 'CNAME', 'name': 'CNAME'},
61
+            {'id': 'TXT', 'name': 'TXT'},
62
+            {'id': 'SRV', 'name': 'SRV'},
63
+            {'id': 'NS', 'name': 'NS'},
64
+            {'id': 'PTR', 'name': 'PTR'},
65
+            {'id': 'SPF', 'name': 'SPF'},
66
+            {'id': 'SSHFP', 'name': 'SSHFP'},
67
+        ];
68
+
69
+        $scope.admin = $scope.options.auth.admin;
70
+        this.$onInit = function(){
71
+            if (typeof this.recordset.records === 'undefined'){
72
+                this.recordset.records = [];
73
+            }
74
+
75
+            if (typeof this.connectedoptions === 'undefined'){
76
+                $scope.connected_options = []
77
+            } else{
78
+                $scope.connected_options = this.connectedoptions;
79
+            }
80
+
81
+            this.disable = {'zone': false}
82
+
83
+            if ( $scope.connected_options.zone && $scope.connected_options.zone.length > 0){
84
+                this.recordset.zone = $scope.connected_options.zone[0].value
85
+                this.disable.zone = true
86
+            }
87
+            $scope.dependson = this.dependson;
88
+        }
89
+
90
+        $scope.validate_name = validationRules['name'];
91
+    }
92
+
93
+    osDesignateRecordsetController.$inject = ['$scope', 'hotgenGlobals',
94
+        'horizon.dashboard.project.heat_dashboard.template_generator.validationRules',
95
+    ];
96
+    osDesignateRecordsetPath.$inject = ['horizon.dashboard.project.heat_dashboard.template_generator.basePath'];
97
+
98
+    function osDesignateRecordsetPath(basePath){
99
+        return basePath + 'js/resources/os__designate__recordset/os__designate__recordset.html';
100
+    }
101
+
102
+    angular.module('horizon.dashboard.project.heat_dashboard.template_generator').component('osDesignateRecordset', {
103
+        templateUrl: osDesignateRecordsetPath,
104
+        controller: osDesignateRecordsetController,
105
+        bindings:{
106
+            'recordset': '=',
107
+            'dependson': '=',
108
+            'connectedoptions': '<',
109
+            'formReference': '<',
110
+        }
111
+    });
112
+
113
+})(window.angular);

+ 49
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.spec.js View File

@@ -0,0 +1,49 @@
1
+(function() {
2
+    'use strict';
3
+
4
+    describe('component os-designate-recordset', 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 element;
12
+
13
+        beforeEach(inject(function($injector) {
14
+            $scope = $injector.get('$rootScope').$new();
15
+            $compile = $injector.get('$compile');
16
+
17
+            $scope.resource = {};
18
+            $scope.dependson = [];
19
+            $scope.connectedoptions = [];
20
+            $scope.resourceForm = {};
21
+
22
+            // element will enable you to test your directive's element on the DOM
23
+            element = $compile(angular.element('<os-designate-recordset recordset="resource"'+
24
+                    'dependson="dependson" connectedoptions="connectedoptions"'+
25
+                    'form-reference="resourceForm"></os-designate-recordset>'))($scope);
26
+
27
+            // Digest needs to be called to set any values on the directive's scope
28
+            $scope.$digest();
29
+
30
+            $isolateScope = element.isolateScope();
31
+        }));
32
+
33
+        it('find tab title Properties',  function() {
34
+            expect(element.find('span').html()).toContain("Properties");
35
+        });
36
+
37
+        it('find tab title Properties with resource properties set',  function() {
38
+            $scope.resource = { masters: [], attributes: []};
39
+            element = $compile(angular.element('<os-designate-recordset recordset="resource" '+
40
+                    'dependson="dependson" form-reference="resourceForm">'+
41
+                    '</os-designate-recordset>'))($scope);
42
+
43
+            $scope.$digest();
44
+
45
+            expect(element.find('span').html()).toContain("Properties");
46
+        });
47
+    });
48
+
49
+})();

+ 3
- 0
heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.svg View File

@@ -0,0 +1,3 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="55" height="55" preserveAspectRatio="xMidYMid meet" style="background-color: #FFFFFF;" viewBox="0 0 55 55">
2
+<g class="currentLayer" style=""><title>Layer 1</title><circle class="frame" r="25" style="fill:white;fill-opacity=0.0;stroke-width:3;stroke:black" cy="27.395854949951172" cx="28.040435791015625" id="svg_2"/><g transform="translate(0,300) scale(0.10000000149011612,-0.10000000149011612) " fill="black" stroke="none" id="svg_1" class="selected">
3
+</g></g><g class="currentLayer" style=""><title>Layer 1</title><text x="15.8037456780144" y="26.947444905433" style="fill: #000000; stroke: #000; font-size: 12px;font-family:Helvetica;" id="svg_1" class="" transform="matrix(0.8689477029051922,0,0,0.8383460251007016,2.074099908632737,2.043217027694234) ">DNS</text><text x="6.2547533214092255" y="38.90199057917994" style="fill: #000000; stroke: #000; font-size: 10px;font-family:Helvetica; " id="svg_2" class="" transform="matrix(0.9034689664840698,0,0,0.8999947905540465,2.8846876919269557,2.8923381669446826) ">RECORD</text></g></svg>

Loading…
Cancel
Save