myio-js-library 0.1.580 → 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 +642 -226
- package/dist/index.js +621 -205
- package/dist/myio-js-library.umd.js +621 -205
- 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",
|
|
@@ -21082,10 +21082,18 @@ function indicatorStateText(ind, short = false) {
|
|
|
21082
21082
|
if (ind.kind === "valve") return ind.active ? short ? "Aberta" : "aberta" : short ? "Fechada" : "fechada";
|
|
21083
21083
|
return ind.active ? short ? "Ligada" : "ligada" : short ? "Deslig." : "desligada";
|
|
21084
21084
|
}
|
|
21085
|
+
var SHORT_TAG_MAX = 4;
|
|
21086
|
+
function indicatorTag(ind) {
|
|
21087
|
+
const label = String(ind?.label ?? "").trim();
|
|
21088
|
+
return label && label.length <= SHORT_TAG_MAX && !/\s/.test(label) ? label : String(ind?.code ?? "");
|
|
21089
|
+
}
|
|
21085
21090
|
function indicatorTitle(ind) {
|
|
21086
21091
|
const profile = ind.deviceProfile ? ` (${ind.deviceProfile})` : "";
|
|
21087
21092
|
const since = ind.since ? ` desde ${formatClock(ind.since)}` : "";
|
|
21088
|
-
|
|
21093
|
+
const tag = indicatorTag(ind);
|
|
21094
|
+
const name = String(ind.label ?? "").trim();
|
|
21095
|
+
const head = name && name !== tag ? `${tag} \xB7 ${name}` : tag;
|
|
21096
|
+
return `${head}${profile}: ${indicatorStateText(ind)}${ind.active === null || ind.active === void 0 ? "" : since}`;
|
|
21089
21097
|
}
|
|
21090
21098
|
function ensureEquipmentIndicatorStyles() {
|
|
21091
21099
|
if (typeof document === "undefined" || document.getElementById(STYLE_ID4)) return;
|
|
@@ -21140,7 +21148,8 @@ function ensureEquipmentIndicatorStyles() {
|
|
|
21140
21148
|
function renderEquipmentStripHTML(indicators) {
|
|
21141
21149
|
return (indicators || []).map((ind) => {
|
|
21142
21150
|
const cls = indicatorStateClass(ind);
|
|
21143
|
-
const
|
|
21151
|
+
const tag = indicatorTag(ind);
|
|
21152
|
+
const content = ind.kind === "valve" && tag.length <= 1 ? VALVE_SVG : escapeHtml2(tag);
|
|
21144
21153
|
return `<span class="myio-eq-b ${cls}" data-code="${escapeHtml2(ind.code)}" title="${escapeHtml2(indicatorTitle(ind))}">${content}</span>`;
|
|
21145
21154
|
}).join("");
|
|
21146
21155
|
}
|
|
@@ -21165,12 +21174,12 @@ function renderEquipmentTilesHTML(indicators) {
|
|
|
21165
21174
|
if (!indicators?.length) return "";
|
|
21166
21175
|
return `<div class="myio-eq-tiles">${indicators.map((ind) => {
|
|
21167
21176
|
const cls = indicatorStateClass(ind);
|
|
21168
|
-
return `<div class="myio-eq-ti ${cls}" title="${escapeHtml2(indicatorTitle(ind))}"><i></i><b>${escapeHtml2(ind
|
|
21177
|
+
return `<div class="myio-eq-ti ${cls}" title="${escapeHtml2(indicatorTitle(ind))}"><i></i><b>${escapeHtml2(indicatorTag(ind))}</b><small>${indicatorStateText(ind, true)}</small></div>`;
|
|
21169
21178
|
}).join("")}</div>`;
|
|
21170
21179
|
}
|
|
21171
21180
|
function renderEquipmentShortcutHTML(indicators, label = "Bombas") {
|
|
21172
21181
|
const anyOn = (indicators || []).some((i) => i.kind === "pump" && i.active === true);
|
|
21173
|
-
return `<span class="${anyOn ? "myio-eq-spin" : ""}" style="display:inline-flex">${PUMP_SVG}</span><span>${escapeHtml2(label)}</span>` + (indicators || []).map((ind) => `<i class="${indicatorStateClass(ind)}">${escapeHtml2(ind
|
|
21182
|
+
return `<span class="${anyOn ? "myio-eq-spin" : ""}" style="display:inline-flex">${PUMP_SVG}</span><span>${escapeHtml2(label)}</span>` + (indicators || []).map((ind) => `<i class="${indicatorStateClass(ind)}">${escapeHtml2(indicatorTag(ind))}</i>`).join("");
|
|
21174
21183
|
}
|
|
21175
21184
|
|
|
21176
21185
|
// src/components/financial-goals/moneyFormat.ts
|
|
@@ -33181,8 +33190,8 @@ var EnergyDataFetcher = class {
|
|
|
33181
33190
|
// src/components/premium-modals/internal/engines/CsvExporter.ts
|
|
33182
33191
|
var toCsv = (rows, locale = "pt-BR", sep = ";") => {
|
|
33183
33192
|
const fmt2 = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
33184
|
-
const
|
|
33185
|
-
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");
|
|
33186
33195
|
};
|
|
33187
33196
|
|
|
33188
33197
|
// src/components/premium-modals/energy/types.ts
|
|
@@ -37590,14 +37599,14 @@ var DeviceReportModal = class {
|
|
|
37590
37599
|
// Header: "Relatório - <identifier> - <label>" + nome do device (sutil, com copiar).
|
|
37591
37600
|
// O customer já aparece no footer premium. Texto escapado — o shell usa innerHTML no título.
|
|
37592
37601
|
buildHeaderTitleHTML() {
|
|
37593
|
-
const
|
|
37594
|
-
const base =
|
|
37602
|
+
const esc12 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
37603
|
+
const base = esc12(
|
|
37595
37604
|
`Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`
|
|
37596
37605
|
);
|
|
37597
37606
|
const deviceName = String(this.params.deviceName || "").trim();
|
|
37598
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;">
|
|
37599
|
-
${
|
|
37600
|
-
<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"
|
|
37601
37610
|
aria-label="Copiar nome do dispositivo"
|
|
37602
37611
|
style="border:none;background:transparent;color:inherit;cursor:pointer;padding:0 2px;line-height:1;opacity:.9;display:inline-flex;">
|
|
37603
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>
|
|
@@ -63383,6 +63392,32 @@ var EDITABLE_ATTRS = [
|
|
|
63383
63392
|
{ key: "gcdrCustomerId", label: "GCDR Customer ID" },
|
|
63384
63393
|
{ key: "gcdrAssetId", label: "GCDR Asset ID" }
|
|
63385
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
|
+
}
|
|
63386
63421
|
var READONLY_ATTRS = [
|
|
63387
63422
|
{ key: "deviceType", label: "Device Type" },
|
|
63388
63423
|
{ key: "slaveId", label: "Slave ID" },
|
|
@@ -63656,10 +63691,12 @@ var DeviceProfileTab = class {
|
|
|
63656
63691
|
renderRow(field, label, value, kind) {
|
|
63657
63692
|
const text2 = this.esc(this.displayText(value));
|
|
63658
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>`;
|
|
63659
63696
|
return `
|
|
63660
63697
|
<div class="dpt-row" data-field="${this.esc(field)}">
|
|
63661
63698
|
<span class="dpt-label">${this.esc(label)}</span>
|
|
63662
|
-
|
|
63699
|
+
${valueHtml}
|
|
63663
63700
|
</div>`;
|
|
63664
63701
|
}
|
|
63665
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>` : "";
|
|
@@ -63690,8 +63727,14 @@ var DeviceProfileTab = class {
|
|
|
63690
63727
|
({ key, label }) => this.renderRow(key, label, this.attrValue(key), "readonly")
|
|
63691
63728
|
).join("");
|
|
63692
63729
|
const highlightedKeys = /* @__PURE__ */ new Set([...EDITABLE_ATTRS.map((a) => a.key), ...READONLY_ATTRS.map((a) => a.key)]);
|
|
63693
|
-
const otherAttrs = this.attributes.filter((a) => !highlightedKeys.has(a.key))
|
|
63694
|
-
|
|
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>`;
|
|
63695
63738
|
return `
|
|
63696
63739
|
<div class="dpt-tab">
|
|
63697
63740
|
<div class="dpt-notice">\u{1F512} Aba vis\xEDvel apenas para administradores MyIO \u2014 altera dados direto no ThingsBoard.</div>
|
|
@@ -63868,6 +63911,7 @@ var DeviceProfileTab = class {
|
|
|
63868
63911
|
.dpt-label { font-size: 12px; color: #6b7280; font-weight: 600; white-space: nowrap; }
|
|
63869
63912
|
.dpt-value { font-size: 13px; color: #111827; text-align: right; word-break: break-word; }
|
|
63870
63913
|
.dpt-value-wrap { display: flex; align-items: center; gap: 6px; }
|
|
63914
|
+
.dpt-rel { color: #9ca3af; font-size: 12px; }
|
|
63871
63915
|
.dpt-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
|
63872
63916
|
.dpt-empty { padding: 16px 0; text-align: center; color: #9ca3af; font-size: 13px; }
|
|
63873
63917
|
.dpt-icon-btn {
|
|
@@ -64026,11 +64070,13 @@ var WellEquipmentTab = class {
|
|
|
64026
64070
|
<label for="wet-b2-device">Bomba B2</label>${options("pump", "B2", binding(this.bindings.pumps, "B2"))}${labelInput("B2", binding(this.bindings.pumps, "B2"))}
|
|
64027
64071
|
<label for="wet-s-device">Solenoide S</label>${options("valve", "S", binding(this.bindings.valves, "S"))}${labelInput("S", binding(this.bindings.valves, "S"))}
|
|
64028
64072
|
</div>
|
|
64073
|
+
<p class="wet-hint">R\xF3tulos com at\xE9 4 caracteres (ex.: B3) aparecem no card no lugar de B1/B2/S.</p>
|
|
64029
64074
|
<p id="wet-message" class="wet-message" role="status" aria-live="polite"></p>
|
|
64030
64075
|
<button type="button" id="wet-save" ${this.loaded ? "" : "disabled"}>Salvar v\xEDnculos</button>
|
|
64031
64076
|
</section>
|
|
64032
64077
|
<style>
|
|
64033
64078
|
.wet-tab{padding:24px;color:#374151}.wet-grid{display:grid;grid-template-columns:130px minmax(180px,1fr) minmax(180px,1fr);gap:12px;align-items:center}
|
|
64079
|
+
.wet-hint{margin:12px 0 0;font-size:12px;color:#6b7280}
|
|
64034
64080
|
.wet-grid label{font-weight:600}.wet-grid select,.wet-grid input{box-sizing:border-box;width:100%;min-height:38px;padding:7px 9px;border:1px solid #d1d5db;border-radius:6px;background:white}
|
|
64035
64081
|
#wet-save{margin-top:18px;padding:9px 16px;border:0;border-radius:6px;background:#2563eb;color:white;font-weight:600;cursor:pointer}
|
|
64036
64082
|
#wet-save:disabled{opacity:.6;cursor:wait}.wet-message{min-height:20px;margin:12px 0 0}.wet-message.wet-error,.wet-error{color:#b91c1c}.wet-message.wet-success{color:#15803d}.wet-state{text-align:center;padding:30px;color:#6b7280}
|
|
@@ -64132,7 +64178,8 @@ var WellEquipmentTab = class {
|
|
|
64132
64178
|
// src/components/premium-modals/settings/retrolavagem/RetrolavagemTab.ts
|
|
64133
64179
|
var RETROLAVAGEM_PROFILE = "HIDROMETRO_ENTRADA_RETROLAVAGEM";
|
|
64134
64180
|
var RETROLAVAGEM_BINDINGS_KEY = "retrolavagemBindings";
|
|
64135
|
-
var MAX_RETROLAVAGEM_DEVICES_PER_SIDE =
|
|
64181
|
+
var MAX_RETROLAVAGEM_DEVICES_PER_SIDE = 5;
|
|
64182
|
+
var RETROLAVAGEM_LEGACY_MAX_PER_SIDE = 10;
|
|
64136
64183
|
var MAX_CUSTOMER_DEVICE_PAGES2 = 100;
|
|
64137
64184
|
var SIDE_TEXT = {
|
|
64138
64185
|
inputs: { title: "Entrada", add: "+ Adicionar entrada", hint: "Hidr\xF4metros que medem a \xE1gua que entra na retrolavagem." },
|
|
@@ -64162,7 +64209,7 @@ function normalizeRetrolavagemBindings(value) {
|
|
|
64162
64209
|
}
|
|
64163
64210
|
const raw = parsed && typeof parsed === "object" ? parsed : {};
|
|
64164
64211
|
const seen = /* @__PURE__ */ new Set();
|
|
64165
|
-
const side = (items) => (Array.isArray(items) ? items : []).filter((item) => !!item && typeof item === "object" && typeof item.tbId === "string" && !!item.tbId).filter((item) => seen.has(item.tbId) ? false : (seen.add(item.tbId), true)).slice(0,
|
|
64212
|
+
const side = (items) => (Array.isArray(items) ? items : []).filter((item) => !!item && typeof item === "object" && typeof item.tbId === "string" && !!item.tbId).filter((item) => seen.has(item.tbId) ? false : (seen.add(item.tbId), true)).slice(0, RETROLAVAGEM_LEGACY_MAX_PER_SIDE).map((item) => ({
|
|
64166
64213
|
tbId: item.tbId,
|
|
64167
64214
|
label: String(item.label || item.tbId),
|
|
64168
64215
|
...item.gcdrId ? { gcdrId: String(item.gcdrId) } : {}
|
|
@@ -64269,6 +64316,7 @@ var RetrolavagemTab = class {
|
|
|
64269
64316
|
const text2 = SIDE_TEXT[side];
|
|
64270
64317
|
const rows = this.rows[side];
|
|
64271
64318
|
const full = rows.length >= MAX_RETROLAVAGEM_DEVICES_PER_SIDE;
|
|
64319
|
+
const excess = rows.length - MAX_RETROLAVAGEM_DEVICES_PER_SIDE;
|
|
64272
64320
|
const options = (current) => {
|
|
64273
64321
|
const missing = current && !this.catalog.some((o) => o.tbId === current) ? `<option value="${escapeHtml7(current)}" selected data-unavailable="true">V\xEDnculo atual indispon\xEDvel \u2014 ${escapeHtml7(
|
|
64274
64322
|
this.storedRef(current)?.label || current
|
|
@@ -64281,6 +64329,7 @@ var RetrolavagemTab = class {
|
|
|
64281
64329
|
<fieldset class="rlt-side" data-side="${side}">
|
|
64282
64330
|
<legend>${text2.title} <span class="rlt-count">${rows.length}/${MAX_RETROLAVAGEM_DEVICES_PER_SIDE}</span></legend>
|
|
64283
64331
|
<p class="rlt-hint">${text2.hint}</p>
|
|
64332
|
+
${excess > 0 ? `<p class="rlt-over" role="alert">Esta retrolavagem tem ${rows.length} hidr\xF4metros de ${text2.title.toLowerCase()}, acima do limite de ${MAX_RETROLAVAGEM_DEVICES_PER_SIDE}. O painel continua somando todos. Remova ${excess} para poder salvar.</p>` : ""}
|
|
64284
64333
|
${rows.length ? rows.map(
|
|
64285
64334
|
(tbId, i) => `<div class="rlt-row">
|
|
64286
64335
|
<select data-side="${side}" data-index="${i}" aria-label="${text2.title} ${i + 1}">${options(tbId)}</select>
|
|
@@ -64306,6 +64355,7 @@ var RetrolavagemTab = class {
|
|
|
64306
64355
|
.rlt-side{border:1px solid #e5e7eb;border-radius:8px;padding:12px 14px;margin:0}.rlt-side legend{font-weight:700;padding:0 6px}
|
|
64307
64356
|
.rlt-count{font-weight:500;color:#6b7280;font-size:12px}.rlt-hint,.rlt-empty,.rlt-note{margin:0 0 10px;font-size:13px;color:#6b7280}
|
|
64308
64357
|
.rlt-note{background:#f1ecfa;color:#3e1a7d;border-radius:6px;padding:8px 10px}
|
|
64358
|
+
.rlt-over{margin:0 0 10px;font-size:13px;color:#92400e;background:#fffbeb;border:1px solid #fde68a;border-radius:6px;padding:8px 10px}
|
|
64309
64359
|
.rlt-row{display:flex;gap:8px;margin-bottom:8px}.rlt-row select{flex:1;min-width:0;min-height:36px;padding:6px 8px;border:1px solid #d1d5db;border-radius:6px;background:#fff}
|
|
64310
64360
|
.rlt-remove{border:1px solid #d1d5db;background:#fff;border-radius:6px;padding:0 10px;cursor:pointer;color:#6b7280}
|
|
64311
64361
|
.rlt-add{border:1px dashed #9ca3af;background:#fff;border-radius:6px;padding:7px 12px;cursor:pointer;color:#374151;font-weight:600}
|
|
@@ -65710,6 +65760,204 @@ function createTicketsTab(config2) {
|
|
|
65710
65760
|
return { destroy: () => tab.destroy() };
|
|
65711
65761
|
}
|
|
65712
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
|
+
|
|
65713
65961
|
// src/components/premium-modals/settings/commercialCatalog.ts
|
|
65714
65962
|
var DEFAULT_STORE_SEGMENTS = [
|
|
65715
65963
|
{
|
|
@@ -66009,7 +66257,7 @@ async function createInputDateRangePickerInsideDIV(params) {
|
|
|
66009
66257
|
placeholder = "Clique para selecionar per\xEDodo",
|
|
66010
66258
|
pickerOptions = {},
|
|
66011
66259
|
classNames = {},
|
|
66012
|
-
injectStyles:
|
|
66260
|
+
injectStyles: injectStyles27 = true,
|
|
66013
66261
|
showHelper = true
|
|
66014
66262
|
} = params;
|
|
66015
66263
|
validateId(containerId, "containerId");
|
|
@@ -66018,7 +66266,7 @@ async function createInputDateRangePickerInsideDIV(params) {
|
|
|
66018
66266
|
if (!container) {
|
|
66019
66267
|
throw new Error(`[createInputDateRangePickerInsideDIV] Container '#${containerId}' not found`);
|
|
66020
66268
|
}
|
|
66021
|
-
if (
|
|
66269
|
+
if (injectStyles27) {
|
|
66022
66270
|
injectPremiumStyles();
|
|
66023
66271
|
}
|
|
66024
66272
|
let inputEl = document.getElementById(inputId);
|
|
@@ -66198,6 +66446,33 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66198
66446
|
const email = userEmail.toLowerCase().trim();
|
|
66199
66447
|
return email.endsWith(ALLOWED_EMAIL_DOMAIN.toLowerCase());
|
|
66200
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
|
+
}
|
|
66201
66476
|
/**
|
|
66202
66477
|
* Check if the user may edit the "Identificador" field.
|
|
66203
66478
|
* True when isSuperAdmin() OR the caller already resolved the user as a
|
|
@@ -66217,10 +66492,14 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66217
66492
|
isWellEquipmentDevice() {
|
|
66218
66493
|
return ["CISTERNA", "CISTERNA_ENTRADA"].includes(String(this.config.deviceProfile || "").toUpperCase());
|
|
66219
66494
|
}
|
|
66220
|
-
/** Retrolavagem virtual: escolhe os hidrômetros de entrada e de saída
|
|
66495
|
+
/** Retrolavagem virtual: escolhe os hidrômetros de entrada e de saída. */
|
|
66221
66496
|
isRetrolavagemDevice() {
|
|
66222
66497
|
return String(this.config.deviceProfile || "").toUpperCase() === RETROLAVAGEM_PROFILE;
|
|
66223
66498
|
}
|
|
66499
|
+
/** Permissão de configuração: SuperAdmin ou administrador da holding já validado pelo host. */
|
|
66500
|
+
canManageRetrolavagem() {
|
|
66501
|
+
return this.isSuperAdmin() || this.config.holdingAdmin === true;
|
|
66502
|
+
}
|
|
66224
66503
|
render(initialData) {
|
|
66225
66504
|
this.originalActiveElement = document.activeElement;
|
|
66226
66505
|
document.body.appendChild(this.container);
|
|
@@ -66256,13 +66535,16 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66256
66535
|
if (this.isWellEquipmentDevice() && this.isSuperAdmin()) {
|
|
66257
66536
|
this.initWellEquipmentTab();
|
|
66258
66537
|
}
|
|
66259
|
-
if (this.isRetrolavagemDevice() && this.
|
|
66538
|
+
if (this.isRetrolavagemDevice() && this.canManageRetrolavagem()) {
|
|
66260
66539
|
this.initRetrolavagemTab();
|
|
66261
66540
|
}
|
|
66262
66541
|
if (this.config.isGateway && this.isSuperAdmin()) {
|
|
66263
66542
|
this.bindIncidentsTabEvents();
|
|
66264
66543
|
this.initIncidentsDateRange();
|
|
66265
66544
|
}
|
|
66545
|
+
if (this.isMyioUser()) {
|
|
66546
|
+
this.initDeviceOpsTabs();
|
|
66547
|
+
}
|
|
66266
66548
|
this._updateTabBadges(initialData);
|
|
66267
66549
|
}
|
|
66268
66550
|
// RFC-0104: Initialize the Annotations Tab
|
|
@@ -66538,7 +66820,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66538
66820
|
}
|
|
66539
66821
|
async initRetrolavagemTab() {
|
|
66540
66822
|
const container = this.modal.querySelector("#retrolavagem-tab-content");
|
|
66541
|
-
if (!container || !this.isRetrolavagemDevice() || !this.
|
|
66823
|
+
if (!container || !this.isRetrolavagemDevice() || !this.canManageRetrolavagem()) return;
|
|
66542
66824
|
const customerId = this.config.customerId || window.MyIOUtils?.customerTB_ID;
|
|
66543
66825
|
const { deviceId, jwtToken, tbBaseUrl } = this.config;
|
|
66544
66826
|
if (!deviceId || !jwtToken || !customerId) {
|
|
@@ -66584,6 +66866,10 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66584
66866
|
if (retrolavagemContent) retrolavagemContent.style.display = tab === "retrolavagem" ? "block" : "none";
|
|
66585
66867
|
if (exclusionGroupsContent) exclusionGroupsContent.style.display = tab === "exclusion-groups" ? "block" : "none";
|
|
66586
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";
|
|
66587
66873
|
const saveBtn = this.modal.querySelector(".btn-save");
|
|
66588
66874
|
if (saveBtn) saveBtn.style.display = tab === "general" ? "inline-flex" : "none";
|
|
66589
66875
|
if (tab === "annotations" && this.annotationsTab) {
|
|
@@ -66723,12 +67009,63 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66723
67009
|
data[key] = num;
|
|
66724
67010
|
}
|
|
66725
67011
|
} else if (value.trim()) {
|
|
66726
|
-
data[key] = value.trim();
|
|
67012
|
+
data[key] = key === "label" ? this.labelCase(value.trim()) : value.trim();
|
|
66727
67013
|
}
|
|
66728
67014
|
}
|
|
66729
67015
|
}
|
|
66730
67016
|
return data;
|
|
66731
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
|
+
}
|
|
66732
67069
|
createModal() {
|
|
66733
67070
|
this.container = document.createElement("div");
|
|
66734
67071
|
this.container.className = "myio-device-settings-overlay";
|
|
@@ -66797,7 +67134,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66797
67134
|
<line x1="3" y1="9" x2="21" y2="9"></line>
|
|
66798
67135
|
<line x1="9" y1="21" x2="9" y2="9"></line>
|
|
66799
67136
|
</svg>
|
|
66800
|
-
Perfil
|
|
67137
|
+
Perfil Disp.
|
|
66801
67138
|
</button>` : ""}
|
|
66802
67139
|
${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="well-equipment">
|
|
66803
67140
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -66806,7 +67143,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66806
67143
|
</svg>
|
|
66807
67144
|
Equipamentos do Po\xE7o
|
|
66808
67145
|
</button>` : ""}
|
|
66809
|
-
${this.isRetrolavagemDevice() && this.
|
|
67146
|
+
${this.isRetrolavagemDevice() && this.canManageRetrolavagem() ? `<button type="button" class="modal-tab" data-tab="retrolavagem">
|
|
66810
67147
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
66811
67148
|
<path d="M3 12h7M14 12h7"></path>
|
|
66812
67149
|
<path d="M7 8l-4 4 4 4"></path>
|
|
@@ -66814,14 +67151,31 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66814
67151
|
</svg>
|
|
66815
67152
|
Equipamentos da Retrolavagem
|
|
66816
67153
|
</button>` : ""}
|
|
66817
|
-
<!--
|
|
66818
|
-
${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">
|
|
66819
67163
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
66820
67164
|
<path d="M12 9v4"></path>
|
|
66821
67165
|
<path d="M12 17h.01"></path>
|
|
66822
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>
|
|
66823
67167
|
</svg>
|
|
66824
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
|
|
66825
67179
|
${(this.config.interpolatedSlots?.length ?? 0) > 0 ? `<span class="modal-tab-badge modal-tab-badge--incidents">${this.config.interpolatedSlots.length}</span>` : ""}
|
|
66826
67180
|
</button>` : ""}
|
|
66827
67181
|
</div>
|
|
@@ -66871,13 +67225,15 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66871
67225
|
${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<div id="well-equipment-tab-content" class="tab-content" style="display:none;">
|
|
66872
67226
|
<p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>
|
|
66873
67227
|
</div>` : ""}
|
|
66874
|
-
${this.isRetrolavagemDevice() && this.
|
|
67228
|
+
${this.isRetrolavagemDevice() && this.canManageRetrolavagem() ? `<div id="retrolavagem-tab-content" class="tab-content" style="display:none;">
|
|
66875
67229
|
<p class="rlt-state">Carregando v\xEDnculos e hidr\xF4metros\u2026</p>
|
|
66876
67230
|
</div>` : ""}
|
|
66877
67231
|
<!-- RFC-0232: Incidentes (interpola\xE7\xE3o) Tab Content \u2014 central + admin MyIO only.
|
|
66878
67232
|
Rendered synchronously (data comes pre-fetched via config.interpolatedSlots,
|
|
66879
67233
|
same as getGatewayInfoHTML() \u2014 no async loading state needed here). -->
|
|
66880
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>` : ""}
|
|
66881
67237
|
</div>
|
|
66882
67238
|
<div class="modal-footer">
|
|
66883
67239
|
<button type="button" class="btn-cancel">Fechar</button>
|
|
@@ -66919,8 +67275,13 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66919
67275
|
<!-- Col 1, rows 1-6: single wrapper \u2192 borda cont\xEDnua -->
|
|
66920
67276
|
<div class="identity-col1">
|
|
66921
67277
|
<div class="identity-name-block">
|
|
66922
|
-
<div class="identity-name-text">${this.config.deviceLabel || "\u2014"}</div>
|
|
66923
|
-
|
|
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>` : ""}
|
|
66924
67285
|
</div>
|
|
66925
67286
|
<div class="identity-icon-cell">
|
|
66926
67287
|
${this.getDeviceImage(deviceType)}
|
|
@@ -67023,8 +67384,8 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
67023
67384
|
const segmentEl = this.modal.querySelector("#segment");
|
|
67024
67385
|
const activityEl = this.modal.querySelector("#activity");
|
|
67025
67386
|
if (!segmentEl || !activityEl) return;
|
|
67026
|
-
const
|
|
67027
|
-
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("");
|
|
67028
67389
|
const catalog = await loadStoreSegmentCatalog(this.config.segmentCatalog);
|
|
67029
67390
|
const savedSegment = String(saved.segment || "");
|
|
67030
67391
|
const savedActivity = String(saved.activity || "");
|
|
@@ -68213,6 +68574,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
68213
68574
|
.modal-tab-badge--chamados { background: #0891b2; }
|
|
68214
68575
|
.modal-tab-badge--exclusion { background: #d97706; }
|
|
68215
68576
|
.modal-tab-badge--incidents { background: #7C3AED; }
|
|
68577
|
+
.modal-tab-badge--os { background: #0891b2; }
|
|
68216
68578
|
|
|
68217
68579
|
.tab-content {
|
|
68218
68580
|
min-height: 400px;
|
|
@@ -68826,6 +69188,40 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
68826
69188
|
display: none;
|
|
68827
69189
|
}
|
|
68828
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
|
+
|
|
68829
69225
|
.section-title {
|
|
68830
69226
|
margin: 0 0 20px 0;
|
|
68831
69227
|
font-size: 16px;
|
|
@@ -69925,7 +70321,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
69925
70321
|
for (const [key, value] of Object.entries(data)) {
|
|
69926
70322
|
const input = this.form.querySelector(`[name="${key}"]`);
|
|
69927
70323
|
if (input && value !== void 0 && value !== null) {
|
|
69928
|
-
input.value = String(value);
|
|
70324
|
+
input.value = key === "label" ? this.labelCase(value) : String(value);
|
|
69929
70325
|
}
|
|
69930
70326
|
}
|
|
69931
70327
|
}
|
|
@@ -70021,6 +70417,20 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
70021
70417
|
this.switchTab("alarms");
|
|
70022
70418
|
}
|
|
70023
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
|
+
});
|
|
70024
70434
|
this.form.addEventListener("submit", (event) => {
|
|
70025
70435
|
event.preventDefault();
|
|
70026
70436
|
this.hideError();
|
|
@@ -70489,7 +70899,7 @@ function connectivityFieldsetHtml(data, l, language, errors) {
|
|
|
70489
70899
|
`;
|
|
70490
70900
|
}
|
|
70491
70901
|
var STYLE_ID5 = "myio-central-settings-modal-styles";
|
|
70492
|
-
function
|
|
70902
|
+
function injectStyles10() {
|
|
70493
70903
|
if (typeof document === "undefined" || document.getElementById(STYLE_ID5)) return;
|
|
70494
70904
|
const tag = document.createElement("style");
|
|
70495
70905
|
tag.id = STYLE_ID5;
|
|
@@ -70567,7 +70977,7 @@ var CentralSettingsModal = class extends SettingsModalView {
|
|
|
70567
70977
|
this.csLanguage = language;
|
|
70568
70978
|
this.csLabels = l;
|
|
70569
70979
|
this.csCurrentData = initialData;
|
|
70570
|
-
|
|
70980
|
+
injectStyles10();
|
|
70571
70981
|
config2.onSave = (formData) => this.handleCentralSave(formData);
|
|
70572
70982
|
config2.onClose = () => {
|
|
70573
70983
|
this.close();
|
|
@@ -73513,7 +73923,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73513
73923
|
if (this.metaTipEl) this.metaTipEl.style.display = "none";
|
|
73514
73924
|
}
|
|
73515
73925
|
buildMetaTipHtml(type, card) {
|
|
73516
|
-
const
|
|
73926
|
+
const esc12 = _WelcomeModalView.escapeMetaHtml;
|
|
73517
73927
|
const chip = _WelcomeModalView.metaChip;
|
|
73518
73928
|
const meta = card.metaCounts || {};
|
|
73519
73929
|
const details = card.metaDetails || {};
|
|
@@ -73523,7 +73933,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73523
73933
|
).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
|
|
73524
73934
|
const frame = (icon2, label, body) => `<div class="myio-welcome-meta-tip__header">
|
|
73525
73935
|
<span class="myio-welcome-meta-tip__icon">${icon2}</span>
|
|
73526
|
-
<span class="myio-welcome-meta-tip__title">${label} (${
|
|
73936
|
+
<span class="myio-welcome-meta-tip__title">${label} (${esc12(card.title)})</span>
|
|
73527
73937
|
<span class="myio-welcome-meta-tip__timestamp">${stamp}</span>
|
|
73528
73938
|
<button type="button" class="myio-welcome-meta-tip__close" title="Fechar">\u2715</button>
|
|
73529
73939
|
</div>
|
|
@@ -73551,8 +73961,8 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73551
73961
|
const chips = Object.entries(byState).map(([s, n]) => chip(`${s}: ${n}`)).join("");
|
|
73552
73962
|
const rows = alarms.slice(0, 10).map(
|
|
73553
73963
|
(a) => row(
|
|
73554
|
-
|
|
73555
|
-
[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 ")
|
|
73556
73966
|
)
|
|
73557
73967
|
).join("");
|
|
73558
73968
|
return frame(
|
|
@@ -73576,7 +73986,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73576
73986
|
const rows = annotations.slice(0, 10).map((a) => {
|
|
73577
73987
|
const when = a.createdAt ? new Date(a.createdAt).toLocaleDateString("pt-BR") : "";
|
|
73578
73988
|
const text2 = a.text.length > 90 ? `${a.text.slice(0, 90)}\u2026` : a.text;
|
|
73579
|
-
return row(
|
|
73989
|
+
return row(esc12(a.deviceLabel || "Dispositivo"), `${esc12(text2)}${when ? ` \xB7 ${esc12(when)}` : ""}`);
|
|
73580
73990
|
}).join("");
|
|
73581
73991
|
return frame(
|
|
73582
73992
|
"\u{1F4CB}",
|
|
@@ -73587,7 +73997,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
73587
73997
|
if (type === "users") {
|
|
73588
73998
|
if (meta.users === null) return frame("\u{1F465}", "Usu\xE1rios", loadingBody);
|
|
73589
73999
|
const users = details.users || [];
|
|
73590
|
-
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("");
|
|
73591
74001
|
return frame(
|
|
73592
74002
|
"\u{1F465}",
|
|
73593
74003
|
"Usu\xE1rios",
|
|
@@ -76486,7 +76896,7 @@ var STYLE_ID6 = "myio-footer-component-styles";
|
|
|
76486
76896
|
function areStylesInjected() {
|
|
76487
76897
|
return !!document.getElementById(STYLE_ID6);
|
|
76488
76898
|
}
|
|
76489
|
-
function
|
|
76899
|
+
function injectStyles11() {
|
|
76490
76900
|
if (areStylesInjected()) return;
|
|
76491
76901
|
const style = document.createElement("style");
|
|
76492
76902
|
style.id = STYLE_ID6;
|
|
@@ -77231,7 +77641,7 @@ var FooterView = class {
|
|
|
77231
77641
|
this.chipRenderer = new ChipRenderer();
|
|
77232
77642
|
this.footerEl = document.createElement("section");
|
|
77233
77643
|
this.footerEl.className = this.getClassName();
|
|
77234
|
-
|
|
77644
|
+
injectStyles11();
|
|
77235
77645
|
this.applyThemeColors();
|
|
77236
77646
|
}
|
|
77237
77647
|
container;
|
|
@@ -79567,7 +79977,7 @@ var MODAL_CSS = `
|
|
|
79567
79977
|
to { transform: rotate(360deg); }
|
|
79568
79978
|
}
|
|
79569
79979
|
`;
|
|
79570
|
-
function
|
|
79980
|
+
function injectStyles12() {
|
|
79571
79981
|
if (document.getElementById(CSS_ID4)) return;
|
|
79572
79982
|
const style = document.createElement("style");
|
|
79573
79983
|
style.id = CSS_ID4;
|
|
@@ -79584,7 +79994,7 @@ var IntegrationsModalView = class {
|
|
|
79584
79994
|
closeHandlers = [];
|
|
79585
79995
|
tabChangeHandlers = [];
|
|
79586
79996
|
constructor(options) {
|
|
79587
|
-
|
|
79997
|
+
injectStyles12();
|
|
79588
79998
|
this.options = options;
|
|
79589
79999
|
this.tabs = options.tabs || DEFAULT_INTEGRATION_TABS;
|
|
79590
80000
|
this.activeTabId = options.defaultTab || this.tabs[0]?.id || "chiller";
|
|
@@ -80879,6 +81289,12 @@ function timelineHTML(history, now, kind) {
|
|
|
80879
81289
|
<small><span>${formatClock(now - DAY_MS)}</span><span>agora</span></small>
|
|
80880
81290
|
</div>`;
|
|
80881
81291
|
}
|
|
81292
|
+
function equipmentNameHTML(item, fallbackProfile) {
|
|
81293
|
+
const tag = indicatorTag(item);
|
|
81294
|
+
const label = String(item.label ?? "").trim();
|
|
81295
|
+
const name = label && label !== tag ? label : item.identifier || item.deviceProfile || fallbackProfile;
|
|
81296
|
+
return `<span class="myio-wp-tag">${escapeHtml2(tag)}</span>${escapeHtml2(name)}`;
|
|
81297
|
+
}
|
|
80882
81298
|
function pumpCardHTML(p, now, images, focusWellId) {
|
|
80883
81299
|
const on = isActive(p.history);
|
|
80884
81300
|
const known = Array.isArray(p.history);
|
|
@@ -80895,7 +81311,7 @@ function pumpCardHTML(p, now, images, focusWellId) {
|
|
|
80895
81311
|
<div class="myio-wp-top">
|
|
80896
81312
|
<img class="myio-wp-img" src="${escapeHtml2(images.pump)}" alt="">
|
|
80897
81313
|
<div>
|
|
80898
|
-
<div class="myio-wp-name"
|
|
81314
|
+
<div class="myio-wp-name">${equipmentNameHTML(p, "BOMBA_POCO")}</div>
|
|
80899
81315
|
<div class="myio-wp-meta"><span class="myio-wp-prof">${escapeHtml2(p.deviceProfile || "BOMBA_POCO")}</span>${meta}</div>
|
|
80900
81316
|
</div>
|
|
80901
81317
|
<span class="myio-wp-state ${!known ? "unk" : on ? "on" : "off"}">${PUMP_SVG}${!known ? "SEM LEITURA" : on ? "LIGADA" : "DESLIGADA"}</span>
|
|
@@ -80925,7 +81341,7 @@ function valveCardHTML(v, now, images) {
|
|
|
80925
81341
|
<div style="display:flex;flex-direction:column;gap:10px;min-width:0">
|
|
80926
81342
|
<div class="myio-wp-top">
|
|
80927
81343
|
<div>
|
|
80928
|
-
<div class="myio-wp-name"
|
|
81344
|
+
<div class="myio-wp-name">${equipmentNameHTML(v, "SOLENOIDE")}</div>
|
|
80929
81345
|
<div class="myio-wp-meta"><span class="myio-wp-prof">${escapeHtml2(v.deviceProfile || "SOLENOIDE")}</span>${meta}</div>
|
|
80930
81346
|
</div>
|
|
80931
81347
|
<span class="myio-wp-state ${!known ? "unk" : open ? "open" : "closed"}">${VALVE_SVG}${!known ? "SEM LEITURA" : open ? "ABERTA" : "FECHADA"}</span>
|
|
@@ -83953,7 +84369,7 @@ var PRESETS = [
|
|
|
83953
84369
|
{ id: "custom", label: "Personalizado" }
|
|
83954
84370
|
];
|
|
83955
84371
|
var STEPS = ["Dispositivos", "Per\xEDodo", "Telemetrias", "Resumo"];
|
|
83956
|
-
var
|
|
84372
|
+
var esc6 = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
83957
84373
|
var norm = (s) => String(s ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
83958
84374
|
var fmtN = (n) => n.toLocaleString("pt-BR");
|
|
83959
84375
|
var pad = (n) => String(n).padStart(2, "0");
|
|
@@ -84341,8 +84757,8 @@ var DemandPanelV2 = class {
|
|
|
84341
84757
|
highlight(text2) {
|
|
84342
84758
|
const q = norm(this.s.search).trim();
|
|
84343
84759
|
const i = q ? norm(text2).indexOf(q) : -1;
|
|
84344
|
-
if (i < 0) return
|
|
84345
|
-
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));
|
|
84346
84762
|
}
|
|
84347
84763
|
deviceRow(d, mode) {
|
|
84348
84764
|
const picked = this.s.selected.includes(d.tbDeviceId);
|
|
@@ -84350,13 +84766,13 @@ var DemandPanelV2 = class {
|
|
|
84350
84766
|
const cat = this.categoryOf.get(d.tbDeviceId);
|
|
84351
84767
|
const chip = this.chips.find((c) => c.key === cat);
|
|
84352
84768
|
const dup = (this.labelCount.get(d.label) || 0) > 1;
|
|
84353
|
-
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>`;
|
|
84354
84770
|
return `<div class="dp2-item ${el2.ok ? "" : "blocked"}">
|
|
84355
|
-
<img class="dp2-ico" src="${
|
|
84771
|
+
<img class="dp2-ico" src="${esc6(deviceIconUrl(d.deviceProfile))}" alt="" loading="lazy">
|
|
84356
84772
|
<div style="min-width:0">
|
|
84357
|
-
<div class="dp2-name">${mode === "result" ? this.highlight(d.label) :
|
|
84358
|
-
<div class="dp2-sub">${chip ? `<span class="dp2-tag">${
|
|
84359
|
-
${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>
|
|
84360
84776
|
</div>
|
|
84361
84777
|
<div>${action}</div>
|
|
84362
84778
|
</div>`;
|
|
@@ -84374,8 +84790,8 @@ var DemandPanelV2 = class {
|
|
|
84374
84790
|
this.el.body.innerHTML = `<div class="dp2-s1">
|
|
84375
84791
|
<section class="dp2-col" aria-label="Buscar medidores">
|
|
84376
84792
|
<div class="dp2-col-head">
|
|
84377
|
-
<input class="dp2-search" data-role="search" type="search" placeholder="\u{1F50E} Buscar por nome, identificador ou tipo\u2026" value="${
|
|
84378
|
-
<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>
|
|
84379
84795
|
<h3><span>${fmtN(results.length)} resultado(s)</span>
|
|
84380
84796
|
<button class="dp2-btn link" type="button" data-action="add-all" ${addable ? "" : "disabled"}>+ Adicionar todos (${addable})</button></h3>
|
|
84381
84797
|
</div>
|
|
@@ -84414,7 +84830,7 @@ var DemandPanelV2 = class {
|
|
|
84414
84830
|
<div class="dp2-card"><h3 tabindex="-1" data-role="step-title">Per\xEDodo</h3>
|
|
84415
84831
|
<div class="dp2-chips" style="margin-bottom:12px">${PRESETS.map((p) => {
|
|
84416
84832
|
const off = p.id !== "custom" && presetTooLong(p.id);
|
|
84417
|
-
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>`;
|
|
84418
84834
|
}).join("")}</div>
|
|
84419
84835
|
<div class="dp2-row">
|
|
84420
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>
|
|
@@ -84427,24 +84843,24 @@ var DemandPanelV2 = class {
|
|
|
84427
84843
|
const d = limits?.maxDaysByResolution[x.id];
|
|
84428
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>`;
|
|
84429
84845
|
}).join("")}</div>
|
|
84430
|
-
<p class="dp2-info" style="margin:10px 0 0">Cada linha do relat\xF3rio \xE9 um intervalo com <b>${
|
|
84431
|
-
${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>
|
|
84432
84848
|
${valid && !tooLong ? `<p class="dp2-info" style="margin:6px 0 0">${fmtN(bucketCount(start, end, this.s.resolution))} intervalo(s) por medidor.</p>` : ""}
|
|
84433
|
-
${tooLong ? `<div class="dp2-fix"><span class="dp2-err">O per\xEDodo \xE9 longo demais para intervalos de ${
|
|
84434
|
-
${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>` : ""}
|
|
84435
84851
|
<button class="dp2-btn sm" type="button" data-action="shorten">Encurtar para os \xFAltimos ${maxDays} dia(s)</button></div>` : ""}
|
|
84436
84852
|
${misaligned ? `<div class="dp2-fix"><span class="dp2-err">Com intervalos de 1 dia, o in\xEDcio precisa ser \xE0 meia-noite.</span>
|
|
84437
|
-
<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>` : ""}
|
|
84438
84854
|
</div>
|
|
84439
|
-
${otherErrs.length ? `<p class="dp2-err">${otherErrs.map(
|
|
84855
|
+
${otherErrs.length ? `<p class="dp2-err">${otherErrs.map(esc6).join("<br>")}</p>` : ""}`;
|
|
84440
84856
|
}
|
|
84441
84857
|
renderStep3() {
|
|
84442
84858
|
this.el.body.innerHTML = `<div class="dp2-tgrid">${TELEMETRY_GROUPS.map((g) => {
|
|
84443
84859
|
const all = g.items.every((t) => this.s.telemetries.has(t.key));
|
|
84444
|
-
return `<div class="dp2-card"><h3><span>${g.icon} ${
|
|
84860
|
+
return `<div class="dp2-card"><h3><span>${g.icon} ${esc6(g.label)}</span>
|
|
84445
84861
|
<button class="dp2-btn link" type="button" data-action="group-all" data-gid="${g.id}">${all ? "Desmarcar" : "Marcar"} todos</button></h3>
|
|
84446
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" : ""}>
|
|
84447
|
-
${
|
|
84863
|
+
${esc6(t.label)}<span class="u">${this.p.supportMode ? esc6(t.key) + " \xB7 " : ""}${esc6(t.unit)}</span></label>`).join("")}
|
|
84448
84864
|
</div>`;
|
|
84449
84865
|
}).join("")}</div>
|
|
84450
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>`;
|
|
@@ -84464,14 +84880,14 @@ var DemandPanelV2 = class {
|
|
|
84464
84880
|
let validation = "";
|
|
84465
84881
|
if (v.state === "loading") validation = '<div class="dp2-info">\u23F3 Validando o pedido no servidor\u2026</div>';
|
|
84466
84882
|
else if (v.state === "error") {
|
|
84467
|
-
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)}
|
|
84468
84884
|
<button class="dp2-btn link" type="button" data-action="revalidate">Tentar de novo</button></div>`;
|
|
84469
84885
|
} else if (vr) {
|
|
84470
84886
|
const warns = (vr.warnings || []).map((w) => {
|
|
84471
84887
|
const dev = w.deviceId;
|
|
84472
|
-
return `<li>${
|
|
84888
|
+
return `<li>${esc6(warningText(w.code, w.message) + (dev ? this.devicesSuffix({ devices: [{ deviceId: dev }] }) : ""))}</li>`;
|
|
84473
84889
|
}).join("");
|
|
84474
|
-
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).
|
|
84475
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>` : "";
|
|
84476
84892
|
validation = `${vr.ok ? '<div class="dp2-info">\u2713 Pedido validado no servidor.</div>' : ""}
|
|
84477
84893
|
${warns ? `<ul class="dp2-info" style="margin:6px 0 0;padding-left:18px">${warns}</ul>` : ""}${reuse}`;
|
|
@@ -84479,12 +84895,12 @@ var DemandPanelV2 = class {
|
|
|
84479
84895
|
this.el.body.innerHTML = `
|
|
84480
84896
|
<div class="dp2-card"><h3 tabindex="-1" data-role="step-title">Resumo do pedido</h3>
|
|
84481
84897
|
<dl class="dp2-sum">
|
|
84482
|
-
<dt>Solicitante</dt><dd>${
|
|
84483
|
-
<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>
|
|
84484
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>
|
|
84485
|
-
<dt>Resolu\xE7\xE3o</dt><dd>${
|
|
84486
|
-
<dt>Telemetrias (${req.telemetries.length})</dt><dd><div class="dp2-pills">${req.telemetries.map((t) => `<span class="dp2-pill">${
|
|
84487
|
-
${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>
|
|
84488
84904
|
<dt>Tamanho</dt><dd><span class="dp2-size ${cls}">${txt}</span> <span class="dp2-info">\u2248 ${fmtN(pts)} pontos</span>
|
|
84489
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>
|
|
84490
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>
|
|
@@ -84492,15 +84908,15 @@ var DemandPanelV2 = class {
|
|
|
84492
84908
|
<div style="margin-top:12px">${validation}</div>
|
|
84493
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>
|
|
84494
84910
|
</div>
|
|
84495
|
-
${this.p.supportMode ? `<div class="dp2-card"><h3>Pedido que ser\xE1 registrado (suporte)</h3><pre class="dp2-json">${
|
|
84496
|
-
${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>` : ""}`;
|
|
84497
84913
|
}
|
|
84498
84914
|
renderNav() {
|
|
84499
84915
|
const errs = this.stepErrors(this.s.step);
|
|
84500
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"];
|
|
84501
84917
|
this.el.nav.innerHTML = `
|
|
84502
84918
|
<button class="dp2-btn" type="button" data-action="back" ${this.s.step === 1 ? "disabled" : ""}>\u2190 Voltar</button>
|
|
84503
|
-
<span class="hint">${
|
|
84919
|
+
<span class="hint">${esc6(hints[this.s.step])}</span>
|
|
84504
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>`}`;
|
|
84505
84921
|
}
|
|
84506
84922
|
jobTitle(e) {
|
|
@@ -84518,7 +84934,7 @@ var DemandPanelV2 = class {
|
|
|
84518
84934
|
return;
|
|
84519
84935
|
}
|
|
84520
84936
|
if (s.listState === "error") {
|
|
84521
|
-
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>`;
|
|
84522
84938
|
return;
|
|
84523
84939
|
}
|
|
84524
84940
|
const orphans = this.p.supportMode ? s.active.filter((j) => !s.keys.includes(envelopeKey(j.jobId))) : [];
|
|
@@ -84536,43 +84952,43 @@ var DemandPanelV2 = class {
|
|
|
84536
84952
|
const note = (cls, text2) => `<div class="${cls}" style="margin-top:6px">${text2}</div>`;
|
|
84537
84953
|
const queue = st === "queued" && j?.queue?.position ? ` (N\xBA ${j.queue.position})` : "";
|
|
84538
84954
|
const peak = j?.totals?.largestDevicePeak;
|
|
84539
|
-
const peakTxt = peak && (peak.kw != null || peak.w != null) ? `Maior pico individual: <b>${
|
|
84540
|
-
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))}">
|
|
84541
84957
|
<div class="dp2-job-top">
|
|
84542
|
-
<span class="dp2-job-title">${
|
|
84958
|
+
<span class="dp2-job-title">${esc6(this.jobTitle(e))}</span>
|
|
84543
84959
|
<span class="dp2-status ${st}">${JOB_STATE_LABEL[st]}${queue}${st === "running" ? ` ${progress}%` : ""}</span>
|
|
84544
84960
|
<span style="flex:1"></span>
|
|
84545
|
-
<span class="dp2-info">${
|
|
84961
|
+
<span class="dp2-info">${esc6(e.requestedBy.name)} \xB7 ${when(e.requestedAt)}</span>
|
|
84546
84962
|
</div>
|
|
84547
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>` : ""}
|
|
84548
|
-
${st === "queued" && j?.queue?.estimatedStartAt ? note("dp2-info", `In\xEDcio estimado: ${
|
|
84549
|
-
${st === "failed" ? note("dp2-err", `${
|
|
84550
|
-
${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>` : ""}`) : ""}
|
|
84551
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.") : ""}
|
|
84552
84968
|
${st === "query_unavailable" ? note("dp2-info", "N\xE3o foi poss\xEDvel consultar o andamento agora \u2014 tentaremos de novo.") : ""}
|
|
84553
84969
|
${st === "old_request" ? note("dp2-info", 'Pedido antigo, sem registro de processamento. Use "Duplicar e editar".') : ""}
|
|
84554
84970
|
${st === "result_expired" ? note("dp2-info", "O relat\xF3rio foi conclu\xEDdo, mas os arquivos j\xE1 expiraram (ficam 3 dias).") : ""}
|
|
84555
84971
|
${st === "purged" ? note("dp2-info", "O conte\xFAdo deste relat\xF3rio foi removido.") : ""}
|
|
84556
|
-
${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)}` : ""}.`) : ""}
|
|
84557
84973
|
${st === "succeeded" && peakTxt ? note("dp2-info", peakTxt) : ""}
|
|
84558
|
-
${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))}.`) : ""}
|
|
84559
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>' : ""}
|
|
84560
84976
|
<div class="dp2-job-actions">
|
|
84561
|
-
${st === "succeeded" ? `<button class="dp2-btn sm primary" type="button" data-action="download" data-kind="xlsx" data-job="${
|
|
84562
|
-
<button class="dp2-btn sm" type="button" data-action="download" data-kind="csv" data-job="${
|
|
84563
|
-
<button class="dp2-btn sm" type="button" data-action="download" data-kind="json" data-job="${
|
|
84564
|
-
${st === "queued" || st === "running" ? `<button class="dp2-btn sm" type="button" data-action="cancel" data-job="${
|
|
84565
|
-
${v.canResend ? `<button class="dp2-btn sm primary" type="button" data-action="resend" data-job="${
|
|
84566
|
-
${["failed", "cancelled", "succeeded", "result_expired", "purged", "old_request", "rejected"].includes(st) ? `<button class="dp2-btn sm" type="button" data-action="clone" data-job="${
|
|
84567
|
-
${this.p.supportMode ? `<button class="dp2-btn link" type="button" data-action="details" data-job="${
|
|
84568
|
-
</div>
|
|
84569
|
-
${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>` : ""}
|
|
84570
84986
|
</article>`;
|
|
84571
84987
|
}).join("");
|
|
84572
84988
|
const orphanCards = orphans.map((j) => `<article class="dp2-job ghost"><div class="dp2-job-top">
|
|
84573
|
-
<span class="dp2-job-title">Job sem registro no ThingsBoard (O-6)</span><span class="dp2-status ${j.status}">${
|
|
84574
|
-
<span style="flex:1"></span><span class="dp2-info">${
|
|
84575
|
-
<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("");
|
|
84576
84992
|
this.el.body.innerHTML = cards + orphanCards;
|
|
84577
84993
|
}
|
|
84578
84994
|
/* ------------------------------------------------------------------ data flows */
|
|
@@ -86031,7 +86447,7 @@ function buildYearOptions() {
|
|
|
86031
86447
|
for (let y = now + 2; y >= now - 2; y--) out.push(y);
|
|
86032
86448
|
return out;
|
|
86033
86449
|
}
|
|
86034
|
-
function
|
|
86450
|
+
function esc7(s) {
|
|
86035
86451
|
return String(s == null ? "" : s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
86036
86452
|
}
|
|
86037
86453
|
function resolveThemeVars(theme) {
|
|
@@ -86602,7 +87018,7 @@ function openGoalsPanel(params) {
|
|
|
86602
87018
|
});
|
|
86603
87019
|
}
|
|
86604
87020
|
container.appendChild(rootEl);
|
|
86605
|
-
|
|
87021
|
+
injectStyles27();
|
|
86606
87022
|
rootEl.addEventListener("click", onClick);
|
|
86607
87023
|
rootEl.addEventListener("change", onChange);
|
|
86608
87024
|
rootEl.addEventListener("input", onInput);
|
|
@@ -86847,13 +87263,13 @@ function openGoalsPanel(params) {
|
|
|
86847
87263
|
const g = state6.goals || {};
|
|
86848
87264
|
const parts = [];
|
|
86849
87265
|
if (hasCoverageGaps(g.coverageGaps)) {
|
|
86850
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
87266
|
+
parts.push(`<p style="margin:0 0 8px;">${esc7(buildCoverageWarningTextPtBR(g.coverageGaps, "GERAL"))}</p>`);
|
|
86851
87267
|
}
|
|
86852
87268
|
(Array.isArray(g.devices) ? g.devices : []).forEach((d) => {
|
|
86853
87269
|
if (!hasCoverageGaps(d && d.coverageGaps)) return;
|
|
86854
87270
|
const label = d.label || d.code || "medidor";
|
|
86855
87271
|
parts.push(
|
|
86856
|
-
`<p style="margin:0 0 8px;">${
|
|
87272
|
+
`<p style="margin:0 0 8px;">${esc7(buildCoverageWarningTextPtBR(d.coverageGaps, `do medidor ${label}`))}</p>`
|
|
86857
87273
|
);
|
|
86858
87274
|
});
|
|
86859
87275
|
return `<div style="font-size:12px;line-height:1.55;color:#334155;">${parts.join("")}</div>`;
|
|
@@ -86893,7 +87309,7 @@ function openGoalsPanel(params) {
|
|
|
86893
87309
|
html += `<div class="myio-goals-alert myio-goals-alert-amber">${icon2("alert")} ${i18n2.versionConflict}</div>`;
|
|
86894
87310
|
}
|
|
86895
87311
|
if (state6.saveError && !state6.conflict) {
|
|
86896
|
-
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>`;
|
|
86897
87313
|
}
|
|
86898
87314
|
if (state6.saved && !state6.saveError) {
|
|
86899
87315
|
html += `<div class="myio-goals-alert myio-goals-alert-green">${icon2("check")} ${i18n2.saveSuccess}</div>`;
|
|
@@ -86908,7 +87324,7 @@ function openGoalsPanel(params) {
|
|
|
86908
87324
|
return `
|
|
86909
87325
|
<div class="myio-goals-center myio-goals-center-col">
|
|
86910
87326
|
${icon2("alert-lg")}
|
|
86911
|
-
<p>${
|
|
87327
|
+
<p>${esc7(state6.error)}</p>
|
|
86912
87328
|
<button class="myio-goals-btn myio-goals-btn-outline" data-action="retry">${i18n2.retry}</button>
|
|
86913
87329
|
</div>`;
|
|
86914
87330
|
}
|
|
@@ -86998,7 +87414,7 @@ function openGoalsPanel(params) {
|
|
|
86998
87414
|
const cellLabel = state6.level === "month" ? i18n2.months[key] : state6.level === "day" ? i18n2.dayCell.replace("{day}", Number(key)) : `${key}:00`;
|
|
86999
87415
|
const canDrill = state6.level !== "hour";
|
|
87000
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>`;
|
|
87001
|
-
const val = state6.draft[key] !== void 0 ?
|
|
87417
|
+
const val = state6.draft[key] !== void 0 ? esc7(state6.draft[key]) : "";
|
|
87002
87418
|
const minAttr = cfg.allowsNegative ? "" : 'min="0"';
|
|
87003
87419
|
return `
|
|
87004
87420
|
<div class="myio-goals-cell">
|
|
@@ -87066,7 +87482,7 @@ function openGoalsPanel(params) {
|
|
|
87066
87482
|
const actor = ev.actor ? `${String(ev.actor).slice(0, 8)}\u2026` : i18n2.history.system;
|
|
87067
87483
|
const extra = ev.bucketCount - (ev.details ? ev.details.length : 0);
|
|
87068
87484
|
const chips = (ev.details || []).slice(0, DETAIL_PREVIEW).map(
|
|
87069
|
-
(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>`
|
|
87070
87486
|
).join("");
|
|
87071
87487
|
const more = extra > 0 ? `<span class="myio-goals-tl-more">${i18n2.history.moreDetails.replace("{n}", extra)}</span>` : "";
|
|
87072
87488
|
return `
|
|
@@ -87076,7 +87492,7 @@ function openGoalsPanel(params) {
|
|
|
87076
87492
|
<span class="myio-goals-tl-title">${i18n2.history.source[ev.source] || i18n2.history.source.EDIT}</span>
|
|
87077
87493
|
<span class="myio-goals-tl-ver">v${ev.version}</span>
|
|
87078
87494
|
</div>
|
|
87079
|
-
<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>
|
|
87080
87496
|
<p class="myio-goals-tl-records">${i18n2.history.records.replace("{n}", ev.bucketCount)} \xB7 ${i18n2.levels[ev.actionLevel] || ev.actionLevel}</p>
|
|
87081
87497
|
${chips || more ? `<div class="myio-goals-tl-chips">${chips}${more}</div>` : ""}
|
|
87082
87498
|
</li>`;
|
|
@@ -87123,7 +87539,7 @@ ${state6.year}-03-15T08,15`;
|
|
|
87123
87539
|
let html = `
|
|
87124
87540
|
<div class="myio-goals-import-hint">
|
|
87125
87541
|
<p>${i18n2.import.formatHint}</p>
|
|
87126
|
-
<code>${
|
|
87542
|
+
<code>${esc7(sample)}</code>
|
|
87127
87543
|
</div>`;
|
|
87128
87544
|
if (!applied) {
|
|
87129
87545
|
html += `
|
|
@@ -87137,16 +87553,16 @@ ${state6.year}-03-15T08,15`;
|
|
|
87137
87553
|
<input type="file" id="myio-goals-csv-file" accept=".csv,.txt,text/csv,text/plain" style="display:none" />
|
|
87138
87554
|
</div>
|
|
87139
87555
|
</div>
|
|
87140
|
-
<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
|
|
87141
87557
|
${state6.year},100000
|
|
87142
87558
|
${state6.year}-03,9000
|
|
87143
87559
|
${state6.year}-03-15,310
|
|
87144
|
-
${state6.year}-03-15T08,15`)}">${
|
|
87560
|
+
${state6.year}-03-15T08,15`)}">${esc7(state6.csv)}</textarea>
|
|
87145
87561
|
<p class="myio-goals-microhint">${i18n2.import.unitNote.replace("{unit}", unitLabel2())}</p>
|
|
87146
87562
|
</div>`;
|
|
87147
87563
|
}
|
|
87148
87564
|
if (state6.saveError && state6.conflictVersion === null) {
|
|
87149
|
-
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>`;
|
|
87150
87566
|
}
|
|
87151
87567
|
if (state6.conflictVersion !== null) {
|
|
87152
87568
|
html += `<div class="myio-goals-alert myio-goals-alert-amber">${icon2("alert")} ${i18n2.import.conflict}</div>`;
|
|
@@ -87175,7 +87591,7 @@ ${state6.year}-03-15T08,15`)}">${esc6(state6.csv)}</textarea>
|
|
|
87175
87591
|
<div class="myio-goals-import-diags">
|
|
87176
87592
|
<p class="myio-goals-import-diags-title">${i18n2.import.diagnosticsTitle}</p>
|
|
87177
87593
|
<ul>${result.diagnostics.map(
|
|
87178
|
-
(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>`
|
|
87179
87595
|
).join("")}</ul>
|
|
87180
87596
|
</div>`;
|
|
87181
87597
|
}
|
|
@@ -87183,7 +87599,7 @@ ${state6.year}-03-15T08,15`)}">${esc6(state6.csv)}</textarea>
|
|
|
87183
87599
|
html += `
|
|
87184
87600
|
<div class="myio-goals-import-log">
|
|
87185
87601
|
<p class="myio-goals-import-log-title">${i18n2.import.logTitle}</p>
|
|
87186
|
-
<ul>${result.log.map((line) => `<li>${
|
|
87602
|
+
<ul>${result.log.map((line) => `<li>${esc7(line)}</li>`).join("")}</ul>
|
|
87187
87603
|
</div>`;
|
|
87188
87604
|
}
|
|
87189
87605
|
html += `</div>`;
|
|
@@ -87257,7 +87673,7 @@ ${state6.year}-03-15T08,15`)}">${esc6(state6.csv)}</textarea>
|
|
|
87257
87673
|
return "";
|
|
87258
87674
|
}
|
|
87259
87675
|
}
|
|
87260
|
-
function
|
|
87676
|
+
function injectStyles27() {
|
|
87261
87677
|
const id = "myio-goals-gcdr-styles";
|
|
87262
87678
|
const prev = document.getElementById(id);
|
|
87263
87679
|
if (prev) prev.remove();
|
|
@@ -94426,7 +94842,7 @@ function injectCSS10() {
|
|
|
94426
94842
|
document.head.appendChild(style);
|
|
94427
94843
|
_cssInjected2 = true;
|
|
94428
94844
|
}
|
|
94429
|
-
function
|
|
94845
|
+
function esc8(value) {
|
|
94430
94846
|
return String(value == null ? "" : value).replace(
|
|
94431
94847
|
/[&<>"]/g,
|
|
94432
94848
|
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]
|
|
@@ -94476,7 +94892,7 @@ function buildPieSvg(visible, total) {
|
|
|
94476
94892
|
const val = Number(v.d.value) || 0;
|
|
94477
94893
|
return `<svg class="myio-col-summary__pie" viewBox="0 0 220 220">
|
|
94478
94894
|
<circle class="myio-col-summary__slice" data-idx="${v.idx}" cx="110" cy="110" r="100"
|
|
94479
|
-
fill="${sliceColor(v.idx)}"><title>${
|
|
94895
|
+
fill="${sliceColor(v.idx)}"><title>${esc8(v.d.name)} \u2014 ${esc8(fmt2(val))} (${fmtPct2(
|
|
94480
94896
|
val,
|
|
94481
94897
|
total,
|
|
94482
94898
|
pd
|
|
@@ -94491,7 +94907,7 @@ function buildPieSvg(visible, total) {
|
|
|
94491
94907
|
const a1 = acc / total * 360;
|
|
94492
94908
|
return `<path class="myio-col-summary__slice" data-idx="${v.idx}"
|
|
94493
94909
|
d="${arcPath(110, 110, 100, a0, a1)}" fill="${sliceColor(v.idx)}"
|
|
94494
|
-
><title>${
|
|
94910
|
+
><title>${esc8(v.d.name)} \u2014 ${esc8(fmt2(val))} (${fmtPct2(val, total, pd)})</title></path>`;
|
|
94495
94911
|
}).join("");
|
|
94496
94912
|
return `<svg class="myio-col-summary__pie" viewBox="0 0 220 220">${paths}</svg>`;
|
|
94497
94913
|
}
|
|
@@ -94505,8 +94921,8 @@ function buildLegend(total) {
|
|
|
94505
94921
|
return `<div class="myio-col-summary__legend-row${isExcl ? " is-excluded" : ""}" data-idx="${idx}"
|
|
94506
94922
|
title="Clique para ${isExcl ? "incluir" : "remover"} da pizza">
|
|
94507
94923
|
<span class="myio-col-summary__legend-dot" style="background:${sliceColor(idx)};"></span>
|
|
94508
|
-
<span class="myio-col-summary__legend-name">${
|
|
94509
|
-
<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>
|
|
94510
94926
|
<span class="myio-col-summary__legend-pct">${pct}</span>
|
|
94511
94927
|
</div>`;
|
|
94512
94928
|
}).join("");
|
|
@@ -94527,25 +94943,25 @@ function buildAverageInner() {
|
|
|
94527
94943
|
const dash = "\u2014";
|
|
94528
94944
|
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
94529
94945
|
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
94530
|
-
<span class="myio-col-summary__kpi-value">${
|
|
94946
|
+
<span class="myio-col-summary__kpi-value">${esc8(data.periodLabel)}</span>
|
|
94531
94947
|
</div>` : "";
|
|
94532
94948
|
const note = "M\xE9dia, m\xEDnima e m\xE1xima consideram apenas dispositivos online (com leitura).";
|
|
94533
94949
|
const kpis = `<div class="myio-col-summary__kpis">
|
|
94534
94950
|
${periodRow}
|
|
94535
94951
|
<div class="myio-col-summary__kpi">
|
|
94536
94952
|
<span class="myio-col-summary__kpi-label">Dispositivos
|
|
94537
|
-
<span class="myio-col-summary__info" title="${
|
|
94953
|
+
<span class="myio-col-summary__info" title="${esc8(note)}" aria-label="${esc8(note)}"
|
|
94538
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>
|
|
94539
94955
|
</span>
|
|
94540
94956
|
<span class="myio-col-summary__kpi-value">${online.length} online \xB7 ${offline.length} offline</span>
|
|
94541
94957
|
</div>
|
|
94542
94958
|
<div class="myio-col-summary__kpi">
|
|
94543
|
-
<span class="myio-col-summary__kpi-label">${
|
|
94544
|
-
<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>
|
|
94545
94961
|
</div>
|
|
94546
94962
|
<div class="myio-col-summary__kpi">
|
|
94547
94963
|
<span class="myio-col-summary__kpi-label">M\xEDnima \xB7 M\xE1xima</span>
|
|
94548
|
-
<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>
|
|
94549
94965
|
</div>
|
|
94550
94966
|
</div>`;
|
|
94551
94967
|
if (!data.devices.length) {
|
|
@@ -94554,12 +94970,12 @@ function buildAverageInner() {
|
|
|
94554
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);
|
|
94555
94971
|
const row = (v) => `
|
|
94556
94972
|
<div class="myio-col-summary__row">
|
|
94557
|
-
<span class="myio-col-summary__name" title="${
|
|
94558
|
-
<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>
|
|
94559
94975
|
</div>`;
|
|
94560
94976
|
const offRow = (v) => `
|
|
94561
94977
|
<div class="myio-col-summary__row">
|
|
94562
|
-
<span class="myio-col-summary__name" title="${
|
|
94978
|
+
<span class="myio-col-summary__name" title="${esc8(v.d.name)}">${esc8(v.d.name)}</span>
|
|
94563
94979
|
<span class="myio-col-summary__val" style="color:#94a3b8;">sem leitura</span>
|
|
94564
94980
|
</div>`;
|
|
94565
94981
|
const group = (label, list, r = row) => list.length ? `<div class="myio-col-summary__group">
|
|
@@ -94576,8 +94992,8 @@ function buildAverageInner() {
|
|
|
94576
94992
|
</div>
|
|
94577
94993
|
</div>
|
|
94578
94994
|
<div class="myio-col-summary__footer">
|
|
94579
|
-
<span class="myio-col-summary__footer-label">${
|
|
94580
|
-
<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>
|
|
94581
94997
|
</div>`;
|
|
94582
94998
|
}
|
|
94583
94999
|
function buildInner() {
|
|
@@ -94590,7 +95006,7 @@ function buildInner() {
|
|
|
94590
95006
|
const avg = count ? total / count : 0;
|
|
94591
95007
|
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
94592
95008
|
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
94593
|
-
<span class="myio-col-summary__kpi-value">${
|
|
95009
|
+
<span class="myio-col-summary__kpi-value">${esc8(data.periodLabel)}</span>
|
|
94594
95010
|
</div>` : "";
|
|
94595
95011
|
const kpis = `<div class="myio-col-summary__kpis">
|
|
94596
95012
|
${periodRow}
|
|
@@ -94600,13 +95016,13 @@ function buildInner() {
|
|
|
94600
95016
|
</div>
|
|
94601
95017
|
<div class="myio-col-summary__kpi">
|
|
94602
95018
|
<span class="myio-col-summary__kpi-label">Consumo m\xE9dio</span>
|
|
94603
|
-
<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(
|
|
94604
95020
|
fmt2(avg)
|
|
94605
95021
|
)}</span>
|
|
94606
95022
|
</div>
|
|
94607
95023
|
<div class="myio-col-summary__kpi">
|
|
94608
95024
|
<span class="myio-col-summary__kpi-label">Consumo total</span>
|
|
94609
|
-
<span class="myio-col-summary__kpi-value">${
|
|
95025
|
+
<span class="myio-col-summary__kpi-value">${esc8(fmt2(total))}</span>
|
|
94610
95026
|
</div>
|
|
94611
95027
|
</div>`;
|
|
94612
95028
|
if (!data.devices.length) {
|
|
@@ -94620,8 +95036,8 @@ function buildInner() {
|
|
|
94620
95036
|
).slice(0, 3);
|
|
94621
95037
|
const row = (v) => `
|
|
94622
95038
|
<div class="myio-col-summary__row">
|
|
94623
|
-
<span class="myio-col-summary__name" title="${
|
|
94624
|
-
<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>
|
|
94625
95041
|
<span class="myio-col-summary__pct">${fmtPct2(Number(v.d.value) || 0, total, pd)}</span>
|
|
94626
95042
|
</div>`;
|
|
94627
95043
|
const group = (label, list) => list.length ? `<div class="myio-col-summary__group">
|
|
@@ -94644,7 +95060,7 @@ function buildInner() {
|
|
|
94644
95060
|
</div>
|
|
94645
95061
|
<div class="myio-col-summary__footer">
|
|
94646
95062
|
<span class="myio-col-summary__footer-label">Consumo Total \xB7 ${count} dispositivos</span>
|
|
94647
|
-
<span class="myio-col-summary__footer-value">${
|
|
95063
|
+
<span class="myio-col-summary__footer-value">${esc8(fmt2(total))}</span>
|
|
94648
95064
|
</div>`;
|
|
94649
95065
|
}
|
|
94650
95066
|
function setHighlight(idx) {
|
|
@@ -101584,7 +102000,7 @@ function createConsumptionChartWidget(config2) {
|
|
|
101584
102000
|
</div>
|
|
101585
102001
|
`;
|
|
101586
102002
|
}
|
|
101587
|
-
function
|
|
102003
|
+
function injectStyles27() {
|
|
101588
102004
|
if (styleElement) return;
|
|
101589
102005
|
styleElement = document.createElement("style");
|
|
101590
102006
|
styleElement.id = `${widgetId}-styles`;
|
|
@@ -102098,7 +102514,7 @@ function createConsumptionChartWidget(config2) {
|
|
|
102098
102514
|
console.error(`[ConsumptionWidget] Container #${config2.containerId} not found`);
|
|
102099
102515
|
return;
|
|
102100
102516
|
}
|
|
102101
|
-
|
|
102517
|
+
injectStyles27();
|
|
102102
102518
|
containerElement.innerHTML = renderHTML();
|
|
102103
102519
|
setupListeners();
|
|
102104
102520
|
applyCollapseState();
|
|
@@ -102234,7 +102650,7 @@ function createConsumptionChartWidget(config2) {
|
|
|
102234
102650
|
// src/components/tooltips/goals-bar-tooltip/createGoalsBarTooltip.ts
|
|
102235
102651
|
var STYLE_ID10 = "myio-goals-bar-tooltip-styles";
|
|
102236
102652
|
var DEFAULT_ACCENT = "#6c5ce7";
|
|
102237
|
-
function
|
|
102653
|
+
function injectStyles13(doc) {
|
|
102238
102654
|
if (doc.getElementById(STYLE_ID10)) return;
|
|
102239
102655
|
const s = doc.createElement("style");
|
|
102240
102656
|
s.id = STYLE_ID10;
|
|
@@ -102424,7 +102840,7 @@ function injectStyles12(doc) {
|
|
|
102424
102840
|
`;
|
|
102425
102841
|
(doc.head || doc.documentElement).appendChild(s);
|
|
102426
102842
|
}
|
|
102427
|
-
function
|
|
102843
|
+
function esc9(v) {
|
|
102428
102844
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
102429
102845
|
}
|
|
102430
102846
|
function fmtPct3(pct) {
|
|
@@ -102445,8 +102861,8 @@ function renderDeltaChip(delta) {
|
|
|
102445
102861
|
const tone = delta.tone === "good" ? "good" : delta.tone === "bad" ? "bad" : "neutral";
|
|
102446
102862
|
const arrow = delta.arrow === "up" ? "\u2191" : delta.arrow === "down" ? "\u2193" : "\u2248";
|
|
102447
102863
|
const pctTxt = fmtPct3(Math.abs(Number(delta.pct)));
|
|
102448
|
-
const txt = delta.text ? ` ${
|
|
102449
|
-
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>`;
|
|
102450
102866
|
}
|
|
102451
102867
|
function renderRow(row, level) {
|
|
102452
102868
|
const hasChildren = Array.isArray(row.children) && row.children.length > 0;
|
|
@@ -102454,12 +102870,12 @@ function renderRow(row, level) {
|
|
|
102454
102870
|
const id = `gbtr-${++_rowSeq}`;
|
|
102455
102871
|
const pct = row.pct;
|
|
102456
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>`;
|
|
102457
|
-
const swatch = row.color ? `<span class="myio-gbt__swatch" style="background:${
|
|
102458
|
-
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>` : "";
|
|
102459
102875
|
const chipHtml = row.delta ? renderDeltaChip(row.delta) : "";
|
|
102460
|
-
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>` : "";
|
|
102461
102877
|
const rowClass = level > 0 ? "myio-gbt__row myio-gbt__row--child" : "myio-gbt__row";
|
|
102462
|
-
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>`;
|
|
102463
102879
|
if (hasChildren) {
|
|
102464
102880
|
const childHtml = row.children.map((c) => renderRow(c, level + 1)).join("");
|
|
102465
102881
|
html += `<div class="myio-gbt__children${open ? " is-open" : ""}" data-children="${id}">${childHtml}</div>`;
|
|
@@ -102474,7 +102890,7 @@ function createGoalsBarTooltip(opts) {
|
|
|
102474
102890
|
return document;
|
|
102475
102891
|
}
|
|
102476
102892
|
})();
|
|
102477
|
-
|
|
102893
|
+
injectStyles13(doc);
|
|
102478
102894
|
const el2 = doc.createElement("div");
|
|
102479
102895
|
el2.className = "myio-gbt";
|
|
102480
102896
|
el2.style.setProperty("--myio-gbt-accent", resolveAccent3(opts?.accentColor, doc));
|
|
@@ -102542,8 +102958,8 @@ function createGoalsBarTooltip(opts) {
|
|
|
102542
102958
|
<div class="myio-gbt__card">
|
|
102543
102959
|
<div class="myio-gbt__header">
|
|
102544
102960
|
<div class="myio-gbt__title-wrap">
|
|
102545
|
-
<div class="myio-gbt__title">${
|
|
102546
|
-
${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>` : ""}
|
|
102547
102963
|
</div>
|
|
102548
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>
|
|
102549
102965
|
<button class="myio-gbt__btn myio-gbt__btn--close" data-action="close" title="Fechar">\u2715</button>
|
|
@@ -103552,19 +103968,19 @@ function _updateCoverageHint(topDoc) {
|
|
|
103552
103968
|
const deviceCount = data.granularity === "DEVICE" ? data.devices?.length ?? 0 : 0;
|
|
103553
103969
|
hint.textContent = `\u26A0 Meta incompleta para este dom\xEDnio/ano` + (deviceCount > 0 ? ` \xB7 Por medidor (${deviceCount})` : "") + ` \u2014 passe o mouse para detalhes`;
|
|
103554
103970
|
tabs.insertAdjacentElement("afterend", hint);
|
|
103555
|
-
const
|
|
103971
|
+
const esc12 = (s) => String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
103556
103972
|
try {
|
|
103557
103973
|
_coverageDetach = InfoTooltip.attach(hint, () => {
|
|
103558
103974
|
const d = _getGoalsData(_currentDomain);
|
|
103559
103975
|
const parts = [];
|
|
103560
103976
|
if (hasCoverageGaps(d?.coverageGaps)) {
|
|
103561
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
103977
|
+
parts.push(`<p style="margin:0 0 8px;">${esc12(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
|
|
103562
103978
|
}
|
|
103563
103979
|
(d?.devices || []).forEach((dev) => {
|
|
103564
103980
|
if (!hasCoverageGaps(dev?.coverageGaps)) return;
|
|
103565
103981
|
const label = dev.label || dev.code || "medidor";
|
|
103566
103982
|
parts.push(
|
|
103567
|
-
`<p style="margin:0 0 8px;">${
|
|
103983
|
+
`<p style="margin:0 0 8px;">${esc12(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
|
|
103568
103984
|
);
|
|
103569
103985
|
});
|
|
103570
103986
|
return {
|
|
@@ -109086,11 +109502,11 @@ function deviceCategoryToPanelTerm(cat) {
|
|
|
109086
109502
|
function panelTermToDeviceCategory(term) {
|
|
109087
109503
|
return term == null ? null : panelCategoryToWire(term);
|
|
109088
109504
|
}
|
|
109089
|
-
function
|
|
109505
|
+
function esc10(s) {
|
|
109090
109506
|
return String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
109091
109507
|
}
|
|
109092
109508
|
function categoryOptionsHTML(selected) {
|
|
109093
|
-
const opt = (value, label, isSel) => `<option value="${value}"${isSel ? " selected" : ""}>${
|
|
109509
|
+
const opt = (value, label, isSel) => `<option value="${value}"${isSel ? " selected" : ""}>${esc10(label)}</option>`;
|
|
109094
109510
|
return opt("", NONE_LABEL, selected == null) + opt("COMMON_AREA", deviceCategoryLabel("COMMON_AREA"), selected === "COMMON_AREA") + opt("SPECIFIC", deviceCategoryLabel("SPECIFIC"), selected === "SPECIFIC");
|
|
109095
109511
|
}
|
|
109096
109512
|
function openDeviceCategoryPanel(params) {
|
|
@@ -109127,8 +109543,8 @@ function openDeviceCategoryPanel(params) {
|
|
|
109127
109543
|
<select class="myio-devcat__filter" data-devcat-filter="1" aria-label="Filtrar por categoria">
|
|
109128
109544
|
<option value="all">Todas as categorias</option>
|
|
109129
109545
|
<option value="uncategorized">Sem categoria</option>
|
|
109130
|
-
<option value="COMMON_AREA">${
|
|
109131
|
-
<option value="SPECIFIC">${
|
|
109546
|
+
<option value="COMMON_AREA">${esc10(deviceCategoryLabel("COMMON_AREA"))}</option>
|
|
109547
|
+
<option value="SPECIFIC">${esc10(deviceCategoryLabel("SPECIFIC"))}</option>
|
|
109132
109548
|
</select>
|
|
109133
109549
|
<label class="myio-devcat__filter" style="display:flex;align-items:center;gap:6px;cursor:pointer;">
|
|
109134
109550
|
<input type="checkbox" data-devcat-selectall="1" /> Selecionar vis\xEDveis
|
|
@@ -109137,9 +109553,9 @@ function openDeviceCategoryPanel(params) {
|
|
|
109137
109553
|
<div class="myio-devcat__bulkbar" data-devcat-bulkbar="1">
|
|
109138
109554
|
<span data-devcat-bulkcount="1">0 selecionados</span>
|
|
109139
109555
|
<select data-devcat-bulkcat="1" aria-label="Categoria para os selecionados">
|
|
109140
|
-
<option value="">${
|
|
109141
|
-
<option value="COMMON_AREA">${
|
|
109142
|
-
<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>
|
|
109143
109559
|
</select>
|
|
109144
109560
|
<button type="button" class="myio-devcat__bulk-apply" data-devcat-bulkapply="1">Aplicar a selecionados</button>
|
|
109145
109561
|
</div>
|
|
@@ -109169,16 +109585,16 @@ function openDeviceCategoryPanel(params) {
|
|
|
109169
109585
|
return rows.filter((r) => matchesFilter(r) && matchesSearch(r));
|
|
109170
109586
|
}
|
|
109171
109587
|
function rowHTML(r) {
|
|
109172
|
-
const name =
|
|
109173
|
-
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>` : "";
|
|
109174
109590
|
const checked = selected.has(r.deviceId) ? " checked" : "";
|
|
109175
109591
|
const focused = r.deviceId === params.focusDeviceId ? ' data-focused="1"' : "";
|
|
109176
109592
|
const catAttr = r.tariffCategory == null ? "null" : r.tariffCategory;
|
|
109177
|
-
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(
|
|
109178
109594
|
r.deviceId
|
|
109179
|
-
)}"${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(
|
|
109180
109596
|
r.deviceId
|
|
109181
|
-
)}" 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>`;
|
|
109182
109598
|
}
|
|
109183
109599
|
function render3() {
|
|
109184
109600
|
const vis = visibleRows();
|
|
@@ -109338,7 +109754,7 @@ function openDeviceCategoryPanel(params) {
|
|
|
109338
109754
|
rows = await port.listDevices({ customerId, domain: params.domain });
|
|
109339
109755
|
} catch (err) {
|
|
109340
109756
|
rows = [];
|
|
109341
|
-
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(
|
|
109342
109758
|
err?.message || "erro"
|
|
109343
109759
|
)}</div>`;
|
|
109344
109760
|
countEl.textContent = "";
|
|
@@ -116730,7 +117146,7 @@ var openCount3 = 0;
|
|
|
116730
117146
|
function escapeHtml15(v) {
|
|
116731
117147
|
return String(v).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
116732
117148
|
}
|
|
116733
|
-
function
|
|
117149
|
+
function injectStyles14() {
|
|
116734
117150
|
if (!document.getElementById(FONT_LINK_ID3)) {
|
|
116735
117151
|
const link = document.createElement("link");
|
|
116736
117152
|
link.id = FONT_LINK_ID3;
|
|
@@ -116772,7 +117188,7 @@ function injectStyles13() {
|
|
|
116772
117188
|
}
|
|
116773
117189
|
var FOCUSABLE2 = 'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
116774
117190
|
function openStandardModal(params) {
|
|
116775
|
-
|
|
117191
|
+
injectStyles14();
|
|
116776
117192
|
const dismissible = params.dismissible ?? true;
|
|
116777
117193
|
const buttons = params.buttons ?? [];
|
|
116778
117194
|
const modalId = `myio-stdmodal-${++openCount3}`;
|
|
@@ -116907,14 +117323,14 @@ function buildTemplateCsv(domain, devices, start, end, now = Date.now()) {
|
|
|
116907
117323
|
if (domain === "energy") header.push("value_reactive_kvarh");
|
|
116908
117324
|
const today = nowSaoPaulo(now);
|
|
116909
117325
|
const lines = [header.join(";")];
|
|
116910
|
-
const
|
|
117326
|
+
const esc12 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
116911
117327
|
const { ok } = splitImportableDevices(devices);
|
|
116912
117328
|
for (const dev of ok) {
|
|
116913
117329
|
for (const date of daysBetween(start, end)) {
|
|
116914
117330
|
if (date > today.date) break;
|
|
116915
117331
|
for (let h3 = 0; h3 < 24; h3++) {
|
|
116916
117332
|
if (date === today.date && h3 >= today.hour) break;
|
|
116917
|
-
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`, ""];
|
|
116918
117334
|
if (domain === "energy") cols.push("");
|
|
116919
117335
|
lines.push(cols.join(";"));
|
|
116920
117336
|
}
|
|
@@ -117175,10 +117591,10 @@ function accumulatedRows(domain, entries, profile = DEFAULT_DISTRIBUTION_PROFILE
|
|
|
117175
117591
|
}
|
|
117176
117592
|
function buildAccumulatedTemplateCsv(domain, devices, start, end) {
|
|
117177
117593
|
const lines = [["gateway_id", "slave_id", "device_name", "start_date", "end_date", TOTAL_COLUMN[domain]].join(";")];
|
|
117178
|
-
const
|
|
117594
|
+
const esc12 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
117179
117595
|
for (const dev of devices || []) {
|
|
117180
117596
|
if (!isImportableKey(dev)) continue;
|
|
117181
|
-
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(";"));
|
|
117182
117598
|
}
|
|
117183
117599
|
return { csv: "\uFEFF" + lines.join("\r\n") + "\r\n", rows: lines.length - 1 };
|
|
117184
117600
|
}
|
|
@@ -117368,11 +117784,11 @@ function fmtSaoPaulo(iso) {
|
|
|
117368
117784
|
return `${p(d.getUTCDate())}/${p(d.getUTCMonth() + 1)}/${d.getUTCFullYear()} ${p(d.getUTCHours())}:00`;
|
|
117369
117785
|
}
|
|
117370
117786
|
var STYLE_ID15 = "myio-tlmimport-styles";
|
|
117371
|
-
function
|
|
117787
|
+
function esc11(v) {
|
|
117372
117788
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
117373
117789
|
}
|
|
117374
117790
|
var fmtNum = (n, d = 0) => Number.isFinite(Number(n)) ? Number(n).toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d }) : "\u2014";
|
|
117375
|
-
function
|
|
117791
|
+
function injectStyles15() {
|
|
117376
117792
|
if (document.getElementById(STYLE_ID15)) return;
|
|
117377
117793
|
const style = document.createElement("style");
|
|
117378
117794
|
style.id = STYLE_ID15;
|
|
@@ -117431,7 +117847,7 @@ function injectStyles14() {
|
|
|
117431
117847
|
document.head.appendChild(style);
|
|
117432
117848
|
}
|
|
117433
117849
|
function issuesTable(errors, limit = 100) {
|
|
117434
|
-
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("");
|
|
117435
117851
|
const more = errors.length > limit ? `<p class="tlmi-muted">\u2026 e mais ${errors.length - limit} erro(s).</p>` : "";
|
|
117436
117852
|
return `<div class="tlmi-errors"><table><thead><tr><th>Linha</th><th>Problema</th></tr></thead><tbody>${rows}</tbody></table></div>${more}`;
|
|
117437
117853
|
}
|
|
@@ -117443,7 +117859,7 @@ function defaultPeriod(now) {
|
|
|
117443
117859
|
return { start: ymd(start), end: ymd(end) };
|
|
117444
117860
|
}
|
|
117445
117861
|
function openTelemetryImportModal(params) {
|
|
117446
|
-
|
|
117862
|
+
injectStyles15();
|
|
117447
117863
|
const domain = params.domain;
|
|
117448
117864
|
const txt = DOMAIN_TEXT[domain];
|
|
117449
117865
|
const now = params.now ?? (() => Date.now());
|
|
@@ -117509,10 +117925,10 @@ function openTelemetryImportModal(params) {
|
|
|
117509
117925
|
}
|
|
117510
117926
|
function apiErrorBanner() {
|
|
117511
117927
|
if (!s.apiError) return "";
|
|
117512
|
-
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>`;
|
|
117513
117929
|
}
|
|
117514
117930
|
function step1() {
|
|
117515
|
-
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(
|
|
117516
117932
|
missingKey.slice(0, 5).map((d) => d.label).join(", ")
|
|
117517
117933
|
)}${missingKey.length > 5 ? "\u2026" : ""}</div>` : "";
|
|
117518
117934
|
const model = (value, title, hint) => `
|
|
@@ -117539,16 +117955,16 @@ function openTelemetryImportModal(params) {
|
|
|
117539
117955
|
${warn}
|
|
117540
117956
|
<div class="tlmi-card"><h3>${s.model === "accumulated" ? "Per\xEDodo" : "Modelo da planilha"}</h3>
|
|
117541
117957
|
<div class="tlmi-row">
|
|
117542
|
-
<label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${
|
|
117543
|
-
<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>
|
|
117544
117960
|
<button class="tlmi-btn" type="button" data-action="template" ${importable.length ? "" : "disabled"}>\u2B07 Baixar modelo (CSV)</button>
|
|
117545
117961
|
</div>
|
|
117546
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>
|
|
117547
117963
|
</div>`;
|
|
117548
117964
|
}
|
|
117549
117965
|
function step2() {
|
|
117550
|
-
const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${
|
|
117551
|
-
<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>
|
|
117552
117968
|
<div class="tlmi-kpi"><span>Linhas para importar</span><strong>${fmtNum(s.rows.length)}</strong></div>
|
|
117553
117969
|
<div class="tlmi-kpi"><span>Em branco (ignoradas)</span><strong>${fmtNum(s.skippedEmpty)}</strong></div>
|
|
117554
117970
|
<div class="tlmi-kpi"><span>Com erro</span><strong style="color:${s.localErrors.length ? "#dc2626" : "#16a34a"}">${fmtNum(s.localErrors.length)}</strong></div>
|
|
@@ -117588,12 +118004,12 @@ function openTelemetryImportModal(params) {
|
|
|
117588
118004
|
}
|
|
117589
118005
|
function step2Accumulated() {
|
|
117590
118006
|
const fromFile = !!s.fileName && !s.parseError;
|
|
117591
|
-
const form = fromFile ? `<p class="tlmi-muted">Usando <strong>${
|
|
117592
|
-
<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>
|
|
117593
118009
|
<div class="tlmi-acc"><table><thead><tr><th>Dispositivo</th><th>Total (${txt.unit})</th></tr></thead><tbody>
|
|
117594
118010
|
${importable.map(
|
|
117595
|
-
(d, i) => `<tr><td>${
|
|
117596
|
-
<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>`
|
|
117597
118013
|
).join("")}
|
|
117598
118014
|
</tbody></table></div>`;
|
|
117599
118015
|
return `
|
|
@@ -117606,7 +118022,7 @@ function openTelemetryImportModal(params) {
|
|
|
117606
118022
|
<input type="file" accept=".xlsx,.xls,.csv" data-field="file" hidden />
|
|
117607
118023
|
\u{1F4C4} Clique ou arraste a planilha aqui (.xlsx ou .csv)
|
|
117608
118024
|
</label>
|
|
117609
|
-
${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>` : ""}
|
|
117610
118026
|
</div>
|
|
117611
118027
|
<div data-role="acc-summary" style="display:flex;flex-direction:column;gap:12px">${accSummaryHtml()}</div>`;
|
|
117612
118028
|
}
|
|
@@ -117632,7 +118048,7 @@ function openTelemetryImportModal(params) {
|
|
|
117632
118048
|
<div class="tlmi-kpi"><span>Total (${txt.unit})</span><strong>${fmtNum(p.totalValue, 2)}</strong></div>
|
|
117633
118049
|
<div class="tlmi-kpi"><span>Leituras substitu\xEDdas</span><strong>${fmtNum(p.existingReadingsInTarget)}</strong></div>
|
|
117634
118050
|
</div>
|
|
117635
|
-
<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>
|
|
117636
118052
|
${reactiveWarn}
|
|
117637
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.
|
|
117638
118054
|
<label class="tlmi-check" style="margin-top:6px"><input type="checkbox" data-field="confirmReal" ${s.confirmReal ? "checked" : ""} />
|
|
@@ -117651,7 +118067,7 @@ function openTelemetryImportModal(params) {
|
|
|
117651
118067
|
<div class="tlmi-muted" style="margin-top:4px">Dispositivos manuais continuam aparecendo sem comunica\xE7\xE3o no status:
|
|
117652
118068
|
o status conta s\xF3 leitura medida. Os totais e os cards usam os dados importados.</div></div>`;
|
|
117653
118069
|
} else if (j.status === "failed") {
|
|
117654
|
-
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>`;
|
|
117655
118071
|
} else if (j.status === "cancelled") {
|
|
117656
118072
|
banner = '<div class="tlmi-banner warn">Importa\xE7\xE3o cancelada. As leituras anteriores foram mantidas.</div>';
|
|
117657
118073
|
} else if (j.status === "reverted") {
|
|
@@ -117663,14 +118079,14 @@ function openTelemetryImportModal(params) {
|
|
|
117663
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>
|
|
117664
118080
|
</div>` : "";
|
|
117665
118081
|
return `
|
|
117666
|
-
<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>
|
|
117667
118083
|
<div class="tlmi-progress" role="progressbar" aria-valuenow="${pct}" aria-valuemin="0" aria-valuemax="100"><i style="width:${pct}%"></i></div>
|
|
117668
118084
|
<div class="tlmi-kpis" style="margin-top:12px">
|
|
117669
118085
|
<div class="tlmi-kpi"><span>Progresso</span><strong>${fmtNum(pct)}%</strong></div>
|
|
117670
118086
|
<div class="tlmi-kpi"><span>Leituras removidas</span><strong>${fmtNum(j.deleted)}</strong></div>
|
|
117671
118087
|
<div class="tlmi-kpi"><span>Leituras gravadas</span><strong>${fmtNum(j.inserted)}</strong></div>
|
|
117672
118088
|
</div>
|
|
117673
|
-
${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>` : ""}
|
|
117674
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>
|
|
117675
118091
|
<span class="tlmi-muted" style="margin-left:8px">Voc\xEA pode fechar esta janela; a importa\xE7\xE3o continua.</span></div>` : ""}
|
|
117676
118092
|
${revert}
|
|
@@ -117980,8 +118396,8 @@ function siglaFromManualAsset(assetName) {
|
|
|
117980
118396
|
return /^[A-Z0-9_]+$/.test(sigla) ? sigla : null;
|
|
117981
118397
|
}
|
|
117982
118398
|
function nextManualSeq(domain, sigla, existingNames) {
|
|
117983
|
-
const
|
|
117984
|
-
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");
|
|
117985
118401
|
const max = existingNames.reduce((acc, n) => {
|
|
117986
118402
|
const m = re.exec(String(n || "").trim());
|
|
117987
118403
|
return m ? Math.max(acc, Number(m[1])) : acc;
|
|
@@ -118130,7 +118546,7 @@ var STYLE_ID16 = "myio-manualdev-styles";
|
|
|
118130
118546
|
function escapeHtml16(v) {
|
|
118131
118547
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
118132
118548
|
}
|
|
118133
|
-
function
|
|
118549
|
+
function injectStyles16() {
|
|
118134
118550
|
if (document.getElementById(STYLE_ID16)) return;
|
|
118135
118551
|
const style = document.createElement("style");
|
|
118136
118552
|
style.id = STYLE_ID16;
|
|
@@ -118270,7 +118686,7 @@ function progressHtml(steps, message, ok, open = false) {
|
|
|
118270
118686
|
function openManualDeviceModal(params) {
|
|
118271
118687
|
const domain = params.domain;
|
|
118272
118688
|
if (!MANUAL_DEVICE_PROFILES[domain]) throw new Error(`[openManualDeviceModal] dom\xEDnio inv\xE1lido: ${domain}`);
|
|
118273
|
-
|
|
118689
|
+
injectStyles16();
|
|
118274
118690
|
if (params.provisioner) return openProvisionedModal(params, params.provisioner);
|
|
118275
118691
|
const values = { label: "", identifier: "" };
|
|
118276
118692
|
let busy = false;
|
|
@@ -120540,7 +120956,7 @@ var FONT_LINK_ID4 = "myio-dialog-font-nunito";
|
|
|
120540
120956
|
function escapeHtml17(value) {
|
|
120541
120957
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
120542
120958
|
}
|
|
120543
|
-
function
|
|
120959
|
+
function injectStyles17() {
|
|
120544
120960
|
if (!document.getElementById(FONT_LINK_ID4)) {
|
|
120545
120961
|
const link = document.createElement("link");
|
|
120546
120962
|
link.id = FONT_LINK_ID4;
|
|
@@ -120625,7 +121041,7 @@ function createScrollableTabs(options) {
|
|
|
120625
121041
|
if (typeof document === "undefined") {
|
|
120626
121042
|
throw new Error("[createScrollableTabs] requires a browser environment");
|
|
120627
121043
|
}
|
|
120628
|
-
|
|
121044
|
+
injectStyles17();
|
|
120629
121045
|
const theme = options.theme ?? "light";
|
|
120630
121046
|
const accent = options.accent ?? "#7C3AED";
|
|
120631
121047
|
const showArrows = options.showArrows ?? "auto";
|
|
@@ -120764,7 +121180,7 @@ function escapeHtml18(value) {
|
|
|
120764
121180
|
return String(value == null ? "" : value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
120765
121181
|
}
|
|
120766
121182
|
var PRM = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
120767
|
-
function
|
|
121183
|
+
function injectStyles18() {
|
|
120768
121184
|
if (!document.getElementById(FONT_LINK_ID5)) {
|
|
120769
121185
|
const link = document.createElement("link");
|
|
120770
121186
|
link.id = FONT_LINK_ID5;
|
|
@@ -120933,7 +121349,7 @@ function createImgGallery(options) {
|
|
|
120933
121349
|
if (typeof document === "undefined") {
|
|
120934
121350
|
throw new Error("[createImgGallery] requires a browser environment");
|
|
120935
121351
|
}
|
|
120936
|
-
|
|
121352
|
+
injectStyles18();
|
|
120937
121353
|
const locale = options.locale === "en-US" ? "en-US" : "pt-BR";
|
|
120938
121354
|
const theme = options.theme ?? "light";
|
|
120939
121355
|
const accent = options.accent ?? "#7C3AED";
|
|
@@ -134572,7 +134988,7 @@ var MODAL_CSS2 = `
|
|
|
134572
134988
|
background: rgba(255, 255, 255, 0.2);
|
|
134573
134989
|
}
|
|
134574
134990
|
`;
|
|
134575
|
-
function
|
|
134991
|
+
function injectStyles19() {
|
|
134576
134992
|
if (document.getElementById(CSS_ID5)) return;
|
|
134577
134993
|
const style = document.createElement("style");
|
|
134578
134994
|
style.id = CSS_ID5;
|
|
@@ -134589,7 +135005,7 @@ var FilterModalComponent = class {
|
|
|
134589
135005
|
showDeviceGrid;
|
|
134590
135006
|
deviceSearchQuery = "";
|
|
134591
135007
|
constructor(options) {
|
|
134592
|
-
|
|
135008
|
+
injectStyles19();
|
|
134593
135009
|
this.options = options;
|
|
134594
135010
|
this.themeMode = options.themeMode || "light";
|
|
134595
135011
|
this.selectedCategories = new Set(
|
|
@@ -138739,7 +139155,7 @@ function buildSections(ctx) {
|
|
|
138739
139155
|
}
|
|
138740
139156
|
];
|
|
138741
139157
|
}
|
|
138742
|
-
function
|
|
139158
|
+
function injectStyles20() {
|
|
138743
139159
|
if (document.getElementById(STYLE_ID20)) return;
|
|
138744
139160
|
const style = document.createElement("style");
|
|
138745
139161
|
style.id = STYLE_ID20;
|
|
@@ -138841,7 +139257,7 @@ function openMetasGuide(options = {}) {
|
|
|
138841
139257
|
const sections = buildSections({ energy, water, curY, prevY });
|
|
138842
139258
|
const total = sections.length;
|
|
138843
139259
|
document.getElementById(ROOT_ID)?.remove();
|
|
138844
|
-
|
|
139260
|
+
injectStyles20();
|
|
138845
139261
|
const previouslyFocused = document.activeElement;
|
|
138846
139262
|
let index = 0;
|
|
138847
139263
|
let closed = false;
|
|
@@ -142686,7 +143102,7 @@ var TELEMETRY_GRID_SHOPPING_STYLES = `
|
|
|
142686
143102
|
text-overflow: ellipsis;
|
|
142687
143103
|
}
|
|
142688
143104
|
`;
|
|
142689
|
-
function
|
|
143105
|
+
function injectStyles21(_container) {
|
|
142690
143106
|
const styleId = "telemetry-grid-shopping-styles";
|
|
142691
143107
|
if (document.getElementById(styleId)) {
|
|
142692
143108
|
return;
|
|
@@ -142734,7 +143150,7 @@ var TelemetryGridShoppingView = class {
|
|
|
142734
143150
|
// Render
|
|
142735
143151
|
// =========================================================================
|
|
142736
143152
|
render() {
|
|
142737
|
-
|
|
143153
|
+
injectStyles21(this.root);
|
|
142738
143154
|
this.root.innerHTML = this.buildHTML();
|
|
142739
143155
|
this.cacheElements();
|
|
142740
143156
|
this.bindEvents();
|
|
@@ -144405,7 +144821,7 @@ var TELEMETRY_INFO_SHOPPING_STYLES = `
|
|
|
144405
144821
|
}
|
|
144406
144822
|
}
|
|
144407
144823
|
`;
|
|
144408
|
-
function
|
|
144824
|
+
function injectStyles22(_container) {
|
|
144409
144825
|
const styleId = "telemetry-info-shopping-styles-v2";
|
|
144410
144826
|
if (document.getElementById(styleId)) {
|
|
144411
144827
|
return;
|
|
@@ -144465,7 +144881,7 @@ var TelemetryInfoShoppingView = class _TelemetryInfoShoppingView {
|
|
|
144465
144881
|
// Render
|
|
144466
144882
|
// =========================================================================
|
|
144467
144883
|
render() {
|
|
144468
|
-
|
|
144884
|
+
injectStyles22(this.root);
|
|
144469
144885
|
this.root.innerHTML = this.buildHTML();
|
|
144470
144886
|
this.cacheElements();
|
|
144471
144887
|
this.bindEvents();
|
|
@@ -152846,10 +153262,10 @@ var AlarmsNotificationsPanelView = class {
|
|
|
152846
153262
|
const renderListPanel = (group, items, sel) => {
|
|
152847
153263
|
if (items.length === 0) return '<div class="afm-empty">Nenhum item encontrado</div>';
|
|
152848
153264
|
return items.map((item) => {
|
|
152849
|
-
const
|
|
153265
|
+
const esc12 = this.esc(item);
|
|
152850
153266
|
return `<label class="afm-check-item">
|
|
152851
|
-
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${
|
|
152852
|
-
<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>
|
|
152853
153269
|
</label>`;
|
|
152854
153270
|
}).join("");
|
|
152855
153271
|
};
|
|
@@ -163318,7 +163734,7 @@ var STYLES = `
|
|
|
163318
163734
|
color: var(--dgv6-ink-2);
|
|
163319
163735
|
}
|
|
163320
163736
|
`;
|
|
163321
|
-
function
|
|
163737
|
+
function injectStyles23() {
|
|
163322
163738
|
if (document.getElementById(CSS_ID6)) return;
|
|
163323
163739
|
const style = document.createElement("style");
|
|
163324
163740
|
style.id = CSS_ID6;
|
|
@@ -163357,7 +163773,7 @@ var DeviceGridV6View = class {
|
|
|
163357
163773
|
// Render
|
|
163358
163774
|
// =========================================================================
|
|
163359
163775
|
render() {
|
|
163360
|
-
|
|
163776
|
+
injectStyles23();
|
|
163361
163777
|
this.root.innerHTML = this.buildHTML();
|
|
163362
163778
|
this.cacheElements();
|
|
163363
163779
|
this.bindEvents();
|
|
@@ -165727,7 +166143,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165727
166143
|
const docTitle = buildActivationReportTitle(deviceName, opts.customerName);
|
|
165728
166144
|
const issuedAt = formatIssuedAt(/* @__PURE__ */ new Date(), locale);
|
|
165729
166145
|
const utilization = data.totalHours > 0 ? (data.totalOnMinutes / (data.totalHours * 60) * 100).toFixed(1) : "0.0";
|
|
165730
|
-
const
|
|
166146
|
+
const esc12 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
165731
166147
|
const htmlContent = `
|
|
165732
166148
|
<!DOCTYPE html>
|
|
165733
166149
|
<html lang="pt-BR">
|
|
@@ -165779,14 +166195,14 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165779
166195
|
<div class="brand">MyIO BAS</div>
|
|
165780
166196
|
<h1>Relat\xF3rio de Acionamentos</h1>
|
|
165781
166197
|
<div class="meta">
|
|
165782
|
-
<div><b>Dispositivo:</b> ${
|
|
166198
|
+
<div><b>Dispositivo:</b> ${esc12(deviceName)}</div>
|
|
165783
166199
|
<div><b>Per\xEDodo:</b> ${periodStart} \u2014 ${periodEnd}</div>
|
|
165784
166200
|
</div>
|
|
165785
166201
|
</div>
|
|
165786
166202
|
${customerName ? `
|
|
165787
166203
|
<div class="customer-badge">
|
|
165788
166204
|
<div class="label">Cliente</div>
|
|
165789
|
-
<div class="value">${
|
|
166205
|
+
<div class="value">${esc12(customerName)}</div>
|
|
165790
166206
|
</div>` : ""}
|
|
165791
166207
|
</div>
|
|
165792
166208
|
|
|
@@ -165797,7 +166213,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165797
166213
|
</div>
|
|
165798
166214
|
<div class="summary-card accent-green">
|
|
165799
166215
|
<div class="summary-value">${formatDurationMinutes(data.totalOnMinutes)}</div>
|
|
165800
|
-
<div class="summary-label">Tempo ${
|
|
166216
|
+
<div class="summary-label">Tempo ${esc12(labelOn)}</div>
|
|
165801
166217
|
</div>
|
|
165802
166218
|
<div class="summary-card accent-amber">
|
|
165803
166219
|
<div class="summary-value">${utilization}%</div>
|
|
@@ -165825,7 +166241,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165825
166241
|
<tr>
|
|
165826
166242
|
<td>${formatDateForExport(seg.startTime, locale)}</td>
|
|
165827
166243
|
<td>${formatDateForExport(seg.endTime, locale)}</td>
|
|
165828
|
-
<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>
|
|
165829
166245
|
<td>${formatDurationMinutes(seg.durationMinutes)}</td>
|
|
165830
166246
|
<td>${seg.source === "manual" ? "Manual" : seg.source === "schedule" ? "Agendamento" : seg.source === "automation" ? "Automa\xE7\xE3o" : "Desconhecido"}</td>
|
|
165831
166247
|
</tr>
|
|
@@ -165834,7 +166250,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
165834
166250
|
</table>
|
|
165835
166251
|
|
|
165836
166252
|
<div class="footer">
|
|
165837
|
-
<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>
|
|
165838
166254
|
</div>
|
|
165839
166255
|
</body>
|
|
165840
166256
|
</html>
|
|
@@ -171824,7 +172240,7 @@ var STYLES2 = `
|
|
|
171824
172240
|
}
|
|
171825
172241
|
#${MODAL_ID6} .gcdr-fail-item:last-child { border-bottom: none; }
|
|
171826
172242
|
`;
|
|
171827
|
-
function
|
|
172243
|
+
function injectStyles24() {
|
|
171828
172244
|
if (document.getElementById(`${MODAL_ID6}-styles`)) return;
|
|
171829
172245
|
const style = document.createElement("style");
|
|
171830
172246
|
style.id = `${MODAL_ID6}-styles`;
|
|
@@ -171933,7 +172349,7 @@ function escHtml4(str) {
|
|
|
171933
172349
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
171934
172350
|
}
|
|
171935
172351
|
async function openGCDRSyncModal(params) {
|
|
171936
|
-
|
|
172352
|
+
injectStyles24();
|
|
171937
172353
|
removeExistingModal();
|
|
171938
172354
|
if (!params.thingsboardToken) {
|
|
171939
172355
|
alert("Token ThingsBoard n\xE3o encontrado. Fa\xE7a login novamente.");
|
|
@@ -172506,7 +172922,7 @@ var STYLES3 = `
|
|
|
172506
172922
|
.abm-confirm-btn--confirm { background: #e67e22; color: #fff; }
|
|
172507
172923
|
.abm-confirm-btn--confirm:hover { background: #cf6d17; }
|
|
172508
172924
|
`;
|
|
172509
|
-
function
|
|
172925
|
+
function injectStyles25() {
|
|
172510
172926
|
if (document.getElementById(`${MODAL_ID7}-styles`)) return;
|
|
172511
172927
|
const style = document.createElement("style");
|
|
172512
172928
|
style.id = `${MODAL_ID7}-styles`;
|
|
@@ -173185,7 +173601,7 @@ async function fetchBundle(customerTB_ID, gcdrTenantId, baseUrl) {
|
|
|
173185
173601
|
return json.data;
|
|
173186
173602
|
}
|
|
173187
173603
|
async function openAlarmBundleMapModal(params) {
|
|
173188
|
-
|
|
173604
|
+
injectStyles25();
|
|
173189
173605
|
removeExistingModal2();
|
|
173190
173606
|
if (!params.customerTB_ID) {
|
|
173191
173607
|
alert("Customer TB ID n\xE3o informado. N\xE3o \xE9 poss\xEDvel carregar o mapa de alarmes.");
|
|
@@ -177247,7 +177663,7 @@ var VirtualList = class {
|
|
|
177247
177663
|
|
|
177248
177664
|
// src/components/header-annotations-panel/ExportModal.ts
|
|
177249
177665
|
var MODAL_DOM_ID = "myio-annotations-export-modal";
|
|
177250
|
-
var
|
|
177666
|
+
var STYLES_ID5 = "myio-annotations-export-modal-styles";
|
|
177251
177667
|
var STYLES4 = `
|
|
177252
177668
|
.${MODAL_DOM_ID}-backdrop {
|
|
177253
177669
|
position: fixed; inset: 0; z-index: 99999;
|
|
@@ -177322,17 +177738,17 @@ var STYLES4 = `
|
|
|
177322
177738
|
background: #cbd5e1; border-color: #cbd5e1; cursor: not-allowed;
|
|
177323
177739
|
}
|
|
177324
177740
|
`;
|
|
177325
|
-
function
|
|
177741
|
+
function injectStyles26() {
|
|
177326
177742
|
if (typeof document === "undefined") return;
|
|
177327
|
-
if (document.getElementById(
|
|
177743
|
+
if (document.getElementById(STYLES_ID5)) return;
|
|
177328
177744
|
const el2 = document.createElement("style");
|
|
177329
|
-
el2.id =
|
|
177745
|
+
el2.id = STYLES_ID5;
|
|
177330
177746
|
el2.textContent = STYLES4;
|
|
177331
177747
|
document.head.appendChild(el2);
|
|
177332
177748
|
}
|
|
177333
177749
|
var _activeBackdrop = null;
|
|
177334
177750
|
function openExportModal(options) {
|
|
177335
|
-
|
|
177751
|
+
injectStyles26();
|
|
177336
177752
|
closeExportModal();
|
|
177337
177753
|
const backdrop = document.createElement("div");
|
|
177338
177754
|
backdrop.className = `${MODAL_DOM_ID}-backdrop`;
|