diff options
author | Michael Lando <ml636r@att.com> | 2018-03-04 14:53:33 +0200 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-03-07 13:19:05 +0000 |
commit | a5445100050e49e83f73424198d73cd72d672a4d (patch) | |
tree | cacf4df817df31be23e4e790d1dda857bdae061e /catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-service-path-utils.ts | |
parent | 51157f92c21976cba4914c378aaa3cba49826931 (diff) |
Sync Integ to Master
Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74
Issue-ID: SDC-977
Signed-off-by: Gitelman, Tal (tg851x) <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-service-path-utils.ts')
-rw-r--r-- | catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-service-path-utils.ts | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-service-path-utils.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-service-path-utils.ts new file mode 100644 index 0000000000..ef047d7dd3 --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-service-path-utils.ts @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +import * as _ from "lodash"; +import {LoaderService} from "app/services"; +import {CompositionGraphGeneralUtils} from "./composition-graph-general-utils"; +import {ICompositionGraphScope} from "../composition-graph.directive"; +import {ServiceServiceNg2} from 'app/ng2/services/component-services/service.service'; +import {Service} from "../../../../models/components/service"; +import {ForwardingPath} from "app/models/forwarding-path"; +import {ForwardingPathLink} from "app/models/forwarding-path-link"; +import {CompositionCiServicePathLink} from "../../../../models/graph/graph-links/composition-graph-links/composition-ci-service-path-link"; +import {CommonGraphUtils} from "app/directives/graphs-v2/common/common-graph-utils"; + +export class ServicePathGraphUtils { + + constructor( + private loaderService:LoaderService, + private generalGraphUtils:CompositionGraphGeneralUtils, + private serviceService:ServiceServiceNg2, + private commonGraphUtils:CommonGraphUtils + ) {} + + public deletePathsFromGraph(cy: Cy.Instance, service:Service){ + cy.remove(`[type="${CompositionCiServicePathLink.LINK_TYPE}"]`); + } + + public drawPath(cy: Cy.Instance, forwardingPath: ForwardingPath, service:Service) { + let pathElements = forwardingPath.pathElements.listToscaDataDefinition; + + _.forEach(pathElements, (link: ForwardingPathLink) => { + let data:CompositionCiServicePathLink = new CompositionCiServicePathLink(link); + data.source = data.forwardingPathLink.fromNode; + data.target = data.forwardingPathLink.toNode; + data.pathId = forwardingPath.uniqueId; + data.pathName = forwardingPath.name; + this.commonGraphUtils.insertServicePathLinkToGraph(cy, data); + }); + } + + public createOrUpdateServicePath = (scope:ICompositionGraphScope, path: any): void => { + let service = <Service>scope.component; + this.loaderService.showLoader('composition-graph'); + + let onSuccess: (response: ForwardingPath) => void = (response: ForwardingPath) => { + + service.forwardingPaths[response.uniqueId] = response; + scope.selectedPathId = response.uniqueId; + }; + + this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback( + () => this.serviceService.createOrUpdateServicePath(service, path).subscribe(onSuccess), + () => this.loaderService.hideLoader('composition-graph') + ); + }; +} + +ServicePathGraphUtils.$inject = [ + 'LoaderService', + 'CompositionGraphGeneralUtils', + 'ServiceServiceNg2', + 'CommonGraphUtils' +]; |