diff --git a/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/refinementWebSocket.service.ts b/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/refinementWebSocket.service.ts deleted file mode 100644 index 92729a3616..0000000000 --- a/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/refinementWebSocket.service.ts +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2018 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - *******************************************************************************/ -import { Injectable } from '@angular/core'; -import { webSocketURL } from '../../../configuration'; -import { BehaviorSubject } from 'rxjs/BehaviorSubject'; -import { InstanceService } from '../../instance.service'; - -export enum RefinementTasks { - START = 'START', - REFINE_WITH = 'REFINE_WITH', - STOP = 'STOP' -} - -export interface RefinementElement { - patternRefinementModel: { - name: string; - targetNamespace: string; - }; - id: number; - xmlId?: { - decoded: string; - }; - namespace?: { - decoded: string - }; -} - -export interface RefinementWebSocketData { - task: RefinementTasks; - refineWith?: number; - serviceTemplate?: string; -} - -@Injectable() -export class RefinementWebSocketService { - - private socket: WebSocket; - private listener: BehaviorSubject; - - constructor(private sharedData: InstanceService) { - } - - startRefinement() { - this.socket = new WebSocket(webSocketURL + '/refinetopology'); - this.listener = new BehaviorSubject(null); - - const start: RefinementWebSocketData = { - task: RefinementTasks.START, - serviceTemplate: this.sharedData.toscaComponent.getQName() - }; - - this.socket.onmessage = event => this.onMessage(event); - this.socket.onclose = event => this.onClose(event); - this.socket.onopen = event => this.socket.send(JSON.stringify(start)); - - return this.listener.asObservable(); - } - - refineWith(option: RefinementElement) { - const update: RefinementWebSocketData = { - task: RefinementTasks.REFINE_WITH, - refineWith: option.id - }; - this.socket.send(JSON.stringify(update)); - } - - private onMessage(event: MessageEvent) { - if (event.data) { - const data: RefinementElement[] = JSON.parse(event.data); - this.listener.next(data); - } - } - - private onClose(event: CloseEvent) { - this.socket.close(); - this.listener.complete(); - } - - cancel() { - this.socket.send(JSON.stringify({ task: RefinementTasks.STOP })); - } -} diff --git a/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/topologyTemplate.component.html b/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/topologyTemplate.component.html index a65060db9a..6559179c73 100644 --- a/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/topologyTemplate.component.html +++ b/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/topologyTemplate.component.html @@ -16,9 +16,6 @@ -
Open Old Editor @@ -47,35 +44,3 @@

Select the version you want to compare with the current

[okButtonLabel]="'Compare'" [disableOkButton]="!selectedVersion" (onOk)="onCompare()"> - - - - -
-
-
Refinement successful!
-
- - - -
- - - -
    -
  • - {{ option.patternRefinementModel.name }} -
    - - - -
    -
  • -
-
-
-
- - - -
diff --git a/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/topologyTemplate.component.ts b/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/topologyTemplate.component.ts index 524d6acf98..d302ecfd5a 100644 --- a/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/topologyTemplate.component.ts +++ b/org.eclipse.winery.repository.ui/src/app/instance/sharedComponents/topologyTemplate/topologyTemplate.component.ts @@ -19,13 +19,9 @@ import { WineryVersion } from '../../../model/wineryVersion'; import { BsModalRef, BsModalService, ModalDirective } from 'ngx-bootstrap'; import { ActivatedRoute } from '@angular/router'; import { ToscaTypes } from '../../../model/enums'; -import { RefinementElement, RefinementWebSocketService } from './refinementWebSocket.service'; @Component({ templateUrl: 'topologyTemplate.component.html', - providers: [ - RefinementWebSocketService - ] }) export class TopologyTemplateComponent implements OnInit { @@ -41,18 +37,14 @@ export class TopologyTemplateComponent implements OnInit { @ViewChild('compareToModal') compareToModal: ModalDirective; compareToModalRef: BsModalRef; - @ViewChild('refinementModal') refinementModal: ModalDirective; - refinementModalRef: BsModalRef; refinementIsRunning: boolean; refinementIsLoading: boolean; refinementIsDone: boolean; - prmOptions: RefinementElement[]; constructor(private sanitizer: DomSanitizer, public sharedData: InstanceService, private modalService: BsModalService, - private webSocketService: RefinementWebSocketService, private activatedRoute: ActivatedRoute) { } @@ -98,62 +90,13 @@ export class TopologyTemplateComponent implements OnInit { window.open(compareUrl, '_blank'); } - startRefinement() { - this.refinementIsDone = false; - this.refinementIsRunning = true; - this.refinementIsLoading = true; - this.webSocketService.startRefinement() - .subscribe( - value => this.handleWebSocketData(value), - error => this.handleError(error), - () => this.handleWebSocketComplete() - ); - } - showCompareToModal() { this.compareToModalRef = this.modalService.show(this.compareToModal); } - showRefinementModal() { - this.refinementModalRef = this.modalService.show(this.refinementModal); - } - - onAbortRefinement() { - this.refinementModalRef.hide(); - this.webSocketService.cancel(); - } - - private handleWebSocketData(value: RefinementElement[]) { - if (value) { - this.refinementIsLoading = false; - this.prmOptions = value; - } - } - - private handleError(error: any) { - this.refinementIsLoading = false; - console.log(error); - } - private handleWebSocketComplete() { this.refinementIsDone = true; this.refinementIsRunning = false; this.refinementIsLoading = false; } - - openModelerFor(patternRefinementModel: { name: string; targetNamespace: string }, element: string, type = 'patternrefinementmodels') { - const editorConfig = topologyModelerURL + '?repositoryURL=' + encodeURIComponent(backendBaseURL) - + '&uiURL=' + this.uiURL - + '&ns=' + encodeURIComponent(patternRefinementModel.targetNamespace) - + '&id=' + patternRefinementModel.name - + '&parentPath=' + type - + '&elementPath=' + element - + '&isReadonly=true'; - window.open(editorConfig, '_blank'); - } - - prmChosen(option: RefinementElement) { - this.webSocketService.refineWith(option); - this.refinementIsLoading = true; - } }