Commit 63725029 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add running method loader

parent 77567db6
......@@ -17,22 +17,13 @@
</nav>
</div>
<main
*ngIf="
runningProcessLoaderService.error &&
runningProcessLoaderService.errorStatus === 404
"
role="main"
>
<main *ngIf="error && errorStatus === 404" role="main">
<div class="alert alert-info container my-3">
<p>
This running method does not exist. Reason:
{{ runningProcessLoaderService.errorReason }}.
</p>
<p>This running method does not exist. Reason: {{ errorReason }}.</p>
<p class="mb-0">
<a [routerLink]="['/', 'runningprocess']"
>Go back to overview of running methods</a
>
<a [routerLink]="['/', 'runningprocess']">
Go back to overview of running methods
</a>
</p>
</div>
</main>
......
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { RunningProcessService } from '../../development-process-registry/running-process/running-process.service';
import { RunningProcess } from '../../development-process-registry/running-process/running-process';
......@@ -9,7 +8,7 @@ import { OutputArtifactMappingFormService } from '../shared/output-artifact-mapp
import { Comment } from '../../development-process-registry/running-process/comment';
import { ArtifactDataReference } from '../../development-process-registry/running-process/artifact-data';
import { MetaModelApi } from '../../development-process-registry/meta-model-definition';
import { RunningProcessLoaderService } from '../shared/running-process-loader.service';
import { RunningMethodLoaderService } from '../shared/running-method-loader.service';
enum State {
INPUT_SELECTION,
......@@ -21,38 +20,17 @@ enum State {
selector: 'app-running-process-method',
templateUrl: './running-process-method.component.html',
styleUrls: ['./running-process-method.component.css'],
providers: [RunningProcessLoaderService],
providers: [RunningMethodLoaderService],
})
export class RunningProcessMethodComponent implements OnInit, OnDestroy {
runningMethod: RunningMethod;
private executionId: string;
private routeSubscription: Subscription;
export class RunningProcessMethodComponent {
constructor(
private outputArtifactMappingFormService: OutputArtifactMappingFormService,
private route: ActivatedRoute,
private router: Router,
public runningProcessLoaderService: RunningProcessLoaderService,
private runningMethodLoaderService: RunningMethodLoaderService,
private runningProcessService: RunningProcessService
) {}
ngOnInit() {
this.runningProcessLoaderService.loaded.subscribe((runningProcess) =>
this.afterReload(runningProcess)
);
this.routeSubscription = this.route.paramMap.subscribe((paramMap) => {
this.runningProcessLoaderService.updateId(paramMap.get('id'));
this.executionId = paramMap.get('executionId');
});
}
ngOnDestroy() {
if (this.routeSubscription) {
this.routeSubscription.unsubscribe();
}
}
async selectInputArtifacts(inputArtifactMapping: FormArray) {
const inputArtifactMappingValue = inputArtifactMapping.value;
const inputArtifactMap = (mapping) => {
......@@ -174,14 +152,23 @@ export class RunningProcessMethodComponent implements OnInit, OnDestroy {
return State.OUTPUT_SELECTION;
}
private async afterReload(runningProcess: RunningProcess) {
this.runningMethod = runningProcess.getRunningMethod(this.executionId);
if (this.runningMethod == null) {
this.runningMethod = null;
}
get error(): boolean {
return this.runningMethodLoaderService.error;
}
get errorStatus(): number {
return this.runningMethodLoaderService.errorStatus;
}
get errorReason(): string {
return this.runningMethodLoaderService.errorReason;
}
get runningProcess(): RunningProcess {
return this.runningProcessLoaderService.runningProcess;
return this.runningMethodLoaderService.runningProcess;
}
get runningMethod(): RunningMethod {
return this.runningMethodLoaderService.runningMethod;
}
}
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { Subscription } from 'rxjs';
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { RunningProcessService } from '../../development-process-registry/running-process/running-process.service';
import { RunningProcessViewerComponent } from '../../development-process-view/running-process-viewer/running-process-viewer.component';
......@@ -34,11 +33,9 @@ import { ConcreteArtifactService } from '../../development-process-registry/runn
styleUrls: ['./running-process.component.css'],
providers: [RunningProcessLoaderService],
})
export class RunningProcessComponent implements OnInit, OnDestroy {
export class RunningProcessComponent implements OnInit {
decisions: any[];
private routeSubscription: Subscription;
private modalReference: NgbModalRef;
modalDecision: Decision;
modalArtifact: RunningArtifact;
......@@ -76,18 +73,9 @@ export class RunningProcessComponent implements OnInit, OnDestroy {
) {}
ngOnInit() {
this.runningProcessLoaderService.loaded.subscribe((runningProcess) =>
this.afterReload(runningProcess)
this.runningProcessLoaderService.loaded.subscribe(() =>
this.afterReload(this.runningProcess)
);
this.routeSubscription = this.route.paramMap.subscribe((map) => {
this.runningProcessLoaderService.updateId(map.get('id'));
});
}
ngOnDestroy() {
if (this.routeSubscription) {
this.routeSubscription.unsubscribe();
}
}
openShowArtifactVersionModal(
......
import { Injectable } from '@angular/core';
import { RunningProcessLoaderService } from './running-process-loader.service';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { RunningMethod } from '../../development-process-registry/running-process/running-method';
import { RunningProcessService } from '../../development-process-registry/running-process/running-process.service';
@Injectable()
export class RunningMethodLoaderService extends RunningProcessLoaderService {
runningMethod: RunningMethod;
private executionId: string;
constructor(
runningProcessService: RunningProcessService,
route: ActivatedRoute
) {
super(runningProcessService, route);
this.loaded.subscribe(() => this.loadRunningMethod());
}
protected initParams(paramMap: ParamMap) {
this.executionId = paramMap.get('executionId');
super.initParams(paramMap);
}
private loadRunningMethod() {
this.runningMethod = this.runningProcess.getRunningMethod(this.executionId);
if (this.runningMethod == null) {
this.runningMethod = null;
}
}
}
import { Injectable, OnDestroy } from '@angular/core';
import { Injectable } from '@angular/core';
import { RunningProcess } from '../../development-process-registry/running-process/running-process';
import { RunningProcessService } from '../../development-process-registry/running-process/running-process.service';
import { Observable, Subject, Subscription } from 'rxjs';
import { ElementLoaderService } from '../../database/element-loader.service';
import { ActivatedRoute, ParamMap } from '@angular/router';
@Injectable()
export class RunningProcessLoaderService implements OnDestroy {
export class RunningProcessLoaderService extends ElementLoaderService {
runningProcess: RunningProcess;
private runningProcessId: string;
error: boolean;
errorStatus: number;
errorReason: string;
loaded: Observable<RunningProcess>;
private $loaded: Subject<RunningProcess>;
private changesFeed: Subscription;
constructor(private runningProcessService: RunningProcessService) {
this.init();
constructor(
private runningProcessService: RunningProcessService,
route: ActivatedRoute
) {
super(route);
}
private init() {
this.$loaded = new Subject<RunningProcess>();
this.loaded = this.$loaded.asObservable();
}
updateId(id: string) {
this.checkUnsubscribeChangesFeed();
this.runningProcessId = id;
protected initParams(paramMap: ParamMap) {
const runningProcessId = paramMap.get('id');
this.changesFeed = this.runningProcessService
.getChangesFeed(this.runningProcessId)
.subscribe(() => this.reload());
this.reload().then();
.getChangesFeed(runningProcessId)
.subscribe(() => this.loadRunningProcess(runningProcessId));
this.loadRunningProcess(runningProcessId).then();
}
async reload() {
private async loadRunningProcess(runningProcessId: string) {
try {
this.runningProcess = await this.runningProcessService.get(
this.runningProcessId
runningProcessId
);
} catch (error) {
this.runningProcess = null;
this.error = true;
this.errorStatus = error.status;
this.errorReason = error.reason;
this.checkUnsubscribeChangesFeed();
console.error(error);
return;
}
this.$loaded.next(this.runningProcess);
}
ngOnDestroy() {
this.checkUnsubscribeChangesFeed();
this.$loaded.complete();
}
private checkUnsubscribeChangesFeed() {
if (this.changesFeed) {
this.changesFeed.unsubscribe();
this.changesFeed = null;
}
this.elementLoaded();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment