myio-js-library 0.1.570 → 0.1.571
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/index.cjs +217 -23
- package/dist/index.d.cts +63 -1
- package/dist/index.d.ts +63 -1
- package/dist/index.js +216 -23
- package/dist/myio-js-library.umd.js +216 -23
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -890,6 +890,7 @@ __export(src_exports, {
|
|
|
890
890
|
resolveClassification: () => resolveClassification,
|
|
891
891
|
resolveGoalAmount: () => resolveGoalAmount,
|
|
892
892
|
resolveGroup: () => resolveGroup,
|
|
893
|
+
resolveManualDeviceName: () => resolveManualDeviceName,
|
|
893
894
|
resolveMoneyRollout: () => resolveMoneyRollout,
|
|
894
895
|
resolveMoneyRowValues: () => resolveMoneyRowValues,
|
|
895
896
|
resolvePercentDecimals: () => resolvePercentDecimals,
|
|
@@ -953,7 +954,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
953
954
|
// package.json
|
|
954
955
|
var package_default = {
|
|
955
956
|
name: "myio-js-library",
|
|
956
|
-
version: "0.1.
|
|
957
|
+
version: "0.1.571",
|
|
957
958
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
958
959
|
license: "MIT",
|
|
959
960
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -112148,7 +112149,7 @@ async function openClearGcdrIdsModal(state6) {
|
|
|
112148
112149
|
opacity:${disabled ? "0.5" : "1"};
|
|
112149
112150
|
" ${disabled ? "disabled" : ""}>${label}</button>`;
|
|
112150
112151
|
}
|
|
112151
|
-
function
|
|
112152
|
+
function progressHtml2(phase, done, total) {
|
|
112152
112153
|
const pct = total > 0 ? Math.round(done / total * 100) : 0;
|
|
112153
112154
|
return `
|
|
112154
112155
|
<div style="padding:8px 0;">
|
|
@@ -112204,7 +112205,7 @@ async function openClearGcdrIdsModal(state6) {
|
|
|
112204
112205
|
${tableHtml(assetToClear, GCDR_CLEAR_ASSET_KEYS)}
|
|
112205
112206
|
${devToClear.length + assetToClear.length === 0 ? '<div style="text-align:center; color:#6b7280; padding:16px 0; font-size:13px;">\u2705 Nenhum device ou asset possui essas chaves. Nada a limpar.</div>' : ""}`;
|
|
112206
112207
|
}
|
|
112207
|
-
renderShell(
|
|
112208
|
+
renderShell(progressHtml2("Buscando devices e assets\u2026", 0, 0), "");
|
|
112208
112209
|
try {
|
|
112209
112210
|
const [devicesResp, assetsResp] = await Promise.all([
|
|
112210
112211
|
tbFetch(state6, `/api/customer/${customerId}/devices?pageSize=1000&page=0`),
|
|
@@ -112233,7 +112234,7 @@ async function openClearGcdrIdsModal(state6) {
|
|
|
112233
112234
|
}));
|
|
112234
112235
|
const done = deviceRows.length + assetRows.length;
|
|
112235
112236
|
const bodyEl = overlay.querySelector("#gcdr-clear-body");
|
|
112236
|
-
if (bodyEl) bodyEl.innerHTML =
|
|
112237
|
+
if (bodyEl) bodyEl.innerHTML = progressHtml2(`Lendo SERVER_SCOPE (${entityType})\u2026`, done, total);
|
|
112237
112238
|
}
|
|
112238
112239
|
}
|
|
112239
112240
|
const fetchDeviceAttrs = async (id) => {
|
|
@@ -112263,7 +112264,7 @@ async function openClearGcdrIdsModal(state6) {
|
|
|
112263
112264
|
overlay.querySelector("#gcdr-clear-apply")?.addEventListener("click", async () => {
|
|
112264
112265
|
let done3 = 0;
|
|
112265
112266
|
overlay.querySelector("#gcdr-clear-footer").innerHTML = "";
|
|
112266
|
-
overlay.querySelector("#gcdr-clear-body").innerHTML =
|
|
112267
|
+
overlay.querySelector("#gcdr-clear-body").innerHTML = progressHtml2("Removendo atributos GCDR\u2026", 0, totalToClear);
|
|
112267
112268
|
async function execClear(rows, keys, entityType) {
|
|
112268
112269
|
const results = [];
|
|
112269
112270
|
const chunks = [];
|
|
@@ -112280,7 +112281,7 @@ async function openClearGcdrIdsModal(state6) {
|
|
|
112280
112281
|
}
|
|
112281
112282
|
done3++;
|
|
112282
112283
|
const progEl = overlay.querySelector("#gcdr-clear-body");
|
|
112283
|
-
if (progEl) progEl.innerHTML =
|
|
112284
|
+
if (progEl) progEl.innerHTML = progressHtml2("Removendo atributos GCDR\u2026", done3, totalToClear);
|
|
112284
112285
|
}));
|
|
112285
112286
|
}
|
|
112286
112287
|
return results;
|
|
@@ -115267,7 +115268,7 @@ function splitImportableDevices(devices) {
|
|
|
115267
115268
|
const missingKey = [];
|
|
115268
115269
|
for (const d of devices || []) {
|
|
115269
115270
|
const slave = Number(d?.slaveId);
|
|
115270
|
-
if (d?.centralId && UUID_RE.test(String(d.centralId)) && Number.isInteger(slave) && slave >= 1
|
|
115271
|
+
if (d?.centralId && UUID_RE.test(String(d.centralId)) && Number.isInteger(slave) && slave >= 1) ok.push(d);
|
|
115271
115272
|
else missingKey.push(d);
|
|
115272
115273
|
}
|
|
115273
115274
|
return { ok, missingKey };
|
|
@@ -115402,7 +115403,7 @@ function rowsFromTable(domain, table) {
|
|
|
115402
115403
|
}
|
|
115403
115404
|
const lineErrors = [];
|
|
115404
115405
|
if (!UUID_RE.test(gw)) lineErrors.push("gateway_id inv\xE1lido");
|
|
115405
|
-
if (!Number.isInteger(slave) || slave < 1
|
|
115406
|
+
if (!Number.isInteger(slave) || slave < 1) lineErrors.push("slave_id deve ser inteiro maior ou igual a 1");
|
|
115406
115407
|
if (!date) lineErrors.push("data inv\xE1lida (use AAAA-MM-DD)");
|
|
115407
115408
|
if (!hour) lineErrors.push("hora inv\xE1lida (use HH:00)");
|
|
115408
115409
|
if (Number.isNaN(value) || value < 0) lineErrors.push("valor deve ser n\xFAmero \u2265 0");
|
|
@@ -115963,20 +115964,12 @@ function nextManualSeq(domain, sigla, existingNames) {
|
|
|
115963
115964
|
}, 0);
|
|
115964
115965
|
return max + 1;
|
|
115965
115966
|
}
|
|
115966
|
-
async function
|
|
115967
|
-
const domain = params.domain;
|
|
115968
|
-
const profile = MANUAL_DEVICE_PROFILES[domain];
|
|
115969
|
-
if (!profile) throw new ManualDeviceError(`Dom\xEDnio inv\xE1lido: ${domain}`);
|
|
115970
|
-
const label = String(params.label || "").trim();
|
|
115971
|
-
const identifier = String(params.identifier || "").trim();
|
|
115972
|
-
if (!label) throw new ManualDeviceError("Informe a etiqueta.");
|
|
115973
|
-
if (!identifier) throw new ManualDeviceError("Informe o identificador.");
|
|
115974
|
-
if (!params.customerId) throw new ManualDeviceError("Cliente n\xE3o identificado.");
|
|
115967
|
+
async function buildTbApi(params) {
|
|
115975
115968
|
const base = params.baseUrl ?? "";
|
|
115976
115969
|
const doFetch = params.fetchImpl ?? fetch.bind(window);
|
|
115977
115970
|
const tokenValue = typeof params.token === "function" ? await params.token() : params.token;
|
|
115978
115971
|
const headers = { "X-Authorization": `Bearer ${tokenValue}`, "Content-Type": "application/json" };
|
|
115979
|
-
|
|
115972
|
+
return async (method, path, body, okStatuses = []) => {
|
|
115980
115973
|
const res = await doFetch(`${base}${path}`, {
|
|
115981
115974
|
method,
|
|
115982
115975
|
headers,
|
|
@@ -115989,7 +115982,9 @@ async function createManualDevice(params) {
|
|
|
115989
115982
|
const text2 = await res.text().catch(() => "");
|
|
115990
115983
|
return text2 ? JSON.parse(text2) : null;
|
|
115991
115984
|
};
|
|
115992
|
-
|
|
115985
|
+
}
|
|
115986
|
+
async function findManualAsset(api, customerId) {
|
|
115987
|
+
const cid = encodeURIComponent(customerId);
|
|
115993
115988
|
const assets = await api("GET", `/api/customer/${cid}/assets?pageSize=100&page=0&textSearch=MANUAIS`);
|
|
115994
115989
|
const asset = (assets?.data || []).find(
|
|
115995
115990
|
(a) => String(a?.name || "").toUpperCase().endsWith(MANUAL_ASSET_SUFFIX)
|
|
@@ -116007,12 +116002,45 @@ async function createManualDevice(params) {
|
|
|
116007
116002
|
`n\xE3o foi poss\xEDvel extrair a sigla de "${asset.name}"`
|
|
116008
116003
|
);
|
|
116009
116004
|
}
|
|
116005
|
+
return { asset, sigla };
|
|
116006
|
+
}
|
|
116007
|
+
async function existingManualNames(api, customerId, sigla) {
|
|
116010
116008
|
const existing = await api(
|
|
116011
116009
|
"GET",
|
|
116012
|
-
`/api/customer/${
|
|
116010
|
+
`/api/customer/${encodeURIComponent(customerId)}/devices?pageSize=1000&page=0&textSearch=${encodeURIComponent(`${sigla}_LOJA_`)}`
|
|
116013
116011
|
);
|
|
116014
|
-
|
|
116015
|
-
|
|
116012
|
+
return (existing?.data || []).map((d) => String(d?.name || ""));
|
|
116013
|
+
}
|
|
116014
|
+
async function resolveManualDeviceName(params) {
|
|
116015
|
+
const profile = MANUAL_DEVICE_PROFILES[params.domain];
|
|
116016
|
+
if (!profile) throw new ManualDeviceError(`Dom\xEDnio inv\xE1lido: ${params.domain}`);
|
|
116017
|
+
if (!params.customerId) throw new ManualDeviceError("Cliente n\xE3o identificado.");
|
|
116018
|
+
const api = await buildTbApi(params);
|
|
116019
|
+
const { asset, sigla } = await findManualAsset(api, params.customerId);
|
|
116020
|
+
const seq = nextManualSeq(params.domain, sigla, await existingManualNames(api, params.customerId, sigla));
|
|
116021
|
+
return {
|
|
116022
|
+
name: manualDeviceName(params.domain, sigla, seq),
|
|
116023
|
+
sigla,
|
|
116024
|
+
seq,
|
|
116025
|
+
assetId: asset.id.id,
|
|
116026
|
+
assetName: asset.name,
|
|
116027
|
+
deviceProfile: profile
|
|
116028
|
+
};
|
|
116029
|
+
}
|
|
116030
|
+
async function createManualDevice(params) {
|
|
116031
|
+
const domain = params.domain;
|
|
116032
|
+
const profile = MANUAL_DEVICE_PROFILES[domain];
|
|
116033
|
+
if (!profile) throw new ManualDeviceError(`Dom\xEDnio inv\xE1lido: ${domain}`);
|
|
116034
|
+
const label = String(params.label || "").trim();
|
|
116035
|
+
const identifier = String(params.identifier || "").trim();
|
|
116036
|
+
if (!label) throw new ManualDeviceError("Informe a etiqueta.");
|
|
116037
|
+
if (!identifier) throw new ManualDeviceError("Informe o identificador.");
|
|
116038
|
+
if (!params.customerId) throw new ManualDeviceError("Cliente n\xE3o identificado.");
|
|
116039
|
+
const api = await buildTbApi(params);
|
|
116040
|
+
const cid = encodeURIComponent(params.customerId);
|
|
116041
|
+
const { asset, sigla } = await findManualAsset(api, params.customerId);
|
|
116042
|
+
const fixedName = String(params.name || "").trim();
|
|
116043
|
+
let seq = fixedName ? 0 : nextManualSeq(domain, sigla, await existingManualNames(api, params.customerId, sigla));
|
|
116016
116044
|
let deviceProfileId;
|
|
116017
116045
|
try {
|
|
116018
116046
|
const profiles = await api("GET", `/api/deviceProfileInfos?pageSize=50&page=0&textSearch=${encodeURIComponent(profile)}`);
|
|
@@ -116020,7 +116048,7 @@ async function createManualDevice(params) {
|
|
|
116020
116048
|
if (p?.id?.id) deviceProfileId = { id: p.id.id, entityType: "DEVICE_PROFILE" };
|
|
116021
116049
|
} catch {
|
|
116022
116050
|
}
|
|
116023
|
-
let name = manualDeviceName(domain, sigla, seq);
|
|
116051
|
+
let name = fixedName || manualDeviceName(domain, sigla, seq);
|
|
116024
116052
|
let created = null;
|
|
116025
116053
|
for (let attempt = 0; ; attempt++) {
|
|
116026
116054
|
try {
|
|
@@ -116033,6 +116061,9 @@ async function createManualDevice(params) {
|
|
|
116033
116061
|
break;
|
|
116034
116062
|
} catch (err) {
|
|
116035
116063
|
const dup = /already exists|já existe/i.test(err?.detail || "");
|
|
116064
|
+
if (fixedName && dup) {
|
|
116065
|
+
throw new ManualDeviceError(`J\xE1 existe um dispositivo chamado ${fixedName} no ThingsBoard.`, err?.detail);
|
|
116066
|
+
}
|
|
116036
116067
|
if (!dup || attempt >= 4) throw err;
|
|
116037
116068
|
seq += 1;
|
|
116038
116069
|
name = manualDeviceName(domain, sigla, seq);
|
|
@@ -116055,6 +116086,7 @@ async function createManualDevice(params) {
|
|
|
116055
116086
|
typeGroup: "COMMON"
|
|
116056
116087
|
});
|
|
116057
116088
|
await api("POST", `/api/plugins/telemetry/DEVICE/${deviceId}/attributes/SERVER_SCOPE`, {
|
|
116089
|
+
...params.extraAttributes || {},
|
|
116058
116090
|
deviceProfile: profile,
|
|
116059
116091
|
identifier
|
|
116060
116092
|
});
|
|
@@ -116108,6 +116140,18 @@ function injectStyles15() {
|
|
|
116108
116140
|
border: 1px dashed #e5e7eb; border-radius: 6px; padding: 8px 10px; line-height: 1.6;
|
|
116109
116141
|
}
|
|
116110
116142
|
.myio-manualdev__tech code { font-size: 11.5px; color: #374151; }
|
|
116143
|
+
.myio-manualdev__summary { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
116144
|
+
.myio-manualdev__summary th { text-align: left; font-weight: 500; color: #6b7280; padding: 4px 8px 4px 0; width: 42%; vertical-align: top; }
|
|
116145
|
+
.myio-manualdev__summary td { color: #111827; padding: 4px 0; word-break: break-word; }
|
|
116146
|
+
.myio-manualdev__steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
116147
|
+
.myio-manualdev__step { display: grid; grid-template-columns: 22px 92px 1fr; gap: 8px; align-items: start; font-size: 13px; }
|
|
116148
|
+
.myio-manualdev__step-sys { font-weight: 600; color: #3e1a7d; }
|
|
116149
|
+
.myio-manualdev__step-msg { display: block; font-size: 11.5px; color: #6b7280; word-break: break-word; }
|
|
116150
|
+
.myio-manualdev__step[data-status="error"] .myio-manualdev__step-msg { color: #991b1b; }
|
|
116151
|
+
.myio-manualdev__step[data-status="warn"] .myio-manualdev__step-msg { color: #92400e; }
|
|
116152
|
+
.myio-manualdev__note { margin: 0; font-size: 12.5px; border-radius: 6px; padding: 8px 10px; }
|
|
116153
|
+
.myio-manualdev__note--warn { color: #92400e; background: #fef3c7; }
|
|
116154
|
+
.myio-manualdev__note--block { color: #991b1b; background: #fee2e2; }
|
|
116111
116155
|
`;
|
|
116112
116156
|
document.head.appendChild(style);
|
|
116113
116157
|
}
|
|
@@ -116145,10 +116189,52 @@ function successHtml(domain, r, tech) {
|
|
|
116145
116189
|
</div>` : ""}
|
|
116146
116190
|
</div>`;
|
|
116147
116191
|
}
|
|
116192
|
+
var STEP_ICON = {
|
|
116193
|
+
pending: "\u25CB",
|
|
116194
|
+
running: "\u23F3",
|
|
116195
|
+
ok: "\u2705",
|
|
116196
|
+
warn: "\u26A0\uFE0F",
|
|
116197
|
+
error: "\u274C",
|
|
116198
|
+
skipped: "\u23ED\uFE0F",
|
|
116199
|
+
rolledback: "\u21A9\uFE0F"
|
|
116200
|
+
};
|
|
116201
|
+
function stepsHtml(steps) {
|
|
116202
|
+
return `<ol class="myio-manualdev__steps">${steps.map(
|
|
116203
|
+
(s) => `<li class="myio-manualdev__step" data-status="${escapeHtml14(s.status)}">
|
|
116204
|
+
<span aria-hidden="true">${STEP_ICON[s.status] || "\u25CB"}</span>
|
|
116205
|
+
<span class="myio-manualdev__step-sys">${escapeHtml14(s.system)}</span>
|
|
116206
|
+
<span>${escapeHtml14(s.title)}${s.message ? `<small class="myio-manualdev__step-msg">${escapeHtml14(s.message)}</small>` : ""}</span>
|
|
116207
|
+
</li>`
|
|
116208
|
+
).join("")}</ol>`;
|
|
116209
|
+
}
|
|
116210
|
+
function notesHtml(plan) {
|
|
116211
|
+
const block = (plan.blockers || []).map((b) => `<p class="myio-manualdev__note myio-manualdev__note--block" role="alert">\u26D4 ${escapeHtml14(b)}</p>`);
|
|
116212
|
+
const warn = (plan.warnings || []).map((w) => `<p class="myio-manualdev__note myio-manualdev__note--warn">\u26A0\uFE0F ${escapeHtml14(w)}</p>`);
|
|
116213
|
+
return [...block, ...warn].join("");
|
|
116214
|
+
}
|
|
116215
|
+
function planHtml(plan) {
|
|
116216
|
+
return `
|
|
116217
|
+
<div class="myio-manualdev">
|
|
116218
|
+
<p class="myio-manualdev__hint">Revise o que ser\xE1 criado. Nada foi gravado ainda.</p>
|
|
116219
|
+
<table class="myio-manualdev__summary"><tbody>${plan.summary.map((r) => `<tr><th>${escapeHtml14(r.label)}</th><td>${escapeHtml14(r.value)}</td></tr>`).join("")}</tbody></table>
|
|
116220
|
+
${stepsHtml(plan.steps)}
|
|
116221
|
+
${notesHtml(plan)}
|
|
116222
|
+
</div>`;
|
|
116223
|
+
}
|
|
116224
|
+
function progressHtml(steps, message, ok) {
|
|
116225
|
+
return `
|
|
116226
|
+
<div class="myio-manualdev">
|
|
116227
|
+
${ok === void 0 ? '<p class="myio-manualdev__hint">Criando nos sistemas\u2026 n\xE3o feche esta janela.</p>' : `<p class="myio-manualdev__note ${ok ? "myio-manualdev__note--warn" : "myio-manualdev__note--block"}" role="status">${escapeHtml14(
|
|
116228
|
+
message || (ok ? "Conclu\xEDdo com avisos." : "N\xE3o foi poss\xEDvel concluir.")
|
|
116229
|
+
)}</p>`}
|
|
116230
|
+
${stepsHtml(steps)}
|
|
116231
|
+
</div>`;
|
|
116232
|
+
}
|
|
116148
116233
|
function openManualDeviceModal(params) {
|
|
116149
116234
|
const domain = params.domain;
|
|
116150
116235
|
if (!MANUAL_DEVICE_PROFILES[domain]) throw new Error(`[openManualDeviceModal] dom\xEDnio inv\xE1lido: ${domain}`);
|
|
116151
116236
|
injectStyles15();
|
|
116237
|
+
if (params.provisioner) return openProvisionedModal(params, params.provisioner);
|
|
116152
116238
|
const values = { label: "", identifier: "" };
|
|
116153
116239
|
let busy = false;
|
|
116154
116240
|
let created = null;
|
|
@@ -116218,6 +116304,113 @@ function openManualDeviceModal(params) {
|
|
|
116218
116304
|
}
|
|
116219
116305
|
return modal;
|
|
116220
116306
|
}
|
|
116307
|
+
function openProvisionedModal(params, provisioner) {
|
|
116308
|
+
const domain = params.domain;
|
|
116309
|
+
const values = { label: "", identifier: "" };
|
|
116310
|
+
let phase = "form";
|
|
116311
|
+
let plan = null;
|
|
116312
|
+
let outcome = null;
|
|
116313
|
+
const modal = openStandardModal({
|
|
116314
|
+
title: DOMAIN_TEXT2[domain].title,
|
|
116315
|
+
icon: DOMAIN_TEXT2[domain].icon,
|
|
116316
|
+
bodyHtml: formHtml(domain, values),
|
|
116317
|
+
width: 560,
|
|
116318
|
+
container: params.container,
|
|
116319
|
+
buttons: [
|
|
116320
|
+
{ label: "Cancelar", value: "cancel", variant: "secondary" },
|
|
116321
|
+
{ label: "Voltar", value: "back", variant: "secondary", closeOnClick: false },
|
|
116322
|
+
{ label: "Revisar", value: "next", variant: "primary", closeOnClick: false }
|
|
116323
|
+
],
|
|
116324
|
+
onButton: (v) => {
|
|
116325
|
+
if (v === "back" && phase === "plan") return showForm();
|
|
116326
|
+
if (v !== "next") return;
|
|
116327
|
+
if (phase === "form") return void review();
|
|
116328
|
+
if (phase === "plan") return void apply();
|
|
116329
|
+
if (phase === "done") {
|
|
116330
|
+
modal.close();
|
|
116331
|
+
if (outcome?.result) params.onCreated?.(outcome.result);
|
|
116332
|
+
}
|
|
116333
|
+
}
|
|
116334
|
+
});
|
|
116335
|
+
modal.setButton("back", { hidden: true });
|
|
116336
|
+
const bindForm = (focus = true) => {
|
|
116337
|
+
const form = modal.getBodyEl().querySelector("form");
|
|
116338
|
+
form?.addEventListener("submit", (e) => {
|
|
116339
|
+
e.preventDefault();
|
|
116340
|
+
void review();
|
|
116341
|
+
});
|
|
116342
|
+
if (focus) form?.querySelector('input[name="label"]')?.focus();
|
|
116343
|
+
};
|
|
116344
|
+
bindForm();
|
|
116345
|
+
function showForm(error, detail) {
|
|
116346
|
+
phase = "form";
|
|
116347
|
+
modal.setBodyHtml(formHtml(domain, values, error, detail));
|
|
116348
|
+
bindForm();
|
|
116349
|
+
modal.setButton("back", { hidden: true });
|
|
116350
|
+
modal.setButton("cancel", { disabled: false, hidden: false });
|
|
116351
|
+
modal.setButton("next", { disabled: false, label: "Revisar" });
|
|
116352
|
+
}
|
|
116353
|
+
const errorText = (err) => {
|
|
116354
|
+
const msg = err instanceof ManualDeviceError ? err.message : "N\xE3o foi poss\xEDvel montar o plano.";
|
|
116355
|
+
const detail = params.showTechnicalDetails ? (err instanceof ManualDeviceError ? err.detail : String(err?.message || err)) || void 0 : void 0;
|
|
116356
|
+
return { msg, detail };
|
|
116357
|
+
};
|
|
116358
|
+
async function review() {
|
|
116359
|
+
if (phase !== "form") return;
|
|
116360
|
+
const body = modal.getBodyEl();
|
|
116361
|
+
values.label = (body.querySelector('input[name="label"]')?.value || "").trim();
|
|
116362
|
+
values.identifier = (body.querySelector('input[name="identifier"]')?.value || "").trim();
|
|
116363
|
+
const missing = !values.label ? "label" : !values.identifier ? "identifier" : null;
|
|
116364
|
+
if (missing) {
|
|
116365
|
+
showForm(missing === "label" ? "Informe a etiqueta." : "Informe o identificador.");
|
|
116366
|
+
const input = modal.getBodyEl().querySelector(`input[name="${missing}"]`);
|
|
116367
|
+
input?.setAttribute("aria-invalid", "true");
|
|
116368
|
+
input?.focus();
|
|
116369
|
+
return;
|
|
116370
|
+
}
|
|
116371
|
+
phase = "planning";
|
|
116372
|
+
modal.setButton("next", { disabled: true, label: "Revisando\u2026" });
|
|
116373
|
+
body.querySelectorAll("input").forEach((i) => i.disabled = true);
|
|
116374
|
+
try {
|
|
116375
|
+
plan = await provisioner.plan({ domain, label: values.label, identifier: values.identifier });
|
|
116376
|
+
phase = "plan";
|
|
116377
|
+
modal.setBodyHtml(planHtml(plan));
|
|
116378
|
+
modal.setButton("back", { hidden: false, disabled: false });
|
|
116379
|
+
modal.setButton("next", { disabled: !!plan.blockers?.length, label: "Criar" });
|
|
116380
|
+
} catch (err) {
|
|
116381
|
+
const { msg, detail } = errorText(err);
|
|
116382
|
+
showForm(msg, detail);
|
|
116383
|
+
}
|
|
116384
|
+
}
|
|
116385
|
+
async function apply() {
|
|
116386
|
+
if (phase !== "plan" || !plan || plan.blockers?.length) return;
|
|
116387
|
+
phase = "applying";
|
|
116388
|
+
const steps = plan.steps.map((s) => ({ ...s }));
|
|
116389
|
+
modal.setBodyHtml(progressHtml(steps));
|
|
116390
|
+
modal.setButton("back", { hidden: true });
|
|
116391
|
+
modal.setButton("cancel", { hidden: true });
|
|
116392
|
+
modal.setButton("next", { disabled: true, label: "Criando\u2026" });
|
|
116393
|
+
const onStep = (step) => {
|
|
116394
|
+
const i = steps.findIndex((s) => s.key === step.key);
|
|
116395
|
+
if (i >= 0) steps[i] = { ...steps[i], ...step };
|
|
116396
|
+
else steps.push(step);
|
|
116397
|
+
modal.setBodyHtml(progressHtml(steps));
|
|
116398
|
+
};
|
|
116399
|
+
try {
|
|
116400
|
+
outcome = await provisioner.apply(plan, onStep);
|
|
116401
|
+
} catch (err) {
|
|
116402
|
+
outcome = { ok: false, steps, message: errorText(err).msg };
|
|
116403
|
+
}
|
|
116404
|
+
phase = "done";
|
|
116405
|
+
const finalSteps = outcome.steps?.length ? outcome.steps : steps;
|
|
116406
|
+
const clean = outcome.ok && finalSteps.every((s) => s.status === "ok");
|
|
116407
|
+
modal.setBodyHtml(
|
|
116408
|
+
clean && outcome.result ? successHtml(domain, outcome.result, !!params.showTechnicalDetails) + (params.showTechnicalDetails ? stepsHtml(finalSteps) : "") : progressHtml(finalSteps, outcome.message, outcome.ok)
|
|
116409
|
+
);
|
|
116410
|
+
modal.setButton("next", { disabled: false, label: outcome.ok ? "Concluir" : "Fechar" });
|
|
116411
|
+
}
|
|
116412
|
+
return modal;
|
|
116413
|
+
}
|
|
116221
116414
|
|
|
116222
116415
|
// src/components/myio-gcdr-login/dom.ts
|
|
116223
116416
|
function h2(doc, tag, attrs = {}, ...children) {
|
|
@@ -179107,6 +179300,7 @@ var version = package_default.version || "0.0.0";
|
|
|
179107
179300
|
resolveClassification,
|
|
179108
179301
|
resolveGoalAmount,
|
|
179109
179302
|
resolveGroup,
|
|
179303
|
+
resolveManualDeviceName,
|
|
179110
179304
|
resolveMoneyRollout,
|
|
179111
179305
|
resolveMoneyRowValues,
|
|
179112
179306
|
resolvePercentDecimals,
|