app name and flat file download, minor bugfix

This commit is contained in:
Timo 2021-01-21 14:19:46 +02:00
parent 6f5b6c76f2
commit f3a3b00e95
14 changed files with 108 additions and 11 deletions

View File

@ -5,7 +5,7 @@
To regnerate http rune swaagger
```
BASE=https://timo-redaction-dev.iqser.cloud/
BASE=https://redapi-staging.iqser.cloud/
URL="$BASE"v2/api-docs?group=redaction-gateway-v1
mkdir -p /tmp/swagger
swagger-codegen generate -i "$URL" -l typescript-angular -o /tmp/swagger

View File

@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { tap } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { Title } from '@angular/platform-browser';
export enum AppConfigKey {
OAUTH_URL = 'OAUTH_URL',
@ -10,7 +11,8 @@ export enum AppConfigKey {
ADMIN_CONTACT_NAME = 'ADMIN_CONTACT_NAME',
ADMIN_CONTACT_URL = 'ADMIN_CONTACT_URL',
AUTO_READ_TIME = 'AUTO_READ_TIME',
MAX_FILE_SIZE_MB = 'MAX_FILE_SIZE_MB'
MAX_FILE_SIZE_MB = 'MAX_FILE_SIZE_MB',
APP_NAME = 'APP_NAME'
}
@Injectable({
@ -19,18 +21,19 @@ export enum AppConfigKey {
export class AppConfigService {
private _config: { [key in AppConfigKey]?: any } = {};
constructor(private readonly _httpClient: HttpClient) {}
constructor(private readonly _httpClient: HttpClient, private readonly _titleService: Title) {}
loadAppConfig(): Observable<any> {
return this._httpClient.get<any>('/assets/config/config.json').pipe(
tap((config) => {
console.log('[REDACTION] Started with config: ', config);
this._config = config;
this._titleService.setTitle(this.getConfig(AppConfigKey.APP_NAME, 'DDA-R'));
})
);
}
getConfig(key: AppConfigKey, defaultValue?: any) {
getConfig(key: AppConfigKey | string, defaultValue?: any) {
return this._config[key] ? this._config[key] : defaultValue;
}
}

View File

@ -16,4 +16,7 @@
<div (click)="downloadRedactedFiles($event)" mat-menu-item>
<div [translate]="'project-overview.download-redacted-file'"></div>
</div>
<div (click)="downloadFlatRedactedFiles($event)" mat-menu-item *ngIf="canDownloadFlatRedactedFile">
<div [translate]="'project-overview.download-flat-redacted-file'"></div>
</div>
</mat-menu>

View File

@ -7,6 +7,7 @@ import { StatusOverlayService } from '../../../upload-download/status-overlay.se
import { FileDownloadService } from '../../../upload-download/file-download.service';
import { SingleFileDownloadService } from '../../../screens/file/service/single-file-download.service';
import { saveAs } from 'file-saver';
import { UserPreferenceService } from '../../../common/service/user-preference.service';
export type MenuState = 'OPEN' | 'CLOSED';
@ -28,6 +29,7 @@ export class FileDownloadBtnComponent {
private readonly _permissionsService: PermissionsService,
private readonly _fileDownloadService: FileDownloadService,
private readonly _singleFileDownloadService: SingleFileDownloadService,
private readonly _userPreferencesService: UserPreferenceService,
private readonly _changeDetectorRef: ChangeDetectorRef,
private readonly _statusOverlayService: StatusOverlayService,
private readonly _fileManagementControllerService: FileManagementControllerService
@ -83,4 +85,14 @@ export class FileDownloadBtnComponent {
this._singleFileDownloadService.loadFile('REDACTED', this.file).subscribe((data) => saveAs(data, (<FileStatusWrapper>this.file).filename));
}
}
get canDownloadFlatRedactedFile() {
return this._userPreferencesService.areDevFeaturesEnabled && !Array.isArray(this.file);
}
downloadFlatRedactedFiles($event: MouseEvent) {
this._singleFileDownloadService
.loadFile('FLAT_REDACTED', <FileStatusWrapper>this.file)
.subscribe((data) => saveAs(data, (<FileStatusWrapper>this.file).filename));
}
}

View File

@ -64,7 +64,7 @@
<redaction-hidden-action (action)="userPreferenceService.toggleDevFeatures()">
<redaction-logo></redaction-logo>
</redaction-hidden-action>
<div class="app-name" translate="app-name"></div>
<div class="app-name">{{ titleService.getTitle() }}</div>
<span class="dev-mode" *ngIf="userPreferenceService.areDevFeaturesEnabled" translate="dev-mode"></span>
</div>
<div class="menu right flex-2">

View File

@ -5,6 +5,8 @@ import { LanguageService } from '../../i18n/language.service';
import { PermissionsService } from '../../common/service/permissions.service';
import { UserPreferenceService } from '../../common/service/user-preference.service';
import { Router } from '@angular/router';
import { AppConfigKey, AppConfigService } from '../../app-config/app-config.service';
import { Title } from '@angular/platform-browser';
@Component({
selector: 'redaction-base-screen',
@ -14,10 +16,16 @@ import { Router } from '@angular/router';
export class BaseScreenComponent {
private _projectsView: boolean;
get user() {
return this._userService.user;
}
constructor(
public readonly appStateService: AppStateService,
public readonly permissionsService: PermissionsService,
public readonly userPreferenceService: UserPreferenceService,
public readonly titleService: Title,
private readonly _appConfigService: AppConfigService,
private readonly _router: Router,
private readonly _languageService: LanguageService,
private readonly _userService: UserService
@ -27,10 +35,6 @@ export class BaseScreenComponent {
});
}
get user() {
return this._userService.user;
}
get projectsView() {
return this._projectsView;
}

View File

@ -1,5 +1,6 @@
export enum FileType {
ORIGINAL = 'ORIGINAL',
ANNOTATED = 'ANNOTATED',
REDACTED = 'REDACTED'
REDACTED = 'REDACTED',
FLAT_REDACTED = 'FLAT_REDACTED'
}

View File

@ -78,6 +78,15 @@ export class SingleFileDownloadService {
})
);
break;
case FileType.FLAT_REDACTED:
fileObs$ = fetch()
? of(fetch())
: this._fileManagementControllerService.downloadFlatRedacted(fileStatus.fileId, true, fileStatus.lastProcessed, 'body').pipe(
tap((data) => {
saveTo(data);
})
);
break;
case FileType.ORIGINAL:
default:
fileObs$ = fetch()

View File

@ -118,6 +118,7 @@
},
"download-file": "Dateien herunterladen)",
"download-redacted-file": "Heruntergeladene Datei (en) herunterladen",
"download-flat-redacted-file": "Laden Sie Flat Redacted File (s) herunter",
"download-redacted-file-preview": "Laden Sie die Vorschau der redigierten Datei (en) herunter",
"under-approval": "Zur Genehmigung",
"approve": "Genehmigen",

View File

@ -199,6 +199,7 @@
},
"download-file": "Download File(s)",
"download-redacted-file": "Download Redacted File(s)",
"download-flat-redacted-file": "Download Flat Redacted File(s)",
"download-redacted-file-preview": "Download Redacted File(s) Preview",
"under-approval": "For Approval",
"approve": "Approve",

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>DDA-R</title>
<title>...</title>
<base href="/" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="favicon.ico" rel="icon" type="image/x-icon" />

View File

@ -2,6 +2,7 @@
OAUTH_CLIENT_ID="${OAUTH_CLIENT_ID:-gin-client}"
OAUTH_URL="${OAUTH_URL:-https://keycloak-dev.iqser.cloud/auth/realms/dev}"
APP_NAME="${APP_NAME:-DDA-R}"
API_URL="${API_URL:-}"
ADMIN_CONTACT_NAME="${ADMIN_CONTACT_NAME:-}"
ADMIN_CONTACT_URL="${ADMIN_CONTACT_URL:-}"
@ -14,6 +15,7 @@ echo '{
"OAUTH_URL":"'"$OAUTH_URL"'",
"ADMIN_CONTACT_NAME":"'"$ADMIN_CONTACT_NAME"'",
"ADMIN_CONTACT_URL":"'"$ADMIN_CONTACT_URL"'",
"APP_NAME":"'"$APP_NAME"'",
"AUTO_READ_TIME":'"$AUTO_READ_TIME"',
"MAX_FILE_SIZE_MB":'"$MAX_FILE_SIZE_MB"',
"API_URL":"'"$API_URL"'"

View File

@ -278,6 +278,64 @@ export class FileManagementControllerService {
});
}
/**
* Returns a downloadable byte stream of the fatted redacted file with the specified fileId
* Use the optional \&quot;inline\&quot; request parameter to select, if this file will be opened in the browser.
* @param fileId fileId
* @param inline inline
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public downloadFlatRedacted(fileId: string, inline?: boolean, indicator?: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public downloadFlatRedacted(
fileId: string,
inline?: boolean,
indicator?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public downloadFlatRedacted(fileId: string, inline?: boolean, indicator?: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
public downloadFlatRedacted(fileId: string, inline?: boolean, indicator?: string, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
if (fileId === null || fileId === undefined) {
throw new Error('Required parameter fileId was null or undefined when calling downloadFlatRedacted.');
}
let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
if (inline !== undefined && inline !== null) {
queryParameters = queryParameters.set('inline', <any>inline);
}
if (indicator !== undefined && indicator !== null) {
queryParameters = queryParameters.set('indicator', <any>indicator);
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
let httpHeaderAccepts: string[] = ['*/*'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = [];
return this.httpClient.request('get', `${this.basePath}/download/flatted/${encodeURIComponent(String(fileId))}`, {
responseType: 'blob',
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Returns a downloadable byte stream of the annotated file with the specified fileId
* Use the optional \&quot;inline\&quot; request parameter to select, if this downloadAnnotated will be opened in the browser.

View File

@ -533,3 +533,6 @@ Select from the list below.|Noch keine Mitglieder. Wählen Sie aus der folgenden
Failed to add redaction: {{message}}|Fehler beim Hinzufügen der Redaktion: {{message}}
Remove Redaction|Redaktion entfernen
Are you sure you wish to remove this redaction?|Möchten Sie diese Redaktion wirklich entfernen?
Download Flat Redacted File(s)|Laden Sie Flat Redacted File (s) herunter
No members yet.
Select from the list below.|Noch keine Mitglieder. Wählen Sie aus der folgenden Liste.