myio-js-library 0.1.581 → 0.1.582
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 +604 -213
- package/dist/index.js +583 -192
- package/dist/myio-js-library.umd.js +583 -192
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -719,7 +719,7 @@ __export(src_exports, {
|
|
|
719
719
|
injectCustomerCardV1Styles: () => injectCustomerCardV1Styles,
|
|
720
720
|
injectCustomerCardV2Styles: () => injectCustomerCardV2Styles,
|
|
721
721
|
injectDeviceCategoryStyles: () => injectDeviceCategoryStyles,
|
|
722
|
-
injectDeviceGridV6Styles: () =>
|
|
722
|
+
injectDeviceGridV6Styles: () => injectStyles23,
|
|
723
723
|
injectDeviceOperationalCardGridStyles: () => injectDeviceOperationalCardGridStyles,
|
|
724
724
|
injectDeviceOperationalCardStyles: () => injectDeviceOperationalCardStyles,
|
|
725
725
|
injectExportButtonStyles: () => injectExportButtonStyles,
|
|
@@ -989,7 +989,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
989
989
|
// package.json
|
|
990
990
|
var package_default = {
|
|
991
991
|
name: "myio-js-library",
|
|
992
|
-
version: "0.1.
|
|
992
|
+
version: "0.1.582",
|
|
993
993
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
994
994
|
license: "MIT",
|
|
995
995
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -33190,8 +33190,8 @@ var EnergyDataFetcher = class {
|
|
|
33190
33190
|
// src/components/premium-modals/internal/engines/CsvExporter.ts
|
|
33191
33191
|
var toCsv = (rows, locale = "pt-BR", sep = ";") => {
|
|
33192
33192
|
const fmt2 = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
33193
|
-
const
|
|
33194
|
-
return rows.map((r) => r.map((c) => `"${
|
|
33193
|
+
const esc12 = (v) => (typeof v === "number" ? fmt2.format(v) : String(v)).replace(/"/g, '""');
|
|
33194
|
+
return rows.map((r) => r.map((c) => `"${esc12(c)}"`).join(sep)).join("\r\n");
|
|
33195
33195
|
};
|
|
33196
33196
|
|
|
33197
33197
|
// src/components/premium-modals/energy/types.ts
|
|
@@ -37599,14 +37599,14 @@ var DeviceReportModal = class {
|
|
|
37599
37599
|
// Header: "Relatório - <identifier> - <label>" + nome do device (sutil, com copiar).
|
|
37600
37600
|
// O customer já aparece no footer premium. Texto escapado — o shell usa innerHTML no título.
|
|
37601
37601
|
buildHeaderTitleHTML() {
|
|
37602
|
-
const
|
|
37603
|
-
const base =
|
|
37602
|
+
const esc12 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
37603
|
+
const base = esc12(
|
|
37604
37604
|
`Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`
|
|
37605
37605
|
);
|
|
37606
37606
|
const deviceName = String(this.params.deviceName || "").trim();
|
|
37607
37607
|
const deviceHTML = deviceName ? `<span class="myio-dr-devname" style="margin-left:10px;font-size:0.72em;font-weight:400;opacity:.75;display:inline-flex;align-items:center;gap:4px;vertical-align:middle;">
|
|
37608
|
-
${
|
|
37609
|
-
<button type="button" class="myio-dr-copy" data-copy="${
|
|
37608
|
+
${esc12(deviceName)}
|
|
37609
|
+
<button type="button" class="myio-dr-copy" data-copy="${esc12(deviceName)}" title="Copiar nome do dispositivo"
|
|
37610
37610
|
aria-label="Copiar nome do dispositivo"
|
|
37611
37611
|
style="border:none;background:transparent;color:inherit;cursor:pointer;padding:0 2px;line-height:1;opacity:.9;display:inline-flex;">
|
|
37612
37612
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
|
|
@@ -63392,6 +63392,32 @@ var EDITABLE_ATTRS = [
|
|
|
63392
63392
|
{ key: "gcdrCustomerId", label: "GCDR Customer ID" },
|
|
63393
63393
|
{ key: "gcdrAssetId", label: "GCDR Asset ID" }
|
|
63394
63394
|
];
|
|
63395
|
+
var EDITABLE_OTHER_ATTRS = ["contract", "floor"];
|
|
63396
|
+
var MIN_EPOCH_MS = 1e12;
|
|
63397
|
+
var MAX_EPOCH_MS = 1e13;
|
|
63398
|
+
function attrTimestampMs(key, value) {
|
|
63399
|
+
if (!/(Time|At|Ts|Timestamp)$/.test(key)) return null;
|
|
63400
|
+
if (typeof value === "number" || typeof value === "string" && /^\d{12,13}$/.test(value.trim())) {
|
|
63401
|
+
const n = Number(value);
|
|
63402
|
+
return n >= MIN_EPOCH_MS && n < MAX_EPOCH_MS ? n : null;
|
|
63403
|
+
}
|
|
63404
|
+
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}T/.test(value)) {
|
|
63405
|
+
const n = Date.parse(value);
|
|
63406
|
+
return Number.isFinite(n) ? n : null;
|
|
63407
|
+
}
|
|
63408
|
+
return null;
|
|
63409
|
+
}
|
|
63410
|
+
function relativeTime(ts, now = Date.now()) {
|
|
63411
|
+
const diff = now - ts;
|
|
63412
|
+
const abs = Math.abs(diff);
|
|
63413
|
+
const min = Math.round(abs / 6e4);
|
|
63414
|
+
let txt;
|
|
63415
|
+
if (min < 1) txt = "menos de 1 min";
|
|
63416
|
+
else if (min < 60) txt = `${min} min`;
|
|
63417
|
+
else if (min < 48 * 60) txt = `${Math.round(min / 60)} h`;
|
|
63418
|
+
else txt = `${Math.round(min / 1440)} dias`;
|
|
63419
|
+
return diff >= 0 ? `h\xE1 ${txt}` : `em ${txt}`;
|
|
63420
|
+
}
|
|
63395
63421
|
var READONLY_ATTRS = [
|
|
63396
63422
|
{ key: "deviceType", label: "Device Type" },
|
|
63397
63423
|
{ key: "slaveId", label: "Slave ID" },
|
|
@@ -63665,10 +63691,12 @@ var DeviceProfileTab = class {
|
|
|
63665
63691
|
renderRow(field, label, value, kind) {
|
|
63666
63692
|
const text2 = this.esc(this.displayText(value));
|
|
63667
63693
|
if (kind === "readonly") {
|
|
63694
|
+
const ts = attrTimestampMs(field, value);
|
|
63695
|
+
const valueHtml = ts !== null ? `<span class="dpt-value" title="${text2}">${this.esc(this.formatDate(ts))} <span class="dpt-rel">(${this.esc(relativeTime(ts))})</span></span>` : `<span class="dpt-value">${text2}</span>`;
|
|
63668
63696
|
return `
|
|
63669
63697
|
<div class="dpt-row" data-field="${this.esc(field)}">
|
|
63670
63698
|
<span class="dpt-label">${this.esc(label)}</span>
|
|
63671
|
-
|
|
63699
|
+
${valueHtml}
|
|
63672
63700
|
</div>`;
|
|
63673
63701
|
}
|
|
63674
63702
|
const syncBtn = kind === "ingestion" ? `<button type="button" class="dpt-icon-btn" data-action="sync-ingestion" title="Buscar ingestionId na Ingestion API">\u{1F504}</button>` : "";
|
|
@@ -63699,8 +63727,14 @@ var DeviceProfileTab = class {
|
|
|
63699
63727
|
({ key, label }) => this.renderRow(key, label, this.attrValue(key), "readonly")
|
|
63700
63728
|
).join("");
|
|
63701
63729
|
const highlightedKeys = /* @__PURE__ */ new Set([...EDITABLE_ATTRS.map((a) => a.key), ...READONLY_ATTRS.map((a) => a.key)]);
|
|
63702
|
-
const otherAttrs = this.attributes.filter((a) => !highlightedKeys.has(a.key))
|
|
63703
|
-
|
|
63730
|
+
const otherAttrs = this.attributes.filter((a) => !highlightedKeys.has(a.key));
|
|
63731
|
+
EDITABLE_OTHER_ATTRS.forEach((key) => {
|
|
63732
|
+
if (!otherAttrs.some((a) => a.key === key)) otherAttrs.push({ key, value: void 0 });
|
|
63733
|
+
});
|
|
63734
|
+
otherAttrs.sort((a, b) => a.key.localeCompare(b.key));
|
|
63735
|
+
const otherRows = otherAttrs.length ? otherAttrs.map(
|
|
63736
|
+
(a) => this.renderRow(a.key, a.key, a.value, EDITABLE_OTHER_ATTRS.includes(a.key) ? "attr-text" : "readonly")
|
|
63737
|
+
).join("") : `<div class="dpt-empty">Nenhum outro atributo SERVER_SCOPE.</div>`;
|
|
63704
63738
|
return `
|
|
63705
63739
|
<div class="dpt-tab">
|
|
63706
63740
|
<div class="dpt-notice">\u{1F512} Aba vis\xEDvel apenas para administradores MyIO \u2014 altera dados direto no ThingsBoard.</div>
|
|
@@ -63877,6 +63911,7 @@ var DeviceProfileTab = class {
|
|
|
63877
63911
|
.dpt-label { font-size: 12px; color: #6b7280; font-weight: 600; white-space: nowrap; }
|
|
63878
63912
|
.dpt-value { font-size: 13px; color: #111827; text-align: right; word-break: break-word; }
|
|
63879
63913
|
.dpt-value-wrap { display: flex; align-items: center; gap: 6px; }
|
|
63914
|
+
.dpt-rel { color: #9ca3af; font-size: 12px; }
|
|
63880
63915
|
.dpt-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
|
63881
63916
|
.dpt-empty { padding: 16px 0; text-align: center; color: #9ca3af; font-size: 13px; }
|
|
63882
63917
|
.dpt-icon-btn {
|
|
@@ -65725,6 +65760,204 @@ function createTicketsTab(config2) {
|
|
|
65725
65760
|
return { destroy: () => tab.destroy() };
|
|
65726
65761
|
}
|
|
65727
65762
|
|
|
65763
|
+
// src/components/premium-modals/settings/myio-ops/DeviceOpsTabs.ts
|
|
65764
|
+
var WO_TYPE_LABELS = {
|
|
65765
|
+
INSTALACAO: "Instala\xE7\xE3o",
|
|
65766
|
+
MANUTENCAO: "Manuten\xE7\xE3o",
|
|
65767
|
+
VISITA_TECNICA: "Visita t\xE9cnica",
|
|
65768
|
+
IMPLANTACAO: "Implanta\xE7\xE3o",
|
|
65769
|
+
RETIRADA: "Retirada",
|
|
65770
|
+
CHAMADO: "Chamado",
|
|
65771
|
+
GRUPO: "Grupo de OS"
|
|
65772
|
+
};
|
|
65773
|
+
var WO_STATUS_LABELS = {
|
|
65774
|
+
PLANEJADA: "Planejada",
|
|
65775
|
+
EM_ANDAMENTO: "Em andamento",
|
|
65776
|
+
INTERROMPIDA: "Interrompida",
|
|
65777
|
+
AGUARDANDO: "Aguardando",
|
|
65778
|
+
REAGENDADA: "Reagendada",
|
|
65779
|
+
FINALIZADA: "Finalizada",
|
|
65780
|
+
CANCELADA: "Cancelada"
|
|
65781
|
+
};
|
|
65782
|
+
var INCIDENT_STATUS_LABELS = {
|
|
65783
|
+
OPEN: "Aberto",
|
|
65784
|
+
ACK: "Reconhecido",
|
|
65785
|
+
ACKNOWLEDGED: "Reconhecido",
|
|
65786
|
+
RESOLVED: "Resolvido",
|
|
65787
|
+
CLOSED: "Fechado"
|
|
65788
|
+
};
|
|
65789
|
+
var SEVERITY_COLORS = {
|
|
65790
|
+
CRITICAL: "#dc2626",
|
|
65791
|
+
HIGH: "#f59e0b",
|
|
65792
|
+
MEDIUM: "#3b82f6",
|
|
65793
|
+
LOW: "#6b7280",
|
|
65794
|
+
INFO: "#6b7280"
|
|
65795
|
+
};
|
|
65796
|
+
var STYLES_ID4 = "myio-dops-styles";
|
|
65797
|
+
function esc5(value) {
|
|
65798
|
+
return String(value ?? "").replace(
|
|
65799
|
+
/[&<>"']/g,
|
|
65800
|
+
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]
|
|
65801
|
+
);
|
|
65802
|
+
}
|
|
65803
|
+
function fmtDate(value) {
|
|
65804
|
+
if (!value) return "\u2014";
|
|
65805
|
+
const d = new Date(value);
|
|
65806
|
+
return Number.isNaN(d.getTime()) ? esc5(value) : d.toLocaleString("pt-BR", { dateStyle: "short", timeStyle: "short" });
|
|
65807
|
+
}
|
|
65808
|
+
function resolveApi(config2) {
|
|
65809
|
+
const orch = globalThis.window?.MyIOOrchestrator || {};
|
|
65810
|
+
const apiKey = config2.gcdrApiKey ?? orch.gcdrApiKey ?? "";
|
|
65811
|
+
const tenantId = config2.gcdrTenantId ?? orch.gcdrTenantId ?? "";
|
|
65812
|
+
const headers = { Accept: "application/json", "X-API-Key": apiKey };
|
|
65813
|
+
if (tenantId) headers["X-Tenant-ID"] = tenantId;
|
|
65814
|
+
return {
|
|
65815
|
+
gcdrDeviceId: String(config2.gcdrDeviceId || ""),
|
|
65816
|
+
identifier: String(config2.identifier || ""),
|
|
65817
|
+
gcdrRoot: String(config2.gcdrApiBaseUrl ?? orch.gcdrApiBaseUrl ?? "https://gcdr-api.a.myio-bas.com").replace(/\/+$/, "").replace(/\/api\/v1$/, ""),
|
|
65818
|
+
alarmsBase: String(config2.alarmsApiBaseUrl ?? orch.alarmsApiBaseUrl ?? "https://alarms-api.a.myio-bas.com/api/v1").replace(
|
|
65819
|
+
/\/+$/,
|
|
65820
|
+
""
|
|
65821
|
+
),
|
|
65822
|
+
headers
|
|
65823
|
+
};
|
|
65824
|
+
}
|
|
65825
|
+
async function fetchDeviceWorkOrders(config2) {
|
|
65826
|
+
const api = resolveApi(config2);
|
|
65827
|
+
if (!api.gcdrDeviceId) return [];
|
|
65828
|
+
const url = `${api.gcdrRoot}/api/v1/wo/work-orders?deviceId=${encodeURIComponent(api.gcdrDeviceId)}&limit=100`;
|
|
65829
|
+
const res = await fetch(url, { headers: api.headers });
|
|
65830
|
+
if (!res.ok) throw Object.assign(new Error(`GCDR work-orders HTTP ${res.status}`), { status: res.status });
|
|
65831
|
+
const body = await res.json();
|
|
65832
|
+
const data = body?.data ?? body;
|
|
65833
|
+
const items = Array.isArray(data) ? data : Array.isArray(data?.items) ? data.items : [];
|
|
65834
|
+
return items;
|
|
65835
|
+
}
|
|
65836
|
+
async function fetchDeviceIncidents(config2) {
|
|
65837
|
+
const api = resolveApi(config2);
|
|
65838
|
+
if (!api.gcdrDeviceId) return [];
|
|
65839
|
+
const url = `${api.alarmsBase}/incidents?device=${encodeURIComponent(api.gcdrDeviceId)}&sortBy=firstDetectedAt&sortDir=desc&limit=100`;
|
|
65840
|
+
const res = await fetch(url, { headers: api.headers });
|
|
65841
|
+
if (!res.ok) throw Object.assign(new Error(`Alarms incidents HTTP ${res.status}`), { status: res.status });
|
|
65842
|
+
const body = await res.json();
|
|
65843
|
+
return Array.isArray(body?.data) ? body.data : [];
|
|
65844
|
+
}
|
|
65845
|
+
function countDeviceFreshdeskTickets(identifier) {
|
|
65846
|
+
const tso = globalThis.window?.TicketServiceOrchestrator;
|
|
65847
|
+
if (!identifier || typeof tso?.getTicketCountForDevice !== "function") return 0;
|
|
65848
|
+
return Number(tso.getTicketCountForDevice(identifier)) || 0;
|
|
65849
|
+
}
|
|
65850
|
+
function injectStyles9() {
|
|
65851
|
+
if (document.getElementById(STYLES_ID4)) return;
|
|
65852
|
+
const style = document.createElement("style");
|
|
65853
|
+
style.id = STYLES_ID4;
|
|
65854
|
+
style.textContent = `
|
|
65855
|
+
.dops-tab { padding: 4px 2px 20px; font-family: 'Nunito', system-ui, sans-serif; }
|
|
65856
|
+
.dops-notice { background:#f1ecfa; color:#3e1a7d; border-radius:8px; padding:8px 12px; font-size:12px; margin-bottom:14px; }
|
|
65857
|
+
.dops-state { padding:28px 16px; text-align:center; color:#6b7280; font-size:13px; }
|
|
65858
|
+
.dops-error { color:#b91c1c; }
|
|
65859
|
+
.dops-summary { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:12px; }
|
|
65860
|
+
.dops-kpi { border:1px solid #e5e7eb; border-radius:8px; padding:8px 12px; min-width:110px; background:#fff; }
|
|
65861
|
+
.dops-kpi b { display:block; font-size:18px; color:#111827; }
|
|
65862
|
+
.dops-kpi span { font-size:11px; color:#6b7280; text-transform:uppercase; letter-spacing:.4px; }
|
|
65863
|
+
.dops-table { width:100%; border-collapse:collapse; font-size:12px; background:#fff; border:1px solid #e5e7eb; border-radius:8px; overflow:hidden; }
|
|
65864
|
+
.dops-table th { text-align:left; background:#f9fafb; color:#6b7280; font-weight:700; padding:8px 10px; border-bottom:1px solid #e5e7eb; white-space:nowrap; }
|
|
65865
|
+
.dops-table td { padding:8px 10px; border-bottom:1px solid #f1f5f9; color:#111827; vertical-align:top; }
|
|
65866
|
+
.dops-table tr:last-child td { border-bottom:none; }
|
|
65867
|
+
.dops-chip { display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; font-weight:700; background:#f3f4f6; color:#374151; white-space:nowrap; }
|
|
65868
|
+
.dops-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
65869
|
+
.dops-muted { color:#9ca3af; }
|
|
65870
|
+
.theme-dark .dops-table, .theme-dark .dops-kpi { background:#111827; border-color:#374151; }
|
|
65871
|
+
.theme-dark .dops-table th { background:#1f2937; color:#9ca3af; border-color:#374151; }
|
|
65872
|
+
.theme-dark .dops-table td { color:#e5e7eb; border-color:#1f2937; }
|
|
65873
|
+
.theme-dark .dops-kpi b { color:#e5e7eb; }
|
|
65874
|
+
`;
|
|
65875
|
+
document.head.appendChild(style);
|
|
65876
|
+
}
|
|
65877
|
+
function noDeviceHTML(what) {
|
|
65878
|
+
return `<div class="dops-state">${what} indispon\xEDveis: o dispositivo n\xE3o tem <code>gcdrDeviceId</code>.</div>`;
|
|
65879
|
+
}
|
|
65880
|
+
async function renderDeviceWorkOrdersTab(container, config2) {
|
|
65881
|
+
injectStyles9();
|
|
65882
|
+
const tickets = countDeviceFreshdeskTickets(config2.identifier);
|
|
65883
|
+
if (!config2.gcdrDeviceId) {
|
|
65884
|
+
container.innerHTML = `<div class="dops-tab">${noDeviceHTML("OSs")}</div>`;
|
|
65885
|
+
return tickets;
|
|
65886
|
+
}
|
|
65887
|
+
container.innerHTML = `<div class="dops-tab"><div class="dops-state">Carregando ordens de servi\xE7o\u2026</div></div>`;
|
|
65888
|
+
let orders = [];
|
|
65889
|
+
let errorHtml = "";
|
|
65890
|
+
try {
|
|
65891
|
+
orders = await fetchDeviceWorkOrders(config2);
|
|
65892
|
+
} catch (e) {
|
|
65893
|
+
errorHtml = e?.status === 401 || e?.status === 403 ? "O GCDR ainda n\xE3o libera a leitura de OSs com a chave do customer (as rotas /wo/work-orders exigem login de usu\xE1rio GCDR)." : `Erro ao carregar OSs: ${esc5(e?.message || e)}`;
|
|
65894
|
+
}
|
|
65895
|
+
const open = orders.filter((o) => !["FINALIZADA", "CANCELADA"].includes(String(o.status))).length;
|
|
65896
|
+
const rows = orders.slice().sort((a, b) => String(b.createdAt || "").localeCompare(String(a.createdAt || ""))).map(
|
|
65897
|
+
(o) => `<tr>
|
|
65898
|
+
<td class="dops-mono">${esc5(o.code || o.id)}</td>
|
|
65899
|
+
<td>${esc5(o.title || "\u2014")}</td>
|
|
65900
|
+
<td>${esc5(WO_TYPE_LABELS[String(o.type)] || o.type || "\u2014")}</td>
|
|
65901
|
+
<td><span class="dops-chip">${esc5(WO_STATUS_LABELS[String(o.status)] || o.status || "\u2014")}</span></td>
|
|
65902
|
+
<td>${esc5(o.assignedTo || "\u2014")}</td>
|
|
65903
|
+
<td>${fmtDate(o.scheduledAt)}</td>
|
|
65904
|
+
<td>${fmtDate(o.createdAt)}</td>
|
|
65905
|
+
</tr>`
|
|
65906
|
+
).join("");
|
|
65907
|
+
container.innerHTML = `
|
|
65908
|
+
<div class="dops-tab">
|
|
65909
|
+
<div class="dops-notice">\u{1F512} Vis\xEDvel s\xF3 para usu\xE1rios MyIO. A contagem da aba soma OSs e chamados (FreshDesk) do dispositivo.</div>
|
|
65910
|
+
<div class="dops-summary">
|
|
65911
|
+
<div class="dops-kpi"><b>${errorHtml ? "\u2014" : orders.length}</b><span>OSs</span></div>
|
|
65912
|
+
<div class="dops-kpi"><b>${errorHtml ? "\u2014" : open}</b><span>OSs em aberto</span></div>
|
|
65913
|
+
<div class="dops-kpi"><b>${tickets}</b><span>Chamados</span></div>
|
|
65914
|
+
</div>
|
|
65915
|
+
${errorHtml ? `<div class="dops-state dops-error">${errorHtml}</div>` : orders.length ? `<table class="dops-table"><thead><tr><th>C\xF3digo</th><th>T\xEDtulo</th><th>Tipo</th><th>Status</th><th>Respons\xE1vel</th><th>Agendada</th><th>Criada</th></tr></thead><tbody>${rows}</tbody></table>` : `<div class="dops-state">Nenhuma OS para este dispositivo.</div>`}
|
|
65916
|
+
</div>`;
|
|
65917
|
+
return (errorHtml ? 0 : orders.length) + tickets;
|
|
65918
|
+
}
|
|
65919
|
+
async function renderDeviceIncidentsTab(container, config2) {
|
|
65920
|
+
injectStyles9();
|
|
65921
|
+
if (!config2.gcdrDeviceId) {
|
|
65922
|
+
container.innerHTML = `<div class="dops-tab">${noDeviceHTML("Incidentes")}</div>`;
|
|
65923
|
+
return 0;
|
|
65924
|
+
}
|
|
65925
|
+
container.innerHTML = `<div class="dops-tab"><div class="dops-state">Carregando incidentes\u2026</div></div>`;
|
|
65926
|
+
let incidents = [];
|
|
65927
|
+
try {
|
|
65928
|
+
incidents = await fetchDeviceIncidents(config2);
|
|
65929
|
+
} catch (e) {
|
|
65930
|
+
container.innerHTML = `<div class="dops-tab"><div class="dops-state dops-error">Erro ao carregar incidentes: ${esc5(
|
|
65931
|
+
e?.message || e
|
|
65932
|
+
)}</div></div>`;
|
|
65933
|
+
return 0;
|
|
65934
|
+
}
|
|
65935
|
+
const active = incidents.filter((i) => !["RESOLVED", "CLOSED"].includes(String(i.status))).length;
|
|
65936
|
+
const rows = incidents.map((i) => {
|
|
65937
|
+
const sev = String(i.severity || "");
|
|
65938
|
+
return `<tr>
|
|
65939
|
+
<td><span class="dops-chip" style="background:${SEVERITY_COLORS[sev] || "#6b7280"};color:#fff">${esc5(sev || "\u2014")}</span></td>
|
|
65940
|
+
<td>${esc5(i.kind || "\u2014")}</td>
|
|
65941
|
+
<td><span class="dops-chip">${esc5(INCIDENT_STATUS_LABELS[String(i.status)] || i.status || "\u2014")}</span></td>
|
|
65942
|
+
<td>${esc5(i.day || "\u2014")}</td>
|
|
65943
|
+
<td>${esc5(i.centralName || "\u2014")}</td>
|
|
65944
|
+
<td>${fmtDate(i.firstDetectedAt)}</td>
|
|
65945
|
+
<td>${fmtDate(i.lastEvaluatedAt)}</td>
|
|
65946
|
+
<td class="dops-muted">${esc5(i.description || "")}</td>
|
|
65947
|
+
</tr>`;
|
|
65948
|
+
}).join("");
|
|
65949
|
+
container.innerHTML = `
|
|
65950
|
+
<div class="dops-tab">
|
|
65951
|
+
<div class="dops-notice">\u{1F512} Vis\xEDvel s\xF3 para usu\xE1rios MyIO. Incidentes do alarms-backend que envolvem este dispositivo.</div>
|
|
65952
|
+
<div class="dops-summary">
|
|
65953
|
+
<div class="dops-kpi"><b>${incidents.length}</b><span>Incidentes</span></div>
|
|
65954
|
+
<div class="dops-kpi"><b>${active}</b><span>N\xE3o resolvidos</span></div>
|
|
65955
|
+
</div>
|
|
65956
|
+
${incidents.length ? `<table class="dops-table"><thead><tr><th>Severidade</th><th>Tipo</th><th>Status</th><th>Dia</th><th>Central</th><th>Detectado</th><th>\xDAltima avalia\xE7\xE3o</th><th>Descri\xE7\xE3o</th></tr></thead><tbody>${rows}</tbody></table>` : `<div class="dops-state">Nenhum incidente para este dispositivo.</div>`}
|
|
65957
|
+
</div>`;
|
|
65958
|
+
return active;
|
|
65959
|
+
}
|
|
65960
|
+
|
|
65728
65961
|
// src/components/premium-modals/settings/commercialCatalog.ts
|
|
65729
65962
|
var DEFAULT_STORE_SEGMENTS = [
|
|
65730
65963
|
{
|
|
@@ -66024,7 +66257,7 @@ async function createInputDateRangePickerInsideDIV(params) {
|
|
|
66024
66257
|
placeholder = "Clique para selecionar per\xEDodo",
|
|
66025
66258
|
pickerOptions = {},
|
|
66026
66259
|
classNames = {},
|
|
66027
|
-
injectStyles:
|
|
66260
|
+
injectStyles: injectStyles27 = true,
|
|
66028
66261
|
showHelper = true
|
|
66029
66262
|
} = params;
|
|
66030
66263
|
validateId(containerId, "containerId");
|
|
@@ -66033,7 +66266,7 @@ async function createInputDateRangePickerInsideDIV(params) {
|
|
|
66033
66266
|
if (!container) {
|
|
66034
66267
|
throw new Error(`[createInputDateRangePickerInsideDIV] Container '#${containerId}' not found`);
|
|
66035
66268
|
}
|
|
66036
|
-
if (
|
|
66269
|
+
if (injectStyles27) {
|
|
66037
66270
|
injectPremiumStyles();
|
|
66038
66271
|
}
|
|
66039
66272
|
let inputEl = document.getElementById(inputId);
|
|
@@ -66213,6 +66446,33 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66213
66446
|
const email = userEmail.toLowerCase().trim();
|
|
66214
66447
|
return email.endsWith(ALLOWED_EMAIL_DOMAIN.toLowerCase());
|
|
66215
66448
|
}
|
|
66449
|
+
/** Usuário @myio.com.br (só pelo e-mail — o flag superadmin não basta). Gate das abas OSs/Incidentes. */
|
|
66450
|
+
isMyioUser() {
|
|
66451
|
+
const email = String(this.config.userEmail || "").toLowerCase().trim();
|
|
66452
|
+
return !!email && email.endsWith(ALLOWED_EMAIL_DOMAIN.toLowerCase());
|
|
66453
|
+
}
|
|
66454
|
+
/** Abas OSs + Incidentes do dispositivo (GCDR work-orders / alarms-backend incidents). */
|
|
66455
|
+
initDeviceOpsTabs() {
|
|
66456
|
+
const cfg = {
|
|
66457
|
+
gcdrDeviceId: this.config.gcdrDeviceId,
|
|
66458
|
+
identifier: this.config.identifier,
|
|
66459
|
+
gcdrApiBaseUrl: this.config.gcdrApiBaseUrl
|
|
66460
|
+
};
|
|
66461
|
+
const setBadge = (id, n) => {
|
|
66462
|
+
const el2 = this.modal.querySelector(`#${id}`);
|
|
66463
|
+
if (!el2) return;
|
|
66464
|
+
el2.textContent = n > 99 ? "99+" : String(n);
|
|
66465
|
+
el2.style.display = n > 0 ? "" : "none";
|
|
66466
|
+
};
|
|
66467
|
+
const osEl = this.modal.querySelector("#device-os-tab-content");
|
|
66468
|
+
if (osEl) {
|
|
66469
|
+
renderDeviceWorkOrdersTab(osEl, cfg).then((n) => setBadge("tab-badge-device-os", n)).catch((e) => console.warn("[SettingsModalView] OSs tab:", e));
|
|
66470
|
+
}
|
|
66471
|
+
const incEl = this.modal.querySelector("#device-incidents-tab-content");
|
|
66472
|
+
if (incEl) {
|
|
66473
|
+
renderDeviceIncidentsTab(incEl, cfg).then((n) => setBadge("tab-badge-device-incidents", n)).catch((e) => console.warn("[SettingsModalView] Incidentes tab:", e));
|
|
66474
|
+
}
|
|
66475
|
+
}
|
|
66216
66476
|
/**
|
|
66217
66477
|
* Check if the user may edit the "Identificador" field.
|
|
66218
66478
|
* True when isSuperAdmin() OR the caller already resolved the user as a
|
|
@@ -66282,6 +66542,9 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66282
66542
|
this.bindIncidentsTabEvents();
|
|
66283
66543
|
this.initIncidentsDateRange();
|
|
66284
66544
|
}
|
|
66545
|
+
if (this.isMyioUser()) {
|
|
66546
|
+
this.initDeviceOpsTabs();
|
|
66547
|
+
}
|
|
66285
66548
|
this._updateTabBadges(initialData);
|
|
66286
66549
|
}
|
|
66287
66550
|
// RFC-0104: Initialize the Annotations Tab
|
|
@@ -66603,6 +66866,10 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66603
66866
|
if (retrolavagemContent) retrolavagemContent.style.display = tab === "retrolavagem" ? "block" : "none";
|
|
66604
66867
|
if (exclusionGroupsContent) exclusionGroupsContent.style.display = tab === "exclusion-groups" ? "block" : "none";
|
|
66605
66868
|
if (incidentsContent) incidentsContent.style.display = tab === "incidents" ? "block" : "none";
|
|
66869
|
+
const deviceOsContent = this.modal.querySelector("#device-os-tab-content");
|
|
66870
|
+
const deviceIncidentsContent = this.modal.querySelector("#device-incidents-tab-content");
|
|
66871
|
+
if (deviceOsContent) deviceOsContent.style.display = tab === "device-os" ? "block" : "none";
|
|
66872
|
+
if (deviceIncidentsContent) deviceIncidentsContent.style.display = tab === "device-incidents" ? "block" : "none";
|
|
66606
66873
|
const saveBtn = this.modal.querySelector(".btn-save");
|
|
66607
66874
|
if (saveBtn) saveBtn.style.display = tab === "general" ? "inline-flex" : "none";
|
|
66608
66875
|
if (tab === "annotations" && this.annotationsTab) {
|
|
@@ -66742,12 +67009,63 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66742
67009
|
data[key] = num;
|
|
66743
67010
|
}
|
|
66744
67011
|
} else if (value.trim()) {
|
|
66745
|
-
data[key] = value.trim();
|
|
67012
|
+
data[key] = key === "label" ? this.labelCase(value.trim()) : value.trim();
|
|
66746
67013
|
}
|
|
66747
67014
|
}
|
|
66748
67015
|
}
|
|
66749
67016
|
return data;
|
|
66750
67017
|
}
|
|
67018
|
+
/** Copia texto para a área de transferência (Clipboard API; fallback execCommand fora de HTTPS). */
|
|
67019
|
+
static async copyText(text2) {
|
|
67020
|
+
if (!text2) return false;
|
|
67021
|
+
try {
|
|
67022
|
+
if (navigator.clipboard?.writeText) {
|
|
67023
|
+
await navigator.clipboard.writeText(text2);
|
|
67024
|
+
return true;
|
|
67025
|
+
}
|
|
67026
|
+
} catch {
|
|
67027
|
+
}
|
|
67028
|
+
try {
|
|
67029
|
+
const ta = document.createElement("textarea");
|
|
67030
|
+
ta.value = text2;
|
|
67031
|
+
ta.setAttribute("readonly", "");
|
|
67032
|
+
ta.style.cssText = "position:fixed;left:-9999px;top:0;opacity:0";
|
|
67033
|
+
document.body.appendChild(ta);
|
|
67034
|
+
ta.select();
|
|
67035
|
+
const ok = document.execCommand("copy");
|
|
67036
|
+
ta.remove();
|
|
67037
|
+
return ok;
|
|
67038
|
+
} catch {
|
|
67039
|
+
return false;
|
|
67040
|
+
}
|
|
67041
|
+
}
|
|
67042
|
+
/** Etiqueta (label) do device sempre em maiúsculas — exibição, digitação, colagem e gravação. */
|
|
67043
|
+
static toLabelCase(value) {
|
|
67044
|
+
return String(value ?? "").toLocaleUpperCase("pt-BR");
|
|
67045
|
+
}
|
|
67046
|
+
/** Etiqueta do modal: maiúsculas para dispositivos; centrais (isGateway) mantêm o nome como está. */
|
|
67047
|
+
labelCase(value) {
|
|
67048
|
+
return this.config.isGateway ? String(value ?? "") : _SettingsModalView.toLabelCase(value);
|
|
67049
|
+
}
|
|
67050
|
+
/**
|
|
67051
|
+
* Input "Etiqueta": converte para maiúsculas enquanto digita/cola (preservando o cursor) e
|
|
67052
|
+
* espelha o valor no título ao lado do ícone.
|
|
67053
|
+
*/
|
|
67054
|
+
bindLabelUppercase() {
|
|
67055
|
+
const input = this.form?.querySelector("#label");
|
|
67056
|
+
if (!input || input.dataset.upperBound) return;
|
|
67057
|
+
input.dataset.upperBound = "true";
|
|
67058
|
+
const nameText = this.modal.querySelector(".identity-name-text");
|
|
67059
|
+
input.addEventListener("input", () => {
|
|
67060
|
+
const upper = this.labelCase(input.value);
|
|
67061
|
+
if (upper !== input.value) {
|
|
67062
|
+
const { selectionStart, selectionEnd } = input;
|
|
67063
|
+
input.value = upper;
|
|
67064
|
+
if (selectionStart !== null && selectionEnd !== null) input.setSelectionRange(selectionStart, selectionEnd);
|
|
67065
|
+
}
|
|
67066
|
+
if (nameText) nameText.textContent = input.value.trim() || "\u2014";
|
|
67067
|
+
});
|
|
67068
|
+
}
|
|
66751
67069
|
createModal() {
|
|
66752
67070
|
this.container = document.createElement("div");
|
|
66753
67071
|
this.container.className = "myio-device-settings-overlay";
|
|
@@ -66816,7 +67134,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66816
67134
|
<line x1="3" y1="9" x2="21" y2="9"></line>
|
|
66817
67135
|
<line x1="9" y1="21" x2="9" y2="9"></line>
|
|
66818
67136
|
</svg>
|
|
66819
|
-
Perfil
|
|
67137
|
+
Perfil Disp.
|
|
66820
67138
|
</button>` : ""}
|
|
66821
67139
|
${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="well-equipment">
|
|
66822
67140
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -66833,14 +67151,31 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66833
67151
|
</svg>
|
|
66834
67152
|
Equipamentos da Retrolavagem
|
|
66835
67153
|
</button>` : ""}
|
|
66836
|
-
<!--
|
|
66837
|
-
${this.
|
|
67154
|
+
<!-- OSs + Incidentes do dispositivo \u2014 s\xF3 @myio.com.br -->
|
|
67155
|
+
${this.isMyioUser() ? `<button type="button" class="modal-tab" data-tab="device-os">
|
|
67156
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
67157
|
+
<path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.5 2.5-2.4-.6-.6-2.4z"></path>
|
|
67158
|
+
</svg>
|
|
67159
|
+
OSs
|
|
67160
|
+
<span class="modal-tab-badge modal-tab-badge--os" id="tab-badge-device-os" style="display:none"></span>
|
|
67161
|
+
</button>
|
|
67162
|
+
<button type="button" class="modal-tab" data-tab="device-incidents">
|
|
66838
67163
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
66839
67164
|
<path d="M12 9v4"></path>
|
|
66840
67165
|
<path d="M12 17h.01"></path>
|
|
66841
67166
|
<path d="M10.29 3.86l-8.18 14.14A2 2 0 0 0 3.93 21h16.14a2 2 0 0 0 1.82-2.99L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
|
|
66842
67167
|
</svg>
|
|
66843
67168
|
Incidentes
|
|
67169
|
+
<span class="modal-tab-badge modal-tab-badge--incidents" id="tab-badge-device-incidents" style="display:none"></span>
|
|
67170
|
+
</button>` : ""}
|
|
67171
|
+
<!-- RFC-0232: Interpola\xE7\xF5es (antes "Incidentes") \u2014 central + admin MyIO only -->
|
|
67172
|
+
${this.config.isGateway && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="incidents">
|
|
67173
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
67174
|
+
<path d="M12 9v4"></path>
|
|
67175
|
+
<path d="M12 17h.01"></path>
|
|
67176
|
+
<path d="M10.29 3.86l-8.18 14.14A2 2 0 0 0 3.93 21h16.14a2 2 0 0 0 1.82-2.99L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
|
|
67177
|
+
</svg>
|
|
67178
|
+
Interpola\xE7\xF5es
|
|
66844
67179
|
${(this.config.interpolatedSlots?.length ?? 0) > 0 ? `<span class="modal-tab-badge modal-tab-badge--incidents">${this.config.interpolatedSlots.length}</span>` : ""}
|
|
66845
67180
|
</button>` : ""}
|
|
66846
67181
|
</div>
|
|
@@ -66897,6 +67232,8 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66897
67232
|
Rendered synchronously (data comes pre-fetched via config.interpolatedSlots,
|
|
66898
67233
|
same as getGatewayInfoHTML() \u2014 no async loading state needed here). -->
|
|
66899
67234
|
${this.config.isGateway && this.isSuperAdmin() ? `<div id="incidents-tab-content" class="tab-content" style="display: none;">${this.getInterpolationIncidentsHTML()}</div>` : ""}
|
|
67235
|
+
${this.isMyioUser() ? `<div id="device-os-tab-content" class="tab-content" style="display: none;"></div>
|
|
67236
|
+
<div id="device-incidents-tab-content" class="tab-content" style="display: none;"></div>` : ""}
|
|
66900
67237
|
</div>
|
|
66901
67238
|
<div class="modal-footer">
|
|
66902
67239
|
<button type="button" class="btn-cancel">Fechar</button>
|
|
@@ -66938,8 +67275,13 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66938
67275
|
<!-- Col 1, rows 1-6: single wrapper \u2192 borda cont\xEDnua -->
|
|
66939
67276
|
<div class="identity-col1">
|
|
66940
67277
|
<div class="identity-name-block">
|
|
66941
|
-
<div class="identity-name-text">${this.config.deviceLabel || "\u2014"}</div>
|
|
66942
|
-
|
|
67278
|
+
<div class="identity-name-text">${this.labelCase(this.config.deviceLabel) || "\u2014"}</div>
|
|
67279
|
+
${this.config.deviceName ? `<div class="device-name-row">
|
|
67280
|
+
<div class="device-name-subtitle">${this.config.deviceName}</div>
|
|
67281
|
+
<button type="button" class="device-name-copy" id="btnCopyDeviceName" title="Copiar nome do dispositivo" aria-label="Copiar nome do dispositivo">
|
|
67282
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
|
|
67283
|
+
</button>
|
|
67284
|
+
</div>` : ""}
|
|
66943
67285
|
</div>
|
|
66944
67286
|
<div class="identity-icon-cell">
|
|
66945
67287
|
${this.getDeviceImage(deviceType)}
|
|
@@ -67042,8 +67384,8 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
67042
67384
|
const segmentEl = this.modal.querySelector("#segment");
|
|
67043
67385
|
const activityEl = this.modal.querySelector("#activity");
|
|
67044
67386
|
if (!segmentEl || !activityEl) return;
|
|
67045
|
-
const
|
|
67046
|
-
const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${
|
|
67387
|
+
const esc12 = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
67388
|
+
const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc12(v)}"${v === selected ? " selected" : ""}>${esc12(v)}</option>`).join("");
|
|
67047
67389
|
const catalog = await loadStoreSegmentCatalog(this.config.segmentCatalog);
|
|
67048
67390
|
const savedSegment = String(saved.segment || "");
|
|
67049
67391
|
const savedActivity = String(saved.activity || "");
|
|
@@ -68232,6 +68574,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
68232
68574
|
.modal-tab-badge--chamados { background: #0891b2; }
|
|
68233
68575
|
.modal-tab-badge--exclusion { background: #d97706; }
|
|
68234
68576
|
.modal-tab-badge--incidents { background: #7C3AED; }
|
|
68577
|
+
.modal-tab-badge--os { background: #0891b2; }
|
|
68235
68578
|
|
|
68236
68579
|
.tab-content {
|
|
68237
68580
|
min-height: 400px;
|
|
@@ -68845,6 +69188,40 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
68845
69188
|
display: none;
|
|
68846
69189
|
}
|
|
68847
69190
|
|
|
69191
|
+
/* device.name + bot\xE3o copiar */
|
|
69192
|
+
.device-name-row {
|
|
69193
|
+
display: flex;
|
|
69194
|
+
align-items: center;
|
|
69195
|
+
gap: 4px;
|
|
69196
|
+
min-width: 0;
|
|
69197
|
+
margin-top: 2px;
|
|
69198
|
+
}
|
|
69199
|
+
.device-name-row .device-name-subtitle {
|
|
69200
|
+
margin-top: 0;
|
|
69201
|
+
min-width: 0;
|
|
69202
|
+
}
|
|
69203
|
+
.device-name-copy {
|
|
69204
|
+
flex: none;
|
|
69205
|
+
display: inline-flex;
|
|
69206
|
+
align-items: center;
|
|
69207
|
+
justify-content: center;
|
|
69208
|
+
width: 20px;
|
|
69209
|
+
height: 20px;
|
|
69210
|
+
padding: 0;
|
|
69211
|
+
border: none;
|
|
69212
|
+
border-radius: 4px;
|
|
69213
|
+
background: transparent;
|
|
69214
|
+
color: #9ca3af;
|
|
69215
|
+
cursor: pointer;
|
|
69216
|
+
}
|
|
69217
|
+
.device-name-copy:hover {
|
|
69218
|
+
background: #f3f4f6;
|
|
69219
|
+
color: #3e1a7d;
|
|
69220
|
+
}
|
|
69221
|
+
.device-name-copy.is-copied {
|
|
69222
|
+
color: #15803d;
|
|
69223
|
+
}
|
|
69224
|
+
|
|
68848
69225
|
.section-title {
|
|
68849
69226
|
margin: 0 0 20px 0;
|
|
68850
69227
|
font-size: 16px;
|
|
@@ -69944,7 +70321,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
69944
70321
|
for (const [key, value] of Object.entries(data)) {
|
|
69945
70322
|
const input = this.form.querySelector(`[name="${key}"]`);
|
|
69946
70323
|
if (input && value !== void 0 && value !== null) {
|
|
69947
|
-
input.value = String(value);
|
|
70324
|
+
input.value = key === "label" ? this.labelCase(value) : String(value);
|
|
69948
70325
|
}
|
|
69949
70326
|
}
|
|
69950
70327
|
}
|
|
@@ -70040,6 +70417,20 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
70040
70417
|
this.switchTab("alarms");
|
|
70041
70418
|
}
|
|
70042
70419
|
});
|
|
70420
|
+
this.bindLabelUppercase();
|
|
70421
|
+
const btnCopyName = this.modal.querySelector("#btnCopyDeviceName");
|
|
70422
|
+
btnCopyName?.addEventListener("click", async (e) => {
|
|
70423
|
+
e.preventDefault();
|
|
70424
|
+
e.stopPropagation();
|
|
70425
|
+
const ok = await _SettingsModalView.copyText(String(this.config.deviceName || ""));
|
|
70426
|
+
if (!ok) return;
|
|
70427
|
+
btnCopyName.classList.add("is-copied");
|
|
70428
|
+
btnCopyName.title = "Copiado!";
|
|
70429
|
+
setTimeout(() => {
|
|
70430
|
+
btnCopyName.classList.remove("is-copied");
|
|
70431
|
+
btnCopyName.title = "Copiar nome do dispositivo";
|
|
70432
|
+
}, 1500);
|
|
70433
|
+
});
|
|
70043
70434
|
this.form.addEventListener("submit", (event) => {
|
|
70044
70435
|
event.preventDefault();
|
|
70045
70436
|
this.hideError();
|
|
@@ -70508,7 +70899,7 @@ function connectivityFieldsetHtml(data, l, language, errors) {
|
|
|
70508
70899
|
`;
|
|
70509
70900
|
}
|
|
70510
70901
|
var STYLE_ID5 = "myio-central-settings-modal-styles";
|
|
70511
|
-
function
|
|
70902
|
+
function injectStyles10() {
|
|
70512
70903
|
if (typeof document === "undefined" || document.getElementById(STYLE_ID5)) return;
|
|
70513
70904
|
const tag = document.createElement("style");
|
|
70514
70905
|
tag.id = STYLE_ID5;
|
|
@@ -70586,7 +70977,7 @@ var CentralSettingsModal = class extends SettingsModalView {
|
|
|
70586
70977
|
this.csLanguage = language;
|
|
70587
70978
|
this.csLabels = l;
|
|
70588
70979
|
this.csCurrentData = initialData;
|
|
70589
|
-
|
|
70980
|
+
injectStyles10();
|
|
70590
70981
|
config2.onSave = (formData) => this.handleCentralSave(formData);
|
|
70591
70982
|
config2.onClose = () => {
|
|
70592
70983
|
this.close();
|
|
@@ -73532,7 +73923,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73532
73923
|
if (this.metaTipEl) this.metaTipEl.style.display = "none";
|
|
73533
73924
|
}
|
|
73534
73925
|
buildMetaTipHtml(type, card) {
|
|
73535
|
-
const
|
|
73926
|
+
const esc12 = _WelcomeModalView.escapeMetaHtml;
|
|
73536
73927
|
const chip = _WelcomeModalView.metaChip;
|
|
73537
73928
|
const meta = card.metaCounts || {};
|
|
73538
73929
|
const details = card.metaDetails || {};
|
|
@@ -73542,7 +73933,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73542
73933
|
).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
|
|
73543
73934
|
const frame = (icon2, label, body) => `<div class="myio-welcome-meta-tip__header">
|
|
73544
73935
|
<span class="myio-welcome-meta-tip__icon">${icon2}</span>
|
|
73545
|
-
<span class="myio-welcome-meta-tip__title">${label} (${
|
|
73936
|
+
<span class="myio-welcome-meta-tip__title">${label} (${esc12(card.title)})</span>
|
|
73546
73937
|
<span class="myio-welcome-meta-tip__timestamp">${stamp}</span>
|
|
73547
73938
|
<button type="button" class="myio-welcome-meta-tip__close" title="Fechar">\u2715</button>
|
|
73548
73939
|
</div>
|
|
@@ -73570,8 +73961,8 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73570
73961
|
const chips = Object.entries(byState).map(([s, n]) => chip(`${s}: ${n}`)).join("");
|
|
73571
73962
|
const rows = alarms.slice(0, 10).map(
|
|
73572
73963
|
(a) => row(
|
|
73573
|
-
|
|
73574
|
-
[a.severity, a.state].filter(Boolean).map(
|
|
73964
|
+
esc12(a.deviceName ? `${a.deviceName} \u2014 ${a.title || "Alarme"}` : a.title || "Alarme"),
|
|
73965
|
+
[a.severity, a.state].filter(Boolean).map(esc12).join(" \xB7 ")
|
|
73575
73966
|
)
|
|
73576
73967
|
).join("");
|
|
73577
73968
|
return frame(
|
|
@@ -73595,7 +73986,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73595
73986
|
const rows = annotations.slice(0, 10).map((a) => {
|
|
73596
73987
|
const when = a.createdAt ? new Date(a.createdAt).toLocaleDateString("pt-BR") : "";
|
|
73597
73988
|
const text2 = a.text.length > 90 ? `${a.text.slice(0, 90)}\u2026` : a.text;
|
|
73598
|
-
return row(
|
|
73989
|
+
return row(esc12(a.deviceLabel || "Dispositivo"), `${esc12(text2)}${when ? ` \xB7 ${esc12(when)}` : ""}`);
|
|
73599
73990
|
}).join("");
|
|
73600
73991
|
return frame(
|
|
73601
73992
|
"\u{1F4CB}",
|
|
@@ -73606,7 +73997,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73606
73997
|
if (type === "users") {
|
|
73607
73998
|
if (meta.users === null) return frame("\u{1F465}", "Usu\xE1rios", loadingBody);
|
|
73608
73999
|
const users = details.users || [];
|
|
73609
|
-
const rows = users.slice(0, 10).map((u) => row(
|
|
74000
|
+
const rows = users.slice(0, 10).map((u) => row(esc12(u.name), esc12(u.email || ""))).join("");
|
|
73610
74001
|
return frame(
|
|
73611
74002
|
"\u{1F465}",
|
|
73612
74003
|
"Usu\xE1rios",
|
|
@@ -76505,7 +76896,7 @@ var STYLE_ID6 = "myio-footer-component-styles";
|
|
|
76505
76896
|
function areStylesInjected() {
|
|
76506
76897
|
return !!document.getElementById(STYLE_ID6);
|
|
76507
76898
|
}
|
|
76508
|
-
function
|
|
76899
|
+
function injectStyles11() {
|
|
76509
76900
|
if (areStylesInjected()) return;
|
|
76510
76901
|
const style = document.createElement("style");
|
|
76511
76902
|
style.id = STYLE_ID6;
|
|
@@ -77250,7 +77641,7 @@ var FooterView = class {
|
|
|
77250
77641
|
this.chipRenderer = new ChipRenderer();
|
|
77251
77642
|
this.footerEl = document.createElement("section");
|
|
77252
77643
|
this.footerEl.className = this.getClassName();
|
|
77253
|
-
|
|
77644
|
+
injectStyles11();
|
|
77254
77645
|
this.applyThemeColors();
|
|
77255
77646
|
}
|
|
77256
77647
|
container;
|
|
@@ -79586,7 +79977,7 @@ var MODAL_CSS = `
|
|
|
79586
79977
|
to { transform: rotate(360deg); }
|
|
79587
79978
|
}
|
|
79588
79979
|
`;
|
|
79589
|
-
function
|
|
79980
|
+
function injectStyles12() {
|
|
79590
79981
|
if (document.getElementById(CSS_ID4)) return;
|
|
79591
79982
|
const style = document.createElement("style");
|
|
79592
79983
|
style.id = CSS_ID4;
|
|
@@ -79603,7 +79994,7 @@ var IntegrationsModalView = class {
|
|
|
79603
79994
|
closeHandlers = [];
|
|
79604
79995
|
tabChangeHandlers = [];
|
|
79605
79996
|
constructor(options) {
|
|
79606
|
-
|
|
79997
|
+
injectStyles12();
|
|
79607
79998
|
this.options = options;
|
|
79608
79999
|
this.tabs = options.tabs || DEFAULT_INTEGRATION_TABS;
|
|
79609
80000
|
this.activeTabId = options.defaultTab || this.tabs[0]?.id || "chiller";
|
|
@@ -83978,7 +84369,7 @@ var PRESETS = [
|
|
|
83978
84369
|
{ id: "custom", label: "Personalizado" }
|
|
83979
84370
|
];
|
|
83980
84371
|
var STEPS = ["Dispositivos", "Per\xEDodo", "Telemetrias", "Resumo"];
|
|
83981
|
-
var
|
|
84372
|
+
var esc6 = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
83982
84373
|
var norm = (s) => String(s ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
83983
84374
|
var fmtN = (n) => n.toLocaleString("pt-BR");
|
|
83984
84375
|
var pad = (n) => String(n).padStart(2, "0");
|
|
@@ -84366,8 +84757,8 @@ var DemandPanelV2 = class {
|
|
|
84366
84757
|
highlight(text2) {
|
|
84367
84758
|
const q = norm(this.s.search).trim();
|
|
84368
84759
|
const i = q ? norm(text2).indexOf(q) : -1;
|
|
84369
|
-
if (i < 0) return
|
|
84370
|
-
return
|
|
84760
|
+
if (i < 0) return esc6(text2);
|
|
84761
|
+
return esc6(text2.slice(0, i)) + `<mark class="dp2-mark">${esc6(text2.slice(i, i + q.length))}</mark>` + esc6(text2.slice(i + q.length));
|
|
84371
84762
|
}
|
|
84372
84763
|
deviceRow(d, mode) {
|
|
84373
84764
|
const picked = this.s.selected.includes(d.tbDeviceId);
|
|
@@ -84375,13 +84766,13 @@ var DemandPanelV2 = class {
|
|
|
84375
84766
|
const cat = this.categoryOf.get(d.tbDeviceId);
|
|
84376
84767
|
const chip = this.chips.find((c) => c.key === cat);
|
|
84377
84768
|
const dup = (this.labelCount.get(d.label) || 0) > 1;
|
|
84378
|
-
const action = mode === "result" ? picked ? '<span class="dp2-added">\u2713 Adicionado</span>' : `<button class="dp2-btn sm" type="button" data-action="add" data-id="${
|
|
84769
|
+
const action = mode === "result" ? picked ? '<span class="dp2-added">\u2713 Adicionado</span>' : `<button class="dp2-btn sm" type="button" data-action="add" data-id="${esc6(d.tbDeviceId)}" ${el2.ok ? "" : "disabled"} aria-label="Adicionar ${esc6(d.label)}">+ Adicionar</button>` : `<button class="dp2-btn sm" type="button" data-action="remove" data-id="${esc6(d.tbDeviceId)}" aria-label="Remover ${esc6(d.label)}">\u2715 Remover</button>`;
|
|
84379
84770
|
return `<div class="dp2-item ${el2.ok ? "" : "blocked"}">
|
|
84380
|
-
<img class="dp2-ico" src="${
|
|
84771
|
+
<img class="dp2-ico" src="${esc6(deviceIconUrl(d.deviceProfile))}" alt="" loading="lazy">
|
|
84381
84772
|
<div style="min-width:0">
|
|
84382
|
-
<div class="dp2-name">${mode === "result" ? this.highlight(d.label) :
|
|
84383
|
-
<div class="dp2-sub">${chip ? `<span class="dp2-tag">${
|
|
84384
|
-
${mode === "result" ? this.highlight(d.name) :
|
|
84773
|
+
<div class="dp2-name">${mode === "result" ? this.highlight(d.label) : esc6(d.label)}${dup && d.identifier ? ` <small class="dp2-info">\xB7 ${esc6(d.identifier)}</small>` : ""}</div>
|
|
84774
|
+
<div class="dp2-sub">${chip ? `<span class="dp2-tag">${esc6(chip.label)}</span>` : ""}${el2.text ? `<span class="dp2-tag ${el2.cls}" title="${esc6(el2.title)}">${el2.text}</span>` : ""}
|
|
84775
|
+
${mode === "result" ? this.highlight(d.name) : esc6(d.name)}${d.identifier ? " \xB7 " + esc6(d.identifier) : ""}</div>
|
|
84385
84776
|
</div>
|
|
84386
84777
|
<div>${action}</div>
|
|
84387
84778
|
</div>`;
|
|
@@ -84399,8 +84790,8 @@ var DemandPanelV2 = class {
|
|
|
84399
84790
|
this.el.body.innerHTML = `<div class="dp2-s1">
|
|
84400
84791
|
<section class="dp2-col" aria-label="Buscar medidores">
|
|
84401
84792
|
<div class="dp2-col-head">
|
|
84402
|
-
<input class="dp2-search" data-role="search" type="search" placeholder="\u{1F50E} Buscar por nome, identificador ou tipo\u2026" value="${
|
|
84403
|
-
<div class="dp2-chips" role="group" aria-label="Filtrar por tipo">${chips.map((c) => `<button class="dp2-chip" type="button" data-action="category" data-key="${
|
|
84793
|
+
<input class="dp2-search" data-role="search" type="search" placeholder="\u{1F50E} Buscar por nome, identificador ou tipo\u2026" value="${esc6(this.s.search)}" aria-label="Buscar medidores">
|
|
84794
|
+
<div class="dp2-chips" role="group" aria-label="Filtrar por tipo">${chips.map((c) => `<button class="dp2-chip" type="button" data-action="category" data-key="${esc6(c.key)}" aria-pressed="${this.s.category === c.key}">${c.icon ? esc6(c.icon) + " " : ""}${esc6(c.label)} \xB7 ${c.count}</button>`).join("")}</div>
|
|
84404
84795
|
<h3><span>${fmtN(results.length)} resultado(s)</span>
|
|
84405
84796
|
<button class="dp2-btn link" type="button" data-action="add-all" ${addable ? "" : "disabled"}>+ Adicionar todos (${addable})</button></h3>
|
|
84406
84797
|
</div>
|
|
@@ -84439,7 +84830,7 @@ var DemandPanelV2 = class {
|
|
|
84439
84830
|
<div class="dp2-card"><h3 tabindex="-1" data-role="step-title">Per\xEDodo</h3>
|
|
84440
84831
|
<div class="dp2-chips" style="margin-bottom:12px">${PRESETS.map((p) => {
|
|
84441
84832
|
const off = p.id !== "custom" && presetTooLong(p.id);
|
|
84442
|
-
return `<button class="dp2-chip" type="button" data-action="preset" data-preset="${p.id}" aria-pressed="${preset === p.id}" ${off ? `disabled title="at\xE9 ${maxDays} dia(s) com intervalos de ${
|
|
84833
|
+
return `<button class="dp2-chip" type="button" data-action="preset" data-preset="${p.id}" aria-pressed="${preset === p.id}" ${off ? `disabled title="at\xE9 ${maxDays} dia(s) com intervalos de ${esc6(r.label)}"` : ""}>${p.label}</button>`;
|
|
84443
84834
|
}).join("")}</div>
|
|
84444
84835
|
<div class="dp2-row">
|
|
84445
84836
|
<label class="dp2-field">In\xEDcio<input type="datetime-local" data-role="start" min="${MIN_PERIOD_START}T00:00" value="${Number.isFinite(start) ? toLocalDateTimeInput(start) : ""}"></label>
|
|
@@ -84452,24 +84843,24 @@ var DemandPanelV2 = class {
|
|
|
84452
84843
|
const d = limits?.maxDaysByResolution[x.id];
|
|
84453
84844
|
return `<button class="dp2-chip" type="button" data-action="resolution" data-res="${x.id}" aria-pressed="${this.s.resolution === x.id}">${x.label}${d != null ? ` <small>(at\xE9 ${d} d)</small>` : ""}</button>`;
|
|
84454
84845
|
}).join("")}</div>
|
|
84455
|
-
<p class="dp2-info" style="margin:10px 0 0">Cada linha do relat\xF3rio \xE9 um intervalo com <b>${
|
|
84456
|
-
${this.s.telemetries.has("consumption") ? `Com <b>Pot\xEAncia Total</b>, o arquivo traz tamb\xE9m a <b>${
|
|
84846
|
+
<p class="dp2-info" style="margin:10px 0 0">Cada linha do relat\xF3rio \xE9 um intervalo com <b>${esc6(BUCKET_STATS_LABEL)}</b> de cada telemetria. Os intervalos contam a partir do in\xEDcio do per\xEDodo${this.s.resolution === "1d" ? " (com 1 dia, cada linha \xE9 um dia do calend\xE1rio)" : ""}.
|
|
84847
|
+
${this.s.telemetries.has("consumption") ? `Com <b>Pot\xEAncia Total</b>, o arquivo traz tamb\xE9m a <b>${esc6(this.demandLabel())}</b>, em janelas de 15 min alinhadas ao rel\xF3gio.` : ""}</p>
|
|
84457
84848
|
${valid && !tooLong ? `<p class="dp2-info" style="margin:6px 0 0">${fmtN(bucketCount(start, end, this.s.resolution))} intervalo(s) por medidor.</p>` : ""}
|
|
84458
|
-
${tooLong ? `<div class="dp2-fix"><span class="dp2-err">O per\xEDodo \xE9 longo demais para intervalos de ${
|
|
84459
|
-
${fit ? `<button class="dp2-btn sm primary" type="button" data-action="resolution" data-res="${fit}">Usar ${
|
|
84849
|
+
${tooLong ? `<div class="dp2-fix"><span class="dp2-err">O per\xEDodo \xE9 longo demais para intervalos de ${esc6(r.label)} (m\xE1ximo ${maxDays} dia(s)).</span>
|
|
84850
|
+
${fit ? `<button class="dp2-btn sm primary" type="button" data-action="resolution" data-res="${fit}">Usar ${esc6(RESOLUTION_BY_ID[fit].label)}</button>` : ""}
|
|
84460
84851
|
<button class="dp2-btn sm" type="button" data-action="shorten">Encurtar para os \xFAltimos ${maxDays} dia(s)</button></div>` : ""}
|
|
84461
84852
|
${misaligned ? `<div class="dp2-fix"><span class="dp2-err">Com intervalos de 1 dia, o in\xEDcio precisa ser \xE0 meia-noite.</span>
|
|
84462
|
-
<button class="dp2-btn sm primary" type="button" data-action="snap-midnight">Come\xE7ar em ${
|
|
84853
|
+
<button class="dp2-btn sm primary" type="button" data-action="snap-midnight">Come\xE7ar em ${esc6(formatLocalDateTime(localMidnightOf(start)))}</button></div>` : ""}
|
|
84463
84854
|
</div>
|
|
84464
|
-
${otherErrs.length ? `<p class="dp2-err">${otherErrs.map(
|
|
84855
|
+
${otherErrs.length ? `<p class="dp2-err">${otherErrs.map(esc6).join("<br>")}</p>` : ""}`;
|
|
84465
84856
|
}
|
|
84466
84857
|
renderStep3() {
|
|
84467
84858
|
this.el.body.innerHTML = `<div class="dp2-tgrid">${TELEMETRY_GROUPS.map((g) => {
|
|
84468
84859
|
const all = g.items.every((t) => this.s.telemetries.has(t.key));
|
|
84469
|
-
return `<div class="dp2-card"><h3><span>${g.icon} ${
|
|
84860
|
+
return `<div class="dp2-card"><h3><span>${g.icon} ${esc6(g.label)}</span>
|
|
84470
84861
|
<button class="dp2-btn link" type="button" data-action="group-all" data-gid="${g.id}">${all ? "Desmarcar" : "Marcar"} todos</button></h3>
|
|
84471
84862
|
${g.items.map((t) => `<label class="dp2-check"><input type="checkbox" data-role="tel" data-key="${t.key}" ${this.s.telemetries.has(t.key) ? "checked" : ""}>
|
|
84472
|
-
${
|
|
84863
|
+
${esc6(t.label)}<span class="u">${this.p.supportMode ? esc6(t.key) + " \xB7 " : ""}${esc6(t.unit)}</span></label>`).join("")}
|
|
84473
84864
|
</div>`;
|
|
84474
84865
|
}).join("")}</div>
|
|
84475
84866
|
<p class="dp2-info">${this.s.telemetries.size} de ${TELEMETRY_CATALOG.length} telemetrias. Mesmo cat\xE1logo da modal "Telemetrias Instant\xE2neas e Pico de Demanda".</p>`;
|
|
@@ -84489,14 +84880,14 @@ var DemandPanelV2 = class {
|
|
|
84489
84880
|
let validation = "";
|
|
84490
84881
|
if (v.state === "loading") validation = '<div class="dp2-info">\u23F3 Validando o pedido no servidor\u2026</div>';
|
|
84491
84882
|
else if (v.state === "error") {
|
|
84492
|
-
validation = `<div class="dp2-err">N\xE3o foi poss\xEDvel validar agora: ${
|
|
84883
|
+
validation = `<div class="dp2-err">N\xE3o foi poss\xEDvel validar agora: ${esc6(v.error)}
|
|
84493
84884
|
<button class="dp2-btn link" type="button" data-action="revalidate">Tentar de novo</button></div>`;
|
|
84494
84885
|
} else if (vr) {
|
|
84495
84886
|
const warns = (vr.warnings || []).map((w) => {
|
|
84496
84887
|
const dev = w.deviceId;
|
|
84497
|
-
return `<li>${
|
|
84888
|
+
return `<li>${esc6(warningText(w.code, w.message) + (dev ? this.devicesSuffix({ devices: [{ deviceId: dev }] }) : ""))}</li>`;
|
|
84498
84889
|
}).join("");
|
|
84499
|
-
const reuse = vr.reusable ? `<div class="dp2-banner info" style="margin-top:8px">\u267B J\xE1 existe um relat\xF3rio id\xEAntico${vr.reusable.generatedAt ? ` gerado em ${
|
|
84890
|
+
const reuse = vr.reusable ? `<div class="dp2-banner info" style="margin-top:8px">\u267B J\xE1 existe um relat\xF3rio id\xEAntico${vr.reusable.generatedAt ? ` gerado em ${esc6(formatLocalDateTime(Date.parse(vr.reusable.generatedAt)))}` : ""}${vr.reusable.generatedBy?.userId ? ` por ${esc6(vr.reusable.generatedBy.userId)}` : ""}. Confirmar reaproveita o arquivo (sem custo de cota).
|
|
84500
84891
|
<label class="dp2-check" style="margin-top:6px"><input type="checkbox" data-role="force" ${this.s.force ? "checked" : ""}> Gerar novamente mesmo assim</label></div>` : "";
|
|
84501
84892
|
validation = `${vr.ok ? '<div class="dp2-info">\u2713 Pedido validado no servidor.</div>' : ""}
|
|
84502
84893
|
${warns ? `<ul class="dp2-info" style="margin:6px 0 0;padding-left:18px">${warns}</ul>` : ""}${reuse}`;
|
|
@@ -84504,12 +84895,12 @@ var DemandPanelV2 = class {
|
|
|
84504
84895
|
this.el.body.innerHTML = `
|
|
84505
84896
|
<div class="dp2-card"><h3 tabindex="-1" data-role="step-title">Resumo do pedido</h3>
|
|
84506
84897
|
<dl class="dp2-sum">
|
|
84507
|
-
<dt>Solicitante</dt><dd>${
|
|
84508
|
-
<dt>Medidores (${req.devices.length})</dt><dd><div class="dp2-pills">${req.devices.map((d) => `<span class="dp2-pill">${
|
|
84898
|
+
<dt>Solicitante</dt><dd>${esc6(this.p.user.name)}</dd>
|
|
84899
|
+
<dt>Medidores (${req.devices.length})</dt><dd><div class="dp2-pills">${req.devices.map((d) => `<span class="dp2-pill">${esc6(labelOf(d))}</span>`).join("")}</div></dd>
|
|
84509
84900
|
<dt>Per\xEDodo</dt><dd>${formatLocalDateTime(start)} \u2192 ${formatLocalDateTime(end)} <span class="dp2-info">(${fmtDuration(end - start)}, hor\xE1rio de Bras\xEDlia${req.period.preset === "today" || req.period.preset === "thisMonth" ? `, calculado \xE0s ${formatLocalDateTime(snap.takenAt).slice(11)}` : ""})</span></dd>
|
|
84510
|
-
<dt>Resolu\xE7\xE3o</dt><dd>${
|
|
84511
|
-
<dt>Telemetrias (${req.telemetries.length})</dt><dd><div class="dp2-pills">${req.telemetries.map((t) => `<span class="dp2-pill">${
|
|
84512
|
-
${req.telemetries.some((t) => t.key === "consumption") ? `<div class="dp2-info" style="margin-top:4px">Inclui a ${
|
|
84901
|
+
<dt>Resolu\xE7\xE3o</dt><dd>${esc6(this.resolutionLabel(req.resolution))} <span class="dp2-info">(${esc6(BUCKET_STATS_LABEL)})</span></dd>
|
|
84902
|
+
<dt>Telemetrias (${req.telemetries.length})</dt><dd><div class="dp2-pills">${req.telemetries.map((t) => `<span class="dp2-pill">${esc6(t.label)} \xB7 ${esc6(t.unit)}</span>`).join("")}</div>
|
|
84903
|
+
${req.telemetries.some((t) => t.key === "consumption") ? `<div class="dp2-info" style="margin-top:4px">Inclui a ${esc6(this.demandLabel())}.</div>` : ""}</dd>
|
|
84513
84904
|
<dt>Tamanho</dt><dd><span class="dp2-size ${cls}">${txt}</span> <span class="dp2-info">\u2248 ${fmtN(pts)} pontos</span>
|
|
84514
84905
|
<details class="dp2-details"><summary>Detalhes</summary><span class="dp2-info">${fmtN(est.buckets)} intervalos \xD7 ${req.devices.length} medidores \xD7 ${req.telemetries.length} telemetrias${this.limits()?.maxPoints != null ? ` \xB7 limite ${fmtN(this.limits().maxPoints)}` : ""}</span></details></dd>
|
|
84515
84906
|
<dt>Entrega</dt><dd>Arquivos XLSX, CSV e JSON <span class="dp2-info">(dispon\xEDveis por 3 dias; o resumo fica por 1 ano)</span></dd>
|
|
@@ -84517,15 +84908,15 @@ var DemandPanelV2 = class {
|
|
|
84517
84908
|
<div style="margin-top:12px">${validation}</div>
|
|
84518
84909
|
<p class="dp2-info" style="margin:12px 0 0">Seu pedido fica registrado (quem, quando, o qu\xEA) e \xE9 processado em segundo plano. <b>Voc\xEA pode fechar este painel</b> e acompanhar em Relat\xF3rios.</p>
|
|
84519
84910
|
</div>
|
|
84520
|
-
${this.p.supportMode ? `<div class="dp2-card"><h3>Pedido que ser\xE1 registrado (suporte)</h3><pre class="dp2-json">${
|
|
84521
|
-
${errs.length ? `<p class="dp2-err">${errs.map(
|
|
84911
|
+
${this.p.supportMode ? `<div class="dp2-card"><h3>Pedido que ser\xE1 registrado (suporte)</h3><pre class="dp2-json">${esc6(JSON.stringify(req, null, 2))}</pre></div>` : ""}
|
|
84912
|
+
${errs.length ? `<p class="dp2-err">${errs.map(esc6).join("<br>")}</p>` : ""}`;
|
|
84522
84913
|
}
|
|
84523
84914
|
renderNav() {
|
|
84524
84915
|
const errs = this.stepErrors(this.s.step);
|
|
84525
84916
|
const hints = ["", `${this.s.selected.length} medidor(es) na lista`, "Escolha o per\xEDodo e a resolu\xE7\xE3o", `${this.s.telemetries.size} telemetria(s)`, "Revise e confirme"];
|
|
84526
84917
|
this.el.nav.innerHTML = `
|
|
84527
84918
|
<button class="dp2-btn" type="button" data-action="back" ${this.s.step === 1 ? "disabled" : ""}>\u2190 Voltar</button>
|
|
84528
|
-
<span class="hint">${
|
|
84919
|
+
<span class="hint">${esc6(hints[this.s.step])}</span>
|
|
84529
84920
|
${this.s.step === 4 ? `<button class="dp2-btn primary" type="button" data-action="confirm" ${errs.length || this.s.submitting || this.s.validation.state !== "ok" ? "disabled" : ""}>${this.s.submitting ? "Enviando\u2026" : "\u2713 Confirmar e enviar"}</button>` : `<button class="dp2-btn primary" type="button" data-action="next" ${errs.length ? "disabled" : ""}>Pr\xF3ximo \u2192</button>`}`;
|
|
84530
84921
|
}
|
|
84531
84922
|
jobTitle(e) {
|
|
@@ -84543,7 +84934,7 @@ var DemandPanelV2 = class {
|
|
|
84543
84934
|
return;
|
|
84544
84935
|
}
|
|
84545
84936
|
if (s.listState === "error") {
|
|
84546
|
-
this.el.body.innerHTML = `<div class="dp2-empty">N\xE3o foi poss\xEDvel carregar os relat\xF3rios (${
|
|
84937
|
+
this.el.body.innerHTML = `<div class="dp2-empty">N\xE3o foi poss\xEDvel carregar os relat\xF3rios (${esc6(s.listError)}).<br><button class="dp2-btn" type="button" data-action="reload">Tentar de novo</button></div>`;
|
|
84547
84938
|
return;
|
|
84548
84939
|
}
|
|
84549
84940
|
const orphans = this.p.supportMode ? s.active.filter((j) => !s.keys.includes(envelopeKey(j.jobId))) : [];
|
|
@@ -84561,43 +84952,43 @@ var DemandPanelV2 = class {
|
|
|
84561
84952
|
const note = (cls, text2) => `<div class="${cls}" style="margin-top:6px">${text2}</div>`;
|
|
84562
84953
|
const queue = st === "queued" && j?.queue?.position ? ` (N\xBA ${j.queue.position})` : "";
|
|
84563
84954
|
const peak = j?.totals?.largestDevicePeak;
|
|
84564
|
-
const peakTxt = peak && (peak.kw != null || peak.w != null) ? `Maior pico individual: <b>${
|
|
84565
|
-
return `<article class="dp2-job" aria-label="${
|
|
84955
|
+
const peakTxt = peak && (peak.kw != null || peak.w != null) ? `Maior pico individual: <b>${esc6(fmtN(Number(peak.kw ?? peak.w / 1e3)))} kW</b>${peak.label ? ` \xB7 ${esc6(peak.label)}` : ""}${peak.at ? ` \xB7 ${esc6(when(peak.at))}` : ""}` : "";
|
|
84956
|
+
return `<article class="dp2-job" aria-label="${esc6(this.jobTitle(e))}">
|
|
84566
84957
|
<div class="dp2-job-top">
|
|
84567
|
-
<span class="dp2-job-title">${
|
|
84958
|
+
<span class="dp2-job-title">${esc6(this.jobTitle(e))}</span>
|
|
84568
84959
|
<span class="dp2-status ${st}">${JOB_STATE_LABEL[st]}${queue}${st === "running" ? ` ${progress}%` : ""}</span>
|
|
84569
84960
|
<span style="flex:1"></span>
|
|
84570
|
-
<span class="dp2-info">${
|
|
84961
|
+
<span class="dp2-info">${esc6(e.requestedBy.name)} \xB7 ${when(e.requestedAt)}</span>
|
|
84571
84962
|
</div>
|
|
84572
84963
|
${st === "queued" || st === "running" ? `<div class="dp2-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${progress}"><span style="width:${progress}%"></span></div>` : ""}
|
|
84573
|
-
${st === "queued" && j?.queue?.estimatedStartAt ? note("dp2-info", `In\xEDcio estimado: ${
|
|
84574
|
-
${st === "failed" ? note("dp2-err", `${
|
|
84575
|
-
${st === "rejected" ? note("dp2-err", `${
|
|
84964
|
+
${st === "queued" && j?.queue?.estimatedStartAt ? note("dp2-info", `In\xEDcio estimado: ${esc6(when(j.queue.estimatedStartAt))}`) : ""}
|
|
84965
|
+
${st === "failed" ? note("dp2-err", `${esc6(failureText(j?.error?.code))}${this.p.supportMode && j?.error ? ` <small>(${esc6(j.error.code)}: ${esc6(j.error.message)})</small>` : ""}`) : ""}
|
|
84966
|
+
${st === "rejected" ? note("dp2-err", `${esc6(rejectionText(v.code, v.reason, v.message))}${this.p.supportMode ? ` <small>(${esc6(v.code)}${v.reason ? " \xB7 " + esc6(v.reason) : ""})</small>` : ""}`) : ""}
|
|
84576
84967
|
${st === "not_received" ? note("dp2-err", "O pedido est\xE1 registrado, mas o processamento n\xE3o o recebeu. Reenviar \xE9 seguro: n\xE3o gera relat\xF3rio duplicado.") : ""}
|
|
84577
84968
|
${st === "query_unavailable" ? note("dp2-info", "N\xE3o foi poss\xEDvel consultar o andamento agora \u2014 tentaremos de novo.") : ""}
|
|
84578
84969
|
${st === "old_request" ? note("dp2-info", 'Pedido antigo, sem registro de processamento. Use "Duplicar e editar".') : ""}
|
|
84579
84970
|
${st === "result_expired" ? note("dp2-info", "O relat\xF3rio foi conclu\xEDdo, mas os arquivos j\xE1 expiraram (ficam 3 dias).") : ""}
|
|
84580
84971
|
${st === "purged" ? note("dp2-info", "O conte\xFAdo deste relat\xF3rio foi removido.") : ""}
|
|
84581
|
-
${st === "succeeded" && j?.reused ? note("dp2-info", `\u267B Resultado reaproveitado${j.generatedAt ? ` \u2014 gerado em ${
|
|
84972
|
+
${st === "succeeded" && j?.reused ? note("dp2-info", `\u267B Resultado reaproveitado${j.generatedAt ? ` \u2014 gerado em ${esc6(when(j.generatedAt))}` : ""}${j.generatedBy?.userId ? ` por ${esc6(j.generatedBy.userId)}` : ""}.`) : ""}
|
|
84582
84973
|
${st === "succeeded" && peakTxt ? note("dp2-info", peakTxt) : ""}
|
|
84583
|
-
${st === "succeeded" && j?.expiresAt ? note("dp2-info", `Arquivos dispon\xEDveis at\xE9 ${
|
|
84974
|
+
${st === "succeeded" && j?.expiresAt ? note("dp2-info", `Arquivos dispon\xEDveis at\xE9 ${esc6(when(j.expiresAt))}.`) : ""}
|
|
84584
84975
|
${s.auditPending.has(e.jobId) ? '<div class="dp2-audit-warn">\u26A0 A a\xE7\xE3o foi aceita, mas o registro de auditoria falhou \u2014 ser\xE1 reconciliado.</div>' : ""}
|
|
84585
84976
|
<div class="dp2-job-actions">
|
|
84586
|
-
${st === "succeeded" ? `<button class="dp2-btn sm primary" type="button" data-action="download" data-kind="xlsx" data-job="${
|
|
84587
|
-
<button class="dp2-btn sm" type="button" data-action="download" data-kind="csv" data-job="${
|
|
84588
|
-
<button class="dp2-btn sm" type="button" data-action="download" data-kind="json" data-job="${
|
|
84589
|
-
${st === "queued" || st === "running" ? `<button class="dp2-btn sm" type="button" data-action="cancel" data-job="${
|
|
84590
|
-
${v.canResend ? `<button class="dp2-btn sm primary" type="button" data-action="resend" data-job="${
|
|
84591
|
-
${["failed", "cancelled", "succeeded", "result_expired", "purged", "old_request", "rejected"].includes(st) ? `<button class="dp2-btn sm" type="button" data-action="clone" data-job="${
|
|
84592
|
-
${this.p.supportMode ? `<button class="dp2-btn link" type="button" data-action="details" data-job="${
|
|
84593
|
-
</div>
|
|
84594
|
-
${this.p.supportMode && s.openDetails.has(e.jobId) ? `<pre class="dp2-json">${
|
|
84977
|
+
${st === "succeeded" ? `<button class="dp2-btn sm primary" type="button" data-action="download" data-kind="xlsx" data-job="${esc6(e.jobId)}">\u2B07 XLSX</button>
|
|
84978
|
+
<button class="dp2-btn sm" type="button" data-action="download" data-kind="csv" data-job="${esc6(e.jobId)}">CSV</button>
|
|
84979
|
+
<button class="dp2-btn sm" type="button" data-action="download" data-kind="json" data-job="${esc6(e.jobId)}">JSON</button>` : ""}
|
|
84980
|
+
${st === "queued" || st === "running" ? `<button class="dp2-btn sm" type="button" data-action="cancel" data-job="${esc6(e.jobId)}" ${busy}>\u2715 Cancelar</button>` : ""}
|
|
84981
|
+
${v.canResend ? `<button class="dp2-btn sm primary" type="button" data-action="resend" data-job="${esc6(e.jobId)}" ${busy}>\u21BB Reenviar</button>` : ""}
|
|
84982
|
+
${["failed", "cancelled", "succeeded", "result_expired", "purged", "old_request", "rejected"].includes(st) ? `<button class="dp2-btn sm" type="button" data-action="clone" data-job="${esc6(e.jobId)}">\u29C9 Duplicar e editar</button>` : ""}
|
|
84983
|
+
${this.p.supportMode ? `<button class="dp2-btn link" type="button" data-action="details" data-job="${esc6(e.jobId)}">${s.openDetails.has(e.jobId) ? "Ocultar" : "Detalhes /"} auditoria</button>` : ""}
|
|
84984
|
+
</div>
|
|
84985
|
+
${this.p.supportMode && s.openDetails.has(e.jobId) ? `<pre class="dp2-json">${esc6(JSON.stringify(e, null, 2))}</pre>` : ""}
|
|
84595
84986
|
</article>`;
|
|
84596
84987
|
}).join("");
|
|
84597
84988
|
const orphanCards = orphans.map((j) => `<article class="dp2-job ghost"><div class="dp2-job-top">
|
|
84598
|
-
<span class="dp2-job-title">Job sem registro no ThingsBoard (O-6)</span><span class="dp2-status ${j.status}">${
|
|
84599
|
-
<span style="flex:1"></span><span class="dp2-info">${
|
|
84600
|
-
<div class="dp2-info" style="margin-top:4px"><code>${
|
|
84989
|
+
<span class="dp2-job-title">Job sem registro no ThingsBoard (O-6)</span><span class="dp2-status ${j.status}">${esc6(JOB_STATE_LABEL[j.status] ?? j.status)}</span>
|
|
84990
|
+
<span style="flex:1"></span><span class="dp2-info">${esc6(j.requestedBy?.userId ?? "")} \xB7 ${when(j.createdAt)}</span></div>
|
|
84991
|
+
<div class="dp2-info" style="margin-top:4px"><code>${esc6(j.jobId)}</code></div></article>`).join("");
|
|
84601
84992
|
this.el.body.innerHTML = cards + orphanCards;
|
|
84602
84993
|
}
|
|
84603
84994
|
/* ------------------------------------------------------------------ data flows */
|
|
@@ -86056,7 +86447,7 @@ function buildYearOptions() {
|
|
|
86056
86447
|
for (let y = now + 2; y >= now - 2; y--) out.push(y);
|
|
86057
86448
|
return out;
|
|
86058
86449
|
}
|
|
86059
|
-
function
|
|
86450
|
+
function esc7(s) {
|
|
86060
86451
|
return String(s == null ? "" : s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
86061
86452
|
}
|
|
86062
86453
|
function resolveThemeVars(theme) {
|
|
@@ -86627,7 +87018,7 @@ function openGoalsPanel(params) {
|
|
|
86627
87018
|
});
|
|
86628
87019
|
}
|
|
86629
87020
|
container.appendChild(rootEl);
|
|
86630
|
-
|
|
87021
|
+
injectStyles27();
|
|
86631
87022
|
rootEl.addEventListener("click", onClick);
|
|
86632
87023
|
rootEl.addEventListener("change", onChange);
|
|
86633
87024
|
rootEl.addEventListener("input", onInput);
|
|
@@ -86872,13 +87263,13 @@ function openGoalsPanel(params) {
|
|
|
86872
87263
|
const g = state6.goals || {};
|
|
86873
87264
|
const parts = [];
|
|
86874
87265
|
if (hasCoverageGaps(g.coverageGaps)) {
|
|
86875
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
87266
|
+
parts.push(`<p style="margin:0 0 8px;">${esc7(buildCoverageWarningTextPtBR(g.coverageGaps, "GERAL"))}</p>`);
|
|
86876
87267
|
}
|
|
86877
87268
|
(Array.isArray(g.devices) ? g.devices : []).forEach((d) => {
|
|
86878
87269
|
if (!hasCoverageGaps(d && d.coverageGaps)) return;
|
|
86879
87270
|
const label = d.label || d.code || "medidor";
|
|
86880
87271
|
parts.push(
|
|
86881
|
-
`<p style="margin:0 0 8px;">${
|
|
87272
|
+
`<p style="margin:0 0 8px;">${esc7(buildCoverageWarningTextPtBR(d.coverageGaps, `do medidor ${label}`))}</p>`
|
|
86882
87273
|
);
|
|
86883
87274
|
});
|
|
86884
87275
|
return `<div style="font-size:12px;line-height:1.55;color:#334155;">${parts.join("")}</div>`;
|
|
@@ -86918,7 +87309,7 @@ function openGoalsPanel(params) {
|
|
|
86918
87309
|
html += `<div class="myio-goals-alert myio-goals-alert-amber">${icon2("alert")} ${i18n2.versionConflict}</div>`;
|
|
86919
87310
|
}
|
|
86920
87311
|
if (state6.saveError && !state6.conflict) {
|
|
86921
|
-
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${
|
|
87312
|
+
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${esc7(state6.saveError)}</div>`;
|
|
86922
87313
|
}
|
|
86923
87314
|
if (state6.saved && !state6.saveError) {
|
|
86924
87315
|
html += `<div class="myio-goals-alert myio-goals-alert-green">${icon2("check")} ${i18n2.saveSuccess}</div>`;
|
|
@@ -86933,7 +87324,7 @@ function openGoalsPanel(params) {
|
|
|
86933
87324
|
return `
|
|
86934
87325
|
<div class="myio-goals-center myio-goals-center-col">
|
|
86935
87326
|
${icon2("alert-lg")}
|
|
86936
|
-
<p>${
|
|
87327
|
+
<p>${esc7(state6.error)}</p>
|
|
86937
87328
|
<button class="myio-goals-btn myio-goals-btn-outline" data-action="retry">${i18n2.retry}</button>
|
|
86938
87329
|
</div>`;
|
|
86939
87330
|
}
|
|
@@ -87023,7 +87414,7 @@ function openGoalsPanel(params) {
|
|
|
87023
87414
|
const cellLabel = state6.level === "month" ? i18n2.months[key] : state6.level === "day" ? i18n2.dayCell.replace("{day}", Number(key)) : `${key}:00`;
|
|
87024
87415
|
const canDrill = state6.level !== "hour";
|
|
87025
87416
|
const labelEl = canDrill ? `<button class="myio-goals-cell-drill" data-action="${state6.level === "month" ? "open-month" : "open-day"}" data-key="${key}" title="${i18n2.drill.openTitle}">${cellLabel} ${icon2("chevron-sm")}</button>` : `<span class="myio-goals-cell-label">${cellLabel}</span>`;
|
|
87026
|
-
const val = state6.draft[key] !== void 0 ?
|
|
87417
|
+
const val = state6.draft[key] !== void 0 ? esc7(state6.draft[key]) : "";
|
|
87027
87418
|
const minAttr = cfg.allowsNegative ? "" : 'min="0"';
|
|
87028
87419
|
return `
|
|
87029
87420
|
<div class="myio-goals-cell">
|
|
@@ -87091,7 +87482,7 @@ function openGoalsPanel(params) {
|
|
|
87091
87482
|
const actor = ev.actor ? `${String(ev.actor).slice(0, 8)}\u2026` : i18n2.history.system;
|
|
87092
87483
|
const extra = ev.bucketCount - (ev.details ? ev.details.length : 0);
|
|
87093
87484
|
const chips = (ev.details || []).slice(0, DETAIL_PREVIEW).map(
|
|
87094
|
-
(d) => `<span class="myio-goals-tl-chip"><span class="myio-goals-tl-ref">${
|
|
87485
|
+
(d) => `<span class="myio-goals-tl-chip"><span class="myio-goals-tl-ref">${esc7(formatRef(d.ref))}</span>${d.value === null ? "\u2014" : fmt2(d.value)}</span>`
|
|
87095
87486
|
).join("");
|
|
87096
87487
|
const more = extra > 0 ? `<span class="myio-goals-tl-more">${i18n2.history.moreDetails.replace("{n}", extra)}</span>` : "";
|
|
87097
87488
|
return `
|
|
@@ -87101,7 +87492,7 @@ function openGoalsPanel(params) {
|
|
|
87101
87492
|
<span class="myio-goals-tl-title">${i18n2.history.source[ev.source] || i18n2.history.source.EDIT}</span>
|
|
87102
87493
|
<span class="myio-goals-tl-ver">v${ev.version}</span>
|
|
87103
87494
|
</div>
|
|
87104
|
-
<p class="myio-goals-tl-meta" title="${
|
|
87495
|
+
<p class="myio-goals-tl-meta" title="${esc7(new Date(ev.changedAt).toLocaleString(locale))}">${esc7(actor)} \xB7 ${esc7(timeAgo(ev.changedAt))}</p>
|
|
87105
87496
|
<p class="myio-goals-tl-records">${i18n2.history.records.replace("{n}", ev.bucketCount)} \xB7 ${i18n2.levels[ev.actionLevel] || ev.actionLevel}</p>
|
|
87106
87497
|
${chips || more ? `<div class="myio-goals-tl-chips">${chips}${more}</div>` : ""}
|
|
87107
87498
|
</li>`;
|
|
@@ -87148,7 +87539,7 @@ ${state6.year}-03-15T08,15`;
|
|
|
87148
87539
|
let html = `
|
|
87149
87540
|
<div class="myio-goals-import-hint">
|
|
87150
87541
|
<p>${i18n2.import.formatHint}</p>
|
|
87151
|
-
<code>${
|
|
87542
|
+
<code>${esc7(sample)}</code>
|
|
87152
87543
|
</div>`;
|
|
87153
87544
|
if (!applied) {
|
|
87154
87545
|
html += `
|
|
@@ -87162,16 +87553,16 @@ ${state6.year}-03-15T08,15`;
|
|
|
87162
87553
|
<input type="file" id="myio-goals-csv-file" accept=".csv,.txt,text/csv,text/plain" style="display:none" />
|
|
87163
87554
|
</div>
|
|
87164
87555
|
</div>
|
|
87165
|
-
<textarea id="myio-goals-csv-textarea" rows="8" spellcheck="false" placeholder="${
|
|
87556
|
+
<textarea id="myio-goals-csv-textarea" rows="8" spellcheck="false" placeholder="${esc7(`bucket,value
|
|
87166
87557
|
${state6.year},100000
|
|
87167
87558
|
${state6.year}-03,9000
|
|
87168
87559
|
${state6.year}-03-15,310
|
|
87169
|
-
${state6.year}-03-15T08,15`)}">${
|
|
87560
|
+
${state6.year}-03-15T08,15`)}">${esc7(state6.csv)}</textarea>
|
|
87170
87561
|
<p class="myio-goals-microhint">${i18n2.import.unitNote.replace("{unit}", unitLabel2())}</p>
|
|
87171
87562
|
</div>`;
|
|
87172
87563
|
}
|
|
87173
87564
|
if (state6.saveError && state6.conflictVersion === null) {
|
|
87174
|
-
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${
|
|
87565
|
+
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${esc7(state6.saveError)}</div>`;
|
|
87175
87566
|
}
|
|
87176
87567
|
if (state6.conflictVersion !== null) {
|
|
87177
87568
|
html += `<div class="myio-goals-alert myio-goals-alert-amber">${icon2("alert")} ${i18n2.import.conflict}</div>`;
|
|
@@ -87200,7 +87591,7 @@ ${state6.year}-03-15T08,15`)}">${esc6(state6.csv)}</textarea>
|
|
|
87200
87591
|
<div class="myio-goals-import-diags">
|
|
87201
87592
|
<p class="myio-goals-import-diags-title">${i18n2.import.diagnosticsTitle}</p>
|
|
87202
87593
|
<ul>${result.diagnostics.map(
|
|
87203
|
-
(d) => `<li>${icon2("alert-sm")} <span><span class="myio-goals-diag-line">${i18n2.import.line.replace("{line}", d.line)}</span>${d.bucket ? ` <span class="myio-goals-diag-bucket">[${
|
|
87594
|
+
(d) => `<li>${icon2("alert-sm")} <span><span class="myio-goals-diag-line">${i18n2.import.line.replace("{line}", d.line)}</span>${d.bucket ? ` <span class="myio-goals-diag-bucket">[${esc7(d.bucket)}]</span>` : ""} ${esc7(d.reason)}</span></li>`
|
|
87204
87595
|
).join("")}</ul>
|
|
87205
87596
|
</div>`;
|
|
87206
87597
|
}
|
|
@@ -87208,7 +87599,7 @@ ${state6.year}-03-15T08,15`)}">${esc6(state6.csv)}</textarea>
|
|
|
87208
87599
|
html += `
|
|
87209
87600
|
<div class="myio-goals-import-log">
|
|
87210
87601
|
<p class="myio-goals-import-log-title">${i18n2.import.logTitle}</p>
|
|
87211
|
-
<ul>${result.log.map((line) => `<li>${
|
|
87602
|
+
<ul>${result.log.map((line) => `<li>${esc7(line)}</li>`).join("")}</ul>
|
|
87212
87603
|
</div>`;
|
|
87213
87604
|
}
|
|
87214
87605
|
html += `</div>`;
|
|
@@ -87282,7 +87673,7 @@ ${state6.year}-03-15T08,15`)}">${esc6(state6.csv)}</textarea>
|
|
|
87282
87673
|
return "";
|
|
87283
87674
|
}
|
|
87284
87675
|
}
|
|
87285
|
-
function
|
|
87676
|
+
function injectStyles27() {
|
|
87286
87677
|
const id = "myio-goals-gcdr-styles";
|
|
87287
87678
|
const prev = document.getElementById(id);
|
|
87288
87679
|
if (prev) prev.remove();
|
|
@@ -94451,7 +94842,7 @@ function injectCSS10() {
|
|
|
94451
94842
|
document.head.appendChild(style);
|
|
94452
94843
|
_cssInjected2 = true;
|
|
94453
94844
|
}
|
|
94454
|
-
function
|
|
94845
|
+
function esc8(value) {
|
|
94455
94846
|
return String(value == null ? "" : value).replace(
|
|
94456
94847
|
/[&<>"]/g,
|
|
94457
94848
|
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]
|
|
@@ -94501,7 +94892,7 @@ function buildPieSvg(visible, total) {
|
|
|
94501
94892
|
const val = Number(v.d.value) || 0;
|
|
94502
94893
|
return `<svg class="myio-col-summary__pie" viewBox="0 0 220 220">
|
|
94503
94894
|
<circle class="myio-col-summary__slice" data-idx="${v.idx}" cx="110" cy="110" r="100"
|
|
94504
|
-
fill="${sliceColor(v.idx)}"><title>${
|
|
94895
|
+
fill="${sliceColor(v.idx)}"><title>${esc8(v.d.name)} \u2014 ${esc8(fmt2(val))} (${fmtPct2(
|
|
94505
94896
|
val,
|
|
94506
94897
|
total,
|
|
94507
94898
|
pd
|
|
@@ -94516,7 +94907,7 @@ function buildPieSvg(visible, total) {
|
|
|
94516
94907
|
const a1 = acc / total * 360;
|
|
94517
94908
|
return `<path class="myio-col-summary__slice" data-idx="${v.idx}"
|
|
94518
94909
|
d="${arcPath(110, 110, 100, a0, a1)}" fill="${sliceColor(v.idx)}"
|
|
94519
|
-
><title>${
|
|
94910
|
+
><title>${esc8(v.d.name)} \u2014 ${esc8(fmt2(val))} (${fmtPct2(val, total, pd)})</title></path>`;
|
|
94520
94911
|
}).join("");
|
|
94521
94912
|
return `<svg class="myio-col-summary__pie" viewBox="0 0 220 220">${paths}</svg>`;
|
|
94522
94913
|
}
|
|
@@ -94530,8 +94921,8 @@ function buildLegend(total) {
|
|
|
94530
94921
|
return `<div class="myio-col-summary__legend-row${isExcl ? " is-excluded" : ""}" data-idx="${idx}"
|
|
94531
94922
|
title="Clique para ${isExcl ? "incluir" : "remover"} da pizza">
|
|
94532
94923
|
<span class="myio-col-summary__legend-dot" style="background:${sliceColor(idx)};"></span>
|
|
94533
|
-
<span class="myio-col-summary__legend-name">${
|
|
94534
|
-
<span class="myio-col-summary__legend-val">${
|
|
94924
|
+
<span class="myio-col-summary__legend-name">${esc8(d.name)}</span>
|
|
94925
|
+
<span class="myio-col-summary__legend-val">${esc8(fmt2(val))}</span>
|
|
94535
94926
|
<span class="myio-col-summary__legend-pct">${pct}</span>
|
|
94536
94927
|
</div>`;
|
|
94537
94928
|
}).join("");
|
|
@@ -94552,25 +94943,25 @@ function buildAverageInner() {
|
|
|
94552
94943
|
const dash = "\u2014";
|
|
94553
94944
|
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
94554
94945
|
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
94555
|
-
<span class="myio-col-summary__kpi-value">${
|
|
94946
|
+
<span class="myio-col-summary__kpi-value">${esc8(data.periodLabel)}</span>
|
|
94556
94947
|
</div>` : "";
|
|
94557
94948
|
const note = "M\xE9dia, m\xEDnima e m\xE1xima consideram apenas dispositivos online (com leitura).";
|
|
94558
94949
|
const kpis = `<div class="myio-col-summary__kpis">
|
|
94559
94950
|
${periodRow}
|
|
94560
94951
|
<div class="myio-col-summary__kpi">
|
|
94561
94952
|
<span class="myio-col-summary__kpi-label">Dispositivos
|
|
94562
|
-
<span class="myio-col-summary__info" title="${
|
|
94953
|
+
<span class="myio-col-summary__info" title="${esc8(note)}" aria-label="${esc8(note)}"
|
|
94563
94954
|
style="display:inline-flex;align-items:center;justify-content:center;width:13px;height:13px;margin-left:4px;border-radius:50%;background:#3e1a7d;color:#fff;font-size:9px;font-weight:700;font-style:italic;font-family:Georgia,serif;cursor:help;vertical-align:middle;">i</span>
|
|
94564
94955
|
</span>
|
|
94565
94956
|
<span class="myio-col-summary__kpi-value">${online.length} online \xB7 ${offline.length} offline</span>
|
|
94566
94957
|
</div>
|
|
94567
94958
|
<div class="myio-col-summary__kpi">
|
|
94568
|
-
<span class="myio-col-summary__kpi-label">${
|
|
94569
|
-
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${avg === null ? dash :
|
|
94959
|
+
<span class="myio-col-summary__kpi-label">${esc8(measure)} m\xE9dia</span>
|
|
94960
|
+
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${avg === null ? dash : esc8(fmt2(avg))}</span>
|
|
94570
94961
|
</div>
|
|
94571
94962
|
<div class="myio-col-summary__kpi">
|
|
94572
94963
|
<span class="myio-col-summary__kpi-label">M\xEDnima \xB7 M\xE1xima</span>
|
|
94573
|
-
<span class="myio-col-summary__kpi-value">${minV ?
|
|
94964
|
+
<span class="myio-col-summary__kpi-value">${minV ? esc8(fmt2(Number(minV.d.value))) : dash} \xB7 ${maxV ? esc8(fmt2(Number(maxV.d.value))) : dash}</span>
|
|
94574
94965
|
</div>
|
|
94575
94966
|
</div>`;
|
|
94576
94967
|
if (!data.devices.length) {
|
|
@@ -94579,12 +94970,12 @@ function buildAverageInner() {
|
|
|
94579
94970
|
const near3 = avg === null ? [] : online.slice().sort((a, b) => Math.abs(Number(a.d.value) - avg) - Math.abs(Number(b.d.value) - avg)).slice(0, 3);
|
|
94580
94971
|
const row = (v) => `
|
|
94581
94972
|
<div class="myio-col-summary__row">
|
|
94582
|
-
<span class="myio-col-summary__name" title="${
|
|
94583
|
-
<span class="myio-col-summary__val">${
|
|
94973
|
+
<span class="myio-col-summary__name" title="${esc8(v.d.name)}">${esc8(v.d.name)}</span>
|
|
94974
|
+
<span class="myio-col-summary__val">${esc8(fmt2(Number(v.d.value) || 0))}</span>
|
|
94584
94975
|
</div>`;
|
|
94585
94976
|
const offRow = (v) => `
|
|
94586
94977
|
<div class="myio-col-summary__row">
|
|
94587
|
-
<span class="myio-col-summary__name" title="${
|
|
94978
|
+
<span class="myio-col-summary__name" title="${esc8(v.d.name)}">${esc8(v.d.name)}</span>
|
|
94588
94979
|
<span class="myio-col-summary__val" style="color:#94a3b8;">sem leitura</span>
|
|
94589
94980
|
</div>`;
|
|
94590
94981
|
const group = (label, list, r = row) => list.length ? `<div class="myio-col-summary__group">
|
|
@@ -94601,8 +94992,8 @@ function buildAverageInner() {
|
|
|
94601
94992
|
</div>
|
|
94602
94993
|
</div>
|
|
94603
94994
|
<div class="myio-col-summary__footer">
|
|
94604
|
-
<span class="myio-col-summary__footer-label">${
|
|
94605
|
-
<span class="myio-col-summary__footer-value">${avg === null ? dash :
|
|
94995
|
+
<span class="myio-col-summary__footer-label">${esc8(measure)} m\xE9dia \xB7 ${online.length} online</span>
|
|
94996
|
+
<span class="myio-col-summary__footer-value">${avg === null ? dash : esc8(fmt2(avg))}</span>
|
|
94606
94997
|
</div>`;
|
|
94607
94998
|
}
|
|
94608
94999
|
function buildInner() {
|
|
@@ -94615,7 +95006,7 @@ function buildInner() {
|
|
|
94615
95006
|
const avg = count ? total / count : 0;
|
|
94616
95007
|
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
94617
95008
|
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
94618
|
-
<span class="myio-col-summary__kpi-value">${
|
|
95009
|
+
<span class="myio-col-summary__kpi-value">${esc8(data.periodLabel)}</span>
|
|
94619
95010
|
</div>` : "";
|
|
94620
95011
|
const kpis = `<div class="myio-col-summary__kpis">
|
|
94621
95012
|
${periodRow}
|
|
@@ -94625,13 +95016,13 @@ function buildInner() {
|
|
|
94625
95016
|
</div>
|
|
94626
95017
|
<div class="myio-col-summary__kpi">
|
|
94627
95018
|
<span class="myio-col-summary__kpi-label">Consumo m\xE9dio</span>
|
|
94628
|
-
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${
|
|
95019
|
+
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${esc8(
|
|
94629
95020
|
fmt2(avg)
|
|
94630
95021
|
)}</span>
|
|
94631
95022
|
</div>
|
|
94632
95023
|
<div class="myio-col-summary__kpi">
|
|
94633
95024
|
<span class="myio-col-summary__kpi-label">Consumo total</span>
|
|
94634
|
-
<span class="myio-col-summary__kpi-value">${
|
|
95025
|
+
<span class="myio-col-summary__kpi-value">${esc8(fmt2(total))}</span>
|
|
94635
95026
|
</div>
|
|
94636
95027
|
</div>`;
|
|
94637
95028
|
if (!data.devices.length) {
|
|
@@ -94645,8 +95036,8 @@ function buildInner() {
|
|
|
94645
95036
|
).slice(0, 3);
|
|
94646
95037
|
const row = (v) => `
|
|
94647
95038
|
<div class="myio-col-summary__row">
|
|
94648
|
-
<span class="myio-col-summary__name" title="${
|
|
94649
|
-
<span class="myio-col-summary__val">${
|
|
95039
|
+
<span class="myio-col-summary__name" title="${esc8(v.d.name)}">${esc8(v.d.name)}</span>
|
|
95040
|
+
<span class="myio-col-summary__val">${esc8(fmt2(Number(v.d.value) || 0))}</span>
|
|
94650
95041
|
<span class="myio-col-summary__pct">${fmtPct2(Number(v.d.value) || 0, total, pd)}</span>
|
|
94651
95042
|
</div>`;
|
|
94652
95043
|
const group = (label, list) => list.length ? `<div class="myio-col-summary__group">
|
|
@@ -94669,7 +95060,7 @@ function buildInner() {
|
|
|
94669
95060
|
</div>
|
|
94670
95061
|
<div class="myio-col-summary__footer">
|
|
94671
95062
|
<span class="myio-col-summary__footer-label">Consumo Total \xB7 ${count} dispositivos</span>
|
|
94672
|
-
<span class="myio-col-summary__footer-value">${
|
|
95063
|
+
<span class="myio-col-summary__footer-value">${esc8(fmt2(total))}</span>
|
|
94673
95064
|
</div>`;
|
|
94674
95065
|
}
|
|
94675
95066
|
function setHighlight(idx) {
|
|
@@ -101609,7 +102000,7 @@ function createConsumptionChartWidget(config2) {
|
|
|
101609
102000
|
</div>
|
|
101610
102001
|
`;
|
|
101611
102002
|
}
|
|
101612
|
-
function
|
|
102003
|
+
function injectStyles27() {
|
|
101613
102004
|
if (styleElement) return;
|
|
101614
102005
|
styleElement = document.createElement("style");
|
|
101615
102006
|
styleElement.id = `${widgetId}-styles`;
|
|
@@ -102123,7 +102514,7 @@ function createConsumptionChartWidget(config2) {
|
|
|
102123
102514
|
console.error(`[ConsumptionWidget] Container #${config2.containerId} not found`);
|
|
102124
102515
|
return;
|
|
102125
102516
|
}
|
|
102126
|
-
|
|
102517
|
+
injectStyles27();
|
|
102127
102518
|
containerElement.innerHTML = renderHTML();
|
|
102128
102519
|
setupListeners();
|
|
102129
102520
|
applyCollapseState();
|
|
@@ -102259,7 +102650,7 @@ function createConsumptionChartWidget(config2) {
|
|
|
102259
102650
|
// src/components/tooltips/goals-bar-tooltip/createGoalsBarTooltip.ts
|
|
102260
102651
|
var STYLE_ID10 = "myio-goals-bar-tooltip-styles";
|
|
102261
102652
|
var DEFAULT_ACCENT = "#6c5ce7";
|
|
102262
|
-
function
|
|
102653
|
+
function injectStyles13(doc) {
|
|
102263
102654
|
if (doc.getElementById(STYLE_ID10)) return;
|
|
102264
102655
|
const s = doc.createElement("style");
|
|
102265
102656
|
s.id = STYLE_ID10;
|
|
@@ -102449,7 +102840,7 @@ function injectStyles12(doc) {
|
|
|
102449
102840
|
`;
|
|
102450
102841
|
(doc.head || doc.documentElement).appendChild(s);
|
|
102451
102842
|
}
|
|
102452
|
-
function
|
|
102843
|
+
function esc9(v) {
|
|
102453
102844
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
102454
102845
|
}
|
|
102455
102846
|
function fmtPct3(pct) {
|
|
@@ -102470,8 +102861,8 @@ function renderDeltaChip(delta) {
|
|
|
102470
102861
|
const tone = delta.tone === "good" ? "good" : delta.tone === "bad" ? "bad" : "neutral";
|
|
102471
102862
|
const arrow = delta.arrow === "up" ? "\u2191" : delta.arrow === "down" ? "\u2193" : "\u2248";
|
|
102472
102863
|
const pctTxt = fmtPct3(Math.abs(Number(delta.pct)));
|
|
102473
|
-
const txt = delta.text ? ` ${
|
|
102474
|
-
return `<span class="myio-gbt__chip myio-gbt__chip--${tone}">${arrow} ${
|
|
102864
|
+
const txt = delta.text ? ` ${esc9(delta.text)}` : "";
|
|
102865
|
+
return `<span class="myio-gbt__chip myio-gbt__chip--${tone}">${arrow} ${esc9(pctTxt)}${txt}</span>`;
|
|
102475
102866
|
}
|
|
102476
102867
|
function renderRow(row, level) {
|
|
102477
102868
|
const hasChildren = Array.isArray(row.children) && row.children.length > 0;
|
|
@@ -102479,12 +102870,12 @@ function renderRow(row, level) {
|
|
|
102479
102870
|
const id = `gbtr-${++_rowSeq}`;
|
|
102480
102871
|
const pct = row.pct;
|
|
102481
102872
|
const caret = hasChildren ? `<button class="myio-gbt__caret${open ? " is-open" : ""}" data-caret="${id}" title="Expandir/recolher">\u25B8</button>` : `<span class="myio-gbt__caret-spacer"></span>`;
|
|
102482
|
-
const swatch = row.color ? `<span class="myio-gbt__swatch" style="background:${
|
|
102483
|
-
const icon2 = row.icon ? `<span class="myio-gbt__icon">${
|
|
102873
|
+
const swatch = row.color ? `<span class="myio-gbt__swatch" style="background:${esc9(row.color)}"></span>` : "";
|
|
102874
|
+
const icon2 = row.icon ? `<span class="myio-gbt__icon">${esc9(row.icon)}</span>` : "";
|
|
102484
102875
|
const chipHtml = row.delta ? renderDeltaChip(row.delta) : "";
|
|
102485
|
-
const pctHtml = !row.delta && pct != null && isFinite(pct) ? `<span class="myio-gbt__pct">${
|
|
102876
|
+
const pctHtml = !row.delta && pct != null && isFinite(pct) ? `<span class="myio-gbt__pct">${esc9(fmtPct3(pct))}</span>` : "";
|
|
102486
102877
|
const rowClass = level > 0 ? "myio-gbt__row myio-gbt__row--child" : "myio-gbt__row";
|
|
102487
|
-
let html = `<div class="${rowClass}">` + caret + swatch + icon2 + `<span class="myio-gbt__label">${
|
|
102878
|
+
let html = `<div class="${rowClass}">` + caret + swatch + icon2 + `<span class="myio-gbt__label">${esc9(row.label)}</span><span class="myio-gbt__value">${esc9(row.valueText)}</span>` + chipHtml + pctHtml + `</div>`;
|
|
102488
102879
|
if (hasChildren) {
|
|
102489
102880
|
const childHtml = row.children.map((c) => renderRow(c, level + 1)).join("");
|
|
102490
102881
|
html += `<div class="myio-gbt__children${open ? " is-open" : ""}" data-children="${id}">${childHtml}</div>`;
|
|
@@ -102499,7 +102890,7 @@ function createGoalsBarTooltip(opts) {
|
|
|
102499
102890
|
return document;
|
|
102500
102891
|
}
|
|
102501
102892
|
})();
|
|
102502
|
-
|
|
102893
|
+
injectStyles13(doc);
|
|
102503
102894
|
const el2 = doc.createElement("div");
|
|
102504
102895
|
el2.className = "myio-gbt";
|
|
102505
102896
|
el2.style.setProperty("--myio-gbt-accent", resolveAccent3(opts?.accentColor, doc));
|
|
@@ -102567,8 +102958,8 @@ function createGoalsBarTooltip(opts) {
|
|
|
102567
102958
|
<div class="myio-gbt__card">
|
|
102568
102959
|
<div class="myio-gbt__header">
|
|
102569
102960
|
<div class="myio-gbt__title-wrap">
|
|
102570
|
-
<div class="myio-gbt__title">${
|
|
102571
|
-
${data.subtitle ? `<div class="myio-gbt__subtitle">${
|
|
102961
|
+
<div class="myio-gbt__title">${esc9(data.title)}</div>
|
|
102962
|
+
${data.subtitle ? `<div class="myio-gbt__subtitle">${esc9(data.subtitle)}</div>` : ""}
|
|
102572
102963
|
</div>
|
|
102573
102964
|
<button class="myio-gbt__btn myio-gbt__btn--pin${pinned ? " is-pinned" : ""}" data-action="pin" title="${pinned ? "Desafixar" : "Fixar na tela"}">\u{1F4CC}</button>
|
|
102574
102965
|
<button class="myio-gbt__btn myio-gbt__btn--close" data-action="close" title="Fechar">\u2715</button>
|
|
@@ -103577,19 +103968,19 @@ function _updateCoverageHint(topDoc) {
|
|
|
103577
103968
|
const deviceCount = data.granularity === "DEVICE" ? data.devices?.length ?? 0 : 0;
|
|
103578
103969
|
hint.textContent = `\u26A0 Meta incompleta para este dom\xEDnio/ano` + (deviceCount > 0 ? ` \xB7 Por medidor (${deviceCount})` : "") + ` \u2014 passe o mouse para detalhes`;
|
|
103579
103970
|
tabs.insertAdjacentElement("afterend", hint);
|
|
103580
|
-
const
|
|
103971
|
+
const esc12 = (s) => String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
103581
103972
|
try {
|
|
103582
103973
|
_coverageDetach = InfoTooltip.attach(hint, () => {
|
|
103583
103974
|
const d = _getGoalsData(_currentDomain);
|
|
103584
103975
|
const parts = [];
|
|
103585
103976
|
if (hasCoverageGaps(d?.coverageGaps)) {
|
|
103586
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
103977
|
+
parts.push(`<p style="margin:0 0 8px;">${esc12(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
|
|
103587
103978
|
}
|
|
103588
103979
|
(d?.devices || []).forEach((dev) => {
|
|
103589
103980
|
if (!hasCoverageGaps(dev?.coverageGaps)) return;
|
|
103590
103981
|
const label = dev.label || dev.code || "medidor";
|
|
103591
103982
|
parts.push(
|
|
103592
|
-
`<p style="margin:0 0 8px;">${
|
|
103983
|
+
`<p style="margin:0 0 8px;">${esc12(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
|
|
103593
103984
|
);
|
|
103594
103985
|
});
|
|
103595
103986
|
return {
|
|
@@ -109111,11 +109502,11 @@ function deviceCategoryToPanelTerm(cat) {
|
|
|
109111
109502
|
function panelTermToDeviceCategory(term) {
|
|
109112
109503
|
return term == null ? null : panelCategoryToWire(term);
|
|
109113
109504
|
}
|
|
109114
|
-
function
|
|
109505
|
+
function esc10(s) {
|
|
109115
109506
|
return String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
109116
109507
|
}
|
|
109117
109508
|
function categoryOptionsHTML(selected) {
|
|
109118
|
-
const opt = (value, label, isSel) => `<option value="${value}"${isSel ? " selected" : ""}>${
|
|
109509
|
+
const opt = (value, label, isSel) => `<option value="${value}"${isSel ? " selected" : ""}>${esc10(label)}</option>`;
|
|
109119
109510
|
return opt("", NONE_LABEL, selected == null) + opt("COMMON_AREA", deviceCategoryLabel("COMMON_AREA"), selected === "COMMON_AREA") + opt("SPECIFIC", deviceCategoryLabel("SPECIFIC"), selected === "SPECIFIC");
|
|
109120
109511
|
}
|
|
109121
109512
|
function openDeviceCategoryPanel(params) {
|
|
@@ -109152,8 +109543,8 @@ function openDeviceCategoryPanel(params) {
|
|
|
109152
109543
|
<select class="myio-devcat__filter" data-devcat-filter="1" aria-label="Filtrar por categoria">
|
|
109153
109544
|
<option value="all">Todas as categorias</option>
|
|
109154
109545
|
<option value="uncategorized">Sem categoria</option>
|
|
109155
|
-
<option value="COMMON_AREA">${
|
|
109156
|
-
<option value="SPECIFIC">${
|
|
109546
|
+
<option value="COMMON_AREA">${esc10(deviceCategoryLabel("COMMON_AREA"))}</option>
|
|
109547
|
+
<option value="SPECIFIC">${esc10(deviceCategoryLabel("SPECIFIC"))}</option>
|
|
109157
109548
|
</select>
|
|
109158
109549
|
<label class="myio-devcat__filter" style="display:flex;align-items:center;gap:6px;cursor:pointer;">
|
|
109159
109550
|
<input type="checkbox" data-devcat-selectall="1" /> Selecionar vis\xEDveis
|
|
@@ -109162,9 +109553,9 @@ function openDeviceCategoryPanel(params) {
|
|
|
109162
109553
|
<div class="myio-devcat__bulkbar" data-devcat-bulkbar="1">
|
|
109163
109554
|
<span data-devcat-bulkcount="1">0 selecionados</span>
|
|
109164
109555
|
<select data-devcat-bulkcat="1" aria-label="Categoria para os selecionados">
|
|
109165
|
-
<option value="">${
|
|
109166
|
-
<option value="COMMON_AREA">${
|
|
109167
|
-
<option value="SPECIFIC">${
|
|
109556
|
+
<option value="">${esc10(NONE_LABEL)}</option>
|
|
109557
|
+
<option value="COMMON_AREA">${esc10(deviceCategoryLabel("COMMON_AREA"))}</option>
|
|
109558
|
+
<option value="SPECIFIC">${esc10(deviceCategoryLabel("SPECIFIC"))}</option>
|
|
109168
109559
|
</select>
|
|
109169
109560
|
<button type="button" class="myio-devcat__bulk-apply" data-devcat-bulkapply="1">Aplicar a selecionados</button>
|
|
109170
109561
|
</div>
|
|
@@ -109194,16 +109585,16 @@ function openDeviceCategoryPanel(params) {
|
|
|
109194
109585
|
return rows.filter((r) => matchesFilter(r) && matchesSearch(r));
|
|
109195
109586
|
}
|
|
109196
109587
|
function rowHTML(r) {
|
|
109197
|
-
const name =
|
|
109198
|
-
const code = r.code ? `<span class="myio-devcat__row-code">${
|
|
109588
|
+
const name = esc10(r.label || r.code || r.deviceId);
|
|
109589
|
+
const code = r.code ? `<span class="myio-devcat__row-code">${esc10(r.code)}</span>` : "";
|
|
109199
109590
|
const checked = selected.has(r.deviceId) ? " checked" : "";
|
|
109200
109591
|
const focused = r.deviceId === params.focusDeviceId ? ' data-focused="1"' : "";
|
|
109201
109592
|
const catAttr = r.tariffCategory == null ? "null" : r.tariffCategory;
|
|
109202
|
-
return `<div class="myio-devcat__row" data-devcat-row="${
|
|
109593
|
+
return `<div class="myio-devcat__row" data-devcat-row="${esc10(r.deviceId)}" data-cat="${catAttr}"${focused}><input type="checkbox" class="myio-devcat__row-check" data-devcat-rowcheck="${esc10(
|
|
109203
109594
|
r.deviceId
|
|
109204
|
-
)}"${checked} aria-label="Selecionar ${name}" /><div class="myio-devcat__row-main"><span class="myio-devcat__row-label" title="${name}">${name}</span>` + code + `</div><select class="myio-devcat__row-select" data-devcat-rowselect="${
|
|
109595
|
+
)}"${checked} aria-label="Selecionar ${name}" /><div class="myio-devcat__row-main"><span class="myio-devcat__row-label" title="${name}">${name}</span>` + code + `</div><select class="myio-devcat__row-select" data-devcat-rowselect="${esc10(
|
|
109205
109596
|
r.deviceId
|
|
109206
|
-
)}" aria-label="Categoria de ${name}">${categoryOptionsHTML(r.tariffCategory)}</select><div class="myio-devcat__row-conflict" data-devcat-conflict="${
|
|
109597
|
+
)}" aria-label="Categoria de ${name}">${categoryOptionsHTML(r.tariffCategory)}</select><div class="myio-devcat__row-conflict" data-devcat-conflict="${esc10(r.deviceId)}"></div></div>`;
|
|
109207
109598
|
}
|
|
109208
109599
|
function render3() {
|
|
109209
109600
|
const vis = visibleRows();
|
|
@@ -109363,7 +109754,7 @@ function openDeviceCategoryPanel(params) {
|
|
|
109363
109754
|
rows = await port.listDevices({ customerId, domain: params.domain });
|
|
109364
109755
|
} catch (err) {
|
|
109365
109756
|
rows = [];
|
|
109366
|
-
body.innerHTML = `<div class="myio-devcat__empty">N\xE3o foi poss\xEDvel carregar os dispositivos: ${
|
|
109757
|
+
body.innerHTML = `<div class="myio-devcat__empty">N\xE3o foi poss\xEDvel carregar os dispositivos: ${esc10(
|
|
109367
109758
|
err?.message || "erro"
|
|
109368
109759
|
)}</div>`;
|
|
109369
109760
|
countEl.textContent = "";
|
|
@@ -116755,7 +117146,7 @@ var openCount3 = 0;
|
|
|
116755
117146
|
function escapeHtml15(v) {
|
|
116756
117147
|
return String(v).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
116757
117148
|
}
|
|
116758
|
-
function
|
|
117149
|
+
function injectStyles14() {
|
|
116759
117150
|
if (!document.getElementById(FONT_LINK_ID3)) {
|
|
116760
117151
|
const link = document.createElement("link");
|
|
116761
117152
|
link.id = FONT_LINK_ID3;
|
|
@@ -116797,7 +117188,7 @@ function injectStyles13() {
|
|
|
116797
117188
|
}
|
|
116798
117189
|
var FOCUSABLE2 = 'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
116799
117190
|
function openStandardModal(params) {
|
|
116800
|
-
|
|
117191
|
+
injectStyles14();
|
|
116801
117192
|
const dismissible = params.dismissible ?? true;
|
|
116802
117193
|
const buttons = params.buttons ?? [];
|
|
116803
117194
|
const modalId = `myio-stdmodal-${++openCount3}`;
|
|
@@ -116932,14 +117323,14 @@ function buildTemplateCsv(domain, devices, start, end, now = Date.now()) {
|
|
|
116932
117323
|
if (domain === "energy") header.push("value_reactive_kvarh");
|
|
116933
117324
|
const today = nowSaoPaulo(now);
|
|
116934
117325
|
const lines = [header.join(";")];
|
|
116935
|
-
const
|
|
117326
|
+
const esc12 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
116936
117327
|
const { ok } = splitImportableDevices(devices);
|
|
116937
117328
|
for (const dev of ok) {
|
|
116938
117329
|
for (const date of daysBetween(start, end)) {
|
|
116939
117330
|
if (date > today.date) break;
|
|
116940
117331
|
for (let h3 = 0; h3 < 24; h3++) {
|
|
116941
117332
|
if (date === today.date && h3 >= today.hour) break;
|
|
116942
|
-
const cols = [String(dev.centralId), String(Number(dev.slaveId)),
|
|
117333
|
+
const cols = [String(dev.centralId), String(Number(dev.slaveId)), esc12(dev.label || ""), date, `${pad25(h3)}:00`, ""];
|
|
116943
117334
|
if (domain === "energy") cols.push("");
|
|
116944
117335
|
lines.push(cols.join(";"));
|
|
116945
117336
|
}
|
|
@@ -117200,10 +117591,10 @@ function accumulatedRows(domain, entries, profile = DEFAULT_DISTRIBUTION_PROFILE
|
|
|
117200
117591
|
}
|
|
117201
117592
|
function buildAccumulatedTemplateCsv(domain, devices, start, end) {
|
|
117202
117593
|
const lines = [["gateway_id", "slave_id", "device_name", "start_date", "end_date", TOTAL_COLUMN[domain]].join(";")];
|
|
117203
|
-
const
|
|
117594
|
+
const esc12 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
117204
117595
|
for (const dev of devices || []) {
|
|
117205
117596
|
if (!isImportableKey(dev)) continue;
|
|
117206
|
-
lines.push([String(dev.centralId), String(Number(dev.slaveId)),
|
|
117597
|
+
lines.push([String(dev.centralId), String(Number(dev.slaveId)), esc12(dev.label || ""), start, end, ""].join(";"));
|
|
117207
117598
|
}
|
|
117208
117599
|
return { csv: "\uFEFF" + lines.join("\r\n") + "\r\n", rows: lines.length - 1 };
|
|
117209
117600
|
}
|
|
@@ -117393,11 +117784,11 @@ function fmtSaoPaulo(iso) {
|
|
|
117393
117784
|
return `${p(d.getUTCDate())}/${p(d.getUTCMonth() + 1)}/${d.getUTCFullYear()} ${p(d.getUTCHours())}:00`;
|
|
117394
117785
|
}
|
|
117395
117786
|
var STYLE_ID15 = "myio-tlmimport-styles";
|
|
117396
|
-
function
|
|
117787
|
+
function esc11(v) {
|
|
117397
117788
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
117398
117789
|
}
|
|
117399
117790
|
var fmtNum = (n, d = 0) => Number.isFinite(Number(n)) ? Number(n).toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d }) : "\u2014";
|
|
117400
|
-
function
|
|
117791
|
+
function injectStyles15() {
|
|
117401
117792
|
if (document.getElementById(STYLE_ID15)) return;
|
|
117402
117793
|
const style = document.createElement("style");
|
|
117403
117794
|
style.id = STYLE_ID15;
|
|
@@ -117456,7 +117847,7 @@ function injectStyles14() {
|
|
|
117456
117847
|
document.head.appendChild(style);
|
|
117457
117848
|
}
|
|
117458
117849
|
function issuesTable(errors, limit = 100) {
|
|
117459
|
-
const rows = errors.slice(0, limit).map((e) => `<tr><td>${
|
|
117850
|
+
const rows = errors.slice(0, limit).map((e) => `<tr><td>${esc11(e.line)}</td><td>${esc11(e.reason)}</td></tr>`).join("");
|
|
117460
117851
|
const more = errors.length > limit ? `<p class="tlmi-muted">\u2026 e mais ${errors.length - limit} erro(s).</p>` : "";
|
|
117461
117852
|
return `<div class="tlmi-errors"><table><thead><tr><th>Linha</th><th>Problema</th></tr></thead><tbody>${rows}</tbody></table></div>${more}`;
|
|
117462
117853
|
}
|
|
@@ -117468,7 +117859,7 @@ function defaultPeriod(now) {
|
|
|
117468
117859
|
return { start: ymd(start), end: ymd(end) };
|
|
117469
117860
|
}
|
|
117470
117861
|
function openTelemetryImportModal(params) {
|
|
117471
|
-
|
|
117862
|
+
injectStyles15();
|
|
117472
117863
|
const domain = params.domain;
|
|
117473
117864
|
const txt = DOMAIN_TEXT[domain];
|
|
117474
117865
|
const now = params.now ?? (() => Date.now());
|
|
@@ -117534,10 +117925,10 @@ function openTelemetryImportModal(params) {
|
|
|
117534
117925
|
}
|
|
117535
117926
|
function apiErrorBanner() {
|
|
117536
117927
|
if (!s.apiError) return "";
|
|
117537
|
-
return `<div class="tlmi-banner err" role="alert">${
|
|
117928
|
+
return `<div class="tlmi-banner err" role="alert">${esc11(s.apiError)}${s.apiDetail ? `<div class="tlmi-tech">${esc11(s.apiDetail)}</div>` : ""}</div>`;
|
|
117538
117929
|
}
|
|
117539
117930
|
function step1() {
|
|
117540
|
-
const warn = missingKey.length ? `<div class="tlmi-banner warn">${missingKey.length} dispositivo(s) sem central/endere\xE7o cadastrados ficam fora do modelo: ${
|
|
117931
|
+
const warn = missingKey.length ? `<div class="tlmi-banner warn">${missingKey.length} dispositivo(s) sem central/endere\xE7o cadastrados ficam fora do modelo: ${esc11(
|
|
117541
117932
|
missingKey.slice(0, 5).map((d) => d.label).join(", ")
|
|
117542
117933
|
)}${missingKey.length > 5 ? "\u2026" : ""}</div>` : "";
|
|
117543
117934
|
const model = (value, title, hint) => `
|
|
@@ -117564,16 +117955,16 @@ function openTelemetryImportModal(params) {
|
|
|
117564
117955
|
${warn}
|
|
117565
117956
|
<div class="tlmi-card"><h3>${s.model === "accumulated" ? "Per\xEDodo" : "Modelo da planilha"}</h3>
|
|
117566
117957
|
<div class="tlmi-row">
|
|
117567
|
-
<label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${
|
|
117568
|
-
<label class="tlmi-field">Fim<input type="date" data-field="end" value="${
|
|
117958
|
+
<label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${esc11(s.period.start)}" /></label>
|
|
117959
|
+
<label class="tlmi-field">Fim<input type="date" data-field="end" value="${esc11(s.period.end)}" /></label>
|
|
117569
117960
|
<button class="tlmi-btn" type="button" data-action="template" ${importable.length ? "" : "disabled"}>\u2B07 Baixar modelo (CSV)</button>
|
|
117570
117961
|
</div>
|
|
117571
117962
|
<p class="tlmi-muted" style="margin-top:8px">${importable.length} dispositivo(s) no modelo. ${s.model === "accumulated" ? "Para digitar na tela, clique em <strong>Avan\xE7ar</strong>." : "J\xE1 tem a planilha preenchida? Clique em <strong>Avan\xE7ar</strong>."}</p>
|
|
117572
117963
|
</div>`;
|
|
117573
117964
|
}
|
|
117574
117965
|
function step2() {
|
|
117575
|
-
const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${
|
|
117576
|
-
<div class="tlmi-kpi"><span>Arquivo</span><strong style="font-size:13px">${
|
|
117966
|
+
const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${esc11(s.parseError)}</div>` : `<div class="tlmi-kpis">
|
|
117967
|
+
<div class="tlmi-kpi"><span>Arquivo</span><strong style="font-size:13px">${esc11(s.fileName)}</strong></div>
|
|
117577
117968
|
<div class="tlmi-kpi"><span>Linhas para importar</span><strong>${fmtNum(s.rows.length)}</strong></div>
|
|
117578
117969
|
<div class="tlmi-kpi"><span>Em branco (ignoradas)</span><strong>${fmtNum(s.skippedEmpty)}</strong></div>
|
|
117579
117970
|
<div class="tlmi-kpi"><span>Com erro</span><strong style="color:${s.localErrors.length ? "#dc2626" : "#16a34a"}">${fmtNum(s.localErrors.length)}</strong></div>
|
|
@@ -117613,12 +118004,12 @@ function openTelemetryImportModal(params) {
|
|
|
117613
118004
|
}
|
|
117614
118005
|
function step2Accumulated() {
|
|
117615
118006
|
const fromFile = !!s.fileName && !s.parseError;
|
|
117616
|
-
const form = fromFile ? `<p class="tlmi-muted">Usando <strong>${
|
|
117617
|
-
<button class="tlmi-btn" type="button" data-action="use-form">Preencher na tela</button></p>` : `<p class="tlmi-muted" style="margin-bottom:8px">Per\xEDodo: ${
|
|
118007
|
+
const form = fromFile ? `<p class="tlmi-muted">Usando <strong>${esc11(s.fileName)}</strong>.
|
|
118008
|
+
<button class="tlmi-btn" type="button" data-action="use-form">Preencher na tela</button></p>` : `<p class="tlmi-muted" style="margin-bottom:8px">Per\xEDodo: ${esc11(s.period.start)} a ${esc11(s.period.end)}. Deixe em branco o que n\xE3o quer importar.</p>
|
|
117618
118009
|
<div class="tlmi-acc"><table><thead><tr><th>Dispositivo</th><th>Total (${txt.unit})</th></tr></thead><tbody>
|
|
117619
118010
|
${importable.map(
|
|
117620
|
-
(d, i) => `<tr><td>${
|
|
117621
|
-
<td><input inputmode="decimal" data-total="${i}" aria-label="Total de ${
|
|
118011
|
+
(d, i) => `<tr><td>${esc11(d.label)}</td>
|
|
118012
|
+
<td><input inputmode="decimal" data-total="${i}" aria-label="Total de ${esc11(d.label)}" value="${esc11(s.formTotals[i] ?? "")}" /></td></tr>`
|
|
117622
118013
|
).join("")}
|
|
117623
118014
|
</tbody></table></div>`;
|
|
117624
118015
|
return `
|
|
@@ -117631,7 +118022,7 @@ function openTelemetryImportModal(params) {
|
|
|
117631
118022
|
<input type="file" accept=".xlsx,.xls,.csv" data-field="file" hidden />
|
|
117632
118023
|
\u{1F4C4} Clique ou arraste a planilha aqui (.xlsx ou .csv)
|
|
117633
118024
|
</label>
|
|
117634
|
-
${s.parseError ? `<div class="tlmi-banner err" style="margin-top:10px">${
|
|
118025
|
+
${s.parseError ? `<div class="tlmi-banner err" style="margin-top:10px">${esc11(s.parseError)}</div>` : ""}
|
|
117635
118026
|
</div>
|
|
117636
118027
|
<div data-role="acc-summary" style="display:flex;flex-direction:column;gap:12px">${accSummaryHtml()}</div>`;
|
|
117637
118028
|
}
|
|
@@ -117657,7 +118048,7 @@ function openTelemetryImportModal(params) {
|
|
|
117657
118048
|
<div class="tlmi-kpi"><span>Total (${txt.unit})</span><strong>${fmtNum(p.totalValue, 2)}</strong></div>
|
|
117658
118049
|
<div class="tlmi-kpi"><span>Leituras substitu\xEDdas</span><strong>${fmtNum(p.existingReadingsInTarget)}</strong></div>
|
|
117659
118050
|
</div>
|
|
117660
|
-
<p class="tlmi-muted">Per\xEDodo (hor\xE1rio de Bras\xEDlia): ${
|
|
118051
|
+
<p class="tlmi-muted">Per\xEDodo (hor\xE1rio de Bras\xEDlia): ${esc11(period)}</p>
|
|
117661
118052
|
${reactiveWarn}
|
|
117662
118053
|
${real > 0 ? `<div class="tlmi-banner warn"><strong>${fmtNum(real)} leitura(s) reais do medidor</strong> ser\xE3o substitu\xEDdas pelos valores da planilha.
|
|
117663
118054
|
<label class="tlmi-check" style="margin-top:6px"><input type="checkbox" data-field="confirmReal" ${s.confirmReal ? "checked" : ""} />
|
|
@@ -117676,7 +118067,7 @@ function openTelemetryImportModal(params) {
|
|
|
117676
118067
|
<div class="tlmi-muted" style="margin-top:4px">Dispositivos manuais continuam aparecendo sem comunica\xE7\xE3o no status:
|
|
117677
118068
|
o status conta s\xF3 leitura medida. Os totais e os cards usam os dados importados.</div></div>`;
|
|
117678
118069
|
} else if (j.status === "failed") {
|
|
117679
|
-
banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${
|
|
118070
|
+
banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${esc11(j.error)}` : "."}</div>`;
|
|
117680
118071
|
} else if (j.status === "cancelled") {
|
|
117681
118072
|
banner = '<div class="tlmi-banner warn">Importa\xE7\xE3o cancelada. As leituras anteriores foram mantidas.</div>';
|
|
117682
118073
|
} else if (j.status === "reverted") {
|
|
@@ -117688,14 +118079,14 @@ function openTelemetryImportModal(params) {
|
|
|
117688
118079
|
<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>
|
|
117689
118080
|
</div>` : "";
|
|
117690
118081
|
return `
|
|
117691
|
-
<div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${
|
|
118082
|
+
<div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${esc11(statusText)}</span></h3>
|
|
117692
118083
|
<div class="tlmi-progress" role="progressbar" aria-valuenow="${pct}" aria-valuemin="0" aria-valuemax="100"><i style="width:${pct}%"></i></div>
|
|
117693
118084
|
<div class="tlmi-kpis" style="margin-top:12px">
|
|
117694
118085
|
<div class="tlmi-kpi"><span>Progresso</span><strong>${fmtNum(pct)}%</strong></div>
|
|
117695
118086
|
<div class="tlmi-kpi"><span>Leituras removidas</span><strong>${fmtNum(j.deleted)}</strong></div>
|
|
117696
118087
|
<div class="tlmi-kpi"><span>Leituras gravadas</span><strong>${fmtNum(j.inserted)}</strong></div>
|
|
117697
118088
|
</div>
|
|
117698
|
-
${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${
|
|
118089
|
+
${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${esc11(j.phase)}</p>` : ""}
|
|
117699
118090
|
${!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>
|
|
117700
118091
|
<span class="tlmi-muted" style="margin-left:8px">Voc\xEA pode fechar esta janela; a importa\xE7\xE3o continua.</span></div>` : ""}
|
|
117701
118092
|
${revert}
|
|
@@ -118005,8 +118396,8 @@ function siglaFromManualAsset(assetName) {
|
|
|
118005
118396
|
return /^[A-Z0-9_]+$/.test(sigla) ? sigla : null;
|
|
118006
118397
|
}
|
|
118007
118398
|
function nextManualSeq(domain, sigla, existingNames) {
|
|
118008
|
-
const
|
|
118009
|
-
const re = new RegExp(`^${
|
|
118399
|
+
const esc12 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
118400
|
+
const re = new RegExp(`^${esc12(NAME_PREFIX[domain])}${esc12(sigla)}_LOJA_(\\d+)_MANUAL$`, "i");
|
|
118010
118401
|
const max = existingNames.reduce((acc, n) => {
|
|
118011
118402
|
const m = re.exec(String(n || "").trim());
|
|
118012
118403
|
return m ? Math.max(acc, Number(m[1])) : acc;
|
|
@@ -118155,7 +118546,7 @@ var STYLE_ID16 = "myio-manualdev-styles";
|
|
|
118155
118546
|
function escapeHtml16(v) {
|
|
118156
118547
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
118157
118548
|
}
|
|
118158
|
-
function
|
|
118549
|
+
function injectStyles16() {
|
|
118159
118550
|
if (document.getElementById(STYLE_ID16)) return;
|
|
118160
118551
|
const style = document.createElement("style");
|
|
118161
118552
|
style.id = STYLE_ID16;
|
|
@@ -118295,7 +118686,7 @@ function progressHtml(steps, message, ok, open = false) {
|
|
|
118295
118686
|
function openManualDeviceModal(params) {
|
|
118296
118687
|
const domain = params.domain;
|
|
118297
118688
|
if (!MANUAL_DEVICE_PROFILES[domain]) throw new Error(`[openManualDeviceModal] dom\xEDnio inv\xE1lido: ${domain}`);
|
|
118298
|
-
|
|
118689
|
+
injectStyles16();
|
|
118299
118690
|
if (params.provisioner) return openProvisionedModal(params, params.provisioner);
|
|
118300
118691
|
const values = { label: "", identifier: "" };
|
|
118301
118692
|
let busy = false;
|
|
@@ -120565,7 +120956,7 @@ var FONT_LINK_ID4 = "myio-dialog-font-nunito";
|
|
|
120565
120956
|
function escapeHtml17(value) {
|
|
120566
120957
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
120567
120958
|
}
|
|
120568
|
-
function
|
|
120959
|
+
function injectStyles17() {
|
|
120569
120960
|
if (!document.getElementById(FONT_LINK_ID4)) {
|
|
120570
120961
|
const link = document.createElement("link");
|
|
120571
120962
|
link.id = FONT_LINK_ID4;
|
|
@@ -120650,7 +121041,7 @@ function createScrollableTabs(options) {
|
|
|
120650
121041
|
if (typeof document === "undefined") {
|
|
120651
121042
|
throw new Error("[createScrollableTabs] requires a browser environment");
|
|
120652
121043
|
}
|
|
120653
|
-
|
|
121044
|
+
injectStyles17();
|
|
120654
121045
|
const theme = options.theme ?? "light";
|
|
120655
121046
|
const accent = options.accent ?? "#7C3AED";
|
|
120656
121047
|
const showArrows = options.showArrows ?? "auto";
|
|
@@ -120789,7 +121180,7 @@ function escapeHtml18(value) {
|
|
|
120789
121180
|
return String(value == null ? "" : value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
120790
121181
|
}
|
|
120791
121182
|
var PRM = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
120792
|
-
function
|
|
121183
|
+
function injectStyles18() {
|
|
120793
121184
|
if (!document.getElementById(FONT_LINK_ID5)) {
|
|
120794
121185
|
const link = document.createElement("link");
|
|
120795
121186
|
link.id = FONT_LINK_ID5;
|
|
@@ -120958,7 +121349,7 @@ function createImgGallery(options) {
|
|
|
120958
121349
|
if (typeof document === "undefined") {
|
|
120959
121350
|
throw new Error("[createImgGallery] requires a browser environment");
|
|
120960
121351
|
}
|
|
120961
|
-
|
|
121352
|
+
injectStyles18();
|
|
120962
121353
|
const locale = options.locale === "en-US" ? "en-US" : "pt-BR";
|
|
120963
121354
|
const theme = options.theme ?? "light";
|
|
120964
121355
|
const accent = options.accent ?? "#7C3AED";
|
|
@@ -134597,7 +134988,7 @@ var MODAL_CSS2 = `
|
|
|
134597
134988
|
background: rgba(255, 255, 255, 0.2);
|
|
134598
134989
|
}
|
|
134599
134990
|
`;
|
|
134600
|
-
function
|
|
134991
|
+
function injectStyles19() {
|
|
134601
134992
|
if (document.getElementById(CSS_ID5)) return;
|
|
134602
134993
|
const style = document.createElement("style");
|
|
134603
134994
|
style.id = CSS_ID5;
|
|
@@ -134614,7 +135005,7 @@ var FilterModalComponent = class {
|
|
|
134614
135005
|
showDeviceGrid;
|
|
134615
135006
|
deviceSearchQuery = "";
|
|
134616
135007
|
constructor(options) {
|
|
134617
|
-
|
|
135008
|
+
injectStyles19();
|
|
134618
135009
|
this.options = options;
|
|
134619
135010
|
this.themeMode = options.themeMode || "light";
|
|
134620
135011
|
this.selectedCategories = new Set(
|
|
@@ -138764,7 +139155,7 @@ function buildSections(ctx) {
|
|
|
138764
139155
|
}
|
|
138765
139156
|
];
|
|
138766
139157
|
}
|
|
138767
|
-
function
|
|
139158
|
+
function injectStyles20() {
|
|
138768
139159
|
if (document.getElementById(STYLE_ID20)) return;
|
|
138769
139160
|
const style = document.createElement("style");
|
|
138770
139161
|
style.id = STYLE_ID20;
|
|
@@ -138866,7 +139257,7 @@ function openMetasGuide(options = {}) {
|
|
|
138866
139257
|
const sections = buildSections({ energy, water, curY, prevY });
|
|
138867
139258
|
const total = sections.length;
|
|
138868
139259
|
document.getElementById(ROOT_ID)?.remove();
|
|
138869
|
-
|
|
139260
|
+
injectStyles20();
|
|
138870
139261
|
const previouslyFocused = document.activeElement;
|
|
138871
139262
|
let index = 0;
|
|
138872
139263
|
let closed = false;
|
|
@@ -142711,7 +143102,7 @@ var TELEMETRY_GRID_SHOPPING_STYLES = `
|
|
|
142711
143102
|
text-overflow: ellipsis;
|
|
142712
143103
|
}
|
|
142713
143104
|
`;
|
|
142714
|
-
function
|
|
143105
|
+
function injectStyles21(_container) {
|
|
142715
143106
|
const styleId = "telemetry-grid-shopping-styles";
|
|
142716
143107
|
if (document.getElementById(styleId)) {
|
|
142717
143108
|
return;
|
|
@@ -142759,7 +143150,7 @@ var TelemetryGridShoppingView = class {
|
|
|
142759
143150
|
// Render
|
|
142760
143151
|
// =========================================================================
|
|
142761
143152
|
render() {
|
|
142762
|
-
|
|
143153
|
+
injectStyles21(this.root);
|
|
142763
143154
|
this.root.innerHTML = this.buildHTML();
|
|
142764
143155
|
this.cacheElements();
|
|
142765
143156
|
this.bindEvents();
|
|
@@ -144430,7 +144821,7 @@ var TELEMETRY_INFO_SHOPPING_STYLES = `
|
|
|
144430
144821
|
}
|
|
144431
144822
|
}
|
|
144432
144823
|
`;
|
|
144433
|
-
function
|
|
144824
|
+
function injectStyles22(_container) {
|
|
144434
144825
|
const styleId = "telemetry-info-shopping-styles-v2";
|
|
144435
144826
|
if (document.getElementById(styleId)) {
|
|
144436
144827
|
return;
|
|
@@ -144490,7 +144881,7 @@ var TelemetryInfoShoppingView = class _TelemetryInfoShoppingView {
|
|
|
144490
144881
|
// Render
|
|
144491
144882
|
// =========================================================================
|
|
144492
144883
|
render() {
|
|
144493
|
-
|
|
144884
|
+
injectStyles22(this.root);
|
|
144494
144885
|
this.root.innerHTML = this.buildHTML();
|
|
144495
144886
|
this.cacheElements();
|
|
144496
144887
|
this.bindEvents();
|
|
@@ -152871,10 +153262,10 @@ var AlarmsNotificationsPanelView = class {
|
|
|
152871
153262
|
const renderListPanel = (group, items, sel) => {
|
|
152872
153263
|
if (items.length === 0) return '<div class="afm-empty">Nenhum item encontrado</div>';
|
|
152873
153264
|
return items.map((item) => {
|
|
152874
|
-
const
|
|
153265
|
+
const esc12 = this.esc(item);
|
|
152875
153266
|
return `<label class="afm-check-item">
|
|
152876
|
-
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${
|
|
152877
|
-
<span class="afm-check-label">${
|
|
153267
|
+
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${esc12}"${sel.has(item) ? " checked" : ""}>
|
|
153268
|
+
<span class="afm-check-label">${esc12}</span>
|
|
152878
153269
|
</label>`;
|
|
152879
153270
|
}).join("");
|
|
152880
153271
|
};
|
|
@@ -163343,7 +163734,7 @@ var STYLES = `
|
|
|
163343
163734
|
color: var(--dgv6-ink-2);
|
|
163344
163735
|
}
|
|
163345
163736
|
`;
|
|
163346
|
-
function
|
|
163737
|
+
function injectStyles23() {
|
|
163347
163738
|
if (document.getElementById(CSS_ID6)) return;
|
|
163348
163739
|
const style = document.createElement("style");
|
|
163349
163740
|
style.id = CSS_ID6;
|
|
@@ -163382,7 +163773,7 @@ var DeviceGridV6View = class {
|
|
|
163382
163773
|
// Render
|
|
163383
163774
|
// =========================================================================
|
|
163384
163775
|
render() {
|
|
163385
|
-
|
|
163776
|
+
injectStyles23();
|
|
163386
163777
|
this.root.innerHTML = this.buildHTML();
|
|
163387
163778
|
this.cacheElements();
|
|
163388
163779
|
this.bindEvents();
|
|
@@ -165752,7 +166143,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165752
166143
|
const docTitle = buildActivationReportTitle(deviceName, opts.customerName);
|
|
165753
166144
|
const issuedAt = formatIssuedAt(/* @__PURE__ */ new Date(), locale);
|
|
165754
166145
|
const utilization = data.totalHours > 0 ? (data.totalOnMinutes / (data.totalHours * 60) * 100).toFixed(1) : "0.0";
|
|
165755
|
-
const
|
|
166146
|
+
const esc12 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
165756
166147
|
const htmlContent = `
|
|
165757
166148
|
<!DOCTYPE html>
|
|
165758
166149
|
<html lang="pt-BR">
|
|
@@ -165804,14 +166195,14 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165804
166195
|
<div class="brand">MyIO BAS</div>
|
|
165805
166196
|
<h1>Relat\xF3rio de Acionamentos</h1>
|
|
165806
166197
|
<div class="meta">
|
|
165807
|
-
<div><b>Dispositivo:</b> ${
|
|
166198
|
+
<div><b>Dispositivo:</b> ${esc12(deviceName)}</div>
|
|
165808
166199
|
<div><b>Per\xEDodo:</b> ${periodStart} \u2014 ${periodEnd}</div>
|
|
165809
166200
|
</div>
|
|
165810
166201
|
</div>
|
|
165811
166202
|
${customerName ? `
|
|
165812
166203
|
<div class="customer-badge">
|
|
165813
166204
|
<div class="label">Cliente</div>
|
|
165814
|
-
<div class="value">${
|
|
166205
|
+
<div class="value">${esc12(customerName)}</div>
|
|
165815
166206
|
</div>` : ""}
|
|
165816
166207
|
</div>
|
|
165817
166208
|
|
|
@@ -165822,7 +166213,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165822
166213
|
</div>
|
|
165823
166214
|
<div class="summary-card accent-green">
|
|
165824
166215
|
<div class="summary-value">${formatDurationMinutes(data.totalOnMinutes)}</div>
|
|
165825
|
-
<div class="summary-label">Tempo ${
|
|
166216
|
+
<div class="summary-label">Tempo ${esc12(labelOn)}</div>
|
|
165826
166217
|
</div>
|
|
165827
166218
|
<div class="summary-card accent-amber">
|
|
165828
166219
|
<div class="summary-value">${utilization}%</div>
|
|
@@ -165850,7 +166241,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165850
166241
|
<tr>
|
|
165851
166242
|
<td>${formatDateForExport(seg.startTime, locale)}</td>
|
|
165852
166243
|
<td>${formatDateForExport(seg.endTime, locale)}</td>
|
|
165853
|
-
<td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ?
|
|
166244
|
+
<td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ? esc12(labelOn) : esc12(labelOff)}</span></td>
|
|
165854
166245
|
<td>${formatDurationMinutes(seg.durationMinutes)}</td>
|
|
165855
166246
|
<td>${seg.source === "manual" ? "Manual" : seg.source === "schedule" ? "Agendamento" : seg.source === "automation" ? "Automa\xE7\xE3o" : "Desconhecido"}</td>
|
|
165856
166247
|
</tr>
|
|
@@ -165859,7 +166250,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165859
166250
|
</table>
|
|
165860
166251
|
|
|
165861
166252
|
<div class="footer">
|
|
165862
|
-
<span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` · ${
|
|
166253
|
+
<span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` · ${esc12(customerName)}` : ""} · <span class="brand">MyIO BAS</span>
|
|
165863
166254
|
</div>
|
|
165864
166255
|
</body>
|
|
165865
166256
|
</html>
|
|
@@ -171849,7 +172240,7 @@ var STYLES2 = `
|
|
|
171849
172240
|
}
|
|
171850
172241
|
#${MODAL_ID6} .gcdr-fail-item:last-child { border-bottom: none; }
|
|
171851
172242
|
`;
|
|
171852
|
-
function
|
|
172243
|
+
function injectStyles24() {
|
|
171853
172244
|
if (document.getElementById(`${MODAL_ID6}-styles`)) return;
|
|
171854
172245
|
const style = document.createElement("style");
|
|
171855
172246
|
style.id = `${MODAL_ID6}-styles`;
|
|
@@ -171958,7 +172349,7 @@ function escHtml4(str) {
|
|
|
171958
172349
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
171959
172350
|
}
|
|
171960
172351
|
async function openGCDRSyncModal(params) {
|
|
171961
|
-
|
|
172352
|
+
injectStyles24();
|
|
171962
172353
|
removeExistingModal();
|
|
171963
172354
|
if (!params.thingsboardToken) {
|
|
171964
172355
|
alert("Token ThingsBoard n\xE3o encontrado. Fa\xE7a login novamente.");
|
|
@@ -172531,7 +172922,7 @@ var STYLES3 = `
|
|
|
172531
172922
|
.abm-confirm-btn--confirm { background: #e67e22; color: #fff; }
|
|
172532
172923
|
.abm-confirm-btn--confirm:hover { background: #cf6d17; }
|
|
172533
172924
|
`;
|
|
172534
|
-
function
|
|
172925
|
+
function injectStyles25() {
|
|
172535
172926
|
if (document.getElementById(`${MODAL_ID7}-styles`)) return;
|
|
172536
172927
|
const style = document.createElement("style");
|
|
172537
172928
|
style.id = `${MODAL_ID7}-styles`;
|
|
@@ -173210,7 +173601,7 @@ async function fetchBundle(customerTB_ID, gcdrTenantId, baseUrl) {
|
|
|
173210
173601
|
return json.data;
|
|
173211
173602
|
}
|
|
173212
173603
|
async function openAlarmBundleMapModal(params) {
|
|
173213
|
-
|
|
173604
|
+
injectStyles25();
|
|
173214
173605
|
removeExistingModal2();
|
|
173215
173606
|
if (!params.customerTB_ID) {
|
|
173216
173607
|
alert("Customer TB ID n\xE3o informado. N\xE3o \xE9 poss\xEDvel carregar o mapa de alarmes.");
|
|
@@ -177272,7 +177663,7 @@ var VirtualList = class {
|
|
|
177272
177663
|
|
|
177273
177664
|
// src/components/header-annotations-panel/ExportModal.ts
|
|
177274
177665
|
var MODAL_DOM_ID = "myio-annotations-export-modal";
|
|
177275
|
-
var
|
|
177666
|
+
var STYLES_ID5 = "myio-annotations-export-modal-styles";
|
|
177276
177667
|
var STYLES4 = `
|
|
177277
177668
|
.${MODAL_DOM_ID}-backdrop {
|
|
177278
177669
|
position: fixed; inset: 0; z-index: 99999;
|
|
@@ -177347,17 +177738,17 @@ var STYLES4 = `
|
|
|
177347
177738
|
background: #cbd5e1; border-color: #cbd5e1; cursor: not-allowed;
|
|
177348
177739
|
}
|
|
177349
177740
|
`;
|
|
177350
|
-
function
|
|
177741
|
+
function injectStyles26() {
|
|
177351
177742
|
if (typeof document === "undefined") return;
|
|
177352
|
-
if (document.getElementById(
|
|
177743
|
+
if (document.getElementById(STYLES_ID5)) return;
|
|
177353
177744
|
const el2 = document.createElement("style");
|
|
177354
|
-
el2.id =
|
|
177745
|
+
el2.id = STYLES_ID5;
|
|
177355
177746
|
el2.textContent = STYLES4;
|
|
177356
177747
|
document.head.appendChild(el2);
|
|
177357
177748
|
}
|
|
177358
177749
|
var _activeBackdrop = null;
|
|
177359
177750
|
function openExportModal(options) {
|
|
177360
|
-
|
|
177751
|
+
injectStyles26();
|
|
177361
177752
|
closeExportModal();
|
|
177362
177753
|
const backdrop = document.createElement("div");
|
|
177363
177754
|
backdrop.className = `${MODAL_DOM_ID}-backdrop`;
|