@things-factory/figure-library 10.1.178 → 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.
@@ -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;;;;;;;;;;;;;;;;;;;;;;GAsBlB,AAtBY,CAsBZ;IAKD,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;iBAKE,OAAO,CAAC,CAAC,CAAC,8BAA8B,CAAC;uBACnC,OAAO,CAAC,CAAC,CAAC,kCAAkC,CAAC;oBAChD,IAAI,CAAC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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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/figure-library",
3
- "version": "10.1.178",
3
+ "version": "10.1.179",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -29,20 +29,21 @@
29
29
  "dependencies": {
30
30
  "@hatiolab/figure-model": "^0.7.2",
31
31
  "@operato/data-grist": "^10.0.0",
32
- "@operato/graphql": "^10.0.0",
32
+ "@operato/graphql": "^10.29.36",
33
33
  "@operato/i18n": "^10.0.0",
34
+ "@operato/input": "^10.29.37",
34
35
  "@operato/popup": "^10.29.25",
35
36
  "@operato/property-editor": "^10.29.33",
36
37
  "@operato/shell": "^10.0.0",
37
38
  "@operato/slot-layout-editor": "^10.29.33",
38
39
  "@operato/styles": "^10.29.23",
39
40
  "@operato/utils": "^10.0.0",
40
- "@things-factory/attachment-base": "^10.1.178",
41
- "@things-factory/auth-base": "^10.1.178",
42
- "@things-factory/board-service": "^10.1.178",
41
+ "@things-factory/attachment-base": "^10.1.179",
42
+ "@things-factory/auth-base": "^10.1.179",
43
+ "@things-factory/board-service": "^10.1.179",
43
44
  "@things-factory/env": "^10.1.149",
44
45
  "@things-factory/figure-viewer": "^10.1.176",
45
- "@things-factory/shell": "^10.1.178",
46
+ "@things-factory/shell": "^10.1.179",
46
47
  "graphql-scalars": "^1.22.4",
47
48
  "graphql-tag": "^2.12.6",
48
49
  "graphql-upload": "^15.0.2",
@@ -50,5 +51,5 @@
50
51
  "koa-router": "^7.4.0",
51
52
  "lit": "^3.1.2"
52
53
  },
53
- "gitHead": "d57448d3f3045f72a9f24b877a3e306eb34cbaf1"
54
+ "gitHead": "4c8263b08e06b2b15f11dc0575c61a280a0d9e27"
54
55
  }
@@ -52,6 +52,7 @@
52
52
  "figure-library.contract.state-range-narrowed": "The range of the control '{id}' narrowed from {before} to {after}.",
53
53
  "figure-library.contract.state-unit-changed": "The unit of the control '{id}' changed from {before} to {after}.",
54
54
  "figure-library.button.upload": "upload package",
55
+ "figure-library.text.drop-package": "drop a figure package (.figpkg) here",
55
56
  "figure-library.title.import-result": "import result",
56
57
  "figure-library.text.breaking": "breaking",
57
58
  "figure-library.button.save": "save",
@@ -52,6 +52,7 @@
52
52
  "figure-library.contract.state-range-narrowed": "El rango del control '{id}' se redujo de {before} a {after}.",
53
53
  "figure-library.contract.state-unit-changed": "La unidad del control '{id}' cambió de {before} a {after}.",
54
54
  "figure-library.button.upload": "subir paquete",
55
+ "figure-library.text.drop-package": "suelte aquí un paquete de figuras (.figpkg)",
55
56
  "figure-library.title.import-result": "resultado de la importación",
56
57
  "figure-library.text.breaking": "incompatible",
57
58
  "figure-library.button.save": "guardar",
@@ -52,6 +52,7 @@
52
52
  "figure-library.contract.state-range-narrowed": "'{id}' 操作値の範囲が {before} から {after} に狭くなりました。",
53
53
  "figure-library.contract.state-unit-changed": "'{id}' 操作値の単位が {before} から {after} に変わりました。",
54
54
  "figure-library.button.upload": "パッケージをアップロード",
55
+ "figure-library.text.drop-package": "図形パッケージ(.figpkg)をここにドロップします",
55
56
  "figure-library.title.import-result": "インポート結果",
56
57
  "figure-library.text.breaking": "互換性なし",
57
58
  "figure-library.button.save": "保存",
@@ -52,6 +52,7 @@
52
52
  "figure-library.contract.state-range-narrowed": "'{id}' 조작값의 범위가 {before} 에서 {after} 로 좁아졌습니다.",
53
53
  "figure-library.contract.state-unit-changed": "'{id}' 조작값의 단위가 {before} 에서 {after} 로 바뀌었습니다.",
54
54
  "figure-library.button.upload": "꾸러미 올리기",
55
+ "figure-library.text.drop-package": "도형 꾸러미(.figpkg)를 여기에 끌어 놓기",
55
56
  "figure-library.title.import-result": "가져오기 결과",
56
57
  "figure-library.text.breaking": "호환되지 않음",
57
58
  "figure-library.button.save": "저장",
@@ -52,6 +52,7 @@
52
52
  "figure-library.contract.state-range-narrowed": "Julat kawalan '{id}' disempitkan daripada {before} kepada {after}.",
53
53
  "figure-library.contract.state-unit-changed": "Unit kawalan '{id}' berubah daripada {before} kepada {after}.",
54
54
  "figure-library.button.upload": "muat naik pakej",
55
+ "figure-library.text.drop-package": "lepaskan pakej rajah (.figpkg) di sini",
55
56
  "figure-library.title.import-result": "hasil import",
56
57
  "figure-library.text.breaking": "tidak serasi",
57
58
  "figure-library.button.save": "simpan",
@@ -52,6 +52,7 @@
52
52
  "figure-library.contract.state-range-narrowed": "控制值 '{id}' 的范围从 {before} 缩小为 {after}。",
53
53
  "figure-library.contract.state-unit-changed": "控制值 '{id}' 的单位从 {before} 变为 {after}。",
54
54
  "figure-library.button.upload": "上传包",
55
+ "figure-library.text.drop-package": "将图形包(.figpkg)拖放到此处",
55
56
  "figure-library.title.import-result": "导入结果",
56
57
  "figure-library.text.breaking": "不兼容",
57
58
  "figure-library.button.save": "保存",