@deviceinsight/ng-ui-scale-lib 9.14.0
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/README.md +194 -0
- package/dist/AccessEditModal-a5347dbd.js +91 -0
- package/dist/BundleManagementContainer-842bd582.js +17 -0
- package/dist/BundlesContainer-44da5cdf.js +908 -0
- package/dist/ContextBarContext-f745a63a.js +95534 -0
- package/dist/DatapointImport-139761c5.js +860 -0
- package/dist/FileUploadInput-6dc037cb.js +44 -0
- package/dist/Files-cd57769d.js +360 -0
- package/dist/GlobalPowerBiReports-b5b89de7.js +11078 -0
- package/dist/Graph-c912ea08.js +25009 -0
- package/dist/JsonSettingWidget-3d9a995d.js +54 -0
- package/dist/LicensesEditPage-22cc7d68.js +143 -0
- package/dist/LicensesList-1f3f08e2.js +146 -0
- package/dist/PropertiesEditPage-c84dc0d9.js +370 -0
- package/dist/PropertiesList-fe8aa64d.js +265 -0
- package/dist/TemplateEditPage-f163ea2f.js +505 -0
- package/dist/TemplateTextInput-1ba4e19b.js +47 -0
- package/dist/TemplatesListPage-a11b0d84.js +326 -0
- package/dist/UserGroupAssignments-8710d8e3.js +293 -0
- package/dist/UserGroupTheme-0d0d7d48.js +280 -0
- package/dist/api.js +84 -0
- package/dist/consts-012135e5.js +33 -0
- package/dist/customFileCategories-1b64ed45.js +11 -0
- package/dist/extends-0a3e0827.js +13 -0
- package/dist/index-4f55daa8.js +18658 -0
- package/dist/index.js +17373 -0
- package/dist/react-router-f15627c1.js +1152 -0
- package/dist/setupRuntimeEnv.js +27 -0
- package/dist/style.css +1 -0
- package/dist/useCanDeleteBundleVersion-64f35949.js +45 -0
- package/package.json +161 -0
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import { at as e, ag as r, d6 as v, bJ as B, dd as $, ah as R, de as M, bi as S, df as z, b4 as q, b9 as U, bc as H, bf as J, bs as Q, bN as X, ad as Y } from "./ContextBarContext-f745a63a.js";
|
|
2
|
+
import Z, { useState as C, useRef as D, useContext as O, useEffect as w } from "react";
|
|
3
|
+
import { useParams as ee, useHistory as te, useLocation as ae } from "react-router-dom";
|
|
4
|
+
import { fetchEmailTemplateById as ne, fetchEmailTemplates as se, createEmailTemplate as ie, updateEmailTemplate as oe, deleteEmailTemplate as le } from "@deviceinsight/ng-ui-api-client";
|
|
5
|
+
import { Modal as _, Button as k, useConfirm as re, Accordion as ce, AccordionItem as de, Icon as A, ButtonRow as ue, SpinnerContainer as me } from "@deviceinsight/ng-ui-basic-components";
|
|
6
|
+
import { ReactableWithClientSidePagination as W, nanoid10 as fe, messageBoxError as K, ContentHeader as pe } from "@deviceinsight/ng-ui-components";
|
|
7
|
+
import { P as he } from "./react-router-f15627c1.js";
|
|
8
|
+
import { A as xe } from "./AccessEditModal-a5347dbd.js";
|
|
9
|
+
import "react-dom";
|
|
10
|
+
import "./extends-0a3e0827.js";
|
|
11
|
+
const je = (t) => [
|
|
12
|
+
{
|
|
13
|
+
name: "locale",
|
|
14
|
+
label: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.localePicker.localeCode", children: "Locale code" }),
|
|
15
|
+
sortable: !0,
|
|
16
|
+
render: ({ locale: a }) => /* @__PURE__ */ e.jsx("div", { onClick: () => t(a), className: "clickable", children: a })
|
|
17
|
+
}
|
|
18
|
+
], be = ({ locales: t, onSelect: a, onCancel: n }) => {
|
|
19
|
+
const c = t.map((s) => ({
|
|
20
|
+
locale: s
|
|
21
|
+
}));
|
|
22
|
+
return /* @__PURE__ */ e.jsx(
|
|
23
|
+
_,
|
|
24
|
+
{
|
|
25
|
+
className: "di notification-template-modal",
|
|
26
|
+
header: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.localePicker.title", children: "Select locale" }),
|
|
27
|
+
content: /* @__PURE__ */ e.jsx(
|
|
28
|
+
W,
|
|
29
|
+
{
|
|
30
|
+
columnDefs: je(a),
|
|
31
|
+
uniqueItemKey: (s) => `${s.locale}`,
|
|
32
|
+
items: c,
|
|
33
|
+
paginationSettings: {
|
|
34
|
+
page: 0,
|
|
35
|
+
size: c.length,
|
|
36
|
+
sort: {
|
|
37
|
+
property: "locale",
|
|
38
|
+
direction: "ASC"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
isLoading: !1
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
footer: /* @__PURE__ */ e.jsx(k, { onClick: n, children: /* @__PURE__ */ e.jsx(r, { i18nKey: v.cancel.id, children: v.cancel.defaultValue }) }),
|
|
45
|
+
width: 600
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}, Te = (t, a) => [
|
|
49
|
+
"asset.name",
|
|
50
|
+
...t.map(({ key: n }) => `asset.properties.${n}`),
|
|
51
|
+
...a.map(({ key: n }) => `assetGroup.${n}`),
|
|
52
|
+
"event.key",
|
|
53
|
+
"event.ruleId",
|
|
54
|
+
"event.timestamp?datetime"
|
|
55
|
+
], ye = (t) => [
|
|
56
|
+
{
|
|
57
|
+
name: "variable",
|
|
58
|
+
label: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.variablePicker.variable", children: "Variable" }),
|
|
59
|
+
render: (a) => /* @__PURE__ */ e.jsx("div", { onClick: () => t(a), className: "clickable", children: a })
|
|
60
|
+
}
|
|
61
|
+
], ge = () => {
|
|
62
|
+
const { assetProperties: t, assetGroupProperties: a } = B();
|
|
63
|
+
return {
|
|
64
|
+
assetProperties: t.filter((n) => !n.key.startsWith("_") && n.deletable),
|
|
65
|
+
assetGroupProperties: a.filter(
|
|
66
|
+
(n) => !n.key.startsWith("_") && n.deletable
|
|
67
|
+
)
|
|
68
|
+
};
|
|
69
|
+
}, Pe = ({ onSelect: t, onCancel: a }) => {
|
|
70
|
+
const { assetProperties: n, assetGroupProperties: c } = ge(), s = Te(n, c);
|
|
71
|
+
return /* @__PURE__ */ e.jsx(
|
|
72
|
+
_,
|
|
73
|
+
{
|
|
74
|
+
className: "di notification-template-modal",
|
|
75
|
+
header: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.variablePicker.title", children: "Select variable" }),
|
|
76
|
+
content: /* @__PURE__ */ e.jsx(
|
|
77
|
+
W,
|
|
78
|
+
{
|
|
79
|
+
columnDefs: ye(t),
|
|
80
|
+
uniqueItemKey: (m) => m,
|
|
81
|
+
items: s,
|
|
82
|
+
paginationSettings: {
|
|
83
|
+
page: 0,
|
|
84
|
+
size: 10,
|
|
85
|
+
sort: {
|
|
86
|
+
property: "locale",
|
|
87
|
+
direction: "ASC"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
isLoading: !1
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
footer: /* @__PURE__ */ e.jsx(k, { onClick: a, children: /* @__PURE__ */ e.jsx(r, { i18nKey: v.cancel.id, children: v.cancel.defaultValue }) }),
|
|
94
|
+
width: 600
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}, G = Z.lazy(() => import("./TemplateTextInput-1ba4e19b.js")), ve = (t, a) => t.locale === "default" ? -1 : a.locale === "default" ? 1 : t.locale.localeCompare(a.locale);
|
|
98
|
+
function Ce() {
|
|
99
|
+
const t = re(), [a, n] = C(!1), [c, s] = C("message"), {
|
|
100
|
+
watch: m,
|
|
101
|
+
control: h,
|
|
102
|
+
setValue: f,
|
|
103
|
+
formState: { errors: b }
|
|
104
|
+
} = $(), { t: g } = R(), P = D(null), d = D(null), o = m("locales");
|
|
105
|
+
async function l(x) {
|
|
106
|
+
await t({
|
|
107
|
+
title: g("notificationTemplate.form.confirmDeleteTitle", { defaultValue: "Delete translation" }),
|
|
108
|
+
message: g("notificationTemplate.form.confirmDeleteMessage", {
|
|
109
|
+
defaultValue: "Do you really want to delete this translation?"
|
|
110
|
+
})
|
|
111
|
+
}) && f(
|
|
112
|
+
"locales",
|
|
113
|
+
o.filter((y) => y.locale !== x),
|
|
114
|
+
{ shouldDirty: !0 }
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
function T() {
|
|
118
|
+
n(!0);
|
|
119
|
+
}
|
|
120
|
+
function j(x) {
|
|
121
|
+
const u = c === "subject" ? P.current : d.current;
|
|
122
|
+
if (u) {
|
|
123
|
+
const y = u.state.update({
|
|
124
|
+
changes: {
|
|
125
|
+
from: u.state.selection.main.head,
|
|
126
|
+
insert: `\${${x}}`
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
u.dispatch(y), n(!1);
|
|
130
|
+
} else
|
|
131
|
+
throw new Error("Codemirror field not found");
|
|
132
|
+
}
|
|
133
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "notification-content", children: [
|
|
134
|
+
/* @__PURE__ */ e.jsx("h2", { children: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplates.form.languages", children: "Languages" }) }),
|
|
135
|
+
/* @__PURE__ */ e.jsx(ce, { children: [...o].sort(ve).map((x) => {
|
|
136
|
+
var N;
|
|
137
|
+
const { locale: u } = x, y = /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.form.message", children: "Message" }), i = o.indexOf(x), p = !!((N = b.locales) != null && N[i]);
|
|
138
|
+
return /* @__PURE__ */ e.jsx(
|
|
139
|
+
de,
|
|
140
|
+
{
|
|
141
|
+
title: /* @__PURE__ */ e.jsxs("span", { className: "notification-locale-header", children: [
|
|
142
|
+
u,
|
|
143
|
+
p && /* @__PURE__ */ e.jsx("img", { src: M, alt: "" })
|
|
144
|
+
] }),
|
|
145
|
+
tools: [
|
|
146
|
+
/* @__PURE__ */ e.jsx(
|
|
147
|
+
k,
|
|
148
|
+
{
|
|
149
|
+
naked: !0,
|
|
150
|
+
disabled: u === "default",
|
|
151
|
+
onClick: () => l(u),
|
|
152
|
+
"data-testid": "delete-locale-button",
|
|
153
|
+
children: /* @__PURE__ */ e.jsx(A, { del: !0, large: !0 })
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
],
|
|
157
|
+
children: /* @__PURE__ */ e.jsxs("div", { className: "notification-content-fields", children: [
|
|
158
|
+
/* @__PURE__ */ e.jsxs("div", { className: "notification-content-fields-wrapper", children: [
|
|
159
|
+
/* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(
|
|
160
|
+
S,
|
|
161
|
+
{
|
|
162
|
+
name: `locales.${i}.subject`,
|
|
163
|
+
control: h,
|
|
164
|
+
rules: {
|
|
165
|
+
required: !0
|
|
166
|
+
},
|
|
167
|
+
render: ({ field: { value: V, onChange: L }, fieldState: { error: E } }) => /* @__PURE__ */ e.jsx(
|
|
168
|
+
G,
|
|
169
|
+
{
|
|
170
|
+
onFocus: () => s("subject"),
|
|
171
|
+
value: V,
|
|
172
|
+
onChange: L,
|
|
173
|
+
error: E ? g("notificationTemplates.form.subjectRequired", {
|
|
174
|
+
defaultValue: "Please input subject"
|
|
175
|
+
}) : void 0,
|
|
176
|
+
label: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.form.subject", children: "Subject" }),
|
|
177
|
+
required: !0,
|
|
178
|
+
refField: (I) => P.current = I
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
) }),
|
|
183
|
+
/* @__PURE__ */ e.jsx(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
style: {
|
|
187
|
+
marginTop: 10
|
|
188
|
+
},
|
|
189
|
+
children: /* @__PURE__ */ e.jsx(
|
|
190
|
+
S,
|
|
191
|
+
{
|
|
192
|
+
name: `locales.${o.indexOf(x)}.text`,
|
|
193
|
+
control: h,
|
|
194
|
+
rules: {
|
|
195
|
+
required: !0
|
|
196
|
+
},
|
|
197
|
+
render: ({ field: { value: V, onChange: L }, fieldState: { error: E } }) => /* @__PURE__ */ e.jsx(
|
|
198
|
+
G,
|
|
199
|
+
{
|
|
200
|
+
onFocus: () => s("text"),
|
|
201
|
+
value: V,
|
|
202
|
+
onChange: L,
|
|
203
|
+
error: E ? g("notificationTemplates.form.messageRequired", {
|
|
204
|
+
defaultValue: "Please input message"
|
|
205
|
+
}) : void 0,
|
|
206
|
+
label: y,
|
|
207
|
+
refField: (I) => d.current = I,
|
|
208
|
+
renderAs: "textarea",
|
|
209
|
+
required: !0
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
] }),
|
|
217
|
+
/* @__PURE__ */ e.jsx("div", { className: "notification-content-variables-wrapper", children: /* @__PURE__ */ e.jsxs(k, { naked: !0, onClick: T, "data-testid": "add-button", children: [
|
|
218
|
+
/* @__PURE__ */ e.jsx(A, { add: !0 }),
|
|
219
|
+
/* @__PURE__ */ e.jsx("span", { children: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.form.addVariables", children: "Add variables..." }) })
|
|
220
|
+
] }) })
|
|
221
|
+
] })
|
|
222
|
+
},
|
|
223
|
+
u
|
|
224
|
+
);
|
|
225
|
+
}) }),
|
|
226
|
+
a && /* @__PURE__ */ e.jsx(Pe, { onSelect: j, onCancel: () => n(!1) })
|
|
227
|
+
] });
|
|
228
|
+
}
|
|
229
|
+
function ke() {
|
|
230
|
+
const { t } = R(), { control: a } = $();
|
|
231
|
+
return /* @__PURE__ */ e.jsxs(z, { children: [
|
|
232
|
+
/* @__PURE__ */ e.jsx(
|
|
233
|
+
S,
|
|
234
|
+
{
|
|
235
|
+
control: a,
|
|
236
|
+
name: "displayName",
|
|
237
|
+
rules: {
|
|
238
|
+
required: !0
|
|
239
|
+
},
|
|
240
|
+
render: ({ field: n, fieldState: { error: c } }) => /* @__PURE__ */ e.jsx(
|
|
241
|
+
q,
|
|
242
|
+
{
|
|
243
|
+
...n,
|
|
244
|
+
error: c ? t("notificationTemplates.form.nameRequired", {
|
|
245
|
+
defaultValue: "Please enter a name"
|
|
246
|
+
}) : void 0,
|
|
247
|
+
required: !0,
|
|
248
|
+
label: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.form.name", children: "Name" })
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
),
|
|
253
|
+
/* @__PURE__ */ e.jsx(
|
|
254
|
+
S,
|
|
255
|
+
{
|
|
256
|
+
control: a,
|
|
257
|
+
name: "name",
|
|
258
|
+
render: ({ field: n }) => /* @__PURE__ */ e.jsx(
|
|
259
|
+
q,
|
|
260
|
+
{
|
|
261
|
+
...n,
|
|
262
|
+
label: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.form.technicalName", children: "Technical Name" }),
|
|
263
|
+
disabled: !0
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
] });
|
|
269
|
+
}
|
|
270
|
+
function Ne({ onCancel: t, onSubmit: a, disabled: n }) {
|
|
271
|
+
return /* @__PURE__ */ e.jsxs(ue, { dividing: !0, children: [
|
|
272
|
+
/* @__PURE__ */ e.jsx(k, { primary: !0, onClick: a, disabled: n, children: /* @__PURE__ */ e.jsx(r, { i18nKey: v.save.id, children: v.save.defaultValue }) }),
|
|
273
|
+
/* @__PURE__ */ e.jsx(k, { onClick: t, children: /* @__PURE__ */ e.jsx(r, { i18nKey: v.cancel.id, children: v.cancel.defaultValue }) })
|
|
274
|
+
] });
|
|
275
|
+
}
|
|
276
|
+
function we() {
|
|
277
|
+
return {
|
|
278
|
+
name: `__${fe()}`,
|
|
279
|
+
locales: [
|
|
280
|
+
{
|
|
281
|
+
locale: "default",
|
|
282
|
+
subject: "",
|
|
283
|
+
text: "",
|
|
284
|
+
id: 0
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
displayName: ""
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function Se({ onCancel: t, onSubmit: a, editedTemplateData: n }) {
|
|
291
|
+
const { locales: c } = O(U), s = H({
|
|
292
|
+
defaultValues: n ?? we()
|
|
293
|
+
}), {
|
|
294
|
+
handleSubmit: m,
|
|
295
|
+
setValue: h,
|
|
296
|
+
watch: f,
|
|
297
|
+
formState: { isSubmitting: b, isDirty: g }
|
|
298
|
+
} = s, [P, d] = C(!1), [o, l] = C(!1), T = f("locales");
|
|
299
|
+
function j() {
|
|
300
|
+
return m(a, (i) => {
|
|
301
|
+
console.warn("Validation error", i);
|
|
302
|
+
})();
|
|
303
|
+
}
|
|
304
|
+
async function x(i) {
|
|
305
|
+
d(!1), h("accountGroupsWithAccess", i), await j();
|
|
306
|
+
}
|
|
307
|
+
function u(i) {
|
|
308
|
+
l(!1), h("locales", [...T, { locale: i, id: 0, text: "", subject: "" }], { shouldDirty: !0 });
|
|
309
|
+
}
|
|
310
|
+
function y() {
|
|
311
|
+
return c.filter((i) => !T.some((p) => p.locale === i));
|
|
312
|
+
}
|
|
313
|
+
return /* @__PURE__ */ e.jsx(J, { ...s, children: /* @__PURE__ */ e.jsxs("div", { className: "template-form", children: [
|
|
314
|
+
/* @__PURE__ */ e.jsx(ke, {}),
|
|
315
|
+
/* @__PURE__ */ e.jsx(Ce, {}),
|
|
316
|
+
/* @__PURE__ */ e.jsx("div", { className: "di button-row add-locale", children: /* @__PURE__ */ e.jsxs(
|
|
317
|
+
k,
|
|
318
|
+
{
|
|
319
|
+
onClick: () => l(!0),
|
|
320
|
+
"data-testid": "add-locale-button",
|
|
321
|
+
disabled: !y().length,
|
|
322
|
+
naked: !0,
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ e.jsx(A, { add: !0 }),
|
|
325
|
+
/* @__PURE__ */ e.jsx("span", { children: /* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplate.form.addLocale", children: "Add locale..." }) })
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
) }),
|
|
329
|
+
/* @__PURE__ */ e.jsx(
|
|
330
|
+
Ne,
|
|
331
|
+
{
|
|
332
|
+
onCancel: t,
|
|
333
|
+
onSubmit: n ? j : () => d(!0),
|
|
334
|
+
disabled: b
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
o && /* @__PURE__ */ e.jsx(
|
|
338
|
+
be,
|
|
339
|
+
{
|
|
340
|
+
locales: y(),
|
|
341
|
+
onSelect: u,
|
|
342
|
+
onCancel: () => l(!1)
|
|
343
|
+
}
|
|
344
|
+
),
|
|
345
|
+
P && /* @__PURE__ */ e.jsx(
|
|
346
|
+
xe,
|
|
347
|
+
{
|
|
348
|
+
onSave: x,
|
|
349
|
+
onCancel: () => d(!1),
|
|
350
|
+
loading: b
|
|
351
|
+
}
|
|
352
|
+
),
|
|
353
|
+
/* @__PURE__ */ e.jsx(he, { message: "", when: g && !b })
|
|
354
|
+
] }) });
|
|
355
|
+
}
|
|
356
|
+
function Ve() {
|
|
357
|
+
const { templateId: t } = ee(), [a, n] = C(void 0), [c, s] = C(void 0), [m, h] = C(!0);
|
|
358
|
+
return w(() => {
|
|
359
|
+
if (!t || t === "create") {
|
|
360
|
+
h(!1);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
(async () => {
|
|
364
|
+
try {
|
|
365
|
+
const f = await ne(parseInt(t)), P = (await se({
|
|
366
|
+
name: f.name,
|
|
367
|
+
page: 0,
|
|
368
|
+
size: 2e3
|
|
369
|
+
})).filter((d) => d.name === f.name).map((d) => ({
|
|
370
|
+
id: d.id,
|
|
371
|
+
locale: d.locale ?? "default",
|
|
372
|
+
text: d.text,
|
|
373
|
+
subject: d.subject ?? ""
|
|
374
|
+
}));
|
|
375
|
+
n({
|
|
376
|
+
accountGroupsWithAccess: void 0,
|
|
377
|
+
name: f.name,
|
|
378
|
+
displayName: f.displayName,
|
|
379
|
+
locales: P
|
|
380
|
+
});
|
|
381
|
+
} catch (f) {
|
|
382
|
+
s(f);
|
|
383
|
+
} finally {
|
|
384
|
+
h(!1);
|
|
385
|
+
}
|
|
386
|
+
})();
|
|
387
|
+
}, [t]), {
|
|
388
|
+
loading: m,
|
|
389
|
+
error: c,
|
|
390
|
+
initialFormData: a
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function Le(t) {
|
|
394
|
+
return t.map((a) => ie(a));
|
|
395
|
+
}
|
|
396
|
+
function Ee(t) {
|
|
397
|
+
return t.map((a) => oe(a));
|
|
398
|
+
}
|
|
399
|
+
function Ie(t) {
|
|
400
|
+
return t.map((a) => le(a));
|
|
401
|
+
}
|
|
402
|
+
function F(t, a) {
|
|
403
|
+
const { name: n, displayName: c, accountGroupsWithAccess: s } = a, m = a.locales.find((b) => b.locale === t);
|
|
404
|
+
if (!m)
|
|
405
|
+
throw new Error(`Locale ${t} not found`);
|
|
406
|
+
const { subject: h, text: f } = m;
|
|
407
|
+
return {
|
|
408
|
+
accountGroupsWithAccess: s,
|
|
409
|
+
name: n,
|
|
410
|
+
displayName: c,
|
|
411
|
+
tenant: Y.getTenant(),
|
|
412
|
+
locale: t === "default" ? null : t,
|
|
413
|
+
subject: h,
|
|
414
|
+
text: f,
|
|
415
|
+
scope: "CONDITION_MONITORING"
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function Ke(t, a, n) {
|
|
419
|
+
return {
|
|
420
|
+
id: t,
|
|
421
|
+
...F(a, n)
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
const Ae = (t, a) => t.subject !== a.subject || t.text !== a.text;
|
|
425
|
+
function Me() {
|
|
426
|
+
const { t } = R(), { setContextInfo: a } = O(Q), n = te(), { pathname: c } = ae(), { initialFormData: s, error: m, loading: h } = Ve();
|
|
427
|
+
async function f(o, l, T) {
|
|
428
|
+
const j = Le(o), x = Ee(l), u = Ie(T);
|
|
429
|
+
await Promise.all([...j, ...x, ...u]);
|
|
430
|
+
}
|
|
431
|
+
function b(o) {
|
|
432
|
+
const { locales: l } = o;
|
|
433
|
+
return f(
|
|
434
|
+
l.map(({ locale: T }) => F(T, o)),
|
|
435
|
+
[],
|
|
436
|
+
[]
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
function g(o) {
|
|
440
|
+
const { locales: l } = o, T = s == null ? void 0 : s.displayName, j = (s == null ? void 0 : s.locales) ?? [], x = j.filter(
|
|
441
|
+
({ locale: i }) => !l.some((p) => p.locale === i)
|
|
442
|
+
), u = l.filter(
|
|
443
|
+
({ locale: i }) => !j.some((p) => p.locale === i)
|
|
444
|
+
), y = T === o.displayName ? l.filter((i) => {
|
|
445
|
+
const p = j.find(
|
|
446
|
+
(N) => N.locale === i.locale
|
|
447
|
+
);
|
|
448
|
+
return p && Ae(p, i);
|
|
449
|
+
}) : l.filter(
|
|
450
|
+
(i) => j.some((p) => p.locale === i.locale)
|
|
451
|
+
);
|
|
452
|
+
return f(
|
|
453
|
+
u.map(({ locale: i }) => F(i, o)),
|
|
454
|
+
y.map(({ locale: i, id: p }) => Ke(p, i, o)),
|
|
455
|
+
x.map(({ id: i }) => i)
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
async function P(o) {
|
|
459
|
+
try {
|
|
460
|
+
s ? await g(o) : await b(o), d();
|
|
461
|
+
} catch (l) {
|
|
462
|
+
console.error("An error occured while trying to submit the template(s): ", l), l.response && l.response.status === 400 ? K(
|
|
463
|
+
/* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplates.form.nameOccupied", children: "Template with this name already exists" })
|
|
464
|
+
) : K(/* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplates.form.unknownError", children: "Unknown error occured" }));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function d() {
|
|
468
|
+
n.push("/portaladmin/templates");
|
|
469
|
+
}
|
|
470
|
+
return w(() => {
|
|
471
|
+
a({
|
|
472
|
+
type: "string",
|
|
473
|
+
value: (s == null ? void 0 : s.displayName) || (s == null ? void 0 : s.name) || "",
|
|
474
|
+
pathname: c
|
|
475
|
+
});
|
|
476
|
+
}, [s, c, a]), w(() => () => a(), [a]), w(() => {
|
|
477
|
+
m && (console.error(m), K(
|
|
478
|
+
/* @__PURE__ */ e.jsx(r, { i18nKey: "notificationTemplates.form.fetchFailed", children: "An error occurred while trying to fetch the template(s)" })
|
|
479
|
+
));
|
|
480
|
+
}, [m, t]), m ? /* @__PURE__ */ e.jsx(X, {}) : /* @__PURE__ */ e.jsxs(me, { show: h, children: [
|
|
481
|
+
/* @__PURE__ */ e.jsx(
|
|
482
|
+
pe,
|
|
483
|
+
{
|
|
484
|
+
parentPageLink: !0,
|
|
485
|
+
subPagePathPrefixArray: ["/email", "/sms"],
|
|
486
|
+
title: s ? t("notificationTemplate.form.editTemplate", {
|
|
487
|
+
defaultValue: "Edit Template"
|
|
488
|
+
}) : t("notificationTemplate.form.createTemplate", {
|
|
489
|
+
defaultValue: "Create Template"
|
|
490
|
+
})
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
!h && /* @__PURE__ */ e.jsx(
|
|
494
|
+
Se,
|
|
495
|
+
{
|
|
496
|
+
onCancel: d,
|
|
497
|
+
onSubmit: P,
|
|
498
|
+
editedTemplateData: s
|
|
499
|
+
}
|
|
500
|
+
)
|
|
501
|
+
] });
|
|
502
|
+
}
|
|
503
|
+
export {
|
|
504
|
+
Me as default
|
|
505
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { at as l, cz as x, aK as n } from "./ContextBarContext-f745a63a.js";
|
|
2
|
+
import j from "react";
|
|
3
|
+
import { C as d, j as b } from "./index-4f55daa8.js";
|
|
4
|
+
import "react-router-dom";
|
|
5
|
+
import "@deviceinsight/ng-ui-basic-components";
|
|
6
|
+
import "@deviceinsight/ng-ui-components";
|
|
7
|
+
import "@deviceinsight/ng-ui-api-client";
|
|
8
|
+
import "react-dom";
|
|
9
|
+
import "./extends-0a3e0827.js";
|
|
10
|
+
const G = j.forwardRef(
|
|
11
|
+
({ onFocus: r, onChange: i, refField: c, renderAs: a, ...o }, s) => {
|
|
12
|
+
function p() {
|
|
13
|
+
r();
|
|
14
|
+
}
|
|
15
|
+
const m = (t, e) => {
|
|
16
|
+
!a || a === "input" ? i == null || i(t.replace(/\n/g, ""), e) : i == null || i(t, e);
|
|
17
|
+
}, { label: f, ...u } = o;
|
|
18
|
+
return /* @__PURE__ */ l.jsx(x, { ...u, label: f, children: /* @__PURE__ */ l.jsx(
|
|
19
|
+
"div",
|
|
20
|
+
{
|
|
21
|
+
className: n("di notification-template-field", {
|
|
22
|
+
textarea: a === "textarea"
|
|
23
|
+
}),
|
|
24
|
+
children: /* @__PURE__ */ l.jsx(
|
|
25
|
+
d,
|
|
26
|
+
{
|
|
27
|
+
...o,
|
|
28
|
+
basicSetup: {
|
|
29
|
+
lineNumbers: !1,
|
|
30
|
+
highlightActiveLine: !1,
|
|
31
|
+
foldGutter: !1
|
|
32
|
+
},
|
|
33
|
+
onChange: (t, e) => m(t, e),
|
|
34
|
+
onCreateEditor: (t) => {
|
|
35
|
+
c(t), s && (typeof s == "function" ? s(t) : s.current = t);
|
|
36
|
+
},
|
|
37
|
+
onFocus: p,
|
|
38
|
+
extensions: [b()]
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
) });
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
export {
|
|
46
|
+
G as default
|
|
47
|
+
};
|