history dialog

This commit is contained in:
Michele Artini 2023-12-04 11:06:53 +01:00
parent eeff0a04d7
commit fbc618af83
8 changed files with 123 additions and 25 deletions

View File

@ -1,6 +1,7 @@
package eu.dnetlib.wfs.manager.controller;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@ -58,8 +59,8 @@ public class ApiController extends DnetRestController {
}
@GetMapping("/proc/{processId}")
public WfJournalEntry getProcessExecution(@PathVariable final String processId) {
return wfManagerService.findProcessLog(processId);
public List<WfJournalEntry> getProcessExecution(@PathVariable final String processId) {
return Arrays.asList(wfManagerService.findProcessLog(processId));
}
@GetMapping("/sections")
@ -133,11 +134,9 @@ public class ApiController extends DnetRestController {
}
@PostMapping("/repo-hi/{id}/start")
public List<WfJournalEntry> startRepoHi(@PathVariable final String id, @RequestBody final WfRepoHiParams params) {
wfManagerService
public WfJournalEntry startRepoHi(@PathVariable final String id, @RequestBody final WfRepoHiParams params) {
return wfManagerService
.prepareNewJob(id, WorkflowsConstants.REPO_HI_JOB, WorkflowsConstants.REPO_HI_JOB, params.getDsId(), params.getDsName(), params.getApiId());
return wfManagerService.recentHistoryForApiId(params.getApiId());
}
@GetMapping("/template/{id}")

View File

@ -18,6 +18,7 @@ import { MatBadgeModule } from '@angular/material/badge';
import { MatCardModule } from '@angular/material/card';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input'
import { MatRadioModule } from '@angular/material/radio';
import { MatSelectModule } from '@angular/material/select'
import { MatTableModule } from '@angular/material/table';
import { ProtocolsComponent } from './protocols/protocols.component';
@ -109,6 +110,7 @@ import { WfTemplateDialog } from './wf-confs/wf-common.component';
MatCardModule,
MatFormFieldModule,
MatInputModule,
MatRadioModule,
MatSelectModule,
MatCheckboxModule,
MatTableModule,

View File

@ -9,6 +9,10 @@
<mat-icon fontIcon="add"></mat-icon>
add workflow
</button>
<button mat-stroked-button (click)="openJournalDialog(undefined, undefined)">
<mat-icon fontIcon="history"></mat-icon>
history
</button>
<button mat-stroked-button color="warn" (click)="deleteApi()" [disabled]="!api.removable || api.active">
<mat-icon fontIcon="delete"></mat-icon>
delete api

View File

@ -153,6 +153,17 @@ export class DsmApiComponent implements OnInit {
}
}
openJournalDialog(confId: string | undefined, processId: string | undefined) {
const wfDialogRef = this.dialog.open(WfHistoryDialog, {
data: {
'dsId': this.ds.id,
'apiId': this.api.id,
'confId': confId,
'processId': processId
}
});
}
deleteApi() {
alert('TODO DELETE API');
}
@ -356,7 +367,14 @@ export class DsmAddWorkflowDialog {
startRepoHiWf(wfId: string): void {
this.client.dsmRepoHiWf(wfId, this.ds.id, this.ds.officialname, this.api.id, (data: WfHistoryEntry) => {
const wfDialogRef = this.dialog.open(WfHistoryDialog, { data: data });
const wfDialogRef = this.dialog.open(WfHistoryDialog, {
data: {
'dsId': this.ds.id,
'apiId': this.api.id,
'processId': data.processId,
'confId': undefined
}
});
});
}

View File

@ -197,8 +197,6 @@ export class WfConfSingle implements OnInit, OnChanges {
}
}
launchWfConf() {
if (this.conf?.id && this.conf?.workflow) {
this.client.startWfConfiguration(this.conf?.id, (data: WfHistoryEntry) => this.snackBar.open('Workflow launched !!!', 'INFO', { duration: 5000 }));

View File

@ -15,20 +15,23 @@
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef style="width: 15%;" mat-sort-header sortActionDescription="Sort by WF Name">
Workflow Name </th>
Name </th>
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
</ng-container>
<ng-container matColumnDef="family">
<th mat-header-cell *matHeaderCellDef style="width: 10%;" mat-sort-header sortActionDescription="Sort by WF Family">
Workflow Family </th>
Family </th>
<td mat-cell *matCellDef="let element"> {{element.family}} </td>
</ng-container>
<ng-container matColumnDef="dsName">
<th mat-header-cell *matHeaderCellDef style="width: 20%;" mat-sort-header
sortActionDescription="Sort by Datasource"> Datasource </th>
<td mat-cell *matCellDef="let element"> {{element.dsName}} </td>
<td mat-cell *matCellDef="let element">
{{element.dsName}}
<span *ngIf="element.dsApi" style="font-size: 0.8em;"><br /><b>API:</b> {{element.dsApi}}</span>
</td>
</ng-container>
<ng-container matColumnDef="status">

View File

@ -1,12 +1,13 @@
import { Component, Inject, AfterViewInit, OnInit, ViewChild, Injectable, Input, OnChanges } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { MatSort } from '@angular/material/sort';
import { WfHistoryEntry, KeyValue } from '../common/is.model';
import { ActivatedRoute, Params } from '@angular/router';
import { Observable, combineLatest, of } from 'rxjs';
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ISClient } from '../common/is.client';
import { HttpParams } from '@angular/common/http';
import { AfterViewInit, Component, Inject, Injectable, Input, OnChanges, OnInit, ViewChild } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Params } from '@angular/router';
import { combineLatest } from 'rxjs';
import { ISClient } from '../common/is.client';
import { KeyValue, WfHistoryEntry } from '../common/is.model';
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'app-wf-history',
@ -47,13 +48,53 @@ export class WfHistoryComponent implements OnInit {
templateUrl: './wf-history.dialog.html',
styleUrls: []
})
export class WfHistoryDialog {
export class WfHistoryDialog implements OnInit {
dsId: string = '';
apiId: string = '';
confId: string = '';
processId: string = '';
mode: number = 1;
entries: WfHistoryEntry[] = [];
constructor(public dialogRef: MatDialogRef<WfHistoryDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public dialog: MatDialog) {
this.entries = data;
constructor(public client: WfHistoryClient, public dialogRef: MatDialogRef<WfHistoryDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public dialog: MatDialog, public snackBar: MatSnackBar) {
this.dsId = data.dsId;
this.apiId = data.apiId;
this.confId = data.confId;
this.processId = data.processId;
if (this.processId) { this.mode = 4 }
else if (this.confId) { this.mode = 3 }
else if (this.apiId) { this.mode = 2; }
else if (this.dsId) { this.mode = 1 }
else {
this.snackBar.open("One of dsId, apiId, confId or processId is expected", 'ERROR', { duration: 5000 });
}
}
ngOnInit() {
this.reload(this.mode);
};
reload(mode: number) {
this.mode = mode;
if (mode == 1) {
this.client.recentHistory(this.dsId, 1, (data: WfHistoryEntry[]) => this.entries = data);
} else if (mode == 2) {
this.client.recentHistory(this.apiId, 2, (data: WfHistoryEntry[]) => this.entries = data);
} else if (mode == 3) {
this.client.recentHistory(this.confId, 3, (data: WfHistoryEntry[]) => this.entries = data);
} else if (mode == 4) {
this.client.recentHistory(this.processId, 4, (data: WfHistoryEntry[]) => this.entries = data);
} else {
this.snackBar.open("invalid mode", 'ERROR', { duration: 5000 });
return;
}
}
}
@Component({
@ -138,7 +179,6 @@ export class WfHistoryDetailsDialog {
this.dialogRef.close();
}
calculateDateDiff(start: number, end: number): string {
if (start <= 0 || end <= 0) {
return '-';
@ -201,4 +241,24 @@ export class WfHistoryClient extends ISClient {
this.httpGetWithOptions<WfHistoryEntry[]>('/proxy/byType/wf_manager/api/history', { params: params }, onSuccess);
}
recentHistory(id: string, mode: number, onSuccess: Function) {
let url = '/proxy/byType/wf_manager/api/';
if (mode == 1) {
url += '/history/byDsId/' + encodeURIComponent(id);
} else if (mode == 2) {
url += '/history/byApiId/' + encodeURIComponent(id);
} else if (mode == 3) {
url += '/history/byConf/' + encodeURIComponent(id);
} else if (mode == 4) {
url += '/proc/' + encodeURIComponent(id);
} else {
this.snackBar.open("invalid mode", 'ERROR', { duration: 5000 });
return;
}
this.httpGet(url, onSuccess);
}
}

View File

@ -1,7 +1,21 @@
<h1 mat-dialog-title>Workflows</h1>
<h1 mat-dialog-title>Recent Workflows</h1>
<div mat-dialog-content>
<div style="margin-bottom: 1em">
<button mat-stroked-button color="primary" (click)="reload(mode)">
<mat-icon fontIcon="refresh"></mat-icon> refresh
</button>
<mat-radio-group [(ngModel)]="mode" (change)="reload(mode)" style="float: right;">
<mat-radio-button [value]="1" *ngIf="dsId">by datasource</mat-radio-button>
<mat-radio-button [value]="2" *ngIf="apiId">by api</mat-radio-button>
<mat-radio-button [value]="3" *ngIf="confId">by workflow</mat-radio-button>
<mat-radio-button [value]="4" *ngIf="processId">by process</mat-radio-button>
</mat-radio-group>
</div>
<wf-history-table [entries]="entries"></wf-history-table>
</div>
<div mat-dialog-actions>