diff options
author | ys9693 <ys9693@att.com> | 2020-01-19 13:50:02 +0200 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-01-22 12:33:31 +0000 |
commit | 16a9fce0e104a38371a9e5a567ec611ae3fc7f33 (patch) | |
tree | 03a2aff3060ddb5bc26a90115805a04becbaffc9 /catalog-ui/src/app/models/componentsInstances | |
parent | aa83a2da4f911c3ac89318b8e9e8403b072942e1 (diff) |
Catalog alignment
Issue-ID: SDC-2724
Signed-off-by: ys9693 <ys9693@att.com>
Change-Id: I52b4aacb58cbd432ca0e1ff7ff1f7dd52099c6fe
Diffstat (limited to 'catalog-ui/src/app/models/componentsInstances')
-rw-r--r-- | catalog-ui/src/app/models/componentsInstances/componentInstance.ts | 60 | ||||
-rw-r--r-- | catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts | 110 |
2 files changed, 162 insertions, 8 deletions
diff --git a/catalog-ui/src/app/models/componentsInstances/componentInstance.ts b/catalog-ui/src/app/models/componentsInstances/componentInstance.ts index f95d6553cd..d3a99e5390 100644 --- a/catalog-ui/src/app/models/componentsInstances/componentInstance.ts +++ b/catalog-ui/src/app/models/componentsInstances/componentInstance.ts @@ -23,12 +23,53 @@ */ 'use strict'; import * as _ from "lodash"; -import {ArtifactGroupModel, CapabilitiesGroup,RequirementsGroup, PropertyModel, InputModel, Module} from "../../models"; -import {ResourceType,ComponentType} from "../../utils/constants"; +import { + ArtifactGroupModel, + CapabilitiesGroup, + RequirementsGroup, + PropertyModel, + InputModel, + Module +} from "../../models"; +import {ResourceType, ComponentType} from "../../utils/constants"; import {Capability} from "../capability"; import {Requirement} from "../requirement"; -export class ComponentInstance { +export interface IComponentInstance { + + componentUid:string; + componentName:string; + posX:number; + posY:number; + componentVersion:string; + description:string; + icon:string; + name:string; + normalizedName:string; + originType:string; + deploymentArtifacts:ArtifactGroupModel; + artifacts:ArtifactGroupModel; + propertyValueCounter:number; + uniqueId:string; + creationTime:number; + modificationTime:number; + capabilities:CapabilitiesGroup; + requirements:RequirementsGroup; + customizationUUID:string; + sourceModelInvariant:string; + sourceModelName:string; + sourceModelUid:string; + sourceModelUuid:string; + //custom properties + certified:boolean; + iconSprite:string; + inputs:Array<InputModel>; + properties:Array<PropertyModel>; + groupInstances:Array<Module>; + invariantName:string; + originArchived:boolean; +} +export class ComponentInstance implements IComponentInstance{ public componentUid:string; public componentName:string; @@ -61,7 +102,7 @@ export class ComponentInstance { public groupInstances:Array<Module>; public invariantName:string; public originArchived:boolean; - public directives: Array<string>; + public directives: string[]; DIRECTIVES_TYPES = { SELECTABLE: 'selectable' @@ -112,14 +153,18 @@ export class ComponentInstance { return this.originType === 'VL'; }; - public isComplex = () : boolean => { - return this.originType === ResourceType.VF || this.originType === ResourceType.PNF || this.originType === ResourceType.CVFC || this.originType === ResourceType.CR ; + public isComplex = ():boolean => { + return this.originType === ResourceType.VF || this.originType === ResourceType.PNF || this.originType === ResourceType.CVFC || this.originType === ResourceType.CR; } - public isServiceProxy = () :boolean => { + public isServiceProxy = ():boolean => { return this.originType === ComponentType.SERVICE_PROXY; } + public getComponentUid = ():string => { + return this.isServiceProxy()? this.sourceModelUid : this.componentUid; + } + public setInstanceRC = ():void=> { _.forEach(this.requirements, (requirementValue:Array<any>, requirementKey)=> { _.forEach(requirementValue, (requirement)=> { @@ -183,7 +228,6 @@ export class ComponentInstance { public get iconClass() { return this.iconSprite + ' ' + this.icon; } - public isDependent = () : boolean => { return this.directives && this.directives.indexOf(this.DIRECTIVES_TYPES.SELECTABLE) !== -1; } diff --git a/catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts b/catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts new file mode 100644 index 0000000000..ce5aa1dae9 --- /dev/null +++ b/catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts @@ -0,0 +1,110 @@ +import { ComponentInstance, Component, ArtifactGroupModel, Service, Resource, IMainCategory, ArtifactModel, AttributeModel } from "app/models"; +import { ComponentType } from '../../utils/constants'; +import * as _ from 'lodash'; + + +export class FullComponentInstance extends ComponentInstance { + public contactId: string; + public componentType: string; + public interfaces:any; + public tags:Array<string>; + public version:string; + public allVersions:any; + public highestVersion:boolean; + public categories:Array<IMainCategory>; + public creationDate:number; + public creatorFullName:string; + public vendorName:string; + public vendorRelease:string; + public systemName:string; + public uuid:string; + public lifecycleState: string; + public archived: boolean; + + public isServiceInstance: boolean; + public isResourceInstance: boolean; + public directives: string[]; + + DIRECTIVES_TYPES = { + SELECTABLE: 'selectable' + }; + + //service + public serviceApiArtifacts:ArtifactGroupModel; + public serviceType:string; + public serviceRole:string; + + //resource + public csarUUID:string; + public isCsarComponent: boolean; + public csarVersion:string; + public csarPackageType:string; + public packageId:string; + public resourceType:string; + public resourceVendorModelNumber:string; + + public attributes: Array<AttributeModel>; + + constructor(componentInstance:ComponentInstance, originComponent:Component) { + super(componentInstance); + + this.componentType = originComponent.componentType; + this.interfaces = originComponent.interfaces; + this.tags = []; + this.tags = _.clone(originComponent.tags); + this.version = originComponent.version; + this.allVersions = originComponent.allVersions; + this.highestVersion = originComponent.highestVersion; + this.categories = originComponent.categories; + this.creationDate = originComponent.creationDate; + this.creatorFullName = originComponent.creatorFullName; + this.vendorName = originComponent.vendorName; + this.vendorRelease = originComponent.vendorRelease; + this.contactId = originComponent.contactId; + this.description = originComponent.description; + this.systemName = originComponent.systemName; + this.uuid = originComponent.uuid; + this.lifecycleState = originComponent.lifecycleState; + this.archived = originComponent.archived; + this.attributes = originComponent.attributes; + this.directives = componentInstance.directives; + + + if(originComponent.componentType === ComponentType.SERVICE || originComponent.componentType === ComponentType.SERVICE_PROXY){ + this.isServiceInstance = true; + this.serviceApiArtifacts = (<Service>originComponent).serviceApiArtifacts; + this.serviceType = (<Service>originComponent).serviceType; + this.serviceRole = (<Service>originComponent).serviceRole; + } + if(originComponent.componentType === ComponentType.RESOURCE) { + this.isResourceInstance = true; + this.csarUUID = (<Resource>originComponent).csarUUID; + this.isCsarComponent = !!this.csarUUID; + this.resourceType = (<Resource>originComponent).resourceType; + this.resourceVendorModelNumber = (<Resource>originComponent).resourceVendorModelNumber; + } + } + + public isResource = ():boolean => { + return this.isResourceInstance; + } + + public isService = ():boolean => { + return this.isServiceInstance; + } + public isDependent = () : boolean => { + return this.directives && this.directives.indexOf(this.DIRECTIVES_TYPES.SELECTABLE) !== -1; + } + + public markAsDependent = () : void => { + this.directives.push(this.DIRECTIVES_TYPES.SELECTABLE); + } + + public unmarkAsDependent = () : void => { + const index = this.directives.indexOf(this.DIRECTIVES_TYPES.SELECTABLE); + if(index >= 0) { + this.directives.splice(index, 1); + } + } + +}
\ No newline at end of file |