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