@deviceinsight/ng-ui-scale-lib 9.26.0 → 10.0.1

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.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/dist/AccessEditModal-CcR8UUJ1.js +90 -0
  3. package/dist/AccessEditModal-CcR8UUJ1.js.map +1 -0
  4. package/dist/BundleManagementContainer--zLnsGKr.js +16 -0
  5. package/dist/BundleManagementContainer--zLnsGKr.js.map +1 -0
  6. package/dist/BundlesContainer-Cjb66440.js +914 -0
  7. package/dist/BundlesContainer-Cjb66440.js.map +1 -0
  8. package/dist/DatapointImport-D00OnAV4.js +293 -0
  9. package/dist/DatapointImport-D00OnAV4.js.map +1 -0
  10. package/dist/FileUploadInput-DfeELXM6.js +45 -0
  11. package/dist/FileUploadInput-DfeELXM6.js.map +1 -0
  12. package/dist/Files-jXxYNeMa.js +347 -0
  13. package/dist/Files-jXxYNeMa.js.map +1 -0
  14. package/dist/GlobalPowerBiReports-DANUj2j5.js +103 -0
  15. package/dist/GlobalPowerBiReports-DANUj2j5.js.map +1 -0
  16. package/dist/Graph-BqYDNKEo.js +53 -0
  17. package/dist/Graph-BqYDNKEo.js.map +1 -0
  18. package/dist/JsonSettingWidget-DE1lID1f.js +53 -0
  19. package/dist/JsonSettingWidget-DE1lID1f.js.map +1 -0
  20. package/dist/LicensesEditPage-PbKGjtzy.js +145 -0
  21. package/dist/LicensesEditPage-PbKGjtzy.js.map +1 -0
  22. package/dist/LicensesList-CxQ5TtrL.js +149 -0
  23. package/dist/LicensesList-CxQ5TtrL.js.map +1 -0
  24. package/dist/PropertiesEditPage-DpRwYhiU.js +373 -0
  25. package/dist/PropertiesEditPage-DpRwYhiU.js.map +1 -0
  26. package/dist/{PropertiesList-59c05fe4.js → PropertiesList-DI0mfPLo.js} +56 -58
  27. package/dist/PropertiesList-DI0mfPLo.js.map +1 -0
  28. package/dist/TemplateEditPage-BzoiAhuZ.js +508 -0
  29. package/dist/TemplateEditPage-BzoiAhuZ.js.map +1 -0
  30. package/dist/TemplateTextInput-CWPLnhST.js +45 -0
  31. package/dist/TemplateTextInput-CWPLnhST.js.map +1 -0
  32. package/dist/TemplatesListPage-BbDysOaR.js +330 -0
  33. package/dist/TemplatesListPage-BbDysOaR.js.map +1 -0
  34. package/dist/UserGroupAssignments-D4LC_sIB.js +297 -0
  35. package/dist/UserGroupAssignments-D4LC_sIB.js.map +1 -0
  36. package/dist/{UserGroupTheme-6768666a.js → UserGroupTheme-Mfh7WwKs.js} +51 -53
  37. package/dist/UserGroupTheme-Mfh7WwKs.js.map +1 -0
  38. package/dist/api.d.ts +805 -802
  39. package/dist/api.js +73 -77
  40. package/dist/api.js.map +1 -0
  41. package/dist/{consts-012135e5.js → consts-CZ_QkIyI.js} +1 -2
  42. package/dist/consts-CZ_QkIyI.js.map +1 -0
  43. package/dist/{customFileCategories-1b64ed45.js → customFileCategories-bG5S9qSy.js} +1 -0
  44. package/dist/customFileCategories-bG5S9qSy.js.map +1 -0
  45. package/dist/index.d.ts +3 -7
  46. package/dist/index.js +4729 -17113
  47. package/dist/index.js.map +1 -0
  48. package/dist/setTitle-BkLWezzi.js +39377 -0
  49. package/dist/setTitle-BkLWezzi.js.map +1 -0
  50. package/dist/style.css +1 -1
  51. package/dist/{useCanDeleteBundleVersion-64f35949.js → useCanDeleteBundleVersion-CUD1pDJ0.js} +1 -0
  52. package/dist/useCanDeleteBundleVersion-CUD1pDJ0.js.map +1 -0
  53. package/package.json +85 -108
  54. package/dist/AccessEditModal-c2178ad5.js +0 -92
  55. package/dist/BundleManagementContainer-60c28e65.js +0 -20
  56. package/dist/BundlesContainer-b3ee1991.js +0 -912
  57. package/dist/ContextBarContext-a6c59c97.js +0 -88776
  58. package/dist/DatapointImport-f6bdbdbc.js +0 -864
  59. package/dist/FileUploadInput-81bb787f.js +0 -44
  60. package/dist/Files-dc240d97.js +0 -364
  61. package/dist/GlobalPowerBiReports-3b7feef9.js +0 -11081
  62. package/dist/Graph-f5463f47.js +0 -25012
  63. package/dist/JsonSettingWidget-307658b8.js +0 -56
  64. package/dist/LicensesEditPage-f62cca26.js +0 -146
  65. package/dist/LicensesList-85279448.js +0 -150
  66. package/dist/PropertiesEditPage-4edb93b7.js +0 -371
  67. package/dist/TemplateEditPage-fe1b5f44.js +0 -508
  68. package/dist/TemplateTextInput-34e4356f.js +0 -49
  69. package/dist/TemplatesListPage-cd3194a7.js +0 -330
  70. package/dist/UserGroupAssignments-291f29f0.js +0 -297
  71. package/dist/index-738ab9ab.js +0 -18679
@@ -1,44 +0,0 @@
1
- import { ax as t, cC as m } from "./ContextBarContext-a6c59c97.js";
2
- import { useState as p } from "react";
3
- import { Button as d, Icon as u } from "@deviceinsight/ng-ui-basic-components";
4
- import { ImageUpload as x, FileUpload as F } from "@deviceinsight/ng-ui-components";
5
- const s = ({ file: e, onRemoveFile: o }) => /* @__PURE__ */ t.jsxs(
6
- "strong",
7
- {
8
- style: {
9
- display: "flex",
10
- alignItems: "center",
11
- justifyContent: "center"
12
- },
13
- children: [
14
- e && e.name,
15
- /* @__PURE__ */ t.jsx(d, { naked: !0, onClick: o, "data-testid": "delete-file-button", children: /* @__PURE__ */ t.jsx(u, { del: !0 }) })
16
- ]
17
- }
18
- ), U = ({ imagesOnly: e, onChange: o, ...a }) => {
19
- const [c, l] = p(null), n = (r) => {
20
- e && l(r.preview), o(r);
21
- }, i = () => {
22
- e && l(null), o(null);
23
- };
24
- return /* @__PURE__ */ t.jsx(m, { ...a, className: "fileuploadinput", children: e ? /* @__PURE__ */ t.jsx(
25
- x,
26
- {
27
- onRemoveFile: i,
28
- onSelectFile: n,
29
- previewComponent: s,
30
- imageUrl: c,
31
- accept: "image/*"
32
- }
33
- ) : /* @__PURE__ */ t.jsx(
34
- F,
35
- {
36
- onRemoveFile: i,
37
- onSelectFile: n,
38
- previewComponent: s
39
- }
40
- ) });
41
- };
42
- export {
43
- U as F
44
- };
@@ -1,364 +0,0 @@
1
- import { ah as R, ax as e, ag as p, d1 as D, d2 as L, bs as G, a6 as Y, b5 as z, cs as Z, d3 as q, aZ as _, aR as $ } from "./ContextBarContext-a6c59c97.js";
2
- import { messageBoxError as J, ReactableWithClientSidePagination as ee, ContentHeader as te, RouteTabs as se } from "@deviceinsight/ng-ui-components";
3
- import "react-i18next";
4
- import { useState as B, useCallback as S, useRef as ie, useEffect as U, useMemo as X, createContext as ae, useContext as ne } from "react";
5
- import { Modal as le, SpinnerContainer as P, Button as k, Icon as W, useConfirm as oe } from "@deviceinsight/ng-ui-basic-components";
6
- import { F as re } from "./FileUploadInput-81bb787f.js";
7
- import { createPortal as de } from "react-dom";
8
- import { Link as ce } from "react-router-dom";
9
- import { g as M } from "./customFileCategories-1b64ed45.js";
10
- import "i18next";
11
- import "@deviceinsight/ng-ui-api-client";
12
- import "ux4iot-react";
13
- const Ae = ({ fileType: t, onClose: s, onUpload: l }) => {
14
- const { t: n } = R(), [u, i] = B(null), [m, A] = B(""), [g, f] = B(!1), h = u && !m, d = async (o) => {
15
- if (o) {
16
- f(!0);
17
- try {
18
- await l(o, t), s();
19
- } catch (F) {
20
- J(F.message), console.error(F), f(!1);
21
- }
22
- }
23
- }, x = (o) => {
24
- i(o), A(o ? "" : n("assets.detail.files.uploadForm.error.missingFile", {
25
- defaultValue: "Please select a file"
26
- }));
27
- };
28
- return /* @__PURE__ */ e.jsx(
29
- le,
30
- {
31
- width: 450,
32
- header: t === "documents" ? /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.uploadForm.addDocument", children: "Add document" }) : /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.uploadForm.addImage", children: "Add image" }),
33
- content: /* @__PURE__ */ e.jsx(P, { show: g, children: /* @__PURE__ */ e.jsx(
34
- re,
35
- {
36
- label: /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.uploadForm.fileLabel", children: "File to upload" }),
37
- onChange: x,
38
- imagesOnly: t === "images",
39
- error: m,
40
- required: !0
41
- }
42
- ) }),
43
- footer: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
44
- /* @__PURE__ */ e.jsx(
45
- k,
46
- {
47
- onClick: () => d(u),
48
- primary: !0,
49
- disabled: !h || g,
50
- "data-testid": "save-button",
51
- children: /* @__PURE__ */ e.jsx(p, { i18nKey: "general.actions.save", children: "Save" })
52
- }
53
- ),
54
- /* @__PURE__ */ e.jsx(k, { onClick: s, children: /* @__PURE__ */ e.jsx(p, { i18nKey: "general.actions.cancel", children: "Cancel" }) })
55
- ] })
56
- }
57
- );
58
- }, ue = ({ contentType: t, loading: s, content: l }) => /* @__PURE__ */ e.jsx("div", { className: "image-preview", children: /* @__PURE__ */ e.jsxs(P, { show: s, children: [
59
- t === "image/svg+xml" && /* @__PURE__ */ e.jsx(
60
- "div",
61
- {
62
- className: "svg-preview",
63
- style: {
64
- backgroundImage: `url("${s || !l ? "" : l}")`
65
- }
66
- }
67
- ),
68
- t !== "image/svg+xml" && /* @__PURE__ */ e.jsx("img", { src: l, alt: "" })
69
- ] }) }), me = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAfCAYAAADwbH0HAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4ggUCDQxnLQ5VQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAGASURBVEjHvde3UgMxEIBhAUNBdoKCHEo/Aa9BCwWtXw7GBRVDGPKAzzahIaeKmhp+CmSP5izJF/a8rXb3mztJJ51SRgB9qkfRb6AVpdQWMCiNANPANlAKD1SAX/6jKolr9F73bgKF1sCGgSKJh9BWBEBOAbPAE52RCtfog6XvLjDUSpoDnqVwD7rXRo3keeAlLQ7MONB9YNhVlArX6KOl/sCJGsULwGtc3IMedkWNJovAW1Tcgx4BI3EXSCTcgx4Do0m3xBLw7sI96Eli1MCXgQ9L8x0HegqMSX32XHg4zsRQA18BPj3oOTCeyVEGrDrQ746TRxAtATeeJ66KH6kavY4wx3I4UHSgl8BXJrhGm66FBJTFcaAANCxNL8zVK4pHRUVxjdYdczrhqUuOA/kkaCpco4Gl6ArIxZim6LhGa5bkWhw0Fg7kHGgA5FNsRT8OrFnu1fU0aBf81rzUbwI/eqDRHpD58pn4HTAZTljXr7yYwQFT1tfbKVfCQK/+Fv8AJCO91qtSsKIAAAAASUVORK5CYII=", ge = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAnCAYAAADtu3N3AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4ggUCCsYE1yvpwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAFTSURBVEjHrdY9S5BhFAbgNykUKUIRE10kGxxsUgQXF2lLGppsCTcdGhprCZxqcNCxKRp0EcTJpaWGwBaDhpCIoJZECIQkTOty8Ajvfs7zAy44D/f5aJrkQweGmgLoEtZxioEs9sL5+4CODLQY0DfcyECzUdovjGagCfzGMaYz0DB+4j/mMlAPPsc/PclAnXgX0MuKLME2LldkaRdXM9BCQN8xmIHuRpYOMZaBxiNLfzFTkSV4WJWlZ9ksvQ3oVTZLawG9wZUM9jygT7iegYYCOsVIxQy/6LvXFbO8F3sBLlWAN7Ef4HwFOIkjnOBOBXgP/6Inb1eAj6LcH1ULdjnAj7hWEZmNkgkbYBfep2d/C+zDlwCfVoC3cBD78kEFOIU/6U3eAu9HBnM3Rgt8XHL9tMCV1l3WXZHBzQC3UodegN3YCXC1otx+fA2wpIeHsdA0TXMGpWMqV6FcS+MAAAAASUVORK5CYII=", fe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAnCAYAAAACeRhJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4ggUCCwH0RU0lQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAFISURBVEjHrdaxS9VhFAZgja43JUy4uETocBsjwSXvLLnYEjQn4pKb4B6I08XJ1SXK6bo4Oogt3T0QHXTLJMGWFDFI83HwDM7f+Z0/4OF7h++8pwfD6O/JDn5gD0NZaM3dfEVfBqphJ7D17KueRDxYzmIj+BXYXBYbxwWuMJXFpnGNc4xlsQ8R8RjPslg7sF0MZqBedALbRi2D1fEtsE/ZiA0cBPYxizVxGtj7LPYKl/iHySz2Fv/xBy+y2EJEPMLTLLYa2Hc8zkAPsBnYFh5msIF72+JNBloM5CeGS5F3uMEZXpYiLfyNnfW6FHmO3xFpNvPnDgNZKkUeoRvIl8xe2rjXfbVSaCWQ/eI2xnwgJxjNtskFxrP9do3pKhp3vooboF3FVdJBbyn0OZAu6qXIUiAHaJQiM4GcoplZUCdRMxNVVEwre9TeAsA6JS24jJJMAAAAAElFTkSuQmCC", xe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAdCAYAAACqhkzFAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4ggUCDYA/1xb7QAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAADlSURBVEjH7dW/CsIwEAbw7ySDjyFOujgJ4jMU3AWp7eJLCE7+2ZzENxB8GmdHV0FBN5f6uVQMIW0aCk45KLSX3I9LCI3AEiRHAGYoj4WInMykKpjcBhA5wJ0t2XAULQF0jedQVqAc4FVEzsZ2PMoKXB16RwADGMAA/gdUJFsAJkZ+WKF2TLKvfWcA9kpELiSbAOaezcTa+xtAKiJP/U+84i+2JBOSHcsFNsjHjvncjGSMgtvui95I9opaIxmRfOXYtHQdLtQL04rWNtTAEq8dN9FamIZucvSuYWmtg6qh9TFj+ZWwD7+x6apgNh+aAAAAAElFTkSuQmCC";
70
- const he = ({ initialImageNumber: t, items: s, onDownload: l, onClose: n }) => {
71
- const [u, i] = B(t), [m, A] = B(), [g, f] = B(!1), h = S(() => i((b) => Math.min(s.length - 1, b + 1)), [s]), d = S(() => i((b) => Math.max(0, b - 1)), []), x = ie({});
72
- U(() => (D.addListener("right", h), D.addListener("left", d), D.addListener("esc", n), () => {
73
- D.removeListener("right", h), D.removeListener("left", d), D.removeListener("esc", n);
74
- }), [h, d, n]);
75
- const o = s[u];
76
- U(() => {
77
- const b = x.current[o.key];
78
- b ? A(L(o.contentType, b)) : (f(!0), l(o).then((w) => {
79
- f(!1), x.current[o.key] = w, A(L(o.contentType, w));
80
- }));
81
- }, [o, l]);
82
- const F = () => {
83
- G.saveAs(new Blob([x.current[o.key]]), o.filename);
84
- }, I = s.length > 0 && u > 0, v = s.length > 0 && u < s.length - 1, { body: y } = document;
85
- return y ? de(
86
- /* @__PURE__ */ e.jsxs("div", { className: "di file-previewer", children: [
87
- /* @__PURE__ */ e.jsx("div", { className: "background" }),
88
- /* @__PURE__ */ e.jsxs("div", { className: "header", children: [
89
- /* @__PURE__ */ e.jsx("h1", { className: "filename", children: o.filename }),
90
- /* @__PURE__ */ e.jsx("button", { className: "btn close", onClick: n, children: /* @__PURE__ */ e.jsx("span", { role: "img", "aria-label": "close", children: /* @__PURE__ */ e.jsx("img", { src: me, alt: "close" }) }) })
91
- ] }),
92
- /* @__PURE__ */ e.jsxs("div", { className: "content", children: [
93
- /* @__PURE__ */ e.jsx("div", { className: "left", children: I && /* @__PURE__ */ e.jsx("button", { className: "btn previous", onClick: d, children: /* @__PURE__ */ e.jsx("span", { role: "img", "aria-label": "previous", children: /* @__PURE__ */ e.jsx("img", { src: ge, alt: "previous" }) }) }) }),
94
- /* @__PURE__ */ e.jsx("div", { className: "center", children: /* @__PURE__ */ e.jsx(ue, { loading: g, content: m, contentType: o.contentType }) }),
95
- /* @__PURE__ */ e.jsx("div", { className: "right", children: v && /* @__PURE__ */ e.jsx("button", { className: "btn next", onClick: h, children: /* @__PURE__ */ e.jsx("span", { role: "img", "aria-label": "next", children: /* @__PURE__ */ e.jsx("img", { src: fe, alt: "next" }) }) }) })
96
- ] }),
97
- /* @__PURE__ */ e.jsx("div", { className: "footer", children: /* @__PURE__ */ e.jsx("button", { className: "btn download", onClick: F, disabled: g, children: /* @__PURE__ */ e.jsx("span", { role: "img", "aria-label": "close", children: /* @__PURE__ */ e.jsx("img", { src: xe, alt: "download" }) }) }) })
98
- ] }),
99
- y
100
- ) : null;
101
- };
102
- var Q = { exports: {} };
103
- (function(t, s) {
104
- (function(l) {
105
- var n = /^(b|B)$/, u = { iec: { bits: ["b", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib"], bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] }, jedec: { bits: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"], bytes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] } }, i = { iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"], jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"] };
106
- function m(A) {
107
- var g, f, h, d, x, o, F, I, v, y, b, w, j, C, V, c = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : {}, a = [], N = 0, r = void 0, T = void 0;
108
- if (isNaN(A))
109
- throw new TypeError("Invalid number");
110
- return f = c.bits === !0, b = c.unix === !0, g = c.base || 2, y = c.round !== void 0 ? c.round : b ? 1 : 2, o = c.locale !== void 0 ? c.locale : "", F = c.localeOptions || {}, w = c.separator !== void 0 ? c.separator : "", j = c.spacer !== void 0 ? c.spacer : b ? "" : " ", V = c.symbols || {}, C = g === 2 && c.standard || "jedec", v = c.output || "string", d = c.fullform === !0, x = c.fullforms instanceof Array ? c.fullforms : [], r = c.exponent !== void 0 ? c.exponent : -1, h = 2 < g ? 1e3 : 1024, (I = (T = Number(A)) < 0) && (T = -T), (r === -1 || isNaN(r)) && (r = Math.floor(Math.log(T) / Math.log(h))) < 0 && (r = 0), 8 < r && (r = 8), v === "exponent" ? r : (T === 0 ? (a[0] = 0, a[1] = b ? "" : u[C][f ? "bits" : "bytes"][r]) : (N = T / (g === 2 ? Math.pow(2, 10 * r) : Math.pow(1e3, r)), f && h <= (N *= 8) && r < 8 && (N /= h, r++), a[0] = Number(N.toFixed(0 < r ? y : 0)), a[0] === h && r < 8 && c.exponent === void 0 && (a[0] = 1, r++), a[1] = g === 10 && r === 1 ? f ? "kb" : "kB" : u[C][f ? "bits" : "bytes"][r], b && (a[1] = C === "jedec" ? a[1].charAt(0) : 0 < r ? a[1].replace(/B$/, "") : a[1], n.test(a[1]) && (a[0] = Math.floor(a[0]), a[1] = ""))), I && (a[0] = -a[0]), a[1] = V[a[1]] || a[1], o === !0 ? a[0] = a[0].toLocaleString() : 0 < o.length ? a[0] = a[0].toLocaleString(o, F) : 0 < w.length && (a[0] = a[0].toString().replace(".", w)), v === "array" ? a : (d && (a[1] = x[r] ? x[r] : i[C][r] + (f ? "bit" : "byte") + (a[0] === 1 ? "" : "s")), v === "object" ? { value: a[0], symbol: a[1], exponent: r } : a.join(j)));
111
- }
112
- m.partial = function(A) {
113
- return function(g) {
114
- return m(g, A);
115
- };
116
- }, t.exports = m;
117
- })();
118
- })(Q);
119
- var pe = Q.exports;
120
- const be = /* @__PURE__ */ Y(pe), je = {
121
- page: 0,
122
- size: 10,
123
- sort: {
124
- property: "creationDate",
125
- direction: "DESC"
126
- }
127
- };
128
- function Be(t, s, l, n, u) {
129
- return [
130
- {
131
- name: "filename",
132
- label: /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.columns.filename", children: "Filename" }),
133
- width: "50%",
134
- sortable: !0,
135
- filterable: {
136
- filterType: "text",
137
- filterFn(i, m) {
138
- return i.filename.toLowerCase().indexOf(m.toLowerCase()) !== -1;
139
- }
140
- },
141
- render: (i) => /* @__PURE__ */ e.jsxs(ce, { to: "#", onClick: () => s(i), children: [
142
- i.filename,
143
- i.context && /* @__PURE__ */ e.jsxs("span", { children: [
144
- " [",
145
- i.context === "svgWidget" ? "Svg Widget" : "Asset Image Widget",
146
- "]"
147
- ] })
148
- ] })
149
- },
150
- {
151
- name: "size",
152
- sortable: !0,
153
- label: /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.columns.size", children: "Size" }),
154
- width: "20%",
155
- render: (i) => be(i.size)
156
- },
157
- {
158
- name: "creationDate",
159
- sortable: !0,
160
- label: /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.columns.lastModificationDate", children: "Last modification date" }),
161
- width: "20%",
162
- render: (i) => z(new Date(i.creationDate).getTime())
163
- },
164
- {
165
- name: "deleteAndDownload",
166
- label: "",
167
- align: "right",
168
- render: (i) => /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
169
- /* @__PURE__ */ e.jsx(k, { onClick: () => l(i), naked: !0, children: /* @__PURE__ */ e.jsx("img", { src: Z, alt: "Download" }) }),
170
- /* @__PURE__ */ e.jsx(
171
- "span",
172
- {
173
- title: i.context ? u("assets.detail.files.deleteDisabledTooltip", {
174
- defaultValue: "Cannot be removed because is used by some {{widget}}",
175
- widget: i.context === "svgWidget" ? "Svg Widget" : "Asset Image Widget"
176
- }) : void 0,
177
- children: /* @__PURE__ */ e.jsx(
178
- k,
179
- {
180
- naked: !0,
181
- disabled: !!i.context,
182
- onClick: () => n(i),
183
- "data-testid": "delete-file-button",
184
- children: /* @__PURE__ */ e.jsx(W, { del: !0 })
185
- }
186
- )
187
- }
188
- )
189
- ] })
190
- }
191
- ];
192
- }
193
- function Fe({ files: t, loading: s, type: l, onFilenameClick: n, onDownload: u, onDelete: i }) {
194
- const { t: m } = R();
195
- return /* @__PURE__ */ e.jsx(
196
- ee,
197
- {
198
- columnDefs: Be(l, n, u, i, m),
199
- uniqueItemKey: (A) => A.key,
200
- paginationSettings: je,
201
- items: t,
202
- isLoading: s,
203
- tableName: "filesTable"
204
- }
205
- );
206
- }
207
- function K(t, s, l) {
208
- const n = X(() => q(s, l, t), [s, l, t]), [u, i] = B(!1), [m, A] = B([]);
209
- U(() => {
210
- const { promise: d, cancel: x } = _(n.fetchFiles());
211
- return d.then((o) => {
212
- A(o), i(!1);
213
- }).catch((o) => {
214
- o.isCanceled || i(!1);
215
- }), x;
216
- }, [n]);
217
- async function g(d, x) {
218
- i(!0);
219
- try {
220
- const o = await n.uploadFile(d, x);
221
- A([...m, o]);
222
- } finally {
223
- i(!1);
224
- }
225
- }
226
- async function f(d) {
227
- i(!0);
228
- try {
229
- await n.deleteFile(d.key), A(m.filter((x) => x.key !== d.key));
230
- } finally {
231
- i(!1);
232
- }
233
- }
234
- function h(d) {
235
- return n.fetchFile(d.key);
236
- }
237
- return {
238
- loading: u,
239
- files: m,
240
- uploadFile: g,
241
- deleteFile: f,
242
- fetchFile: h
243
- };
244
- }
245
- const H = {
246
- deleteFile: () => {
247
- },
248
- files: [],
249
- uploadFile: () => {
250
- },
251
- fetchFile: () => Promise.resolve(new ArrayBuffer(0)),
252
- loading: !1
253
- }, O = ae({
254
- documents: H,
255
- images: H
256
- });
257
- function Ce({ asset: t, assetGroup: s, children: l }) {
258
- const n = K("documents", t, s), u = K("images", t, s);
259
- return /* @__PURE__ */ e.jsx(O.Provider, { value: { documents: n, images: u }, children: l });
260
- }
261
- function ve(t) {
262
- const { documents: s, images: l } = ne(O);
263
- return t === "documents" ? s : l;
264
- }
265
- function we(t, s) {
266
- const l = M().map(({ categoryName: n }) => n);
267
- return s && l.includes(s) ? t.filter((n) => n.category === s) : t.filter(
268
- (n) => !n.category || !l.includes(n.category)
269
- );
270
- }
271
- function E({ type: t, category: s }) {
272
- const { loading: l, files: n, uploadFile: u, deleteFile: i, fetchFile: m } = ve(t), A = X(() => we(n, s), [n, s]), [g, f] = B(!1), [h, d] = B(!1), [x, o] = B(0), { t: F } = R(), I = oe();
273
- async function v(j) {
274
- const C = await m(j);
275
- G.saveAs(new Blob([C]), j.filename);
276
- }
277
- function y(j) {
278
- t === "images" ? (o(A.indexOf(j)), d(!0)) : v(j);
279
- }
280
- async function b(j) {
281
- try {
282
- await u(j, s);
283
- } catch (C) {
284
- console.error(C), J(/* @__PURE__ */ e.jsx(p, { i18nKey: "files.error.unknown", children: "Operation failed" }));
285
- }
286
- }
287
- async function w(j) {
288
- await I({
289
- title: F("assets.detail.files.deleteConfirmTitle", { defaultValue: "Delete File" }),
290
- message: F("assets.detail.files.deleteConfirmMessage", {
291
- defaultValue: "Do you really want to delete this file?"
292
- })
293
- }) && await i(j);
294
- }
295
- return /* @__PURE__ */ e.jsxs("div", { children: [
296
- /* @__PURE__ */ e.jsx(
297
- Fe,
298
- {
299
- files: A,
300
- loading: l,
301
- type: t,
302
- onDownload: v,
303
- onFilenameClick: y,
304
- onDelete: w
305
- }
306
- ),
307
- /* @__PURE__ */ e.jsx($, { authorities: ["WRITE_ASSET_OR_ASSET_GROUP_FILE"], children: /* @__PURE__ */ e.jsxs(k, { onClick: () => f(!0), "data-testid": "add-file-button", children: [
308
- /* @__PURE__ */ e.jsx(W, { add: !0 }),
309
- t === "images" && /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.addImage", children: "Add image" }),
310
- t === "documents" && /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.addFile", children: "Add file" })
311
- ] }) }),
312
- g && /* @__PURE__ */ e.jsx(Ae, { fileType: t, onClose: () => f(!1), onUpload: b }),
313
- h && /* @__PURE__ */ e.jsx(
314
- he,
315
- {
316
- initialImageNumber: x,
317
- items: A,
318
- onDownload: m,
319
- onClose: () => d(!1)
320
- }
321
- )
322
- ] });
323
- }
324
- function ye() {
325
- return [
326
- {
327
- path: "documents",
328
- renderHeading: () => /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.tabs.documents", children: "Documents" }),
329
- renderBody: () => /* @__PURE__ */ e.jsx(E, { type: "documents" })
330
- },
331
- ...M().filter(({ type: t }) => t === "documents").map(({ categoryName: t, locizeKey: s, locizeDefaultValue: l }) => ({
332
- path: t,
333
- renderHeading: () => /* @__PURE__ */ e.jsx(p, { i18nKey: s, children: l }),
334
- renderBody: () => /* @__PURE__ */ e.jsx(E, { type: "documents", category: t })
335
- })),
336
- {
337
- path: "images",
338
- renderHeading: () => /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.tabs.images", children: "Images" }),
339
- renderBody: () => /* @__PURE__ */ e.jsx(E, { type: "images" })
340
- },
341
- ...M().filter(({ type: t }) => t === "images").map(({ categoryName: t, locizeKey: s, locizeDefaultValue: l }) => ({
342
- path: t,
343
- renderHeading: () => /* @__PURE__ */ e.jsx(p, { i18nKey: s, children: l }),
344
- renderBody: () => /* @__PURE__ */ e.jsx(E, { type: "images", category: t })
345
- }))
346
- ];
347
- }
348
- function Ke({ asset: t, assetGroup: s }) {
349
- return /* @__PURE__ */ e.jsxs("div", { children: [
350
- /* @__PURE__ */ e.jsx(
351
- te,
352
- {
353
- title: {
354
- id: "assets.detail.files.name",
355
- defaultValue: "Files"
356
- }
357
- }
358
- ),
359
- /* @__PURE__ */ e.jsx(Ce, { asset: t, assetGroup: s, children: /* @__PURE__ */ e.jsx(se, { pages: ye() }) })
360
- ] });
361
- }
362
- export {
363
- Ke as default
364
- };