Skip to content

Commit

Permalink
load default tmplate from environment variables
Browse files Browse the repository at this point in the history
deactivate buttons when qb running
show info message when qb failed
  • Loading branch information
thkoehler11 authored and djuarezgf committed Nov 20, 2023
1 parent f18e42d commit 59d123a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/app/embedded/quality-report/quality-report.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ <h2 i18n>Qualit&auml;tsbericht</h2>
<div class="button-status">
<mat-form-field class="template_dropdown">
<mat-label>Template</mat-label>
<select class="template-select" matNativeControl required [(ngModel)]="selectedTemplate" [disabled]="buttonDisabled">
<select class="template-select" matNativeControl required [(ngModel)]="selectedTemplate" [disabled]="buttonDisabled" (change)="changeTemplateSelection()">
<option *ngFor="let id of templateIDs" [value]="id.value">{{id.display}}</option>
</select>
</mat-form-field>
<button class="cancel-button" mat-raised-button color="primary" (click)=cancelQB() [ngClass]="{ 'visible-button': buttonDisabled }" i18n>abbrechen</button>
<button class="generate-button" mat-raised-button color="primary" (click)=generateQB() [ngClass]="{ 'visible-button': (selectedTemplate !== 'custom' && !buttonDisabled) }" i18n>neuen QB generieren</button>
<div class="upload-button" [ngClass]="{ 'visible': selectedTemplate === 'custom' }">
<div class="upload-button" [ngClass]="{ 'visible': (selectedTemplate === 'custom' && !buttonDisabled) }">
<input type="file" class="file-input" (change)="doImportFromFile($event)" #fileUpload />
<button class="file-upload" mat-raised-button color="primary" (click)="fileUpload.click()" [disabled]="buttonDisabled">
<span i18n>Template auswählen und neuen QB generieren</span>
</button>
</div>
<button class="download-button" mat-raised-button color="primary" (click)=downloadTemplate() [ngClass]="{ 'visible-button': selectedTemplate !== 'custom' }" i18n>Template herunterladen</button>
<button class="download-button" mat-raised-button color="primary" (click)=downloadTemplate() [ngClass]="{ 'visible-button': selectedTemplate !== 'custom' }" [disabled]="buttonDisabled" i18n>Template herunterladen</button>

<div class="status">
<ng-container *ngIf="qbStatus === QBStatus.EMPTY"><span class="status-empty"></span></ng-container>
Expand Down
17 changes: 11 additions & 6 deletions src/app/embedded/quality-report/quality-report.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute} from "@angular/router";

import {DatePipe} from '@angular/common';
import {MatTableDataSource} from "@angular/material/table";
import {MatPaginator} from "@angular/material/paginator";
import {QualityReportService, reportLog} from "../../teiler/quality-report.service";
import {Subscription} from "rxjs";
import {environment} from "../../../environments/environment";

export interface QualityReports {
id: string;
Expand Down Expand Up @@ -59,7 +58,7 @@ export class QualityReportComponent implements OnInit, OnDestroy {
buttonDisabled: boolean = false;
fileName: string | undefined;
importTemplate: string = "";
selectedTemplate: string = "ccp";
selectedTemplate: string = environment.config.REPORTER_DEFAULT_TEMPLATE_ID;
templateIDs: Templates[] = []

constructor(private route: ActivatedRoute, private qualityReportService: QualityReportService) {
Expand Down Expand Up @@ -104,15 +103,17 @@ export class QualityReportComponent implements OnInit, OnDestroy {
this.buttonDisabled = true;
this.subscriptionGenerateQB = this.qualityReportService.generateQB(this.selectedTemplate, this.importTemplate).subscribe({
next: (response:QBResponse) => {
const url = new URL(response.responseUrl)
const url = new URL(response.responseUrl);
const id = url.searchParams.get("report-id");
this.qbStatus = QBStatus.RUNNING
this.qbStatus = QBStatus.RUNNING;
if (id) {
this.pollingStatusAndLogs(id, false);
}
},
error: (error) => {
console.log(error);
this.buttonDisabled = false;
this.qbStatus = QBStatus.ERROR;
},
complete: () => {}
});
Expand Down Expand Up @@ -233,7 +234,7 @@ export class QualityReportComponent implements OnInit, OnDestroy {
templateList.forEach((template) => {
this.templateIDs.push({value: template, display: template})
})
this.templateIDs.push({value: "custom", display:"Eigenes Template"})
this.templateIDs.push({value: "custom", display:$localize`Eigenes Template`})
},
error: (error) => {
console.log(error);
Expand All @@ -251,4 +252,8 @@ export class QualityReportComponent implements OnInit, OnDestroy {
downloadTemplate(): void {
window.location.href = this.reportUrl + 'report-template?template-id=' + this.selectedTemplate;
}

changeTemplateSelection(): void {
this.qbStatus = QBStatus.EMPTY;
}
}
9 changes: 9 additions & 0 deletions src/i18n/messages.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,15 @@
<target>link</target>
</segment>
</unit>
<unit id="8722084746247976035">
<notes>
<note category="location">src/app/embedded/quality-report/quality-report.component.ts:237</note>
</notes>
<segment>
<source>Eigenes Template</source>
<target>custom template</target>
</segment>
</unit>
<unit id="6445536054910475490">
<notes>
<note category="location">src/app/embedded/uploads/uploads.component.html:5</note>
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@
<source>Link</source>
</segment>
</unit>
<unit id="8722084746247976035">
<notes>
<note category="location">src/app/embedded/quality-report/quality-report.component.ts:237</note>
</notes>
<segment>
<source>Eigenes Template</source>
</segment>
</unit>
<unit id="6445536054910475490">
<notes>
<note category="location">src/app/embedded/uploads/uploads.component.html:5</note>
Expand Down

0 comments on commit 59d123a

Please sign in to comment.