summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnjali walsatwar <anjali.walsatwar@huawei.com>2018-09-25 14:16:47 +0530
committerAnjali Walsatwar <anjali.walsatwar@huawei.com>2018-12-28 09:30:56 +0000
commitc3f4278b607e853959273f4fbb5c43b9ecb0c49c (patch)
treea0b103aedd2e1a353e829056683f2079bbeee159
parent8eaa66c35b6dc428491f5064c68f4f6bebf38086 (diff)
Keyboard Shortcut for copy&Paste and delete
Issue-ID: SDC-1694 Change-Id: I6da5532520e289774c1e028cb7c31db0c5f79489 Signed-off-by: Anjali walsatwar <anjali.walsatwar@huawei.com>
-rw-r--r--catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.directive.ts172
-rw-r--r--catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.html3
-rw-r--r--catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.less4
-rw-r--r--catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts40
-rw-r--r--catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts85
-rw-r--r--catalog-ui/src/app/models/components/component.ts620
-rw-r--r--catalog-ui/src/app/services/components/component-service.ts542
7 files changed, 938 insertions, 528 deletions
diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.directive.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.directive.ts
index 804e772ac4..a6af9a8110 100644
--- a/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.directive.ts
+++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.directive.ts
@@ -35,7 +35,7 @@ import {
NodesFactory,
Point
} from "app/models";
-import { ComponentInstanceFactory, ComponentFactory, GRAPH_EVENTS, GraphColors } from "app/utils";
+import { ComponentInstanceFactory, ComponentFactory, GRAPH_EVENTS, GraphColors, GraphUIObjects, ModalsHandler } from "app/utils";
import { EventListenerService, LoaderService } from "app/services";
import { CompositionGraphLinkUtils } from "./utils/composition-graph-links-utils";
import { CompositionGraphGeneralUtils } from "./utils/composition-graph-general-utils";
@@ -127,6 +127,11 @@ export interface ICompositionGraphScope extends ng.IScope {
deletePathsOnCy(): void;
drawPathOnCy(data: ForwardingPath): void;
selectedPathId: string;
+
+ copyComponentInstance(): void;
+ pasteComponentInstance(event: IDragDropEvent): void;
+
+ origComponentId: string;
}
export class CompositionGraph implements ng.IDirective {
@@ -134,6 +139,7 @@ export class CompositionGraph implements ng.IDirective {
private _currentlyCLickedNodePosition: Cy.Position;
private dragElement: JQuery;
private dragComponent: ComponentInstance;
+ private cyBackgroundClickEvent: any;
constructor(private $q: ng.IQService,
private $log: ng.ILogService,
@@ -154,7 +160,8 @@ export class CompositionGraph implements ng.IDirective {
private ModalServiceNg2: ModalService,
private ConnectionWizardServiceNg2: ConnectionWizardService,
private ComponentInstanceServiceNg2: ComponentInstanceServiceNg2,
- private servicePathGraphUtils: ServicePathGraphUtils) {
+ private servicePathGraphUtils: ServicePathGraphUtils,
+ private ModalsHandler: ModalsHandler) {
}
@@ -531,8 +538,135 @@ export class CompositionGraph implements ng.IDirective {
this.CompositionGraphLinkUtils.deleteLink(this._cy, scope.component, true, link);
}
};
+
+
+ document.onkeydown = (event) => {
+ let isModalExist = document.getElementsByTagName('body')[0].classList.contains('modal-open');
+
+ if (!scope.isViewOnly && !isModalExist) {
+
+ switch (event.keyCode) {
+
+ case 46: //delete
+ scope.deleteSelectedElements();
+ break;
+
+ case 67: //ctrl+c : copy componentInstance
+ if (event.ctrlKey && scope.component.isService()) {
+ scope.copyComponentInstance();
+ }
+ break;
+ case 86: // ctrl+v: paste componentInstance
+ if (event.ctrlKey && scope.component.isService()) {
+ let hidePasteObj = $(".w-canvas-content-paste");
+ hidePasteObj.click();
+ }
+ break;
+
+ }
+ }
+ };
+
+ scope.deleteSelectedElements = (): void => {
+ if (this._cy) {
+ let nodesToDelete = this._cy.$('node:selected');
+ let edgesSelected = this._cy.$('edge:selected');
+ if (nodesToDelete.length + edgesSelected.length <= 0) {
+ return;
+ }
+ let componentInstancetobeDele;
+ let title: string = "Delete Confirmation";
+ let message: string = "Are you sure you would like to delete selected elements?";
+ if (nodesToDelete.size() == 1 && edgesSelected.size() == 0) {
+
+ componentInstancetobeDele = nodesToDelete[0].data().componentInstance;
+ let showName = nodesToDelete[0].data().componentInstance.name;
+ message = "Are you sure you would like to delete" + " " + showName + "?";
+ }
+
+ let onOk = (): void => {
+ if (nodesToDelete.size() == 1 && edgesSelected.size() == 0) {
+ this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE, componentInstancetobeDele);
+ }
+ else {
+ this.NodesGraphUtils.batchDeleteNodes(this._cy, scope.component, nodesToDelete);
+ }
+
+ };
+
+ this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk);
+ }
+
+ };
+
+ scope.copyComponentInstance = (): void => {
+ scope.origComponentId = scope.component.uniqueId;
+ if (scope.component.selectedInstance) {
+ scope.origSelectedInstance = scope.component.selectedInstance;
+ }
+ };
+
+
+ scope.pasteComponentInstance = (event: IDragDropEvent): void => {
+ event.clientX = event.clientX ? event.clientX : this.cyBackgroundClickEvent ? this.cyBackgroundClickEvent.originalEvent.clientX : null;
+ event.clientY = event.clientY ? event.clientY : this.cyBackgroundClickEvent ? this.cyBackgroundClickEvent.originalEvent.clientY : null;
+
+ if (event.clientX == null || event.clientY == null) {
+ return;
+ }
+ let offsetPosition = {
+ x: event.clientX - GraphUIObjects.DIAGRAM_PALETTE_WIDTH_OFFSET,
+ y: event.clientY - GraphUIObjects.DIAGRAM_HEADER_OFFSET
+ };
+
+ let mousePosition = this.commonGraphUtils.HTMLCoordsToCytoscapeCoords(this._cy.extent(), offsetPosition);
+ let newPositionX = mousePosition.x;
+ let newPositionY = mousePosition.y;
+ let origSelectedInstance = scope.origSelectedInstance;
+
+ let copyComponentInstance = `{
+ "posX":"${newPositionX}",
+ "posY":"${newPositionY}",
+ "name":"${origSelectedInstance.componentName}",
+ "componentVersion":"${origSelectedInstance.componentVersion}",
+ "originType":"${origSelectedInstance.originType}",
+ "icon":"${origSelectedInstance.icon}",
+ "componentUid":"${origSelectedInstance.componentUid}"
+ }`;
+
+ this.isComponentPasteValid(scope, this._cy, event, offsetPosition, origSelectedInstance);
+
+
+ let onSuccess = (response): void => {
+ let success = (component: Component) => {
+ scope.component.componentInstances = component.componentInstances;
+ if (component.isService() && component.componentInstances.length > 0) {
+ _.each(component.componentInstances, (instance) => {
+ if (instance.uniqueId == response.componentInstance.uniqueId) {
+ let compositionGraphNode: CompositionCiNodeBase = this.NodesFactory.createNode(instance);
+ this.commonGraphUtils.addComponentInstanceNodeToGraph(this._cy, compositionGraphNode);
+ }
+ });
+ }
+ scope.isLoading = false;
+ };
+ scope.component.getComponent().then(success);
+ };
+ let onFailed = (error: any): void => {
+ console.log(error);
+ scope.isLoading = false;
+ };
+
+ if (scope.pasteValid) {
+ scope.isLoading = true;
+ scope.component.pasteMenuComponentInstance(origSelectedInstance.uniqueId, copyComponentInstance).then(onSuccess, onFailed);
+ }
+ };
+
}
+
+
private registerCytoscapeGraphEvents(scope: ICompositionGraphScope) {
this._cy.on('addedgemouseup', (event, data) => {
@@ -633,6 +767,7 @@ export class CompositionGraph implements ng.IDirective {
}
this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED);
}
+ this.cyBackgroundClickEvent = event;
scope.hideRelationMenu();
}
@@ -752,7 +887,6 @@ export class CompositionGraph implements ng.IDirective {
});
}
-
private initDropZone(scope: ICompositionGraphScope) {
if (scope.isViewOnly) {
@@ -866,7 +1000,30 @@ export class CompositionGraph implements ng.IDirective {
}
};
};
+ private isComponentPasteValid(scope: ICompositionGraphScope, cy: Cy.Instance, event: IDragDropEvent, offsetPosition: Cy.Position, origSelectedInstance: ComponentInstance) {
+ let bbox = this._getNodeBBox(cy, event, origSelectedInstance, offsetPosition);
+ if (this.GeneralGraphUtils.isPaletteDropValid(cy, bbox, origSelectedInstance)) {
+ scope.pasteValid = true;
+ } else {
+ scope.pasteValid = false;
+ }
+ }
+
+ private _getNodeBBox(cy: Cy.Instance, event: IDragDropEvent, origSelectedInstance: ComponentInstance, position?: Cy.Position) {
+ let bbox = <Cy.BoundingBox>{};
+ if (!position) {
+ position = this.commonGraphUtils.getCytoscapeNodePosition(cy, event);
+ }
+ let cushionWidth: number = 40;
+ let cushionHeight: number = 40;
+
+ bbox.x1 = position.x - cushionWidth / 2;
+ bbox.y1 = position.y - cushionHeight / 2;
+ bbox.x2 = position.x + cushionWidth / 2;
+ bbox.y2 = position.y + cushionHeight / 2;
+ return bbox;
+ }
public static factory = ($q,
$log,
@@ -887,7 +1044,8 @@ export class CompositionGraph implements ng.IDirective {
ModalService,
ConnectionWizardService,
ComponentInstanceServiceNg2,
- ServicePathGraphUtils) => {
+ ServicePathGraphUtils,
+ ModalsHandler) => {
return new CompositionGraph(
$q,
$log,
@@ -908,7 +1066,8 @@ export class CompositionGraph implements ng.IDirective {
ModalService,
ConnectionWizardService,
ComponentInstanceServiceNg2,
- ServicePathGraphUtils);
+ ServicePathGraphUtils,
+ ModalsHandler);
}
}
@@ -932,5 +1091,6 @@ CompositionGraph.factory.$inject = [
'ModalServiceNg2',
'ConnectionWizardServiceNg2',
'ComponentInstanceServiceNg2',
- 'ServicePathGraphUtils'
+ 'ServicePathGraphUtils',
+ 'ModalsHandler'
];
diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.html b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.html
index b473f44628..e264381a99 100644
--- a/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.html
+++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.html
@@ -26,6 +26,9 @@
create-relation="createLinkFromMenu" cancel="cancelRelationMenu()"></relation-menu> -->
<menu-list-ng2 [props]="canvasMenuProps"></menu-list-ng2>
+<div id="cyMenu" class="hidePaste">
+ <div class="w-canvas-content-paste" data-ng-click="pasteComponentInstance($event)">paste</div>
+</div>
<div class="w-sdc-search-menu" data-ng-class="{'with-sidebar': withSidebar}">
diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.less b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.less
index 7124a4b5a6..a310cd447e 100644
--- a/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.less
+++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.less
@@ -16,6 +16,10 @@ composition-graph {
background-color:rgb(248, 248, 248);
}
+ .hidePaste {
+ display:none;
+ }
+
.sdc-canvas-zones__wrapper {
position: absolute;
bottom: 10px;
diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts
index 705367c5f7..6c83810312 100644
--- a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts
+++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts
@@ -105,6 +105,46 @@ export class CompositionGraphLinkUtils {
this.createLink(linkObg, cy, component);
};
+ public batchDeleteEdges(cy: Cy.Instance, component: Component, edgesToDelete: Cy.CollectionEdges, alreadyDeleteNodeIds?: Array<string>): void {
+ let toDeleteLinks: Array<RelationshipModel> = new Array<RelationshipModel>();
+ if (alreadyDeleteNodeIds && alreadyDeleteNodeIds.length > 0) {
+ edgesToDelete.each((i: number, link: Cy.CollectionEdges) => {
+ if (alreadyDeleteNodeIds.indexOf(link.data().source) < 0 && alreadyDeleteNodeIds.indexOf(link.data().target) < 0) {
+ toDeleteLinks.push(link.data().relation);
+ }
+ });
+ }
+ else {
+ edgesToDelete.each((i: number, link: Cy.CollectionEdges) => {
+ toDeleteLinks.push(link.data().relation);
+ });
+ }
+ this.loaderService.showLoader('composition-graph');
+ let onSuccessDeleteRelations = (response: Array<RelationshipModel>) => {
+ console.info('onSuccessDeleteRelations response is ', response);
+ //remove tempSimplePortNodes
+ if (alreadyDeleteNodeIds && alreadyDeleteNodeIds.length > 0) {
+ edgesToDelete.each((i: number, link: Cy.CollectionEdges) => {
+ if (alreadyDeleteNodeIds.indexOf(link.data().source) < 0 && alreadyDeleteNodeIds.indexOf(link.data().target) < 0) {
+ cy.remove(edgesToDelete);
+ }
+ });
+ }
+ else {
+ edgesToDelete.each((i: number, link: Cy.CollectionEdges) => {
+ cy.remove(edgesToDelete);
+ });
+ }
+ };
+
+ if (toDeleteLinks.length > 0) {
+ this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback(
+ () => component.batchDeleteRelation(toDeleteLinks).then(onSuccessDeleteRelations),
+ () => this.loaderService.hideLoader('composition-graph'));
+
+ }
+ };
+
public createLinkFromMenu = (cy:Cy.Instance, chosenMatch:Match, component:Component):void => {
if (chosenMatch) {
diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts
index c6c732b7df..7d08d7f9b5 100644
--- a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts
+++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts
@@ -122,6 +122,91 @@ export class CompositionGraphNodesUtils {
};
/**
+ * Batch delete component instances on server and then removes them from the graph as well
+ * @param cy
+ * @param component
+ * @param nodesToDelete
+ */
+ public batchDeleteNodes(cy:Cy.Instance, component:Component, nodesToDelete:Cy.CollectionNodes):Array<string> {
+ let nodesToDeleteIds:Array<string> = new Array<string>();
+ if(nodesToDelete && nodesToDelete.size() > 0){
+ nodesToDelete.each((i:number, node:Cy.CollectionNodes) => {
+ nodesToDeleteIds.push(node.data('id'));
+ });
+ this.loaderService.showLoader('composition-graph');
+ let componentInstances:Array<ComponentInstance> = component.componentInstances;
+ let onSuccess:(response:any) => void = (deleteFailedIds:any) => {
+ this.removeDeletedNodesOnGraph(cy, nodesToDelete, deleteFailedIds, componentInstances);
+ };
+
+ let onFailed:(response:any) => void = (response:any) => {
+ console.error('batchDeleteNodes failed error is', response);
+ };
+
+ this.GeneralGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback(
+ () => component.batchDeleteComponentInstance(nodesToDeleteIds).then(onSuccess, onFailed),
+ () => this.loaderService.hideLoader('composition-graph')
+ );
+ }
+
+ return nodesToDeleteIds;
+ };
+
+ private deleteNodeSuccess(cy:Cy.Instance, component:Component, nodeToDelete:Cy.CollectionNodes):void{
+ //if node to delete is a UCPE, remove all children (except UCPE-CPs) and remove their "hostedOn" links
+ if (nodeToDelete.data().isUcpe) {
+ _.each(cy.nodes('[?isInsideGroup]'), (node)=> {
+ this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_REMOVE_NODE_FROM_UCPE, node, nodeToDelete);
+ });
+ }
+
+ //check whether the node is connected to any VLs that only have one other connection. If so, delete that VL as well
+ if (!(nodeToDelete.data() instanceof CompositionCiNodeVl)) {
+ let connectedVls:Array<Cy.CollectionFirstNode> = this.getConnectedVlToNode(nodeToDelete);
+ this.handleConnectedVlsToDelete(connectedVls);
+ }
+
+ // check whether there is a service path going through this node, and if so clean it from the graph.
+ let nodeId = nodeToDelete.data().id;
+ let connectedPathLinks = cy.collection(`[type="${CompositionCiServicePathLink.LINK_TYPE}"][source="${nodeId}"], [type="${CompositionCiServicePathLink.LINK_TYPE}"][target="${nodeId}"]`);
+ _.forEach(connectedPathLinks, (link, key) => {
+ cy.remove(`[pathId="${link.data().pathId}"]`);
+ });
+
+ // update service path list
+ this.serviceService.getComponentCompositionData(component).subscribe((response:ServiceGenericResponse) => {
+ (<Service>component).forwardingPaths = response.forwardingPaths;
+ });
+
+ this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE_SUCCESS, nodeId);
+
+ //update UI
+ cy.remove(nodeToDelete);
+ }
+
+ private removeDeletedNodesOnGraph(cy:Cy.Instance, nodesToDelete:Cy.CollectionNodes, deleteFailedIds:Array<string>, componentInstances:Array<ComponentInstance>):void {
+ nodesToDelete.each((j:number, nodeToDelete:Cy.CollectionNodes) => {
+ if(deleteFailedIds.indexOf(nodeToDelete.data('id')) < 0) {
+ //if node to delete is a UCPE, remove all children (except UCPE-CPs) and remove their "hostedOn" links
+ if (nodeToDelete.data().isUcpe) {
+ _.each(cy.nodes('[?isInsideGroup]'), (node)=> {
+ this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_REMOVE_NODE_FROM_UCPE, node , nodeToDelete);
+ });
+ }
+
+ //check whether the node is connected to any VLs that only have one other connection. If so, delete that VL as well
+ if(!(nodeToDelete.data() instanceof CompositionCiNodeVl)) {
+ let connectedVls:Array<Cy.CollectionFirstNode> = this.getConnectedVlToNode(nodeToDelete);
+ this.handleConnectedVlsToDelete(connectedVls);
+ }
+
+
+ cy.remove(nodeToDelete);
+ }
+ });
+ }
+
+ /**
* Finds all VLs connected to a single node
* @param node
* @returns {Array<Cy.CollectionFirstNode>}
diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts
index 8f0fa33c42..e81cf35630 100644
--- a/catalog-ui/src/app/models/components/component.ts
+++ b/catalog-ui/src/app/models/components/component.ts
@@ -21,18 +21,20 @@
'use strict';
import * as _ from "lodash";
-import {AsdcComment, ArtifactModel, ArtifactGroupModel, IFileDownload, PropertyModel, PropertiesGroup, AttributeModel, AttributesGroup, ComponentInstance,
+import {
+ AsdcComment, ArtifactModel, ArtifactGroupModel, IFileDownload, PropertyModel, PropertiesGroup, AttributeModel, AttributesGroup, ComponentInstance,
InputModel, DisplayModule, Module, IValidate, RelationshipModel, IMainCategory, RequirementsGroup, CapabilitiesGroup, AdditionalInformationModel,
- Resource, IAppMenu, OperationModel, Service} from "../../models";
-
-import {IComponentService} from "../../services/components/component-service";
-import {CommonUtils} from "../../utils/common-utils";
-import {QueueUtils} from "../../utils/functions";
-import {ArtifactGroupType} from "../../utils/constants";
-import {ComponentMetadata} from "../component-metadata";
-import {Capability} from "../capability";
-import {Requirement} from "../requirement";
-import {Relationship} from "../graph/relationship";
+ Resource, IAppMenu, OperationModel, Service
+} from "../../models";
+
+import { IComponentService } from "../../services/components/component-service";
+import { CommonUtils } from "../../utils/common-utils";
+import { QueueUtils } from "../../utils/functions";
+import { ArtifactGroupType } from "../../utils/constants";
+import { ComponentMetadata } from "../component-metadata";
+import { Capability } from "../capability";
+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";
@@ -43,141 +45,144 @@ export interface IComponent {
//---------------------------------------------- API CALLS ----------------------------------------------------//
//Component API
- getComponent():ng.IPromise<Component>;
- updateComponent():ng.IPromise<Component>;
- createComponentOnServer():ng.IPromise<Component>;
- changeLifecycleState(state:string, commentObj:AsdcComment):ng.IPromise<Component>;
- validateName(newName:string):ng.IPromise<IValidate>;
- updateRequirementsCapabilities():ng.IPromise<any>;
+ getComponent(): ng.IPromise<Component>;
+ updateComponent(): ng.IPromise<Component>;
+ createComponentOnServer(): ng.IPromise<Component>;
+ changeLifecycleState(state: string, commentObj: AsdcComment): ng.IPromise<Component>;
+ validateName(newName: string): ng.IPromise<IValidate>;
+ updateRequirementsCapabilities(): ng.IPromise<any>;
//Artifacts API
- addOrUpdateArtifact(artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
- updateMultipleArtifacts(artifacts:Array<ArtifactModel>):ng.IPromise<any>;
- deleteArtifact(artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel>;
- downloadInstanceArtifact(artifactId:string):ng.IPromise<IFileDownload>;
- downloadArtifact(artifactId:string):ng.IPromise<IFileDownload>;
- getArtifactByGroupType(artifactGroupType:string):ng.IPromise<ArtifactGroupModel>;
+ addOrUpdateArtifact(artifact: ArtifactModel): ng.IPromise<ArtifactModel>;
+ updateMultipleArtifacts(artifacts: Array<ArtifactModel>): ng.IPromise<any>;
+ deleteArtifact(artifactId: string, artifactLabel: string): ng.IPromise<ArtifactModel>;
+ downloadInstanceArtifact(artifactId: string): ng.IPromise<IFileDownload>;
+ downloadArtifact(artifactId: string): ng.IPromise<IFileDownload>;
+ getArtifactByGroupType(artifactGroupType: string): ng.IPromise<ArtifactGroupModel>;
//Property API
- addOrUpdateProperty(property:PropertyModel):ng.IPromise<PropertyModel>;
- deleteProperty(propertyId:string):ng.IPromise<PropertyModel>;
- updateInstanceProperties(componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]>;
+ addOrUpdateProperty(property: PropertyModel): ng.IPromise<PropertyModel>;
+ deleteProperty(propertyId: string): ng.IPromise<PropertyModel>;
+ updateInstanceProperties(componentInstanceId: string, properties: PropertyModel[]): ng.IPromise<PropertyModel[]>;
//Attribute API
- deleteAttribute(attributeId:string):ng.IPromise<AttributeModel>;
- addOrUpdateAttribute(attribute:AttributeModel):ng.IPromise<AttributeModel>;
- updateInstanceAttribute(attribute:AttributeModel):ng.IPromise<AttributeModel>;
+ deleteAttribute(attributeId: string): ng.IPromise<AttributeModel>;
+ addOrUpdateAttribute(attribute: AttributeModel): ng.IPromise<AttributeModel>;
+ updateInstanceAttribute(attribute: AttributeModel): ng.IPromise<AttributeModel>;
//Component Instance API
- createComponentInstance(componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>;
- deleteComponentInstance(componentInstanceId:string):ng.IPromise<ComponentInstance>;
- addOrUpdateInstanceArtifact(artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
- deleteInstanceArtifact(artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel>;
- uploadInstanceEnvFile(artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
- checkComponentInstanceVersionChange(componentUid:string):ng.IPromise<any>;
- changeComponentInstanceVersion(componentUid:string):ng.IPromise<Component>;
- updateComponentInstance(componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>;
- updateMultipleComponentInstances(instances:Array<ComponentInstance>):ng.IPromise<Array<ComponentInstance>>;
+ createComponentInstance(componentInstance: ComponentInstance): ng.IPromise<ComponentInstance>;
+ deleteComponentInstance(componentInstanceId: string): ng.IPromise<ComponentInstance>;
+ batchDeleteComponentInstance(componentInstanceIds: Array<string>): ng.IPromise<ComponentInstance>;
+ addOrUpdateInstanceArtifact(artifact: ArtifactModel): ng.IPromise<ArtifactModel>;
+ deleteInstanceArtifact(artifactId: string, artifactLabel: string): ng.IPromise<ArtifactModel>;
+ uploadInstanceEnvFile(artifact: ArtifactModel): ng.IPromise<ArtifactModel>;
+ checkComponentInstanceVersionChange(componentUid: string): ng.IPromise<any>;
+ changeComponentInstanceVersion(componentUid: string): ng.IPromise<Component>;
+ updateComponentInstance(componentInstance: ComponentInstance): ng.IPromise<ComponentInstance>;
+ updateMultipleComponentInstances(instances: Array<ComponentInstance>): ng.IPromise<Array<ComponentInstance>>;
//Inputs API
- getComponentInstanceInputProperties(componentInstanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>>
- getComponentInstanceProperties(componentInstanceId:string):ng.IPromise<Array<PropertyModel>>
- getComponentInputs(componentId:string):ng.IPromise<Array<InputModel>>;
+ getComponentInstanceInputProperties(componentInstanceId: string, inputId: string): ng.IPromise<Array<PropertyModel>>
+ getComponentInstanceProperties(componentInstanceId: string): ng.IPromise<Array<PropertyModel>>
+ getComponentInputs(componentId: string): ng.IPromise<Array<InputModel>>;
- createRelation(link:RelationshipModel):ng.IPromise<RelationshipModel>;
- deleteRelation(link:RelationshipModel):ng.IPromise<RelationshipModel>;
- fetchRelation(linkId:string):ng.IPromise<RelationshipModel>;
+ createRelation(link: RelationshipModel): ng.IPromise<RelationshipModel>;
+ deleteRelation(link: RelationshipModel): ng.IPromise<RelationshipModel>;
+ batchDeleteRelation(relations: Array<RelationshipModel>): ng.IPromise<Array<RelationshipModel>>
+
+ fetchRelation(linkId: string): ng.IPromise<RelationshipModel>;
//Modules
- getModuleForDisplay(moduleId:string):ng.IPromise<DisplayModule>;
- getModuleInstanceForDisplay(componentInstanceId:string, moduleId:string):ng.IPromise<DisplayModule>;
- updateGroupMetadata(group:Module):ng.IPromise<Module>;
-
+ getModuleForDisplay(moduleId: string): ng.IPromise<DisplayModule>;
+ getModuleInstanceForDisplay(componentInstanceId: string, moduleId: string): ng.IPromise<DisplayModule>;
+ updateGroupMetadata(group: Module): ng.IPromise<Module>;
+
//---------------------------------------------- HELP FUNCTIONS ----------------------------------------------------//
- getComponentSubType():string;
- isAlreadyCertified():boolean;
- isService():boolean;
- isResource():boolean;
- isComplex():boolean;
- getAdditionalInformation():Array<AdditionalInformationModel>;
- getAllVersionsAsSortedArray():Array<any>;
- getStatus(sdcMenu:IAppMenu):string;
+ getComponentSubType(): string;
+ isAlreadyCertified(): boolean;
+ isService(): boolean;
+ isResource(): boolean;
+ isComplex(): boolean;
+ getAdditionalInformation(): Array<AdditionalInformationModel>;
+ getAllVersionsAsSortedArray(): Array<any>;
+ getStatus(sdcMenu: IAppMenu): string;
}
export abstract class Component implements IComponent {
//server data
- public abstract:string;
- public uniqueId:string;
- public uuid:string;
- public invariantUUID:string;
- public name:string;
- public version:string;
- public creationDate:number;
- public lastUpdateDate:number;
- public description:string;
- public lifecycleState:string;
- public tags:Array<string>;
- public icon:string;
- public contactId:string;
- public allVersions:any;
- public creatorUserId:string;
- public creatorFullName:string;
- public lastUpdaterUserId:string;
- public lastUpdaterFullName:string;
- public componentType:string;
- public deploymentArtifacts:ArtifactGroupModel;
- public artifacts:ArtifactGroupModel;
- public toscaArtifacts:ArtifactGroupModel;
- public interfaceOperations:Array<OperationModel>;
- public distributionStatus:string;
- public categories:Array<IMainCategory>;
+ public abstract: string;
+ public uniqueId: string;
+ public uuid: string;
+ public invariantUUID: string;
+ public name: string;
+ public version: string;
+ public creationDate: number;
+ public lastUpdateDate: number;
+ public description: string;
+ public lifecycleState: string;
+ public tags: Array<string>;
+ public icon: string;
+ public contactId: string;
+ public allVersions: any;
+ public creatorUserId: string;
+ public creatorFullName: string;
+ public lastUpdaterUserId: string;
+ public lastUpdaterFullName: string;
+ public componentType: string;
+ public deploymentArtifacts: ArtifactGroupModel;
+ public artifacts: ArtifactGroupModel;
+ public toscaArtifacts: ArtifactGroupModel;
+ public interfaceOperations: Array<OperationModel>;
+ public distributionStatus: string;
+ public categories: Array<IMainCategory>;
public categoryNormalizedName: string;
public subCategoryNormalizedName: string;
- public componentInstancesProperties:PropertiesGroup;
- public componentInstancesAttributes:AttributesGroup;
- public componentInstancesRelations:Array<RelationshipModel>;
- public componentInstances:Array<ComponentInstance>;
- public inputs:Array<InputModel>;
- public capabilities:CapabilitiesGroup;
- public requirements:RequirementsGroup;
- public additionalInformation:any;
- public properties:Array<PropertyModel>;
- public attributes:Array<AttributeModel>;
- public highestVersion:boolean;
- public vendorName:string;
- public vendorRelease:string;
- public derivedList:Array<any>;
- public interfaces:any;
- public normalizedName:string;
- public systemName:string;
- public projectCode:string;
- public policies:Array<PolicyInstance>;
- public groupInstances:Array<GroupInstance>
- public modules:Array<Module>;
+ public componentInstancesProperties: PropertiesGroup;
+ public componentInstancesAttributes: AttributesGroup;
+ public componentInstancesRelations: Array<RelationshipModel>;
+ public componentInstances: Array<ComponentInstance>;
+ public inputs: Array<InputModel>;
+ public capabilities: CapabilitiesGroup;
+ public requirements: RequirementsGroup;
+ public additionalInformation: any;
+ public properties: Array<PropertyModel>;
+ public attributes: Array<AttributeModel>;
+ public highestVersion: boolean;
+ public vendorName: string;
+ public vendorRelease: string;
+ public derivedList: Array<any>;
+ public interfaces: any;
+ public normalizedName: string;
+ public systemName: string;
+ public projectCode: string;
+ public policies: Array<PolicyInstance>;
+ public groupInstances: Array<GroupInstance>
+ public modules: Array<Module>;
//custom properties
- public componentService:IComponentService;
- public filterTerm:string;
- public iconSprite:string;
- public selectedInstance:ComponentInstance;
- public mainCategory:string;
- public subCategory:string;
- public selectedCategory:string;
- public showMenu:boolean;
- public archived:boolean;
+ public componentService: IComponentService;
+ public filterTerm: string;
+ public iconSprite: string;
+ public selectedInstance: ComponentInstance;
+ public mainCategory: string;
+ public subCategory: string;
+ public selectedCategory: string;
+ public showMenu: boolean;
+ public archived: boolean;
public vspArchived: boolean;
- constructor(componentService:IComponentService, protected $q:ng.IQService, component?:Component) {
+ constructor(componentService: IComponentService, protected $q: ng.IQService, component?: Component) {
if (component) {
this.abstract = component.abstract;
this.uniqueId = component.uniqueId;
@@ -239,89 +244,89 @@ export abstract class Component implements IComponent {
this.componentService = componentService;
}
- public setUniqueId = (uniqueId:string):void => {
+ public setUniqueId = (uniqueId: string): void => {
this.uniqueId = uniqueId;
};
- public setSelectedInstance = (componentInstance:ComponentInstance):void => {
+ public setSelectedInstance = (componentInstance: ComponentInstance): void => {
this.selectedInstance = componentInstance;
};
//------------------------------------------ API Calls ----------------------------------------------------------------//
- public changeLifecycleState = (state:string, commentObj:AsdcComment):ng.IPromise<Component> => {
+ public changeLifecycleState = (state: string, commentObj: AsdcComment): ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
- let onSuccess = (componentMetadata:ComponentMetadata):void => {
+ let onSuccess = (componentMetadata: ComponentMetadata): void => {
this.setComponentMetadata(componentMetadata);
// this.version = componentMetadata.version;
this.lifecycleState = componentMetadata.lifecycleState;
deferred.resolve(this);
};
- let onError = (error:any):void => {
+ let onError = (error: any): void => {
deferred.reject(error);
};
this.componentService.changeLifecycleState(this, state, JSON.stringify(commentObj)).then(onSuccess, onError);
return deferred.promise;
};
- public getComponent = ():ng.IPromise<Component> => {
+ public getComponent = (): ng.IPromise<Component> => {
return this.componentService.getComponent(this.uniqueId);
};
- public createComponentOnServer = ():ng.IPromise<Component> => {
+ public createComponentOnServer = (): ng.IPromise<Component> => {
this.handleTags();
return this.componentService.createComponent(this);
};
- public updateComponent = ():ng.IPromise<Component> => {
+ public updateComponent = (): ng.IPromise<Component> => {
this.handleTags();
return this.componentService.updateComponent(this);
};
- public validateName = (newName:string, subtype?:string):ng.IPromise<IValidate> => {
+ public validateName = (newName: string, subtype?: string): ng.IPromise<IValidate> => {
return this.componentService.validateName(newName, subtype);
};
- public downloadArtifact = (artifactId:string):ng.IPromise<IFileDownload> => {
+ public downloadArtifact = (artifactId: string): ng.IPromise<IFileDownload> => {
return this.componentService.downloadArtifact(this.uniqueId, artifactId);
};
- public addOrUpdateArtifact = (artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
+ public addOrUpdateArtifact = (artifact: ArtifactModel): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
- let onSuccess = (artifactObj:ArtifactModel):void => {
+ let onSuccess = (artifactObj: ArtifactModel): void => {
let newArtifact = new ArtifactModel(artifactObj);
let artifacts = this.getArtifactsByType(artifactObj.artifactGroupType);
artifacts[artifactObj.artifactLabel] = newArtifact;
deferred.resolve(newArtifact);
};
- let onError = (error:any):void => {
+ let onError = (error: any): void => {
deferred.reject(error);
};
this.componentService.addOrUpdateArtifact(this.uniqueId, artifact).then(onSuccess, onError);
return deferred.promise;
};
- public updateMultipleArtifacts = (artifacts:Array<ArtifactModel>):ng.IPromise<any>=> {
+ public updateMultipleArtifacts = (artifacts: Array<ArtifactModel>): ng.IPromise<any> => {
let deferred = this.$q.defer();
- let onSuccess = (response:any):void => {
+ let onSuccess = (response: any): void => {
deferred.resolve(response);
};
- let onError = (error:any):void => {
+ let onError = (error: any): void => {
deferred.reject(error);
};
let q = new QueueUtils(this.$q);
- _.forEach(artifacts, (artifact)=> {
- q.addBlockingUIAction(()=> this.addOrUpdateArtifact(artifact).then(onSuccess, onError));
+ _.forEach(artifacts, (artifact) => {
+ q.addBlockingUIAction(() => this.addOrUpdateArtifact(artifact).then(onSuccess, onError));
});
return deferred.promise;
};
- public deleteArtifact = (artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => {
+ public deleteArtifact = (artifactId: string, artifactLabel: string): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
- let onSuccess = (artifactObj:ArtifactModel):void => {
+ let onSuccess = (artifactObj: ArtifactModel): void => {
let newArtifact = new ArtifactModel(artifactObj);
let artifacts = this.getArtifactsByType(artifactObj.artifactGroupType);
if (newArtifact.mandatory || newArtifact.serviceApi) {
@@ -336,41 +341,41 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public getArtifactByGroupType = (artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => {
+ public getArtifactByGroupType = (artifactGroupType: string): ng.IPromise<ArtifactGroupModel> => {
let deferred = this.$q.defer<ArtifactGroupModel>();
- let onSuccess = (response:ArtifactGroupModel):void => {
+ let onSuccess = (response: ArtifactGroupModel): void => {
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getArtifactByGroupType(this.uniqueId, artifactGroupType).then(onSuccess, onFailed);
return deferred.promise;
};
- public getComponentInstanceArtifactsByGroupType = (componentInstanceId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => {
+ public getComponentInstanceArtifactsByGroupType = (componentInstanceId: string, artifactGroupType: string): ng.IPromise<ArtifactGroupModel> => {
let deferred = this.$q.defer<ArtifactGroupModel>();
- let onSuccess = (response:ArtifactGroupModel):void => {
+ let onSuccess = (response: ArtifactGroupModel): void => {
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getComponentInstanceArtifactsByGroupType(this.uniqueId, componentInstanceId, artifactGroupType).then(onSuccess, onFailed);
return deferred.promise;
};
- public addOrUpdateProperty = (property:PropertyModel):ng.IPromise<PropertyModel> => {
+ public addOrUpdateProperty = (property: PropertyModel): ng.IPromise<PropertyModel> => {
let deferred = this.$q.defer<PropertyModel>();
- let onError = (error:any):void => {
+ let onError = (error: any): void => {
deferred.reject(error);
};
if (!property.uniqueId) {
- let onSuccess = (property:PropertyModel):void => {
+ let onSuccess = (property: PropertyModel): void => {
let newProperty = new PropertyModel(property);
this.properties.push(newProperty);
deferred.resolve(newProperty);
@@ -378,9 +383,9 @@ export abstract class Component implements IComponent {
this.componentService.addProperty(this.uniqueId, property).then(onSuccess, onError);
}
else {
- let onSuccess = (newProperty:PropertyModel):void => {
+ let onSuccess = (newProperty: PropertyModel): void => {
// find exist instance property in parent component for update the new value ( find bu uniqueId )
- let existProperty:PropertyModel = <PropertyModel>_.find(this.properties, {uniqueId: newProperty.uniqueId});
+ let existProperty: PropertyModel = <PropertyModel>_.find(this.properties, { uniqueId: newProperty.uniqueId });
let propertyIndex = this.properties.indexOf(existProperty);
this.properties[propertyIndex] = newProperty;
deferred.resolve(newProperty);
@@ -390,15 +395,15 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public addOrUpdateAttribute = (attribute:AttributeModel):ng.IPromise<AttributeModel> => {
+ public addOrUpdateAttribute = (attribute: AttributeModel): ng.IPromise<AttributeModel> => {
let deferred = this.$q.defer<AttributeModel>();
- let onError = (error:any):void => {
+ let onError = (error: any): void => {
deferred.reject(error);
};
if (!attribute.uniqueId) {
- let onSuccess = (attribute:AttributeModel):void => {
+ let onSuccess = (attribute: AttributeModel): void => {
let newAttribute = new AttributeModel(attribute);
this.attributes.push(newAttribute);
deferred.resolve(newAttribute);
@@ -406,8 +411,8 @@ export abstract class Component implements IComponent {
this.componentService.addAttribute(this.uniqueId, attribute).then(onSuccess, onError);
}
else {
- let onSuccess = (newAttribute:AttributeModel):void => {
- let existAttribute:AttributeModel = <AttributeModel>_.find(this.attributes, {uniqueId: newAttribute.uniqueId});
+ let onSuccess = (newAttribute: AttributeModel): void => {
+ let existAttribute: AttributeModel = <AttributeModel>_.find(this.attributes, { uniqueId: newAttribute.uniqueId });
let attributeIndex = this.attributes.indexOf(existAttribute);
newAttribute.readonly = this.uniqueId != newAttribute.parentUniqueId;
this.attributes[attributeIndex] = newAttribute;
@@ -418,14 +423,14 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public deleteProperty = (propertyId:string):ng.IPromise<PropertyModel> => {
+ public deleteProperty = (propertyId: string): ng.IPromise<PropertyModel> => {
let deferred = this.$q.defer<PropertyModel>();
- let onSuccess = ():void => {
+ let onSuccess = (): void => {
console.log("Property deleted");
- delete _.remove(this.properties, {uniqueId: propertyId})[0];
+ delete _.remove(this.properties, { uniqueId: propertyId })[0];
deferred.resolve();
};
- let onFailed = ():void => {
+ let onFailed = (): void => {
console.log("Failed to delete property");
deferred.reject();
};
@@ -433,13 +438,13 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public deleteAttribute = (attributeId:string):ng.IPromise<AttributeModel> => {
+ public deleteAttribute = (attributeId: string): ng.IPromise<AttributeModel> => {
let deferred = this.$q.defer<AttributeModel>();
- let onSuccess = ():void => {
+ let onSuccess = (): void => {
console.log("Attribute deleted");
- delete _.remove(this.attributes, {uniqueId: attributeId})[0];
+ delete _.remove(this.attributes, { uniqueId: attributeId })[0];
};
- let onFailed = ():void => {
+ let onFailed = (): void => {
console.log("Failed to delete attribute");
};
this.componentService.deleteAttribute(this.uniqueId, attributeId).then(onSuccess, onFailed);
@@ -447,7 +452,7 @@ export abstract class Component implements IComponent {
};
- public updateInstancePropertiesSuccess = (newProperties:PropertyModel[]):void => {
+ public updateInstancePropertiesSuccess = (newProperties: PropertyModel[]): void => {
newProperties.forEach((newProperty) => {
// find exist instance property in parent component for update the new value ( find bu uniqueId & path)
let existProperty: PropertyModel = <PropertyModel>_.find(this.componentInstancesProperties[newProperty.resourceInstanceUniqueId], {
@@ -459,13 +464,13 @@ export abstract class Component implements IComponent {
});
}
- public updateInstanceProperties = (componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]> => {
+ public updateInstanceProperties = (componentInstanceId: string, properties: PropertyModel[]): ng.IPromise<PropertyModel[]> => {
let deferred = this.$q.defer<PropertyModel[]>();
- let onSuccess = (newProperties:PropertyModel[]):void => {
+ let onSuccess = (newProperties: PropertyModel[]): void => {
this.updateInstancePropertiesSuccess(newProperties);
deferred.resolve(newProperties);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
console.log('Failed to update property value');
deferred.reject(error);
};
@@ -473,15 +478,15 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public updateInstanceAttribute = (attribute:AttributeModel):ng.IPromise<AttributeModel> => {
+ public updateInstanceAttribute = (attribute: AttributeModel): ng.IPromise<AttributeModel> => {
let deferred = this.$q.defer<AttributeModel>();
- let onSuccess = (newAttribute:AttributeModel):void => {
- let existAttribute:AttributeModel = <AttributeModel>_.find(this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId], {uniqueId: newAttribute.uniqueId});
+ let onSuccess = (newAttribute: AttributeModel): void => {
+ let existAttribute: AttributeModel = <AttributeModel>_.find(this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId], { uniqueId: newAttribute.uniqueId });
let index = this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId].indexOf(existAttribute);
this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId][index] = newAttribute;
deferred.resolve(newAttribute);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
console.log('Failed to update attribute value');
deferred.reject(error);
};
@@ -489,13 +494,13 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public downloadInstanceArtifact = (artifactId:string):ng.IPromise<IFileDownload> => {
+ public downloadInstanceArtifact = (artifactId: string): ng.IPromise<IFileDownload> => {
return this.componentService.downloadInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifactId);
};
- public deleteInstanceArtifact = (artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => {
+ public deleteInstanceArtifact = (artifactId: string, artifactLabel: string): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
- let onSuccess = (artifactObj:ArtifactModel):void => {
+ let onSuccess = (artifactObj: ArtifactModel): void => {
let newArtifact = new ArtifactModel(artifactObj);
let artifacts = this.selectedInstance.deploymentArtifacts;
if (newArtifact.mandatory || newArtifact.serviceApi) {//?????????
@@ -510,9 +515,9 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public addOrUpdateInstanceArtifact = (artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
+ public addOrUpdateInstanceArtifact = (artifact: ArtifactModel): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
- let onSuccess = (artifactObj:ArtifactModel):void => {
+ let onSuccess = (artifactObj: ArtifactModel): void => {
switch (artifactObj.artifactGroupType) {
case ArtifactGroupType.DEPLOYMENT:
this.selectedInstance.deploymentArtifacts[artifactObj.artifactLabel] = artifactObj;
@@ -523,7 +528,7 @@ export abstract class Component implements IComponent {
}
deferred.resolve(artifactObj);
};
- let onError = (error:any):void => {
+ let onError = (error: any): void => {
deferred.reject(error);
};
if (artifact.uniqueId) {
@@ -534,13 +539,13 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public uploadInstanceEnvFile = (artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
+ public uploadInstanceEnvFile = (artifact: ArtifactModel): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
- let onSuccess = (artifactObj:ArtifactModel):void => {
+ let onSuccess = (artifactObj: ArtifactModel): void => {
this.selectedInstance.deploymentArtifacts[artifactObj.artifactLabel] = artifactObj;
deferred.resolve(artifactObj);
};
- let onError = (error:any):void => {
+ let onError = (error: any): void => {
deferred.reject(error);
};
this.componentService.uploadInstanceEnvFile(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError);
@@ -548,13 +553,13 @@ export abstract class Component implements IComponent {
};
//this function will update the instance version than the function call getComponent to update the current component and return the new instance version
- public changeComponentInstanceVersion = (componentUid:string):ng.IPromise<Component> => {
+ public changeComponentInstanceVersion = (componentUid: string): ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
- let onSuccess = (componentInstance:ComponentInstance):void => {
- let onSuccess = (component:Component):void => {
+ let onSuccess = (componentInstance: ComponentInstance): void => {
+ let onSuccess = (component: Component): void => {
component.setSelectedInstance(componentInstance);
deferred.resolve(component);
};
@@ -564,27 +569,27 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public checkComponentInstanceVersionChange = (componentUid:string):ng.IPromise<any> => {
+ public checkComponentInstanceVersionChange = (componentUid: string): ng.IPromise<any> => {
return this.componentService.checkResourceInstanceVersionChange(this.uniqueId, this.selectedInstance.uniqueId, componentUid);
};
- public createComponentInstance = (componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => {
+ public createComponentInstance = (componentInstance: ComponentInstance): ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer<ComponentInstance>();
- let onSuccess = (instance:ComponentInstance):void => {
+ let onSuccess = (instance: ComponentInstance): void => {
this.componentInstances.push(instance);
deferred.resolve(instance);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.createComponentInstance(this.uniqueId, componentInstance).then(onSuccess, onFailed);
return deferred.promise;
};
- public updateComponentInstance = (componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => {
+ public updateComponentInstance = (componentInstance: ComponentInstance): ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer<ComponentInstance>();
- let onSuccess = (updatedInstance:ComponentInstance):void => {
- let componentInstance:ComponentInstance = _.find(this.componentInstances, (instance:ComponentInstance) => {
+ let onSuccess = (updatedInstance: ComponentInstance): void => {
+ let componentInstance: ComponentInstance = _.find(this.componentInstances, (instance: ComponentInstance) => {
return instance.uniqueId === updatedInstance.uniqueId;
});
@@ -593,18 +598,18 @@ export abstract class Component implements IComponent {
deferred.resolve(updatedInstance);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.updateComponentInstance(this.uniqueId, componentInstance).then(onSuccess, onFailed);
return deferred.promise;
};
- public updateMultipleComponentInstances = (instances:Array<ComponentInstance>):ng.IPromise<Array<ComponentInstance>> => {
+ public updateMultipleComponentInstances = (instances: Array<ComponentInstance>): ng.IPromise<Array<ComponentInstance>> => {
let deferred = this.$q.defer<Array<ComponentInstance>>();
- let onSuccess = (updatedInstances:Array<ComponentInstance>):void => {
+ let onSuccess = (updatedInstances: Array<ComponentInstance>): void => {
_.forEach(updatedInstances, (updatedComponentInstance) => {
- let componentInstance:ComponentInstance = _.find(this.componentInstances, (instance:ComponentInstance) => {
+ let componentInstance: ComponentInstance = _.find(this.componentInstances, (instance: ComponentInstance) => {
return instance.uniqueId === updatedComponentInstance.uniqueId;
});
@@ -615,17 +620,17 @@ export abstract class Component implements IComponent {
deferred.resolve(updatedInstances);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.updateMultipleComponentInstances(this.uniqueId, instances).then(onSuccess, onFailed);
return deferred.promise;
};
- public deleteComponentInstance = (componentInstanceId:string):ng.IPromise<ComponentInstance> => {
+ public deleteComponentInstance = (componentInstanceId: string): ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer<ComponentInstance>();
- let onSuccess = ():void => {
- let onSuccess = (component:Component):void => {
+ let onSuccess = (): void => {
+ let onSuccess = (component: Component): void => {
this.componentInstances = CommonUtils.initComponentInstances(component.componentInstances);
this.componentInstancesProperties = new PropertiesGroup(component.componentInstancesProperties);
this.componentInstancesAttributes = new AttributesGroup(component.componentInstancesAttributes);
@@ -635,21 +640,45 @@ export abstract class Component implements IComponent {
};
this.getComponent().then(onSuccess);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.deleteComponentInstance(this.uniqueId, componentInstanceId).then(onSuccess, onFailed);
return deferred.promise;
};
+ public batchDeleteComponentInstance = (componentInstanceIds: Array<string>): ng.IPromise<any> => {
+ let deferred = this.$q.defer();
+ let onSuccess = (res: any): void => {
+ let onSuccess = (component: Component): void => {
+ this.componentInstances = CommonUtils.initComponentInstances(component.componentInstances);
+ this.componentInstancesProperties = new PropertiesGroup(component.componentInstancesProperties);
+ this.componentInstancesAttributes = new AttributesGroup(component.componentInstancesAttributes);
+ this.modules = component.modules;
+ this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(component.componentInstancesRelations);
+ deferred.resolve();
+
+ };
+ this.getComponent().then(onSuccess);
+ deferred.resolve(res);
+ };
+ let onFailed = (error: any): void => {
+ deferred.reject(error);
+ };
+
+ this.componentService.batchDeleteComponentInstance(this.uniqueId, componentInstanceIds).then(onSuccess, onFailed);
+ return deferred.promise;
+
+ };
+
- public syncComponentByRelation(relation:RelationshipModel) {
+ public syncComponentByRelation(relation: RelationshipModel) {
relation.relationships.forEach((rel) => {
if (rel.capability) {
- const toComponentInstance:ComponentInstance = this.componentInstances.find((inst) => inst.uniqueId === relation.toNode);
- const toComponentInstanceCapability:Capability = toComponentInstance.findCapability(
+ const toComponentInstance: ComponentInstance = this.componentInstances.find((inst) => inst.uniqueId === relation.toNode);
+ const toComponentInstanceCapability: Capability = toComponentInstance.findCapability(
rel.capability.type, rel.capability.uniqueId, rel.capability.ownerId, rel.capability.name);
- const isCapabilityFulfilled:boolean = rel.capability.isFulfilled();
+ const isCapabilityFulfilled: boolean = rel.capability.isFulfilled();
if (isCapabilityFulfilled && toComponentInstanceCapability) {
// if capability is fulfilled and in component, then remove it
console.log('Capability is fulfilled', rel.capability.getFullTitle(), rel.capability.leftOccurrences);
@@ -663,10 +692,10 @@ export abstract class Component implements IComponent {
}
}
if (rel.requirement) {
- const fromComponentInstance:ComponentInstance = this.componentInstances.find((inst) => inst.uniqueId === relation.fromNode);
- const fromComponentInstanceRequirement:Requirement = fromComponentInstance.findRequirement(
+ const fromComponentInstance: ComponentInstance = this.componentInstances.find((inst) => inst.uniqueId === relation.fromNode);
+ const fromComponentInstanceRequirement: Requirement = fromComponentInstance.findRequirement(
rel.requirement.capability, rel.requirement.uniqueId, rel.requirement.ownerId, rel.requirement.name);
- const isRequirementFulfilled:boolean = rel.requirement.isFulfilled();
+ const isRequirementFulfilled: boolean = rel.requirement.isFulfilled();
if (isRequirementFulfilled && fromComponentInstanceRequirement) {
// if requirement is fulfilled and in component, then remove it
console.log('Requirement is fulfilled', rel.requirement.getFullTitle(), rel.requirement.leftOccurrences);
@@ -682,22 +711,22 @@ export abstract class Component implements IComponent {
});
}
- public fetchRelation = (linkId:string):ng.IPromise<RelationshipModel> => {
+ public fetchRelation = (linkId: string): ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer<RelationshipModel>();
- let onSuccess = (relation:RelationshipModel):void => {
+ let onSuccess = (relation: RelationshipModel): void => {
this.syncComponentByRelation(relation);
deferred.resolve(relation);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.fetchRelation(this.uniqueId, linkId).then(onSuccess, onFailed);
return deferred.promise;
};
- public createRelation = (relation:RelationshipModel):ng.IPromise<RelationshipModel> => {
+ public createRelation = (relation: RelationshipModel): ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer<RelationshipModel>();
- let onSuccess = (relation:RelationshipModel):void => {
+ let onSuccess = (relation: RelationshipModel): void => {
console.info('Link created successfully', relation);
if (!this.componentInstancesRelations) {
this.componentInstancesRelations = [];
@@ -706,7 +735,7 @@ export abstract class Component implements IComponent {
this.syncComponentByRelation(relation);
deferred.resolve(relation);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
console.info('Failed to create relation', error);
deferred.reject(error);
};
@@ -714,32 +743,35 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public deleteRelation = (relation:RelationshipModel):ng.IPromise<RelationshipModel> => {
- let deferred = this.$q.defer<RelationshipModel>();
- let onSuccess = (relation:RelationshipModel):void => {
- console.log("Link Deleted In Server");
- let relationToDelete = _.find(this.componentInstancesRelations, (item) => {
- return item.fromNode === relation.fromNode && item.toNode === relation.toNode && _.some(item.relationships, (relationship)=> {
- return angular.equals(relation.relationships[0].relation, relationship.relation);
- });
+ private deleteRelationOnSuccess(relation: RelationshipModel) {
+ let relationToDelete = _.find(this.componentInstancesRelations, (item) => {
+ return item.fromNode === relation.fromNode && item.toNode === relation.toNode && _.some(item.relationships, (relationship) => {
+ return angular.equals(relation.relationships[0].relation, relationship.relation);
});
- let index = this.componentInstancesRelations.indexOf(relationToDelete);
- if (relationToDelete != undefined && index > -1) {
- if (relationToDelete.relationships.length == 1) {
- this.componentInstancesRelations.splice(index, 1);
- } else {
- this.componentInstancesRelations[index].relationships =
- _.reject(this.componentInstancesRelations[index].relationships, (relationship) => {
- return angular.equals(relation.relationships[0].relation, relationship.relation);
- });
- }
+ });
+ let index = this.componentInstancesRelations.indexOf(relationToDelete);
+ if (relationToDelete != undefined && index > -1) {
+ if (relationToDelete.relationships.length == 1) {
+ this.componentInstancesRelations.splice(index, 1);
} else {
- console.error("Error while deleting relation - the return delete relation from server was not found in UI")
+ this.componentInstancesRelations[index].relationships =
+ _.reject(this.componentInstancesRelations[index].relationships, (relationship) => {
+ return angular.equals(relation.relationships[0].relation, relationship.relation);
+ });
}
- this.syncComponentByRelation(relation);
+ } else {
+ console.error("Error while deleting relation - the return delete relation from server was not found in UI")
+ }
+ this.syncComponentByRelation(relation);
+ }
+
+ public deleteRelation = (relation: RelationshipModel): ng.IPromise<RelationshipModel> => {
+ let deferred = this.$q.defer<RelationshipModel>();
+ let onSuccess = (relation: RelationshipModel): void => {
+ this.deleteRelationOnSuccess(relation);
deferred.resolve(relation);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
console.error("Failed To Delete Link");
deferred.reject(error);
};
@@ -747,20 +779,38 @@ export abstract class Component implements IComponent {
return deferred.promise;
};
- public getRelationRequirementCapability(relationship: Relationship, sourceNode:ComponentInstance, targetNode:ComponentInstance): Promise<{requirement:Requirement, capability:Capability}> {
+ public batchDeleteRelation = (relations: Array<RelationshipModel>): ng.IPromise<Array<RelationshipModel>> => {
+ let deferred = this.$q.defer<Array<RelationshipModel>>();
+ let onSuccess = (responseRelations: Array<RelationshipModel>): void => {
+ console.log("Link Batch Deleted In Server");
+ let len = responseRelations.length;
+ for (let i = 0; i < len; i++) {
+ this.deleteRelationOnSuccess(responseRelations[i]);
+ }
+ deferred.resolve(responseRelations);
+ };
+ let onFailed = (error: any): void => {
+ console.error("Failed to batch Delete Link");
+ deferred.reject(error);
+ };
+ this.componentService.batchDeleteRelation(this.uniqueId, relations).then(onSuccess, onFailed);
+ return deferred.promise;
+ };
+
+ public getRelationRequirementCapability(relationship: Relationship, sourceNode: ComponentInstance, targetNode: ComponentInstance): Promise<{ requirement: Requirement, capability: Capability }> {
// try find the requirement and capability in the source and target component instances:
- let capability:Capability = targetNode.findCapability(undefined,
+ let capability: Capability = targetNode.findCapability(undefined,
relationship.relation.capabilityUid,
relationship.relation.capabilityOwnerId,
relationship.relation.capability);
- let requirement:Requirement = sourceNode.findRequirement(undefined,
+ let requirement: Requirement = sourceNode.findRequirement(undefined,
relationship.relation.requirementUid,
relationship.relation.requirementOwnerId,
relationship.relation.requirement);
- return new Promise<{requirement:Requirement, capability:Capability}>((resolve, reject) => {
+ return new Promise<{ requirement: Requirement, capability: Capability }>((resolve, reject) => {
if (capability && requirement) {
- resolve({capability, requirement});
+ resolve({ capability, requirement });
}
else {
// if requirement and/or capability is missing, then fetch the full relation with its requirement and capability:
@@ -774,40 +824,40 @@ export abstract class Component implements IComponent {
});
}
- public updateRequirementsCapabilities = ():ng.IPromise<any> => {
+ public updateRequirementsCapabilities = (): ng.IPromise<any> => {
let deferred = this.$q.defer();
- let onSuccess = (response:any):void => {
+ let onSuccess = (response: any): void => {
this.capabilities = new CapabilitiesGroup(response.capabilities);
this.requirements = new RequirementsGroup(response.requirements);
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getRequirementsCapabilities(this.uniqueId).then(onSuccess, onFailed);
return deferred.promise;
};
- public getModuleForDisplay = (moduleId:string):ng.IPromise<DisplayModule> => {
+ public getModuleForDisplay = (moduleId: string): ng.IPromise<DisplayModule> => {
let deferred = this.$q.defer<DisplayModule>();
- let onSuccess = (response:DisplayModule):void => {
+ let onSuccess = (response: DisplayModule): void => {
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getModuleForDisplay(this.uniqueId, moduleId).then(onSuccess, onFailed);
return deferred.promise;
};
- public getModuleInstanceForDisplay = (componentInstanceId:string, moduleId:string):ng.IPromise<DisplayModule> => {
+ public getModuleInstanceForDisplay = (componentInstanceId: string, moduleId: string): ng.IPromise<DisplayModule> => {
let deferred = this.$q.defer<DisplayModule>();
- let onSuccess = (response:DisplayModule):void => {
+ let onSuccess = (response: DisplayModule): void => {
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getComponentInstanceModule(this.uniqueId, componentInstanceId, moduleId).then(onSuccess, onFailed);
@@ -817,13 +867,13 @@ export abstract class Component implements IComponent {
// this function get all instances filtered by inputs and properties (optional) - if no search string insert - this function will
// get all the instances of the component (in service only VF instances)
- public getComponentInstancesFilteredByInputsAndProperties = (searchText?:string):ng.IPromise<Array<ComponentInstance>> => {
+ public getComponentInstancesFilteredByInputsAndProperties = (searchText?: string): ng.IPromise<Array<ComponentInstance>> => {
let deferred = this.$q.defer<Array<ComponentInstance>>();
- let onSuccess = (response:Array<ComponentInstance>):void => {
+ let onSuccess = (response: Array<ComponentInstance>): void => {
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getComponentInstancesFilteredByInputsAndProperties(this.uniqueId, searchText).then(onSuccess, onFailed);
@@ -832,14 +882,14 @@ export abstract class Component implements IComponent {
// get inputs for instance - Pagination function
- public getComponentInputs = ():ng.IPromise<Array<InputModel>> => {
+ public getComponentInputs = (): ng.IPromise<Array<InputModel>> => {
let deferred = this.$q.defer<Array<InputModel>>();
- let onSuccess = (inputsRes:Array<InputModel>):void => {
+ let onSuccess = (inputsRes: Array<InputModel>): void => {
this.inputs = inputsRes;
deferred.resolve(inputsRes);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getComponentInputs(this.uniqueId).then(onSuccess, onFailed);
@@ -848,13 +898,13 @@ export abstract class Component implements IComponent {
// get inputs instance - Pagination function
- public getComponentInstanceInputs = (componentInstanceId:string, originComponentUid:string):ng.IPromise<Array<InputModel>> => {
+ public getComponentInstanceInputs = (componentInstanceId: string, originComponentUid: string): ng.IPromise<Array<InputModel>> => {
let deferred = this.$q.defer<Array<InputModel>>();
- let onSuccess = (response:Array<InputModel>):void => {
+ let onSuccess = (response: Array<InputModel>): void => {
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getComponentInstanceInputs(this.uniqueId, componentInstanceId, originComponentUid).then(onSuccess, onFailed);
@@ -862,13 +912,13 @@ export abstract class Component implements IComponent {
};
// get inputs inatnce - Pagination function
- public getComponentInstanceInputProperties = (componentInstanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>> => {
+ public getComponentInstanceInputProperties = (componentInstanceId: string, inputId: string): ng.IPromise<Array<PropertyModel>> => {
let deferred = this.$q.defer<Array<PropertyModel>>();
- let onSuccess = (response:Array<PropertyModel>):void => {
+ let onSuccess = (response: Array<PropertyModel>): void => {
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getComponentInstanceInputProperties(this.uniqueId, componentInstanceId, inputId).then(onSuccess, onFailed);
@@ -876,13 +926,13 @@ export abstract class Component implements IComponent {
};
// get inputs inatnce - Pagination function
- public getComponentInstanceProperties = (componentInstanceId:string):ng.IPromise<Array<PropertyModel>> => {
+ public getComponentInstanceProperties = (componentInstanceId: string): ng.IPromise<Array<PropertyModel>> => {
let deferred = this.$q.defer<Array<PropertyModel>>();
- let onSuccess = (response:Array<PropertyModel>):void => {
+ let onSuccess = (response: Array<PropertyModel>): void => {
deferred.resolve(response);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
this.componentService.getComponentInstanceProperties(this.uniqueId, componentInstanceId).then(onSuccess, onFailed);
@@ -890,12 +940,12 @@ export abstract class Component implements IComponent {
};
- public updateGroupMetadata = (module:Module):ng.IPromise<Module> => {
+ public updateGroupMetadata = (module: Module): ng.IPromise<Module> => {
let deferred = this.$q.defer<Module>();
- let onSuccess = (updatedModule:Module):void => {
- let groupIndex:number = _.indexOf(this.modules, _.find(this.modules, (module:Module) => {
+ let onSuccess = (updatedModule: Module): void => {
+ let groupIndex: number = _.indexOf(this.modules, _.find(this.modules, (module: Module) => {
return module.uniqueId === updatedModule.uniqueId;
}));
@@ -904,7 +954,7 @@ export abstract class Component implements IComponent {
}
deferred.resolve(updatedModule);
};
- let onFailed = (error:any):void => {
+ let onFailed = (error: any): void => {
deferred.reject(error);
};
@@ -915,28 +965,28 @@ export abstract class Component implements IComponent {
//------------------------------------------ Help Functions ----------------------------------------------------------------//
- public isService = ():boolean => {
+ public isService = (): boolean => {
return this instanceof Service;
};
- public isResource = ():boolean => {
+ public isResource = (): boolean => {
return this instanceof Resource;
};
- public getComponentSubType = ():string => {
+ public getComponentSubType = (): string => {
return this.componentType;
};
- public isAlreadyCertified = ():boolean => {
+ public isAlreadyCertified = (): boolean => {
return parseInt(this.version) >= 1;
};
- public isComplex = ():boolean => {
+ public isComplex = (): boolean => {
return true;
};
//sort string version value from hash to sorted version (i.e 1.9 before 1.11)
- private sortVersions = (v1:string, v2:string):number => {
+ private sortVersions = (v1: string, v2: string): number => {
let ver1 = v1.split('.');
let ver2 = v2.split('.');
let diff = parseInt(_.first(ver1)) - parseInt(_.first(ver2));
@@ -946,11 +996,11 @@ export abstract class Component implements IComponent {
return diff;
};
- public getAllVersionsAsSortedArray = ():Array<any> => {
+ public getAllVersionsAsSortedArray = (): Array<any> => {
let res = [];
if (this.allVersions) {
let keys = Object.keys(this.allVersions).sort(this.sortVersions);
- _.forEach(keys, (key)=> {
+ _.forEach(keys, (key) => {
res.push({
versionNumber: key,
versionId: this.allVersions[key]
@@ -960,7 +1010,7 @@ export abstract class Component implements IComponent {
return res;
};
- public isLatestVersion = ():boolean => {
+ public isLatestVersion = (): boolean => {
if (this.allVersions) {
return this.version === _.last(Object.keys(this.allVersions).sort(this.sortVersions));
} else {
@@ -969,8 +1019,8 @@ export abstract class Component implements IComponent {
};
- public getAdditionalInformation = ():Array<AdditionalInformationModel> => {
- let additionalInformationObject:any = _.find(this.additionalInformation, (obj:any):boolean => {
+ public getAdditionalInformation = (): Array<AdditionalInformationModel> => {
+ let additionalInformationObject: any = _.find(this.additionalInformation, (obj: any): boolean => {
return obj.parentUniqueId == this.uniqueId;
});
if (additionalInformationObject) {
@@ -979,8 +1029,8 @@ export abstract class Component implements IComponent {
return [];
};
- public handleTags = ():void => {
- let isContainTag = _.find(this.tags, (tag)=> {
+ public handleTags = (): void => {
+ let isContainTag = _.find(this.tags, (tag) => {
return tag === this.name;
});
if (!isContainTag) {
@@ -988,7 +1038,7 @@ export abstract class Component implements IComponent {
}
};
- public getArtifactsByType = (artifactGroupType:string):ArtifactGroupModel => {
+ public getArtifactsByType = (artifactGroupType: string): ArtifactGroupModel => {
switch (artifactGroupType) {
case ArtifactGroupType.DEPLOYMENT:
return this.deploymentArtifacts;
@@ -997,16 +1047,28 @@ export abstract class Component implements IComponent {
}
};
- public getStatus = (sdcMenu:IAppMenu):string => {
- let status:string = sdcMenu.LifeCycleStatuses[this.lifecycleState].text;
+ public getStatus = (sdcMenu: IAppMenu): string => {
+ let status: string = sdcMenu.LifeCycleStatuses[this.lifecycleState].text;
if (this.lifecycleState == "CERTIFIED" && sdcMenu.DistributionStatuses[this.distributionStatus]) {
status = sdcMenu.DistributionStatuses[this.distributionStatus].text;
}
return status;
};
- public abstract setComponentDisplayData():void;
- public abstract getTypeUrl():string;
+ public pasteMenuComponentInstance = (srcComponentId: string, msg: string): ng.IPromise<string> => {
+ let deferred = this.$q.defer<string>();
+ let onSuccess = (response): void => {
+ deferred.resolve(response);
+ };
+ let onFailed = (error: any): void => {
+ deferred.reject(error);
+ };
+ this.componentService.pasteMenuComponentInstance(this.uniqueId, srcComponentId, msg).then(onSuccess, onFailed);
+ return deferred.promise;
+
+ };
+ public abstract setComponentDisplayData(): void;
+ public abstract getTypeUrl(): string;
public setComponentMetadata(componentMetadata: ComponentMetadata) {
this.abstract = componentMetadata.abstract;
@@ -1042,7 +1104,7 @@ export abstract class Component implements IComponent {
this.vspArchived = componentMetadata.vspArchived;
}
- public toJSON = ():any => {
+ public toJSON = (): any => {
let temp = angular.copy(this);
temp.componentService = undefined;
temp.filterTerm = undefined;
diff --git a/catalog-ui/src/app/services/components/component-service.ts b/catalog-ui/src/app/services/components/component-service.ts
index 25203e7732..0d4b5bb83e 100644
--- a/catalog-ui/src/app/services/components/component-service.ts
+++ b/catalog-ui/src/app/services/components/component-service.ts
@@ -19,59 +19,65 @@
*/
'use strict';
import * as _ from "lodash";
-import {ArtifactModel, IFileDownload, InstancesInputsPropertiesMap, InputModel, IValidate, RelationshipModel, PropertyModel, Component, ComponentInstance,
- AttributeModel, IAppConfigurtaion, Resource, Module, DisplayModule, ArtifactGroupModel, InputsAndProperties} from "app/models";
-import {ComponentInstanceFactory, CommonUtils} from "app/utils";
-import {SharingService} from "../sharing-service";
-import {ComponentMetadata} from "../../models/component-metadata";
+import {
+ ArtifactModel, IFileDownload, InstancesInputsPropertiesMap, InputModel, IValidate, RelationshipModel, PropertyModel, Component, ComponentInstance,
+ AttributeModel, IAppConfigurtaion, Resource, Module, DisplayModule, ArtifactGroupModel, InputsAndProperties
+} from "app/models";
+import { ComponentInstanceFactory, CommonUtils } from "app/utils";
+import { SharingService } from "../sharing-service";
+import { ComponentMetadata } from "../../models/component-metadata";
export interface IComponentService {
- getComponent(id:string);
- updateComponent(component:Component):ng.IPromise<Component>;
- changeLifecycleState(component:Component, state:string, userRemarks:any):ng.IPromise<ComponentMetadata> ;
- validateName(newName:string, subtype?:string):ng.IPromise<IValidate>;
- createComponent(component:Component):ng.IPromise<Component>;
- addOrUpdateArtifact(componentId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
- deleteArtifact(componentId:string, artifact:string, artifactLabel):ng.IPromise<ArtifactModel>;
- addProperty(componentId:string, property:PropertyModel):ng.IPromise<PropertyModel>;
- updateProperty(componentId:string, property:PropertyModel):ng.IPromise<PropertyModel>;
- addAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>;
- updateAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>;
- deleteProperty(componentId:string, propertyId:string):ng.IPromise<PropertyModel>;
- deleteAttribute(componentId:string, attributeId:string):ng.IPromise<AttributeModel>;
- checkResourceInstanceVersionChange(componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<any>;
- changeResourceInstanceVersion(componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<ComponentInstance>;
- updateInstanceArtifact(componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
- addInstanceArtifact(componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
- deleteInstanceArtifact(componentId:string, instanceId:string, artifact:string, artifactLabel):ng.IPromise<ArtifactModel>;
- createComponentInstance(componentId:string, componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>;
- updateComponentInstance(componentId:string, componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>;
- updateMultipleComponentInstances(componentId:string, instances:Array<ComponentInstance>):ng.IPromise< Array<ComponentInstance>>;
- downloadArtifact(componentId:string, artifactId:string):ng.IPromise<IFileDownload>;
- uploadInstanceEnvFile(componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>;
- downloadInstanceArtifact(componentId:string, instanceId:string, artifactId:string):ng.IPromise<IFileDownload>;
- deleteComponentInstance(componentId:string, componentInstanceId:string):ng.IPromise<ComponentInstance>;
- createRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>;
- deleteRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>;
- fetchRelation(componentId:string, linkId:string):ng.IPromise<RelationshipModel>;
- getRequirementsCapabilities(componentId:string):ng.IPromise<any>;
- updateInstanceProperties(componentId:string, componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]>;
- updateInstanceAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>;
- getComponentInstancesFilteredByInputsAndProperties(componentId:string, searchText:string):ng.IPromise<Array<ComponentInstance>>
- getComponentInstanceInputs(componentId:string, instanceId:string, originComponentUid):ng.IPromise<Array<InputModel>>;
- getComponentInputs(componentId:string):ng.IPromise<Array<InputModel>>;
- getComponentInstanceInputProperties(componentId:string, instanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>>;
- getComponentInstanceProperties(componentId:string, instanceId:string):ng.IPromise<Array<PropertyModel>>;
- getModuleForDisplay(componentId:string, moduleId:string):ng.IPromise<DisplayModule>;
- getComponentInstanceModule(componentId:string, componentInstanceId:string, moduleId:string):ng.IPromise<DisplayModule>;
- updateGroupMetadata(componentId:string, group:Module):ng.IPromise<Module>;
- getComponentInputInputsAndProperties(serviceId:string, input:string):ng.IPromise<InputsAndProperties>;
- createInputsFromInstancesInputs(serviceId:string, instancesInputsMap:InstancesInputsPropertiesMap):ng.IPromise<Array<InputModel>>;
- createInputsFromInstancesInputsProperties(resourceId:string, instanceInputsPropertiesMap:InstancesInputsPropertiesMap):ng.IPromise<Array<PropertyModel>>;
- deleteComponentInput(serviceId:string, inputId:string):ng.IPromise<InputModel>;
- getArtifactByGroupType(componentId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel>;
- getComponentInstanceArtifactsByGroupType(componentId:string, componentInstanceId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel>;
+ getComponent(id: string);
+ updateComponent(component: Component): ng.IPromise<Component>;
+ changeLifecycleState(component: Component, state: string, userRemarks: any): ng.IPromise<ComponentMetadata>;
+ validateName(newName: string, subtype?: string): ng.IPromise<IValidate>;
+ createComponent(component: Component): ng.IPromise<Component>;
+ addOrUpdateArtifact(componentId: string, artifact: ArtifactModel): ng.IPromise<ArtifactModel>;
+ deleteArtifact(componentId: string, artifact: string, artifactLabel): ng.IPromise<ArtifactModel>;
+ addProperty(componentId: string, property: PropertyModel): ng.IPromise<PropertyModel>;
+ updateProperty(componentId: string, property: PropertyModel): ng.IPromise<PropertyModel>;
+ addAttribute(componentId: string, attribute: AttributeModel): ng.IPromise<AttributeModel>;
+ updateAttribute(componentId: string, attribute: AttributeModel): ng.IPromise<AttributeModel>;
+ deleteProperty(componentId: string, propertyId: string): ng.IPromise<PropertyModel>;
+ deleteAttribute(componentId: string, attributeId: string): ng.IPromise<AttributeModel>;
+ checkResourceInstanceVersionChange(componentId: string, componentInstanceId: string, componentUid: string): ng.IPromise<any>;
+ changeResourceInstanceVersion(componentId: string, componentInstanceId: string, componentUid: string): ng.IPromise<ComponentInstance>;
+ updateInstanceArtifact(componentId: string, instanceId: string, artifact: ArtifactModel): ng.IPromise<ArtifactModel>;
+ addInstanceArtifact(componentId: string, instanceId: string, artifact: ArtifactModel): ng.IPromise<ArtifactModel>;
+ deleteInstanceArtifact(componentId: string, instanceId: string, artifact: string, artifactLabel): ng.IPromise<ArtifactModel>;
+ createComponentInstance(componentId: string, componentInstance: ComponentInstance): ng.IPromise<ComponentInstance>;
+ updateComponentInstance(componentId: string, componentInstance: ComponentInstance): ng.IPromise<ComponentInstance>;
+ updateMultipleComponentInstances(componentId: string, instances: Array<ComponentInstance>): ng.IPromise<Array<ComponentInstance>>;
+ downloadArtifact(componentId: string, artifactId: string): ng.IPromise<IFileDownload>;
+ uploadInstanceEnvFile(componentId: string, instanceId: string, artifact: ArtifactModel): ng.IPromise<ArtifactModel>;
+ downloadInstanceArtifact(componentId: string, instanceId: string, artifactId: string): ng.IPromise<IFileDownload>;
+ deleteComponentInstance(componentId: string, componentInstanceId: string): ng.IPromise<ComponentInstance>;
+ createRelation(componentId: string, link: RelationshipModel): ng.IPromise<RelationshipModel>;
+ deleteRelation(componentId: string, link: RelationshipModel): ng.IPromise<RelationshipModel>;
+ fetchRelation(componentId: string, linkId: string): ng.IPromise<RelationshipModel>;
+ getRequirementsCapabilities(componentId: string): ng.IPromise<any>;
+ updateInstanceProperties(componentId: string, componentInstanceId: string, properties: PropertyModel[]): ng.IPromise<PropertyModel[]>;
+ updateInstanceAttribute(componentId: string, attribute: AttributeModel): ng.IPromise<AttributeModel>;
+ getComponentInstancesFilteredByInputsAndProperties(componentId: string, searchText: string): ng.IPromise<Array<ComponentInstance>>
+ getComponentInstanceInputs(componentId: string, instanceId: string, originComponentUid): ng.IPromise<Array<InputModel>>;
+ getComponentInputs(componentId: string): ng.IPromise<Array<InputModel>>;
+ getComponentInstanceInputProperties(componentId: string, instanceId: string, inputId: string): ng.IPromise<Array<PropertyModel>>;
+ getComponentInstanceProperties(componentId: string, instanceId: string): ng.IPromise<Array<PropertyModel>>;
+ getModuleForDisplay(componentId: string, moduleId: string): ng.IPromise<DisplayModule>;
+ getComponentInstanceModule(componentId: string, componentInstanceId: string, moduleId: string): ng.IPromise<DisplayModule>;
+ updateGroupMetadata(componentId: string, group: Module): ng.IPromise<Module>;
+ getComponentInputInputsAndProperties(serviceId: string, input: string): ng.IPromise<InputsAndProperties>;
+ createInputsFromInstancesInputs(serviceId: string, instancesInputsMap: InstancesInputsPropertiesMap): ng.IPromise<Array<InputModel>>;
+ createInputsFromInstancesInputsProperties(resourceId: string, instanceInputsPropertiesMap: InstancesInputsPropertiesMap): ng.IPromise<Array<PropertyModel>>;
+ deleteComponentInput(serviceId: string, inputId: string): ng.IPromise<InputModel>;
+ getArtifactByGroupType(componentId: string, artifactGroupType: string): ng.IPromise<ArtifactGroupModel>;
+ getComponentInstanceArtifactsByGroupType(componentId: string, componentInstanceId: string, artifactGroupType: string): ng.IPromise<ArtifactGroupModel>;
+ batchDeleteComponentInstance(componentId: string, componentInstanceIdList: Array<string>): ng.IPromise<any>;
+ pasteMenuComponentInstance(componentId: string, srcComponentId: string, msg: string): ng.IPromise<string>;
+ batchDeleteRelation(componentId: string, links: Array<RelationshipModel>): ng.IPromise<Array<RelationshipModel>>
+
}
export class ComponentService implements IComponentService {
@@ -84,12 +90,12 @@ export class ComponentService implements IComponentService {
'$base64'
];
- constructor(protected restangular:restangular.IElement,
- protected sdcConfig:IAppConfigurtaion,
- protected sharingService:SharingService,
- protected $q:ng.IQService,
- protected $base64:any
- ) {
+ constructor(protected restangular: restangular.IElement,
+ protected sdcConfig: IAppConfigurtaion,
+ protected sharingService: SharingService,
+ protected $q: ng.IQService,
+ protected $base64: any
+ ) {
this.restangular.setBaseUrl(sdcConfig.api.root + sdcConfig.api.component_api_root);
this.restangular.setRequestInterceptor(function (elem, operation) {
@@ -102,27 +108,27 @@ export class ComponentService implements IComponentService {
}
//this function is override by each service, we need to change this method to abstract when updtaing typescript version
- protected createComponentObject = (component:Component):Component => {
+ protected createComponentObject = (component: Component): Component => {
return component;
};
- public getComponent = (id:string):ng.IPromise<Component> => {
+ public getComponent = (id: string): ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
- this.restangular.one(id).get().then((response:Component) => {
- let component:Component = this.createComponentObject(response);
+ this.restangular.one(id).get().then((response: Component) => {
+ let component: Component = this.createComponentObject(response);
//console.log("Component Loaded successfully : ", component);
deferred.resolve(component);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to load component with ID: " + id);
deferred.reject(err);
});
return deferred.promise;
};
- public updateComponent = (component:Component):ng.IPromise<Component> => {
+ public updateComponent = (component: Component): ng.IPromise<Component> => {
// If this is resource
if (component instanceof Resource) {
- let resource:Resource = <Resource>component;
+ let resource: Resource = <Resource>component;
if (resource.importedFile) {
// Update resource with payload data.
return this.updateResourceWithPayload(resource);
@@ -140,34 +146,34 @@ export class ComponentService implements IComponentService {
}
};
- private updateService = (component:Component):ng.IPromise<Component> => {
+ private updateService = (component: Component): ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
- this.restangular.one(component.uniqueId).one("metadata").customPUT(JSON.stringify(component)).then((response:Component) => {
- let component:Component = this.createComponentObject(response);
+ this.restangular.one(component.uniqueId).one("metadata").customPUT(JSON.stringify(component)).then((response: Component) => {
+ let component: Component = this.createComponentObject(response);
deferred.resolve(component);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- private updateResource = (component:Component):ng.IPromise<Component> => {
+ private updateResource = (component: Component): ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
- this.restangular.one(component.uniqueId).customPUT(JSON.stringify(component)).then((response:Component) => {
- let component:Component = this.createComponentObject(response);
+ this.restangular.one(component.uniqueId).customPUT(JSON.stringify(component)).then((response: Component) => {
+ let component: Component = this.createComponentObject(response);
deferred.resolve(component);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- private updateResourceMetadata = (component:Component):ng.IPromise<Component> => {
+ private updateResourceMetadata = (component: Component): ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
- this.restangular.one(component.uniqueId).one('metadata').customPUT(JSON.stringify(component)).then((response:Component) => {
- let component:Component = this.createComponentObject(response);
+ this.restangular.one(component.uniqueId).one('metadata').customPUT(JSON.stringify(component)).then((response: Component) => {
+ let component: Component = this.createComponentObject(response);
deferred.resolve(component);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
@@ -178,109 +184,109 @@ export class ComponentService implements IComponentService {
* @param component
* @returns {IPromise<T>}
*/
- private updateResourceWithPayload = (resource:Resource):ng.IPromise<Component> => {
+ private updateResourceWithPayload = (resource: Resource): ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
resource.payloadData = resource.importedFile.base64;
resource.payloadName = resource.importedFile.filename;
let headerObj = this.getHeaderMd5(resource);
- this.restangular.one(resource.uniqueId).customPUT(JSON.stringify(resource), '', {}, headerObj).then((response:Component) => {
- let componentResult:Component = this.createComponentObject(response);
+ this.restangular.one(resource.uniqueId).customPUT(JSON.stringify(resource), '', {}, headerObj).then((response: Component) => {
+ let componentResult: Component = this.createComponentObject(response);
deferred.resolve(componentResult);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public createComponent = (component:Component):ng.IPromise<Component> => {
+ public createComponent = (component: Component): ng.IPromise<Component> => {
let deferred = this.$q.defer<Component>();
let headerObj = this.getHeaderMd5(component);
- this.restangular.customPOST(JSON.stringify(component), '', {}, headerObj).then((response:Component) => {
- let component:Component = this.createComponentObject(response);
+ this.restangular.customPOST(JSON.stringify(component), '', {}, headerObj).then((response: Component) => {
+ let component: Component = this.createComponentObject(response);
deferred.resolve(component);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public validateName = (newName:string, subtype?:string):ng.IPromise<IValidate> => {
+ public validateName = (newName: string, subtype?: string): ng.IPromise<IValidate> => {
let deferred = this.$q.defer<IValidate>();
- this.restangular.one("validate-name").one(newName).get({'subtype': subtype}).then((response:any) => {
+ this.restangular.one("validate-name").one(newName).get({ 'subtype': subtype }).then((response: any) => {
deferred.resolve(response.plain());
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public changeLifecycleState = (component:Component, state:string, userRemarks:any):ng.IPromise<ComponentMetadata> => {
+ public changeLifecycleState = (component: Component, state: string, userRemarks: any): ng.IPromise<ComponentMetadata> => {
let deferred = this.$q.defer<ComponentMetadata>();
- this.restangular.one(component.uniqueId).one(state).customPOST(userRemarks).then((response:ComponentMetadata) => {
+ this.restangular.one(component.uniqueId).one(state).customPOST(userRemarks).then((response: ComponentMetadata) => {
this.sharingService.addUuidValue(response.uniqueId, response.uuid);
- let component:ComponentMetadata = new ComponentMetadata().deserialize(response);
+ let component: ComponentMetadata = new ComponentMetadata().deserialize(response);
deferred.resolve(component);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
// ------------------------------------------------ Artifacts API --------------------------------------------------//
- public addOrUpdateArtifact = (componentId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
+ public addOrUpdateArtifact = (componentId: string, artifact: ArtifactModel): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
let headerObj = {};
if (artifact.payloadData) {
headerObj = this.getHeaderMd5(artifact);
}
- this.restangular.one(componentId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => {
+ this.restangular.one(componentId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response: any) => {
deferred.resolve(response.plain());
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public downloadArtifact = (componentId:string, artifactId:string):ng.IPromise<IFileDownload> => {
+ public downloadArtifact = (componentId: string, artifactId: string): ng.IPromise<IFileDownload> => {
let deferred = this.$q.defer<IFileDownload>();
- this.restangular.one(componentId).one("artifacts").one(artifactId).get().then((response:any) => {
+ this.restangular.one(componentId).one("artifacts").one(artifactId).get().then((response: any) => {
deferred.resolve(response.plain());
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public deleteArtifact = (componentId:string, artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => {
+ public deleteArtifact = (componentId: string, artifactId: string, artifactLabel: string): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
- this.restangular.one(componentId).one("artifacts").one(artifactId).remove({'operation': artifactLabel}).then((response:ArtifactModel) => {
+ this.restangular.one(componentId).one("artifacts").one(artifactId).remove({ 'operation': artifactLabel }).then((response: ArtifactModel) => {
deferred.resolve(response);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public getArtifactByGroupType = (componentId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => {
+ public getArtifactByGroupType = (componentId: string, artifactGroupType: string): ng.IPromise<ArtifactGroupModel> => {
let deferred = this.$q.defer<ArtifactGroupModel>();
- this.restangular.one(componentId).one("artifactsByType").one(artifactGroupType).get().then((response:any) => {
- var artifacts:ArtifactGroupModel = new ArtifactGroupModel(response.plain());
+ this.restangular.one(componentId).one("artifactsByType").one(artifactGroupType).get().then((response: any) => {
+ var artifacts: ArtifactGroupModel = new ArtifactGroupModel(response.plain());
deferred.resolve(artifacts);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public getComponentInstanceArtifactsByGroupType = (componentId:string, componentInstanceId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => {
+ public getComponentInstanceArtifactsByGroupType = (componentId: string, componentInstanceId: string, artifactGroupType: string): ng.IPromise<ArtifactGroupModel> => {
let deferred = this.$q.defer<ArtifactGroupModel>();
- this.restangular.one(componentId).one("resourceInstances").one(componentInstanceId).one("artifactsByType").one(artifactGroupType).get().then((response:any) => {
- var artifacts:ArtifactGroupModel = new ArtifactGroupModel(response.plain());
+ this.restangular.one(componentId).one("resourceInstances").one(componentInstanceId).one("artifactsByType").one(artifactGroupType).get().then((response: any) => {
+ var artifacts: ArtifactGroupModel = new ArtifactGroupModel(response.plain());
deferred.resolve(artifacts);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
@@ -288,66 +294,66 @@ export class ComponentService implements IComponentService {
// ------------------------------------------------ Properties API --------------------------------------------------//
- public addProperty = (componentId:string, property:PropertyModel):ng.IPromise<PropertyModel> => {
+ public addProperty = (componentId: string, property: PropertyModel): ng.IPromise<PropertyModel> => {
let deferred = this.$q.defer<PropertyModel>();
- this.restangular.one(componentId).one("properties").customPOST(property.convertToServerObject()).then((response:any) => {
- let property:PropertyModel = new PropertyModel(response[Object.keys(response)[0]]);
+ this.restangular.one(componentId).one("properties").customPOST(property.convertToServerObject()).then((response: any) => {
+ let property: PropertyModel = new PropertyModel(response[Object.keys(response)[0]]);
deferred.resolve(property);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public updateProperty = (componentId:string, property:PropertyModel):ng.IPromise<PropertyModel> => {
+ public updateProperty = (componentId: string, property: PropertyModel): ng.IPromise<PropertyModel> => {
let deferred = this.$q.defer<PropertyModel>();
- this.restangular.one(componentId).one("properties").one(property.uniqueId).customPUT(property.convertToServerObject()).then((response:any) => {
- let property:PropertyModel = new PropertyModel(response[Object.keys(response)[0]]);
+ this.restangular.one(componentId).one("properties").one(property.uniqueId).customPUT(property.convertToServerObject()).then((response: any) => {
+ let property: PropertyModel = new PropertyModel(response[Object.keys(response)[0]]);
deferred.resolve(property);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public deleteProperty = (componentId:string, propertyId:string):ng.IPromise<PropertyModel> => {
+ public deleteProperty = (componentId: string, propertyId: string): ng.IPromise<PropertyModel> => {
let deferred = this.$q.defer<PropertyModel>();
- this.restangular.one(componentId).one("properties").one(propertyId).remove().then((response:any) => {
+ this.restangular.one(componentId).one("properties").one(propertyId).remove().then((response: any) => {
deferred.resolve(response);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
// ------------------------------------------------ Attributes API --------------------------------------------------//
- public addAttribute = (componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel> => {
+ public addAttribute = (componentId: string, attribute: AttributeModel): ng.IPromise<AttributeModel> => {
let deferred = this.$q.defer<AttributeModel>();
- this.restangular.one(componentId).one("attributes").customPOST(attribute.convertToServerObject()).then((response:any) => {
- let attribute:AttributeModel = new AttributeModel(response);
+ this.restangular.one(componentId).one("attributes").customPOST(attribute.convertToServerObject()).then((response: any) => {
+ let attribute: AttributeModel = new AttributeModel(response);
deferred.resolve(attribute);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public updateAttribute = (componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel> => {
+ public updateAttribute = (componentId: string, attribute: AttributeModel): ng.IPromise<AttributeModel> => {
let deferred = this.$q.defer<AttributeModel>();
- this.restangular.one(componentId).one("attributes").one(attribute.uniqueId).customPUT(attribute.convertToServerObject()).then((response:any) => {
- let attribute:AttributeModel = new AttributeModel(response);
+ this.restangular.one(componentId).one("attributes").one(attribute.uniqueId).customPUT(attribute.convertToServerObject()).then((response: any) => {
+ let attribute: AttributeModel = new AttributeModel(response);
deferred.resolve(attribute);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public deleteAttribute = (componentId:string, attributeId:string):ng.IPromise<AttributeModel> => {
+ public deleteAttribute = (componentId: string, attributeId: string): ng.IPromise<AttributeModel> => {
let deferred = this.$q.defer<AttributeModel>();
- this.restangular.one(componentId).one("attributes").one(attributeId).remove().then((response:any) => {
+ this.restangular.one(componentId).one("attributes").one(attributeId).remove().then((response: any) => {
deferred.resolve(response);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
@@ -355,64 +361,64 @@ export class ComponentService implements IComponentService {
// ------------------------------------------------ Component Instances API --------------------------------------------------//
- public createComponentInstance = (componentId:string, componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => {
+ public createComponentInstance = (componentId: string, componentInstance: ComponentInstance): ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer<ComponentInstance>();
- this.restangular.one(componentId).one("resourceInstance").customPOST(JSON.stringify(componentInstance)).then((response:any) => {
- let componentInstance:ComponentInstance = ComponentInstanceFactory.createComponentInstance(response);
+ this.restangular.one(componentId).one("resourceInstance").customPOST(JSON.stringify(componentInstance)).then((response: any) => {
+ let componentInstance: ComponentInstance = ComponentInstanceFactory.createComponentInstance(response);
console.log("Component Instance created", componentInstance);
deferred.resolve(componentInstance);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to create componentInstance. With Name: " + componentInstance.name);
deferred.reject(err);
});
return deferred.promise;
};
- public updateComponentInstance = (componentId:string, componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => {
+ public updateComponentInstance = (componentId: string, componentInstance: ComponentInstance): ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer<ComponentInstance>();
- this.restangular.one(componentId).one("resourceInstance").one(componentInstance.uniqueId).customPOST(JSON.stringify(componentInstance)).then((response:any) => {
- let componentInstance:ComponentInstance = ComponentInstanceFactory.createComponentInstance(response);
+ this.restangular.one(componentId).one("resourceInstance").one(componentInstance.uniqueId).customPOST(JSON.stringify(componentInstance)).then((response: any) => {
+ let componentInstance: ComponentInstance = ComponentInstanceFactory.createComponentInstance(response);
console.log("Component Instance was updated", componentInstance);
deferred.resolve(componentInstance);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to update componentInstance. With ID: " + componentInstance.uniqueId + "Name: " + componentInstance.name);
deferred.reject(err);
});
return deferred.promise;
};
- public updateMultipleComponentInstances = (componentId:string, instances:Array<ComponentInstance>):ng.IPromise<Array<ComponentInstance>> => {
+ public updateMultipleComponentInstances = (componentId: string, instances: Array<ComponentInstance>): ng.IPromise<Array<ComponentInstance>> => {
let deferred = this.$q.defer<Array<ComponentInstance>>();
- this.restangular.one(componentId).one("resourceInstance/multipleComponentInstance").customPOST(JSON.stringify(instances)).then((response:any) => {
+ this.restangular.one(componentId).one("resourceInstance/multipleComponentInstance").customPOST(JSON.stringify(instances)).then((response: any) => {
console.log("Multiple Component Instances was updated", response);
- let updateInstances:Array<ComponentInstance> = new Array<ComponentInstance>();
- _.forEach(response, (componentInstance:ComponentInstance) => {
- let updatedComponentInstance:ComponentInstance = ComponentInstanceFactory.createComponentInstance(componentInstance);
+ let updateInstances: Array<ComponentInstance> = new Array<ComponentInstance>();
+ _.forEach(response, (componentInstance: ComponentInstance) => {
+ let updatedComponentInstance: ComponentInstance = ComponentInstanceFactory.createComponentInstance(componentInstance);
updateInstances.push(updatedComponentInstance);
});
deferred.resolve(updateInstances);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to update Multiple componentInstance.");
deferred.reject(err);
});
return deferred.promise;
};
- public deleteComponentInstance = (componentId:string, componentInstanceId:string):ng.IPromise<ComponentInstance> => {
+ public deleteComponentInstance = (componentId: string, componentInstanceId: string): ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer<ComponentInstance>();
this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).remove().then(() => {
console.log("Component Instance was deleted");
deferred.resolve();
- }, (err)=> {
+ }, (err) => {
console.log("Failed to delete componentInstance. With ID: " + componentInstanceId);
deferred.reject(err);
});
return deferred.promise;
};
- public checkResourceInstanceVersionChange = (componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<ComponentInstance> => {
+ public checkResourceInstanceVersionChange = (componentId: string, componentInstanceId: string, componentUid: string): ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer<ComponentInstance>();
- this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one(componentUid).one("checkForwardingPathOnVersionChange").get().then((response:any) => {
+ this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one(componentUid).one("checkForwardingPathOnVersionChange").get().then((response: any) => {
deferred.resolve(response);
}, err => {
deferred.reject(err);
@@ -420,85 +426,85 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
- public changeResourceInstanceVersion = (componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<ComponentInstance> => {
+ public changeResourceInstanceVersion = (componentId: string, componentInstanceId: string, componentUid: string): ng.IPromise<ComponentInstance> => {
let deferred = this.$q.defer<ComponentInstance>();
- this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("changeVersion").customPOST({'componentUid': componentUid}).then((response:any) => {
- let componentInstance:ComponentInstance = ComponentInstanceFactory.createComponentInstance(response);
+ this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("changeVersion").customPOST({ 'componentUid': componentUid }).then((response: any) => {
+ let componentInstance: ComponentInstance = ComponentInstanceFactory.createComponentInstance(response);
deferred.resolve(componentInstance);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public downloadInstanceArtifact = (componentId:string, instanceId:string, artifactId:string):ng.IPromise<IFileDownload> => {
+ public downloadInstanceArtifact = (componentId: string, instanceId: string, artifactId: string): ng.IPromise<IFileDownload> => {
let deferred = this.$q.defer<IFileDownload>();
- this.restangular.one(componentId).one("resourceInstances").one(instanceId).one("artifacts").one(artifactId).get().then((response:any) => {
+ this.restangular.one(componentId).one("resourceInstances").one(instanceId).one("artifacts").one(artifactId).get().then((response: any) => {
deferred.resolve(response.plain());
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public updateInstanceArtifact = (componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
+ public updateInstanceArtifact = (componentId: string, instanceId: string, artifact: ArtifactModel): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
let headerObj = {};
if (artifact.payloadData) {
headerObj = this.getHeaderMd5(artifact);
}
- this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => {
+ this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response: any) => {
let newArtifact = new ArtifactModel(response);
deferred.resolve(newArtifact);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public addInstanceArtifact = (componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
+ public addInstanceArtifact = (componentId: string, instanceId: string, artifact: ArtifactModel): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
let headerObj = {};
if (artifact.payloadData) {
headerObj = this.getHeaderMd5(artifact);
}
- this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => {
- let artifact:ArtifactModel = new ArtifactModel(response.plain());
+ this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response: any) => {
+ let artifact: ArtifactModel = new ArtifactModel(response.plain());
deferred.resolve(artifact);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public deleteInstanceArtifact = (componentId:string, instanceId:string, artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => {
+ public deleteInstanceArtifact = (componentId: string, instanceId: string, artifactId: string, artifactLabel: string): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
- this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").one(artifactId).remove({'operation': artifactLabel}).then((response:ArtifactModel) => {
+ this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").one(artifactId).remove({ 'operation': artifactLabel }).then((response: ArtifactModel) => {
deferred.resolve(response);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public uploadInstanceEnvFile = (componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel> => {
+ public uploadInstanceEnvFile = (componentId: string, instanceId: string, artifact: ArtifactModel): ng.IPromise<ArtifactModel> => {
let deferred = this.$q.defer<ArtifactModel>();
let headerObj = {};
if (artifact.payloadData) {
headerObj = this.getHeaderMd5(artifact);
}
- this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => {
+ this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response: any) => {
let newArtifact = new ArtifactModel(response);
deferred.resolve(newArtifact);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public updateInstanceProperties = (componentId:string, componentInstanceId:string, properties:PropertyModel[]):ng.IPromise<PropertyModel[]> => {
+ public updateInstanceProperties = (componentId: string, componentInstanceId: string, properties: PropertyModel[]): ng.IPromise<PropertyModel[]> => {
let deferred = this.$q.defer<PropertyModel[]>();
- this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("properties").customPOST(JSON.stringify(properties)).then((response:any) => {
+ this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("properties").customPOST(JSON.stringify(properties)).then((response: any) => {
const newProperties = response.map((res) => {
const newProperty = new PropertyModel(res);
newProperty.readonly = true;
@@ -506,118 +512,118 @@ export class ComponentService implements IComponentService {
return newProperty;
});
deferred.resolve(newProperties);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public updateInstanceAttribute = (componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel> => {
+ public updateInstanceAttribute = (componentId: string, attribute: AttributeModel): ng.IPromise<AttributeModel> => {
let deferred = this.$q.defer<AttributeModel>();
let instanceId = attribute.resourceInstanceUniqueId;
- this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("attribute").customPOST(JSON.stringify(attribute)).then((response:any) => {
+ this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("attribute").customPOST(JSON.stringify(attribute)).then((response: any) => {
let newAttribute = new AttributeModel(response);
newAttribute.readonly = true;
newAttribute.resourceInstanceUniqueId = instanceId;
deferred.resolve(newAttribute);
- }, (err)=> {
+ }, (err) => {
deferred.reject(err);
});
return deferred.promise;
};
- public createRelation = (componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel> => {
+ public createRelation = (componentId: string, link: RelationshipModel): ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer<RelationshipModel>();
- const linkPayload:RelationshipModel = new RelationshipModel(link);
+ const linkPayload: RelationshipModel = new RelationshipModel(link);
linkPayload.relationships.forEach((rel) => {
delete rel.capability;
delete rel.requirement;
});
- this.restangular.one(componentId).one("resourceInstance").one("associate").customPOST(JSON.stringify(linkPayload)).then((response:any) => {
- let relation:RelationshipModel = new RelationshipModel(response.plain());
+ this.restangular.one(componentId).one("resourceInstance").one("associate").customPOST(JSON.stringify(linkPayload)).then((response: any) => {
+ let relation: RelationshipModel = new RelationshipModel(response.plain());
console.log("Link created successfully ", relation);
deferred.resolve(relation);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to create Link From: " + link.fromNode + "To: " + link.toNode);
deferred.reject(err);
});
return deferred.promise;
};
- public deleteRelation = (componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel> => {
+ public deleteRelation = (componentId: string, link: RelationshipModel): ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer<RelationshipModel>();
- const linkPayload:RelationshipModel = new RelationshipModel(link);
+ const linkPayload: RelationshipModel = new RelationshipModel(link);
linkPayload.relationships.forEach((rel) => {
delete rel.capability;
delete rel.requirement;
});
- this.restangular.one(componentId).one("resourceInstance").one("dissociate").customPUT(JSON.stringify(linkPayload)).then((response:any) => {
- let relation:RelationshipModel = new RelationshipModel(response);
+ this.restangular.one(componentId).one("resourceInstance").one("dissociate").customPUT(JSON.stringify(linkPayload)).then((response: any) => {
+ let relation: RelationshipModel = new RelationshipModel(response);
console.log("Link deleted successfully ", relation);
deferred.resolve(relation);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to delete Link From: " + link.fromNode + "To: " + link.toNode);
deferred.reject(err);
});
return deferred.promise;
};
- public fetchRelation = (componentId:string, linkId:string):ng.IPromise<RelationshipModel> => {
+ public fetchRelation = (componentId: string, linkId: string): ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer<RelationshipModel>();
- this.restangular.one(componentId).one("relationId").one(linkId).get().then((response:any) => {
- let relation:RelationshipModel = new RelationshipModel(response);
+ this.restangular.one(componentId).one("relationId").one(linkId).get().then((response: any) => {
+ let relation: RelationshipModel = new RelationshipModel(response);
console.log("Link fetched successfully ", relation);
deferred.resolve(relation);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to fetch Link Id: " + linkId);
deferred.reject(err);
});
return deferred.promise;
};
- public getRequirementsCapabilities = (componentId:string):ng.IPromise<any> => {
+ public getRequirementsCapabilities = (componentId: string): ng.IPromise<any> => {
let deferred = this.$q.defer();
- this.restangular.one(componentId).one("requirmentsCapabilities").get().then((response:any) => {
+ this.restangular.one(componentId).one("requirmentsCapabilities").get().then((response: any) => {
console.log("Component requirement capabilities recived: ", response);
deferred.resolve(response);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to get requirements & capabilities");
deferred.reject(err);
});
return deferred.promise;
};
- public getModuleForDisplay = (componentId:string, moduleId:string):ng.IPromise<DisplayModule> => {
+ public getModuleForDisplay = (componentId: string, moduleId: string): ng.IPromise<DisplayModule> => {
let deferred = this.$q.defer<DisplayModule>();
- this.restangular.one(componentId).one("groups").one(moduleId).get().then((response:any) => {
+ this.restangular.one(componentId).one("groups").one(moduleId).get().then((response: any) => {
console.log("module loaded successfully: ", response);
- let module:DisplayModule = new DisplayModule(response);
+ let module: DisplayModule = new DisplayModule(response);
deferred.resolve(module);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to get module with id: ", moduleId);
deferred.reject(err);
});
return deferred.promise;
};
- public getComponentInstanceModule = (componentId:string, componentInstanceId:string, moduleId:string):ng.IPromise<DisplayModule> => {
+ public getComponentInstanceModule = (componentId: string, componentInstanceId: string, moduleId: string): ng.IPromise<DisplayModule> => {
let deferred = this.$q.defer<DisplayModule>();
- this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("groupInstance").one(moduleId).get().then((response:any) => {
+ this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("groupInstance").one(moduleId).get().then((response: any) => {
console.log("module loaded successfully: ", response);
- let module:DisplayModule = new DisplayModule(response);
+ let module: DisplayModule = new DisplayModule(response);
deferred.resolve(module);
- }, (err)=> {
+ }, (err) => {
console.log("Failed to get module with id: ", moduleId);
deferred.reject(err);
});
return deferred.promise;
};
- public getComponentInstancesFilteredByInputsAndProperties = (componentId:string, searchText?:string):ng.IPromise<Array<ComponentInstance>> => {
+ public getComponentInstancesFilteredByInputsAndProperties = (componentId: string, searchText?: string): ng.IPromise<Array<ComponentInstance>> => {
let deferred = this.$q.defer<Array<ComponentInstance>>();
- this.restangular.one(componentId).one("componentInstances").get({'searchText': searchText}).then((response:any) => {
+ this.restangular.one(componentId).one("componentInstances").get({ 'searchText': searchText }).then((response: any) => {
console.log("component instances return successfully: ", response);
- let componentInstances:Array<ComponentInstance> = CommonUtils.initComponentInstances(response);
+ let componentInstances: Array<ComponentInstance> = CommonUtils.initComponentInstances(response);
deferred.resolve(componentInstances);
}, (err) => {
console.log("Failed to get component instances of component with id: " + componentId);
@@ -627,13 +633,13 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
- public getComponentInstanceInputs = (componentId:string, instanceId:string, originComponentUid):ng.IPromise<Array<InputModel>> => {
+ public getComponentInstanceInputs = (componentId: string, instanceId: string, originComponentUid): ng.IPromise<Array<InputModel>> => {
let deferred = this.$q.defer<Array<InputModel>>();
- this.restangular.one(componentId).one("componentInstances").one(instanceId).one(originComponentUid).one("inputs").get().then((response:any) => {
+ this.restangular.one(componentId).one("componentInstances").one(instanceId).one(originComponentUid).one("inputs").get().then((response: any) => {
console.log("component instance input return successfully: ", response);
- let inputsArray:Array<InputModel> = new Array<InputModel>();
- _.forEach(response, (inputObj:InputModel) => {
+ let inputsArray: Array<InputModel> = new Array<InputModel>();
+ _.forEach(response, (inputObj: InputModel) => {
inputsArray.push(new InputModel(inputObj));
});
deferred.resolve(inputsArray);
@@ -645,13 +651,13 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
- public getComponentInputs = (componentId:string):ng.IPromise<Array<InputModel>> => {
+ public getComponentInputs = (componentId: string): ng.IPromise<Array<InputModel>> => {
let deferred = this.$q.defer<Array<InputModel>>();
- this.restangular.one(componentId).one("inputs").get().then((response:any) => {
+ this.restangular.one(componentId).one("inputs").get().then((response: any) => {
console.log("component inputs return successfully: ", response);
- let inputsArray:Array<InputModel> = new Array<InputModel>();
- _.forEach(response, (inputObj:InputModel) => {
+ let inputsArray: Array<InputModel> = new Array<InputModel>();
+ _.forEach(response, (inputObj: InputModel) => {
inputsArray.push(new InputModel(inputObj));
});
deferred.resolve(inputsArray);
@@ -663,13 +669,13 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
- public getComponentInstanceInputProperties = (componentId:string, instanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>> => {
+ public getComponentInstanceInputProperties = (componentId: string, instanceId: string, inputId: string): ng.IPromise<Array<PropertyModel>> => {
let deferred = this.$q.defer<Array<PropertyModel>>();
- this.restangular.one(componentId).one("componentInstances").one(instanceId).one(inputId).one("properties").get().then((response:any) => {
+ this.restangular.one(componentId).one("componentInstances").one(instanceId).one(inputId).one("properties").get().then((response: any) => {
console.log("component instance input properties return successfully: ", response);
- let propertiesArray:Array<PropertyModel> = new Array<PropertyModel>();
- _.forEach(response, (propertyObj:PropertyModel) => {
+ let propertiesArray: Array<PropertyModel> = new Array<PropertyModel>();
+ _.forEach(response, (propertyObj: PropertyModel) => {
propertiesArray.push(new PropertyModel(propertyObj));
});
deferred.resolve(propertiesArray);
@@ -682,13 +688,13 @@ export class ComponentService implements IComponentService {
};
- public getComponentInstanceProperties = (componentId:string, instanceId:string):ng.IPromise<Array<PropertyModel>> => {
+ public getComponentInstanceProperties = (componentId: string, instanceId: string): ng.IPromise<Array<PropertyModel>> => {
let deferred = this.$q.defer<Array<PropertyModel>>();
- this.restangular.one(componentId).one("componentInstances").one(instanceId).one("properties").get().then((response:any) => {
+ this.restangular.one(componentId).one("componentInstances").one(instanceId).one("properties").get().then((response: any) => {
console.log("component instance properties return successfully: ", response);
- let propertiesArray:Array<PropertyModel> = new Array<PropertyModel>();
- _.forEach(response, (propertyObj:PropertyModel) => {
+ let propertiesArray: Array<PropertyModel> = new Array<PropertyModel>();
+ _.forEach(response, (propertyObj: PropertyModel) => {
propertiesArray.push(new PropertyModel(propertyObj));
});
deferred.resolve(propertiesArray);
@@ -700,12 +706,12 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
- public updateGroupMetadata = (componentId:string, group:Module):ng.IPromise<Module> => {
+ public updateGroupMetadata = (componentId: string, group: Module): ng.IPromise<Module> => {
let deferred = this.$q.defer<Module>();
- this.restangular.one(componentId).one("groups").one(group.uniqueId).one("metadata").customPUT(JSON.stringify(group)).then((response:Module) => {
+ this.restangular.one(componentId).one("groups").one(group.uniqueId).one("metadata").customPUT(JSON.stringify(group)).then((response: Module) => {
console.log("group metadata updated successfully: ", response);
- let updatedGroup:Module = new Module(response);
+ let updatedGroup: Module = new Module(response);
deferred.resolve(updatedGroup);
}, (err) => {
@@ -716,78 +722,128 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
- public getComponentInputInputsAndProperties = (serviceId:string, inputId:string):ng.IPromise<InputsAndProperties> => {
+ public getComponentInputInputsAndProperties = (serviceId: string, inputId: string): ng.IPromise<InputsAndProperties> => {
let defer = this.$q.defer<InputsAndProperties>();
- this.restangular.one(serviceId).one("inputs").one(inputId).get().then((response:InputsAndProperties) => {
+ this.restangular.one(serviceId).one("inputs").one(inputId).get().then((response: InputsAndProperties) => {
- let inputsArray:Array<InputModel> = new Array<InputModel>();
- _.forEach(response.inputs, (inputObj:InputModel) => {
+ let inputsArray: Array<InputModel> = new Array<InputModel>();
+ _.forEach(response.inputs, (inputObj: InputModel) => {
inputsArray.push(new InputModel(inputObj));
});
- let propertiesArray:Array<PropertyModel> = new Array<PropertyModel>();
- _.forEach(response.properties, (property:PropertyModel) => {
+ let propertiesArray: Array<PropertyModel> = new Array<PropertyModel>();
+ _.forEach(response.properties, (property: PropertyModel) => {
propertiesArray.push(new PropertyModel(property));
});
defer.resolve(new InputsAndProperties(inputsArray, propertiesArray));
- }, (err)=> {
+ }, (err) => {
console.log("failed to get inputs of input : ", err);
defer.reject(err);
});
return defer.promise;
};
- createInputsFromInstancesInputsProperties = (resourceId:string, instancePropertyMap:InstancesInputsPropertiesMap):ng.IPromise<Array<PropertyModel>> => {
+ public batchDeleteComponentInstance = (componentId: string, componentInstanceIdList: Array<string>): ng.IPromise<any> => {
+ let deferred = this.$q.defer();
+ this.restangular.one(componentId).one("batchDeleteResourceInstances").customPOST(JSON.stringify(componentInstanceIdList)).then((response: any) => {
+ deferred.resolve(response.deleteFailedIds);
+ }, (err) => {
+ console.log("Failed to delete componentInstanceIdList. With IDs: " + componentInstanceIdList);
+ deferred.reject(err);
+ });
+ return deferred.promise;
+ };
+
+ public batchDeleteRelation = (componentId: string, links: Array<RelationshipModel>): ng.IPromise<Array<RelationshipModel>> => {
+ let deferred = this.$q.defer<Array<RelationshipModel>>();
+
+ _.forEach(links, (link: RelationshipModel) => {
+ let linkPayload: RelationshipModel = new RelationshipModel(link);
+ linkPayload.relationships.forEach((rel) => {
+ delete rel.capability;
+ delete rel.requirement;
+ });
+ });
+
+ this.restangular.one(componentId).one("resourceInstance").one("batchDissociate").customPUT(JSON.stringify(links)).then((response: any) => {
+ console.log("Link batch deleted successfully result is ", response);
+ let relationshipModelArray: Array<RelationshipModel> = new Array<RelationshipModel>();
+ _.forEach(response, (relationshipModelObj: RelationshipModel) => {
+ relationshipModelArray.push(new RelationshipModel(relationshipModelObj));
+ });
+ deferred.resolve(relationshipModelArray);
+ //deferred.resolve(response);
+ }, (err) => {
+ console.log("Failed to batch delete links", links);
+ deferred.reject(err);
+ });
+ return deferred.promise;
+ }
+
+ public pasteMenuComponentInstance = (componentId: string, srcComponentId: string, msg: string): ng.IPromise<string> => {
+ let deferred = this.$q.defer<string>();
+ this.restangular.one(componentId).one("copyComponentInstance").one(srcComponentId).customPOST(msg).then((response: any) => {
+ deferred.resolve(response);
+ }, (err) => {
+ deferred.reject(err);
+ });
+ return deferred.promise;
+
+ };
+
+
+
+ createInputsFromInstancesInputsProperties = (resourceId: string, instancePropertyMap: InstancesInputsPropertiesMap): ng.IPromise<Array<PropertyModel>> => {
let defer = this.$q.defer<Array<PropertyModel>>();
- this.restangular.one(resourceId).one("create/properties").customPOST(instancePropertyMap).then((response:any) => {
- let inputsArray:Array<PropertyModel> = new Array<PropertyModel>();
- _.forEach(response, (inputObj:PropertyModel) => {
+ this.restangular.one(resourceId).one("create/properties").customPOST(instancePropertyMap).then((response: any) => {
+ let inputsArray: Array<PropertyModel> = new Array<PropertyModel>();
+ _.forEach(response, (inputObj: PropertyModel) => {
inputsArray.push(new PropertyModel(inputObj));
});
defer.resolve(inputsArray);
- }, (err)=> {
+ }, (err) => {
console.log("failed to create service inputs from VF instances inputs : ", err);
defer.reject(err);
});
return defer.promise;
};
- createInputsFromInstancesInputs = (serviceId:string, instancesMap:InstancesInputsPropertiesMap):ng.IPromise<Array<InputModel>> => {
+ createInputsFromInstancesInputs = (serviceId: string, instancesMap: InstancesInputsPropertiesMap): ng.IPromise<Array<InputModel>> => {
let defer = this.$q.defer<Array<InputModel>>();
- this.restangular.one(serviceId).one("create/inputs").customPOST(instancesMap).then((response:any) => {
- let inputsArray:Array<InputModel> = new Array<InputModel>();
- _.forEach(response, (inputObj:InputModel) => {
+ this.restangular.one(serviceId).one("create/inputs").customPOST(instancesMap).then((response: any) => {
+ let inputsArray: Array<InputModel> = new Array<InputModel>();
+ _.forEach(response, (inputObj: InputModel) => {
inputsArray.push(new InputModel(inputObj));
});
defer.resolve(inputsArray);
- }, (err)=> {
+ }, (err) => {
console.log("failed to create service inputs from VF instances inputs : ", err);
defer.reject(err);
});
return defer.promise;
};
- deleteComponentInput = (serviceId:string, inputId:string):ng.IPromise<InputModel> => {
+ deleteComponentInput = (serviceId: string, inputId: string): ng.IPromise<InputModel> => {
let defer = this.$q.defer<InputModel>();
- this.restangular.one(serviceId).one("delete").one(inputId).one("input").remove().then((response:any) => {
+ this.restangular.one(serviceId).one("delete").one(inputId).one("input").remove().then((response: any) => {
let inputToDelete = new InputModel(response);
defer.resolve(inputToDelete);
- }, (err)=> {
+ }, (err) => {
console.log("failed to delete input from service: ", err);
defer.reject(err);
});
return defer.promise;
};
- private getHeaderMd5 = (object:any):any => {
+ private getHeaderMd5 = (object: any): any => {
let headerObj = {};
// This is ugly workaround!!!
// The md5 result is not correct if we do not add the line JSON.stringify(resource); twice.
JSON.stringify(object);
- let componentString:string = JSON.stringify(object);
+ let componentString: string = JSON.stringify(object);
let md5Result = md5(componentString).toLowerCase();
- headerObj = {'Content-MD5': this.$base64.encode(md5Result)};
+ headerObj = { 'Content-MD5': this.$base64.encode(md5Result) };
return headerObj;
};