2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 import * as _ from "lodash";
23 import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model";
24 import {VendorModel} from "app/view-models/workspace/tabs/management-workflow/management-workflow-view-model";
25 import {ResourceType, ArtifactType} from "app/utils";
26 import {ComponentInstance} from "app/models";
27 import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response";
28 import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service";
29 declare var PunchOutRegistry;
31 export interface INetworkCallFlowViewModelScope extends IWorkspaceViewModelScope {
32 vendorMessageModel:VendorModel;
36 export class participant {
40 constructor(instance:ComponentInstance) {
41 this.name = instance.name;
42 this.id = instance.uniqueId;
47 export class NetworkCallFlowViewModel {
55 constructor(private $scope:INetworkCallFlowViewModelScope,
57 private ComponentServiceNg2: ComponentServiceNg2) {
59 this.$scope.isLoading = true;
61 PunchOutRegistry.loadOnBoarding(()=> {
62 this.$scope.isLoading = false;
63 this.initComponentInstancesAndInformationalArtifacts();
67 private getVFParticipantsFromInstances(instances:Array<ComponentInstance>):Array<participant> {
68 let participants = [];
69 _.forEach(instances, (instance)=> {
70 if (ResourceType.VF == instance.originType) {
71 participants.push(new participant(instance));
77 private initComponentInstancesAndInformationalArtifacts = ():void => {
78 if(!this.$scope.component.artifacts || !this.$scope.component.componentInstances) {
79 this.$scope.isLoading = true;
80 this.ComponentServiceNg2.getComponentInformationalArtifactsAndInstances(this.$scope.component).subscribe((response:ComponentGenericResponse) => {
81 this.$scope.component.artifacts = response.artifacts;
82 this.$scope.component.componentInstances = response.componentInstances;
84 this.$scope.isLoading = false;
91 private initScope():void {
92 this.$scope.vendorMessageModel = new VendorModel(
93 this.$scope.component.artifacts.filteredByType(ArtifactType.THIRD_PARTY_RESERVED_TYPES.NETWORK_CALL_FLOW),
94 this.$scope.component.uniqueId,
95 this.$scope.isViewMode(),
96 this.$scope.user.userId,
97 this.uuid4.generate(),
98 ArtifactType.THIRD_PARTY_RESERVED_TYPES.NETWORK_CALL_FLOW,
99 this.getVFParticipantsFromInstances(this.$scope.component.componentInstances)
102 this.$scope.thirdParty = true;
103 this.$scope.setValidState(true);