Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#45772] fix PR comments

Eric Schubertcf1bfe07bd0b
diff --git a/frontend/src/app/core/file-upload/op-direct-file-upload.service.ts b/frontend/src/app/core/file-upload/op-direct-file-upload.service.ts
index 6c9d31912a2..830197d91cd 100644
--- a/frontend/src/app/core/file-upload/op-direct-file-upload.service.ts
+++ b/frontend/src/app/core/file-upload/op-direct-file-upload.service.ts
@@ -26,16 +26,17 @@
// See COPYRIGHT and LICENSE files for more details.
//++
+import { getType } from 'mime';
import { Injectable } from '@angular/core';
import { HttpEvent, HttpResponse } from '@angular/common/http';
import { from, Observable, of } from 'rxjs';
import { share, switchMap } from 'rxjs/operators';
+
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import { getType } from 'mime';
+import { EXTERNAL_REQUEST_HEADER } from 'core-app/features/hal/http/openproject-header-interceptor';
import {
OpenProjectFileUploadService, UploadBlob, UploadFile, UploadInProgress,
} from './op-file-upload.service';
-import { EXTERNAL_REQUEST_HEADER } from "core-app/features/hal/http/openproject-header-interceptor";
interface PrepareUploadResult {
url:string;
@@ -53,21 +54,18 @@ interface PrepareUploadResult {
export class OpenProjectDirectFileUploadService extends OpenProjectFileUploadService {
/**
* Upload a single file, get an UploadResult observable
- * @param {string} url
- * @param {UploadFile} file
- * @param {string} method
*/
- public uploadSingle(url:string, file:UploadFile|UploadBlob, method = 'post', responseType:'text'|'json' = 'text') {
+ public uploadSingle(url:string, file:UploadFile|UploadBlob, method = 'post') {
const observable = from(this.getDirectUploadFormFrom(url, file))
.pipe(
- switchMap(this.uploadToExternal(file, method, responseType)),
+ switchMap(this.uploadToExternal(file, method)),
share(),
);
return [file, observable] as UploadInProgress;
}
- private uploadToExternal(file:UploadFile|UploadBlob, method:string, responseType:string):(result:PrepareUploadResult) => Observable<HttpEvent<unknown>> {
+ private uploadToExternal(file:UploadFile|UploadBlob, method:string):(result:PrepareUploadResult) => Observable<HttpEvent<unknown>> {
return (result) => {
result.form.append('file', file, file.customName || file.name);
@@ -83,7 +81,7 @@ export class OpenProjectDirectFileUploadService extends OpenProjectFileUploadSer
headers: {
[EXTERNAL_REQUEST_HEADER]: 'true',
},
- responseType: responseType as 'json',
+ responseType: 'json',
// Subscribe to progress events. subscribe() will fire multiple times!
reportProgress: true,
},
diff --git a/frontend/src/app/core/file-upload/op-file-upload.service.ts b/frontend/src/app/core/file-upload/op-file-upload.service.ts
index c8a82614ece..31c34c8f6cc 100644
--- a/frontend/src/app/core/file-upload/op-file-upload.service.ts
+++ b/frontend/src/app/core/file-upload/op-file-upload.service.ts
@@ -72,17 +72,13 @@ export class OpenProjectFileUploadService {
/**
* Upload multiple files and return a promise for each uploading file and a single promise for all processed uploads
* with their accessible URLs returned.
- * @param {string} url
- * @param {UploadFile[]} files
- * @param {string} method
- * @returns {Promise<{response:HalResource; uploadUrl:any}[]>}
*/
- public uploadAndMapResponse(url:string, files:UploadFile[], method = 'post') {
+ public uploadAndMapResponse(url:string, files:UploadFile[]):MappedUploadResult {
const { uploads, finished } = this.upload(url, files);
const mapped = finished
- .then((result:HalResource[]) => result.map((el:HalResource) => ({
- response: el,
- uploadUrl: (el.staticDownloadLocation as unknown&{ href:string }).href,
+ .then((result:HalResource[]) => result.map((element:HalResource) => ({
+ response: element,
+ uploadUrl: (element.staticDownloadLocation as unknown&{ href:string }).href,
}))) as Promise<{ response:HalResource, uploadUrl:string }[]>;
return { uploads, finished: mapped } as MappedUploadResult;
@@ -102,12 +98,12 @@ export class OpenProjectFileUploadService {
/**
* Upload a single file, get an UploadResult observable
- * @param {string} url
- * @param {UploadFile} file
- * @param {string} method
- * @param {'text'|'json'} responseType
*/
- public uploadSingle(url:string, file:UploadFile|UploadBlob, method = 'post', responseType:'text'|'json' = 'json') {
+ public uploadSingle(
+ url:string,
+ file:UploadFile|UploadBlob,
+ method = 'post',
+ ):UploadInProgress {
const formData = new FormData();
const metadata = {
description: file.description,
@@ -131,7 +127,7 @@ export class OpenProjectFileUploadService {
// Observe the response, not the body
observe: 'events',
withCredentials: true,
- responseType: responseType as any,
+ responseType: 'json',
// Subscribe to progress events. subscribe() will fire multiple times!
reportProgress: true,
},
diff --git a/frontend/src/app/core/state/attachments/attachments.service.ts b/frontend/src/app/core/state/attachments/attachments.service.ts
index 5115e648df2..ec7d6c18b10 100644
--- a/frontend/src/app/core/state/attachments/attachments.service.ts
+++ b/frontend/src/app/core/state/attachments/attachments.service.ts
@@ -28,7 +28,6 @@
import { Injectable } from '@angular/core';
import {
- HttpClient,
HttpHeaders,
} from '@angular/common/http';
import { applyTransaction } from '@datorama/akita';
@@ -52,7 +51,6 @@ import {
import { OpenProjectDirectFileUploadService } from 'core-app/core/file-upload/op-direct-file-upload.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { HalLink } from 'core-app/features/hal/hal-link/hal-link';
import isNewResource, { HAL_NEW_RESOURCE_ID } from 'core-app/features/hal/helpers/is-new-resource';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
diff --git a/frontend/src/app/shared/components/toaster/upload-progress.component.ts b/frontend/src/app/shared/components/toaster/upload-progress.component.ts
index f20a3f0d925..044b3d4d916 100644
--- a/frontend/src/app/shared/components/toaster/upload-progress.component.ts
+++ b/frontend/src/app/shared/components/toaster/upload-progress.component.ts
@@ -116,7 +116,7 @@ export class UploadProgressComponent extends UntilDestroyedMixin implements OnIn
this.uploadSuccess.emit();
break;
default:
- // unknown event
+ console.warn(`unknown event type: ${evt.type}`);
}
},
(error:HttpErrorResponse) => this.handleError(error),
diff --git a/modules/avatars/frontend/module/avatar-upload-form/avatar-upload-form.component.ts b/modules/avatars/frontend/module/avatar-upload-form/avatar-upload-form.component.ts
index 039962458ef..f07efce52c0 100644
--- a/modules/avatars/frontend/module/avatar-upload-form/avatar-upload-form.component.ts
+++ b/modules/avatars/frontend/module/avatar-upload-form/avatar-upload-form.component.ts
@@ -95,7 +95,7 @@ export class AvatarUploadFormComponent implements OnInit {
public uploadAvatar(evt:Event) {
evt.preventDefault();
this.busy = true;
- const upload = this.opFileUpload.uploadSingle(this.target, this.avatarFile, this.method, 'text');
+ const upload = this.opFileUpload.uploadSingle(this.target, this.avatarFile, this.method);
this.toastService.addAttachmentUpload(this.text.uploading, [upload]);
upload[1].subscribe(