myio-js-library 0.1.573 → 0.1.575
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 +553 -129
- package/dist/index.d.cts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +553 -129
- package/dist/myio-js-library.umd.js +553 -129
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -558,7 +558,7 @@ __export(src_exports, {
|
|
|
558
558
|
doSchedulesOverlap: () => doSchedulesOverlap,
|
|
559
559
|
downloadAnnotationsTextFile: () => downloadTextFile,
|
|
560
560
|
encodeDeviceProductCode: () => encodeDeviceProductCode,
|
|
561
|
-
escapeAnnotationHtml: () =>
|
|
561
|
+
escapeAnnotationHtml: () => escapeHtml21,
|
|
562
562
|
evaluateDeviceStatus: () => evaluateDeviceStatus,
|
|
563
563
|
expandBandHours: () => expandBandHours,
|
|
564
564
|
expandBandToHourBucketsByYear: () => expandBandToHourBucketsByYear,
|
|
@@ -907,7 +907,7 @@ __export(src_exports, {
|
|
|
907
907
|
schedCreateNumberInput: () => createNumberInput,
|
|
908
908
|
schedCreateSelect: () => createSelect,
|
|
909
909
|
schedCreateTimeInput: () => createTimeInput,
|
|
910
|
-
schedEscapeHtml: () =>
|
|
910
|
+
schedEscapeHtml: () => escapeHtml20,
|
|
911
911
|
schedShowConfirmModal: () => showConfirmModal,
|
|
912
912
|
schedShowNotificationModal: () => showNotificationModal,
|
|
913
913
|
selectBreakdownItems: () => selectBreakdownItems,
|
|
@@ -958,7 +958,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
958
958
|
// package.json
|
|
959
959
|
var package_default = {
|
|
960
960
|
name: "myio-js-library",
|
|
961
|
-
version: "0.1.
|
|
961
|
+
version: "0.1.575",
|
|
962
962
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
963
963
|
license: "MIT",
|
|
964
964
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -63317,6 +63317,285 @@ var WellEquipmentTab = class {
|
|
|
63317
63317
|
}
|
|
63318
63318
|
};
|
|
63319
63319
|
|
|
63320
|
+
// src/components/premium-modals/settings/retrolavagem/RetrolavagemTab.ts
|
|
63321
|
+
var RETROLAVAGEM_PROFILE = "HIDROMETRO_ENTRADA_RETROLAVAGEM";
|
|
63322
|
+
var RETROLAVAGEM_BINDINGS_KEY = "retrolavagemBindings";
|
|
63323
|
+
var MAX_RETROLAVAGEM_DEVICES_PER_SIDE = 10;
|
|
63324
|
+
var MAX_CUSTOMER_DEVICE_PAGES2 = 100;
|
|
63325
|
+
var SIDE_TEXT = {
|
|
63326
|
+
inputs: { title: "Entrada", add: "+ Adicionar entrada", hint: "Hidr\xF4metros que medem a \xE1gua que entra na retrolavagem." },
|
|
63327
|
+
outputs: { title: "Sa\xEDda", add: "+ Adicionar sa\xEDda", hint: "Hidr\xF4metros que medem a \xE1gua que sai da retrolavagem." }
|
|
63328
|
+
};
|
|
63329
|
+
function isRetrolavagemCandidateProfile(profile) {
|
|
63330
|
+
const p = String(profile || "").trim().toUpperCase();
|
|
63331
|
+
return p.startsWith("HIDROMETRO") && p !== RETROLAVAGEM_PROFILE && !p.endsWith("_MANUAL");
|
|
63332
|
+
}
|
|
63333
|
+
function escapeHtml7(value) {
|
|
63334
|
+
return value.replace(/[&<>"']/g, (char) => ({
|
|
63335
|
+
"&": "&",
|
|
63336
|
+
"<": "<",
|
|
63337
|
+
">": ">",
|
|
63338
|
+
'"': """,
|
|
63339
|
+
"'": "'"
|
|
63340
|
+
})[char]);
|
|
63341
|
+
}
|
|
63342
|
+
function normalizeRetrolavagemBindings(value) {
|
|
63343
|
+
let parsed = value;
|
|
63344
|
+
if (typeof value === "string") {
|
|
63345
|
+
try {
|
|
63346
|
+
parsed = JSON.parse(value);
|
|
63347
|
+
} catch {
|
|
63348
|
+
parsed = null;
|
|
63349
|
+
}
|
|
63350
|
+
}
|
|
63351
|
+
const raw = parsed && typeof parsed === "object" ? parsed : {};
|
|
63352
|
+
const seen = /* @__PURE__ */ new Set();
|
|
63353
|
+
const side = (items) => (Array.isArray(items) ? items : []).filter((item) => !!item && typeof item === "object" && typeof item.tbId === "string" && !!item.tbId).filter((item) => seen.has(item.tbId) ? false : (seen.add(item.tbId), true)).slice(0, MAX_RETROLAVAGEM_DEVICES_PER_SIDE).map((item) => ({
|
|
63354
|
+
tbId: item.tbId,
|
|
63355
|
+
label: String(item.label || item.tbId),
|
|
63356
|
+
...item.gcdrId ? { gcdrId: String(item.gcdrId) } : {}
|
|
63357
|
+
}));
|
|
63358
|
+
const inputs = side(raw.inputs);
|
|
63359
|
+
const outputs = side(raw.outputs);
|
|
63360
|
+
return { version: 1, inputs, outputs };
|
|
63361
|
+
}
|
|
63362
|
+
var RetrolavagemTab = class {
|
|
63363
|
+
config;
|
|
63364
|
+
catalog = [];
|
|
63365
|
+
bindings = { version: 1, inputs: [], outputs: [] };
|
|
63366
|
+
/** Linhas na tela (tbId '' = linha vazia ainda sem device escolhido) */
|
|
63367
|
+
rows = { inputs: [], outputs: [] };
|
|
63368
|
+
loaded = false;
|
|
63369
|
+
catalogWarnings = 0;
|
|
63370
|
+
constructor(config2) {
|
|
63371
|
+
this.config = config2;
|
|
63372
|
+
}
|
|
63373
|
+
async init() {
|
|
63374
|
+
this.config.container.innerHTML = '<p class="rlt-state">Carregando v\xEDnculos e hidr\xF4metros\u2026</p>';
|
|
63375
|
+
try {
|
|
63376
|
+
const [attributes, catalog] = await Promise.all([
|
|
63377
|
+
this.fetchAttributes(this.config.deviceId, RETROLAVAGEM_BINDINGS_KEY),
|
|
63378
|
+
this.fetchCatalog()
|
|
63379
|
+
]);
|
|
63380
|
+
this.bindings = normalizeRetrolavagemBindings(attributes.get(RETROLAVAGEM_BINDINGS_KEY));
|
|
63381
|
+
this.catalog = catalog;
|
|
63382
|
+
this.rows = { inputs: this.bindings.inputs.map((d) => d.tbId), outputs: this.bindings.outputs.map((d) => d.tbId) };
|
|
63383
|
+
this.loaded = true;
|
|
63384
|
+
this.render();
|
|
63385
|
+
if (this.catalogWarnings > 0) {
|
|
63386
|
+
this.showMessage(`${this.catalogWarnings} hidr\xF4metro(s) n\xE3o puderam ser verificados e foram omitidos da lista.`, true);
|
|
63387
|
+
}
|
|
63388
|
+
} catch (error) {
|
|
63389
|
+
this.config.container.innerHTML = `<p class="rlt-state rlt-error" role="alert">N\xE3o foi poss\xEDvel carregar os v\xEDnculos ou a lista de hidr\xF4metros: ${escapeHtml7(
|
|
63390
|
+
this.errorMessage(error)
|
|
63391
|
+
)}</p>`;
|
|
63392
|
+
}
|
|
63393
|
+
}
|
|
63394
|
+
destroy() {
|
|
63395
|
+
}
|
|
63396
|
+
headers() {
|
|
63397
|
+
return { "X-Authorization": `Bearer ${this.config.jwtToken}`, "Content-Type": "application/json" };
|
|
63398
|
+
}
|
|
63399
|
+
async fetchAttributes(deviceId, keys) {
|
|
63400
|
+
const url = `${this.config.tbBaseUrl}/api/plugins/telemetry/DEVICE/${encodeURIComponent(deviceId)}/values/attributes/SERVER_SCOPE?keys=${encodeURIComponent(keys)}`;
|
|
63401
|
+
const response = await fetch(url, { headers: this.headers() });
|
|
63402
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
63403
|
+
const raw = await response.json();
|
|
63404
|
+
if (!Array.isArray(raw)) throw new Error("Resposta de atributos inv\xE1lida");
|
|
63405
|
+
return new Map(raw.map(({ key, value }) => [key, value]));
|
|
63406
|
+
}
|
|
63407
|
+
async fetchCatalog() {
|
|
63408
|
+
if (!this.config.customerId) throw new Error("customerId indispon\xEDvel");
|
|
63409
|
+
const devices = [];
|
|
63410
|
+
let page = 0;
|
|
63411
|
+
let hasNext = true;
|
|
63412
|
+
while (hasNext) {
|
|
63413
|
+
if (page >= MAX_CUSTOMER_DEVICE_PAGES2) throw new Error(`Lista excede o limite de ${MAX_CUSTOMER_DEVICE_PAGES2} p\xE1ginas`);
|
|
63414
|
+
const query = new URLSearchParams({ pageSize: "1000", page: String(page) });
|
|
63415
|
+
const response = await fetch(
|
|
63416
|
+
`${this.config.tbBaseUrl}/api/customer/${encodeURIComponent(this.config.customerId)}/devices?${query}`,
|
|
63417
|
+
{ headers: this.headers() }
|
|
63418
|
+
);
|
|
63419
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
63420
|
+
const result = await response.json();
|
|
63421
|
+
if (!Array.isArray(result.data)) throw new Error("Resposta de dispositivos inv\xE1lida");
|
|
63422
|
+
if (result.hasNext === true && result.data.length === 0) throw new Error("Pagina\xE7\xE3o da lista n\xE3o avan\xE7ou");
|
|
63423
|
+
devices.push(...result.data);
|
|
63424
|
+
hasNext = result.hasNext === true;
|
|
63425
|
+
page += 1;
|
|
63426
|
+
}
|
|
63427
|
+
const queue = devices.map((device) => ({ device, tbId: typeof device.id === "string" ? device.id : device.id?.id })).filter((item) => !!item.tbId && item.tbId !== this.config.deviceId);
|
|
63428
|
+
const matching = [];
|
|
63429
|
+
const worker = async () => {
|
|
63430
|
+
while (queue.length) {
|
|
63431
|
+
const item = queue.shift();
|
|
63432
|
+
if (!item) return;
|
|
63433
|
+
try {
|
|
63434
|
+
const attributes = await this.fetchAttributes(item.tbId, "deviceProfile,gcdrDeviceId");
|
|
63435
|
+
const profile = String(attributes.get("deviceProfile") || "").toUpperCase();
|
|
63436
|
+
if (!isRetrolavagemCandidateProfile(profile)) continue;
|
|
63437
|
+
matching.push({
|
|
63438
|
+
tbId: item.tbId,
|
|
63439
|
+
label: String(item.device.label || item.device.name || item.tbId),
|
|
63440
|
+
profile,
|
|
63441
|
+
...attributes.get("gcdrDeviceId") != null ? { gcdrId: String(attributes.get("gcdrDeviceId")) } : {}
|
|
63442
|
+
});
|
|
63443
|
+
} catch (error) {
|
|
63444
|
+
this.catalogWarnings += 1;
|
|
63445
|
+
console.warn(`[RetrolavagemTab] Falha ao ler atributos do hidr\xF4metro ${item.tbId}:`, error);
|
|
63446
|
+
}
|
|
63447
|
+
}
|
|
63448
|
+
};
|
|
63449
|
+
await Promise.all(Array.from({ length: Math.min(8, Math.max(1, queue.length)) }, () => worker()));
|
|
63450
|
+
return matching.sort((a, b) => a.label.localeCompare(b.label));
|
|
63451
|
+
}
|
|
63452
|
+
/** Vínculo salvo que não está mais no catálogo (device apagado, perfil mudou, sem acesso). */
|
|
63453
|
+
storedRef(tbId) {
|
|
63454
|
+
return [...this.bindings.inputs, ...this.bindings.outputs].find((d) => d.tbId === tbId);
|
|
63455
|
+
}
|
|
63456
|
+
sideHtml(side) {
|
|
63457
|
+
const text2 = SIDE_TEXT[side];
|
|
63458
|
+
const rows = this.rows[side];
|
|
63459
|
+
const full = rows.length >= MAX_RETROLAVAGEM_DEVICES_PER_SIDE;
|
|
63460
|
+
const options = (current) => {
|
|
63461
|
+
const missing = current && !this.catalog.some((o) => o.tbId === current) ? `<option value="${escapeHtml7(current)}" selected data-unavailable="true">V\xEDnculo atual indispon\xEDvel \u2014 ${escapeHtml7(
|
|
63462
|
+
this.storedRef(current)?.label || current
|
|
63463
|
+
)}</option>` : "";
|
|
63464
|
+
return `<option value="">Selecione\u2026</option>${missing}${this.catalog.map(
|
|
63465
|
+
(o) => `<option value="${escapeHtml7(o.tbId)}"${o.tbId === current ? " selected" : ""}>${escapeHtml7(o.label)} \xB7 ${escapeHtml7(o.profile)}</option>`
|
|
63466
|
+
).join("")}`;
|
|
63467
|
+
};
|
|
63468
|
+
return `
|
|
63469
|
+
<fieldset class="rlt-side" data-side="${side}">
|
|
63470
|
+
<legend>${text2.title} <span class="rlt-count">${rows.length}/${MAX_RETROLAVAGEM_DEVICES_PER_SIDE}</span></legend>
|
|
63471
|
+
<p class="rlt-hint">${text2.hint}</p>
|
|
63472
|
+
${rows.length ? rows.map(
|
|
63473
|
+
(tbId, i) => `<div class="rlt-row">
|
|
63474
|
+
<select data-side="${side}" data-index="${i}" aria-label="${text2.title} ${i + 1}">${options(tbId)}</select>
|
|
63475
|
+
<button type="button" class="rlt-remove" data-remove="${side}" data-index="${i}" aria-label="Remover ${text2.title} ${i + 1}">\u2715</button>
|
|
63476
|
+
</div>`
|
|
63477
|
+
).join("") : `<p class="rlt-empty">Nenhum hidr\xF4metro de ${text2.title.toLowerCase()}.</p>`}
|
|
63478
|
+
<button type="button" class="rlt-add" data-add="${side}" ${full ? "disabled" : ""}>${text2.add}</button>
|
|
63479
|
+
</fieldset>`;
|
|
63480
|
+
}
|
|
63481
|
+
render() {
|
|
63482
|
+
const noConfig = !this.rows.inputs.length && !this.rows.outputs.length;
|
|
63483
|
+
this.config.container.innerHTML = `
|
|
63484
|
+
<section class="rlt-tab">
|
|
63485
|
+
<p>Escolha os hidr\xF4metros de entrada e de sa\xEDda. A retrolavagem passa a ser <strong>total de entrada \u2212 total de sa\xEDda</strong>
|
|
63486
|
+
no per\xEDodo. O mesmo hidr\xF4metro pode ser usado em outras retrolavagens.</p>
|
|
63487
|
+
${noConfig ? '<p class="rlt-note">Sem v\xEDnculos, o painel usa a conta autom\xE1tica: entrada do shopping \u2212 consumo de lojas e \xE1rea comum.</p>' : ""}
|
|
63488
|
+
<div class="rlt-grid">${this.sideHtml("inputs")}${this.sideHtml("outputs")}</div>
|
|
63489
|
+
<p id="rlt-message" class="rlt-message" role="status" aria-live="polite"></p>
|
|
63490
|
+
<button type="button" id="rlt-save" ${this.loaded ? "" : "disabled"}>Salvar v\xEDnculos</button>
|
|
63491
|
+
</section>
|
|
63492
|
+
<style>
|
|
63493
|
+
.rlt-tab{padding:24px;color:#374151}.rlt-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:16px;margin-top:12px}
|
|
63494
|
+
.rlt-side{border:1px solid #e5e7eb;border-radius:8px;padding:12px 14px;margin:0}.rlt-side legend{font-weight:700;padding:0 6px}
|
|
63495
|
+
.rlt-count{font-weight:500;color:#6b7280;font-size:12px}.rlt-hint,.rlt-empty,.rlt-note{margin:0 0 10px;font-size:13px;color:#6b7280}
|
|
63496
|
+
.rlt-note{background:#f1ecfa;color:#3e1a7d;border-radius:6px;padding:8px 10px}
|
|
63497
|
+
.rlt-row{display:flex;gap:8px;margin-bottom:8px}.rlt-row select{flex:1;min-width:0;min-height:36px;padding:6px 8px;border:1px solid #d1d5db;border-radius:6px;background:#fff}
|
|
63498
|
+
.rlt-remove{border:1px solid #d1d5db;background:#fff;border-radius:6px;padding:0 10px;cursor:pointer;color:#6b7280}
|
|
63499
|
+
.rlt-add{border:1px dashed #9ca3af;background:#fff;border-radius:6px;padding:7px 12px;cursor:pointer;color:#374151;font-weight:600}
|
|
63500
|
+
.rlt-add:disabled{opacity:.5;cursor:not-allowed}
|
|
63501
|
+
#rlt-save{margin-top:18px;padding:9px 16px;border:0;border-radius:6px;background:#2563eb;color:#fff;font-weight:600;cursor:pointer}
|
|
63502
|
+
#rlt-save:disabled{opacity:.6;cursor:wait}.rlt-message{min-height:20px;margin:12px 0 0}.rlt-message.rlt-error,.rlt-error{color:#b91c1c}
|
|
63503
|
+
.rlt-message.rlt-success{color:#15803d}.rlt-state{text-align:center;padding:30px;color:#6b7280}
|
|
63504
|
+
</style>`;
|
|
63505
|
+
const c = this.config.container;
|
|
63506
|
+
c.querySelectorAll("select[data-side]").forEach((select) => {
|
|
63507
|
+
select.addEventListener("change", () => {
|
|
63508
|
+
this.rows[select.dataset.side][Number(select.dataset.index)] = select.value;
|
|
63509
|
+
this.showMessage("");
|
|
63510
|
+
});
|
|
63511
|
+
});
|
|
63512
|
+
c.querySelectorAll("[data-add]").forEach((btn) => {
|
|
63513
|
+
btn.addEventListener("click", () => {
|
|
63514
|
+
const side = btn.dataset.add;
|
|
63515
|
+
if (this.rows[side].length >= MAX_RETROLAVAGEM_DEVICES_PER_SIDE) return;
|
|
63516
|
+
this.rows[side].push("");
|
|
63517
|
+
this.render();
|
|
63518
|
+
});
|
|
63519
|
+
});
|
|
63520
|
+
c.querySelectorAll("[data-remove]").forEach((btn) => {
|
|
63521
|
+
btn.addEventListener("click", () => {
|
|
63522
|
+
this.rows[btn.dataset.remove].splice(Number(btn.dataset.index), 1);
|
|
63523
|
+
this.render();
|
|
63524
|
+
});
|
|
63525
|
+
});
|
|
63526
|
+
c.querySelector("#rlt-save")?.addEventListener("click", () => {
|
|
63527
|
+
void this.save();
|
|
63528
|
+
});
|
|
63529
|
+
}
|
|
63530
|
+
/** Linhas da tela → vínculos, ou a mensagem do primeiro problema encontrado. */
|
|
63531
|
+
buildBindings() {
|
|
63532
|
+
const known = (tbId) => this.catalog.find((o) => o.tbId === tbId);
|
|
63533
|
+
const seen = /* @__PURE__ */ new Map();
|
|
63534
|
+
const out = { version: 1, inputs: [], outputs: [] };
|
|
63535
|
+
for (const side of ["inputs", "outputs"]) {
|
|
63536
|
+
const ids = this.rows[side].filter(Boolean);
|
|
63537
|
+
if (ids.length > MAX_RETROLAVAGEM_DEVICES_PER_SIDE) {
|
|
63538
|
+
return `No m\xE1ximo ${MAX_RETROLAVAGEM_DEVICES_PER_SIDE} hidr\xF4metros de ${SIDE_TEXT[side].title.toLowerCase()}.`;
|
|
63539
|
+
}
|
|
63540
|
+
for (const tbId of ids) {
|
|
63541
|
+
const option = known(tbId);
|
|
63542
|
+
const stored = this.storedRef(tbId);
|
|
63543
|
+
const name = option?.label || stored?.label || tbId;
|
|
63544
|
+
if (seen.has(tbId)) {
|
|
63545
|
+
return seen.get(tbId) === side ? `${name} aparece duas vezes em ${SIDE_TEXT[side].title}.` : `${name} n\xE3o pode estar na entrada e na sa\xEDda ao mesmo tempo.`;
|
|
63546
|
+
}
|
|
63547
|
+
if (!option && !stored) return `${name} n\xE3o \xE9 um hidr\xF4metro v\xE1lido deste cliente.`;
|
|
63548
|
+
seen.set(tbId, side);
|
|
63549
|
+
const gcdrId = option?.gcdrId || stored?.gcdrId;
|
|
63550
|
+
out[side].push({ tbId, label: name, ...gcdrId ? { gcdrId } : {} });
|
|
63551
|
+
}
|
|
63552
|
+
}
|
|
63553
|
+
return out;
|
|
63554
|
+
}
|
|
63555
|
+
async save() {
|
|
63556
|
+
const button = this.config.container.querySelector("#rlt-save");
|
|
63557
|
+
if (!this.loaded || !button) return;
|
|
63558
|
+
const bindings = this.buildBindings();
|
|
63559
|
+
if (typeof bindings === "string") {
|
|
63560
|
+
this.showMessage(bindings, true);
|
|
63561
|
+
return;
|
|
63562
|
+
}
|
|
63563
|
+
if (bindings.inputs.length && !bindings.outputs.length) {
|
|
63564
|
+
this.showMessage("Aten\xE7\xE3o: sem hidr\xF4metro de sa\xEDda, a retrolavagem fica igual ao total de entrada.");
|
|
63565
|
+
}
|
|
63566
|
+
button.disabled = true;
|
|
63567
|
+
button.textContent = "Salvando\u2026";
|
|
63568
|
+
try {
|
|
63569
|
+
const response = await fetch(
|
|
63570
|
+
`${this.config.tbBaseUrl}/api/plugins/telemetry/DEVICE/${encodeURIComponent(this.config.deviceId)}/attributes/SERVER_SCOPE`,
|
|
63571
|
+
{ method: "POST", headers: this.headers(), body: JSON.stringify({ [RETROLAVAGEM_BINDINGS_KEY]: bindings }) }
|
|
63572
|
+
);
|
|
63573
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
63574
|
+
this.bindings = bindings;
|
|
63575
|
+
this.rows = { inputs: bindings.inputs.map((d) => d.tbId), outputs: bindings.outputs.map((d) => d.tbId) };
|
|
63576
|
+
this.render();
|
|
63577
|
+
this.showMessage("V\xEDnculos salvos. O painel recalcula a retrolavagem na pr\xF3xima atualiza\xE7\xE3o dos dados.", false, true);
|
|
63578
|
+
} catch (error) {
|
|
63579
|
+
this.showMessage(`Falha ao salvar os v\xEDnculos: ${this.errorMessage(error)}`, true);
|
|
63580
|
+
const b = this.config.container.querySelector("#rlt-save");
|
|
63581
|
+
if (b) {
|
|
63582
|
+
b.disabled = false;
|
|
63583
|
+
b.textContent = "Salvar v\xEDnculos";
|
|
63584
|
+
}
|
|
63585
|
+
}
|
|
63586
|
+
}
|
|
63587
|
+
showMessage(message, isError = false, isSuccess = false) {
|
|
63588
|
+
const element = this.config.container.querySelector("#rlt-message");
|
|
63589
|
+
if (!element) return;
|
|
63590
|
+
element.textContent = message;
|
|
63591
|
+
element.classList.toggle("rlt-error", isError);
|
|
63592
|
+
element.classList.toggle("rlt-success", isSuccess);
|
|
63593
|
+
}
|
|
63594
|
+
errorMessage(error) {
|
|
63595
|
+
return error instanceof Error ? error.message : String(error);
|
|
63596
|
+
}
|
|
63597
|
+
};
|
|
63598
|
+
|
|
63320
63599
|
// src/services/freshdesk/FreshdeskClient.ts
|
|
63321
63600
|
var FreshdeskClient_exports = {};
|
|
63322
63601
|
__export(FreshdeskClient_exports, {
|
|
@@ -65067,6 +65346,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65067
65346
|
exclusionGroupsTab = null;
|
|
65068
65347
|
deviceProfileTab = null;
|
|
65069
65348
|
wellEquipmentTab = null;
|
|
65349
|
+
retrolavagemTab = null;
|
|
65070
65350
|
currentTab = "general";
|
|
65071
65351
|
currentUser = null;
|
|
65072
65352
|
permissions = null;
|
|
@@ -65118,6 +65398,10 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65118
65398
|
isWellEquipmentDevice() {
|
|
65119
65399
|
return ["CISTERNA", "CISTERNA_ENTRADA"].includes(String(this.config.deviceProfile || "").toUpperCase());
|
|
65120
65400
|
}
|
|
65401
|
+
/** Retrolavagem virtual: escolhe os hidrômetros de entrada e de saída (aba só para SuperAdmin). */
|
|
65402
|
+
isRetrolavagemDevice() {
|
|
65403
|
+
return String(this.config.deviceProfile || "").toUpperCase() === RETROLAVAGEM_PROFILE;
|
|
65404
|
+
}
|
|
65121
65405
|
render(initialData) {
|
|
65122
65406
|
this.originalActiveElement = document.activeElement;
|
|
65123
65407
|
document.body.appendChild(this.container);
|
|
@@ -65155,6 +65439,9 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65155
65439
|
if (this.isWellEquipmentDevice() && this.isSuperAdmin()) {
|
|
65156
65440
|
this.initWellEquipmentTab();
|
|
65157
65441
|
}
|
|
65442
|
+
if (this.isRetrolavagemDevice() && this.isSuperAdmin()) {
|
|
65443
|
+
this.initRetrolavagemTab();
|
|
65444
|
+
}
|
|
65158
65445
|
if (this.config.isGateway && this.isSuperAdmin()) {
|
|
65159
65446
|
this.bindIncidentsTabEvents();
|
|
65160
65447
|
this.initIncidentsDateRange();
|
|
@@ -65432,6 +65719,29 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65432
65719
|
container.innerHTML = '<p class="wet-state wet-error" role="alert">Erro ao carregar configura\xE7\xF5es de equipamentos do po\xE7o.</p>';
|
|
65433
65720
|
}
|
|
65434
65721
|
}
|
|
65722
|
+
async initRetrolavagemTab() {
|
|
65723
|
+
const container = this.modal.querySelector("#retrolavagem-tab-content");
|
|
65724
|
+
if (!container || !this.isRetrolavagemDevice() || !this.isSuperAdmin()) return;
|
|
65725
|
+
const customerId = this.config.customerId || window.MyIOUtils?.customerTB_ID;
|
|
65726
|
+
const { deviceId, jwtToken, tbBaseUrl } = this.config;
|
|
65727
|
+
if (!deviceId || !jwtToken || !customerId) {
|
|
65728
|
+
container.innerHTML = '<p class="rlt-state rlt-error" role="alert">Configura\xE7\xE3o da retrolavagem indispon\xEDvel: deviceId, autentica\xE7\xE3o ou customerId n\xE3o informado.</p>';
|
|
65729
|
+
return;
|
|
65730
|
+
}
|
|
65731
|
+
try {
|
|
65732
|
+
this.retrolavagemTab = new RetrolavagemTab({
|
|
65733
|
+
container,
|
|
65734
|
+
deviceId,
|
|
65735
|
+
customerId,
|
|
65736
|
+
jwtToken,
|
|
65737
|
+
tbBaseUrl: tbBaseUrl ?? window.location.origin
|
|
65738
|
+
});
|
|
65739
|
+
await this.retrolavagemTab.init();
|
|
65740
|
+
} catch (error) {
|
|
65741
|
+
console.error("[SettingsModalView] Failed to initialize RetrolavagemTab:", error);
|
|
65742
|
+
container.innerHTML = '<p class="rlt-state rlt-error" role="alert">Erro ao carregar os equipamentos da retrolavagem.</p>';
|
|
65743
|
+
}
|
|
65744
|
+
}
|
|
65435
65745
|
// RFC-0104 / RFC-0180 / RFC-0198: Switch between tabs
|
|
65436
65746
|
switchTab(tab) {
|
|
65437
65747
|
this.currentTab = tab;
|
|
@@ -65446,6 +65756,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65446
65756
|
const exclusionGroupsContent = this.modal.querySelector("#exclusion-groups-tab-content");
|
|
65447
65757
|
const deviceProfileContent = this.modal.querySelector("#device-profile-tab-content");
|
|
65448
65758
|
const wellEquipmentContent = this.modal.querySelector("#well-equipment-tab-content");
|
|
65759
|
+
const retrolavagemContent = this.modal.querySelector("#retrolavagem-tab-content");
|
|
65449
65760
|
const incidentsContent = this.modal.querySelector("#incidents-tab-content");
|
|
65450
65761
|
if (generalContent) generalContent.style.display = tab === "general" ? "block" : "none";
|
|
65451
65762
|
if (annotationsContent) annotationsContent.style.display = tab === "annotations" ? "block" : "none";
|
|
@@ -65453,6 +65764,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65453
65764
|
if (chamadosContent) chamadosContent.style.display = tab === "chamados" ? "block" : "none";
|
|
65454
65765
|
if (deviceProfileContent) deviceProfileContent.style.display = tab === "device-profile" ? "block" : "none";
|
|
65455
65766
|
if (wellEquipmentContent) wellEquipmentContent.style.display = tab === "well-equipment" ? "block" : "none";
|
|
65767
|
+
if (retrolavagemContent) retrolavagemContent.style.display = tab === "retrolavagem" ? "block" : "none";
|
|
65456
65768
|
if (exclusionGroupsContent) exclusionGroupsContent.style.display = tab === "exclusion-groups" ? "block" : "none";
|
|
65457
65769
|
if (incidentsContent) incidentsContent.style.display = tab === "incidents" ? "block" : "none";
|
|
65458
65770
|
const saveBtn = this.modal.querySelector(".btn-save");
|
|
@@ -65487,6 +65799,10 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65487
65799
|
this.wellEquipmentTab.destroy();
|
|
65488
65800
|
this.wellEquipmentTab = null;
|
|
65489
65801
|
}
|
|
65802
|
+
if (this.retrolavagemTab) {
|
|
65803
|
+
this.retrolavagemTab.destroy();
|
|
65804
|
+
this.retrolavagemTab = null;
|
|
65805
|
+
}
|
|
65490
65806
|
if (this.incidentsDateRangeController) {
|
|
65491
65807
|
this.incidentsDateRangeController.destroy();
|
|
65492
65808
|
this.incidentsDateRangeController = null;
|
|
@@ -65673,6 +65989,14 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65673
65989
|
</svg>
|
|
65674
65990
|
Equipamentos do Po\xE7o
|
|
65675
65991
|
</button>` : ""}
|
|
65992
|
+
${this.isRetrolavagemDevice() && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="retrolavagem">
|
|
65993
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
65994
|
+
<path d="M3 12h7M14 12h7"></path>
|
|
65995
|
+
<path d="M7 8l-4 4 4 4"></path>
|
|
65996
|
+
<path d="M17 8l4 4-4 4"></path>
|
|
65997
|
+
</svg>
|
|
65998
|
+
Equipamentos da Retrolavagem
|
|
65999
|
+
</button>` : ""}
|
|
65676
66000
|
<!-- RFC-0232: Incidentes (interpola\xE7\xE3o) \u2014 central + admin MyIO only -->
|
|
65677
66001
|
${this.config.isGateway && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="incidents">
|
|
65678
66002
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -65730,6 +66054,9 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65730
66054
|
${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<div id="well-equipment-tab-content" class="tab-content" style="display:none;">
|
|
65731
66055
|
<p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>
|
|
65732
66056
|
</div>` : ""}
|
|
66057
|
+
${this.isRetrolavagemDevice() && this.isSuperAdmin() ? `<div id="retrolavagem-tab-content" class="tab-content" style="display:none;">
|
|
66058
|
+
<p class="rlt-state">Carregando v\xEDnculos e hidr\xF4metros\u2026</p>
|
|
66059
|
+
</div>` : ""}
|
|
65733
66060
|
<!-- RFC-0232: Incidentes (interpola\xE7\xE3o) Tab Content \u2014 central + admin MyIO only.
|
|
65734
66061
|
Rendered synchronously (data comes pre-fetched via config.interpolatedSlots,
|
|
65735
66062
|
same as getGatewayInfoHTML() \u2014 no async loading state needed here). -->
|
|
@@ -76655,10 +76982,10 @@ function render(container, modalId, state6) {
|
|
|
76655
76982
|
<div class="alarm-list">
|
|
76656
76983
|
${state6.alarms.map((a) => `
|
|
76657
76984
|
<div class="alarm-row">
|
|
76658
|
-
<div class="alarm-title">${
|
|
76659
|
-
<div class="alarm-meta">${
|
|
76660
|
-
<div class="alarm-meta">${
|
|
76661
|
-
<div class="alarm-meta">${
|
|
76985
|
+
<div class="alarm-title">${escapeHtml8(a.title || a.id)}</div>
|
|
76986
|
+
<div class="alarm-meta">${escapeHtml8(a.customerName || "")}</div>
|
|
76987
|
+
<div class="alarm-meta">${escapeHtml8(a.severity)}</div>
|
|
76988
|
+
<div class="alarm-meta">${escapeHtml8(a.state)}</div>
|
|
76662
76989
|
<div class="alarm-meta">${formatDate2(a.lastOccurrence, state6.locale, true)}</div>
|
|
76663
76990
|
</div>
|
|
76664
76991
|
`).join("")}
|
|
@@ -76845,7 +77172,7 @@ function buildBars(data, order, colors2) {
|
|
|
76845
77172
|
const pct = Math.round(value / maxVal * 100);
|
|
76846
77173
|
return `
|
|
76847
77174
|
<div class="bar-row">
|
|
76848
|
-
<span class="bar-label">${
|
|
77175
|
+
<span class="bar-label">${escapeHtml8(String(key))}</span>
|
|
76849
77176
|
<div class="bar-track"><div class="bar-fill" style="width:${pct}%"></div></div>
|
|
76850
77177
|
<span class="bar-value">${value}</span>
|
|
76851
77178
|
</div>
|
|
@@ -76875,7 +77202,7 @@ function toTime(value) {
|
|
|
76875
77202
|
const parsed = new Date(value).getTime();
|
|
76876
77203
|
return Number.isNaN(parsed) ? 0 : parsed;
|
|
76877
77204
|
}
|
|
76878
|
-
function
|
|
77205
|
+
function escapeHtml8(text2) {
|
|
76879
77206
|
const div = document.createElement("div");
|
|
76880
77207
|
div.textContent = text2 || "";
|
|
76881
77208
|
return div.innerHTML;
|
|
@@ -77062,8 +77389,8 @@ function render2(container, modalId, state6) {
|
|
|
77062
77389
|
</div>
|
|
77063
77390
|
${state6.devices.map((d) => `
|
|
77064
77391
|
<div class="device-table-row">
|
|
77065
|
-
<div class="col-name">${
|
|
77066
|
-
<div class="col-customer">${
|
|
77392
|
+
<div class="col-name">${escapeHtml9(d.name)}</div>
|
|
77393
|
+
<div class="col-customer">${escapeHtml9(d.customerName)}</div>
|
|
77067
77394
|
<div class="col-status">
|
|
77068
77395
|
<span class="status-badge" style="background: ${STATUS_COLORS3[d.status] || "#6b7280"}20; color: ${STATUS_COLORS3[d.status] || "#6b7280"};">
|
|
77069
77396
|
${STATUS_LABELS5[d.status] || d.status}
|
|
@@ -77310,7 +77637,7 @@ function buildHorizontalBarChart(devices, metric, unit, colors2, getColor, inver
|
|
|
77310
77637
|
const displayValue = metric === "availability" ? value.toFixed(1) : value.toFixed(metric === "mttr" ? 1 : 0);
|
|
77311
77638
|
return `
|
|
77312
77639
|
<div class="bar-row">
|
|
77313
|
-
<span class="bar-label" title="${
|
|
77640
|
+
<span class="bar-label" title="${escapeHtml9(d.name)}">${escapeHtml9(d.name)}</span>
|
|
77314
77641
|
<div class="bar-track">
|
|
77315
77642
|
<div class="bar-fill" style="width:${pct}%; background:${color};"></div>
|
|
77316
77643
|
</div>
|
|
@@ -77341,7 +77668,7 @@ function formatDate3(value, locale) {
|
|
|
77341
77668
|
if (isNaN(d.getTime())) return "-";
|
|
77342
77669
|
return d.toLocaleDateString(locale, { day: "2-digit", month: "2-digit", year: "numeric" });
|
|
77343
77670
|
}
|
|
77344
|
-
function
|
|
77671
|
+
function escapeHtml9(text2) {
|
|
77345
77672
|
const div = document.createElement("div");
|
|
77346
77673
|
div.textContent = text2 || "";
|
|
77347
77674
|
return div.innerHTML;
|
|
@@ -81693,11 +82020,11 @@ function injectDialogStyles() {
|
|
|
81693
82020
|
// src/components/premium-modals/dialog/openDialog.ts
|
|
81694
82021
|
var BASE_Z_INDEX = 10500;
|
|
81695
82022
|
var openCount = 0;
|
|
81696
|
-
function
|
|
82023
|
+
function escapeHtml10(value) {
|
|
81697
82024
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
81698
82025
|
}
|
|
81699
82026
|
function escapeMessage(value) {
|
|
81700
|
-
return
|
|
82027
|
+
return escapeHtml10(value).replace(/\n/g, "<br>");
|
|
81701
82028
|
}
|
|
81702
82029
|
function cssWidth(width) {
|
|
81703
82030
|
if (width == null) return "420px";
|
|
@@ -81722,7 +82049,7 @@ function openDialog(params) {
|
|
|
81722
82049
|
overlay.style.zIndex = String(BASE_Z_INDEX + openCount);
|
|
81723
82050
|
const buttonsHtml = params.buttons.map((btn, i) => {
|
|
81724
82051
|
const variant = btn.variant ?? "secondary";
|
|
81725
|
-
return `<button type="button" class="myio-dialog__btn myio-dialog__btn--${variant}" data-index="${i}">${
|
|
82052
|
+
return `<button type="button" class="myio-dialog__btn myio-dialog__btn--${variant}" data-index="${i}">${escapeHtml10(btn.label)}</button>`;
|
|
81726
82053
|
}).join("");
|
|
81727
82054
|
overlay.innerHTML = `
|
|
81728
82055
|
<div class="myio-dialog${params.modifier ? ` ${params.modifier}` : ""}"
|
|
@@ -81732,7 +82059,7 @@ function openDialog(params) {
|
|
|
81732
82059
|
<div class="myio-dialog__accent"></div>
|
|
81733
82060
|
<div class="myio-dialog__header">
|
|
81734
82061
|
${params.icon ? `<span class="myio-dialog__icon" aria-hidden="true">${params.icon}</span>` : ""}
|
|
81735
|
-
<h3 class="myio-dialog__title" id="${idBase}-title">${
|
|
82062
|
+
<h3 class="myio-dialog__title" id="${idBase}-title">${escapeHtml10(params.title)}</h3>
|
|
81736
82063
|
${dismissible ? `<button type="button" class="myio-dialog__close" aria-label="Fechar">\u2715</button>` : ""}
|
|
81737
82064
|
</div>
|
|
81738
82065
|
<p class="myio-dialog__message" id="${idBase}-message">${escapeMessage(params.message)}</p>
|
|
@@ -81828,7 +82155,7 @@ var STYLE_ID9 = "myio-genmodal-styles";
|
|
|
81828
82155
|
var FONT_LINK_ID2 = "myio-dialog-font-nunito";
|
|
81829
82156
|
var BASE_Z_INDEX2 = 10600;
|
|
81830
82157
|
var openCount2 = 0;
|
|
81831
|
-
function
|
|
82158
|
+
function escapeHtml11(value) {
|
|
81832
82159
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
81833
82160
|
}
|
|
81834
82161
|
function cssSize(v, fallback) {
|
|
@@ -81981,17 +82308,17 @@ function openGenericModal(params) {
|
|
|
81981
82308
|
overlay.style.zIndex = String(BASE_Z_INDEX2 + openCount2);
|
|
81982
82309
|
const buttonsHtml = buttons.map((btn, i) => {
|
|
81983
82310
|
const variant = btn.variant ?? "secondary";
|
|
81984
|
-
return `<button type="button" class="myio-genmodal__btn myio-genmodal__btn--${variant}" data-index="${i}">${
|
|
82311
|
+
return `<button type="button" class="myio-genmodal__btn myio-genmodal__btn--${variant}" data-index="${i}">${escapeHtml11(btn.label)}</button>`;
|
|
81985
82312
|
}).join("");
|
|
81986
82313
|
overlay.innerHTML = `
|
|
81987
|
-
<div class="myio-genmodal${params.className ? ` ${
|
|
82314
|
+
<div class="myio-genmodal${params.className ? ` ${escapeHtml11(params.className)}` : ""}"
|
|
81988
82315
|
role="dialog" aria-modal="true"
|
|
81989
82316
|
aria-labelledby="${idBase}-title"
|
|
81990
82317
|
style="width:${cssSize(params.width, "560px")}">
|
|
81991
82318
|
<div class="myio-genmodal__accent"></div>
|
|
81992
82319
|
<div class="myio-genmodal__header">
|
|
81993
82320
|
${params.icon ? `<span class="myio-genmodal__icon" aria-hidden="true">${params.icon}</span>` : ""}
|
|
81994
|
-
<h3 class="myio-genmodal__title" id="${idBase}-title">${
|
|
82321
|
+
<h3 class="myio-genmodal__title" id="${idBase}-title">${escapeHtml11(params.title)}</h3>
|
|
81995
82322
|
${dismissible ? `<button type="button" class="myio-genmodal__close" aria-label="Fechar">\u2715</button>` : ""}
|
|
81996
82323
|
</div>
|
|
81997
82324
|
<div class="myio-genmodal__body" id="${idBase}-body" style="max-height:${cssSize(params.bodyMaxHeight, "70vh")}"></div>
|
|
@@ -105003,7 +105330,7 @@ var HUB_CSS = `
|
|
|
105003
105330
|
color: var(--myio-brand-700, #7B2FF7);
|
|
105004
105331
|
}
|
|
105005
105332
|
`;
|
|
105006
|
-
function
|
|
105333
|
+
function escapeHtml12(value) {
|
|
105007
105334
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
105008
105335
|
}
|
|
105009
105336
|
function resolveTopDocument() {
|
|
@@ -105050,7 +105377,7 @@ function openSettingsHubModal(options) {
|
|
|
105050
105377
|
<div class="myio-conf-picker__overlay"></div>
|
|
105051
105378
|
<div class="myio-conf-picker__content">
|
|
105052
105379
|
<div class="myio-conf-picker__header">
|
|
105053
|
-
<h3>\u2699\uFE0F Configura\xE7\xF5es${customerName ? ` \u2014 ${
|
|
105380
|
+
<h3>\u2699\uFE0F Configura\xE7\xF5es${customerName ? ` \u2014 ${escapeHtml12(customerName)}` : ""}</h3>
|
|
105054
105381
|
<button class="myio-conf-picker__close" aria-label="Fechar">×</button>
|
|
105055
105382
|
</div>
|
|
105056
105383
|
<div class="myio-conf-picker__body">${cardsHtml}
|
|
@@ -106245,7 +106572,7 @@ function createTariffApiAdapter(client, opts) {
|
|
|
106245
106572
|
|
|
106246
106573
|
// src/components/pricing-panel/openPricingPanel.ts
|
|
106247
106574
|
var MODAL_ID3 = "myio-pricing-panel";
|
|
106248
|
-
function
|
|
106575
|
+
function escapeHtml13(value) {
|
|
106249
106576
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
106250
106577
|
}
|
|
106251
106578
|
function resolveTopDocument2() {
|
|
@@ -106400,7 +106727,7 @@ function openPricingPanel(params) {
|
|
|
106400
106727
|
}
|
|
106401
106728
|
const initDomain = params.domain || "energy";
|
|
106402
106729
|
const initCategory = params.category || "lojas";
|
|
106403
|
-
const customerOptions = customers.map((c) => `<option value="${
|
|
106730
|
+
const customerOptions = customers.map((c) => `<option value="${escapeHtml13(resolveCustomerId(c))}">${escapeHtml13(c.title)}</option>`).join("");
|
|
106404
106731
|
modal.innerHTML = `
|
|
106405
106732
|
<div class="myio-pricing__overlay"></div>
|
|
106406
106733
|
<div class="myio-pricing__content">
|
|
@@ -106615,9 +106942,9 @@ function openPricingPanel(params) {
|
|
|
106615
106942
|
const pushAudit = (rec) => {
|
|
106616
106943
|
if (rec) auditLog = [rec, ...auditLog];
|
|
106617
106944
|
};
|
|
106618
|
-
const badge = (domain, category) => `<span class="myio-pricing__badge${domain === "water" ? " myio-pricing__badge--water" : ""}">${
|
|
106945
|
+
const badge = (domain, category) => `<span class="myio-pricing__badge${domain === "water" ? " myio-pricing__badge--water" : ""}">${escapeHtml13(
|
|
106619
106946
|
DOMAIN_LABEL[domain]
|
|
106620
|
-
)} \xB7 ${
|
|
106947
|
+
)} \xB7 ${escapeHtml13(CATEGORY_LABEL[category])}</span>`;
|
|
106621
106948
|
const renderList2 = () => {
|
|
106622
106949
|
const customerId = customerSel.value;
|
|
106623
106950
|
const rows = entries.filter((e) => e.customerId === customerId).sort((a, b) => {
|
|
@@ -106630,15 +106957,15 @@ function openPricingPanel(params) {
|
|
|
106630
106957
|
const boundsKey = b ? `${b.start}__${b.end}` : "";
|
|
106631
106958
|
return `
|
|
106632
106959
|
<li class="myio-pricing__item">
|
|
106633
|
-
<span class="myio-pricing__item-period">${badge(e.domain, e.category)} ${
|
|
106960
|
+
<span class="myio-pricing__item-period">${badge(e.domain, e.category)} ${escapeHtml13(
|
|
106634
106961
|
formatPeriodLabel(e)
|
|
106635
106962
|
)}</span>
|
|
106636
|
-
<span class="myio-pricing__item-price">${
|
|
106963
|
+
<span class="myio-pricing__item-price">${escapeHtml13(formatBRL2(e.pricePerKwh))} ${escapeHtml13(
|
|
106637
106964
|
unitLabel(e.domain)
|
|
106638
106965
|
)}</span>
|
|
106639
|
-
<button class="myio-pricing__remove" data-remove="${
|
|
106966
|
+
<button class="myio-pricing__remove" data-remove="${escapeHtml13(e.domain)}|${escapeHtml13(
|
|
106640
106967
|
e.category
|
|
106641
|
-
)}|${
|
|
106968
|
+
)}|${escapeHtml13(boundsKey)}" aria-label="Remover" type="button">\u2715</button>
|
|
106642
106969
|
</li>`;
|
|
106643
106970
|
}).join("");
|
|
106644
106971
|
emptyEl.style.display = rows.length ? "none" : "";
|
|
@@ -106737,8 +107064,8 @@ function openPricingPanel(params) {
|
|
|
106737
107064
|
kpiEl.innerHTML = cards.map(
|
|
106738
107065
|
(c) => `
|
|
106739
107066
|
<div class="myio-pricing__kpi">
|
|
106740
|
-
<div class="myio-pricing__kpi-value">${
|
|
106741
|
-
<div class="myio-pricing__kpi-label">${
|
|
107067
|
+
<div class="myio-pricing__kpi-value">${escapeHtml13(c.value)}</div>
|
|
107068
|
+
<div class="myio-pricing__kpi-label">${escapeHtml13(c.label)}</div>
|
|
106742
107069
|
</div>`
|
|
106743
107070
|
).join("");
|
|
106744
107071
|
renderReport();
|
|
@@ -106757,11 +107084,11 @@ function openPricingPanel(params) {
|
|
|
106757
107084
|
reportBody.innerHTML = rows.length ? rows.map(
|
|
106758
107085
|
(e) => `
|
|
106759
107086
|
<tr>
|
|
106760
|
-
<td>${
|
|
106761
|
-
<td>${
|
|
106762
|
-
<td>${
|
|
106763
|
-
<td>${
|
|
106764
|
-
<td>${
|
|
107087
|
+
<td>${escapeHtml13(customerTitle(e.customerId))}</td>
|
|
107088
|
+
<td>${escapeHtml13(DOMAIN_LABEL[e.domain])}</td>
|
|
107089
|
+
<td>${escapeHtml13(CATEGORY_LABEL[e.category])}</td>
|
|
107090
|
+
<td>${escapeHtml13(formatPeriodLabel(e))}</td>
|
|
107091
|
+
<td>${escapeHtml13(formatBRL2(e.pricePerKwh))} ${escapeHtml13(unitLabel(e.domain))}</td>
|
|
106765
107092
|
</tr>`
|
|
106766
107093
|
).join("") : `<tr><td colspan="5" style="text-align:center;color:var(--myio-text-muted,#6b7280);padding:24px;">Nenhum pre\xE7o para o filtro selecionado.</td></tr>`;
|
|
106767
107094
|
}
|
|
@@ -106771,15 +107098,15 @@ function openPricingPanel(params) {
|
|
|
106771
107098
|
return `
|
|
106772
107099
|
<li class="myio-pricing__history-item">
|
|
106773
107100
|
<div class="myio-pricing__history-head">
|
|
106774
|
-
<span class="myio-pricing__action myio-pricing__action--${
|
|
107101
|
+
<span class="myio-pricing__action myio-pricing__action--${escapeHtml13(rec.action)}">${escapeHtml13(
|
|
106775
107102
|
rec.action
|
|
106776
107103
|
)}</span>
|
|
106777
107104
|
${badge(rec.domain, rec.category)}
|
|
106778
|
-
<span>${
|
|
107105
|
+
<span>${escapeHtml13(rec.periodLabel)}${escapeHtml13(priceInfo)}</span>
|
|
106779
107106
|
</div>
|
|
106780
|
-
<div class="myio-pricing__history-meta">${
|
|
107107
|
+
<div class="myio-pricing__history-meta">${escapeHtml13(customerTitle(rec.customerId))} \xB7 ${escapeHtml13(
|
|
106781
107108
|
rec.by || "\u2014"
|
|
106782
|
-
)} \xB7 ${
|
|
107109
|
+
)} \xB7 ${escapeHtml13(fmtTimestamp(rec.at))}</div>
|
|
106783
107110
|
</li>`;
|
|
106784
107111
|
}).join("");
|
|
106785
107112
|
historyEmpty.style.display = auditLog.length ? "none" : "";
|
|
@@ -115119,7 +115446,7 @@ var STYLE_ID13 = "myio-stdmodal-styles";
|
|
|
115119
115446
|
var FONT_LINK_ID3 = "myio-dialog-font-nunito";
|
|
115120
115447
|
var BASE_Z_INDEX3 = 10700;
|
|
115121
115448
|
var openCount3 = 0;
|
|
115122
|
-
function
|
|
115449
|
+
function escapeHtml14(v) {
|
|
115123
115450
|
return String(v).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
115124
115451
|
}
|
|
115125
115452
|
function injectStyles13() {
|
|
@@ -115173,10 +115500,10 @@ function openStandardModal(params) {
|
|
|
115173
115500
|
overlay.className = "myio-stdmodal-overlay";
|
|
115174
115501
|
overlay.style.zIndex = String(BASE_Z_INDEX3 + openCount3);
|
|
115175
115502
|
overlay.innerHTML = `
|
|
115176
|
-
<div class="myio-stdmodal" role="dialog" aria-modal="true" aria-label="${
|
|
115503
|
+
<div class="myio-stdmodal" role="dialog" aria-modal="true" aria-label="${escapeHtml14(params.title)}" style="width:${width}">
|
|
115177
115504
|
${ModalHeader.generateHTML({
|
|
115178
115505
|
icon: params.icon,
|
|
115179
|
-
title:
|
|
115506
|
+
title: escapeHtml14(params.title),
|
|
115180
115507
|
modalId,
|
|
115181
115508
|
showThemeToggle: false,
|
|
115182
115509
|
showMaximize: false,
|
|
@@ -115185,7 +115512,7 @@ function openStandardModal(params) {
|
|
|
115185
115512
|
})}
|
|
115186
115513
|
<div class="myio-stdmodal__body"></div>
|
|
115187
115514
|
${buttons.length ? `<div class="myio-stdmodal__footer">${buttons.map(
|
|
115188
|
-
(b, i) => `<button type="button" class="myio-stdmodal__btn myio-stdmodal__btn--${b.variant ?? "secondary"}" data-index="${i}" data-value="${
|
|
115515
|
+
(b, i) => `<button type="button" class="myio-stdmodal__btn myio-stdmodal__btn--${b.variant ?? "secondary"}" data-index="${i}" data-value="${escapeHtml14(b.value)}">${escapeHtml14(b.label)}</button>`
|
|
115189
115516
|
).join("")}</div>` : ""}
|
|
115190
115517
|
</div>`;
|
|
115191
115518
|
const root = overlay.querySelector(".myio-stdmodal");
|
|
@@ -115636,27 +115963,74 @@ var ImportApiError = class extends Error {
|
|
|
115636
115963
|
this.name = "ImportApiError";
|
|
115637
115964
|
}
|
|
115638
115965
|
};
|
|
115966
|
+
var CONFLICT_TEXT = {
|
|
115967
|
+
VALIDATION_EXPIRED: "A valida\xE7\xE3o expirou (vale 30 minutos). Valide a planilha de novo.",
|
|
115968
|
+
REAL_READINGS_PRESENT: "H\xE1 leituras reais nessas horas. Confirme a substitui\xE7\xE3o para importar.",
|
|
115969
|
+
NOT_CANCELLABLE: 'A importa\xE7\xE3o j\xE1 terminou e n\xE3o pode ser cancelada. Use "Desfazer importa\xE7\xE3o".',
|
|
115970
|
+
NOT_REVERTABLE: "Esta importa\xE7\xE3o n\xE3o pode ser desfeita.",
|
|
115971
|
+
GATEWAY_BUSY: "A central est\xE1 ocupada com outra importa\xE7\xE3o. Tente em instantes."
|
|
115972
|
+
};
|
|
115973
|
+
function importErrorMessage(status, path, body) {
|
|
115974
|
+
const code = String(body?.error || "");
|
|
115975
|
+
const apiMsg = String(body?.message || "");
|
|
115976
|
+
switch (status) {
|
|
115977
|
+
case 400:
|
|
115978
|
+
return apiMsg ? `Pedido recusado pela API: ${apiMsg}` : "Pedido recusado pela API (400).";
|
|
115979
|
+
case 401:
|
|
115980
|
+
return "Sess\xE3o da importa\xE7\xE3o expirada. Feche esta janela e abra a importa\xE7\xE3o de novo.";
|
|
115981
|
+
case 403:
|
|
115982
|
+
return /customer/i.test(apiMsg) ? "Esta credencial n\xE3o pode importar dados deste cliente." : "Sem permiss\xE3o para importar telemetria: a credencial n\xE3o tem o escopo telemetry.import.";
|
|
115983
|
+
case 404:
|
|
115984
|
+
return path === "/validate" ? "A importa\xE7\xE3o ainda n\xE3o est\xE1 dispon\xEDvel neste ambiente." : "Importa\xE7\xE3o n\xE3o encontrada.";
|
|
115985
|
+
case 409:
|
|
115986
|
+
return CONFLICT_TEXT[code] || apiMsg || "Opera\xE7\xE3o n\xE3o permitida no estado atual da importa\xE7\xE3o.";
|
|
115987
|
+
case 413:
|
|
115988
|
+
return "Planilha grande demais para uma importa\xE7\xE3o. Divida em partes de at\xE9 5.000 linhas.";
|
|
115989
|
+
case 429:
|
|
115990
|
+
return "Muitas tentativas seguidas. Aguarde um minuto e tente de novo.";
|
|
115991
|
+
default:
|
|
115992
|
+
return `Falha na API de importa\xE7\xE3o (${status}).`;
|
|
115993
|
+
}
|
|
115994
|
+
}
|
|
115639
115995
|
function createTelemetryImportApi(cfg) {
|
|
115640
115996
|
const base = String(cfg.baseUrl || "").replace(/\/+$/, "");
|
|
115641
115997
|
const doFetch = cfg.fetchImpl ?? fetch.bind(window);
|
|
115642
|
-
const
|
|
115643
|
-
|
|
115644
|
-
|
|
115645
|
-
|
|
115646
|
-
|
|
115647
|
-
|
|
115648
|
-
|
|
115998
|
+
const send = async (method, path, token, body) => {
|
|
115999
|
+
try {
|
|
116000
|
+
return await doFetch(`${base}/import${path}`, {
|
|
116001
|
+
method,
|
|
116002
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
116003
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
116004
|
+
});
|
|
116005
|
+
} catch (err) {
|
|
116006
|
+
throw new ImportApiError(
|
|
116007
|
+
"N\xE3o foi poss\xEDvel falar com a API de importa\xE7\xE3o. Verifique a conex\xE3o e tente de novo.",
|
|
116008
|
+
0,
|
|
116009
|
+
`${method} /import${path} \u2192 ${String(err?.message || err)}`
|
|
116010
|
+
);
|
|
116011
|
+
}
|
|
116012
|
+
};
|
|
116013
|
+
const readJson = async (res) => {
|
|
115649
116014
|
const text2 = await res.text().catch(() => "");
|
|
115650
|
-
let data = null;
|
|
115651
116015
|
try {
|
|
115652
|
-
|
|
116016
|
+
return { text: text2, data: text2 ? JSON.parse(text2) : null };
|
|
115653
116017
|
} catch {
|
|
115654
|
-
data
|
|
116018
|
+
return { text: text2, data: null };
|
|
115655
116019
|
}
|
|
116020
|
+
};
|
|
116021
|
+
const call = async (method, path, body, accept422 = false) => {
|
|
116022
|
+
let res = await send(method, path, await cfg.getToken(), body);
|
|
116023
|
+
let parsed = await readJson(res);
|
|
116024
|
+
const scopeMissing = res.status === 403 && /scope/i.test(String(parsed.data?.message || ""));
|
|
116025
|
+
if ((res.status === 401 || scopeMissing) && cfg.refreshToken) {
|
|
116026
|
+
res = await send(method, path, await cfg.refreshToken(), body);
|
|
116027
|
+
parsed = await readJson(res);
|
|
116028
|
+
}
|
|
116029
|
+
const data = parsed.data;
|
|
115656
116030
|
if (res.ok || accept422 && res.status === 422) return { status: res.status, data: data?.data ?? data };
|
|
116031
|
+
const msg = importErrorMessage(res.status, path.startsWith("/jobs") ? "/jobs" : path, data);
|
|
115657
116032
|
const apiMsg = data?.message || data?.error || "";
|
|
115658
|
-
|
|
115659
|
-
throw new ImportApiError(msg, res.status, `${method} /import${path} \u2192 ${res.status} ${String(apiMsg || text2).slice(0, 200)}`);
|
|
116033
|
+
throw new ImportApiError(msg, res.status, `${method} /import${path} \u2192 ${res.status} ${String(apiMsg || parsed.text).slice(0, 200)}`);
|
|
115660
116034
|
};
|
|
115661
116035
|
return {
|
|
115662
116036
|
async validate(body) {
|
|
@@ -115677,6 +116051,10 @@ function createTelemetryImportApi(cfg) {
|
|
|
115677
116051
|
async cancelJob(jobId) {
|
|
115678
116052
|
const { data } = await call("POST", `/jobs/${encodeURIComponent(jobId)}/cancel`);
|
|
115679
116053
|
return data ? { jobId, ...data } : null;
|
|
116054
|
+
},
|
|
116055
|
+
async revertJob(jobId) {
|
|
116056
|
+
const { data } = await call("POST", `/jobs/${encodeURIComponent(jobId)}/revert`);
|
|
116057
|
+
return data ? { jobId, ...data } : null;
|
|
115680
116058
|
}
|
|
115681
116059
|
};
|
|
115682
116060
|
}
|
|
@@ -115698,8 +116076,16 @@ var JOB_STATUS_TEXT = {
|
|
|
115698
116076
|
completed: "Conclu\xEDda",
|
|
115699
116077
|
failed: "Falhou",
|
|
115700
116078
|
cancelled: "Cancelada",
|
|
115701
|
-
|
|
116079
|
+
reverting: "Desfazendo",
|
|
116080
|
+
reverted: "Desfeita"
|
|
115702
116081
|
};
|
|
116082
|
+
function fmtSaoPaulo(iso) {
|
|
116083
|
+
const t = new Date(String(iso ?? "")).getTime();
|
|
116084
|
+
if (!Number.isFinite(t)) return "";
|
|
116085
|
+
const d = new Date(t - 3 * 3600 * 1e3);
|
|
116086
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
116087
|
+
return `${p(d.getUTCDate())}/${p(d.getUTCMonth() + 1)}/${d.getUTCFullYear()} ${p(d.getUTCHours())}:00`;
|
|
116088
|
+
}
|
|
115703
116089
|
var STYLE_ID14 = "myio-tlmimport-styles";
|
|
115704
116090
|
function esc9(v) {
|
|
115705
116091
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
@@ -115802,6 +116188,8 @@ function openTelemetryImportModal(params) {
|
|
|
115802
116188
|
apiError: "",
|
|
115803
116189
|
apiDetail: "",
|
|
115804
116190
|
confirmReal: false,
|
|
116191
|
+
/** "Desfazer importação" pede um segundo clique antes de chamar o revert */
|
|
116192
|
+
confirmRevert: false,
|
|
115805
116193
|
job: null
|
|
115806
116194
|
};
|
|
115807
116195
|
let pollTimer = null;
|
|
@@ -115950,8 +116338,10 @@ function openTelemetryImportModal(params) {
|
|
|
115950
116338
|
}
|
|
115951
116339
|
const p = v.preview || {};
|
|
115952
116340
|
const real = Number(p.existingRealReadings || 0);
|
|
115953
|
-
const period = typeof p.period === "string" ? p.period : p.period ? `${p.period.start
|
|
116341
|
+
const period = typeof p.period === "string" ? p.period : p.period ? `${fmtSaoPaulo(p.period.start)} at\xE9 a hora de ${fmtSaoPaulo(p.period.end)}` : "\u2014";
|
|
115954
116342
|
const devices = Array.isArray(p.devices) ? p.devices.length : p.devices;
|
|
116343
|
+
const reactiveWarn = domain === "energy" && Number(p.existingReadingsInTarget || 0) > 0 && !s.rows.some((r) => r.value_reactive_kvarh !== void 0) ? `<div class="tlmi-banner warn">A planilha n\xE3o traz energia reativa: as ${fmtNum(p.existingReadingsInTarget)} hora(s) que j\xE1 t\xEAm leitura
|
|
116344
|
+
ficar\xE3o com reativa 0. A reativa original fica guardada e volta se a importa\xE7\xE3o for desfeita.</div>` : "";
|
|
115955
116345
|
return `
|
|
115956
116346
|
<div class="tlmi-banner ok">${s.model === "accumulated" ? "Valores v\xE1lidos" : "Planilha v\xE1lida"}. Confira o resumo antes de importar.</div>
|
|
115957
116347
|
${s.model === "accumulated" ? '<div class="tlmi-banner warn">Os valores por hora s\xE3o estimados a partir do total informado.</div>' : ""}
|
|
@@ -115961,7 +116351,8 @@ function openTelemetryImportModal(params) {
|
|
|
115961
116351
|
<div class="tlmi-kpi"><span>Total (${txt.unit})</span><strong>${fmtNum(p.totalValue, 2)}</strong></div>
|
|
115962
116352
|
<div class="tlmi-kpi"><span>Leituras substitu\xEDdas</span><strong>${fmtNum(p.existingReadingsInTarget)}</strong></div>
|
|
115963
116353
|
</div>
|
|
115964
|
-
<p class="tlmi-muted">Per\xEDodo: ${esc9(period)}</p>
|
|
116354
|
+
<p class="tlmi-muted">Per\xEDodo (hor\xE1rio de Bras\xEDlia): ${esc9(period)}</p>
|
|
116355
|
+
${reactiveWarn}
|
|
115965
116356
|
${real > 0 ? `<div class="tlmi-banner warn"><strong>${fmtNum(real)} leitura(s) reais do medidor</strong> ser\xE3o substitu\xEDdas pelos valores da planilha.
|
|
115966
116357
|
<label class="tlmi-check" style="margin-top:6px"><input type="checkbox" data-field="confirmReal" ${s.confirmReal ? "checked" : ""} />
|
|
115967
116358
|
Confirmo a substitui\xE7\xE3o das leituras reais.</label></div>` : ""}
|
|
@@ -115975,12 +116366,21 @@ function openTelemetryImportModal(params) {
|
|
|
115975
116366
|
const terminal = TERMINAL_JOB_STATUSES.includes(j.status);
|
|
115976
116367
|
let banner = "";
|
|
115977
116368
|
if (j.status === "completed") {
|
|
115978
|
-
banner = j.refreshStatus === "failed" ? '<div class="tlmi-banner warn">Dados importados, mas a atualiza\xE7\xE3o dos totais falhou. Avise o suporte MyIO.</div>' :
|
|
116369
|
+
banner = j.refreshStatus === "failed" ? '<div class="tlmi-banner warn">Dados importados, mas a atualiza\xE7\xE3o dos totais falhou. Avise o suporte MyIO.</div>' : `<div class="tlmi-banner ok">Importa\xE7\xE3o conclu\xEDda. Os totais podem levar alguns minutos para refletir.
|
|
116370
|
+
<div class="tlmi-muted" style="margin-top:4px">Dispositivos manuais continuam aparecendo sem comunica\xE7\xE3o no status:
|
|
116371
|
+
o status conta s\xF3 leitura medida. Os totais e os cards usam os dados importados.</div></div>`;
|
|
115979
116372
|
} else if (j.status === "failed") {
|
|
115980
116373
|
banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${esc9(j.error)}` : "."}</div>`;
|
|
115981
116374
|
} else if (j.status === "cancelled") {
|
|
115982
116375
|
banner = '<div class="tlmi-banner warn">Importa\xE7\xE3o cancelada. As leituras anteriores foram mantidas.</div>';
|
|
116376
|
+
} else if (j.status === "reverted") {
|
|
116377
|
+
banner = '<div class="tlmi-banner ok">Importa\xE7\xE3o desfeita. As leituras anteriores foram restauradas.</div>';
|
|
115983
116378
|
}
|
|
116379
|
+
const canRevert = j.status === "completed" || j.status === "failed";
|
|
116380
|
+
const revert = canRevert ? `<div style="margin-top:12px;display:flex;gap:8px;align-items:center;flex-wrap:wrap">
|
|
116381
|
+
<button class="tlmi-btn" type="button" data-action="revert" ${s.busy ? "disabled" : ""}>${s.confirmRevert ? "Confirmar: desfazer importa\xE7\xE3o" : "Desfazer importa\xE7\xE3o"}</button>
|
|
116382
|
+
<span class="tlmi-muted">${s.confirmRevert ? "Remove as horas importadas e devolve as leituras apagadas. Clique de novo para confirmar." : "Use para remover uma importa\xE7\xE3o errada ou de teste."}</span>
|
|
116383
|
+
</div>` : "";
|
|
115984
116384
|
return `
|
|
115985
116385
|
<div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${esc9(statusText)}</span></h3>
|
|
115986
116386
|
<div class="tlmi-progress" role="progressbar" aria-valuenow="${pct}" aria-valuemin="0" aria-valuemax="100"><i style="width:${pct}%"></i></div>
|
|
@@ -115990,8 +116390,9 @@ function openTelemetryImportModal(params) {
|
|
|
115990
116390
|
<div class="tlmi-kpi"><span>Leituras gravadas</span><strong>${fmtNum(j.inserted)}</strong></div>
|
|
115991
116391
|
</div>
|
|
115992
116392
|
${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${esc9(j.phase)}</p>` : ""}
|
|
115993
|
-
${!terminal ? `<div style="margin-top:12px"><button class="tlmi-btn" type="button" data-action="cancel" ${s.busy ? "disabled" : ""}>Cancelar importa\xE7\xE3o</button>
|
|
116393
|
+
${!terminal && j.status !== "reverting" ? `<div style="margin-top:12px"><button class="tlmi-btn" type="button" data-action="cancel" ${s.busy ? "disabled" : ""}>Cancelar importa\xE7\xE3o</button>
|
|
115994
116394
|
<span class="tlmi-muted" style="margin-left:8px">Voc\xEA pode fechar esta janela; a importa\xE7\xE3o continua.</span></div>` : ""}
|
|
116395
|
+
${revert}
|
|
115995
116396
|
</div>
|
|
115996
116397
|
${banner}
|
|
115997
116398
|
${apiErrorBanner()}`;
|
|
@@ -116164,7 +116565,7 @@ function openTelemetryImportModal(params) {
|
|
|
116164
116565
|
render3();
|
|
116165
116566
|
}
|
|
116166
116567
|
}
|
|
116167
|
-
function schedulePoll(delay = params.pollMs ??
|
|
116568
|
+
function schedulePoll(delay = params.pollMs ?? 2500) {
|
|
116168
116569
|
if (closed || !s.job?.jobId) return;
|
|
116169
116570
|
pollTimer = setTimeout(async () => {
|
|
116170
116571
|
if (closed || !s.job?.jobId) return;
|
|
@@ -116192,11 +116593,34 @@ function openTelemetryImportModal(params) {
|
|
|
116192
116593
|
render3();
|
|
116193
116594
|
}
|
|
116194
116595
|
}
|
|
116596
|
+
async function revertJob() {
|
|
116597
|
+
if (!s.job?.jobId || s.busy) return;
|
|
116598
|
+
if (!s.confirmRevert) {
|
|
116599
|
+
s.confirmRevert = true;
|
|
116600
|
+
render3();
|
|
116601
|
+
return;
|
|
116602
|
+
}
|
|
116603
|
+
s.busy = true;
|
|
116604
|
+
s.confirmRevert = false;
|
|
116605
|
+
s.apiError = "";
|
|
116606
|
+
render3();
|
|
116607
|
+
try {
|
|
116608
|
+
const j = await api.revertJob(s.job.jobId);
|
|
116609
|
+
if (j?.status) s.job = { ...s.job, ...j };
|
|
116610
|
+
if (s.job && !TERMINAL_JOB_STATUSES.includes(s.job.status)) schedulePoll(0);
|
|
116611
|
+
} catch (err) {
|
|
116612
|
+
setError(err);
|
|
116613
|
+
} finally {
|
|
116614
|
+
s.busy = false;
|
|
116615
|
+
render3();
|
|
116616
|
+
}
|
|
116617
|
+
}
|
|
116195
116618
|
root.addEventListener("click", (e) => {
|
|
116196
116619
|
const el2 = e.target.closest("[data-action]");
|
|
116197
116620
|
if (!el2) return;
|
|
116198
116621
|
if (el2.dataset.action === "template") downloadTemplate();
|
|
116199
116622
|
if (el2.dataset.action === "cancel") void cancelJob();
|
|
116623
|
+
if (el2.dataset.action === "revert") void revertJob();
|
|
116200
116624
|
if (el2.dataset.action === "use-form") {
|
|
116201
116625
|
resetAccumulatedSource();
|
|
116202
116626
|
recomputeAccumulated();
|
|
@@ -116422,7 +116846,7 @@ var DOMAIN_TEXT2 = {
|
|
|
116422
116846
|
water: { title: "Novo hidr\xF4metro manual", icon: "\u{1F4A7}", noun: "Hidr\xF4metro" }
|
|
116423
116847
|
};
|
|
116424
116848
|
var STYLE_ID15 = "myio-manualdev-styles";
|
|
116425
|
-
function
|
|
116849
|
+
function escapeHtml15(v) {
|
|
116426
116850
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
116427
116851
|
}
|
|
116428
116852
|
function injectStyles15() {
|
|
@@ -116483,18 +116907,18 @@ function formHtml(domain, values, error, detail) {
|
|
|
116483
116907
|
return `
|
|
116484
116908
|
<form class="myio-manualdev" novalidate>
|
|
116485
116909
|
<p class="myio-manualdev__hint">Cadastre um ponto de leitura manual. Ele aparece nesta lista e n\xE3o entra nos totais nem nos relat\xF3rios.</p>
|
|
116486
|
-
<span class="myio-manualdev__type">${t.icon} ${
|
|
116910
|
+
<span class="myio-manualdev__type">${t.icon} ${escapeHtml15(t.noun)} manual</span>
|
|
116487
116911
|
<label class="myio-manualdev__field">
|
|
116488
116912
|
<span class="myio-manualdev__label">Etiqueta</span>
|
|
116489
116913
|
<input class="myio-manualdev__input" name="label" maxlength="80" autocomplete="off"
|
|
116490
|
-
placeholder="Ex.: Burger King" value="${
|
|
116914
|
+
placeholder="Ex.: Burger King" value="${escapeHtml15(values.label)}" />
|
|
116491
116915
|
</label>
|
|
116492
116916
|
<label class="myio-manualdev__field">
|
|
116493
116917
|
<span class="myio-manualdev__label">Identificador</span>
|
|
116494
116918
|
<input class="myio-manualdev__input" name="identifier" maxlength="40" autocomplete="off"
|
|
116495
|
-
placeholder="Ex.: STB01010" value="${
|
|
116919
|
+
placeholder="Ex.: STB01010" value="${escapeHtml15(values.identifier)}" />
|
|
116496
116920
|
</label>
|
|
116497
|
-
${error ? `<p class="myio-manualdev__error" role="alert">${
|
|
116921
|
+
${error ? `<p class="myio-manualdev__error" role="alert">${escapeHtml15(error)}${detail ? `<small class="myio-manualdev__detail">${escapeHtml15(detail)}</small>` : ""}</p>` : ""}
|
|
116498
116922
|
<button type="submit" hidden></button>
|
|
116499
116923
|
</form>`;
|
|
116500
116924
|
}
|
|
@@ -116502,13 +116926,13 @@ function successHtml(domain, r, tech) {
|
|
|
116502
116926
|
return `
|
|
116503
116927
|
<div class="myio-manualdev__ok">
|
|
116504
116928
|
<div class="myio-manualdev__ok-icon">\u2705</div>
|
|
116505
|
-
<p class="myio-manualdev__ok-title">${
|
|
116506
|
-
<p class="myio-manualdev__ok-text"><strong>${
|
|
116929
|
+
<p class="myio-manualdev__ok-title">${escapeHtml15(DOMAIN_TEXT2[domain].noun)} criado</p>
|
|
116930
|
+
<p class="myio-manualdev__ok-text"><strong>${escapeHtml15(r.label)}</strong> \xB7 ${escapeHtml15(r.identifier)}</p>
|
|
116507
116931
|
${tech ? `<div class="myio-manualdev__tech">
|
|
116508
|
-
device <code>${
|
|
116509
|
-
profile <code>${
|
|
116510
|
-
asset <code>${
|
|
116511
|
-
id <code>${
|
|
116932
|
+
device <code>${escapeHtml15(r.name)}</code><br/>
|
|
116933
|
+
profile <code>${escapeHtml15(r.deviceProfile)}</code><br/>
|
|
116934
|
+
asset <code>${escapeHtml15(r.assetName)}</code><br/>
|
|
116935
|
+
id <code>${escapeHtml15(r.deviceId)}</code>
|
|
116512
116936
|
</div>` : ""}
|
|
116513
116937
|
</div>`;
|
|
116514
116938
|
}
|
|
@@ -116523,20 +116947,20 @@ var STEP_ICON = {
|
|
|
116523
116947
|
};
|
|
116524
116948
|
function stepsHtml(steps) {
|
|
116525
116949
|
return `<ol class="myio-manualdev__steps">${steps.map(
|
|
116526
|
-
(s) => `<li class="myio-manualdev__step" data-status="${
|
|
116950
|
+
(s) => `<li class="myio-manualdev__step" data-status="${escapeHtml15(s.status)}">
|
|
116527
116951
|
<span aria-hidden="true">${STEP_ICON[s.status] || "\u25CB"}</span>
|
|
116528
|
-
<span class="myio-manualdev__step-sys">${
|
|
116529
|
-
<span>${
|
|
116952
|
+
<span class="myio-manualdev__step-sys">${escapeHtml15(s.system)}</span>
|
|
116953
|
+
<span>${escapeHtml15(s.title)}${s.message ? `<small class="myio-manualdev__step-msg">${escapeHtml15(s.message)}</small>` : ""}</span>
|
|
116530
116954
|
</li>`
|
|
116531
116955
|
).join("")}</ol>`;
|
|
116532
116956
|
}
|
|
116533
116957
|
function notesHtml(plan) {
|
|
116534
|
-
const block = (plan.blockers || []).map((b) => `<p class="myio-manualdev__note myio-manualdev__note--block" role="alert">\u26D4 ${
|
|
116535
|
-
const warn = (plan.warnings || []).map((w) => `<p class="myio-manualdev__note myio-manualdev__note--warn">\u26A0\uFE0F ${
|
|
116958
|
+
const block = (plan.blockers || []).map((b) => `<p class="myio-manualdev__note myio-manualdev__note--block" role="alert">\u26D4 ${escapeHtml15(b)}</p>`);
|
|
116959
|
+
const warn = (plan.warnings || []).map((w) => `<p class="myio-manualdev__note myio-manualdev__note--warn">\u26A0\uFE0F ${escapeHtml15(w)}</p>`);
|
|
116536
116960
|
return [...block, ...warn].join("");
|
|
116537
116961
|
}
|
|
116538
116962
|
function rowsHtml(rows) {
|
|
116539
|
-
return `<table class="myio-manualdev__summary"><tbody>${rows.map((r) => `<tr><th>${
|
|
116963
|
+
return `<table class="myio-manualdev__summary"><tbody>${rows.map((r) => `<tr><th>${escapeHtml15(r.label)}</th><td>${escapeHtml15(r.value)}</td></tr>`).join("")}</tbody></table>`;
|
|
116540
116964
|
}
|
|
116541
116965
|
function moreHtml(inner, open = false) {
|
|
116542
116966
|
return `<details class="myio-manualdev__more"${open ? " open" : ""}>
|
|
@@ -116556,7 +116980,7 @@ function planHtml(plan) {
|
|
|
116556
116980
|
function progressHtml(steps, message, ok, open = false) {
|
|
116557
116981
|
return `
|
|
116558
116982
|
<div class="myio-manualdev">
|
|
116559
|
-
${ok === void 0 ? '<p class="myio-manualdev__hint">Criando o dispositivo\u2026 n\xE3o feche esta janela.</p>' : `<p class="myio-manualdev__note ${ok ? "myio-manualdev__note--warn" : "myio-manualdev__note--block"}" role="status">${
|
|
116983
|
+
${ok === void 0 ? '<p class="myio-manualdev__hint">Criando o dispositivo\u2026 n\xE3o feche esta janela.</p>' : `<p class="myio-manualdev__note ${ok ? "myio-manualdev__note--warn" : "myio-manualdev__note--block"}" role="status">${escapeHtml15(
|
|
116560
116984
|
message || (ok ? "Conclu\xEDdo com avisos." : "N\xE3o foi poss\xEDvel concluir.")
|
|
116561
116985
|
)}</p>`}
|
|
116562
116986
|
${moreHtml(stepsHtml(steps), open)}
|
|
@@ -118832,7 +119256,7 @@ function openMyioGcdrLoginModal(options) {
|
|
|
118832
119256
|
// src/components/img-gallery/ScrollableTabs.ts
|
|
118833
119257
|
var STYLE_ID16 = "myio-tabs-styles";
|
|
118834
119258
|
var FONT_LINK_ID4 = "myio-dialog-font-nunito";
|
|
118835
|
-
function
|
|
119259
|
+
function escapeHtml16(value) {
|
|
118836
119260
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
118837
119261
|
}
|
|
118838
119262
|
function injectStyles16() {
|
|
@@ -118968,7 +119392,7 @@ function createScrollableTabs(options) {
|
|
|
118968
119392
|
btn.setAttribute("role", "tab");
|
|
118969
119393
|
btn.dataset.key = t.key;
|
|
118970
119394
|
if (t.disabled) btn.disabled = true;
|
|
118971
|
-
btn.innerHTML = `${t.icon ? `<span aria-hidden="true">${t.icon}</span>` : ""}<span>${
|
|
119395
|
+
btn.innerHTML = `${t.icon ? `<span aria-hidden="true">${t.icon}</span>` : ""}<span>${escapeHtml16(t.label)}</span>`;
|
|
118972
119396
|
styleTab(btn, t.key === active);
|
|
118973
119397
|
btn.addEventListener("click", () => {
|
|
118974
119398
|
if (t.disabled || t.key === active) return;
|
|
@@ -119055,7 +119479,7 @@ function createScrollableTabs(options) {
|
|
|
119055
119479
|
// src/components/img-gallery/ImgGallery.ts
|
|
119056
119480
|
var STYLE_ID17 = "myio-gallery-styles";
|
|
119057
119481
|
var FONT_LINK_ID5 = "myio-dialog-font-nunito";
|
|
119058
|
-
function
|
|
119482
|
+
function escapeHtml17(value) {
|
|
119059
119483
|
return String(value == null ? "" : value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
119060
119484
|
}
|
|
119061
119485
|
var PRM = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
@@ -119279,10 +119703,10 @@ function createImgGallery(options) {
|
|
|
119279
119703
|
root.appendChild(grid);
|
|
119280
119704
|
function detailsHtml(img) {
|
|
119281
119705
|
const lines = [];
|
|
119282
|
-
if (img.filename) lines.push(`<span title="${
|
|
119283
|
-
if (typeof img.sizeBytes === "number") lines.push(`<span>${
|
|
119706
|
+
if (img.filename) lines.push(`<span title="${escapeHtml17(img.filename)}">${escapeHtml17(img.filename)}</span>`);
|
|
119707
|
+
if (typeof img.sizeBytes === "number") lines.push(`<span>${escapeHtml17(formatSize(img.sizeBytes))}</span>`);
|
|
119284
119708
|
const dims = typeof img.width === "number" && typeof img.height === "number" ? `${img.width} \xD7 ${img.height}px` : "";
|
|
119285
|
-
lines.push(`<span data-dims>${
|
|
119709
|
+
lines.push(`<span data-dims>${escapeHtml17(dims)}</span>`);
|
|
119286
119710
|
return lines.join("");
|
|
119287
119711
|
}
|
|
119288
119712
|
function renderDescription(body, img, index) {
|
|
@@ -136749,7 +137173,7 @@ var FALLBACK_THEME = {
|
|
|
136749
137173
|
accentText: "#ffffff",
|
|
136750
137174
|
mode: "light"
|
|
136751
137175
|
};
|
|
136752
|
-
function
|
|
137176
|
+
function escapeHtml18(value) {
|
|
136753
137177
|
return String(value ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
136754
137178
|
}
|
|
136755
137179
|
var nfInt = new Intl.NumberFormat("pt-BR", { maximumFractionDigits: 0 });
|
|
@@ -136777,7 +137201,7 @@ function legendHtml() {
|
|
|
136777
137201
|
[SERIES_COLORS.orcado, "Or\xE7ado"]
|
|
136778
137202
|
];
|
|
136779
137203
|
return `<div class="myio-mg-legend">${items.map(
|
|
136780
|
-
([c, l]) => `<span class="myio-mg-legend__item"><span class="myio-mg-legend__dot" style="background:${c}" aria-hidden="true"></span>${
|
|
137204
|
+
([c, l]) => `<span class="myio-mg-legend__item"><span class="myio-mg-legend__dot" style="background:${c}" aria-hidden="true"></span>${escapeHtml18(
|
|
136781
137205
|
l
|
|
136782
137206
|
)}</span>`
|
|
136783
137207
|
).join("")}</div>`;
|
|
@@ -136817,7 +137241,7 @@ function miniChartSvg(s) {
|
|
|
136817
137241
|
const pts = data.map((v, i) => `${(i * bandW + bandW / 2).toFixed(1)},${y(v).toFixed(1)}`).join(" ");
|
|
136818
137242
|
return `<polyline points="${pts}" fill="none" stroke="${color}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"></polyline>`;
|
|
136819
137243
|
};
|
|
136820
|
-
return `<svg class="myio-mg-chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Gr\xE1fico ilustrativo de ${
|
|
137244
|
+
return `<svg class="myio-mg-chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Gr\xE1fico ilustrativo de ${escapeHtml18(
|
|
136821
137245
|
s.name
|
|
136822
137246
|
)}" preserveAspectRatio="none">
|
|
136823
137247
|
${bars}
|
|
@@ -136834,8 +137258,8 @@ function kpiRowHtml(s, unit) {
|
|
|
136834
137258
|
];
|
|
136835
137259
|
return `<div class="myio-mg-kpis">${kpis.map(
|
|
136836
137260
|
([label, val, color]) => `<div class="myio-mg-kpi">
|
|
136837
|
-
<span class="myio-mg-kpi__label" style="color:${color}">${
|
|
136838
|
-
<span class="myio-mg-kpi__value">${fmtInt(val)} <small>${
|
|
137261
|
+
<span class="myio-mg-kpi__label" style="color:${color}">${escapeHtml18(label)}</span>
|
|
137262
|
+
<span class="myio-mg-kpi__value">${fmtInt(val)} <small>${escapeHtml18(unit)}</small></span>
|
|
136839
137263
|
</div>`
|
|
136840
137264
|
).join("")}</div>`;
|
|
136841
137265
|
}
|
|
@@ -136843,7 +137267,7 @@ function chipsHtml(s) {
|
|
|
136843
137267
|
const c = computeChips(s);
|
|
136844
137268
|
const chip = (label, ratio) => {
|
|
136845
137269
|
const cls = ratio > 0 ? "is-up" : ratio < 0 ? "is-down" : "is-flat";
|
|
136846
|
-
return `<span class="myio-mg-chip ${cls}">${
|
|
137270
|
+
return `<span class="myio-mg-chip ${cls}">${escapeHtml18(label)} <strong>${escapeHtml18(
|
|
136847
137271
|
fmtPct4(ratio)
|
|
136848
137272
|
)}</strong></span>`;
|
|
136849
137273
|
};
|
|
@@ -136858,7 +137282,7 @@ function miniCardHtml(s, unit, opts) {
|
|
|
136858
137282
|
const showKpis = opts?.kpis !== false;
|
|
136859
137283
|
const showChips = opts?.chips !== false;
|
|
136860
137284
|
return `<div class="myio-mg-card">
|
|
136861
|
-
<h5 class="myio-mg-card__title">${
|
|
137285
|
+
<h5 class="myio-mg-card__title">${escapeHtml18(s.name)}</h5>
|
|
136862
137286
|
${showChart ? legendHtml() + miniChartSvg(s) : ""}
|
|
136863
137287
|
${showKpis ? kpiRowHtml(s, unit) : ""}
|
|
136864
137288
|
${showChips ? chipsHtml(s) : ""}
|
|
@@ -136868,7 +137292,7 @@ function miniSidebarHtml(shoppings, unit, prevY, curY) {
|
|
|
136868
137292
|
const total = deriveTotal({ shoppings });
|
|
136869
137293
|
const row = (name, a, r, o, m, isTotal) => `
|
|
136870
137294
|
<div class="myio-mg-side__row${isTotal ? " is-total" : ""}">
|
|
136871
|
-
<span class="myio-mg-side__name">${
|
|
137295
|
+
<span class="myio-mg-side__name">${escapeHtml18(name)}</span>
|
|
136872
137296
|
<span class="myio-mg-side__vals">
|
|
136873
137297
|
<b style="color:${SERIES_COLORS.aMinus1}">${fmtInt(a)}</b>
|
|
136874
137298
|
<b style="color:${SERIES_COLORS.realizado}">${fmtInt(r)}</b>
|
|
@@ -136879,7 +137303,7 @@ function miniSidebarHtml(shoppings, unit, prevY, curY) {
|
|
|
136879
137303
|
return `<div class="myio-mg-side">
|
|
136880
137304
|
<div class="myio-mg-side__head">
|
|
136881
137305
|
<span>Resumo por shopping</span>
|
|
136882
|
-
<span class="myio-mg-side__unit">${
|
|
137306
|
+
<span class="myio-mg-side__unit">${escapeHtml18(unit)}</span>
|
|
136883
137307
|
</div>
|
|
136884
137308
|
<div class="myio-mg-side__cols">
|
|
136885
137309
|
<span>Shopping</span>
|
|
@@ -136906,10 +137330,10 @@ function miniToolbarHtml(prevY, curY, highlight) {
|
|
|
136906
137330
|
</div>`;
|
|
136907
137331
|
}
|
|
136908
137332
|
function bannerHtml(text2) {
|
|
136909
|
-
return `<p class="myio-mg-banner">${
|
|
137333
|
+
return `<p class="myio-mg-banner">${escapeHtml18(text2)}</p>`;
|
|
136910
137334
|
}
|
|
136911
137335
|
function paras(sentences) {
|
|
136912
|
-
return `<div class="myio-mg-copy">${sentences.map((s) => `<p>${
|
|
137336
|
+
return `<div class="myio-mg-copy">${sentences.map((s) => `<p>${escapeHtml18(s)}</p>`).join("")}</div>`;
|
|
136913
137337
|
}
|
|
136914
137338
|
function buildSections(ctx) {
|
|
136915
137339
|
const { energy, water, curY, prevY } = ctx;
|
|
@@ -136934,8 +137358,8 @@ function buildSections(ctx) {
|
|
|
136934
137358
|
"A r\xE9gua da meta muda por dom\xEDnio: em Energia a refer\xEAncia \xE9 a ENTRADA; em \xC1gua, os hidr\xF4metros.",
|
|
136935
137359
|
"Os n\xFAmeros e a unidade de cada card acompanham o dom\xEDnio selecionado."
|
|
136936
137360
|
]) + miniToolbarHtml(prevY, curY, "domain") + `<div class="myio-mg-two">
|
|
136937
|
-
<div><div class="myio-mg-two__tag">\u26A1 Energia \xB7 ${
|
|
136938
|
-
<div><div class="myio-mg-two__tag">\u{1F4A7} \xC1gua \xB7 ${
|
|
137361
|
+
<div><div class="myio-mg-two__tag">\u26A1 Energia \xB7 ${escapeHtml18(energy.unit)}</div>${miniCardHtml(e0, energy.unit, { chips: false })}</div>
|
|
137362
|
+
<div><div class="myio-mg-two__tag">\u{1F4A7} \xC1gua \xB7 ${escapeHtml18(water.unit)}</div>${miniCardHtml(w0, water.unit, { chips: false })}</div>
|
|
136939
137363
|
</div>`
|
|
136940
137364
|
},
|
|
136941
137365
|
{
|
|
@@ -137006,7 +137430,7 @@ function buildSections(ctx) {
|
|
|
137006
137430
|
]) + `<div class="myio-mg-order">
|
|
137007
137431
|
<span class="myio-mg-order__btn">Data de Inaugura\xE7\xE3o \u2191 \xB7 \u2699\uFE0F</span>
|
|
137008
137432
|
<span class="myio-mg-order__btn">\u25BD Filtros</span>
|
|
137009
|
-
</div><ul class="myio-mg-order__list">${energy.shoppings.slice().sort((a, b) => a.inaugurationDate.localeCompare(b.inaugurationDate)).map((s) => `<li><b>${
|
|
137433
|
+
</div><ul class="myio-mg-order__list">${energy.shoppings.slice().sort((a, b) => a.inaugurationDate.localeCompare(b.inaugurationDate)).map((s) => `<li><b>${escapeHtml18(s.name)}</b> <span>inaugurado em ${escapeHtml18(s.inaugurationDate)}</span></li>`).join("")}</ul>`
|
|
137010
137434
|
},
|
|
137011
137435
|
{
|
|
137012
137436
|
id: "engine",
|
|
@@ -137145,9 +137569,9 @@ function openMetasGuide(options = {}) {
|
|
|
137145
137569
|
root.innerHTML = `
|
|
137146
137570
|
<div class="myio-mg-modal${theme.mode === "dark" ? " is-dark" : ""}" role="dialog" aria-modal="true"
|
|
137147
137571
|
aria-labelledby="myio-mg-title"
|
|
137148
|
-
style="--mg-accent:${
|
|
137572
|
+
style="--mg-accent:${escapeHtml18(theme.accent)};--mg-accent-dark:${escapeHtml18(
|
|
137149
137573
|
theme.accentDark
|
|
137150
|
-
)};--mg-accent-text:${
|
|
137574
|
+
)};--mg-accent-text:${escapeHtml18(theme.accentText)};">
|
|
137151
137575
|
<div class="myio-mg-header">
|
|
137152
137576
|
<div class="myio-mg-header__l">
|
|
137153
137577
|
<span class="myio-mg-header__logo" aria-hidden="true">\u{1F393}</span>
|
|
@@ -155243,8 +155667,8 @@ function renderDowntimeList(downtimeList) {
|
|
|
155243
155667
|
<div class="downtime-item">
|
|
155244
155668
|
<span class="rank">${index + 1}</span>
|
|
155245
155669
|
<div class="item-info">
|
|
155246
|
-
<span class="item-name">${
|
|
155247
|
-
<span class="item-location">${
|
|
155670
|
+
<span class="item-name">${escapeHtml19(item.name)}</span>
|
|
155671
|
+
<span class="item-location">${escapeHtml19(item.location)}</span>
|
|
155248
155672
|
</div>
|
|
155249
155673
|
<div class="item-metrics">
|
|
155250
155674
|
<span class="downtime-hours">${item.downtime}h</span>
|
|
@@ -155257,7 +155681,7 @@ function renderDowntimeList(downtimeList) {
|
|
|
155257
155681
|
`
|
|
155258
155682
|
).join("");
|
|
155259
155683
|
}
|
|
155260
|
-
function
|
|
155684
|
+
function escapeHtml19(text2) {
|
|
155261
155685
|
const div = document.createElement("div");
|
|
155262
155686
|
div.textContent = text2;
|
|
155263
155687
|
return div.innerHTML;
|
|
@@ -159840,7 +160264,7 @@ function removeSchedulingSharedStyles() {
|
|
|
159840
160264
|
}
|
|
159841
160265
|
|
|
159842
160266
|
// src/components/scheduling-shared/view-helpers.ts
|
|
159843
|
-
function
|
|
160267
|
+
function escapeHtml20(str) {
|
|
159844
160268
|
const div = document.createElement("div");
|
|
159845
160269
|
div.textContent = str;
|
|
159846
160270
|
return div.innerHTML;
|
|
@@ -160001,7 +160425,7 @@ function showConfirmModal(container, title, message) {
|
|
|
160001
160425
|
overlay.innerHTML = `
|
|
160002
160426
|
<div class="${SCHED_CSS_PREFIX}__modal-backdrop"></div>
|
|
160003
160427
|
<div class="${SCHED_CSS_PREFIX}__modal-content">
|
|
160004
|
-
<h3>${
|
|
160428
|
+
<h3>${escapeHtml20(title)}</h3>
|
|
160005
160429
|
<p>${message}</p>
|
|
160006
160430
|
<div class="${SCHED_CSS_PREFIX}__modal-actions">
|
|
160007
160431
|
<button class="${SCHED_CSS_PREFIX}__modal-btn-cancel">Cancelar</button>
|
|
@@ -160035,8 +160459,8 @@ function showNotificationModal(container, type, message, autoCloseMs = 6e3) {
|
|
|
160035
160459
|
overlay.innerHTML = `
|
|
160036
160460
|
<div class="${SCHED_CSS_PREFIX}__modal-backdrop"></div>
|
|
160037
160461
|
<div class="${SCHED_CSS_PREFIX}__modal-content">
|
|
160038
|
-
<h3>${
|
|
160039
|
-
<p>${
|
|
160462
|
+
<h3>${escapeHtml20(title)}</h3>
|
|
160463
|
+
<p>${escapeHtml20(message)}</p>
|
|
160040
160464
|
<div class="${SCHED_CSS_PREFIX}__modal-actions">
|
|
160041
160465
|
<button class="${SCHED_CSS_PREFIX}__modal-btn-close">Fechar</button>
|
|
160042
160466
|
</div>
|
|
@@ -175355,7 +175779,7 @@ var IMPORTANCE_COLORS4 = {
|
|
|
175355
175779
|
// red
|
|
175356
175780
|
};
|
|
175357
175781
|
var ITEM_TEXT_MAX = 120;
|
|
175358
|
-
function
|
|
175782
|
+
function escapeHtml21(input) {
|
|
175359
175783
|
if (input == null) return "";
|
|
175360
175784
|
return String(input).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
175361
175785
|
}
|
|
@@ -175393,24 +175817,24 @@ function renderAnnotationItemCard(device, annotation, searchTerm) {
|
|
|
175393
175817
|
const domainIcon = DOMAIN_ICONS3[device.domain] ?? DOMAIN_ICONS3.unknown;
|
|
175394
175818
|
const typeIcon = TYPE_ICONS[annotation.type] ?? "\xB7";
|
|
175395
175819
|
const importance = Math.max(1, Math.min(5, annotation.importance || 1));
|
|
175396
|
-
const textEscaped =
|
|
175397
|
-
const deviceLabelEscaped =
|
|
175398
|
-
const author =
|
|
175399
|
-
const when =
|
|
175820
|
+
const textEscaped = escapeHtml21(truncate2(annotation.text || "", ITEM_TEXT_MAX));
|
|
175821
|
+
const deviceLabelEscaped = escapeHtml21(device.label || device.name || device.deviceId);
|
|
175822
|
+
const author = escapeHtml21(annotation.createdBy?.name || "sem autor");
|
|
175823
|
+
const when = escapeHtml21(formatRelative(annotation.createdAt));
|
|
175400
175824
|
const overdueTag = isOverdue(annotation) ? '<span class="myio-annotations-overdue">Vencida</span>' : "";
|
|
175401
175825
|
const text2 = searchTerm ? highlightMatches(textEscaped, searchTerm) : textEscaped;
|
|
175402
175826
|
const deviceLabel = searchTerm ? highlightMatches(deviceLabelEscaped, searchTerm) : deviceLabelEscaped;
|
|
175403
|
-
const identifierEscaped = device.identifier ?
|
|
175827
|
+
const identifierEscaped = device.identifier ? escapeHtml21(device.identifier) : "";
|
|
175404
175828
|
const identifierHighlighted = searchTerm && identifierEscaped ? highlightMatches(identifierEscaped, searchTerm) : identifierEscaped;
|
|
175405
175829
|
const identifierTag = device.identifier ? `<span class="myio-annotations-item-device">${identifierHighlighted}</span>` : "";
|
|
175406
175830
|
return `
|
|
175407
175831
|
<button
|
|
175408
175832
|
class="myio-annotations-item"
|
|
175409
175833
|
type="button"
|
|
175410
|
-
data-device-id="${
|
|
175411
|
-
data-annotation-id="${
|
|
175834
|
+
data-device-id="${escapeHtml21(device.deviceId)}"
|
|
175835
|
+
data-annotation-id="${escapeHtml21(annotation.id)}"
|
|
175412
175836
|
tabindex="0"
|
|
175413
|
-
aria-label="${
|
|
175837
|
+
aria-label="${escapeHtml21(annotation.text)} \u2014 ${deviceLabel}"
|
|
175414
175838
|
>
|
|
175415
175839
|
<span class="myio-annotations-item-icon" aria-hidden="true">${typeIcon}</span>
|
|
175416
175840
|
<div class="myio-annotations-item-body">
|
|
@@ -176387,8 +176811,8 @@ var HeaderAnnotationsPanel = class _HeaderAnnotationsPanel {
|
|
|
176387
176811
|
// group header
|
|
176388
176812
|
render: () => `
|
|
176389
176813
|
<header class="myio-annotations-group-header ${groupClass}">
|
|
176390
|
-
${g.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${
|
|
176391
|
-
<span class="myio-annotations-group-label">${
|
|
176814
|
+
${g.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml21(g.icon)}</span>` : ""}
|
|
176815
|
+
<span class="myio-annotations-group-label">${escapeHtml21(g.label)}</span>
|
|
176392
176816
|
<span class="myio-annotations-group-count">${g.totalAnnotations}</span>
|
|
176393
176817
|
</header>`
|
|
176394
176818
|
});
|
|
@@ -176513,9 +176937,9 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
|
|
|
176513
176937
|
}
|
|
176514
176938
|
_renderToolbar(filteredCount, totalCount) {
|
|
176515
176939
|
const sortOptions = SORT_OPTIONS.map(
|
|
176516
|
-
(o) => `<option value="${o.key}" ${o.key === this.sortBy ? "selected" : ""}>${
|
|
176940
|
+
(o) => `<option value="${o.key}" ${o.key === this.sortBy ? "selected" : ""}>${escapeHtml21(o.label)}</option>`
|
|
176517
176941
|
).join("");
|
|
176518
|
-
const term =
|
|
176942
|
+
const term = escapeHtml21(this.filter.searchTerm || "");
|
|
176519
176943
|
const filtersActiveCount = this._activeFilterCount();
|
|
176520
176944
|
const filterIndicator = filtersActiveCount > 0 ? `<span class="myio-annotations-group-count">${filtersActiveCount}</span>` : "";
|
|
176521
176945
|
const showingHtml = filteredCount === totalCount ? `${totalCount} anota\xE7\xF5es` : `${filteredCount} de ${totalCount} anota\xE7\xF5es`;
|
|
@@ -176556,13 +176980,13 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
|
|
|
176556
176980
|
const typesHtml = FILTER_TYPE_OPTIONS.map(
|
|
176557
176981
|
(t) => `<label class="myio-annotations-filter-chip ${this.filter.types.has(t.id) ? "is-on" : ""}">
|
|
176558
176982
|
<input type="checkbox" data-filter="type" value="${t.id}" ${this.filter.types.has(t.id) ? "checked" : ""} />
|
|
176559
|
-
<span>${t.icon} ${
|
|
176983
|
+
<span>${t.icon} ${escapeHtml21(t.label)}</span>
|
|
176560
176984
|
</label>`
|
|
176561
176985
|
).join("");
|
|
176562
176986
|
const statusHtml = FILTER_STATUS_OPTIONS.map(
|
|
176563
176987
|
(s) => `<label class="myio-annotations-filter-chip ${this.filter.statuses.has(s.id) ? "is-on" : ""}">
|
|
176564
176988
|
<input type="checkbox" data-filter="status" value="${s.id}" ${this.filter.statuses.has(s.id) ? "checked" : ""} />
|
|
176565
|
-
<span>${
|
|
176989
|
+
<span>${escapeHtml21(s.label)}</span>
|
|
176566
176990
|
</label>`
|
|
176567
176991
|
).join("");
|
|
176568
176992
|
const impHtml = [1, 2, 3, 4, 5].map(
|
|
@@ -176639,12 +177063,12 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
|
|
|
176639
177063
|
return `
|
|
176640
177064
|
<section class="${groupClass}">
|
|
176641
177065
|
<header class="myio-annotations-group-header" role="button" tabindex="0"
|
|
176642
|
-
data-group-toggle="${
|
|
177066
|
+
data-group-toggle="${escapeHtml21(group.key)}"
|
|
176643
177067
|
aria-expanded="${!isCollapsed}"
|
|
176644
177068
|
title="${isCollapsed ? "Expandir grupo" : "Recolher grupo"}">
|
|
176645
177069
|
<span class="myio-annotations-group-chevron" aria-hidden="true">${isCollapsed ? "\u25B6" : "\u25BC"}</span>
|
|
176646
|
-
${group.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${
|
|
176647
|
-
<span class="myio-annotations-group-label">${
|
|
177070
|
+
${group.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml21(group.icon)}</span>` : ""}
|
|
177071
|
+
<span class="myio-annotations-group-label">${escapeHtml21(group.label)}</span>
|
|
176648
177072
|
<span class="myio-annotations-group-count">${group.totalAnnotations}</span>
|
|
176649
177073
|
</header>
|
|
176650
177074
|
${itemsHtml}
|