From f5e765adff1e7b32250eb503c9724a4ac99117f3 Mon Sep 17 00:00:00 2001 From: Sophie Zhang Date: Mon, 18 Sep 2023 17:39:20 -0400 Subject: prepare merge --- src/client/util/reportManager/ReportManager.tsx | 1 + src/client/util/reportManager/reportManagerUtils.ts | 1 + 2 files changed, 2 insertions(+) (limited to 'src/client/util') diff --git a/src/client/util/reportManager/ReportManager.tsx b/src/client/util/reportManager/ReportManager.tsx index e684bd637..e6de410a7 100644 --- a/src/client/util/reportManager/ReportManager.tsx +++ b/src/client/util/reportManager/ReportManager.tsx @@ -128,6 +128,7 @@ export class ReportManager extends React.Component<{}> { let formattedLinks: string[] = []; if (this.formData.mediaFiles.length > 0) { const links = await uploadFilesToServer(this.formData.mediaFiles); + console.log('Links', links); if (links) { formattedLinks = links; } diff --git a/src/client/util/reportManager/reportManagerUtils.ts b/src/client/util/reportManager/reportManagerUtils.ts index b95417aa1..1bbb60f7a 100644 --- a/src/client/util/reportManager/reportManagerUtils.ts +++ b/src/client/util/reportManager/reportManagerUtils.ts @@ -111,6 +111,7 @@ export const uploadFilesToServer = async (mediaFiles: FileData[]): Promise ({ file: file.file }))); + console.log('Raw links', links); return (links ?? []).map(getServerPath).map(fileLinktoServerLink); } catch (err) { if (err instanceof Error) { -- cgit v1.2.3-70-g09d2 From 0d6c1aa1869963e548374c634a65b27f0ea32de9 Mon Sep 17 00:00:00 2001 From: Sophie Zhang Date: Thu, 21 Sep 2023 13:24:03 -0400 Subject: fix non-image (video still broken) --- src/client/util/reportManager/reportManagerUtils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/client/util') diff --git a/src/client/util/reportManager/reportManagerUtils.ts b/src/client/util/reportManager/reportManagerUtils.ts index 1bbb60f7a..948229442 100644 --- a/src/client/util/reportManager/reportManagerUtils.ts +++ b/src/client/util/reportManager/reportManagerUtils.ts @@ -89,7 +89,13 @@ export const fileLinktoServerLink = (fileLink: string): string => { const regex = 'public'; const publicIndex = fileLink.indexOf(regex) + regex.length; - const finalUrl = `${serverUrl}${fileLink.substring(publicIndex + 1).replace('.', '_l.')}`; + let finalUrl: string = ''; + if (fileLink.includes('.png') || fileLink.includes('.jpg') || fileLink.includes('.jpeg') || fileLink.includes('.gif')) { + finalUrl = `${serverUrl}${fileLink.substring(publicIndex + 1).replace('.', '_l.')}`; + } else { + finalUrl = `${serverUrl}${fileLink.substring(publicIndex + 1)}`; + } + return finalUrl; }; @@ -108,6 +114,7 @@ export const getServerPath = (link: any): string => { * @returns the server paths or undefined on error */ export const uploadFilesToServer = async (mediaFiles: FileData[]): Promise => { + console.log(mediaFiles); try { // need to always upload to browndash const links = await Networking.UploadFilesToServer(mediaFiles.map(file => ({ file: file.file }))); -- cgit v1.2.3-70-g09d2 From 51d74db190ba898af9f62906ccfd1da097330fb4 Mon Sep 17 00:00:00 2001 From: Sophie Zhang Date: Fri, 22 Sep 2023 03:14:03 -0400 Subject: fix: fix report manager for videos, only add _l suffix for images --- src/client/util/reportManager/ReportManager.tsx | 28 +++++++--------------- .../util/reportManager/reportManagerUtils.ts | 3 --- src/server/ApiManagers/UploadManager.ts | 9 +++---- 3 files changed, 14 insertions(+), 26 deletions(-) (limited to 'src/client/util') diff --git a/src/client/util/reportManager/ReportManager.tsx b/src/client/util/reportManager/ReportManager.tsx index 802a2f09f..e8c69f909 100644 --- a/src/client/util/reportManager/ReportManager.tsx +++ b/src/client/util/reportManager/ReportManager.tsx @@ -333,25 +333,15 @@ export class ReportManager extends React.Component<{}> { fillWidth /> - - {({ getRootProps, getInputProps }) => ( -
- -
- -

Drop or select media that shows the bug (optional)

-
-
- )} -
+ { + if (!e.target.files) return; + this.setFormData({ ...this.formData, mediaFiles: [...this.formData.mediaFiles, ...Array.from(e.target.files).map(file => ({ _id: v4(), file }))] }); + }} + /> {this.formData.mediaFiles.length > 0 &&
    {this.formData.mediaFiles.map(file => this.getMediaPreview(file))}
} {this.submitting ? (