X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-ui%2Fsrc%2Fapp%2Fng2%2Fservices%2Fcomponent-instance-services%2Fcomponent-instance.service.ts;h=c2258fd01eedea56c0ef124ba8d469a42ac53da5;hb=0d9d05e705a6fbc9c4370fdd3a8ad543d04f8210;hp=cc382a3df03f55ccec0b452d764d04b15443a3d5;hpb=16a9fce0e104a38371a9e5a567ec611ae3fc7f33;p=sdc.git diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts index cc382a3df0..c2258fd01e 100644 --- a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts +++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts @@ -18,15 +18,27 @@ * ============LICENSE_END========================================================= */ -import {Injectable, Inject} from '@angular/core'; -import { Observable } from 'rxjs/Observable'; -import {PropertyFEModel, PropertyBEModel} from "app/models"; -import {CommonUtils, ComponentType, ServerTypeUrl, ComponentInstanceFactory} from "app/utils"; -import {Component, ComponentInstance, Capability, PropertyModel, ArtifactGroupModel, ArtifactModel, AttributeModel, IFileDownload} from "app/models"; -import {SdcConfigToken, ISdcConfig} from "../../config/sdc-config.config"; -import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { InputBEModel } from '../../../models/properties-inputs/input-be-model'; -import { HttpHelperService } from '../http-hepler.service'; +import {Inject, Injectable} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { + ArtifactGroupModel, + ArtifactModel, + AttributeModel, + Capability, + Component, + ComponentInstance, + IFileDownload, + PropertyBEModel, + PropertyModel, + Requirement +} from "app/models"; +import {CommonUtils, ComponentInstanceFactory, ComponentType, ServerTypeUrl} from "app/utils"; +import {ISdcConfig, SdcConfigToken} from "../../config/sdc-config.config"; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {InputBEModel} from '../../../models/properties-inputs/input-be-model'; +import {HttpHelperService} from '../http-hepler.service'; +import {AttributeBEModel} from "../../../models/attributes-outputs/attribute-be-model"; +import {OutputBEModel} from "../../../models/attributes-outputs/output-be-model"; @Injectable() export class ComponentInstanceServiceNg2 { @@ -52,13 +64,32 @@ export class ComponentInstanceServiceNg2 { }) } + getComponentInstanceAttributes(component: Component, componentInstanceId: string): Observable> { + return this.http.get>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstanceId + '/attributes') + .map(res => { + return CommonUtils.initBeAttributes(res); + }) + } + getComponentInstanceInputs(component: Component, componentInstance: ComponentInstance): Observable> { - return this.http.get>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstance.uniqueId + '/' + componentInstance.componentUid + '/inputs') + return this.getComponentInstanceInputsByIdAndType(component.uniqueId, component.componentType, componentInstance); + } + + + getComponentInstanceInputsByIdAndType(componentId: string, componentType:string, componentInstance: ComponentInstance): Observable> { + return this.http.get>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/componentInstances/' + componentInstance.uniqueId + '/' + componentInstance.componentUid + '/inputs') .map(res => { return CommonUtils.initInputs(res); }) } + getComponentInstanceOutputs(component: Component, componentInstance: ComponentInstance): Observable> { + return this.http.get>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstance.uniqueId + '/' + componentInstance.componentUid + '/outputs') + .map(res => { + return CommonUtils.initOutputs(res); + }) + } + getComponentInstanceArtifactsByGroupType = (componentType:string, componentId:string, componentInstanceId:string, artifactGroupType:string):Observable => { return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + "/resourceInstances/" + componentInstanceId + "/artifactsByType/" + artifactGroupType) @@ -68,7 +99,7 @@ export class ComponentInstanceServiceNg2 { }; getArtifactByGroupType = (componentType:string, componentId:string, artifactGroupType:string):Observable => { - + return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + "/artifactsByType/" + artifactGroupType) .map(response => new ArtifactGroupModel(response)); }; @@ -93,12 +124,24 @@ export class ComponentInstanceServiceNg2 { .map((res) => { return res.map((resProperty) => { let newProp = new PropertyModel(resProperty); - newProp.resourceInstanceUniqueId = componentInstanceId + newProp.resourceInstanceUniqueId = componentInstanceId; return newProp; }); }); } + updateInstanceAttributes(componentType:string, componentId:string, componentInstanceId: string, attributes: AttributeBEModel[]) { + + return this.http.post>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/resourceInstance/' + componentInstanceId + '/attributes', attributes) + .map((res) => { + return res.map((resAttribute) => { + let newAttrib = new AttributeModel(resAttribute); + newAttrib.resourceInstanceUniqueId = componentInstanceId; + return newAttrib; + }); + }); + } + getInstanceCapabilityProperties(componentType: string, componentId: string, componentInstanceId: string, capability: Capability): Observable> { return this.http.get>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/componentInstances/' + componentInstanceId + '/capability/' + capability.type + @@ -125,6 +168,16 @@ export class ComponentInstanceServiceNg2 { }) } + updateInstanceRequirement(componentType: string, componentId: string, componentInstanceId: string, requirement: Requirement): Observable { + return this.http.put(this.baseUrl + componentType + componentId + '/componentInstances/' + componentInstanceId + '/requirement/' + requirement.capability + + '/requirementName/' + requirement.name, requirement); + } + + updateInstanceCapability(componentTypeUrl: string, componentId: string, componentInstanceId: string, capability: Capability): Observable { + const url = `${this.baseUrl}${componentTypeUrl}${componentId}/componentInstances/${componentInstanceId}/capability/`; + return this.http.put(url, capability); + } + updateInstanceInputs(component: Component, componentInstanceId: string, inputs: PropertyBEModel[]): Observable { return this.http.post>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/inputs', inputs) @@ -133,6 +186,14 @@ export class ComponentInstanceServiceNg2 { }); } + updateInstanceOutputs(component: Component, componentInstanceId: string, outputs: AttributeBEModel[]): Observable { + + return this.http.post>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/outputs', outputs) + .map((res) => { + return res.map((resOutput) => new AttributeBEModel(resOutput)); + }); + } + getComponentGroupInstanceProperties(component: Component, groupInstanceId: string): Observable> { return this.http.get>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/groups/' + groupInstanceId + '/properties') .map((res) => { @@ -162,7 +223,6 @@ export class ComponentInstanceServiceNg2 { } addInstanceArtifact = (componentType:string, componentId:string, instanceId:string, artifact:ArtifactModel):Observable => { - // let deferred = this.$q.defer(); let headerObj = new HttpHeaders(); if (artifact.payloadData) { headerObj = headerObj.set('Content-MD5', HttpHelperService.getHeaderMd5(artifact)); @@ -176,7 +236,7 @@ export class ComponentInstanceServiceNg2 { updateInstanceArtifact = (componentType:string, componentId:string, instanceId:string, artifact:ArtifactModel):Observable => { return this.http.post(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/resourceInstance/' + instanceId + '/artifacts/' + artifact.uniqueId, artifact).map((res) => { return new ArtifactModel(res); - });; + }); }; deleteInstanceArtifact = (componentId:string, componentType:string, instanceId:string, artifactId:string, artifactLabel:string):Observable => {