add file management service
This commit is contained in:
parent
9558a1ed9e
commit
9938a5b276
@ -12,7 +12,7 @@ import {
|
||||
TableColumnConfig,
|
||||
TitleColors,
|
||||
} from '@iqser/common-ui';
|
||||
import { FileManagementControllerService, IFile } from '@redaction/red-ui-http';
|
||||
import { IFile } from '@redaction/red-ui-http';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import * as moment from 'moment';
|
||||
import { ConfigService } from '@services/config.service';
|
||||
@ -22,6 +22,7 @@ import { distinctUntilChanged, map } from 'rxjs/operators';
|
||||
import { DossiersDialogService } from '../../../services/dossiers-dialog.service';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { FileManagementService } from '../../../shared/services/file-management.service';
|
||||
|
||||
interface FileListItem extends IFile, IListable {
|
||||
readonly canRestore: boolean;
|
||||
@ -55,7 +56,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
|
||||
|
||||
constructor(
|
||||
protected readonly _injector: Injector,
|
||||
private readonly _fileManagementController: FileManagementControllerService,
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
private readonly _appStateService: AppStateService,
|
||||
private readonly _filesService: FilesService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
@ -113,7 +114,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
|
||||
|
||||
private async _restore(files: FileListItem[]): Promise<void> {
|
||||
const fileIds = files.map(f => f.fileId);
|
||||
await this._fileManagementController.restoreFiles(fileIds, this.dossier.id).toPromise();
|
||||
await this._fileManagementService.restore(fileIds, this.dossier.id).toPromise();
|
||||
this._removeFromList(fileIds);
|
||||
await this._appStateService.reloadActiveDossierFiles();
|
||||
this.updateDossier.emit();
|
||||
@ -121,7 +122,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
|
||||
|
||||
private async _hardDelete(files: FileListItem[]) {
|
||||
const fileIds = files.map(f => f.fileId);
|
||||
await this._fileManagementController.hardDeleteFile(this.dossier.id, fileIds).toPromise();
|
||||
await this._fileManagementService.hardDelete(this.dossier.id, fileIds).toPromise();
|
||||
this._removeFromList(fileIds);
|
||||
this.updateDossier.emit();
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { FileManagementControllerService, ReanalysisControllerService } from '@redaction/red-ui-http';
|
||||
import { ReanalysisControllerService } from '@redaction/red-ui-http';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { File } from '@models/file/file';
|
||||
import { FileActionService } from '../../../../shared/services/file-action.service';
|
||||
@ -10,8 +10,9 @@ import { CircleButtonTypes, ConfirmationDialogInput, ListingService, LoadingServ
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { Dossier } from '@state/model/dossier';
|
||||
import { LongPressEvent } from '../../../../../shared/directives/long-press.directive';
|
||||
import { UserPreferenceService } from '../../../../../../services/user-preference.service';
|
||||
import { LongPressEvent } from '@shared/directives/long-press.directive';
|
||||
import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { FileManagementService } from '../../../../shared/services/file-management.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossier-overview-bulk-actions',
|
||||
@ -29,7 +30,7 @@ export class DossierOverviewBulkActionsComponent {
|
||||
constructor(
|
||||
private readonly _appStateService: AppStateService,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _fileManagementControllerService: FileManagementControllerService,
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
private readonly _reanalysisControllerService: ReanalysisControllerService,
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
private readonly _fileActionService: FileActionService,
|
||||
@ -134,8 +135,8 @@ export class DossierOverviewBulkActionsComponent {
|
||||
}),
|
||||
async () => {
|
||||
this._loadingService.start();
|
||||
await this._fileManagementControllerService
|
||||
.deleteFiles(
|
||||
await this._fileManagementService
|
||||
.delete(
|
||||
this.selectedFiles.map(item => item.fileId),
|
||||
this.dossier.dossierId,
|
||||
)
|
||||
|
||||
@ -28,7 +28,7 @@ import { PermissionsService } from '@services/permissions.service';
|
||||
import { timer } from 'rxjs';
|
||||
import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { FileManagementControllerService, FileStatus, List } from '@redaction/red-ui-http';
|
||||
import { FileStatus, List } from '@redaction/red-ui-http';
|
||||
import { PdfViewerDataService } from '../../services/pdf-viewer-data.service';
|
||||
import { download } from '@utils/file-download-utils';
|
||||
import { ViewMode } from '@models/file/view-mode';
|
||||
@ -44,6 +44,7 @@ import { User } from '@models/user';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { Dossier } from '@state/model/dossier';
|
||||
import { FileManagementService } from '../../shared/services/file-management.service';
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
const ALL_HOTKEY_ARRAY = ['Escape', 'F', 'f'];
|
||||
@ -99,7 +100,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
private readonly _fileDownloadService: PdfViewerDataService,
|
||||
private readonly _filesService: FilesService,
|
||||
private readonly _ngZone: NgZone,
|
||||
private readonly _fileManagementControllerService: FileManagementControllerService,
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _filterService: FilterService,
|
||||
private readonly _translateService: TranslateService,
|
||||
@ -515,8 +516,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
downloadOriginalFile() {
|
||||
this.addSubscription = this._fileManagementControllerService
|
||||
.downloadOriginalFile(this.fileData.file.dossierId, this.fileId, true, this.fileData.file.cacheIdentifier, 'response')
|
||||
this.addSubscription = this._fileManagementService
|
||||
.downloadOriginalFile(this.fileData.file.dossierId, this.fileId, 'response', true, this.fileData.file.cacheIdentifier)
|
||||
.subscribe(data => {
|
||||
download(data, this.fileData.file.filename);
|
||||
});
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { forkJoin, Observable, of } from 'rxjs';
|
||||
import { catchError, map, tap } from 'rxjs/operators';
|
||||
import {
|
||||
FileManagementControllerService,
|
||||
ManualRedactionControllerService,
|
||||
RedactionLogControllerService,
|
||||
ViewedPagesControllerService,
|
||||
} from '@redaction/red-ui-http';
|
||||
import { ManualRedactionControllerService, RedactionLogControllerService, ViewedPagesControllerService } from '@redaction/red-ui-http';
|
||||
import { FileDataModel } from '@models/file/file-data.model';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { File } from '@models/file/file';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { FileManagementService } from '../shared/services/file-management.service';
|
||||
|
||||
@Injectable()
|
||||
export class PdfViewerDataService {
|
||||
@ -20,7 +16,7 @@ export class PdfViewerDataService {
|
||||
private readonly _dossiersService: DossiersService,
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
private readonly _man: ManualRedactionControllerService,
|
||||
private readonly _fileManagementControllerService: FileManagementControllerService,
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
private readonly _redactionLogControllerService: RedactionLogControllerService,
|
||||
private readonly _viewedPagesControllerService: ViewedPagesControllerService,
|
||||
) {}
|
||||
@ -56,6 +52,6 @@ export class PdfViewerDataService {
|
||||
}
|
||||
|
||||
downloadOriginalFile(file: File): Observable<any> {
|
||||
return this._fileManagementControllerService.downloadOriginalFile(file.dossierId, file.fileId, true, file.cacheIdentifier, 'body');
|
||||
return this._fileManagementService.downloadOriginalFile(file.dossierId, file.fileId, 'body', true, file.cacheIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import {
|
||||
StatusBarConfig,
|
||||
Toaster,
|
||||
} from '@iqser/common-ui';
|
||||
import { FileManagementControllerService, FileStatus } from '@redaction/red-ui-http';
|
||||
import { FileStatus } from '@redaction/red-ui-http';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { filter } from 'rxjs/operators';
|
||||
@ -21,6 +21,7 @@ import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { LongPressEvent } from '@shared/directives/long-press.directive';
|
||||
import { FileActionService } from '../../services/file-action.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { FileManagementService } from '../../services/file-management.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-file-actions',
|
||||
@ -66,7 +67,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _fileActionService: FileActionService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _fileManagementControllerService: FileManagementControllerService,
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
private readonly _userService: UserService,
|
||||
private readonly _toaster: Toaster,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
@ -135,8 +136,8 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
|
||||
}),
|
||||
async () => {
|
||||
this._loadingService.start();
|
||||
await this._fileManagementControllerService
|
||||
.deleteFiles([this.file.fileId], this.file.dossierId)
|
||||
await this._fileManagementService
|
||||
.delete([this.file.fileId], this.file.dossierId)
|
||||
.toPromise()
|
||||
.catch(error => {
|
||||
this._toaster.error(_('error.http.generic'), { params: error });
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
import { GenericService, List, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { HeadersConfiguration } from '../../../../../../../../libs/common-ui/src/lib/utils/headers-configuration';
|
||||
import { HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class FileManagementService extends GenericService<unknown> {
|
||||
constructor(protected readonly _injector: Injector) {
|
||||
super(_injector, '');
|
||||
}
|
||||
|
||||
@Validate()
|
||||
delete(@RequiredParam() body: List, @RequiredParam() dossierId: string) {
|
||||
return super._post(body, `delete/${dossierId}`);
|
||||
}
|
||||
|
||||
@Validate()
|
||||
hardDelete(@RequiredParam() dossierId: string, @RequiredParam() fileIds: List) {
|
||||
const queryParams = fileIds.map<QueryParam>(id => ({ key: 'fileIds', value: id }));
|
||||
return super.delete({}, `delete/hard-delete/${dossierId}`, queryParams);
|
||||
}
|
||||
|
||||
@Validate()
|
||||
restore(@RequiredParam() body: List, @RequiredParam() dossierId: string) {
|
||||
return this._post(body, `delete/restore/${dossierId}`);
|
||||
}
|
||||
|
||||
downloadOriginalFile(dossierId: string, fileId: string, observe?: 'body', inline?: boolean, indicator?: string): Observable<Blob>;
|
||||
downloadOriginalFile(
|
||||
dossierId: string,
|
||||
fileId: string,
|
||||
observe?: 'response',
|
||||
inline?: boolean,
|
||||
indicator?: string,
|
||||
): Observable<HttpResponse<Blob>>;
|
||||
@Validate()
|
||||
downloadOriginalFile(
|
||||
@RequiredParam() dossierId: string,
|
||||
@RequiredParam() fileId: string,
|
||||
observe: 'body' | 'response' = 'body',
|
||||
inline?: boolean,
|
||||
indicator?: string,
|
||||
) {
|
||||
const queryParams: QueryParam[] = [];
|
||||
if (inline) {
|
||||
queryParams.push({ key: 'inline', value: inline });
|
||||
}
|
||||
|
||||
if (indicator) {
|
||||
queryParams.push({ key: 'indicator', value: indicator });
|
||||
}
|
||||
|
||||
let headers = new HttpHeaders();
|
||||
const httpHeaderAcceptSelected = HeadersConfiguration.selectHeaderAccept(['*/*']);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
return this._http.request('get', `/download/original/${encodeURIComponent(dossierId)}/${encodeURIComponent(fileId)}`, {
|
||||
responseType: 'blob',
|
||||
params: this._queryParams(queryParams),
|
||||
headers: headers,
|
||||
observe: observe,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1 +1 @@
|
||||
Subproject commit 3d3af39881ddc9589042d913180e17ae62928da1
|
||||
Subproject commit c16328aa38adcbe68fd20cda2512308ccb8f36f0
|
||||
@ -1,7 +1,6 @@
|
||||
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
|
||||
import { Configuration } from './configuration';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { FileManagementControllerService } from './api/fileManagementController.service';
|
||||
import { GeneralSettingsControllerService } from './api/generalSettingsController.service';
|
||||
import { InfoControllerService } from './api/infoController.service';
|
||||
import { LicenseReportControllerService } from './api/licenseReportController.service';
|
||||
@ -24,7 +23,6 @@ import { StatusReportControllerService } from './api/statusReportController.serv
|
||||
declarations: [],
|
||||
exports: [],
|
||||
providers: [
|
||||
FileManagementControllerService,
|
||||
GeneralSettingsControllerService,
|
||||
InfoControllerService,
|
||||
LicenseReportControllerService,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user