@things-factory/figure-library 10.1.176 → 10.1.179
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/figure-library-page.d.ts +2 -3
- package/dist-client/pages/figure-library-page.js +11 -61
- package/dist-client/pages/figure-library-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/figure-package-import.d.ts +24 -0
- package/dist-client/viewparts/figure-package-import.js +117 -0
- package/dist-client/viewparts/figure-package-import.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/translations/en.json +1 -0
- package/translations/es.json +1 -0
- package/translations/ja.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import '@operato/input/ox-input-file.js';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
export type ImportResult = {
|
|
4
|
+
problems: {
|
|
5
|
+
code: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
}[];
|
|
8
|
+
outcomes: {
|
|
9
|
+
ref: string;
|
|
10
|
+
outcome: string;
|
|
11
|
+
code?: string;
|
|
12
|
+
differs?: string[];
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
declare const FigurePackageImport_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
16
|
+
export declare class FigurePackageImport extends FigurePackageImport_base {
|
|
17
|
+
static styles: import("lit").CSSResult;
|
|
18
|
+
private progress?;
|
|
19
|
+
private result?;
|
|
20
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
21
|
+
private importFile;
|
|
22
|
+
private renderResult;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@operato/input/ox-input-file.js';
|
|
3
|
+
import gql from 'graphql-tag';
|
|
4
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
5
|
+
import { customElement, state } from 'lit/decorators.js';
|
|
6
|
+
import { client, uploadContext } from '@operato/graphql';
|
|
7
|
+
import { i18next, localize } from '@operato/i18n';
|
|
8
|
+
const IMPORT = gql `
|
|
9
|
+
mutation ($file: Upload!) {
|
|
10
|
+
importFigurePackage(file: $file) {
|
|
11
|
+
problems {
|
|
12
|
+
code
|
|
13
|
+
path
|
|
14
|
+
}
|
|
15
|
+
outcomes {
|
|
16
|
+
ref
|
|
17
|
+
outcome
|
|
18
|
+
code
|
|
19
|
+
differs
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
/*
|
|
25
|
+
* Bringing a figure package in (ADR-0114): the file is what this popup is about, so the picker is the drop box
|
|
26
|
+
* (page standard §7-1). It refuses a file of another type or over the server's limit before it goes, shows how far the
|
|
27
|
+
* upload got, and says what each figure of the package came to below it. Another package can be dropped after it.
|
|
28
|
+
* `imported` tells the catalog to read itself again.
|
|
29
|
+
*/
|
|
30
|
+
let FigurePackageImport = class FigurePackageImport extends localize(i18next)(LitElement) {
|
|
31
|
+
static { this.styles = css `
|
|
32
|
+
:host {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
gap: 12px;
|
|
36
|
+
padding: 16px;
|
|
37
|
+
font-size: var(--ui-t-body, 13px);
|
|
38
|
+
}
|
|
39
|
+
[result] {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
}
|
|
44
|
+
[refused] {
|
|
45
|
+
color: var(--ui-crit, var(--md-sys-color-error));
|
|
46
|
+
}
|
|
47
|
+
[ref] {
|
|
48
|
+
font-family: var(--ui-mono, monospace);
|
|
49
|
+
}
|
|
50
|
+
p {
|
|
51
|
+
margin: 0;
|
|
52
|
+
}
|
|
53
|
+
`; }
|
|
54
|
+
render() {
|
|
55
|
+
return html `
|
|
56
|
+
<ox-input-file
|
|
57
|
+
accept=".figpkg,.zip"
|
|
58
|
+
hide-filelist
|
|
59
|
+
icon="upload_file"
|
|
60
|
+
.label=${i18next.t('figure-library.button.upload')}
|
|
61
|
+
.description=${i18next.t('figure-library.text.drop-package')}
|
|
62
|
+
.progress=${this.progress}
|
|
63
|
+
@change=${(e) => {
|
|
64
|
+
const file = e.detail?.[0];
|
|
65
|
+
if (file && this.progress === undefined)
|
|
66
|
+
this.importFile(file);
|
|
67
|
+
}}
|
|
68
|
+
></ox-input-file>
|
|
69
|
+
${this.result ? this.renderResult(this.result) : nothing}
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
async importFile(file) {
|
|
73
|
+
this.result = undefined;
|
|
74
|
+
this.progress = 0;
|
|
75
|
+
let result;
|
|
76
|
+
try {
|
|
77
|
+
const response = await client.mutate({ mutation: IMPORT, variables: { file }, context: uploadContext(fraction => (this.progress = fraction)) });
|
|
78
|
+
if (response.errors?.length)
|
|
79
|
+
throw new Error(response.errors[0].message);
|
|
80
|
+
result = response.data.importFigurePackage;
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
result = { problems: [{ code: e?.message ?? 'error' }], outcomes: [] };
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
this.progress = undefined;
|
|
87
|
+
this.renderRoot.querySelector('ox-input-file')?.reset();
|
|
88
|
+
}
|
|
89
|
+
this.result = result;
|
|
90
|
+
this.dispatchEvent(new CustomEvent('imported', { detail: result }));
|
|
91
|
+
}
|
|
92
|
+
renderResult(result) {
|
|
93
|
+
return html `<div result role="status">
|
|
94
|
+
${result.problems.length
|
|
95
|
+
? html `<p refused role="alert">${i18next.t('figure-library.text.package-refused', { code: result.problems.map(p => p.code).join(', ') })}</p>`
|
|
96
|
+
: result.outcomes.map(o => html `<div>
|
|
97
|
+
<span ref>${o.ref}</span> ·
|
|
98
|
+
<strong ?refused=${o.outcome === 'refused'}>${i18next.t(`figure-library.outcome.${o.outcome}`)}</strong>
|
|
99
|
+
${o.differs?.length ? html `<div>${i18next.t('figure-library.text.differs', { fields: o.differs.join(', ') })}</div>` : nothing}
|
|
100
|
+
${o.outcome === 'refused' && o.code ? html `<div>${o.code}</div>` : nothing}
|
|
101
|
+
</div>`)}
|
|
102
|
+
</div>`;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
__decorate([
|
|
106
|
+
state(),
|
|
107
|
+
__metadata("design:type", Number)
|
|
108
|
+
], FigurePackageImport.prototype, "progress", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
state(),
|
|
111
|
+
__metadata("design:type", Object)
|
|
112
|
+
], FigurePackageImport.prototype, "result", void 0);
|
|
113
|
+
FigurePackageImport = __decorate([
|
|
114
|
+
customElement('figure-package-import')
|
|
115
|
+
], FigurePackageImport);
|
|
116
|
+
export { FigurePackageImport };
|
|
117
|
+
//# sourceMappingURL=figure-package-import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-package-import.js","sourceRoot":"","sources":["../../client/viewparts/figure-package-import.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAEjD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;CAejB,CAAA;AAOD;;;;;GAKG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;aAC7D,WAAM,GAAG,GAAG,CAAA;;;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S,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,OAAO;mBACrE,CACR;WACA,CAAA;IACT,CAAC;;AApDgB;IAAhB,KAAK,EAAE;;qDAA0B;AACjB;IAAhB,KAAK,EAAE;;mDAA8B;AA1B3B,mBAAmB;IAD/B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,mBAAmB,CA8E/B","sourcesContent":["import '@operato/input/ox-input-file.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nimport { client, uploadContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\n\nconst IMPORT = gql`\n mutation ($file: Upload!) {\n importFigurePackage(file: $file) {\n problems {\n code\n path\n }\n outcomes {\n ref\n outcome\n code\n differs\n }\n }\n }\n`\n\nexport type ImportResult = {\n problems: { code: string; path?: string }[]\n outcomes: { ref: string; outcome: string; code?: string; differs?: string[] }[]\n}\n\n/*\n * Bringing a figure package in (ADR-0114): the file is what this popup is about, so the picker is the drop box\n * (page standard §7-1). It refuses a file of another type or over the server's limit before it goes, shows how far the\n * upload got, and says what each figure of the package came to below it. Another package can be dropped after it.\n * `imported` tells the catalog to read itself again.\n */\n@customElement('figure-package-import')\nexport class FigurePackageImport extends localize(i18next)(LitElement) {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n font-size: var(--ui-t-body, 13px);\n }\n [result] {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n [refused] {\n color: var(--ui-crit, var(--md-sys-color-error));\n }\n [ref] {\n font-family: var(--ui-mono, monospace);\n }\n p {\n margin: 0;\n }\n `\n\n @state() private progress?: number\n @state() private result?: ImportResult\n\n render() {\n return html`\n <ox-input-file\n accept=\".figpkg,.zip\"\n hide-filelist\n icon=\"upload_file\"\n .label=${i18next.t('figure-library.button.upload')}\n .description=${i18next.t('figure-library.text.drop-package')}\n .progress=${this.progress}\n @change=${(e: CustomEvent) => {\n const file = (e.detail as File[] | undefined)?.[0]\n if (file && this.progress === undefined) this.importFile(file)\n }}\n ></ox-input-file>\n ${this.result ? this.renderResult(this.result) : nothing}\n `\n }\n\n private async importFile(file: File) {\n this.result = undefined\n this.progress = 0\n let result: ImportResult\n try {\n const response = await client.mutate({ mutation: IMPORT, variables: { file }, context: uploadContext(fraction => (this.progress = fraction)) })\n if (response.errors?.length) throw new Error(response.errors[0].message)\n result = response.data.importFigurePackage\n } catch (e: any) {\n result = { problems: [{ code: e?.message ?? 'error' }], outcomes: [] }\n } finally {\n this.progress = undefined\n this.renderRoot.querySelector<HTMLElement & { reset(): void }>('ox-input-file')?.reset()\n }\n this.result = result\n this.dispatchEvent(new CustomEvent('imported', { detail: result }))\n }\n\n private renderResult(result: ImportResult) {\n return html`<div result role=\"status\">\n ${result.problems.length\n ? html`<p refused role=\"alert\">${i18next.t('figure-library.text.package-refused', { code: result.problems.map(p => p.code).join(', ') })}</p>`\n : result.outcomes.map(\n o => html`<div>\n <span ref>${o.ref}</span> ·\n <strong ?refused=${o.outcome === 'refused'}>${i18next.t(`figure-library.outcome.${o.outcome}`)}</strong>\n ${o.differs?.length ? html`<div>${i18next.t('figure-library.text.differs', { fields: o.differs.join(', ') })}</div>` : nothing}\n ${o.outcome === 'refused' && o.code ? html`<div>${o.code}</div>` : nothing}\n </div>`\n )}\n </div>`\n }\n}\n"]}
|