From 95881194fe43524f01d0ea842bc69084c28b4cd7 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:19:10 +0700 Subject: [PATCH 01/28] fix: type --- Services/client/src/stores/storage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Services/client/src/stores/storage.ts b/Services/client/src/stores/storage.ts index be7b9e5..5502545 100644 --- a/Services/client/src/stores/storage.ts +++ b/Services/client/src/stores/storage.ts @@ -27,7 +27,7 @@ export interface StorageFile { title: string description: string author: string - metadata: Record + metadata?: Record category: string[] keyword: string[] updatedAt: string From 9be446922386182d60a6b16ae6441b6deafa4e9c Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:23:56 +0700 Subject: [PATCH 02/28] fix: type-check error --- .../src/modules/01_user/components/FileDownload.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Services/client/src/modules/01_user/components/FileDownload.vue b/Services/client/src/modules/01_user/components/FileDownload.vue index cee6f16..eece008 100644 --- a/Services/client/src/modules/01_user/components/FileDownload.vue +++ b/Services/client/src/modules/01_user/components/FileDownload.vue @@ -132,7 +132,9 @@ async function downloadSubmit(path: string | undefined) { ชื่อเรื่อง
- {{ fileInfo?.metadata.subject ?? fileInfo?.title }} + {{ + fileInfo?.metadata?.subject ?? fileInfo?.title + }}
@@ -150,7 +152,9 @@ async function downloadSubmit(path: string | undefined) { เจ้าของผลงาน
- {{ fileInfo?.metadata.author ?? fileInfo?.author }} + {{ + fileInfo?.metadata?.author ?? fileInfo?.author + }}
From 63966186743855d39633df4fc80fe144f34f6640 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:53:33 +0700 Subject: [PATCH 03/28] feat: disable certain field if created from external service --- Services/client/src/components/FileForm.vue | 33 +++++++++++++++++++ .../client/src/components/FileFormWrapper.vue | 8 +++++ Services/client/src/components/FileItem.vue | 1 + .../client/src/components/FileSearched.vue | 1 + 4 files changed, 43 insertions(+) diff --git a/Services/client/src/components/FileForm.vue b/Services/client/src/components/FileForm.vue index c9f545c..8705164 100644 --- a/Services/client/src/components/FileForm.vue +++ b/Services/client/src/components/FileForm.vue @@ -13,6 +13,14 @@ const props = withDefaults( fileExist?: boolean fileName2Long?: boolean } + disableFields?: ( + | 'file' + | 'title' + | 'description' + | 'keyword' + | 'category' + | 'author' + )[] mode: 'create' | 'edit' fileNameLabel?: string title?: string @@ -63,6 +71,25 @@ function reset() { } function submit() { + if (props.mode === 'edit') { + return emit('submit', { + mode: props.mode, + file: props.disableFields?.includes('file') ? undefined : file.value, + title: props.disableFields?.includes('title') ? undefined : props.title, + description: props.disableFields?.includes('description') + ? undefined + : props.description ?? '', + keyword: props.disableFields?.includes('keyword') + ? undefined + : props.keyword, + category: props.disableFields?.includes('category') + ? undefined + : props.category, + author: props.disableFields?.includes('author') + ? undefined + : props.author, + }) + } emit('submit', { mode: props.mode, file: file.value, @@ -168,6 +195,7 @@ const file = ref() ? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้' : '' " + :disable="disableFields?.includes('file')" id="inputFile" :rules="[ (v) => v !== undefined || mode === 'edit' || 'โปรดอัปโหลดไฟล์', @@ -186,6 +214,7 @@ const file = ref() dense class="q-my-sm" placeholder="กรอกชื่อเรื่อง" + :disable="disableFields?.includes('title')" :model-value="title" :rules="[ (v) => @@ -204,6 +233,7 @@ const file = ref() class="q-mt-sm no-resize" type="textarea" placeholder="กรอกรายละเอียด" + :disable="disableFields?.includes('description')" :model-value="description" @update:model-value="(v) => $emit('update:description', v)" id="inputDescription" @@ -224,6 +254,7 @@ const file = ref() multiple input-debounce="0" @new-value="createCategory" + :disable="disableFields?.includes('category')" :options="filterDataCategory" @filter="filterCategory" @update:model-value="(v) => $emit('update:category', v)" @@ -245,6 +276,7 @@ const file = ref() multiple hide-dropdown-icon input-debounce="0" + :disable="disableFields?.includes('keyword')" :model-value="props.keyword" @update:model-value="(v) => $emit('update:keyword', v)" @new-value="createKeyword" @@ -261,6 +293,7 @@ const file = ref() dense class="q-my-sm" placeholder="เจ้าของผลงาน" + :disable="disableFields?.includes('author')" :model-value="author" :rules="[ (v) => diff --git a/Services/client/src/components/FileFormWrapper.vue b/Services/client/src/components/FileFormWrapper.vue index 86198c9..81603f0 100644 --- a/Services/client/src/components/FileFormWrapper.vue +++ b/Services/client/src/components/FileFormWrapper.vue @@ -18,6 +18,7 @@ const fileFormData = ref<{ keyword?: string[] category?: string[] author?: string + metadata?: Record }>({}) const fileFormType = ref<'edit' | 'create'>('create') const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({}) @@ -38,6 +39,7 @@ function triggerFileEdit( keyword: string[] category: string[] author: string + metadata?: Record }, pathname: string, file?: string, @@ -51,6 +53,7 @@ function triggerFileEdit( keyword: value.keyword, category: value.category, author: value.author, + metadata: value.metadata, } fileNameLabel.value = file } @@ -133,6 +136,11 @@ async function submitFileForm( :mode="fileFormType" :error="fileFormError" :fileNameLabel="fileNameLabel" + :disableFields=" + fileFormData.metadata && Object.keys(fileFormData.metadata).length > 1 + ? ['file', 'title', 'author'] + : [] + " v-model:open="fileFormState" v-model:title="fileFormData.title" v-model:description="fileFormData.description" diff --git a/Services/client/src/components/FileItem.vue b/Services/client/src/components/FileItem.vue index aa7fef2..36b921e 100644 --- a/Services/client/src/components/FileItem.vue +++ b/Services/client/src/components/FileItem.vue @@ -247,6 +247,7 @@ function triggerFileDelete(pathname: string) { keyword: value.keyword, category: value.category, author: value.author, + metadata: value.metadata, }, value.pathname, value.fileName, diff --git a/Services/client/src/components/FileSearched.vue b/Services/client/src/components/FileSearched.vue index 36a2f72..f1161bb 100644 --- a/Services/client/src/components/FileSearched.vue +++ b/Services/client/src/components/FileSearched.vue @@ -235,6 +235,7 @@ onMounted(() => { keyword: value.keyword, category: value.category, author: value.author, + metadata: value.metadata, }, value.pathname, value.fileName, From e31e1706e6be763a613ad103ed5fc1bffef8cdb1 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:55:42 +0700 Subject: [PATCH 04/28] fix: wrong condition --- Services/client/src/components/FileFormWrapper.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Services/client/src/components/FileFormWrapper.vue b/Services/client/src/components/FileFormWrapper.vue index 81603f0..e7281f4 100644 --- a/Services/client/src/components/FileFormWrapper.vue +++ b/Services/client/src/components/FileFormWrapper.vue @@ -137,7 +137,7 @@ async function submitFileForm( :error="fileFormError" :fileNameLabel="fileNameLabel" :disableFields=" - fileFormData.metadata && Object.keys(fileFormData.metadata).length > 1 + fileFormData.metadata && Object.keys(fileFormData.metadata).length > 0 ? ['file', 'title', 'author'] : [] " From 4b70a1469db8813ab8b52c4706c2f24865476788 Mon Sep 17 00:00:00 2001 From: puri-ph4tt Date: Fri, 12 Jan 2024 09:32:02 +0700 Subject: [PATCH 05/28] =?UTF-8?q?update:=20=E0=B8=8B=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=E0=B8=9B=E0=B8=B8=E0=B9=88=E0=B8=A1=E0=B8=A5=E0=B8=9A?= =?UTF-8?q?=E0=B8=AB=E0=B8=B2=E0=B8=81=E0=B8=A1=E0=B8=B5=20metadata=20(mod?= =?UTF-8?q?ule,=20list,=20search)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/client/src/components/FileItem.vue | 4 ++++ Services/client/src/components/FileItemAction.vue | 2 ++ Services/client/src/components/FileSearched.vue | 9 +++++++++ Services/client/src/components/ListView.vue | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/Services/client/src/components/FileItem.vue b/Services/client/src/components/FileItem.vue index 36b921e..44f7360 100644 --- a/Services/client/src/components/FileItem.vue +++ b/Services/client/src/components/FileItem.vue @@ -117,6 +117,7 @@ function triggerFileDelete(pathname: string) { > diff --git a/Services/client/src/components/ListView.vue b/Services/client/src/components/ListView.vue index f76619c..296ce0b 100644 --- a/Services/client/src/components/ListView.vue +++ b/Services/client/src/components/ListView.vue @@ -391,6 +391,12 @@ const onRowClick = ((_, row) => { color="negative" icon="mdi-trash-can-outline" @click.stop="() => triggerFileDelete(data.row.pathname)" + v-if=" + !( + data.row.metadata && + Object.keys(data.row.metadata).length > 0 + ) + " data-testid="listViewFileDelete" /> From 5c6768e6d9da73c09450db79c147660165e63063 Mon Sep 17 00:00:00 2001 From: puri-ph4tt Date: Fri, 12 Jan 2024 10:03:24 +0700 Subject: [PATCH 06/28] =?UTF-8?q?update:=20=E0=B9=81=E0=B8=81=E0=B9=89?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=A2=E0=B8=B0=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/client/src/components/FileForm.vue | 102 ++++++++++---------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/Services/client/src/components/FileForm.vue b/Services/client/src/components/FileForm.vue index 8705164..fb40252 100644 --- a/Services/client/src/components/FileForm.vue +++ b/Services/client/src/components/FileForm.vue @@ -173,7 +173,7 @@ const file = ref() /> -
+
อัปโหลดไฟล์ ()
-
+
ชื่อเรื่อง () />
-
+
รายละเอียดของเอกสาร () />
-
- กลุ่ม/หมวดหมู่ -
- - -
-
- -
- คำสำคัญ -
- - -
-
- -
+
เจ้าของผลงาน () />
+
+ กลุ่ม/หมวดหมู่ + + +
+ +
+ คำสำคัญ + + +
+
Date: Fri, 12 Jan 2024 10:11:21 +0700 Subject: [PATCH 07/28] =?UTF-8?q?fix:=20=E0=B9=80=E0=B8=9E=E0=B8=B4?= =?UTF-8?q?=E0=B9=88=E0=B8=A1=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/client/src/components/FileFormWrapper.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Services/client/src/components/FileFormWrapper.vue b/Services/client/src/components/FileFormWrapper.vue index e7281f4..f1bf027 100644 --- a/Services/client/src/components/FileFormWrapper.vue +++ b/Services/client/src/components/FileFormWrapper.vue @@ -48,11 +48,11 @@ function triggerFileEdit( fileFormType.value = 'edit' fileFormPath.value = pathname fileFormData.value = { - title: value.title, + title: (value.metadata?.subject as string) ?? value.title, description: value.description, keyword: value.keyword, category: value.category, - author: value.author, + author: (value.metadata?.author as string) ?? value.author, metadata: value.metadata, } fileNameLabel.value = file From dc859800285564ea9e55694da2dced039a5c0413 Mon Sep 17 00:00:00 2001 From: puri-ph4tt Date: Fri, 12 Jan 2024 10:28:40 +0700 Subject: [PATCH 08/28] =?UTF-8?q?update:=20=E0=B9=81=E0=B8=81=E0=B9=89?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80=E0=B8=A0=E0=B8=97=E0=B8=82?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/client/src/stores/file-info-data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Services/client/src/stores/file-info-data.ts b/Services/client/src/stores/file-info-data.ts index d13bc2f..76965ab 100644 --- a/Services/client/src/stores/file-info-data.ts +++ b/Services/client/src/stores/file-info-data.ts @@ -69,7 +69,7 @@ export const useFileInfoStore = defineStore('info', () => { if (extension) return extension if (fileName && fileName.includes('.')) { - return fileName.substring(fileName.lastIndexOf('.')) + return fileName.substring(fileName.lastIndexOf('.') + 1) } return 'ไม่ทราบประเภท' From acc243a432243ba58f9a17b0d1b691465e6f0901 Mon Sep 17 00:00:00 2001 From: puri-ph4tt Date: Fri, 12 Jan 2024 10:29:29 +0700 Subject: [PATCH 09/28] =?UTF-8?q?update:=20=E0=B9=81=E0=B8=81=E0=B9=89?= =?UTF-8?q?=E0=B8=8B=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B8=9B=E0=B8=B8=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=A5=E0=B8=9A=E0=B8=AB=E0=B8=B2=E0=B8=81=E0=B8=A1?= =?UTF-8?q?=E0=B8=B5=20metadata=20=E0=B9=83=E0=B8=AB=E0=B9=89=E0=B9=80?= =?UTF-8?q?=E0=B8=97=E0=B9=88=E0=B8=B2=E0=B8=81=E0=B8=B1=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/client/src/components/FileSearched.vue | 7 +++++++ Services/client/src/components/ListView.vue | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/Services/client/src/components/FileSearched.vue b/Services/client/src/components/FileSearched.vue index 2a65079..96bd36d 100644 --- a/Services/client/src/components/FileSearched.vue +++ b/Services/client/src/components/FileSearched.vue @@ -365,6 +365,13 @@ onMounted(() => { " id="listViewFileDelete" /> +
diff --git a/Services/client/src/components/ListView.vue b/Services/client/src/components/ListView.vue index 296ce0b..363d0a7 100644 --- a/Services/client/src/components/ListView.vue +++ b/Services/client/src/components/ListView.vue @@ -399,6 +399,12 @@ const onRowClick = ((_, row) => { " data-testid="listViewFileDelete" /> +
From d33a9c475e645cd6df9f4d3a57b0d0f06445ef51 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:34:43 +0700 Subject: [PATCH 10/28] feat: search under folder --- Services/server/src/controllers/searchController.ts | 6 +++++- Services/server/src/interfaces/search.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Services/server/src/controllers/searchController.ts b/Services/server/src/controllers/searchController.ts index 394e02a..cc9db6f 100644 --- a/Services/server/src/controllers/searchController.ts +++ b/Services/server/src/controllers/searchController.ts @@ -23,7 +23,11 @@ export class SearchController extends Controller { bool: { must: search.AND?.map((v) => ({ [type[search.exact || v.exact ? 1 : 0]]: { [v.field]: v.value }, - })), + })).concat({ + [["match", "prefix"][search.recursive ? 1 : 0]]: { + path: search.path?.join("/") || "", + }, + }), should: search.OR?.map((v) => ({ [type[search.exact || v.exact ? 1 : 0]]: { [v.field]: v.value }, })), diff --git a/Services/server/src/interfaces/search.ts b/Services/server/src/interfaces/search.ts index 7d20fc4..1ceedf3 100644 --- a/Services/server/src/interfaces/search.ts +++ b/Services/server/src/interfaces/search.ts @@ -10,4 +10,6 @@ export interface Search { exact?: boolean; }[]; exact?: boolean; + recursive?: boolean; + path?: string[]; } From 2aeb8fa6685aecadf29ae7206d4480a5eba60d2a Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 12 Jan 2024 11:08:01 +0700 Subject: [PATCH 11/28] chore: generate routes and swagger --- Services/server/src/routes.ts | 4 +++- Services/server/src/swagger.json | 14 ++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Services/server/src/routes.ts b/Services/server/src/routes.ts index e9c4832..bd422a4 100644 --- a/Services/server/src/routes.ts +++ b/Services/server/src/routes.ts @@ -51,6 +51,8 @@ const models: TsoaRoute.Models = { "AND": {"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"exact":{"dataType":"boolean"},"value":{"dataType":"string","required":true},"field":{"dataType":"string","required":true}}}}, "OR": {"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"exact":{"dataType":"boolean"},"value":{"dataType":"string","required":true},"field":{"dataType":"string","required":true}}}}, "exact": {"dataType":"boolean"}, + "recursive": {"dataType":"boolean"}, + "path": {"dataType":"array","array":{"dataType":"string"}}, }, "additionalProperties": false, }, @@ -274,7 +276,7 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/storage/folder/size', - authenticateMiddleware([{"bearerAuth":["management-role","admin"]}]), + authenticateMiddleware([{"bearerAuth":[]}]), ...(fetchMiddlewares(StorageController)), ...(fetchMiddlewares(StorageController.prototype.folderSize)), diff --git a/Services/server/src/swagger.json b/Services/server/src/swagger.json index ac2cb3d..32a47ea 100644 --- a/Services/server/src/swagger.json +++ b/Services/server/src/swagger.json @@ -156,6 +156,15 @@ }, "exact": { "type": "boolean" + }, + "recursive": { + "type": "boolean" + }, + "path": { + "items": { + "type": "string" + }, + "type": "array" } }, "type": "object", @@ -847,10 +856,7 @@ ], "security": [ { - "bearerAuth": [ - "management-role", - "admin" - ] + "bearerAuth": [] } ], "parameters": [], From 4ab83abacdd39dc79a097e6580e216c3dc3f9a3b Mon Sep 17 00:00:00 2001 From: puri-ph4tt Date: Fri, 12 Jan 2024 11:16:56 +0700 Subject: [PATCH 12/28] =?UTF-8?q?update:=20=E0=B8=84=E0=B9=89=E0=B8=99?= =?UTF-8?q?=E0=B8=AB=E0=B8=B2=E0=B8=97=E0=B8=B1=E0=B9=89=E0=B8=87=E0=B8=AB?= =?UTF-8?q?=E0=B8=A1=E0=B8=94=E0=B8=A0=E0=B8=B2=E0=B8=A2=E0=B9=83=E0=B8=99?= =?UTF-8?q?=E0=B8=8A=E0=B8=B1=E0=B9=89=E0=B8=99=E0=B8=99=E0=B8=B1=E0=B9=89?= =?UTF-8?q?=E0=B8=99=E0=B9=86=20(admin)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/01_user/components/SearchBar.vue | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Services/client/src/modules/01_user/components/SearchBar.vue b/Services/client/src/modules/01_user/components/SearchBar.vue index 694477e..4ddc050 100644 --- a/Services/client/src/modules/01_user/components/SearchBar.vue +++ b/Services/client/src/modules/01_user/components/SearchBar.vue @@ -37,6 +37,9 @@ const submitSearchData = ref<{ value: string exact?: boolean }[] + exact?: boolean + recursive?: boolean + path?: string[] }>({ AND: [], OR: [], @@ -50,39 +53,32 @@ async function submitSearch() { if (searchData.value.value.trim() !== '') { submitSearchData.value = { AND: [], OR: [] } if (props.mode === 'admin') { + submitSearchData.value.exact = true + submitSearchData.value.recursive = true + submitSearchData.value.path = currentInfo.value.path.split('/').filter(Boolean) + optionsField.value.forEach((option) => { submitSearchData.value.OR.push({ field: option.value, value: searchData.value.value, - exact: true, }) }) submitSearchData.value.OR.push({ field: 'fileName', value: searchData.value.value, - exact: true, }) submitSearchData.value.OR.push({ field: 'metadata.author', value: searchData.value.value, - exact: true, }) submitSearchData.value.OR.push({ field: 'metadata.subject', value: searchData.value.value, - exact: true, }) submitSearchData.value.OR.push({ field: 'fileType', value: mime.getType(searchData.value.value) || '', - exact: true, }) - if (currentInfo.value.path !== '/') { - submitSearchData.value.AND.push({ - field: 'path', - value: currentInfo.value.path, - }) - } } else { if (searchData.value.field == 'title') { submitSearchData.value.OR.push({ From dbab045c49157addd308136b9c3ac4e51c01909e Mon Sep 17 00:00:00 2001 From: net Date: Fri, 12 Jan 2024 13:43:13 +0700 Subject: [PATCH 13/28] =?UTF-8?q?fix:=E0=B9=80=E0=B9=80=E0=B8=81=E0=B9=89?= =?UTF-8?q?=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B9=84=E0=B8=9F=E0=B8=A5?= =?UTF-8?q?=E0=B9=8C=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B8=AA=E0=B9=88=E0=B8=87?= =?UTF-8?q?=E0=B9=84=E0=B8=9B=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=AB=E0=B8=99?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B9=80=E0=B9=80=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/client/src/components/ListView.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Services/client/src/components/ListView.vue b/Services/client/src/components/ListView.vue index 363d0a7..389ab42 100644 --- a/Services/client/src/components/ListView.vue +++ b/Services/client/src/components/ListView.vue @@ -377,9 +377,16 @@ const onRowClick = ((_, row) => { @click.stop=" () => fileFormComponent?.triggerFileEdit( - data.row, + { + title: data.row.title, + description: data.row.description, + keyword: data.row.keyword, + category: data.row.category, + author: data.row.author, + metadata: data.row.metadata, + }, data.row.pathname, - data.row.filename, + data.row.fileName, ) " id="listViewFileEdit" From 3bbacf78d6d468b89b986e4657e04a5fdb75d6fc Mon Sep 17 00:00:00 2001 From: net Date: Fri, 12 Jan 2024 13:44:22 +0700 Subject: [PATCH 14/28] =?UTF-8?q?=E0=B8=B5update:=20=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B8=9A=E0=B8=9A=E0=B8=AD=E0=B8=B1=E0=B8=9B=E0=B9=82=E0=B8=AB?= =?UTF-8?q?=E0=B8=A5=E0=B8=94=20=E0=B8=96=E0=B9=89=E0=B8=B2=E0=B8=8A?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C?= =?UTF-8?q?=E0=B8=8B=E0=B9=89=E0=B8=B3=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=B2=E0=B8=88=E0=B8=B2=E0=B8=81=E0=B8=A3=E0=B8=B0=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=E0=B8=AD=E0=B8=B7=E0=B9=88=E0=B8=99=E0=B8=88=E0=B8=B0?= =?UTF-8?q?=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B8=AA=E0=B8=B2=E0=B8=A1=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=96=20=E0=B8=AD=E0=B8=B1=E0=B8=9B=E0=B9=82?= =?UTF-8?q?=E0=B8=AB=E0=B8=A5=E0=B8=94=E0=B9=84=E0=B8=94=E0=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/client/src/components/FileForm.vue | 22 ++++++++----- .../client/src/components/FileFormWrapper.vue | 32 ++++++++++++++++++- .../src/components/UploadExistDialog.vue | 24 +++++++++++--- 3 files changed, 64 insertions(+), 14 deletions(-) diff --git a/Services/client/src/components/FileForm.vue b/Services/client/src/components/FileForm.vue index fb40252..a444aef 100644 --- a/Services/client/src/components/FileForm.vue +++ b/Services/client/src/components/FileForm.vue @@ -10,6 +10,7 @@ const props = withDefaults( defineProps<{ open: boolean error: { + fileExistMetadata?: boolean fileExist?: boolean fileName2Long?: boolean } @@ -187,15 +188,20 @@ const file = ref() ? undefined : 'เลือกไฟล์' " - :error="!!error.fileExist || !!error.fileName2Long" - :error-message=" - error.fileExist - ? 'พบไฟล์ชื่อซ้ำในระบบ ไฟล์ชื่อนี้ภายในระบบจะถูกเขียนทับ' - : error.fileName2Long - ? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้' - : '' + :error=" + !!error.fileExistMetadata || + !!error.fileExist || + !!error.fileName2Long + " + :error-message=" + error.fileExistMetadata + ? 'พบไฟล์ชื่อซ้ำในระบบอื่น' + : error.fileExist + ? 'พบไฟล์ชื่อซ้ำในระบบ ไฟล์ชื่อนี้ภายในระบบจะถูกเขียนทับ' + : error.fileName2Long + ? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้' + : '' " - :disable="disableFields?.includes('file')" id="inputFile" :rules="[ (v) => v !== undefined || mode === 'edit' || 'โปรดอัปโหลดไฟล์', diff --git a/Services/client/src/components/FileFormWrapper.vue b/Services/client/src/components/FileFormWrapper.vue index f1bf027..0baf18e 100644 --- a/Services/client/src/components/FileFormWrapper.vue +++ b/Services/client/src/components/FileFormWrapper.vue @@ -21,8 +21,13 @@ const fileFormData = ref<{ metadata?: Record }>({}) const fileFormType = ref<'edit' | 'create'>('create') -const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({}) +const fileFormError = ref<{ + fileExistMetadata?: boolean + fileExist?: boolean + fileName2Long?: boolean +}>({}) const fileExistNotification = ref(false) +const errorState = ref<'fileExist' | 'fileExistMetadata'>('fileExist') const fileFormComponent = ref>() const fileNameLabel = ref() @@ -65,6 +70,18 @@ defineExpose({ const currentParam = ref[0]>() +function checkFileExistMetadata(name: string) { + const fileInfo = file.value[currentInfo.value.path].find( + (v) => v.fileName === name, + ) + + if (fileInfo?.metadata && Object.keys(fileInfo?.metadata).length > 0) { + return Boolean(true) + } + + return Boolean(false) +} + function checkFileExist(name: string, except?: string) { return Boolean( file.value[currentInfo.value.path].find( @@ -91,6 +108,16 @@ async function submitFileForm( ) { currentParam.value = value + const fileInfo = file.value[currentInfo.value.path].find( + (v) => v.fileName === value.file?.name, + ) + + if (fileInfo?.metadata && Object.keys(fileInfo.metadata).length > 0) { + fileExistNotification.value = true + errorState.value = 'fileExistMetadata' + return + } + if ( value.file && file.value[currentInfo.value.path].find( @@ -99,6 +126,7 @@ async function submitFileForm( !force ) { fileExistNotification.value = true + errorState.value = 'fileExist' return } @@ -150,6 +178,7 @@ async function submitFileForm( @reset="() => (fileFormError = {})" @filechange=" (name: string) => { + fileFormError.fileExistMetadata = checkFileExistMetadata(name) ;(fileFormError.fileExist = checkFileExist(name, fileNameLabel)), (fileFormError.fileName2Long = checkFileName2Long( name, @@ -161,6 +190,7 @@ async function submitFileForm( /> diff --git a/Services/client/src/components/UploadExistDialog.vue b/Services/client/src/components/UploadExistDialog.vue index 1d99ec1..a42b0e8 100644 --- a/Services/client/src/components/UploadExistDialog.vue +++ b/Services/client/src/components/UploadExistDialog.vue @@ -1,6 +1,7 @@