Skip to content
Snippets Groups Projects
Commit 09dcc5ff authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #11698 TIME 0:20 add loader loadtmpfile

parent 68125a14
No related branches found
No related tags found
No related merge requests found
......@@ -214,8 +214,8 @@ $app->get('/groups/{id}/details', \Group\controllers\GroupController::class . ':
$app->get('/groups/{id}/indexing', \Group\controllers\GroupController::class . ':getIndexingInformationsById');
$app->put('/groups/{id}/indexing', \Group\controllers\GroupController::class . ':updateIndexingInformations');
$app->put('/groups/{id}/reassign/{newGroupId}', \Group\controllers\GroupController::class . ':reassignUsers');
$app->post('/groups/{id}/add/{privilegeId}', \Group\controllers\ServiceController::class . ':addPrivilege');
$app->delete('/groups/{id}/remove/{privilegeId}', \Group\controllers\ServiceController::class . ':removePrivilege');
$app->post('/groups/{id}/privileges/{privilegeId}', \Group\controllers\ServiceController::class . ':addPrivilege');
$app->delete('/groups/{id}/privileges/{privilegeId}', \Group\controllers\ServiceController::class . ':removePrivilege');
//Histories
$app->get('/histories', \History\controllers\HistoryController::class . ':get');
......
......@@ -115,24 +115,31 @@ export class DocumentViewerComponent implements OnInit {
}
loadTmpFile(filenameOnTmp: string) {
this.http.get(`../../rest/convertedFile/${filenameOnTmp}`, { params: { convert: 'true'}}).pipe(
tap((data: any) => {
this.file = {
name: filenameOnTmp,
format: data.extension,
type: data.type,
content: data.encodedResource,
src: this.base64ToArrayBuffer(data.encodedConvertedResource)
};
this.editMode = true;
this.noConvertedFound = false;
this.loading = false;
}),
catchError((err: any) => {
this.loading = true;
this.loadingInfo.mode = 'determinate';
this.requestWithLoader(`../../rest/convertedFile/${filenameOnTmp}?convert=true`).subscribe(
(data: any) => {
if (data.encodedResource) {
this.file = {
name: filenameOnTmp,
format: data.extension,
type: data.type,
content: data.encodedResource,
src: this.base64ToArrayBuffer(data.encodedConvertedResource)
};
this.editMode = true;
this.noConvertedFound = false;
this.loading = false;
}
},
(err: any) => {
this.noConvertedFound = true;
this.notify.handleErrors(err);
this.loading = false;
return of(false);
})
).subscribe();
}
);
}
uploadTrigger(fileInput: any) {
......@@ -278,6 +285,32 @@ export class DocumentViewerComponent implements OnInit {
);
}
requestWithLoader(url: string) {
this.loadingInfo.percent = 0;
return this.http.get<any>(url, {
reportProgress: true,
observe: 'events'
}).pipe(map((event) => {
switch (event.type) {
case HttpEventType.DownloadProgress:
const downloadProgress = Math.round(100 * event.loaded / event.total);
this.loadingInfo.percent = downloadProgress;
this.loadingInfo.mode = 'determinate';
this.loadingInfo.message = ``;
return { status: 'progressDownload', message: downloadProgress };
case HttpEventType.Response:
return event.body;
default:
return `Unhandled event: ${event.type}`;
}
})
);
}
onError(error: any) {
console.log(error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment