@things-factory/board-ui 10.0.0-beta.57 → 10.0.0-beta.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/pages/attachment-list-page.d.ts +16 -0
- package/dist-client/pages/attachment-list-page.js +62 -1
- package/dist-client/pages/attachment-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/translations/en.json +3 -0
- package/translations/ja.json +3 -0
- package/translations/ko.json +3 -0
- package/translations/ms.json +3 -0
- package/translations/zh.json +3 -0
|
@@ -19,12 +19,28 @@ export declare class AttachmentListPage extends AttachmentListPage_base {
|
|
|
19
19
|
importable: {
|
|
20
20
|
handler: (data: any, file: any) => Promise<void>;
|
|
21
21
|
};
|
|
22
|
+
actions: {
|
|
23
|
+
icon: string;
|
|
24
|
+
emphasis: {
|
|
25
|
+
raised: boolean;
|
|
26
|
+
outlined: boolean;
|
|
27
|
+
dense: boolean;
|
|
28
|
+
danger: boolean;
|
|
29
|
+
};
|
|
30
|
+
title: string;
|
|
31
|
+
action: () => Promise<void>;
|
|
32
|
+
}[];
|
|
22
33
|
};
|
|
23
34
|
render(): import("lit-html").TemplateResult<1>;
|
|
24
35
|
get grist(): import("@operato/data-grist").DataGrist;
|
|
25
36
|
languageUpdated(i18next: any): void;
|
|
26
37
|
pageInitialized(): Promise<void>;
|
|
27
38
|
exportHandler(): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* 썸네일이 없는 기존 첨부파일들에 대해 서버에서 일괄 썸네일 생성.
|
|
41
|
+
* 한 배치당 20 개씩, remaining 이 0 이 될 때까지 반복 호출.
|
|
42
|
+
*/
|
|
43
|
+
backfillThumbnails(): Promise<void>;
|
|
28
44
|
importHandler(data: any, file: any): Promise<void>;
|
|
29
45
|
}
|
|
30
46
|
export {};
|
|
@@ -5,8 +5,10 @@ import { customElement, query } from 'lit/decorators.js';
|
|
|
5
5
|
import gql from 'graphql-tag';
|
|
6
6
|
import { i18next, localize } from '@operato/i18n';
|
|
7
7
|
import { PageView } from '@operato/shell';
|
|
8
|
+
import { CommonButtonStyles } from '@operato/styles';
|
|
8
9
|
import { OxAttachmentList } from '@operato/attachment/ox-attachment-list.js';
|
|
9
10
|
import { client } from '@operato/graphql';
|
|
11
|
+
import { notify } from '@operato/layout';
|
|
10
12
|
async function fetchDataFromURL(fileURL) {
|
|
11
13
|
try {
|
|
12
14
|
const response = await fetch(fileURL);
|
|
@@ -57,7 +59,14 @@ let AttachmentListPage = class AttachmentListPage extends localize(i18next)(Page
|
|
|
57
59
|
},
|
|
58
60
|
importable: {
|
|
59
61
|
handler: this.importHandler.bind(this)
|
|
60
|
-
}
|
|
62
|
+
},
|
|
63
|
+
actions: [
|
|
64
|
+
{
|
|
65
|
+
title: i18next.t('button.backfill thumbnails'),
|
|
66
|
+
action: this.backfillThumbnails.bind(this),
|
|
67
|
+
...CommonButtonStyles.save
|
|
68
|
+
}
|
|
69
|
+
]
|
|
61
70
|
};
|
|
62
71
|
}
|
|
63
72
|
render() {
|
|
@@ -96,6 +105,58 @@ let AttachmentListPage = class AttachmentListPage extends localize(i18next)(Page
|
|
|
96
105
|
}
|
|
97
106
|
return data;
|
|
98
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* 썸네일이 없는 기존 첨부파일들에 대해 서버에서 일괄 썸네일 생성.
|
|
110
|
+
* 한 배치당 20 개씩, remaining 이 0 이 될 때까지 반복 호출.
|
|
111
|
+
*/
|
|
112
|
+
async backfillThumbnails() {
|
|
113
|
+
const BATCH = 20;
|
|
114
|
+
let total = { attempted: 0, succeeded: 0, failed: 0 };
|
|
115
|
+
let remaining = Number.POSITIVE_INFINITY;
|
|
116
|
+
notify({ message: i18next.t('text.backfilling thumbnails') });
|
|
117
|
+
while (remaining > 0) {
|
|
118
|
+
try {
|
|
119
|
+
const { data } = await client.mutate({
|
|
120
|
+
mutation: gql `
|
|
121
|
+
mutation BackfillAttachmentThumbnails($limit: Int) {
|
|
122
|
+
backfillAttachmentThumbnails(limit: $limit) {
|
|
123
|
+
attempted
|
|
124
|
+
succeeded
|
|
125
|
+
failed
|
|
126
|
+
remaining
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
`,
|
|
130
|
+
variables: { limit: BATCH }
|
|
131
|
+
});
|
|
132
|
+
const r = data?.backfillAttachmentThumbnails;
|
|
133
|
+
if (!r)
|
|
134
|
+
break;
|
|
135
|
+
total.attempted += r.attempted;
|
|
136
|
+
total.succeeded += r.succeeded;
|
|
137
|
+
total.failed += r.failed;
|
|
138
|
+
remaining = r.remaining;
|
|
139
|
+
if (r.attempted === 0)
|
|
140
|
+
break; // 더 이상 처리할 게 없음
|
|
141
|
+
// 한 배치에서 아무것도 성공하지 못했다면 무한 루프 방지를 위해 중단.
|
|
142
|
+
// 동일 후보들이 계속 실패하는 상황이므로 서버 측 원인 해결이 선행되어야 함.
|
|
143
|
+
if (r.succeeded === 0)
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
console.error('backfill error:', err);
|
|
148
|
+
notify({ level: 'error', message: String(err) });
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
notify({
|
|
153
|
+
message: i18next.t('text.thumbnail backfill done', {
|
|
154
|
+
succeeded: total.succeeded,
|
|
155
|
+
failed: total.failed
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
this.grist.fetch();
|
|
159
|
+
}
|
|
99
160
|
async importHandler(data, file) {
|
|
100
161
|
await client.mutate({
|
|
101
162
|
mutation: gql `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-list-page.js","sourceRoot":"","sources":["../../client/pages/attachment-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,2CAA2C,CAAA;AAElD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,M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OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;gBACrC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;gBAChD,OAAM;YACR,CAAC;QACH,CAAC;QAED,MAAM,CAAC;YACL,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,8BAA8B,EAAE;gBACjD,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC;SACH,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI;QAC5B,MAAM,MAAM,CAAC,MAAM,CAAC;YAClB,QAAQ,EAAE,GAAG,CAAA;;;;;;;;;OASZ;YACD,SAAS,EAAE;gBACT,IAAI;aACL;YACD,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;SAC7B,CAAC,CAAA;QAEF,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;;AAlJ4B;IAA5B,KAAK,CAAC,oBAAoB,CAAC;8BAAkB,gBAAgB;0DAAA;AATnD,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CA4J9B","sourcesContent":["import '@operato/attachment/ox-attachment-list.js'\n\nimport { css, html } from 'lit'\nimport { customElement, query } from 'lit/decorators.js'\nimport gql from 'graphql-tag'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { PageView } from '@operato/shell'\nimport { CommonButtonStyles } from '@operato/styles'\nimport { OxAttachmentList } from '@operato/attachment/ox-attachment-list.js'\nimport { client } from '@operato/graphql'\nimport { notify } from '@operato/layout'\n\nasync function fetchDataFromURL(fileURL: string) {\n try {\n const response = await fetch(fileURL)\n\n if (!response.ok) {\n throw new Error('Network response was not ok')\n }\n\n const blob = await response.blob() // 파일 데이터를 Blob으로 변환\n\n if (blob.size === 0) {\n throw new Error('Content is empty') // Content가 비어 있으면 예외\n }\n\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n\n reader.onload = (event: any) => {\n const dataURL = event.target.result\n resolve(dataURL)\n }\n\n reader.onerror = (event: any) => {\n reject(event.error)\n }\n\n reader.readAsDataURL(blob) // Blob을 Data URL로 읽기\n })\n } catch (error) {\n throw error\n }\n}\n\n@customElement('attachment-list-page')\nexport class AttachmentListPage extends localize(i18next)(PageView) {\n static styles = [\n css`\n :host {\n display: flex;\n }\n `\n ]\n\n @query('ox-attachment-list') attachmentList!: OxAttachmentList\n\n get context() {\n return {\n title: i18next.t('title.attachment list'),\n search: {\n handler: search => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n board_topmenu: true,\n exportable: {\n name: i18next.t('title.attachment list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n },\n actions: [\n {\n title: i18next.t('button.backfill thumbnails'),\n action: this.backfillThumbnails.bind(this),\n ...CommonButtonStyles.save\n }\n ]\n }\n }\n\n render() {\n return html` <ox-attachment-list .creatable=${true} without-search></ox-attachment-list> `\n }\n\n get grist() {\n return this.attachmentList.grist\n }\n\n languageUpdated(i18next) {\n this.attachmentList.requestUpdate()\n }\n\n async pageInitialized() {\n await this.updateComplete\n\n this.attachmentList.refreshAttachments()\n }\n\n async exportHandler() {\n const records = this.grist.data.records\n const data = {} as any\n\n for (const record of records) {\n const { id, name, mimetype, encoding, category, fullpath } = record\n\n try {\n const dataURL = await fetchDataFromURL(fullpath)\n\n id &&\n (data[id!] = {\n id,\n name,\n mimetype,\n encoding,\n category,\n contents: dataURL\n })\n } catch (err) {\n console.warn('Failed to process attachment:', name, err)\n }\n }\n\n return data\n }\n\n /**\n * 썸네일이 없는 기존 첨부파일들에 대해 서버에서 일괄 썸네일 생성.\n * 한 배치당 20 개씩, remaining 이 0 이 될 때까지 반복 호출.\n */\n async backfillThumbnails() {\n const BATCH = 20\n let total = { attempted: 0, succeeded: 0, failed: 0 }\n let remaining = Number.POSITIVE_INFINITY\n\n notify({ message: i18next.t('text.backfilling thumbnails') })\n\n while (remaining > 0) {\n try {\n const { data } = await client.mutate({\n mutation: gql`\n mutation BackfillAttachmentThumbnails($limit: Int) {\n backfillAttachmentThumbnails(limit: $limit) {\n attempted\n succeeded\n failed\n remaining\n }\n }\n `,\n variables: { limit: BATCH }\n })\n const r = data?.backfillAttachmentThumbnails\n if (!r) break\n total.attempted += r.attempted\n total.succeeded += r.succeeded\n total.failed += r.failed\n remaining = r.remaining\n\n if (r.attempted === 0) break // 더 이상 처리할 게 없음\n // 한 배치에서 아무것도 성공하지 못했다면 무한 루프 방지를 위해 중단.\n // 동일 후보들이 계속 실패하는 상황이므로 서버 측 원인 해결이 선행되어야 함.\n if (r.succeeded === 0) break\n } catch (err) {\n console.error('backfill error:', err)\n notify({ level: 'error', message: String(err) })\n return\n }\n }\n\n notify({\n message: i18next.t('text.thumbnail backfill done', {\n succeeded: total.succeeded,\n failed: total.failed\n })\n })\n this.grist.fetch()\n }\n\n async importHandler(data, file) {\n await client.mutate({\n mutation: gql`\n mutation importAttachments($file: Upload!) {\n importAttachments(file: $file) {\n id\n name\n description\n path\n }\n }\n `,\n variables: {\n file\n },\n context: { hasUpload: true }\n })\n\n this.grist.fetch()\n }\n}\n"]}
|