From de0734708740c082325123fd1e98ca6f257f8688 Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:28:48 +0900 Subject: [PATCH] fix register logs --- .../admin/custom-emojis-grid.register.vue | 63 ++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/pages/admin/custom-emojis-grid.register.vue b/packages/frontend/src/pages/admin/custom-emojis-grid.register.vue index 7613640bcb..e4544a6f5d 100644 --- a/packages/frontend/src/pages/admin/custom-emojis-grid.register.vue +++ b/packages/frontend/src/pages/admin/custom-emojis-grid.register.vue @@ -20,6 +20,26 @@ + + + + + +
+
+ +
+
+ ログはありません。 +
+
+
+
- {{ i18n.ts.registration }} + + {{ i18n.ts.registration }} + {{ i18n.ts.clear }}
@@ -73,10 +95,22 @@ type FolderItem = { name: string; }; -type UploadResult = { key: string, item: IGridItem, success: boolean, err: any }; +type UploadResult = { + key: string, + item: IGridItem, + success: boolean, + err?: Error +}; + +type RegisterLogItem = { + failed: boolean; + url: string; + name: string; + error?: string; +}; const columnSettings: ColumnSetting[] = [ - { bindTo: 'url', title: '🎨', type: 'image', editable: false, width: 50, validators: [required] }, + { bindTo: 'url', icon: 'ti-icons', type: 'image', editable: true, width: 50, validators: [required] }, { bindTo: 'name', title: 'name', type: 'text', editable: true, width: 140, validators: [required] }, { bindTo: 'category', title: 'category', type: 'text', editable: true, width: 140 }, { bindTo: 'aliases', title: 'aliases', type: 'text', editable: true, width: 140 }, @@ -86,6 +120,13 @@ const columnSettings: ColumnSetting[] = [ { bindTo: 'roleIdsThatCanBeUsedThisEmojiAsReaction', title: 'role', type: 'text', editable: true, width: 100 }, ]; +const registerLogColumnSettings: ColumnSetting[] = [ + { bindTo: 'failed', title: 'failed', type: 'boolean', editable: false, width: 50 }, + { bindTo: 'url', icon: 'ti-icons', type: 'image', editable: false, width: 50 }, + { bindTo: 'name', title: 'name', type: 'text', editable: false, width: 140 }, + { bindTo: 'error', title: 'log', type: 'text', editable: false, width: 'auto' }, +]; + const emit = defineEmits<{ (ev: 'operation:registered'): void; }>(); @@ -95,8 +136,10 @@ const gridItems = ref([]); const selectedFolderId = ref(defaultStore.state.uploadFolder); const keepOriginalUploading = ref(defaultStore.state.keepOriginalUploading); const registerButtonDisabled = ref(false); +const registerLogs = ref([]); const convertedGridItems = computed(() => gridItems.value.map(it => it as Record)); +const convertedRegisterLogs = computed(() => registerLogs.value.map(it => it as Record)); async function onRegistryClicked() { const dialogSelection = await os.confirm({ @@ -135,6 +178,20 @@ async function onRegistryClicked() { const result = await os.promiseDialog(upload()); const failedItems = result.filter(it => !it.success); + if (failedItems.length > 0) { + await os.alert({ + type: 'error', + title: 'エラー', + text: '絵文字の登録に失敗しました。詳細は登録ログをご確認ください。', + }); + } + + registerLogs.value = result.map(it => ({ + failed: !it.success, + url: it.item.url, + name: it.item.name, + error: it.err ? JSON.stringify(it.err) : undefined, + })); gridItems.value = failedItems.map(it => it.item); emit('operation:registered');