diff options
author | MichaelMorris <michael.morris@est.tech> | 2020-12-15 16:12:59 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-01-12 16:35:48 +0000 |
commit | 69779180f8f4e020606634f9bd8cac728daed2a2 (patch) | |
tree | 87167832f478509436365d07bd2e46a9c8970365 /catalog-ui/src/app/models | |
parent | 1f4756dab7b29843a89fb42943ae3dc0ee8b1ae9 (diff) |
Support for category specific metadata
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-3412
Change-Id: I87392cc21dc25253b558bdc1d453d99659d049fa
Diffstat (limited to 'catalog-ui/src/app/models')
-rw-r--r-- | catalog-ui/src/app/models/category.ts | 7 | ||||
-rw-r--r-- | catalog-ui/src/app/models/component-metadata.ts | 4 | ||||
-rw-r--r-- | catalog-ui/src/app/models/components/component.ts | 31 |
3 files changed, 42 insertions, 0 deletions
diff --git a/catalog-ui/src/app/models/category.ts b/catalog-ui/src/app/models/category.ts index 15df98569d..64588d0c44 100644 --- a/catalog-ui/src/app/models/category.ts +++ b/catalog-ui/src/app/models/category.ts @@ -28,6 +28,7 @@ export interface ICategoryBase { normalizedName:string; uniqueId:string; icons:Array<string>; + metadataKeys: IMetadataKey[]; //custom properties filterTerms:string; @@ -46,3 +47,9 @@ export interface ISubCategory extends ICategoryBase { export interface IGroup extends ICategoryBase { } + +export interface IMetadataKey { + name:string; + mandatory:boolean + validValues: string[]; +} diff --git a/catalog-ui/src/app/models/component-metadata.ts b/catalog-ui/src/app/models/component-metadata.ts index 8a4b257f55..186cd8aa39 100644 --- a/catalog-ui/src/app/models/component-metadata.ts +++ b/catalog-ui/src/app/models/component-metadata.ts @@ -21,6 +21,7 @@ import { CapabilitiesGroup, RequirementsGroup } from 'app/models'; import { ComponentType } from 'app/utils'; import { IMainCategory } from './category'; +import { Metadata } from "app/models/metadata"; /** * Created by obarda on 4/18/2017. */ @@ -53,6 +54,7 @@ export interface IComponentMetadata { vspArchived: boolean; selectedCategory: string; filterTerm: string; + categorySpecificMetadata: Metadata; // Resource only resourceType: string; @@ -115,6 +117,7 @@ export class ComponentMetadata implements IComponentMetadata { public toscaResourceName: string; public selectedCategory: string; public filterTerm: string; + public categorySpecificMetadata: Metadata = new Metadata(); // Resource only public resourceType: string; @@ -192,6 +195,7 @@ export class ComponentMetadata implements IComponentMetadata { this.toscaResourceName = response.toscaResourceName; this.capabilities = response.capabilities; this.requirements = response.requirements; + this.categorySpecificMetadata = response.categorySpecificMetadata; return this; } diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts index a0706b4157..1d48151be8 100644 --- a/catalog-ui/src/app/models/components/component.ts +++ b/catalog-ui/src/app/models/components/component.ts @@ -35,6 +35,7 @@ import {Requirement} from "../requirement"; import {Relationship} from "../graph/relationship"; import { PolicyInstance } from "app/models/graph/zones/policy-instance"; import { GroupInstance } from "../graph/zones/group-instance"; +import { Metadata } from "app/models/metadata"; // import {} @@ -142,6 +143,7 @@ export abstract class Component implements IComponent { public archived:boolean; public vspArchived: boolean; public componentMetadata: ComponentMetadata; + public categorySpecificMetadata: Metadata = new Metadata(); constructor(componentService:IComponentService, protected $q:ng.IQService, component?:Component) { if (component) { @@ -198,12 +200,36 @@ export abstract class Component implements IComponent { this.policies = component.policies; this.archived = component.archived; this.vspArchived = component.vspArchived; + + if (component.categorySpecificMetadata && component.categories && component.categories[0]){ + this.copyCategoryMetadata(component); + this.copySubcategoryMetadata(component); + } } //custom properties this.componentService = componentService; } + private copyCategoryMetadata = (component:Component):void => { + if (component.categories[0].metadataKeys){ + for (let key of Object.keys(component.categorySpecificMetadata)) { + if (component.categories[0].metadataKeys.some(metadataKey => metadataKey.name == key)) { + this.categorySpecificMetadata[key] = component.categorySpecificMetadata[key]; + } + } + } + } + private copySubcategoryMetadata = (component:Component):void => { + if (component.categories[0].subcategories && component.categories[0].subcategories[0] && component.categories[0].subcategories[0].metadataKeys){ + for (let key of Object.keys(component.categorySpecificMetadata)) { + if (component.categories[0].subcategories[0].metadataKeys.some(metadataKey => metadataKey.name == key)) { + this.categorySpecificMetadata[key] = component.categorySpecificMetadata[key]; + } + } + } + } + public setUniqueId = (uniqueId:string):void => { this.uniqueId = uniqueId; }; @@ -543,6 +569,11 @@ export abstract class Component implements IComponent { this.archived = componentMetadata.archived || false; this.vspArchived = componentMetadata.vspArchived; this.componentMetadata = componentMetadata; + if (componentMetadata.categorySpecificMetadata){ + this.categorySpecificMetadata = componentMetadata.categorySpecificMetadata; + } else { + this.categorySpecificMetadata = new Metadata(); + } } public toJSON = ():any => { |