Skip to content

Commit

Permalink
remove refinement from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
lharzenetter committed Aug 27, 2018
1 parent 78dc6be commit e6a2538
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 185 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<button *ngIf="sharedData?.versions?.length > 1" class="btn btn-info" (click)="showCompareToModal()">
Compare to...
</button>
<button *ngIf="refinementAvailable" class="btn btn-default" (click)="showRefinementModal()">
Refine Topology
</button>
</div>
<div style="float: right">
<a [href]="oldEditorUrl" target="_blank" class="btn btn-light">Open Old Editor</a>
Expand Down Expand Up @@ -47,35 +44,3 @@ <h4>Select the version you want to compare with the current</h4>
[okButtonLabel]="'Compare'" [disableOkButton]="!selectedVersion" (onOk)="onCompare()">
</winery-modal-footer>
</ng-template>

<ng-template #refinementModal>
<winery-modal-header [modalRef]="refinementModalRef" [title]="'Refine Topology'"></winery-modal-header>
<winery-modal-body>
<div *ngIf="!refinementIsRunning; else showIsRunning">
<div *ngIf="refinementIsDone; else showStart">
<h5>Refinement successful!</h5>
</div>
<ng-template #showStart>
<button class="btn btn-primary" (click)="startRefinement()">Start Refinement</button>
</ng-template>
</div>
<ng-template #showIsRunning>
<winery-loader *ngIf="refinementIsLoading; else showContent"></winery-loader>
<ng-template #showContent>
<ul>
<li *ngFor="let option of prmOptions">
{{ option.patternRefinementModel.name }}
<div class="btn-group">
<button class="btn btn-sm btn-default" (click)="openModelerFor(option.patternRefinementModel, 'detector')">Detector Topology</button>
<button class="btn btn-sm btn-default" (click)="openModelerFor(option.patternRefinementModel, 'refinementstructure')">Refinement Topology</button>
<button class="btn btn-sm btn-primary" (click)="prmChosen(option)">Choose</button>
</div>
</li>
</ul>
</ng-template>
</ng-template>
</winery-modal-body>
<winery-modal-footer [showDefaultButtons]="false">
<button (click)="onAbortRefinement()" class="btn btn-default">Close</button>
</winery-modal-footer>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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) {
}

Expand Down Expand Up @@ -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;
}
}

0 comments on commit e6a2538

Please sign in to comment.