diff --git a/.gitignore b/.gitignore index f0a19a1..7980b2c 100644 --- a/.gitignore +++ b/.gitignore @@ -105,6 +105,7 @@ ENV/ # own settings .idea/* +.vscode/* # angular old versions *angular-1.3.7* diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-template.controller.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-template.controller.js index 12e4a1d..5a98c3f 100644 --- a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-template.controller.js +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/components/modal-template.controller.js @@ -47,6 +47,8 @@ func = hotgenUtils.escape_characters; break; case 'metadata': + case 'X-Account-Meta': + case 'X-Container-Meta': case 'scheduler_hints': case 'value_specs': func = hotgenUtils.extract_keyvalue; diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-blue.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-blue.svg new file mode 100644 index 0000000..49ae4ca --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-blue.svg @@ -0,0 +1,6 @@ + + Layer 1 + + + + diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-gray.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-gray.svg new file mode 100644 index 0000000..9ecf38b --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-gray.svg @@ -0,0 +1,6 @@ + + Layer 1 + + + + diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-green.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-green.svg new file mode 100644 index 0000000..a0a3b30 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-green.svg @@ -0,0 +1,6 @@ + + Layer 1 + + + + diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-red.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-red.svg new file mode 100644 index 0000000..bd8ff0a --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container-red.svg @@ -0,0 +1,6 @@ + + Layer 1 + + + + diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.html b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.html new file mode 100644 index 0000000..022c897 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.html @@ -0,0 +1,64 @@ + + + + + + + +
+
That doesn't look like a valid container name.
+
Your container name is too long.
+
+
+ + + + + + + + + + + + + +
+
+ + + + + + + + + +
+
+ + + +
+
+ + + + + + + + + +
+
+ + + + Purge on Delete + + + +
+
+
diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.js new file mode 100644 index 0000000..8ec1401 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.js @@ -0,0 +1,108 @@ +(function() { + 'use strict'; + var c_meta_key = "X-Container-Meta", + a_meta_key = "X-Account-Meta", + c_read_key = "X-Container-Read", + c_write_key = "X-Container-Write", + purge_key = "PurgeOnDelete"; + + /** + * OS::Swift::Container + */ + angular.module('horizon.dashboard.project.heat_dashboard.template_generator') + .value('osSwiftContainerSettings', + { + resource_key: "OS__Swift__Container", + admin: false, + icon: { + class: 'fa-archive ', + name: 'OS::Swift::Container', + code: '\uf0a0', + color: '#0bb238' + }, + label: 'name', + modal_component: '', + edge_settings: null, + necessary_properties: { + name: null + } + } + ) + + // Register the resource to globals + angular.module('horizon.dashboard.project.heat_dashboard.template_generator') + .run(['osSwiftContainerSettings','hotgenGlobals', function(osSwiftContainerSettings, hotgenGlobals){ + hotgenGlobals.update_resource_icons( + osSwiftContainerSettings.resource_key , + osSwiftContainerSettings.icon); + + hotgenGlobals.update_resource_components( + osSwiftContainerSettings.resource_key, + osSwiftContainerSettings.modal_component); + + hotgenGlobals.update_node_labels( + osSwiftContainerSettings.resource_key, + osSwiftContainerSettings.label); + }]); + + // Define controller + function osSwiftContainerController($scope, hotgenGlobals, hotgenNotify, validationRules) { + this.$onInit = function(){ + // Initialize X-Container-Meta + if (typeof this.container[c_meta_key] === 'undefined'){ + this.container[c_meta_key] = [{}]; + } + // Initialize X-Account-Meta + if (typeof this.container[a_meta_key] === 'undefined'){ + this.container[a_meta_key] = [{}]; + } + // Intialize Purge On Delete + if (typeof this.container[purge_key] === 'undefined'){ + this.container[purge_key] = false; + } + }; + + $scope.options = hotgenGlobals.get_resource_options(); + $scope.show_more = false; + $scope.validate_name = validationRules['name']; + + // Container Metadata manipulation functions + this.add_x_container_meta = function(){ + this.container[c_meta_key].push({}) + } + this.delete_x_container_meta = function(index){ + this.container[c_meta_key].splice(index, 1) + } + + // Account Metadata manipulation functions + this.add_x_account_meta = function(){ + this.container[a_meta_key].push({}) + } + this.delete_x_account_meta = function(index){ + this.container[a_meta_key].splice(index, 1) + } + } + + function osSwiftContainerPath (basePath){ + return basePath + 'js/resources/os__swift__container/os__swift__container.html'; + } + + osSwiftContainerController.$inject = [ + '$scope', + 'hotgenGlobals', + 'hotgenNotify', + 'horizon.dashboard.project.heat_dashboard.template_generator.validationRules', + ]; + + osSwiftContainerPath.$inject = ['horizon.dashboard.project.heat_dashboard.template_generator.basePath']; + + angular.module('horizon.dashboard.project.heat_dashboard.template_generator') + .component('osSwiftContainer', { + templateUrl: osSwiftContainerPath, + controller: osSwiftContainerController, + bindings: { + 'container': '=', + 'formReference': '<', + } + }); +})(); diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.spec.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.spec.js new file mode 100644 index 0000000..040a095 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.spec.js @@ -0,0 +1,80 @@ +(function() { + 'use strict'; + + describe('component os-swift-container', 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.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 with resource set', function() { + $scope.resource = {metadata: [], scheduler_hints:[]}; + + // 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(); + + expect(element.find('span').html()).toContain("Properties"); + }); + + // X-Container-Meta + it('x-container-meta should be successfully added', function() { + var $ctrl = element.isolateScope().$ctrl; + $ctrl.add_x_container_meta(); + + expect($scope.resource['X-Container-Meta'].length).toEqual(2); + }); + + it('x-container-meta should be successfully deleted', function() { + var $ctrl = element.isolateScope().$ctrl; + $ctrl.delete_x_container_meta(); + + expect($scope.resource['X-Container-Meta'].length).toEqual(0); + }); + + // X-Account-Meta + it('x-account-meta should be successfully added', function() { + var $ctrl = element.isolateScope().$ctrl; + $ctrl.add_x_account_meta(); + + expect($scope.resource['X-Account-Meta'].length).toEqual(2); + }); + + it('x-account-meta should be successfully deleted', function() { + var $ctrl = element.isolateScope().$ctrl; + $ctrl.delete_x_account_meta(); + + expect($scope.resource['X-Account-Meta'].length).toEqual(0); + }); + + }); +})(); diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.svg b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.svg new file mode 100644 index 0000000..395f7f2 --- /dev/null +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__swift__container/os__swift__container.svg @@ -0,0 +1,6 @@ + + Layer 1 + + + +