From 3f08ce4cf7a825aaed99ee1b3139fa528bedcab3 Mon Sep 17 00:00:00 2001 From: JiyeYu Date: Tue, 12 Jun 2018 11:38:37 +0900 Subject: [PATCH] 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 --- .../os__designate__recordset-blue.svg | 3 + .../os__designate__recordset-gray.svg | 3 + .../os__designate__recordset-green.svg | 3 + .../os__designate__recordset-red.svg | 3 + .../os__designate__recordset.html | 76 ++++++++++++ .../os__designate__recordset.js | 113 ++++++++++++++++++ .../os__designate__recordset.spec.js | 49 ++++++++ .../os__designate__recordset.svg | 3 + 8 files changed, 253 insertions(+) create mode 100644 heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-blue.svg create mode 100644 heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-gray.svg create mode 100644 heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-green.svg create mode 100644 heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-red.svg create mode 100644 heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.html create mode 100644 heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.js create mode 100644 heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.spec.js create mode 100644 heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.svg diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-blue.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-blue.svg new file mode 100644 index 0000000..a914eba --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-blue.svg @@ -0,0 +1,3 @@ + +Layer 1 +Layer 1DNSRECORD \ No newline at end of file diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-gray.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-gray.svg new file mode 100644 index 0000000..d4ea588 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-gray.svg @@ -0,0 +1,3 @@ + +Layer 1 +Layer 1DNSRECORD \ No newline at end of file diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-green.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-green.svg new file mode 100644 index 0000000..543850d --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-green.svg @@ -0,0 +1,3 @@ + +Layer 1 +Layer 1DNSRECORD \ No newline at end of file diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-red.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-red.svg new file mode 100644 index 0000000..2b7141e --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset-red.svg @@ -0,0 +1,3 @@ + +Layer 1 +Layer 1DNSRECORD \ No newline at end of file diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.html b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.html new file mode 100644 index 0000000..908ea7a --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.html @@ -0,0 +1,76 @@ + + + + + + +
+
You must supply a name.
+
That doesn't look like a valid name. +
+
+ Too long name. +
+
+
+ + + + +
+
You must supply a zone.
+
That doesn't look like a valid id of zone. +
+
+
+ + + + + + {$ type.name $} + + + + + + + +
+
At least one record is required.
+
+
+
+ + + {$ 'Show More Properties' | translate $} + +
+ + + + + + + + + + + + +
+
+ Too long description. +
+
+
+ +
+
+ + + + + + +
diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.js new file mode 100644 index 0000000..73a875c --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.js @@ -0,0 +1,113 @@ +(function(angular) { + 'use strict'; + + // OS::Designate::RecordSet + angular.module('horizon.dashboard.project.heat_dashboard.template_generator').value('osDesignateRecordsetSettings', + { + resource_key: "OS__Designate__RecordSet", + admin: false, + icon: { + class: 'fa-key ', + name: 'OS::Designate::RecordSet', + code: '\uf084', + color: '#483dff' + }, + label: 'name', + modal_component: '', + edge_settings: { + 'OS__Designate__Zone': { + 'type': 'property', + 'property': 'zone', + 'limit': 1, + }, + }, + necessary_properties: { + 'name': null, + 'zone': ['OS__Designate__Zone'], + 'type': null, + 'records': null, + }, + } + ); + + angular.module('horizon.dashboard.project.heat_dashboard.template_generator') + .run(['osDesignateRecordsetSettings', 'hotgenGlobals', function( osDesignateRecordsetSettings, hotgenGlobals){ + hotgenGlobals.update_resource_icons( + osDesignateRecordsetSettings.resource_key, + osDesignateRecordsetSettings.icon); + + hotgenGlobals.update_resource_components( + osDesignateRecordsetSettings.resource_key, + osDesignateRecordsetSettings.modal_component); + + hotgenGlobals.update_edge_directions( + osDesignateRecordsetSettings.resource_key, + osDesignateRecordsetSettings.edge_settings); + + hotgenGlobals.update_node_labels( + osDesignateRecordsetSettings.resource_key, + osDesignateRecordsetSettings.label); + }]); + + + function osDesignateRecordsetController($scope, hotgenGlobals, validationRules){ + $scope.options = hotgenGlobals.get_resource_options(); + + $scope.options.types = [ + {'id': 'A', 'name': 'A'}, + {'id': 'AAAA', 'name': 'AAAA'}, + {'id': 'MX', 'name': 'MX'}, + {'id': 'CNAME', 'name': 'CNAME'}, + {'id': 'TXT', 'name': 'TXT'}, + {'id': 'SRV', 'name': 'SRV'}, + {'id': 'NS', 'name': 'NS'}, + {'id': 'PTR', 'name': 'PTR'}, + {'id': 'SPF', 'name': 'SPF'}, + {'id': 'SSHFP', 'name': 'SSHFP'}, + ]; + + $scope.admin = $scope.options.auth.admin; + this.$onInit = function(){ + if (typeof this.recordset.records === 'undefined'){ + this.recordset.records = []; + } + + if (typeof this.connectedoptions === 'undefined'){ + $scope.connected_options = [] + } else{ + $scope.connected_options = this.connectedoptions; + } + + this.disable = {'zone': false} + + if ( $scope.connected_options.zone && $scope.connected_options.zone.length > 0){ + this.recordset.zone = $scope.connected_options.zone[0].value + this.disable.zone = true + } + $scope.dependson = this.dependson; + } + + $scope.validate_name = validationRules['name']; + } + + osDesignateRecordsetController.$inject = ['$scope', 'hotgenGlobals', + 'horizon.dashboard.project.heat_dashboard.template_generator.validationRules', + ]; + osDesignateRecordsetPath.$inject = ['horizon.dashboard.project.heat_dashboard.template_generator.basePath']; + + function osDesignateRecordsetPath(basePath){ + return basePath + 'js/resources/os__designate__recordset/os__designate__recordset.html'; + } + + angular.module('horizon.dashboard.project.heat_dashboard.template_generator').component('osDesignateRecordset', { + templateUrl: osDesignateRecordsetPath, + controller: osDesignateRecordsetController, + bindings:{ + 'recordset': '=', + 'dependson': '=', + 'connectedoptions': '<', + 'formReference': '<', + } + }); + +})(window.angular); diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.spec.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.spec.js new file mode 100644 index 0000000..c0d227c --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.spec.js @@ -0,0 +1,49 @@ +(function() { + 'use strict'; + + describe('component os-designate-recordset', function(){ + + beforeEach(module('horizon.dashboard.project.heat_dashboard.template_generator')); + + beforeEach(module('appTemplates')); + + var $scope, $isolateScope, $compile; + var element; + + beforeEach(inject(function($injector) { + $scope = $injector.get('$rootScope').$new(); + $compile = $injector.get('$compile'); + + $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(''))($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 Properties with resource properties set', function() { + $scope.resource = { masters: [], attributes: []}; + element = $compile(angular.element(''+ + ''))($scope); + + $scope.$digest(); + + expect(element.find('span').html()).toContain("Properties"); + }); + }); + +})(); diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.svg new file mode 100644 index 0000000..7b0f836 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__designate__recordset/os__designate__recordset.svg @@ -0,0 +1,3 @@ + +Layer 1 +Layer 1DNSRECORD \ No newline at end of file