myio-js-library 0.1.566 → 0.1.568
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 +1719 -220
- package/dist/index.d.cts +307 -12
- package/dist/index.d.ts +307 -12
- package/dist/index.js +1697 -217
- package/dist/myio-js-library.umd.js +1696 -217
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -222,9 +222,12 @@ __export(src_exports, {
|
|
|
222
222
|
IMPORTANCE_COLORS: () => IMPORTANCE_COLORS,
|
|
223
223
|
IMPORTANCE_LABELS: () => IMPORTANCE_LABELS,
|
|
224
224
|
IMPORTANCE_LABELS_EN: () => IMPORTANCE_LABELS_EN,
|
|
225
|
+
ImportApiError: () => ImportApiError,
|
|
225
226
|
InfoTooltip: () => InfoTooltip,
|
|
226
227
|
LoadingSpinner: () => LoadingSpinner,
|
|
227
228
|
LogHelper: () => LogHelper,
|
|
229
|
+
MANUAL_ASSET_SUFFIX: () => MANUAL_ASSET_SUFFIX,
|
|
230
|
+
MANUAL_DEVICE_PROFILES: () => MANUAL_DEVICE_PROFILES,
|
|
228
231
|
MEASUREMENT_DOMAIN_CONFIG: () => DOMAIN_CONFIG5,
|
|
229
232
|
MENU_SHOPPING_CSS_PREFIX: () => MENU_SHOPPING_CSS_PREFIX,
|
|
230
233
|
METRO_TILE_COLORS: () => METRO_TILE_COLORS,
|
|
@@ -235,6 +238,7 @@ __export(src_exports, {
|
|
|
235
238
|
MYIO_ACCENT: () => MYIO_ACCENT,
|
|
236
239
|
MYIO_CHART_PALETTE: () => MYIO_CHART_PALETTE,
|
|
237
240
|
MYIO_CHART_PALETTE_DARK: () => MYIO_CHART_PALETTE_DARK,
|
|
241
|
+
ManualDeviceError: () => ManualDeviceError,
|
|
238
242
|
MenuController: () => MenuController,
|
|
239
243
|
MenuShoppingView: () => MenuShoppingView,
|
|
240
244
|
MenuView: () => MenuView,
|
|
@@ -377,6 +381,7 @@ __export(src_exports, {
|
|
|
377
381
|
buildMoneyVarianceHTML: () => buildMoneyVarianceHTML,
|
|
378
382
|
buildMyioIngestionAuth: () => buildMyioIngestionAuth,
|
|
379
383
|
buildReportItemsList: () => buildReportItemsList,
|
|
384
|
+
buildTemplateCsv: () => buildTemplateCsv,
|
|
380
385
|
buildTemplateExport: () => buildTemplateExport,
|
|
381
386
|
buildTicketServiceOrchestrator: () => buildTicketServiceOrchestrator,
|
|
382
387
|
buildVerdictHTML: () => buildVerdictHTML,
|
|
@@ -476,6 +481,7 @@ __export(src_exports, {
|
|
|
476
481
|
createLibraryVersionChecker: () => createLibraryVersionChecker,
|
|
477
482
|
createLoadingSpinner: () => createLoadingSpinner,
|
|
478
483
|
createLogHelper: () => createLogHelper,
|
|
484
|
+
createManualDevice: () => createManualDevice,
|
|
479
485
|
createMenuComponent: () => createMenuComponent,
|
|
480
486
|
createMenuShoppingComponent: () => createMenuShoppingComponent,
|
|
481
487
|
createModalFooter: () => createModalFooter,
|
|
@@ -512,6 +518,7 @@ __export(src_exports, {
|
|
|
512
518
|
createTbEnvelopeStore: () => createTbEnvelopeStore,
|
|
513
519
|
createTelemetryGridComponent: () => createTelemetryGridComponent,
|
|
514
520
|
createTelemetryGridShoppingComponent: () => createTelemetryGridShoppingComponent,
|
|
521
|
+
createTelemetryImportApi: () => createTelemetryImportApi,
|
|
515
522
|
createTelemetryInfoShoppingComponent: () => createTelemetryInfoShoppingComponent,
|
|
516
523
|
createTicketDetailModal: () => createTicketDetailModal,
|
|
517
524
|
createTicketsTab: () => createTicketsTab,
|
|
@@ -547,7 +554,7 @@ __export(src_exports, {
|
|
|
547
554
|
doSchedulesOverlap: () => doSchedulesOverlap,
|
|
548
555
|
downloadAnnotationsTextFile: () => downloadTextFile,
|
|
549
556
|
encodeDeviceProductCode: () => encodeDeviceProductCode,
|
|
550
|
-
escapeAnnotationHtml: () =>
|
|
557
|
+
escapeAnnotationHtml: () => escapeHtml20,
|
|
551
558
|
evaluateDeviceStatus: () => evaluateDeviceStatus,
|
|
552
559
|
expandBandHours: () => expandBandHours,
|
|
553
560
|
expandBandToHourBucketsByYear: () => expandBandToHourBucketsByYear,
|
|
@@ -574,6 +581,7 @@ __export(src_exports, {
|
|
|
574
581
|
fetchThingsboardCustomerAttrsFromStorage: () => fetchThingsboardCustomerAttrsFromStorage,
|
|
575
582
|
fetchThingsboardCustomerServerScopeAttrs: () => fetchThingsboardCustomerServerScopeAttrs,
|
|
576
583
|
fetchTicketsForDevice: () => fetchTicketsForDevice,
|
|
584
|
+
filterWellAutomationItems: () => filterWellAutomationItems,
|
|
577
585
|
findNode: () => findNode,
|
|
578
586
|
findValue: () => findValue,
|
|
579
587
|
findValueWithDefault: () => findValueWithDefault,
|
|
@@ -680,6 +688,7 @@ __export(src_exports, {
|
|
|
680
688
|
hasSelectedDays: () => hasSelectedDays,
|
|
681
689
|
highlightAnnotationMatches: () => highlightMatches,
|
|
682
690
|
indicatorsFromModalData: () => indicatorsFromModalData,
|
|
691
|
+
indicatorsFromSharedWellValves: () => indicatorsFromSharedWellValves,
|
|
683
692
|
initMyIOAuthContext: () => initMyIOAuthContext,
|
|
684
693
|
initOnOffTimelineTooltips: () => initOnOffTimelineTooltips,
|
|
685
694
|
injectActionButtonStyles: () => injectActionButtonStyles,
|
|
@@ -691,7 +700,7 @@ __export(src_exports, {
|
|
|
691
700
|
injectCustomerCardV1Styles: () => injectCustomerCardV1Styles,
|
|
692
701
|
injectCustomerCardV2Styles: () => injectCustomerCardV2Styles,
|
|
693
702
|
injectDeviceCategoryStyles: () => injectDeviceCategoryStyles,
|
|
694
|
-
injectDeviceGridV6Styles: () =>
|
|
703
|
+
injectDeviceGridV6Styles: () => injectStyles22,
|
|
695
704
|
injectDeviceOperationalCardGridStyles: () => injectDeviceOperationalCardGridStyles,
|
|
696
705
|
injectDeviceOperationalCardStyles: () => injectDeviceOperationalCardStyles,
|
|
697
706
|
injectExportButtonStyles: () => injectExportButtonStyles,
|
|
@@ -751,6 +760,7 @@ __export(src_exports, {
|
|
|
751
760
|
listDeviceProductTypes: () => listDeviceProductTypes,
|
|
752
761
|
listDomains: () => listDomains,
|
|
753
762
|
listGroups: () => listGroups,
|
|
763
|
+
manualDeviceName: () => manualDeviceName,
|
|
754
764
|
mapConnectionStatus: () => mapConnectionStatus,
|
|
755
765
|
mapDeviceStatusToCardStatus: () => mapDeviceStatusToCardStatus,
|
|
756
766
|
mapDeviceToConnectionStatus: () => mapDeviceToConnectionStatus,
|
|
@@ -759,6 +769,7 @@ __export(src_exports, {
|
|
|
759
769
|
minutesToMs: () => minutesToMs,
|
|
760
770
|
msToMinutes: () => msToMinutes,
|
|
761
771
|
myioExportData: () => myioExportData,
|
|
772
|
+
nextManualSeq: () => nextManualSeq,
|
|
762
773
|
nfdNormalizeAnnotationSearch: () => nfdNormalize,
|
|
763
774
|
normalizeBudgetBlock: () => normalizeBudgetBlock,
|
|
764
775
|
normalizeConnectionStatus: () => normalizeConnectionStatus,
|
|
@@ -796,6 +807,7 @@ __export(src_exports, {
|
|
|
796
807
|
openGoalsPanel: () => openGoalsPanel,
|
|
797
808
|
openHelpModal: () => openHelpModal,
|
|
798
809
|
openIntegrationsModal: () => openIntegrationsModal,
|
|
810
|
+
openManualDeviceModal: () => openManualDeviceModal,
|
|
799
811
|
openMeasurementSetupModal: () => openMeasurementSetupModal,
|
|
800
812
|
openMessageDialog: () => openMessageDialog,
|
|
801
813
|
openMetasGuide: () => openMetasGuide,
|
|
@@ -808,6 +820,8 @@ __export(src_exports, {
|
|
|
808
820
|
openRealTimeTelemetryModal: () => openRealTimeTelemetryModal,
|
|
809
821
|
openReportsHub: () => openReportsHub,
|
|
810
822
|
openSettingsHubModal: () => openSettingsHubModal,
|
|
823
|
+
openStandardModal: () => openStandardModal,
|
|
824
|
+
openTelemetryImportModal: () => openTelemetryImportModal,
|
|
811
825
|
openTemperatureComparisonModal: () => openTemperatureComparisonModal,
|
|
812
826
|
openTemperatureModal: () => openTemperatureModal,
|
|
813
827
|
openTemperatureSettingsModal: () => openTemperatureSettingsModal,
|
|
@@ -822,6 +836,7 @@ __export(src_exports, {
|
|
|
822
836
|
panelTermToDeviceCategory: () => panelTermToDeviceCategory,
|
|
823
837
|
parseBinaryState: () => parseBinaryState,
|
|
824
838
|
parseClassificationEntities: () => parseClassificationEntities,
|
|
839
|
+
parseCsv: () => parseCsv,
|
|
825
840
|
parseGcdrEnergyRoot: () => parseGcdrEnergyRoot,
|
|
826
841
|
parseGcdrEntityForest: () => parseGcdrEntityForest,
|
|
827
842
|
parseInputDateToDate: () => parseInputDateToDate,
|
|
@@ -882,17 +897,20 @@ __export(src_exports, {
|
|
|
882
897
|
resolveSubcategory: () => resolveSubcategory,
|
|
883
898
|
resolveWithFallback: () => resolveWithFallback,
|
|
884
899
|
routeMoneyRender: () => routeMoneyRender,
|
|
900
|
+
rowsFromTable: () => rowsFromTable,
|
|
885
901
|
schedCreateDateInput: () => createDateInput,
|
|
886
902
|
schedCreateNumberInput: () => createNumberInput,
|
|
887
903
|
schedCreateSelect: () => createSelect,
|
|
888
904
|
schedCreateTimeInput: () => createTimeInput,
|
|
889
|
-
schedEscapeHtml: () =>
|
|
905
|
+
schedEscapeHtml: () => escapeHtml19,
|
|
890
906
|
schedShowConfirmModal: () => showConfirmModal,
|
|
891
907
|
schedShowNotificationModal: () => showNotificationModal,
|
|
892
908
|
selectBreakdownItems: () => selectBreakdownItems,
|
|
893
909
|
setActiveProfile: () => setActiveProfile,
|
|
910
|
+
sharedWellValveIds: () => sharedWellValveIds,
|
|
894
911
|
shouldFlashIcon: () => shouldFlashIcon,
|
|
895
912
|
shouldVirtualizeAnnotationList: () => shouldVirtualize,
|
|
913
|
+
siglaFromManualAsset: () => siglaFromManualAsset,
|
|
896
914
|
signOf: () => signOf,
|
|
897
915
|
slugifyCustomerName: () => slugifyCustomerName,
|
|
898
916
|
sortAnnotationGroups: () => sortGroups,
|
|
@@ -922,6 +940,7 @@ __export(src_exports, {
|
|
|
922
940
|
validateDeviceProductName: () => validateDeviceProductName,
|
|
923
941
|
validateProfile: () => validateProfile,
|
|
924
942
|
validateTree: () => validateTree,
|
|
943
|
+
valveHistoryFromTelemetry: () => valveHistoryFromTelemetry,
|
|
925
944
|
version: () => version,
|
|
926
945
|
waterDeviceStatusIcons: () => waterDeviceStatusIcons,
|
|
927
946
|
wireCategoryToPanel: () => wireCategoryToPanel,
|
|
@@ -934,7 +953,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
934
953
|
// package.json
|
|
935
954
|
var package_default = {
|
|
936
955
|
name: "myio-js-library",
|
|
937
|
-
version: "0.1.
|
|
956
|
+
version: "0.1.568",
|
|
938
957
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
939
958
|
license: "MIT",
|
|
940
959
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -2449,6 +2468,9 @@ var DEVICE_TYPE_CONFIG = {
|
|
|
2449
2468
|
HIDROMETRO: { category: "water", image: deviceIcons.HIDROMETRO },
|
|
2450
2469
|
HIDROMETRO_AREA_COMUM: { category: "water", image: deviceIcons.HIDROMETRO_AREA_COMUM },
|
|
2451
2470
|
HIDROMETRO_SHOPPING: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
|
|
2471
|
+
HIDROMETRO_ENTRADA: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
|
|
2472
|
+
// Virtual: Entrada − Σ consumos (calculado no dashboard; card informativo na coluna Entrada)
|
|
2473
|
+
HIDROMETRO_ENTRADA_RETROLAVAGEM: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
|
|
2452
2474
|
CAIXA_DAGUA: { category: "water", image: deviceIcons.CAIXA_DAGUA },
|
|
2453
2475
|
// ED-1354: poço/cisterna (nível, como CAIXA_DAGUA) — _ENTRADA vai p/ a coluna Entrada, o outro p/ Área Comum
|
|
2454
2476
|
CISTERNA: { category: "water", image: deviceIcons.CISTERNA },
|
|
@@ -4010,6 +4032,12 @@ function isEntradaDevice(device) {
|
|
|
4010
4032
|
}
|
|
4011
4033
|
|
|
4012
4034
|
// src/utils/devices/deviceClassificationProfile.ts
|
|
4035
|
+
var WELL_AUTOMATION_PROFILES = /* @__PURE__ */ new Set(["BOMBA_POCO", "SOLENOIDE"]);
|
|
4036
|
+
function filterWellAutomationItems(items) {
|
|
4037
|
+
return (items || []).filter(
|
|
4038
|
+
(item) => !WELL_AUTOMATION_PROFILES.has(String(item?.deviceProfile || "").trim().toUpperCase())
|
|
4039
|
+
);
|
|
4040
|
+
}
|
|
4013
4041
|
var DEFAULT_DEVICE_CLASSIFICATION_PROFILE = {
|
|
4014
4042
|
schemaVersion: 1,
|
|
4015
4043
|
domains: {
|
|
@@ -11229,10 +11257,11 @@ async function canEditAlarmRules(jwtToken, tbBaseUrl) {
|
|
|
11229
11257
|
}
|
|
11230
11258
|
}
|
|
11231
11259
|
async function getAnnotationPermissions(customerId, jwtToken, tbBaseUrl) {
|
|
11260
|
+
void customerId;
|
|
11232
11261
|
const [currentUser, isSuperAdminMyio, isSuperAdminHolding] = await Promise.all([
|
|
11233
11262
|
fetchCurrentUserInfo(jwtToken, tbBaseUrl),
|
|
11234
11263
|
detectSuperAdminMyio(jwtToken, tbBaseUrl),
|
|
11235
|
-
|
|
11264
|
+
detectHoldingUserAdmin(jwtToken, tbBaseUrl)
|
|
11236
11265
|
]);
|
|
11237
11266
|
return {
|
|
11238
11267
|
currentUser,
|
|
@@ -20848,17 +20877,34 @@ function intervalsFromTelemetry(points, opts = {}) {
|
|
|
20848
20877
|
if (open !== null) out.push([open, null]);
|
|
20849
20878
|
return out;
|
|
20850
20879
|
}
|
|
20880
|
+
function hasUsableTelemetryPoint(points, parseValue) {
|
|
20881
|
+
return (points || []).some((point) => {
|
|
20882
|
+
const ts = Number(point?.ts);
|
|
20883
|
+
return point?.ts !== null && point?.ts !== void 0 && Number.isFinite(ts) && parseValue(point?.value) !== null;
|
|
20884
|
+
});
|
|
20885
|
+
}
|
|
20886
|
+
function parseNumericTelemetry(value) {
|
|
20887
|
+
if (typeof value !== "number" && typeof value !== "string") return null;
|
|
20888
|
+
if (typeof value === "string" && value.trim() === "") return null;
|
|
20889
|
+
const number = Number(value);
|
|
20890
|
+
return Number.isFinite(number) ? number : null;
|
|
20891
|
+
}
|
|
20851
20892
|
var PUMP_POWER_KEY = "consumption";
|
|
20852
20893
|
var VALVE_STATE_KEYS = ["state", "status"];
|
|
20853
20894
|
function pumpHistoryFromConsumption(points, thresholdW = 0) {
|
|
20895
|
+
if (!hasUsableTelemetryPoint(points, parseNumericTelemetry)) return null;
|
|
20854
20896
|
return intervalsFromTelemetry(points, { threshold: thresholdW });
|
|
20855
20897
|
}
|
|
20898
|
+
function valveHistoryFromTelemetry(points) {
|
|
20899
|
+
if (!hasUsableTelemetryPoint(points, parseBinaryState)) return null;
|
|
20900
|
+
return intervalsFromTelemetry(points);
|
|
20901
|
+
}
|
|
20856
20902
|
function latestPowerKw(points) {
|
|
20857
20903
|
let best = null;
|
|
20858
20904
|
for (const p of points || []) {
|
|
20859
20905
|
const ts = Number(p?.ts);
|
|
20860
|
-
const v =
|
|
20861
|
-
if (!Number.isFinite(ts) ||
|
|
20906
|
+
const v = parseNumericTelemetry(p?.value);
|
|
20907
|
+
if (!Number.isFinite(ts) || v === null) continue;
|
|
20862
20908
|
if (!best || ts > best.ts) best = { ts, v };
|
|
20863
20909
|
}
|
|
20864
20910
|
return best ? best.v / 1e3 : null;
|
|
@@ -20933,6 +20979,33 @@ function indicatorsFromModalData(data) {
|
|
|
20933
20979
|
});
|
|
20934
20980
|
return list;
|
|
20935
20981
|
}
|
|
20982
|
+
function indicatorsFromSharedWellValves(wellData) {
|
|
20983
|
+
const valvesByTbId = /* @__PURE__ */ new Map();
|
|
20984
|
+
(wellData || []).forEach((data) => {
|
|
20985
|
+
(data?.valves || []).forEach((valve) => {
|
|
20986
|
+
const tbId = String(valve.tbId || valve.id || "").trim();
|
|
20987
|
+
if (tbId && !valvesByTbId.has(tbId)) valvesByTbId.set(tbId, valve);
|
|
20988
|
+
});
|
|
20989
|
+
});
|
|
20990
|
+
const sharedIds = new Set(sharedWellValveIds(wellData));
|
|
20991
|
+
return indicatorsFromModalData({
|
|
20992
|
+
pumps: [],
|
|
20993
|
+
valves: [...valvesByTbId.entries()].filter(([id]) => sharedIds.has(id)).map(([, valve]) => valve)
|
|
20994
|
+
});
|
|
20995
|
+
}
|
|
20996
|
+
function sharedWellValveIds(wellData) {
|
|
20997
|
+
const valvesByTbId = /* @__PURE__ */ new Map();
|
|
20998
|
+
(wellData || []).forEach((data, wellIndex) => {
|
|
20999
|
+
(data?.valves || []).forEach((valve) => {
|
|
21000
|
+
const tbId = String(valve.tbId || valve.id || "").trim();
|
|
21001
|
+
if (!tbId) return;
|
|
21002
|
+
const wells = valvesByTbId.get(tbId) || /* @__PURE__ */ new Set();
|
|
21003
|
+
wells.add(wellIndex);
|
|
21004
|
+
valvesByTbId.set(tbId, wells);
|
|
21005
|
+
});
|
|
21006
|
+
});
|
|
21007
|
+
return [...valvesByTbId.entries()].filter(([, wells]) => wells.size > 1).map(([id]) => id);
|
|
21008
|
+
}
|
|
20936
21009
|
|
|
20937
21010
|
// src/components/well-pumps/equipmentIndicators.ts
|
|
20938
21011
|
var STYLE_ID4 = "myio-equipment-indicators-styles";
|
|
@@ -21131,8 +21204,10 @@ function renderCardComponentV5({
|
|
|
21131
21204
|
// ED-1354: indicadores B1/B2/S (bombas MOTOR + solenoide) no card do poço
|
|
21132
21205
|
equipmentIndicators
|
|
21133
21206
|
} = entityObject;
|
|
21134
|
-
const
|
|
21135
|
-
const
|
|
21207
|
+
const rawProfile = String(deviceProfile || legacyDeviceType || "");
|
|
21208
|
+
const isManualDevice = /_MANUAL$/i.test(rawProfile);
|
|
21209
|
+
const deviceType = isManualDevice ? rawProfile.replace(/_MANUAL$/i, "") : rawProfile;
|
|
21210
|
+
const deviceStatus = dataLoading ? "loading" : isManualDevice ? "power_on" : rawDeviceStatus;
|
|
21136
21211
|
const MyIOToast2 = (function() {
|
|
21137
21212
|
let toastContainer = null;
|
|
21138
21213
|
let toastTimeout = null;
|
|
@@ -32391,8 +32466,8 @@ var EnergyDataFetcher = class {
|
|
|
32391
32466
|
// src/components/premium-modals/internal/engines/CsvExporter.ts
|
|
32392
32467
|
var toCsv = (rows, locale = "pt-BR", sep = ";") => {
|
|
32393
32468
|
const fmt2 = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
32394
|
-
const
|
|
32395
|
-
return rows.map((r) => r.map((c) => `"${
|
|
32469
|
+
const esc10 = (v) => (typeof v === "number" ? fmt2.format(v) : String(v)).replace(/"/g, '""');
|
|
32470
|
+
return rows.map((r) => r.map((c) => `"${esc10(c)}"`).join(sep)).join("\r\n");
|
|
32396
32471
|
};
|
|
32397
32472
|
|
|
32398
32473
|
// src/components/premium-modals/energy/types.ts
|
|
@@ -36743,14 +36818,14 @@ var DeviceReportModal = class {
|
|
|
36743
36818
|
// Header: "Relatório - <identifier> - <label>" + nome do device (sutil, com copiar).
|
|
36744
36819
|
// O customer já aparece no footer premium. Texto escapado — o shell usa innerHTML no título.
|
|
36745
36820
|
buildHeaderTitleHTML() {
|
|
36746
|
-
const
|
|
36747
|
-
const base =
|
|
36821
|
+
const esc10 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
36822
|
+
const base = esc10(
|
|
36748
36823
|
`Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`
|
|
36749
36824
|
);
|
|
36750
36825
|
const deviceName = String(this.params.deviceName || "").trim();
|
|
36751
36826
|
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;">
|
|
36752
|
-
${
|
|
36753
|
-
<button type="button" class="myio-dr-copy" data-copy="${
|
|
36827
|
+
${esc10(deviceName)}
|
|
36828
|
+
<button type="button" class="myio-dr-copy" data-copy="${esc10(deviceName)}" title="Copiar nome do dispositivo"
|
|
36754
36829
|
aria-label="Copiar nome do dispositivo"
|
|
36755
36830
|
style="border:none;background:transparent;color:inherit;cursor:pointer;padding:0 2px;line-height:1;opacity:.9;display:inline-flex;">
|
|
36756
36831
|
<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>
|
|
@@ -41318,10 +41393,10 @@ var WaterTankModalView = class {
|
|
|
41318
41393
|
*/
|
|
41319
41394
|
render() {
|
|
41320
41395
|
const { params } = this.config;
|
|
41321
|
-
const
|
|
41322
|
-
if (!document.getElementById(
|
|
41396
|
+
const STYLE_ID23 = "myio-water-tank-modal-styles";
|
|
41397
|
+
if (!document.getElementById(STYLE_ID23)) {
|
|
41323
41398
|
const style = document.createElement("style");
|
|
41324
|
-
style.id =
|
|
41399
|
+
style.id = STYLE_ID23;
|
|
41325
41400
|
style.textContent = `
|
|
41326
41401
|
@media (max-width: 640px) {
|
|
41327
41402
|
.myio-water-tank-modal { width: 100vw !important; max-width: 100vw !important; max-height: 100vh !important; border-radius: 0 !important; }
|
|
@@ -62965,6 +63040,249 @@ var DeviceProfileTab = class {
|
|
|
62965
63040
|
}
|
|
62966
63041
|
};
|
|
62967
63042
|
|
|
63043
|
+
// src/components/premium-modals/settings/well-equipment/WellEquipmentTab.ts
|
|
63044
|
+
var ATTRIBUTE_KEYS = "deviceProfile,gcdrDeviceId,pumpBindings";
|
|
63045
|
+
var MAX_CUSTOMER_DEVICE_PAGES = 100;
|
|
63046
|
+
function escapeHtml6(value) {
|
|
63047
|
+
return value.replace(/[&<>"']/g, (char) => ({
|
|
63048
|
+
"&": "&",
|
|
63049
|
+
"<": "<",
|
|
63050
|
+
">": ">",
|
|
63051
|
+
'"': """,
|
|
63052
|
+
"'": "'"
|
|
63053
|
+
})[char]);
|
|
63054
|
+
}
|
|
63055
|
+
function normalizeBindings(value) {
|
|
63056
|
+
const parsed = typeof value === "string" ? JSON.parse(value) : value;
|
|
63057
|
+
const bindings = parsed && typeof parsed === "object" ? parsed : {};
|
|
63058
|
+
const valid = (items, codes) => (Array.isArray(items) ? items : []).filter((item) => !!item && typeof item === "object" && typeof item.tbId === "string" && codes.has(item.code)).map((item) => ({ ...item }));
|
|
63059
|
+
return {
|
|
63060
|
+
pumps: valid(bindings.pumps, /* @__PURE__ */ new Set(["B1", "B2"])),
|
|
63061
|
+
valves: valid(bindings.valves, /* @__PURE__ */ new Set(["S"]))
|
|
63062
|
+
};
|
|
63063
|
+
}
|
|
63064
|
+
var WellEquipmentTab = class {
|
|
63065
|
+
config;
|
|
63066
|
+
equipment = [];
|
|
63067
|
+
bindings = { pumps: [], valves: [] };
|
|
63068
|
+
loaded = false;
|
|
63069
|
+
catalogWarnings = 0;
|
|
63070
|
+
constructor(config2) {
|
|
63071
|
+
this.config = config2;
|
|
63072
|
+
}
|
|
63073
|
+
async init() {
|
|
63074
|
+
this.config.container.innerHTML = '<p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>';
|
|
63075
|
+
try {
|
|
63076
|
+
const [wellAttributes, equipment] = await Promise.all([
|
|
63077
|
+
this.fetchAttributes(this.config.deviceId, "pumpBindings"),
|
|
63078
|
+
this.fetchEquipment()
|
|
63079
|
+
]);
|
|
63080
|
+
const stored = wellAttributes.get("pumpBindings");
|
|
63081
|
+
this.bindings = stored == null ? { pumps: [], valves: [] } : normalizeBindings(stored);
|
|
63082
|
+
this.equipment = equipment;
|
|
63083
|
+
this.loaded = true;
|
|
63084
|
+
this.render();
|
|
63085
|
+
if (this.catalogWarnings > 0) {
|
|
63086
|
+
this.showMessage(
|
|
63087
|
+
`${this.catalogWarnings} equipamento(s) n\xE3o puderam ser verificados e foram omitidos do cat\xE1logo.`,
|
|
63088
|
+
true
|
|
63089
|
+
);
|
|
63090
|
+
}
|
|
63091
|
+
} catch (error) {
|
|
63092
|
+
this.config.container.innerHTML = `<p class="wet-state wet-error" role="alert">N\xE3o foi poss\xEDvel carregar os v\xEDnculos ou o cat\xE1logo de equipamentos: ${escapeHtml6(this.errorMessage(error))}</p>`;
|
|
63093
|
+
}
|
|
63094
|
+
}
|
|
63095
|
+
destroy() {
|
|
63096
|
+
}
|
|
63097
|
+
headers() {
|
|
63098
|
+
return {
|
|
63099
|
+
"X-Authorization": `Bearer ${this.config.jwtToken}`,
|
|
63100
|
+
"Content-Type": "application/json"
|
|
63101
|
+
};
|
|
63102
|
+
}
|
|
63103
|
+
async fetchAttributes(deviceId, keys) {
|
|
63104
|
+
const url = `${this.config.tbBaseUrl}/api/plugins/telemetry/DEVICE/${encodeURIComponent(deviceId)}/values/attributes/SERVER_SCOPE?keys=${encodeURIComponent(keys)}`;
|
|
63105
|
+
const response = await fetch(url, { headers: this.headers() });
|
|
63106
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
63107
|
+
const raw = await response.json();
|
|
63108
|
+
if (!Array.isArray(raw)) throw new Error("Resposta de atributos inv\xE1lida");
|
|
63109
|
+
return new Map(raw.map(({ key, value }) => [key, value]));
|
|
63110
|
+
}
|
|
63111
|
+
async fetchEquipment() {
|
|
63112
|
+
if (!this.config.customerId) throw new Error("customerId indispon\xEDvel");
|
|
63113
|
+
const devices = [];
|
|
63114
|
+
let page = 0;
|
|
63115
|
+
let hasNext = true;
|
|
63116
|
+
while (hasNext) {
|
|
63117
|
+
if (page >= MAX_CUSTOMER_DEVICE_PAGES) {
|
|
63118
|
+
throw new Error(`Cat\xE1logo excede o limite de ${MAX_CUSTOMER_DEVICE_PAGES} p\xE1ginas`);
|
|
63119
|
+
}
|
|
63120
|
+
const query = new URLSearchParams({ pageSize: "1000", page: String(page) });
|
|
63121
|
+
const url = `${this.config.tbBaseUrl}/api/customer/${encodeURIComponent(this.config.customerId)}/devices?${query}`;
|
|
63122
|
+
const response = await fetch(url, { headers: this.headers() });
|
|
63123
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
63124
|
+
const result = await response.json();
|
|
63125
|
+
if (!Array.isArray(result.data)) throw new Error("Resposta de equipamentos inv\xE1lida");
|
|
63126
|
+
if (result.hasNext === true && result.data.length === 0) {
|
|
63127
|
+
throw new Error("Pagina\xE7\xE3o do cat\xE1logo n\xE3o avan\xE7ou");
|
|
63128
|
+
}
|
|
63129
|
+
devices.push(...result.data);
|
|
63130
|
+
hasNext = result.hasNext === true;
|
|
63131
|
+
page += 1;
|
|
63132
|
+
}
|
|
63133
|
+
const candidates = devices.map((device) => ({
|
|
63134
|
+
device,
|
|
63135
|
+
tbId: typeof device.id === "string" ? device.id : device.id?.id
|
|
63136
|
+
})).filter((item) => !!item.tbId);
|
|
63137
|
+
const queue = [...candidates];
|
|
63138
|
+
const matching = [];
|
|
63139
|
+
const worker = async () => {
|
|
63140
|
+
while (queue.length) {
|
|
63141
|
+
const item = queue.shift();
|
|
63142
|
+
if (!item) return;
|
|
63143
|
+
try {
|
|
63144
|
+
const attributes = await this.fetchAttributes(item.tbId, ATTRIBUTE_KEYS);
|
|
63145
|
+
const profile = String(attributes.get("deviceProfile") || "").toUpperCase();
|
|
63146
|
+
if (profile !== "BOMBA_POCO" && profile !== "SOLENOIDE") continue;
|
|
63147
|
+
matching.push({
|
|
63148
|
+
tbId: item.tbId,
|
|
63149
|
+
profile,
|
|
63150
|
+
label: String(item.device.label || item.device.name || item.tbId),
|
|
63151
|
+
gcdrId: attributes.get("gcdrDeviceId") == null ? void 0 : String(attributes.get("gcdrDeviceId"))
|
|
63152
|
+
});
|
|
63153
|
+
} catch (error) {
|
|
63154
|
+
this.catalogWarnings += 1;
|
|
63155
|
+
console.warn(`[WellEquipmentTab] Falha ao ler atributos do equipamento ${item.tbId}:`, error);
|
|
63156
|
+
}
|
|
63157
|
+
}
|
|
63158
|
+
};
|
|
63159
|
+
await Promise.all(Array.from({ length: Math.min(8, Math.max(1, queue.length)) }, () => worker()));
|
|
63160
|
+
return matching.sort((a, b) => a.label.localeCompare(b.label));
|
|
63161
|
+
}
|
|
63162
|
+
render() {
|
|
63163
|
+
const options = (profile, code, existing) => {
|
|
63164
|
+
const eligible = this.equipment.filter((item) => item.profile === profile);
|
|
63165
|
+
const missing = existing && !eligible.some((item) => item.tbId === existing.tbId) ? `<option value="${escapeHtml6(existing.tbId)}" selected data-unavailable="true">V\xEDnculo atual indispon\xEDvel \u2014 ${escapeHtml6(existing.label)}</option>` : "";
|
|
63166
|
+
const items = eligible.map(
|
|
63167
|
+
(item) => `<option value="${escapeHtml6(item.tbId)}"${item.tbId === existing?.tbId ? " selected" : ""}>${escapeHtml6(item.label)}</option>`
|
|
63168
|
+
).join("");
|
|
63169
|
+
return `<select id="wet-${code.toLowerCase()}-device" data-slot="${code}" aria-label="Equipamento ${code}">
|
|
63170
|
+
<option value="">Nenhum</option>${missing}${items}
|
|
63171
|
+
</select>`;
|
|
63172
|
+
};
|
|
63173
|
+
const binding = (items, code) => items.find((item) => item.code === code);
|
|
63174
|
+
const labelInput = (code, existing) => `<input id="wet-${code.toLowerCase()}-label" data-label="${code}" aria-label="R\xF3tulo ${code}" value="${escapeHtml6(existing?.label || "")}" placeholder="R\xF3tulo opcional">`;
|
|
63175
|
+
this.config.container.innerHTML = `
|
|
63176
|
+
<section class="wet-tab">
|
|
63177
|
+
<p>Configure as bombas e o solenoide associados a este po\xE7o. O mesmo equipamento pode ser usado em outros po\xE7os.</p>
|
|
63178
|
+
<div class="wet-grid">
|
|
63179
|
+
<label for="wet-b1-device">Bomba B1</label>${options("BOMBA_POCO", "B1", binding(this.bindings.pumps, "B1"))}${labelInput("B1", binding(this.bindings.pumps, "B1"))}
|
|
63180
|
+
<label for="wet-b2-device">Bomba B2</label>${options("BOMBA_POCO", "B2", binding(this.bindings.pumps, "B2"))}${labelInput("B2", binding(this.bindings.pumps, "B2"))}
|
|
63181
|
+
<label for="wet-s-device">Solenoide S</label>${options("SOLENOIDE", "S", binding(this.bindings.valves, "S"))}${labelInput("S", binding(this.bindings.valves, "S"))}
|
|
63182
|
+
</div>
|
|
63183
|
+
<p id="wet-message" class="wet-message" role="status" aria-live="polite"></p>
|
|
63184
|
+
<button type="button" id="wet-save" ${this.loaded ? "" : "disabled"}>Salvar v\xEDnculos</button>
|
|
63185
|
+
</section>
|
|
63186
|
+
<style>
|
|
63187
|
+
.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}
|
|
63188
|
+
.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}
|
|
63189
|
+
#wet-save{margin-top:18px;padding:9px 16px;border:0;border-radius:6px;background:#2563eb;color:white;font-weight:600;cursor:pointer}
|
|
63190
|
+
#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}
|
|
63191
|
+
</style>`;
|
|
63192
|
+
this.config.container.querySelectorAll("[data-slot]").forEach((select) => {
|
|
63193
|
+
select.addEventListener("change", () => {
|
|
63194
|
+
const slot = select.dataset.slot || "";
|
|
63195
|
+
const selected = this.equipment.find((item) => item.tbId === select.value);
|
|
63196
|
+
const label = this.config.container.querySelector(`[data-label="${slot}"]`);
|
|
63197
|
+
if (label && selected) label.value = selected.label;
|
|
63198
|
+
if (label && !selected) label.value = "";
|
|
63199
|
+
this.showMessage("");
|
|
63200
|
+
});
|
|
63201
|
+
});
|
|
63202
|
+
this.config.container.querySelector("#wet-save")?.addEventListener("click", () => {
|
|
63203
|
+
void this.save();
|
|
63204
|
+
});
|
|
63205
|
+
}
|
|
63206
|
+
async save() {
|
|
63207
|
+
const container = this.config.container;
|
|
63208
|
+
const saveButton = container.querySelector("#wet-save");
|
|
63209
|
+
if (!this.loaded || !saveButton) return;
|
|
63210
|
+
const b1 = container.querySelector("#wet-b1-device")?.value || "";
|
|
63211
|
+
const b2 = container.querySelector("#wet-b2-device")?.value || "";
|
|
63212
|
+
const solenoid = container.querySelector("#wet-s-device")?.value || "";
|
|
63213
|
+
if (b1 && b1 === b2) {
|
|
63214
|
+
this.showMessage("Selecione bombas diferentes para B1 e B2.", true);
|
|
63215
|
+
return;
|
|
63216
|
+
}
|
|
63217
|
+
const selected = [
|
|
63218
|
+
...b1 ? [{ id: b1, profile: "BOMBA_POCO", code: "B1" }] : [],
|
|
63219
|
+
...b2 ? [{ id: b2, profile: "BOMBA_POCO", code: "B2" }] : [],
|
|
63220
|
+
...solenoid ? [{ id: solenoid, profile: "SOLENOIDE", code: "S" }] : []
|
|
63221
|
+
];
|
|
63222
|
+
for (const item of selected) {
|
|
63223
|
+
const current = item.code === "S" ? this.bindings.valves.find((binding) => binding.code === item.code) : this.bindings.pumps.find((binding) => binding.code === item.code);
|
|
63224
|
+
const unchangedUnavailableBinding = current?.tbId === item.id && !this.equipment.some((equipment) => equipment.tbId === item.id);
|
|
63225
|
+
if (!unchangedUnavailableBinding && !this.equipment.some((equipment) => equipment.tbId === item.id && equipment.profile === item.profile)) {
|
|
63226
|
+
this.showMessage(`O equipamento selecionado para ${item.code} n\xE3o pertence ao cat\xE1logo v\xE1lido.`, true);
|
|
63227
|
+
return;
|
|
63228
|
+
}
|
|
63229
|
+
}
|
|
63230
|
+
const oldBinding = (code) => code === "S" ? this.bindings.valves.find((item) => item.code === code) : this.bindings.pumps.find((item) => item.code === code);
|
|
63231
|
+
const createBinding = (id, code) => {
|
|
63232
|
+
if (!id) return null;
|
|
63233
|
+
const current = oldBinding(code);
|
|
63234
|
+
const equipment = this.equipment.find((item) => item.tbId === id);
|
|
63235
|
+
const label = container.querySelector(`[data-label="${code}"]`)?.value.trim() || equipment?.label || current?.label || id;
|
|
63236
|
+
return {
|
|
63237
|
+
tbId: id,
|
|
63238
|
+
...equipment?.gcdrId || (current?.tbId === id ? current.gcdrId : void 0) ? { gcdrId: equipment?.gcdrId || current?.gcdrId } : {},
|
|
63239
|
+
code,
|
|
63240
|
+
label,
|
|
63241
|
+
...code !== "S" && current?.tbId === id && current.thresholdW !== void 0 ? { thresholdW: current.thresholdW } : {}
|
|
63242
|
+
};
|
|
63243
|
+
};
|
|
63244
|
+
const bindings = {
|
|
63245
|
+
pumps: [createBinding(b1, "B1"), createBinding(b2, "B2")].filter((item) => !!item),
|
|
63246
|
+
valves: [createBinding(solenoid, "S")].filter((item) => !!item)
|
|
63247
|
+
};
|
|
63248
|
+
saveButton.disabled = true;
|
|
63249
|
+
saveButton.textContent = "Salvando\u2026";
|
|
63250
|
+
this.showMessage("");
|
|
63251
|
+
try {
|
|
63252
|
+
const response = await fetch(
|
|
63253
|
+
`${this.config.tbBaseUrl}/api/plugins/telemetry/DEVICE/${encodeURIComponent(this.config.deviceId)}/attributes/SERVER_SCOPE`,
|
|
63254
|
+
{
|
|
63255
|
+
method: "POST",
|
|
63256
|
+
headers: this.headers(),
|
|
63257
|
+
body: JSON.stringify({ pumpBindings: bindings })
|
|
63258
|
+
}
|
|
63259
|
+
);
|
|
63260
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
63261
|
+
this.bindings = bindings;
|
|
63262
|
+
this.render();
|
|
63263
|
+
this.showMessage("V\xEDnculos salvos com sucesso.", false, true);
|
|
63264
|
+
} catch (error) {
|
|
63265
|
+
this.showMessage(`Falha ao salvar os v\xEDnculos: ${this.errorMessage(error)}`, true);
|
|
63266
|
+
} finally {
|
|
63267
|
+
const button = container.querySelector("#wet-save");
|
|
63268
|
+
if (button) {
|
|
63269
|
+
button.disabled = false;
|
|
63270
|
+
button.textContent = "Salvar v\xEDnculos";
|
|
63271
|
+
}
|
|
63272
|
+
}
|
|
63273
|
+
}
|
|
63274
|
+
showMessage(message, isError = false, isSuccess = false) {
|
|
63275
|
+
const element = this.config.container.querySelector("#wet-message");
|
|
63276
|
+
if (!element) return;
|
|
63277
|
+
element.textContent = message;
|
|
63278
|
+
element.classList.toggle("wet-error", isError);
|
|
63279
|
+
element.classList.toggle("wet-success", isSuccess);
|
|
63280
|
+
}
|
|
63281
|
+
errorMessage(error) {
|
|
63282
|
+
return error instanceof Error ? error.message : String(error);
|
|
63283
|
+
}
|
|
63284
|
+
};
|
|
63285
|
+
|
|
62968
63286
|
// src/services/freshdesk/FreshdeskClient.ts
|
|
62969
63287
|
var FreshdeskClient_exports = {};
|
|
62970
63288
|
__export(FreshdeskClient_exports, {
|
|
@@ -63881,10 +64199,10 @@ ${this._formatFileSize(f.size)} \xB7 ${f.type || "arquivo"}`;
|
|
|
63881
64199
|
// Styles
|
|
63882
64200
|
// ==========================================================================
|
|
63883
64201
|
injectStyles() {
|
|
63884
|
-
const
|
|
63885
|
-
if (document.getElementById(
|
|
64202
|
+
const STYLE_ID23 = "myio-tickets-tab-styles";
|
|
64203
|
+
if (document.getElementById(STYLE_ID23)) return;
|
|
63886
64204
|
const style = document.createElement("style");
|
|
63887
|
-
style.id =
|
|
64205
|
+
style.id = STYLE_ID23;
|
|
63888
64206
|
style.textContent = `
|
|
63889
64207
|
/* ===== TicketsTab layout ===== */
|
|
63890
64208
|
.ct-tab {
|
|
@@ -64566,7 +64884,7 @@ async function createInputDateRangePickerInsideDIV(params) {
|
|
|
64566
64884
|
placeholder = "Clique para selecionar per\xEDodo",
|
|
64567
64885
|
pickerOptions = {},
|
|
64568
64886
|
classNames = {},
|
|
64569
|
-
injectStyles:
|
|
64887
|
+
injectStyles: injectStyles26 = true,
|
|
64570
64888
|
showHelper = true
|
|
64571
64889
|
} = params;
|
|
64572
64890
|
validateId(containerId, "containerId");
|
|
@@ -64575,7 +64893,7 @@ async function createInputDateRangePickerInsideDIV(params) {
|
|
|
64575
64893
|
if (!container) {
|
|
64576
64894
|
throw new Error(`[createInputDateRangePickerInsideDIV] Container '#${containerId}' not found`);
|
|
64577
64895
|
}
|
|
64578
|
-
if (
|
|
64896
|
+
if (injectStyles26) {
|
|
64579
64897
|
injectPremiumStyles();
|
|
64580
64898
|
}
|
|
64581
64899
|
let inputEl = document.getElementById(inputId);
|
|
@@ -64714,6 +65032,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
64714
65032
|
// Exclusão de Grupos tab
|
|
64715
65033
|
exclusionGroupsTab = null;
|
|
64716
65034
|
deviceProfileTab = null;
|
|
65035
|
+
wellEquipmentTab = null;
|
|
64717
65036
|
currentTab = "general";
|
|
64718
65037
|
currentUser = null;
|
|
64719
65038
|
permissions = null;
|
|
@@ -64762,6 +65081,9 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
64762
65081
|
canEditIdentifier() {
|
|
64763
65082
|
return this.isSuperAdmin() || this.config.holdingAdmin === true;
|
|
64764
65083
|
}
|
|
65084
|
+
isWellEquipmentDevice() {
|
|
65085
|
+
return ["CISTERNA", "CISTERNA_ENTRADA"].includes(String(this.config.deviceProfile || "").toUpperCase());
|
|
65086
|
+
}
|
|
64765
65087
|
render(initialData) {
|
|
64766
65088
|
this.originalActiveElement = document.activeElement;
|
|
64767
65089
|
document.body.appendChild(this.container);
|
|
@@ -64796,6 +65118,9 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
64796
65118
|
this.initChamadosTab();
|
|
64797
65119
|
this.initExclusionGroupsTab();
|
|
64798
65120
|
this.initDeviceProfileTab();
|
|
65121
|
+
if (this.isWellEquipmentDevice() && this.isSuperAdmin()) {
|
|
65122
|
+
this.initWellEquipmentTab();
|
|
65123
|
+
}
|
|
64799
65124
|
if (this.config.isGateway && this.isSuperAdmin()) {
|
|
64800
65125
|
this.bindIncidentsTabEvents();
|
|
64801
65126
|
this.initIncidentsDateRange();
|
|
@@ -65049,6 +65374,30 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65049
65374
|
container.innerHTML = '<p style="color:#dc3545;padding:20px;text-align:center;">Erro ao carregar perfil do dispositivo</p>';
|
|
65050
65375
|
}
|
|
65051
65376
|
}
|
|
65377
|
+
async initWellEquipmentTab() {
|
|
65378
|
+
const container = this.modal.querySelector("#well-equipment-tab-content");
|
|
65379
|
+
if (!container || !this.isWellEquipmentDevice() || !this.isSuperAdmin()) return;
|
|
65380
|
+
const customerId = this.config.customerId || window.MyIOUtils?.customerTB_ID;
|
|
65381
|
+
const { deviceId, jwtToken, tbBaseUrl, deviceProfile } = this.config;
|
|
65382
|
+
if (!deviceId || !jwtToken || !customerId) {
|
|
65383
|
+
container.innerHTML = '<p class="wet-state wet-error" role="alert">Configura\xE7\xE3o de equipamentos indispon\xEDvel: deviceId, autentica\xE7\xE3o ou customerId n\xE3o informado.</p>';
|
|
65384
|
+
return;
|
|
65385
|
+
}
|
|
65386
|
+
try {
|
|
65387
|
+
this.wellEquipmentTab = new WellEquipmentTab({
|
|
65388
|
+
container,
|
|
65389
|
+
deviceId,
|
|
65390
|
+
deviceProfile: String(deviceProfile || ""),
|
|
65391
|
+
customerId,
|
|
65392
|
+
jwtToken,
|
|
65393
|
+
tbBaseUrl: tbBaseUrl ?? window.location.origin
|
|
65394
|
+
});
|
|
65395
|
+
await this.wellEquipmentTab.init();
|
|
65396
|
+
} catch (error) {
|
|
65397
|
+
console.error("[SettingsModalView] Failed to initialize WellEquipmentTab:", error);
|
|
65398
|
+
container.innerHTML = '<p class="wet-state wet-error" role="alert">Erro ao carregar configura\xE7\xF5es de equipamentos do po\xE7o.</p>';
|
|
65399
|
+
}
|
|
65400
|
+
}
|
|
65052
65401
|
// RFC-0104 / RFC-0180 / RFC-0198: Switch between tabs
|
|
65053
65402
|
switchTab(tab) {
|
|
65054
65403
|
this.currentTab = tab;
|
|
@@ -65062,12 +65411,14 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65062
65411
|
const chamadosContent = this.modal.querySelector("#chamados-tab-content");
|
|
65063
65412
|
const exclusionGroupsContent = this.modal.querySelector("#exclusion-groups-tab-content");
|
|
65064
65413
|
const deviceProfileContent = this.modal.querySelector("#device-profile-tab-content");
|
|
65414
|
+
const wellEquipmentContent = this.modal.querySelector("#well-equipment-tab-content");
|
|
65065
65415
|
const incidentsContent = this.modal.querySelector("#incidents-tab-content");
|
|
65066
65416
|
if (generalContent) generalContent.style.display = tab === "general" ? "block" : "none";
|
|
65067
65417
|
if (annotationsContent) annotationsContent.style.display = tab === "annotations" ? "block" : "none";
|
|
65068
65418
|
if (alarmsContent) alarmsContent.style.display = tab === "alarms" ? "block" : "none";
|
|
65069
65419
|
if (chamadosContent) chamadosContent.style.display = tab === "chamados" ? "block" : "none";
|
|
65070
65420
|
if (deviceProfileContent) deviceProfileContent.style.display = tab === "device-profile" ? "block" : "none";
|
|
65421
|
+
if (wellEquipmentContent) wellEquipmentContent.style.display = tab === "well-equipment" ? "block" : "none";
|
|
65071
65422
|
if (exclusionGroupsContent) exclusionGroupsContent.style.display = tab === "exclusion-groups" ? "block" : "none";
|
|
65072
65423
|
if (incidentsContent) incidentsContent.style.display = tab === "incidents" ? "block" : "none";
|
|
65073
65424
|
const saveBtn = this.modal.querySelector(".btn-save");
|
|
@@ -65098,6 +65449,10 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65098
65449
|
this.deviceProfileTab.destroy();
|
|
65099
65450
|
this.deviceProfileTab = null;
|
|
65100
65451
|
}
|
|
65452
|
+
if (this.wellEquipmentTab) {
|
|
65453
|
+
this.wellEquipmentTab.destroy();
|
|
65454
|
+
this.wellEquipmentTab = null;
|
|
65455
|
+
}
|
|
65101
65456
|
if (this.incidentsDateRangeController) {
|
|
65102
65457
|
this.incidentsDateRangeController.destroy();
|
|
65103
65458
|
this.incidentsDateRangeController = null;
|
|
@@ -65277,6 +65632,13 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65277
65632
|
</svg>
|
|
65278
65633
|
Perfil de Dispositivo
|
|
65279
65634
|
</button>` : ""}
|
|
65635
|
+
${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="well-equipment">
|
|
65636
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
65637
|
+
<path d="M4 18h16M6 18V8l6-4 6 4v10M9 18v-5h6v5"></path>
|
|
65638
|
+
<path d="M12 4v4"></path>
|
|
65639
|
+
</svg>
|
|
65640
|
+
Equipamentos do Po\xE7o
|
|
65641
|
+
</button>` : ""}
|
|
65280
65642
|
<!-- RFC-0232: Incidentes (interpola\xE7\xE3o) \u2014 central + admin MyIO only -->
|
|
65281
65643
|
${this.config.isGateway && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="incidents">
|
|
65282
65644
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -65331,6 +65693,9 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65331
65693
|
<p>Carregando perfil do dispositivo...</p>
|
|
65332
65694
|
</div>
|
|
65333
65695
|
</div>
|
|
65696
|
+
${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<div id="well-equipment-tab-content" class="tab-content" style="display:none;">
|
|
65697
|
+
<p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>
|
|
65698
|
+
</div>` : ""}
|
|
65334
65699
|
<!-- RFC-0232: Incidentes (interpola\xE7\xE3o) Tab Content \u2014 central + admin MyIO only.
|
|
65335
65700
|
Rendered synchronously (data comes pre-fetched via config.interpolatedSlots,
|
|
65336
65701
|
same as getGatewayInfoHTML() \u2014 no async loading state needed here). -->
|
|
@@ -65478,8 +65843,8 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65478
65843
|
const segmentEl = this.modal.querySelector("#segment");
|
|
65479
65844
|
const activityEl = this.modal.querySelector("#activity");
|
|
65480
65845
|
if (!segmentEl || !activityEl) return;
|
|
65481
|
-
const
|
|
65482
|
-
const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${
|
|
65846
|
+
const esc10 = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
65847
|
+
const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc10(v)}"${v === selected ? " selected" : ""}>${esc10(v)}</option>`).join("");
|
|
65483
65848
|
const catalog = await loadStoreSegmentCatalog(this.config.segmentCatalog);
|
|
65484
65849
|
const savedSegment = String(saved.segment || "");
|
|
65485
65850
|
const savedActivity = String(saved.activity || "");
|
|
@@ -71962,7 +72327,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
71962
72327
|
if (this.metaTipEl) this.metaTipEl.style.display = "none";
|
|
71963
72328
|
}
|
|
71964
72329
|
buildMetaTipHtml(type, card) {
|
|
71965
|
-
const
|
|
72330
|
+
const esc10 = _WelcomeModalView.escapeMetaHtml;
|
|
71966
72331
|
const chip = _WelcomeModalView.metaChip;
|
|
71967
72332
|
const meta = card.metaCounts || {};
|
|
71968
72333
|
const details = card.metaDetails || {};
|
|
@@ -71972,7 +72337,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
71972
72337
|
).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
|
|
71973
72338
|
const frame = (icon2, label, body) => `<div class="myio-welcome-meta-tip__header">
|
|
71974
72339
|
<span class="myio-welcome-meta-tip__icon">${icon2}</span>
|
|
71975
|
-
<span class="myio-welcome-meta-tip__title">${label} (${
|
|
72340
|
+
<span class="myio-welcome-meta-tip__title">${label} (${esc10(card.title)})</span>
|
|
71976
72341
|
<span class="myio-welcome-meta-tip__timestamp">${stamp}</span>
|
|
71977
72342
|
<button type="button" class="myio-welcome-meta-tip__close" title="Fechar">\u2715</button>
|
|
71978
72343
|
</div>
|
|
@@ -72000,8 +72365,8 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72000
72365
|
const chips = Object.entries(byState).map(([s, n]) => chip(`${s}: ${n}`)).join("");
|
|
72001
72366
|
const rows = alarms.slice(0, 10).map(
|
|
72002
72367
|
(a) => row(
|
|
72003
|
-
|
|
72004
|
-
[a.severity, a.state].filter(Boolean).map(
|
|
72368
|
+
esc10(a.deviceName ? `${a.deviceName} \u2014 ${a.title || "Alarme"}` : a.title || "Alarme"),
|
|
72369
|
+
[a.severity, a.state].filter(Boolean).map(esc10).join(" \xB7 ")
|
|
72005
72370
|
)
|
|
72006
72371
|
).join("");
|
|
72007
72372
|
return frame(
|
|
@@ -72025,7 +72390,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72025
72390
|
const rows = annotations.slice(0, 10).map((a) => {
|
|
72026
72391
|
const when = a.createdAt ? new Date(a.createdAt).toLocaleDateString("pt-BR") : "";
|
|
72027
72392
|
const text2 = a.text.length > 90 ? `${a.text.slice(0, 90)}\u2026` : a.text;
|
|
72028
|
-
return row(
|
|
72393
|
+
return row(esc10(a.deviceLabel || "Dispositivo"), `${esc10(text2)}${when ? ` \xB7 ${esc10(when)}` : ""}`);
|
|
72029
72394
|
}).join("");
|
|
72030
72395
|
return frame(
|
|
72031
72396
|
"\u{1F4CB}",
|
|
@@ -72036,7 +72401,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72036
72401
|
if (type === "users") {
|
|
72037
72402
|
if (meta.users === null) return frame("\u{1F465}", "Usu\xE1rios", loadingBody);
|
|
72038
72403
|
const users = details.users || [];
|
|
72039
|
-
const rows = users.slice(0, 10).map((u) => row(
|
|
72404
|
+
const rows = users.slice(0, 10).map((u) => row(esc10(u.name), esc10(u.email || ""))).join("");
|
|
72040
72405
|
return frame(
|
|
72041
72406
|
"\u{1F465}",
|
|
72042
72407
|
"Usu\xE1rios",
|
|
@@ -76256,10 +76621,10 @@ function render(container, modalId, state6) {
|
|
|
76256
76621
|
<div class="alarm-list">
|
|
76257
76622
|
${state6.alarms.map((a) => `
|
|
76258
76623
|
<div class="alarm-row">
|
|
76259
|
-
<div class="alarm-title">${
|
|
76260
|
-
<div class="alarm-meta">${
|
|
76261
|
-
<div class="alarm-meta">${
|
|
76262
|
-
<div class="alarm-meta">${
|
|
76624
|
+
<div class="alarm-title">${escapeHtml7(a.title || a.id)}</div>
|
|
76625
|
+
<div class="alarm-meta">${escapeHtml7(a.customerName || "")}</div>
|
|
76626
|
+
<div class="alarm-meta">${escapeHtml7(a.severity)}</div>
|
|
76627
|
+
<div class="alarm-meta">${escapeHtml7(a.state)}</div>
|
|
76263
76628
|
<div class="alarm-meta">${formatDate2(a.lastOccurrence, state6.locale, true)}</div>
|
|
76264
76629
|
</div>
|
|
76265
76630
|
`).join("")}
|
|
@@ -76446,7 +76811,7 @@ function buildBars(data, order, colors2) {
|
|
|
76446
76811
|
const pct = Math.round(value / maxVal * 100);
|
|
76447
76812
|
return `
|
|
76448
76813
|
<div class="bar-row">
|
|
76449
|
-
<span class="bar-label">${
|
|
76814
|
+
<span class="bar-label">${escapeHtml7(String(key))}</span>
|
|
76450
76815
|
<div class="bar-track"><div class="bar-fill" style="width:${pct}%"></div></div>
|
|
76451
76816
|
<span class="bar-value">${value}</span>
|
|
76452
76817
|
</div>
|
|
@@ -76476,7 +76841,7 @@ function toTime(value) {
|
|
|
76476
76841
|
const parsed = new Date(value).getTime();
|
|
76477
76842
|
return Number.isNaN(parsed) ? 0 : parsed;
|
|
76478
76843
|
}
|
|
76479
|
-
function
|
|
76844
|
+
function escapeHtml7(text2) {
|
|
76480
76845
|
const div = document.createElement("div");
|
|
76481
76846
|
div.textContent = text2 || "";
|
|
76482
76847
|
return div.innerHTML;
|
|
@@ -76663,8 +77028,8 @@ function render2(container, modalId, state6) {
|
|
|
76663
77028
|
</div>
|
|
76664
77029
|
${state6.devices.map((d) => `
|
|
76665
77030
|
<div class="device-table-row">
|
|
76666
|
-
<div class="col-name">${
|
|
76667
|
-
<div class="col-customer">${
|
|
77031
|
+
<div class="col-name">${escapeHtml8(d.name)}</div>
|
|
77032
|
+
<div class="col-customer">${escapeHtml8(d.customerName)}</div>
|
|
76668
77033
|
<div class="col-status">
|
|
76669
77034
|
<span class="status-badge" style="background: ${STATUS_COLORS3[d.status] || "#6b7280"}20; color: ${STATUS_COLORS3[d.status] || "#6b7280"};">
|
|
76670
77035
|
${STATUS_LABELS5[d.status] || d.status}
|
|
@@ -76911,7 +77276,7 @@ function buildHorizontalBarChart(devices, metric, unit, colors2, getColor, inver
|
|
|
76911
77276
|
const displayValue = metric === "availability" ? value.toFixed(1) : value.toFixed(metric === "mttr" ? 1 : 0);
|
|
76912
77277
|
return `
|
|
76913
77278
|
<div class="bar-row">
|
|
76914
|
-
<span class="bar-label" title="${
|
|
77279
|
+
<span class="bar-label" title="${escapeHtml8(d.name)}">${escapeHtml8(d.name)}</span>
|
|
76915
77280
|
<div class="bar-track">
|
|
76916
77281
|
<div class="bar-fill" style="width:${pct}%; background:${color};"></div>
|
|
76917
77282
|
</div>
|
|
@@ -76942,7 +77307,7 @@ function formatDate3(value, locale) {
|
|
|
76942
77307
|
if (isNaN(d.getTime())) return "-";
|
|
76943
77308
|
return d.toLocaleDateString(locale, { day: "2-digit", month: "2-digit", year: "numeric" });
|
|
76944
77309
|
}
|
|
76945
|
-
function
|
|
77310
|
+
function escapeHtml8(text2) {
|
|
76946
77311
|
const div = document.createElement("div");
|
|
76947
77312
|
div.textContent = text2 || "";
|
|
76948
77313
|
return div.innerHTML;
|
|
@@ -78835,8 +79200,8 @@ var SettingsController = class {
|
|
|
78835
79200
|
// RFC-0076: Pass deviceProfile for 3F_MEDIDOR fallback
|
|
78836
79201
|
customerName: params.customerName,
|
|
78837
79202
|
// RFC-0077: Pass customer/shopping name for display
|
|
78838
|
-
customerId: params.customerId,
|
|
78839
|
-
//
|
|
79203
|
+
customerId: params.customerId || window.MyIOUtils?.customerTB_ID || void 0,
|
|
79204
|
+
// Shared customer context for settings tabs
|
|
78840
79205
|
deviceId: params.deviceId,
|
|
78841
79206
|
// RFC-0077: Pass deviceId for Power Limits feature
|
|
78842
79207
|
jwtToken: params.jwtToken,
|
|
@@ -79331,15 +79696,16 @@ function timelineHTML(history, now, kind) {
|
|
|
79331
79696
|
function pumpCardHTML(p, now, images, focusWellId) {
|
|
79332
79697
|
const on = isActive(p.history);
|
|
79333
79698
|
const known = Array.isArray(p.history);
|
|
79699
|
+
const stateClass = !known ? "is-unknown" : on ? "is-on" : "is-off";
|
|
79334
79700
|
const since = stateSince(p.history);
|
|
79335
|
-
const { activeMs, starts } = dayStats(p.history, now);
|
|
79336
|
-
const power = on ? typeof p.powerKw === "number" ? fmtKw(p.powerKw) : "\u2014" : fmtKw(0).replace(",0", "");
|
|
79701
|
+
const { activeMs, starts } = dayStats(p.history || [], now);
|
|
79702
|
+
const power = !known ? "\u2014" : on ? typeof p.powerKw === "number" ? fmtKw(p.powerKw) : "\u2014" : fmtKw(0).replace(",0", "");
|
|
79337
79703
|
const hasLevel = typeof p.wellLevelMca === "number";
|
|
79338
79704
|
const hasPerc = typeof p.wellPercentage === "number";
|
|
79339
79705
|
const pct = hasPerc ? Math.round(Math.max(0, Math.min(1, p.wellPercentage)) * 100) : null;
|
|
79340
79706
|
const meta = [p.identifier, p.wellLabel].filter(Boolean).map(escapeHtml2).join(" \xB7 ");
|
|
79341
79707
|
return `
|
|
79342
|
-
<div class="myio-wp-card ${
|
|
79708
|
+
<div class="myio-wp-card ${stateClass} ${focusWellId && p.wellId === focusWellId ? "focus" : ""}" data-code="${escapeHtml2(p.code)}">
|
|
79343
79709
|
<div class="myio-wp-top">
|
|
79344
79710
|
<img class="myio-wp-img" src="${escapeHtml2(images.pump)}" alt="">
|
|
79345
79711
|
<div>
|
|
@@ -79349,25 +79715,26 @@ function pumpCardHTML(p, now, images, focusWellId) {
|
|
|
79349
79715
|
<span class="myio-wp-state ${!known ? "unk" : on ? "on" : "off"}">${PUMP_SVG}${!known ? "SEM LEITURA" : on ? "LIGADA" : "DESLIGADA"}</span>
|
|
79350
79716
|
</div>
|
|
79351
79717
|
<div class="myio-wp-grid">
|
|
79352
|
-
<div class="myio-wp-cell"><small>${on ? "Ligada desde" : "Desligada desde"}</small><span>${formatClock(since)}</span></div>
|
|
79353
|
-
<div class="myio-wp-cell"><small>Tempo ligada hoje</small><span>${formatDuration2(activeMs)}</span></div>
|
|
79354
|
-
<div class="myio-wp-cell"><small>Acionamentos hoje</small><span>${starts}</span></div>
|
|
79718
|
+
<div class="myio-wp-cell"><small>${known ? on ? "Ligada desde" : "Desligada desde" : "Estado desde"}</small><span>${formatClock(since)}</span></div>
|
|
79719
|
+
<div class="myio-wp-cell"><small>Tempo ligada hoje</small><span>${known ? formatDuration2(activeMs) : "\u2014"}</span></div>
|
|
79720
|
+
<div class="myio-wp-cell"><small>Acionamentos hoje</small><span>${known ? starts : "\u2014"}</span></div>
|
|
79355
79721
|
<div class="myio-wp-cell"><small>Pot\xEAncia atual</small><span>${power}</span></div>
|
|
79356
79722
|
<div class="myio-wp-cell"><small>Estado h\xE1</small><span>${since ? formatDuration2(now - since) : "\u2014"}</span></div>
|
|
79357
79723
|
<div class="myio-wp-cell"><small>N\xEDvel do po\xE7o</small><span>${hasLevel ? `${(p.wellLevelMca / 100).toFixed(2).replace(".", ",")} M.C.A` : "\u2014"}</span></div>
|
|
79358
79724
|
</div>
|
|
79359
79725
|
${pct !== null ? `<div class="myio-wp-level">${escapeHtml2(p.wellLabel || "Po\xE7o")}<div class="myio-wp-bar"><i style="width:${pct}%"></i></div>${pct}%</div>` : ""}
|
|
79360
|
-
${timelineHTML(p.history, now, "pump")}
|
|
79726
|
+
${timelineHTML(p.history || [], now, "pump")}
|
|
79361
79727
|
</div>`;
|
|
79362
79728
|
}
|
|
79363
79729
|
function valveCardHTML(v, now, images) {
|
|
79364
79730
|
const open = isActive(v.history);
|
|
79365
79731
|
const known = Array.isArray(v.history);
|
|
79732
|
+
const stateClass = !known ? "is-unknown" : open ? "is-open" : "is-closed";
|
|
79366
79733
|
const since = stateSince(v.history);
|
|
79367
|
-
const { activeMs, starts } = dayStats(v.history, now);
|
|
79734
|
+
const { activeMs, starts } = dayStats(v.history || [], now);
|
|
79368
79735
|
const meta = [v.identifier, v.description].filter(Boolean).map(escapeHtml2).join(" \xB7 ");
|
|
79369
79736
|
return `
|
|
79370
|
-
<div class="myio-wp-card myio-wp-valve ${
|
|
79737
|
+
<div class="myio-wp-card myio-wp-valve ${stateClass}" data-code="${escapeHtml2(v.code)}">
|
|
79371
79738
|
<img class="myio-wp-img" src="${escapeHtml2(images.valve)}" alt="">
|
|
79372
79739
|
<div style="display:flex;flex-direction:column;gap:10px;min-width:0">
|
|
79373
79740
|
<div class="myio-wp-top">
|
|
@@ -79378,11 +79745,11 @@ function valveCardHTML(v, now, images) {
|
|
|
79378
79745
|
<span class="myio-wp-state ${!known ? "unk" : open ? "open" : "closed"}">${VALVE_SVG}${!known ? "SEM LEITURA" : open ? "ABERTA" : "FECHADA"}</span>
|
|
79379
79746
|
</div>
|
|
79380
79747
|
<div class="myio-wp-grid">
|
|
79381
|
-
<div class="myio-wp-cell"><small>${open ? "Aberta desde" : "Fechada desde"}</small><span>${formatClock(since)}</span></div>
|
|
79382
|
-
<div class="myio-wp-cell"><small>Tempo aberta hoje</small><span>${formatDuration2(activeMs)}</span></div>
|
|
79383
|
-
<div class="myio-wp-cell"><small>Aberturas hoje</small><span>${starts}</span></div>
|
|
79748
|
+
<div class="myio-wp-cell"><small>${known ? open ? "Aberta desde" : "Fechada desde" : "Estado desde"}</small><span>${formatClock(since)}</span></div>
|
|
79749
|
+
<div class="myio-wp-cell"><small>Tempo aberta hoje</small><span>${known ? formatDuration2(activeMs) : "\u2014"}</span></div>
|
|
79750
|
+
<div class="myio-wp-cell"><small>Aberturas hoje</small><span>${known ? starts : "\u2014"}</span></div>
|
|
79384
79751
|
</div>
|
|
79385
|
-
${timelineHTML(v.history, now, "valve")}
|
|
79752
|
+
${timelineHTML(v.history || [], now, "valve")}
|
|
79386
79753
|
</div>
|
|
79387
79754
|
</div>`;
|
|
79388
79755
|
}
|
|
@@ -79396,17 +79763,17 @@ function renderWellPumpsBodyHTML(data, opts = {}) {
|
|
|
79396
79763
|
const valves = data?.valves || [];
|
|
79397
79764
|
if (!pumps.length && !valves.length) return `<div class="myio-wp-empty">Nenhuma bomba ou solenoide vinculada a este po\xE7o.</div>`;
|
|
79398
79765
|
const onPumps = pumps.filter((p) => isActive(p.history));
|
|
79766
|
+
const unknownPumpCount = pumps.filter((p) => !Array.isArray(p.history)).length;
|
|
79399
79767
|
const knownPower = onPumps.filter((p) => typeof p.powerKw === "number");
|
|
79400
|
-
const totalPower = knownPower.length ? fmtKw(knownPower.reduce((s, p) => s + p.powerKw, 0)) : onPumps.length ? "\u2014" : "0 kW";
|
|
79768
|
+
const totalPower = unknownPumpCount > 0 ? knownPower.length ? `${fmtKw(knownPower.reduce((s, p) => s + p.powerKw, 0))} parcial` : "\u2014" : knownPower.length ? fmtKw(knownPower.reduce((s, p) => s + p.powerKw, 0)) : onPumps.length ? "\u2014" : "0 kW";
|
|
79401
79769
|
const openValves = valves.filter((v) => isActive(v.history));
|
|
79402
|
-
const
|
|
79403
|
-
|
|
79770
|
+
const unknownValveCount = valves.filter((v) => !Array.isArray(v.history)).length;
|
|
79771
|
+
const valveKpi = valves.length === 1 ? `<div class="myio-wp-kpi"><small>${escapeHtml2(valves[0].label)}</small><b class="${!Array.isArray(valves[0].history) ? "" : openValves.length ? "open" : "closed"}">${!Array.isArray(valves[0].history) ? "SEM LEITURA" : openValves.length ? "Aberta" : "Fechada"}</b>
|
|
79772
|
+
<div class="sub">${Array.isArray(valves[0].history) ? `desde ${formatClock(stateSince(valves[0].history))}` : "Estado desconhecido"}</div></div>` : valves.length > 1 ? `<div class="myio-wp-kpi"><small>Solenoides abertas</small><b>${openValves.length} de ${valves.length}</b>${unknownValveCount ? `<div class="sub">${unknownValveCount} sem leitura</div>` : ""}</div>` : "";
|
|
79773
|
+
const pumpKpis = pumps.length ? `<div class="myio-wp-kpi"><small>Bombas ligadas</small><b>${onPumps.length} de ${pumps.length}</b>${unknownPumpCount ? `<div class="sub">${unknownPumpCount} sem leitura</div>` : ""}</div>
|
|
79774
|
+
<div class="myio-wp-kpi"><small>Pot\xEAncia total</small><b>${totalPower}</b>${unknownPumpCount && knownPower.length ? `<div class="sub">${unknownPumpCount} sem leitura</div>` : ""}</div>` : "";
|
|
79404
79775
|
return `
|
|
79405
|
-
<div class="myio-wp-kpis">
|
|
79406
|
-
<div class="myio-wp-kpi"><small>Bombas ligadas</small><b>${onPumps.length} de ${pumps.length}</b></div>
|
|
79407
|
-
<div class="myio-wp-kpi"><small>Pot\xEAncia total</small><b>${totalPower}</b></div>
|
|
79408
|
-
${valveKpi}
|
|
79409
|
-
</div>
|
|
79776
|
+
<div class="myio-wp-kpis">${pumpKpis}${valveKpi}</div>
|
|
79410
79777
|
${pumps.length ? `<div class="myio-wp-pumps">${pumps.map((p) => pumpCardHTML(p, now, images, opts.focusWellId)).join("")}</div>` : ""}
|
|
79411
79778
|
${valves.map((v) => valveCardHTML(v, now, images)).join("")}
|
|
79412
79779
|
${opts.footnote ? `<div class="myio-wp-foot">\u24D8 ${escapeHtml2(opts.footnote)}</div>` : ""}`;
|
|
@@ -81292,11 +81659,11 @@ function injectDialogStyles() {
|
|
|
81292
81659
|
// src/components/premium-modals/dialog/openDialog.ts
|
|
81293
81660
|
var BASE_Z_INDEX = 10500;
|
|
81294
81661
|
var openCount = 0;
|
|
81295
|
-
function
|
|
81662
|
+
function escapeHtml9(value) {
|
|
81296
81663
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
81297
81664
|
}
|
|
81298
81665
|
function escapeMessage(value) {
|
|
81299
|
-
return
|
|
81666
|
+
return escapeHtml9(value).replace(/\n/g, "<br>");
|
|
81300
81667
|
}
|
|
81301
81668
|
function cssWidth(width) {
|
|
81302
81669
|
if (width == null) return "420px";
|
|
@@ -81321,7 +81688,7 @@ function openDialog(params) {
|
|
|
81321
81688
|
overlay.style.zIndex = String(BASE_Z_INDEX + openCount);
|
|
81322
81689
|
const buttonsHtml = params.buttons.map((btn, i) => {
|
|
81323
81690
|
const variant = btn.variant ?? "secondary";
|
|
81324
|
-
return `<button type="button" class="myio-dialog__btn myio-dialog__btn--${variant}" data-index="${i}">${
|
|
81691
|
+
return `<button type="button" class="myio-dialog__btn myio-dialog__btn--${variant}" data-index="${i}">${escapeHtml9(btn.label)}</button>`;
|
|
81325
81692
|
}).join("");
|
|
81326
81693
|
overlay.innerHTML = `
|
|
81327
81694
|
<div class="myio-dialog${params.modifier ? ` ${params.modifier}` : ""}"
|
|
@@ -81331,7 +81698,7 @@ function openDialog(params) {
|
|
|
81331
81698
|
<div class="myio-dialog__accent"></div>
|
|
81332
81699
|
<div class="myio-dialog__header">
|
|
81333
81700
|
${params.icon ? `<span class="myio-dialog__icon" aria-hidden="true">${params.icon}</span>` : ""}
|
|
81334
|
-
<h3 class="myio-dialog__title" id="${idBase}-title">${
|
|
81701
|
+
<h3 class="myio-dialog__title" id="${idBase}-title">${escapeHtml9(params.title)}</h3>
|
|
81335
81702
|
${dismissible ? `<button type="button" class="myio-dialog__close" aria-label="Fechar">\u2715</button>` : ""}
|
|
81336
81703
|
</div>
|
|
81337
81704
|
<p class="myio-dialog__message" id="${idBase}-message">${escapeMessage(params.message)}</p>
|
|
@@ -81427,7 +81794,7 @@ var STYLE_ID9 = "myio-genmodal-styles";
|
|
|
81427
81794
|
var FONT_LINK_ID2 = "myio-dialog-font-nunito";
|
|
81428
81795
|
var BASE_Z_INDEX2 = 10600;
|
|
81429
81796
|
var openCount2 = 0;
|
|
81430
|
-
function
|
|
81797
|
+
function escapeHtml10(value) {
|
|
81431
81798
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
81432
81799
|
}
|
|
81433
81800
|
function cssSize(v, fallback) {
|
|
@@ -81476,12 +81843,15 @@ function injectGenericModalStyles() {
|
|
|
81476
81843
|
flex-shrink: 0;
|
|
81477
81844
|
}
|
|
81478
81845
|
.myio-genmodal__icon { font-size: 22px; line-height: 1.3; }
|
|
81479
|
-
|
|
81846
|
+
/* h3.\u2026 + prefixo do overlay: vence o "h3" global do ThingsBoard (mat-typography) */
|
|
81847
|
+
.myio-genmodal-overlay h3.myio-genmodal__title {
|
|
81480
81848
|
flex: 1;
|
|
81481
81849
|
margin: 0;
|
|
81850
|
+
font-family: inherit;
|
|
81482
81851
|
font-size: 18px;
|
|
81483
81852
|
font-weight: 700;
|
|
81484
81853
|
line-height: 1.35;
|
|
81854
|
+
letter-spacing: normal;
|
|
81485
81855
|
}
|
|
81486
81856
|
.myio-genmodal__close {
|
|
81487
81857
|
border: none;
|
|
@@ -81577,17 +81947,17 @@ function openGenericModal(params) {
|
|
|
81577
81947
|
overlay.style.zIndex = String(BASE_Z_INDEX2 + openCount2);
|
|
81578
81948
|
const buttonsHtml = buttons.map((btn, i) => {
|
|
81579
81949
|
const variant = btn.variant ?? "secondary";
|
|
81580
|
-
return `<button type="button" class="myio-genmodal__btn myio-genmodal__btn--${variant}" data-index="${i}">${
|
|
81950
|
+
return `<button type="button" class="myio-genmodal__btn myio-genmodal__btn--${variant}" data-index="${i}">${escapeHtml10(btn.label)}</button>`;
|
|
81581
81951
|
}).join("");
|
|
81582
81952
|
overlay.innerHTML = `
|
|
81583
|
-
<div class="myio-genmodal${params.className ? ` ${
|
|
81953
|
+
<div class="myio-genmodal${params.className ? ` ${escapeHtml10(params.className)}` : ""}"
|
|
81584
81954
|
role="dialog" aria-modal="true"
|
|
81585
81955
|
aria-labelledby="${idBase}-title"
|
|
81586
81956
|
style="width:${cssSize(params.width, "560px")}">
|
|
81587
81957
|
<div class="myio-genmodal__accent"></div>
|
|
81588
81958
|
<div class="myio-genmodal__header">
|
|
81589
81959
|
${params.icon ? `<span class="myio-genmodal__icon" aria-hidden="true">${params.icon}</span>` : ""}
|
|
81590
|
-
<h3 class="myio-genmodal__title" id="${idBase}-title">${
|
|
81960
|
+
<h3 class="myio-genmodal__title" id="${idBase}-title">${escapeHtml10(params.title)}</h3>
|
|
81591
81961
|
${dismissible ? `<button type="button" class="myio-genmodal__close" aria-label="Fechar">\u2715</button>` : ""}
|
|
81592
81962
|
</div>
|
|
81593
81963
|
<div class="myio-genmodal__body" id="${idBase}-body" style="max-height:${cssSize(params.bodyMaxHeight, "70vh")}"></div>
|
|
@@ -84912,7 +85282,7 @@ function openGoalsPanel(params) {
|
|
|
84912
85282
|
function sampleHourValue() {
|
|
84913
85283
|
return isAverage() ? 22 : 150;
|
|
84914
85284
|
}
|
|
84915
|
-
function
|
|
85285
|
+
function buildTemplateCsv2() {
|
|
84916
85286
|
const avg = isAverage();
|
|
84917
85287
|
const monthlyValue = avg ? 22 : 1e5;
|
|
84918
85288
|
const dayValue = avg ? 22 : 3200;
|
|
@@ -85014,7 +85384,7 @@ function openGoalsPanel(params) {
|
|
|
85014
85384
|
rootEl.setAttribute("role", "dialog");
|
|
85015
85385
|
rootEl.setAttribute("aria-modal", "true");
|
|
85016
85386
|
container.appendChild(rootEl);
|
|
85017
|
-
|
|
85387
|
+
injectStyles26();
|
|
85018
85388
|
rootEl.addEventListener("click", onClick);
|
|
85019
85389
|
rootEl.addEventListener("change", onChange);
|
|
85020
85390
|
rootEl.addEventListener("input", onInput);
|
|
@@ -85075,7 +85445,7 @@ function openGoalsPanel(params) {
|
|
|
85075
85445
|
openImport();
|
|
85076
85446
|
break;
|
|
85077
85447
|
case "download-template":
|
|
85078
|
-
downloadCsv(
|
|
85448
|
+
downloadCsv(buildTemplateCsv2(), "template");
|
|
85079
85449
|
break;
|
|
85080
85450
|
case "download-hourly":
|
|
85081
85451
|
downloadCsv(buildHourlyExampleCsv(), "hourly-example");
|
|
@@ -85669,7 +86039,7 @@ ${state6.year}-03-15T08,15`)}">${esc5(state6.csv)}</textarea>
|
|
|
85669
86039
|
return "";
|
|
85670
86040
|
}
|
|
85671
86041
|
}
|
|
85672
|
-
function
|
|
86042
|
+
function injectStyles26() {
|
|
85673
86043
|
const id = "myio-goals-gcdr-styles";
|
|
85674
86044
|
const prev = document.getElementById(id);
|
|
85675
86045
|
if (prev) prev.remove();
|
|
@@ -92622,13 +92992,13 @@ var COLUMN_SUMMARY_CSS = `
|
|
|
92622
92992
|
var _cssInjected2 = false;
|
|
92623
92993
|
function injectCSS10() {
|
|
92624
92994
|
if (_cssInjected2 || typeof document === "undefined") return;
|
|
92625
|
-
const
|
|
92626
|
-
if (document.getElementById(
|
|
92995
|
+
const STYLE_ID23 = "myio-column-summary-tooltip-css";
|
|
92996
|
+
if (document.getElementById(STYLE_ID23)) {
|
|
92627
92997
|
_cssInjected2 = true;
|
|
92628
92998
|
return;
|
|
92629
92999
|
}
|
|
92630
93000
|
const style = document.createElement("style");
|
|
92631
|
-
style.id =
|
|
93001
|
+
style.id = STYLE_ID23;
|
|
92632
93002
|
style.textContent = COLUMN_SUMMARY_CSS;
|
|
92633
93003
|
document.head.appendChild(style);
|
|
92634
93004
|
_cssInjected2 = true;
|
|
@@ -99791,7 +100161,7 @@ function createConsumptionChartWidget(config2) {
|
|
|
99791
100161
|
</div>
|
|
99792
100162
|
`;
|
|
99793
100163
|
}
|
|
99794
|
-
function
|
|
100164
|
+
function injectStyles26() {
|
|
99795
100165
|
if (styleElement) return;
|
|
99796
100166
|
styleElement = document.createElement("style");
|
|
99797
100167
|
styleElement.id = `${widgetId}-styles`;
|
|
@@ -100305,7 +100675,7 @@ function createConsumptionChartWidget(config2) {
|
|
|
100305
100675
|
console.error(`[ConsumptionWidget] Container #${config2.containerId} not found`);
|
|
100306
100676
|
return;
|
|
100307
100677
|
}
|
|
100308
|
-
|
|
100678
|
+
injectStyles26();
|
|
100309
100679
|
containerElement.innerHTML = renderHTML();
|
|
100310
100680
|
setupListeners();
|
|
100311
100681
|
applyCollapseState();
|
|
@@ -101759,19 +102129,19 @@ function _updateCoverageHint(topDoc) {
|
|
|
101759
102129
|
const deviceCount = data.granularity === "DEVICE" ? data.devices?.length ?? 0 : 0;
|
|
101760
102130
|
hint.textContent = `\u26A0 Meta incompleta para este dom\xEDnio/ano` + (deviceCount > 0 ? ` \xB7 Por medidor (${deviceCount})` : "") + ` \u2014 passe o mouse para detalhes`;
|
|
101761
102131
|
tabs.insertAdjacentElement("afterend", hint);
|
|
101762
|
-
const
|
|
102132
|
+
const esc10 = (s) => String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
101763
102133
|
try {
|
|
101764
102134
|
_coverageDetach = InfoTooltip.attach(hint, () => {
|
|
101765
102135
|
const d = _getGoalsData(_currentDomain);
|
|
101766
102136
|
const parts = [];
|
|
101767
102137
|
if (hasCoverageGaps(d?.coverageGaps)) {
|
|
101768
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
102138
|
+
parts.push(`<p style="margin:0 0 8px;">${esc10(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
|
|
101769
102139
|
}
|
|
101770
102140
|
(d?.devices || []).forEach((dev) => {
|
|
101771
102141
|
if (!hasCoverageGaps(dev?.coverageGaps)) return;
|
|
101772
102142
|
const label = dev.label || dev.code || "medidor";
|
|
101773
102143
|
parts.push(
|
|
101774
|
-
`<p style="margin:0 0 8px;">${
|
|
102144
|
+
`<p style="margin:0 0 8px;">${esc10(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
|
|
101775
102145
|
);
|
|
101776
102146
|
});
|
|
101777
102147
|
return {
|
|
@@ -104599,7 +104969,7 @@ var HUB_CSS = `
|
|
|
104599
104969
|
color: var(--myio-brand-700, #7B2FF7);
|
|
104600
104970
|
}
|
|
104601
104971
|
`;
|
|
104602
|
-
function
|
|
104972
|
+
function escapeHtml11(value) {
|
|
104603
104973
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
104604
104974
|
}
|
|
104605
104975
|
function resolveTopDocument() {
|
|
@@ -104646,7 +105016,7 @@ function openSettingsHubModal(options) {
|
|
|
104646
105016
|
<div class="myio-conf-picker__overlay"></div>
|
|
104647
105017
|
<div class="myio-conf-picker__content">
|
|
104648
105018
|
<div class="myio-conf-picker__header">
|
|
104649
|
-
<h3>\u2699\uFE0F Configura\xE7\xF5es${customerName ? ` \u2014 ${
|
|
105019
|
+
<h3>\u2699\uFE0F Configura\xE7\xF5es${customerName ? ` \u2014 ${escapeHtml11(customerName)}` : ""}</h3>
|
|
104650
105020
|
<button class="myio-conf-picker__close" aria-label="Fechar">×</button>
|
|
104651
105021
|
</div>
|
|
104652
105022
|
<div class="myio-conf-picker__body">${cardsHtml}
|
|
@@ -105841,7 +106211,7 @@ function createTariffApiAdapter(client, opts) {
|
|
|
105841
106211
|
|
|
105842
106212
|
// src/components/pricing-panel/openPricingPanel.ts
|
|
105843
106213
|
var MODAL_ID3 = "myio-pricing-panel";
|
|
105844
|
-
function
|
|
106214
|
+
function escapeHtml12(value) {
|
|
105845
106215
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
105846
106216
|
}
|
|
105847
106217
|
function resolveTopDocument2() {
|
|
@@ -105996,7 +106366,7 @@ function openPricingPanel(params) {
|
|
|
105996
106366
|
}
|
|
105997
106367
|
const initDomain = params.domain || "energy";
|
|
105998
106368
|
const initCategory = params.category || "lojas";
|
|
105999
|
-
const customerOptions = customers.map((c) => `<option value="${
|
|
106369
|
+
const customerOptions = customers.map((c) => `<option value="${escapeHtml12(resolveCustomerId(c))}">${escapeHtml12(c.title)}</option>`).join("");
|
|
106000
106370
|
modal.innerHTML = `
|
|
106001
106371
|
<div class="myio-pricing__overlay"></div>
|
|
106002
106372
|
<div class="myio-pricing__content">
|
|
@@ -106211,9 +106581,9 @@ function openPricingPanel(params) {
|
|
|
106211
106581
|
const pushAudit = (rec) => {
|
|
106212
106582
|
if (rec) auditLog = [rec, ...auditLog];
|
|
106213
106583
|
};
|
|
106214
|
-
const badge = (domain, category) => `<span class="myio-pricing__badge${domain === "water" ? " myio-pricing__badge--water" : ""}">${
|
|
106584
|
+
const badge = (domain, category) => `<span class="myio-pricing__badge${domain === "water" ? " myio-pricing__badge--water" : ""}">${escapeHtml12(
|
|
106215
106585
|
DOMAIN_LABEL[domain]
|
|
106216
|
-
)} \xB7 ${
|
|
106586
|
+
)} \xB7 ${escapeHtml12(CATEGORY_LABEL[category])}</span>`;
|
|
106217
106587
|
const renderList2 = () => {
|
|
106218
106588
|
const customerId = customerSel.value;
|
|
106219
106589
|
const rows = entries.filter((e) => e.customerId === customerId).sort((a, b) => {
|
|
@@ -106226,15 +106596,15 @@ function openPricingPanel(params) {
|
|
|
106226
106596
|
const boundsKey = b ? `${b.start}__${b.end}` : "";
|
|
106227
106597
|
return `
|
|
106228
106598
|
<li class="myio-pricing__item">
|
|
106229
|
-
<span class="myio-pricing__item-period">${badge(e.domain, e.category)} ${
|
|
106599
|
+
<span class="myio-pricing__item-period">${badge(e.domain, e.category)} ${escapeHtml12(
|
|
106230
106600
|
formatPeriodLabel(e)
|
|
106231
106601
|
)}</span>
|
|
106232
|
-
<span class="myio-pricing__item-price">${
|
|
106602
|
+
<span class="myio-pricing__item-price">${escapeHtml12(formatBRL2(e.pricePerKwh))} ${escapeHtml12(
|
|
106233
106603
|
unitLabel(e.domain)
|
|
106234
106604
|
)}</span>
|
|
106235
|
-
<button class="myio-pricing__remove" data-remove="${
|
|
106605
|
+
<button class="myio-pricing__remove" data-remove="${escapeHtml12(e.domain)}|${escapeHtml12(
|
|
106236
106606
|
e.category
|
|
106237
|
-
)}|${
|
|
106607
|
+
)}|${escapeHtml12(boundsKey)}" aria-label="Remover" type="button">\u2715</button>
|
|
106238
106608
|
</li>`;
|
|
106239
106609
|
}).join("");
|
|
106240
106610
|
emptyEl.style.display = rows.length ? "none" : "";
|
|
@@ -106333,8 +106703,8 @@ function openPricingPanel(params) {
|
|
|
106333
106703
|
kpiEl.innerHTML = cards.map(
|
|
106334
106704
|
(c) => `
|
|
106335
106705
|
<div class="myio-pricing__kpi">
|
|
106336
|
-
<div class="myio-pricing__kpi-value">${
|
|
106337
|
-
<div class="myio-pricing__kpi-label">${
|
|
106706
|
+
<div class="myio-pricing__kpi-value">${escapeHtml12(c.value)}</div>
|
|
106707
|
+
<div class="myio-pricing__kpi-label">${escapeHtml12(c.label)}</div>
|
|
106338
106708
|
</div>`
|
|
106339
106709
|
).join("");
|
|
106340
106710
|
renderReport();
|
|
@@ -106353,11 +106723,11 @@ function openPricingPanel(params) {
|
|
|
106353
106723
|
reportBody.innerHTML = rows.length ? rows.map(
|
|
106354
106724
|
(e) => `
|
|
106355
106725
|
<tr>
|
|
106356
|
-
<td>${
|
|
106357
|
-
<td>${
|
|
106358
|
-
<td>${
|
|
106359
|
-
<td>${
|
|
106360
|
-
<td>${
|
|
106726
|
+
<td>${escapeHtml12(customerTitle(e.customerId))}</td>
|
|
106727
|
+
<td>${escapeHtml12(DOMAIN_LABEL[e.domain])}</td>
|
|
106728
|
+
<td>${escapeHtml12(CATEGORY_LABEL[e.category])}</td>
|
|
106729
|
+
<td>${escapeHtml12(formatPeriodLabel(e))}</td>
|
|
106730
|
+
<td>${escapeHtml12(formatBRL2(e.pricePerKwh))} ${escapeHtml12(unitLabel(e.domain))}</td>
|
|
106361
106731
|
</tr>`
|
|
106362
106732
|
).join("") : `<tr><td colspan="5" style="text-align:center;color:var(--myio-text-muted,#6b7280);padding:24px;">Nenhum pre\xE7o para o filtro selecionado.</td></tr>`;
|
|
106363
106733
|
}
|
|
@@ -106367,15 +106737,15 @@ function openPricingPanel(params) {
|
|
|
106367
106737
|
return `
|
|
106368
106738
|
<li class="myio-pricing__history-item">
|
|
106369
106739
|
<div class="myio-pricing__history-head">
|
|
106370
|
-
<span class="myio-pricing__action myio-pricing__action--${
|
|
106740
|
+
<span class="myio-pricing__action myio-pricing__action--${escapeHtml12(rec.action)}">${escapeHtml12(
|
|
106371
106741
|
rec.action
|
|
106372
106742
|
)}</span>
|
|
106373
106743
|
${badge(rec.domain, rec.category)}
|
|
106374
|
-
<span>${
|
|
106744
|
+
<span>${escapeHtml12(rec.periodLabel)}${escapeHtml12(priceInfo)}</span>
|
|
106375
106745
|
</div>
|
|
106376
|
-
<div class="myio-pricing__history-meta">${
|
|
106746
|
+
<div class="myio-pricing__history-meta">${escapeHtml12(customerTitle(rec.customerId))} \xB7 ${escapeHtml12(
|
|
106377
106747
|
rec.by || "\u2014"
|
|
106378
|
-
)} \xB7 ${
|
|
106748
|
+
)} \xB7 ${escapeHtml12(fmtTimestamp(rec.at))}</div>
|
|
106379
106749
|
</li>`;
|
|
106380
106750
|
}).join("");
|
|
106381
106751
|
historyEmpty.style.display = auditLog.length ? "none" : "";
|
|
@@ -114710,6 +115080,1116 @@ function refreshIncidentBadges(opts) {
|
|
|
114710
115080
|
});
|
|
114711
115081
|
}
|
|
114712
115082
|
|
|
115083
|
+
// src/components/premium-modals/standard-modal/openStandardModal.ts
|
|
115084
|
+
var STYLE_ID13 = "myio-stdmodal-styles";
|
|
115085
|
+
var FONT_LINK_ID3 = "myio-dialog-font-nunito";
|
|
115086
|
+
var BASE_Z_INDEX3 = 10700;
|
|
115087
|
+
var openCount3 = 0;
|
|
115088
|
+
function escapeHtml13(v) {
|
|
115089
|
+
return String(v).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
115090
|
+
}
|
|
115091
|
+
function injectStyles13() {
|
|
115092
|
+
if (!document.getElementById(FONT_LINK_ID3)) {
|
|
115093
|
+
const link = document.createElement("link");
|
|
115094
|
+
link.id = FONT_LINK_ID3;
|
|
115095
|
+
link.rel = "stylesheet";
|
|
115096
|
+
link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
|
|
115097
|
+
document.head.appendChild(link);
|
|
115098
|
+
}
|
|
115099
|
+
if (document.getElementById(STYLE_ID13)) return;
|
|
115100
|
+
const style = document.createElement("style");
|
|
115101
|
+
style.id = STYLE_ID13;
|
|
115102
|
+
style.textContent = `
|
|
115103
|
+
.myio-stdmodal-overlay {
|
|
115104
|
+
position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
|
|
115105
|
+
background: rgba(0, 0, 0, 0.5); font-family: 'Nunito', system-ui, sans-serif;
|
|
115106
|
+
}
|
|
115107
|
+
.myio-stdmodal {
|
|
115108
|
+
background: #fff; color: #1f2937; border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
|
|
115109
|
+
max-width: 94vw; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
|
|
115110
|
+
}
|
|
115111
|
+
.myio-stdmodal__body { padding: 20px 24px; overflow-y: auto; font-size: 14px; color: #374151; }
|
|
115112
|
+
.myio-stdmodal__footer {
|
|
115113
|
+
display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px;
|
|
115114
|
+
border-top: 1px solid #e0e0e0; background: #fff;
|
|
115115
|
+
}
|
|
115116
|
+
.myio-stdmodal__btn {
|
|
115117
|
+
font-family: inherit; padding: 10px 20px; border: none; border-radius: 6px; font-size: 14px;
|
|
115118
|
+
font-weight: 500; cursor: pointer; transition: all 0.2s; color: #fff;
|
|
115119
|
+
}
|
|
115120
|
+
.myio-stdmodal__btn--secondary { background: #6c757d; }
|
|
115121
|
+
.myio-stdmodal__btn--secondary:hover:not(:disabled) { background: #545b62; }
|
|
115122
|
+
.myio-stdmodal__btn--primary { background: var(--myio-brand-700, #3e1a7d); }
|
|
115123
|
+
.myio-stdmodal__btn--primary:hover:not(:disabled) { background: var(--myio-brand-600, #2d1458); }
|
|
115124
|
+
.myio-stdmodal__btn--danger { background: #dc3545; }
|
|
115125
|
+
.myio-stdmodal__btn--danger:hover:not(:disabled) { background: #b02a37; }
|
|
115126
|
+
.myio-stdmodal__btn:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
115127
|
+
.myio-stdmodal__btn:focus-visible { outline: 2px solid #7c3aed; outline-offset: 2px; }
|
|
115128
|
+
`;
|
|
115129
|
+
document.head.appendChild(style);
|
|
115130
|
+
}
|
|
115131
|
+
var FOCUSABLE2 = 'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
115132
|
+
function openStandardModal(params) {
|
|
115133
|
+
injectStyles13();
|
|
115134
|
+
const dismissible = params.dismissible ?? true;
|
|
115135
|
+
const buttons = params.buttons ?? [];
|
|
115136
|
+
const modalId = `myio-stdmodal-${++openCount3}`;
|
|
115137
|
+
const width = params.width == null ? "480px" : typeof params.width === "number" ? `${params.width}px` : params.width;
|
|
115138
|
+
const overlay = document.createElement("div");
|
|
115139
|
+
overlay.className = "myio-stdmodal-overlay";
|
|
115140
|
+
overlay.style.zIndex = String(BASE_Z_INDEX3 + openCount3);
|
|
115141
|
+
overlay.innerHTML = `
|
|
115142
|
+
<div class="myio-stdmodal" role="dialog" aria-modal="true" aria-label="${escapeHtml13(params.title)}" style="width:${width}">
|
|
115143
|
+
${ModalHeader.generateHTML({
|
|
115144
|
+
icon: params.icon,
|
|
115145
|
+
title: escapeHtml13(params.title),
|
|
115146
|
+
modalId,
|
|
115147
|
+
showThemeToggle: false,
|
|
115148
|
+
showMaximize: false,
|
|
115149
|
+
showClose: dismissible,
|
|
115150
|
+
draggable: false
|
|
115151
|
+
})}
|
|
115152
|
+
<div class="myio-stdmodal__body"></div>
|
|
115153
|
+
${buttons.length ? `<div class="myio-stdmodal__footer">${buttons.map(
|
|
115154
|
+
(b, i) => `<button type="button" class="myio-stdmodal__btn myio-stdmodal__btn--${b.variant ?? "secondary"}" data-index="${i}" data-value="${escapeHtml13(b.value)}">${escapeHtml13(b.label)}</button>`
|
|
115155
|
+
).join("")}</div>` : ""}
|
|
115156
|
+
</div>`;
|
|
115157
|
+
const root = overlay.querySelector(".myio-stdmodal");
|
|
115158
|
+
const bodyEl = root.querySelector(".myio-stdmodal__body");
|
|
115159
|
+
bodyEl.innerHTML = params.bodyHtml;
|
|
115160
|
+
const previousFocus = document.activeElement;
|
|
115161
|
+
(params.container ?? document.body).appendChild(overlay);
|
|
115162
|
+
let closed = false;
|
|
115163
|
+
const close = () => {
|
|
115164
|
+
if (closed) return;
|
|
115165
|
+
closed = true;
|
|
115166
|
+
document.removeEventListener("keydown", onKeydown, true);
|
|
115167
|
+
overlay.remove();
|
|
115168
|
+
if (previousFocus?.isConnected) previousFocus.focus();
|
|
115169
|
+
params.onClose?.();
|
|
115170
|
+
};
|
|
115171
|
+
const onKeydown = (e) => {
|
|
115172
|
+
if (!overlay.isConnected) return;
|
|
115173
|
+
if (e.key === "Escape" && dismissible) {
|
|
115174
|
+
e.stopPropagation();
|
|
115175
|
+
close();
|
|
115176
|
+
} else if (e.key === "Tab") {
|
|
115177
|
+
const f = Array.from(root.querySelectorAll(FOCUSABLE2)).filter((el2) => el2.offsetParent !== null || el2 === document.activeElement);
|
|
115178
|
+
if (!f.length) return;
|
|
115179
|
+
const first = f[0];
|
|
115180
|
+
const last = f[f.length - 1];
|
|
115181
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
115182
|
+
e.preventDefault();
|
|
115183
|
+
last.focus();
|
|
115184
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
115185
|
+
e.preventDefault();
|
|
115186
|
+
first.focus();
|
|
115187
|
+
}
|
|
115188
|
+
}
|
|
115189
|
+
};
|
|
115190
|
+
document.addEventListener("keydown", onKeydown, true);
|
|
115191
|
+
root.querySelector(`#${modalId}-close`)?.addEventListener("click", (e) => {
|
|
115192
|
+
e.stopPropagation();
|
|
115193
|
+
close();
|
|
115194
|
+
});
|
|
115195
|
+
if (dismissible) {
|
|
115196
|
+
overlay.addEventListener("click", (e) => {
|
|
115197
|
+
if (e.target === overlay) close();
|
|
115198
|
+
});
|
|
115199
|
+
}
|
|
115200
|
+
root.querySelectorAll(".myio-stdmodal__btn").forEach((el2) => {
|
|
115201
|
+
el2.addEventListener("click", () => {
|
|
115202
|
+
const b = buttons[Number(el2.dataset.index)];
|
|
115203
|
+
if (!b || el2.disabled) return;
|
|
115204
|
+
params.onButton?.(b.value);
|
|
115205
|
+
if (b.closeOnClick !== false) close();
|
|
115206
|
+
});
|
|
115207
|
+
});
|
|
115208
|
+
(root.querySelector(`.myio-stdmodal__body ${FOCUSABLE2}`) ?? root.querySelector(".myio-stdmodal__btn--primary") ?? root)?.focus?.();
|
|
115209
|
+
return {
|
|
115210
|
+
close,
|
|
115211
|
+
getRoot: () => root,
|
|
115212
|
+
getBodyEl: () => bodyEl,
|
|
115213
|
+
setBodyHtml: (html) => {
|
|
115214
|
+
bodyEl.innerHTML = html;
|
|
115215
|
+
},
|
|
115216
|
+
setButton: (value, patch) => {
|
|
115217
|
+
const el2 = Array.from(root.querySelectorAll(".myio-stdmodal__btn")).find(
|
|
115218
|
+
(b) => b.dataset.value === value
|
|
115219
|
+
);
|
|
115220
|
+
if (!el2) return;
|
|
115221
|
+
if (patch.label !== void 0) el2.textContent = patch.label;
|
|
115222
|
+
if (patch.disabled !== void 0) el2.disabled = patch.disabled;
|
|
115223
|
+
if (patch.hidden !== void 0) el2.style.display = patch.hidden ? "none" : "";
|
|
115224
|
+
}
|
|
115225
|
+
};
|
|
115226
|
+
}
|
|
115227
|
+
|
|
115228
|
+
// src/components/premium-modals/telemetry-import/sheet.ts
|
|
115229
|
+
var VALUE_COLUMN = {
|
|
115230
|
+
energy: "value_kwh",
|
|
115231
|
+
water: "value_m3"
|
|
115232
|
+
};
|
|
115233
|
+
var MAX_IMPORT_ROWS = 5e3;
|
|
115234
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
115235
|
+
var pad24 = (n) => String(n).padStart(2, "0");
|
|
115236
|
+
function splitImportableDevices(devices) {
|
|
115237
|
+
const ok = [];
|
|
115238
|
+
const missingKey = [];
|
|
115239
|
+
for (const d of devices || []) {
|
|
115240
|
+
const slave = Number(d?.slaveId);
|
|
115241
|
+
if (d?.centralId && UUID_RE.test(String(d.centralId)) && Number.isInteger(slave) && slave >= 1 && slave <= 247) ok.push(d);
|
|
115242
|
+
else missingKey.push(d);
|
|
115243
|
+
}
|
|
115244
|
+
return { ok, missingKey };
|
|
115245
|
+
}
|
|
115246
|
+
function daysBetween(start, end) {
|
|
115247
|
+
const out = [];
|
|
115248
|
+
const [y1, m1, d1] = start.split("-").map(Number);
|
|
115249
|
+
const [y2, m2, d2] = end.split("-").map(Number);
|
|
115250
|
+
const cur = new Date(Date.UTC(y1, m1 - 1, d1));
|
|
115251
|
+
const last = Date.UTC(y2, m2 - 1, d2);
|
|
115252
|
+
while (cur.getTime() <= last && out.length < 400) {
|
|
115253
|
+
out.push(`${cur.getUTCFullYear()}-${pad24(cur.getUTCMonth() + 1)}-${pad24(cur.getUTCDate())}`);
|
|
115254
|
+
cur.setUTCDate(cur.getUTCDate() + 1);
|
|
115255
|
+
}
|
|
115256
|
+
return out;
|
|
115257
|
+
}
|
|
115258
|
+
function nowSaoPaulo(now) {
|
|
115259
|
+
const d = new Date(now - 3 * 3600 * 1e3);
|
|
115260
|
+
return { date: `${d.getUTCFullYear()}-${pad24(d.getUTCMonth() + 1)}-${pad24(d.getUTCDate())}`, hour: d.getUTCHours() };
|
|
115261
|
+
}
|
|
115262
|
+
function buildTemplateCsv(domain, devices, start, end, now = Date.now()) {
|
|
115263
|
+
const valueCol = VALUE_COLUMN[domain];
|
|
115264
|
+
const header = ["gateway_id", "slave_id", "device_name", "date", "hour", valueCol];
|
|
115265
|
+
if (domain === "energy") header.push("value_reactive_kvarh");
|
|
115266
|
+
const today = nowSaoPaulo(now);
|
|
115267
|
+
const lines = [header.join(";")];
|
|
115268
|
+
const esc10 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
115269
|
+
const { ok } = splitImportableDevices(devices);
|
|
115270
|
+
for (const dev of ok) {
|
|
115271
|
+
for (const date of daysBetween(start, end)) {
|
|
115272
|
+
if (date > today.date) break;
|
|
115273
|
+
for (let h3 = 0; h3 < 24; h3++) {
|
|
115274
|
+
if (date === today.date && h3 >= today.hour) break;
|
|
115275
|
+
const cols = [String(dev.centralId), String(Number(dev.slaveId)), esc10(dev.label || ""), date, `${pad24(h3)}:00`, ""];
|
|
115276
|
+
if (domain === "energy") cols.push("");
|
|
115277
|
+
lines.push(cols.join(";"));
|
|
115278
|
+
}
|
|
115279
|
+
}
|
|
115280
|
+
}
|
|
115281
|
+
return { csv: "\uFEFF" + lines.join("\r\n") + "\r\n", rows: lines.length - 1 };
|
|
115282
|
+
}
|
|
115283
|
+
function parseCsv(text2) {
|
|
115284
|
+
const src = String(text2 || "").replace(/^/, "");
|
|
115285
|
+
const firstLine = src.split(/\r?\n/, 1)[0] || "";
|
|
115286
|
+
const sep = (firstLine.match(/;/g) || []).length >= (firstLine.match(/,/g) || []).length ? ";" : ",";
|
|
115287
|
+
const out = [];
|
|
115288
|
+
let row = [];
|
|
115289
|
+
let cell = "";
|
|
115290
|
+
let quoted = false;
|
|
115291
|
+
for (let i = 0; i < src.length; i++) {
|
|
115292
|
+
const c = src[i];
|
|
115293
|
+
if (quoted) {
|
|
115294
|
+
if (c === '"' && src[i + 1] === '"') {
|
|
115295
|
+
cell += '"';
|
|
115296
|
+
i++;
|
|
115297
|
+
} else if (c === '"') quoted = false;
|
|
115298
|
+
else cell += c;
|
|
115299
|
+
} else if (c === '"') quoted = true;
|
|
115300
|
+
else if (c === sep) {
|
|
115301
|
+
row.push(cell);
|
|
115302
|
+
cell = "";
|
|
115303
|
+
} else if (c === "\n" || c === "\r") {
|
|
115304
|
+
if (c === "\r" && src[i + 1] === "\n") i++;
|
|
115305
|
+
row.push(cell);
|
|
115306
|
+
out.push(row);
|
|
115307
|
+
row = [];
|
|
115308
|
+
cell = "";
|
|
115309
|
+
} else cell += c;
|
|
115310
|
+
}
|
|
115311
|
+
if (cell !== "" || row.length) {
|
|
115312
|
+
row.push(cell);
|
|
115313
|
+
out.push(row);
|
|
115314
|
+
}
|
|
115315
|
+
return out;
|
|
115316
|
+
}
|
|
115317
|
+
function normalizeDate(v) {
|
|
115318
|
+
if (typeof v === "number" && Number.isFinite(v) && v > 2e4 && v < 8e4) {
|
|
115319
|
+
const d = new Date(Date.UTC(1899, 11, 30) + Math.floor(v) * 864e5);
|
|
115320
|
+
return `${d.getUTCFullYear()}-${pad24(d.getUTCMonth() + 1)}-${pad24(d.getUTCDate())}`;
|
|
115321
|
+
}
|
|
115322
|
+
const s = String(v ?? "").trim();
|
|
115323
|
+
let m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s);
|
|
115324
|
+
if (m) return `${m[1]}-${pad24(+m[2])}-${pad24(+m[3])}`;
|
|
115325
|
+
m = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(s);
|
|
115326
|
+
if (m) return `${m[3]}-${pad24(+m[2])}-${pad24(+m[1])}`;
|
|
115327
|
+
return null;
|
|
115328
|
+
}
|
|
115329
|
+
function normalizeHour(v) {
|
|
115330
|
+
if (typeof v === "number" && Number.isFinite(v) && v >= 0 && v < 1) {
|
|
115331
|
+
const mins = Math.round(v * 24 * 60);
|
|
115332
|
+
return mins % 60 === 0 ? `${pad24(mins / 60)}:00` : null;
|
|
115333
|
+
}
|
|
115334
|
+
const s = String(v ?? "").trim();
|
|
115335
|
+
const m = /^(\d{1,2})(?::(\d{2})(?::(\d{2}))?)?$/.exec(s);
|
|
115336
|
+
if (!m) return null;
|
|
115337
|
+
const h3 = Number(m[1]);
|
|
115338
|
+
if (h3 > 23 || Number(m[2] || 0) !== 0 || Number(m[3] || 0) !== 0) return null;
|
|
115339
|
+
return `${pad24(h3)}:00`;
|
|
115340
|
+
}
|
|
115341
|
+
function parseDecimal(v) {
|
|
115342
|
+
if (typeof v === "number") return Number.isFinite(v) ? v : NaN;
|
|
115343
|
+
const s = String(v ?? "").trim();
|
|
115344
|
+
if (!s) return null;
|
|
115345
|
+
const norm2 = s.includes(",") ? s.replace(/\./g, "").replace(",", ".") : s;
|
|
115346
|
+
return /^-?\d+(\.\d+)?$/.test(norm2) ? Number(norm2) : NaN;
|
|
115347
|
+
}
|
|
115348
|
+
function rowsFromTable(domain, table) {
|
|
115349
|
+
const errors = [];
|
|
115350
|
+
const rows = [];
|
|
115351
|
+
let skippedEmpty = 0;
|
|
115352
|
+
const valueCol = VALUE_COLUMN[domain];
|
|
115353
|
+
const header = (table[0] || []).map((h3) => String(h3 ?? "").trim().toLowerCase());
|
|
115354
|
+
const col2 = (name) => header.indexOf(name);
|
|
115355
|
+
const idx = { gw: col2("gateway_id"), slave: col2("slave_id"), date: col2("date"), hour: col2("hour"), value: col2(valueCol), reactive: col2("value_reactive_kvarh") };
|
|
115356
|
+
const missing = ["gateway_id", "slave_id", "date", "hour", valueCol].filter((c) => col2(c) < 0);
|
|
115357
|
+
if (missing.length) {
|
|
115358
|
+
return { rows, errors: [{ line: 1, reason: `Coluna obrigat\xF3ria ausente: ${missing.join(", ")}` }], skippedEmpty };
|
|
115359
|
+
}
|
|
115360
|
+
const seen = /* @__PURE__ */ new Map();
|
|
115361
|
+
for (let i = 1; i < table.length; i++) {
|
|
115362
|
+
const r = table[i] || [];
|
|
115363
|
+
const line = i + 1;
|
|
115364
|
+
if (r.every((c) => String(c ?? "").trim() === "")) continue;
|
|
115365
|
+
const gw = String(r[idx.gw] ?? "").trim();
|
|
115366
|
+
const slave = Number(String(r[idx.slave] ?? "").trim());
|
|
115367
|
+
const date = normalizeDate(r[idx.date]);
|
|
115368
|
+
const hour = normalizeHour(r[idx.hour]);
|
|
115369
|
+
const value = parseDecimal(r[idx.value]);
|
|
115370
|
+
if (value === null) {
|
|
115371
|
+
skippedEmpty++;
|
|
115372
|
+
continue;
|
|
115373
|
+
}
|
|
115374
|
+
const lineErrors = [];
|
|
115375
|
+
if (!UUID_RE.test(gw)) lineErrors.push("gateway_id inv\xE1lido");
|
|
115376
|
+
if (!Number.isInteger(slave) || slave < 1 || slave > 247) lineErrors.push("slave_id deve ser inteiro de 1 a 247");
|
|
115377
|
+
if (!date) lineErrors.push("data inv\xE1lida (use AAAA-MM-DD)");
|
|
115378
|
+
if (!hour) lineErrors.push("hora inv\xE1lida (use HH:00)");
|
|
115379
|
+
if (Number.isNaN(value) || value < 0) lineErrors.push("valor deve ser n\xFAmero \u2265 0");
|
|
115380
|
+
let reactive;
|
|
115381
|
+
if (domain === "energy" && idx.reactive >= 0) {
|
|
115382
|
+
const rv = parseDecimal(r[idx.reactive]);
|
|
115383
|
+
if (Number.isNaN(rv)) lineErrors.push("reativo inv\xE1lido");
|
|
115384
|
+
else if (rv !== null) reactive = rv;
|
|
115385
|
+
}
|
|
115386
|
+
if (lineErrors.length) {
|
|
115387
|
+
errors.push({ line, reason: lineErrors.join("; ") });
|
|
115388
|
+
continue;
|
|
115389
|
+
}
|
|
115390
|
+
const key = `${gw.toLowerCase()}|${slave}|${date}|${hour}`;
|
|
115391
|
+
if (seen.has(key)) {
|
|
115392
|
+
errors.push({ line, reason: `linha duplicada (mesmo device/data/hora da linha ${seen.get(key)})` });
|
|
115393
|
+
continue;
|
|
115394
|
+
}
|
|
115395
|
+
seen.set(key, line);
|
|
115396
|
+
const row = { line, gateway_id: gw, slave_id: slave, date, hour, [valueCol]: value };
|
|
115397
|
+
if (reactive !== void 0) row.value_reactive_kvarh = reactive;
|
|
115398
|
+
rows.push(row);
|
|
115399
|
+
}
|
|
115400
|
+
if (rows.length > MAX_IMPORT_ROWS) {
|
|
115401
|
+
errors.push({ line: 1, reason: `M\xE1ximo de ${MAX_IMPORT_ROWS} linhas por importa\xE7\xE3o (${rows.length} enviadas)` });
|
|
115402
|
+
}
|
|
115403
|
+
return { rows, errors, skippedEmpty };
|
|
115404
|
+
}
|
|
115405
|
+
var SHEETJS_URL = "https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js";
|
|
115406
|
+
async function loadSheetJs() {
|
|
115407
|
+
const w = window;
|
|
115408
|
+
if (w.XLSX) return w.XLSX;
|
|
115409
|
+
await new Promise((resolve, reject) => {
|
|
115410
|
+
const s = document.createElement("script");
|
|
115411
|
+
s.src = SHEETJS_URL;
|
|
115412
|
+
s.onload = () => resolve();
|
|
115413
|
+
s.onerror = () => reject(new Error("N\xE3o foi poss\xEDvel carregar o leitor de Excel"));
|
|
115414
|
+
document.head.appendChild(s);
|
|
115415
|
+
});
|
|
115416
|
+
return w.XLSX;
|
|
115417
|
+
}
|
|
115418
|
+
function readFile(file, as) {
|
|
115419
|
+
return new Promise((resolve, reject) => {
|
|
115420
|
+
const fr = new FileReader();
|
|
115421
|
+
fr.onload = () => resolve(fr.result);
|
|
115422
|
+
fr.onerror = () => reject(new Error("N\xE3o foi poss\xEDvel ler o arquivo"));
|
|
115423
|
+
if (as === "text") fr.readAsText(file, "utf-8");
|
|
115424
|
+
else fr.readAsArrayBuffer(file);
|
|
115425
|
+
});
|
|
115426
|
+
}
|
|
115427
|
+
async function parseSheetFile(file) {
|
|
115428
|
+
const name = String(file?.name || "").toLowerCase();
|
|
115429
|
+
if (name.endsWith(".csv") || name.endsWith(".txt")) return parseCsv(await readFile(file, "text"));
|
|
115430
|
+
if (name.endsWith(".xlsx") || name.endsWith(".xls")) {
|
|
115431
|
+
const XLSX = await loadSheetJs();
|
|
115432
|
+
const wb = XLSX.read(await readFile(file, "buffer"), { type: "array" });
|
|
115433
|
+
const ws = wb.Sheets[wb.SheetNames[0]];
|
|
115434
|
+
return XLSX.utils.sheet_to_json(ws, { header: 1, raw: true, defval: "" });
|
|
115435
|
+
}
|
|
115436
|
+
throw new Error("Formato n\xE3o suportado \u2014 envie .xlsx ou .csv");
|
|
115437
|
+
}
|
|
115438
|
+
|
|
115439
|
+
// src/components/premium-modals/telemetry-import/importApi.ts
|
|
115440
|
+
var TERMINAL_JOB_STATUSES = ["completed", "failed", "cancelled", "reverted"];
|
|
115441
|
+
var ImportApiError = class extends Error {
|
|
115442
|
+
constructor(message, status, detail) {
|
|
115443
|
+
super(message);
|
|
115444
|
+
this.status = status;
|
|
115445
|
+
this.detail = detail;
|
|
115446
|
+
this.name = "ImportApiError";
|
|
115447
|
+
}
|
|
115448
|
+
};
|
|
115449
|
+
function createTelemetryImportApi(cfg) {
|
|
115450
|
+
const base = String(cfg.baseUrl || "").replace(/\/+$/, "");
|
|
115451
|
+
const doFetch = cfg.fetchImpl ?? fetch.bind(window);
|
|
115452
|
+
const call = async (method, path, body, accept422 = false) => {
|
|
115453
|
+
const token = await cfg.getToken();
|
|
115454
|
+
const res = await doFetch(`${base}/import${path}`, {
|
|
115455
|
+
method,
|
|
115456
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
115457
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
115458
|
+
});
|
|
115459
|
+
const text2 = await res.text().catch(() => "");
|
|
115460
|
+
let data = null;
|
|
115461
|
+
try {
|
|
115462
|
+
data = text2 ? JSON.parse(text2) : null;
|
|
115463
|
+
} catch {
|
|
115464
|
+
data = null;
|
|
115465
|
+
}
|
|
115466
|
+
if (res.ok || accept422 && res.status === 422) return { status: res.status, data: data?.data ?? data };
|
|
115467
|
+
const apiMsg = data?.message || data?.error || "";
|
|
115468
|
+
const msg = res.status === 404 ? "A importa\xE7\xE3o ainda n\xE3o est\xE1 dispon\xEDvel neste ambiente." : res.status === 401 || res.status === 403 ? "Sem permiss\xE3o para importar telemetria (credencial sem o escopo telemetry.import)." : res.status === 409 ? apiMsg || "Opera\xE7\xE3o n\xE3o permitida no estado atual da importa\xE7\xE3o." : `Falha na API de importa\xE7\xE3o (${res.status}).`;
|
|
115469
|
+
throw new ImportApiError(msg, res.status, `${method} /import${path} \u2192 ${res.status} ${String(apiMsg || text2).slice(0, 200)}`);
|
|
115470
|
+
};
|
|
115471
|
+
return {
|
|
115472
|
+
async validate(body) {
|
|
115473
|
+
const { status, data } = await call("POST", "/validate", body, true);
|
|
115474
|
+
if (status === 422 || data?.valid === false) {
|
|
115475
|
+
return { valid: false, invalidCount: Number(data?.invalidCount ?? data?.errors?.length ?? 0), errors: data?.errors || [] };
|
|
115476
|
+
}
|
|
115477
|
+
return { valid: true, validationId: data.validationId, expiresAt: data.expiresAt, preview: data.preview || {} };
|
|
115478
|
+
},
|
|
115479
|
+
async startJob(body) {
|
|
115480
|
+
const { data } = await call("POST", "/jobs", body);
|
|
115481
|
+
return { jobId: data.jobId, status: data.status || "queued" };
|
|
115482
|
+
},
|
|
115483
|
+
async getJob(jobId) {
|
|
115484
|
+
const { data } = await call("GET", `/jobs/${encodeURIComponent(jobId)}`);
|
|
115485
|
+
return { jobId, ...data || {} };
|
|
115486
|
+
},
|
|
115487
|
+
async cancelJob(jobId) {
|
|
115488
|
+
const { data } = await call("POST", `/jobs/${encodeURIComponent(jobId)}/cancel`);
|
|
115489
|
+
return data ? { jobId, ...data } : null;
|
|
115490
|
+
}
|
|
115491
|
+
};
|
|
115492
|
+
}
|
|
115493
|
+
|
|
115494
|
+
// src/components/premium-modals/telemetry-import/openTelemetryImportModal.ts
|
|
115495
|
+
var STEPS2 = [
|
|
115496
|
+
{ n: 1, label: "Modelo" },
|
|
115497
|
+
{ n: 2, label: "Planilha" },
|
|
115498
|
+
{ n: 3, label: "Valida\xE7\xE3o" },
|
|
115499
|
+
{ n: 4, label: "Importa\xE7\xE3o" }
|
|
115500
|
+
];
|
|
115501
|
+
var DOMAIN_TEXT = {
|
|
115502
|
+
energy: { noun: "energia", unit: "kWh", icon: "\u26A1" },
|
|
115503
|
+
water: { noun: "\xE1gua", unit: "m\xB3", icon: "\u{1F4A7}" }
|
|
115504
|
+
};
|
|
115505
|
+
var JOB_STATUS_TEXT = {
|
|
115506
|
+
queued: "Na fila",
|
|
115507
|
+
executing: "Importando",
|
|
115508
|
+
completed: "Conclu\xEDda",
|
|
115509
|
+
failed: "Falhou",
|
|
115510
|
+
cancelled: "Cancelada",
|
|
115511
|
+
reverted: "Revertida"
|
|
115512
|
+
};
|
|
115513
|
+
var STYLE_ID14 = "myio-tlmimport-styles";
|
|
115514
|
+
function esc9(v) {
|
|
115515
|
+
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
115516
|
+
}
|
|
115517
|
+
var fmtNum = (n, d = 0) => Number.isFinite(Number(n)) ? Number(n).toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d }) : "\u2014";
|
|
115518
|
+
function injectStyles14() {
|
|
115519
|
+
if (document.getElementById(STYLE_ID14)) return;
|
|
115520
|
+
const style = document.createElement("style");
|
|
115521
|
+
style.id = STYLE_ID14;
|
|
115522
|
+
style.textContent = `
|
|
115523
|
+
.tlmi { --tlmi-ac: #3e1a7d; --tlmi-ac-soft: #f1ecfa; --tlmi-ok: #16a34a; --tlmi-warn: #d97706; --tlmi-err: #dc2626;
|
|
115524
|
+
display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: #1e293b; }
|
|
115525
|
+
.tlmi-stepper { display: flex; gap: 6px; }
|
|
115526
|
+
.tlmi-step { flex: 1; display: flex; align-items: center; gap: 8px; color: #64748b; padding: 6px 8px; border-radius: 10px; font-size: 13px; }
|
|
115527
|
+
.tlmi-step b { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
|
|
115528
|
+
border: 2px solid #e2e8f0; font-size: 12px; flex-shrink: 0; }
|
|
115529
|
+
.tlmi-step[data-state="current"] { color: var(--tlmi-ac); font-weight: 800; background: var(--tlmi-ac-soft); }
|
|
115530
|
+
.tlmi-step[data-state="current"] b { border-color: var(--tlmi-ac); background: var(--tlmi-ac); color: #fff; }
|
|
115531
|
+
.tlmi-step[data-state="done"] { color: #1e293b; }
|
|
115532
|
+
.tlmi-step[data-state="done"] b { border-color: var(--tlmi-ok); background: var(--tlmi-ok); color: #fff; }
|
|
115533
|
+
.tlmi-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px 16px; }
|
|
115534
|
+
.tlmi-card h3 { margin: 0 0 10px !important; font-size: 14px !important; font-weight: 700 !important; line-height: 1.4 !important; }
|
|
115535
|
+
.tlmi-muted { color: #64748b; font-size: 13px; margin: 0; line-height: 1.5; }
|
|
115536
|
+
.tlmi-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
|
|
115537
|
+
.tlmi-field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 12px; color: #64748b; }
|
|
115538
|
+
.tlmi-field input { border: 1px solid #ddd; border-radius: 6px; padding: 8px 10px; font: inherit; color: #1e293b; }
|
|
115539
|
+
.tlmi-btn { font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 6px; border: 1px solid #d1d5db;
|
|
115540
|
+
background: #fff; color: #374151; cursor: pointer; }
|
|
115541
|
+
.tlmi-btn.primary { background: var(--tlmi-ac); border-color: var(--tlmi-ac); color: #fff; }
|
|
115542
|
+
.tlmi-btn:disabled { opacity: 0.55; cursor: not-allowed; }
|
|
115543
|
+
.tlmi-drop { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 22px; text-align: center; color: #64748b; cursor: pointer; }
|
|
115544
|
+
.tlmi-drop[data-over="1"] { border-color: var(--tlmi-ac); background: var(--tlmi-ac-soft); }
|
|
115545
|
+
.tlmi-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
|
|
115546
|
+
.tlmi-kpi { border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px; }
|
|
115547
|
+
.tlmi-kpi span { display: block; font-size: 11.5px; color: #64748b; }
|
|
115548
|
+
.tlmi-kpi strong { font-size: 18px; }
|
|
115549
|
+
.tlmi-banner { padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
|
|
115550
|
+
.tlmi-banner.warn { background: #fef3c7; border: 1px solid #fcd34d; color: #78350f; }
|
|
115551
|
+
.tlmi-banner.err { background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; }
|
|
115552
|
+
.tlmi-banner.ok { background: #dcfce7; border: 1px solid #86efac; color: #14532d; }
|
|
115553
|
+
.tlmi-errors { max-height: 220px; overflow: auto; border: 1px solid #fecaca; border-radius: 8px; }
|
|
115554
|
+
.tlmi-errors table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
|
|
115555
|
+
.tlmi-errors th, .tlmi-errors td { padding: 5px 8px; border-bottom: 1px solid #fee2e2; text-align: left; }
|
|
115556
|
+
.tlmi-errors th { background: #fef2f2; position: sticky; top: 0; }
|
|
115557
|
+
.tlmi-progress { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
|
|
115558
|
+
.tlmi-progress > i { display: block; height: 100%; background: var(--tlmi-ac); transition: width 0.4s; }
|
|
115559
|
+
.tlmi-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
|
|
115560
|
+
.tlmi-tech { font-size: 11.5px; color: #6b7280; word-break: break-word; }
|
|
115561
|
+
`;
|
|
115562
|
+
document.head.appendChild(style);
|
|
115563
|
+
}
|
|
115564
|
+
function issuesTable(errors, limit = 100) {
|
|
115565
|
+
const rows = errors.slice(0, limit).map((e) => `<tr><td>${esc9(e.line)}</td><td>${esc9(e.reason)}</td></tr>`).join("");
|
|
115566
|
+
const more = errors.length > limit ? `<p class="tlmi-muted">\u2026 e mais ${errors.length - limit} erro(s).</p>` : "";
|
|
115567
|
+
return `<div class="tlmi-errors"><table><thead><tr><th>Linha</th><th>Problema</th></tr></thead><tbody>${rows}</tbody></table></div>${more}`;
|
|
115568
|
+
}
|
|
115569
|
+
function defaultPeriod(now) {
|
|
115570
|
+
const sp = new Date(now - 3 * 3600 * 1e3);
|
|
115571
|
+
const ymd = (d) => d.toISOString().slice(0, 10);
|
|
115572
|
+
const end = new Date(Date.UTC(sp.getUTCFullYear(), sp.getUTCMonth(), sp.getUTCDate() - 1));
|
|
115573
|
+
const start = new Date(end.getTime() - 6 * 864e5);
|
|
115574
|
+
return { start: ymd(start), end: ymd(end) };
|
|
115575
|
+
}
|
|
115576
|
+
function openTelemetryImportModal(params) {
|
|
115577
|
+
injectStyles14();
|
|
115578
|
+
const domain = params.domain;
|
|
115579
|
+
const txt = DOMAIN_TEXT[domain];
|
|
115580
|
+
const now = params.now ?? (() => Date.now());
|
|
115581
|
+
const api = "validate" in params.api ? params.api : createTelemetryImportApi(params.api);
|
|
115582
|
+
const { ok: importable, missingKey } = splitImportableDevices(params.devices);
|
|
115583
|
+
const s = {
|
|
115584
|
+
step: 1,
|
|
115585
|
+
period: defaultPeriod(now()),
|
|
115586
|
+
fileName: "",
|
|
115587
|
+
rows: [],
|
|
115588
|
+
localErrors: [],
|
|
115589
|
+
skippedEmpty: 0,
|
|
115590
|
+
parseError: "",
|
|
115591
|
+
busy: false,
|
|
115592
|
+
validation: null,
|
|
115593
|
+
apiError: "",
|
|
115594
|
+
apiDetail: "",
|
|
115595
|
+
confirmReal: false,
|
|
115596
|
+
job: null
|
|
115597
|
+
};
|
|
115598
|
+
let pollTimer = null;
|
|
115599
|
+
let closed = false;
|
|
115600
|
+
const modal = openStandardModal({
|
|
115601
|
+
icon: "\u{1F4E5}",
|
|
115602
|
+
title: `Importar dados de ${txt.noun}`,
|
|
115603
|
+
width: 760,
|
|
115604
|
+
bodyHtml: '<div class="tlmi"></div>',
|
|
115605
|
+
container: params.container,
|
|
115606
|
+
buttons: [
|
|
115607
|
+
{ label: "Voltar", value: "back", variant: "secondary", closeOnClick: false },
|
|
115608
|
+
{ label: "Fechar", value: "close", variant: "secondary" },
|
|
115609
|
+
{ label: "Avan\xE7ar", value: "next", variant: "primary", closeOnClick: false }
|
|
115610
|
+
],
|
|
115611
|
+
onButton: (v) => {
|
|
115612
|
+
if (v === "back") goBack();
|
|
115613
|
+
if (v === "next") void goNext();
|
|
115614
|
+
},
|
|
115615
|
+
onClose: () => {
|
|
115616
|
+
closed = true;
|
|
115617
|
+
if (pollTimer) clearTimeout(pollTimer);
|
|
115618
|
+
}
|
|
115619
|
+
});
|
|
115620
|
+
const root = modal.getBodyEl().querySelector(".tlmi");
|
|
115621
|
+
const setError = (err) => {
|
|
115622
|
+
s.apiError = err instanceof ImportApiError ? err.message : err?.message || "Erro inesperado.";
|
|
115623
|
+
s.apiDetail = params.showTechnicalDetails ? err instanceof ImportApiError ? err.detail || "" : String(err) : "";
|
|
115624
|
+
};
|
|
115625
|
+
function stepper() {
|
|
115626
|
+
return `<div class="tlmi-stepper">${STEPS2.map((st) => {
|
|
115627
|
+
const state6 = st.n === s.step ? "current" : st.n < s.step ? "done" : "todo";
|
|
115628
|
+
return `<div class="tlmi-step" data-state="${state6}"><b>${state6 === "done" ? "\u2713" : st.n}</b>${st.label}</div>`;
|
|
115629
|
+
}).join("")}</div>`;
|
|
115630
|
+
}
|
|
115631
|
+
function apiErrorBanner() {
|
|
115632
|
+
if (!s.apiError) return "";
|
|
115633
|
+
return `<div class="tlmi-banner err" role="alert">${esc9(s.apiError)}${s.apiDetail ? `<div class="tlmi-tech">${esc9(s.apiDetail)}</div>` : ""}</div>`;
|
|
115634
|
+
}
|
|
115635
|
+
function step1() {
|
|
115636
|
+
const warn = missingKey.length ? `<div class="tlmi-banner warn">${missingKey.length} dispositivo(s) sem central/endere\xE7o cadastrados ficam fora do modelo: ${esc9(
|
|
115637
|
+
missingKey.slice(0, 5).map((d) => d.label).join(", ")
|
|
115638
|
+
)}${missingKey.length > 5 ? "\u2026" : ""}</div>` : "";
|
|
115639
|
+
return `
|
|
115640
|
+
<div class="tlmi-card"><h3>Como funciona</h3>
|
|
115641
|
+
<p class="tlmi-muted">1) Baixe o modelo com os dispositivos desta lista, uma linha por hora. 2) Preencha a coluna
|
|
115642
|
+
<strong>${VALUE_COLUMN[domain]}</strong> (${txt.unit}); apague ou deixe em branco as horas que n\xE3o quer alterar.
|
|
115643
|
+
3) Envie a planilha: ela \xE9 validada por inteiro \u2014 qualquer linha inv\xE1lida cancela a importa\xE7\xE3o.
|
|
115644
|
+
Os valores importados <strong>substituem</strong> as leituras existentes nas horas enviadas.</p>
|
|
115645
|
+
</div>
|
|
115646
|
+
${warn}
|
|
115647
|
+
<div class="tlmi-card"><h3>Modelo da planilha</h3>
|
|
115648
|
+
<div class="tlmi-row">
|
|
115649
|
+
<label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${esc9(s.period.start)}" /></label>
|
|
115650
|
+
<label class="tlmi-field">Fim<input type="date" data-field="end" value="${esc9(s.period.end)}" /></label>
|
|
115651
|
+
<button class="tlmi-btn" type="button" data-action="template" ${importable.length ? "" : "disabled"}>\u2B07 Baixar modelo (CSV)</button>
|
|
115652
|
+
</div>
|
|
115653
|
+
<p class="tlmi-muted" style="margin-top:8px">${importable.length} dispositivo(s) no modelo. J\xE1 tem a planilha preenchida? Clique em <strong>Avan\xE7ar</strong>.</p>
|
|
115654
|
+
</div>`;
|
|
115655
|
+
}
|
|
115656
|
+
function step2() {
|
|
115657
|
+
const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${esc9(s.parseError)}</div>` : `<div class="tlmi-kpis">
|
|
115658
|
+
<div class="tlmi-kpi"><span>Arquivo</span><strong style="font-size:13px">${esc9(s.fileName)}</strong></div>
|
|
115659
|
+
<div class="tlmi-kpi"><span>Linhas para importar</span><strong>${fmtNum(s.rows.length)}</strong></div>
|
|
115660
|
+
<div class="tlmi-kpi"><span>Em branco (ignoradas)</span><strong>${fmtNum(s.skippedEmpty)}</strong></div>
|
|
115661
|
+
<div class="tlmi-kpi"><span>Com erro</span><strong style="color:${s.localErrors.length ? "#dc2626" : "#16a34a"}">${fmtNum(s.localErrors.length)}</strong></div>
|
|
115662
|
+
</div>
|
|
115663
|
+
${s.localErrors.length ? `<div class="tlmi-banner err">Corrija as linhas abaixo e envie de novo \u2014 nada foi importado.</div>${issuesTable(s.localErrors)}` : ""}
|
|
115664
|
+
${!s.localErrors.length && !s.rows.length ? '<div class="tlmi-banner warn">Nenhuma linha com valor preenchido.</div>' : ""}` : "";
|
|
115665
|
+
return `
|
|
115666
|
+
<div class="tlmi-card"><h3>Planilha preenchida</h3>
|
|
115667
|
+
<label class="tlmi-drop" data-role="drop">
|
|
115668
|
+
<input type="file" accept=".xlsx,.xls,.csv" data-field="file" hidden />
|
|
115669
|
+
\u{1F4C4} Clique ou arraste a planilha aqui (.xlsx ou .csv)
|
|
115670
|
+
</label>
|
|
115671
|
+
</div>
|
|
115672
|
+
${summary}`;
|
|
115673
|
+
}
|
|
115674
|
+
function step3() {
|
|
115675
|
+
const v = s.validation;
|
|
115676
|
+
if (!v) return `${apiErrorBanner()}<div class="tlmi-card"><p class="tlmi-muted">${s.busy ? "Validando\u2026" : "Aguardando valida\xE7\xE3o."}</p></div>`;
|
|
115677
|
+
if (v.valid === false) {
|
|
115678
|
+
return `<div class="tlmi-banner err">A planilha foi recusada: ${fmtNum(v.invalidCount)} linha(s) inv\xE1lida(s). Nada foi importado.</div>
|
|
115679
|
+
${issuesTable(v.errors)}`;
|
|
115680
|
+
}
|
|
115681
|
+
const p = v.preview || {};
|
|
115682
|
+
const real = Number(p.existingRealReadings || 0);
|
|
115683
|
+
const period = typeof p.period === "string" ? p.period : p.period ? `${p.period.start || ""} \u2192 ${p.period.end || ""}` : "\u2014";
|
|
115684
|
+
const devices = Array.isArray(p.devices) ? p.devices.length : p.devices;
|
|
115685
|
+
return `
|
|
115686
|
+
<div class="tlmi-banner ok">Planilha v\xE1lida. Confira o resumo antes de importar.</div>
|
|
115687
|
+
<div class="tlmi-kpis">
|
|
115688
|
+
<div class="tlmi-kpi"><span>Horas a gravar</span><strong>${fmtNum(p.targetSlots)}</strong></div>
|
|
115689
|
+
<div class="tlmi-kpi"><span>Dispositivos</span><strong>${fmtNum(devices)}</strong></div>
|
|
115690
|
+
<div class="tlmi-kpi"><span>Total (${txt.unit})</span><strong>${fmtNum(p.totalValue, 2)}</strong></div>
|
|
115691
|
+
<div class="tlmi-kpi"><span>Leituras substitu\xEDdas</span><strong>${fmtNum(p.existingReadingsInTarget)}</strong></div>
|
|
115692
|
+
</div>
|
|
115693
|
+
<p class="tlmi-muted">Per\xEDodo: ${esc9(period)}</p>
|
|
115694
|
+
${real > 0 ? `<div class="tlmi-banner warn"><strong>${fmtNum(real)} leitura(s) reais do medidor</strong> ser\xE3o substitu\xEDdas pelos valores da planilha.
|
|
115695
|
+
<label class="tlmi-check" style="margin-top:6px"><input type="checkbox" data-field="confirmReal" ${s.confirmReal ? "checked" : ""} />
|
|
115696
|
+
Confirmo a substitui\xE7\xE3o das leituras reais.</label></div>` : ""}
|
|
115697
|
+
${apiErrorBanner()}`;
|
|
115698
|
+
}
|
|
115699
|
+
function step4() {
|
|
115700
|
+
const j = s.job;
|
|
115701
|
+
if (!j) return `${apiErrorBanner()}<div class="tlmi-card"><p class="tlmi-muted">Iniciando importa\xE7\xE3o\u2026</p></div>`;
|
|
115702
|
+
const pct = Math.max(0, Math.min(100, Number(j.progress ?? (j.status === "completed" ? 100 : 0))));
|
|
115703
|
+
const statusText = JOB_STATUS_TEXT[j.status] || j.status;
|
|
115704
|
+
const terminal = TERMINAL_JOB_STATUSES.includes(j.status);
|
|
115705
|
+
let banner = "";
|
|
115706
|
+
if (j.status === "completed") {
|
|
115707
|
+
banner = j.refreshStatus === "failed" ? '<div class="tlmi-banner warn">Dados importados, mas a atualiza\xE7\xE3o dos totais falhou. Avise o suporte MyIO.</div>' : '<div class="tlmi-banner ok">Importa\xE7\xE3o conclu\xEDda. Os totais podem levar alguns minutos para refletir.</div>';
|
|
115708
|
+
} else if (j.status === "failed") {
|
|
115709
|
+
banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${esc9(j.error)}` : "."}</div>`;
|
|
115710
|
+
} else if (j.status === "cancelled") {
|
|
115711
|
+
banner = '<div class="tlmi-banner warn">Importa\xE7\xE3o cancelada. As leituras anteriores foram mantidas.</div>';
|
|
115712
|
+
}
|
|
115713
|
+
return `
|
|
115714
|
+
<div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${esc9(statusText)}</span></h3>
|
|
115715
|
+
<div class="tlmi-progress" role="progressbar" aria-valuenow="${pct}" aria-valuemin="0" aria-valuemax="100"><i style="width:${pct}%"></i></div>
|
|
115716
|
+
<div class="tlmi-kpis" style="margin-top:12px">
|
|
115717
|
+
<div class="tlmi-kpi"><span>Progresso</span><strong>${fmtNum(pct)}%</strong></div>
|
|
115718
|
+
<div class="tlmi-kpi"><span>Leituras removidas</span><strong>${fmtNum(j.deleted)}</strong></div>
|
|
115719
|
+
<div class="tlmi-kpi"><span>Leituras gravadas</span><strong>${fmtNum(j.inserted)}</strong></div>
|
|
115720
|
+
</div>
|
|
115721
|
+
${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${esc9(j.phase)}</p>` : ""}
|
|
115722
|
+
${!terminal ? `<div style="margin-top:12px"><button class="tlmi-btn" type="button" data-action="cancel" ${s.busy ? "disabled" : ""}>Cancelar importa\xE7\xE3o</button>
|
|
115723
|
+
<span class="tlmi-muted" style="margin-left:8px">Voc\xEA pode fechar esta janela; a importa\xE7\xE3o continua.</span></div>` : ""}
|
|
115724
|
+
</div>
|
|
115725
|
+
${banner}
|
|
115726
|
+
${apiErrorBanner()}`;
|
|
115727
|
+
}
|
|
115728
|
+
function render3() {
|
|
115729
|
+
if (closed) return;
|
|
115730
|
+
const body = s.step === 1 ? step1() : s.step === 2 ? step2() : s.step === 3 ? step3() : step4();
|
|
115731
|
+
root.innerHTML = stepper() + body;
|
|
115732
|
+
syncFooter();
|
|
115733
|
+
}
|
|
115734
|
+
function syncFooter() {
|
|
115735
|
+
const v = s.validation;
|
|
115736
|
+
const terminal = s.job ? TERMINAL_JOB_STATUSES.includes(s.job.status) : false;
|
|
115737
|
+
modal.setButton("back", { hidden: s.step === 1 || s.step === 4, disabled: s.busy });
|
|
115738
|
+
if (s.step === 1) modal.setButton("next", { label: "Avan\xE7ar", disabled: false, hidden: false });
|
|
115739
|
+
if (s.step === 2)
|
|
115740
|
+
modal.setButton("next", { label: "Validar planilha", disabled: s.busy || !s.rows.length || !!s.localErrors.length || !!s.parseError, hidden: false });
|
|
115741
|
+
if (s.step === 3) {
|
|
115742
|
+
const real = v && v.valid ? Number(v.preview?.existingRealReadings || 0) : 0;
|
|
115743
|
+
modal.setButton("next", {
|
|
115744
|
+
label: s.busy ? "Iniciando\u2026" : "Importar",
|
|
115745
|
+
hidden: !v || !v.valid,
|
|
115746
|
+
disabled: s.busy || real > 0 && !s.confirmReal
|
|
115747
|
+
});
|
|
115748
|
+
}
|
|
115749
|
+
if (s.step === 4) modal.setButton("next", { label: "Concluir", hidden: !terminal, disabled: false });
|
|
115750
|
+
}
|
|
115751
|
+
function goBack() {
|
|
115752
|
+
if (s.busy || s.step === 1 || s.step === 4) return;
|
|
115753
|
+
s.apiError = "";
|
|
115754
|
+
if (s.step === 3) s.validation = null;
|
|
115755
|
+
s.step = s.step - 1;
|
|
115756
|
+
render3();
|
|
115757
|
+
}
|
|
115758
|
+
async function goNext() {
|
|
115759
|
+
if (s.busy) return;
|
|
115760
|
+
if (s.step === 1) {
|
|
115761
|
+
s.step = 2;
|
|
115762
|
+
render3();
|
|
115763
|
+
} else if (s.step === 2) {
|
|
115764
|
+
await validate2();
|
|
115765
|
+
} else if (s.step === 3) {
|
|
115766
|
+
await start();
|
|
115767
|
+
} else if (s.step === 4) {
|
|
115768
|
+
if (s.job?.status === "completed") params.onCompleted?.(s.job);
|
|
115769
|
+
modal.close();
|
|
115770
|
+
}
|
|
115771
|
+
}
|
|
115772
|
+
function downloadTemplate() {
|
|
115773
|
+
const { csv, rows } = buildTemplateCsv(domain, importable, s.period.start, s.period.end, now());
|
|
115774
|
+
if (!rows) return;
|
|
115775
|
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8" });
|
|
115776
|
+
const a = document.createElement("a");
|
|
115777
|
+
a.href = URL.createObjectURL(blob);
|
|
115778
|
+
const who = (params.customerName || "shopping").replace(/[^\w-]+/g, "_");
|
|
115779
|
+
a.download = `importacao-${domain === "energy" ? "energia" : "agua"}-${who}-${s.period.start}_${s.period.end}.csv`;
|
|
115780
|
+
document.body.appendChild(a);
|
|
115781
|
+
a.click();
|
|
115782
|
+
a.remove();
|
|
115783
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 1e3);
|
|
115784
|
+
}
|
|
115785
|
+
async function loadFile(file) {
|
|
115786
|
+
if (!file) return;
|
|
115787
|
+
s.fileName = file.name;
|
|
115788
|
+
s.parseError = "";
|
|
115789
|
+
s.rows = [];
|
|
115790
|
+
s.localErrors = [];
|
|
115791
|
+
s.skippedEmpty = 0;
|
|
115792
|
+
s.validation = null;
|
|
115793
|
+
try {
|
|
115794
|
+
const table = await parseSheetFile(file);
|
|
115795
|
+
const r = rowsFromTable(domain, table);
|
|
115796
|
+
s.rows = r.rows;
|
|
115797
|
+
s.localErrors = r.errors;
|
|
115798
|
+
s.skippedEmpty = r.skippedEmpty;
|
|
115799
|
+
} catch (err) {
|
|
115800
|
+
s.parseError = err?.message || "N\xE3o foi poss\xEDvel ler a planilha.";
|
|
115801
|
+
}
|
|
115802
|
+
render3();
|
|
115803
|
+
}
|
|
115804
|
+
async function validate2() {
|
|
115805
|
+
s.busy = true;
|
|
115806
|
+
s.apiError = "";
|
|
115807
|
+
s.validation = null;
|
|
115808
|
+
s.step = 3;
|
|
115809
|
+
render3();
|
|
115810
|
+
try {
|
|
115811
|
+
s.validation = await api.validate({ customerId: params.customerId, readingType: domain, rows: s.rows, sourceRef: s.fileName });
|
|
115812
|
+
} catch (err) {
|
|
115813
|
+
setError(err);
|
|
115814
|
+
} finally {
|
|
115815
|
+
s.busy = false;
|
|
115816
|
+
render3();
|
|
115817
|
+
}
|
|
115818
|
+
}
|
|
115819
|
+
async function start() {
|
|
115820
|
+
const v = s.validation;
|
|
115821
|
+
if (!v || !v.valid) return;
|
|
115822
|
+
s.busy = true;
|
|
115823
|
+
s.apiError = "";
|
|
115824
|
+
render3();
|
|
115825
|
+
try {
|
|
115826
|
+
const started = await api.startJob({ validationId: v.validationId, confirmReplaceReal: s.confirmReal || void 0 });
|
|
115827
|
+
s.job = { jobId: started.jobId, status: started.status };
|
|
115828
|
+
s.step = 4;
|
|
115829
|
+
s.busy = false;
|
|
115830
|
+
render3();
|
|
115831
|
+
schedulePoll(0);
|
|
115832
|
+
} catch (err) {
|
|
115833
|
+
setError(err);
|
|
115834
|
+
s.busy = false;
|
|
115835
|
+
render3();
|
|
115836
|
+
}
|
|
115837
|
+
}
|
|
115838
|
+
function schedulePoll(delay = params.pollMs ?? 5e3) {
|
|
115839
|
+
if (closed || !s.job?.jobId) return;
|
|
115840
|
+
pollTimer = setTimeout(async () => {
|
|
115841
|
+
if (closed || !s.job?.jobId) return;
|
|
115842
|
+
try {
|
|
115843
|
+
s.job = { ...await api.getJob(s.job.jobId), jobId: s.job.jobId };
|
|
115844
|
+
s.apiError = "";
|
|
115845
|
+
} catch (err) {
|
|
115846
|
+
setError(err);
|
|
115847
|
+
}
|
|
115848
|
+
render3();
|
|
115849
|
+
if (s.job && !TERMINAL_JOB_STATUSES.includes(s.job.status)) schedulePoll();
|
|
115850
|
+
}, delay);
|
|
115851
|
+
}
|
|
115852
|
+
async function cancelJob() {
|
|
115853
|
+
if (!s.job?.jobId || s.busy) return;
|
|
115854
|
+
s.busy = true;
|
|
115855
|
+
render3();
|
|
115856
|
+
try {
|
|
115857
|
+
const j = await api.cancelJob(s.job.jobId);
|
|
115858
|
+
if (j?.status) s.job = { ...s.job, ...j };
|
|
115859
|
+
} catch (err) {
|
|
115860
|
+
setError(err);
|
|
115861
|
+
} finally {
|
|
115862
|
+
s.busy = false;
|
|
115863
|
+
render3();
|
|
115864
|
+
}
|
|
115865
|
+
}
|
|
115866
|
+
root.addEventListener("click", (e) => {
|
|
115867
|
+
const el2 = e.target.closest("[data-action]");
|
|
115868
|
+
if (!el2) return;
|
|
115869
|
+
if (el2.dataset.action === "template") downloadTemplate();
|
|
115870
|
+
if (el2.dataset.action === "cancel") void cancelJob();
|
|
115871
|
+
});
|
|
115872
|
+
root.addEventListener("change", (e) => {
|
|
115873
|
+
const t = e.target;
|
|
115874
|
+
if (t.dataset.field === "start") s.period.start = t.value;
|
|
115875
|
+
if (t.dataset.field === "end") s.period.end = t.value;
|
|
115876
|
+
if (t.dataset.field === "file") void loadFile(t.files?.[0]);
|
|
115877
|
+
if (t.dataset.field === "confirmReal") {
|
|
115878
|
+
s.confirmReal = t.checked;
|
|
115879
|
+
syncFooter();
|
|
115880
|
+
}
|
|
115881
|
+
});
|
|
115882
|
+
root.addEventListener("dragover", (e) => {
|
|
115883
|
+
const drop = e.target.closest('[data-role="drop"]');
|
|
115884
|
+
if (!drop) return;
|
|
115885
|
+
e.preventDefault();
|
|
115886
|
+
drop.dataset.over = "1";
|
|
115887
|
+
});
|
|
115888
|
+
root.addEventListener("dragleave", (e) => {
|
|
115889
|
+
const drop = e.target.closest('[data-role="drop"]');
|
|
115890
|
+
if (drop) drop.dataset.over = "";
|
|
115891
|
+
});
|
|
115892
|
+
root.addEventListener("drop", (e) => {
|
|
115893
|
+
const drop = e.target.closest('[data-role="drop"]');
|
|
115894
|
+
if (!drop) return;
|
|
115895
|
+
e.preventDefault();
|
|
115896
|
+
void loadFile(e.dataTransfer?.files?.[0]);
|
|
115897
|
+
});
|
|
115898
|
+
render3();
|
|
115899
|
+
return modal;
|
|
115900
|
+
}
|
|
115901
|
+
|
|
115902
|
+
// src/components/premium-modals/manual-device/createManualDevice.ts
|
|
115903
|
+
var MANUAL_DEVICE_PROFILES = {
|
|
115904
|
+
energy: "3F_MEDIDOR_MANUAL",
|
|
115905
|
+
water: "HIDROMETRO_MANUAL"
|
|
115906
|
+
};
|
|
115907
|
+
var NAME_PREFIX = {
|
|
115908
|
+
energy: "3F ",
|
|
115909
|
+
water: "Hidr. "
|
|
115910
|
+
};
|
|
115911
|
+
var MANUAL_ASSET_SUFFIX = "_DEVICES_MANUAIS";
|
|
115912
|
+
var ManualDeviceError = class extends Error {
|
|
115913
|
+
constructor(message, detail) {
|
|
115914
|
+
super(message);
|
|
115915
|
+
this.detail = detail;
|
|
115916
|
+
this.name = "ManualDeviceError";
|
|
115917
|
+
}
|
|
115918
|
+
};
|
|
115919
|
+
function manualDeviceName(domain, sigla, seq) {
|
|
115920
|
+
return `${NAME_PREFIX[domain]}${sigla}_LOJA_${String(seq).padStart(3, "0")}_MANUAL`;
|
|
115921
|
+
}
|
|
115922
|
+
function siglaFromManualAsset(assetName) {
|
|
115923
|
+
const upper = String(assetName || "").trim().toUpperCase();
|
|
115924
|
+
if (!upper.endsWith(MANUAL_ASSET_SUFFIX)) return null;
|
|
115925
|
+
const sigla = upper.slice(0, -MANUAL_ASSET_SUFFIX.length).replace(/^ASSET_/, "");
|
|
115926
|
+
return /^[A-Z0-9_]+$/.test(sigla) ? sigla : null;
|
|
115927
|
+
}
|
|
115928
|
+
function nextManualSeq(domain, sigla, existingNames) {
|
|
115929
|
+
const esc10 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
115930
|
+
const re = new RegExp(`^${esc10(NAME_PREFIX[domain])}${esc10(sigla)}_LOJA_(\\d+)_MANUAL$`, "i");
|
|
115931
|
+
const max = existingNames.reduce((acc, n) => {
|
|
115932
|
+
const m = re.exec(String(n || "").trim());
|
|
115933
|
+
return m ? Math.max(acc, Number(m[1])) : acc;
|
|
115934
|
+
}, 0);
|
|
115935
|
+
return max + 1;
|
|
115936
|
+
}
|
|
115937
|
+
async function createManualDevice(params) {
|
|
115938
|
+
const domain = params.domain;
|
|
115939
|
+
const profile = MANUAL_DEVICE_PROFILES[domain];
|
|
115940
|
+
if (!profile) throw new ManualDeviceError(`Dom\xEDnio inv\xE1lido: ${domain}`);
|
|
115941
|
+
const label = String(params.label || "").trim();
|
|
115942
|
+
const identifier = String(params.identifier || "").trim();
|
|
115943
|
+
if (!label) throw new ManualDeviceError("Informe a etiqueta.");
|
|
115944
|
+
if (!identifier) throw new ManualDeviceError("Informe o identificador.");
|
|
115945
|
+
if (!params.customerId) throw new ManualDeviceError("Cliente n\xE3o identificado.");
|
|
115946
|
+
const base = params.baseUrl ?? "";
|
|
115947
|
+
const doFetch = params.fetchImpl ?? fetch.bind(window);
|
|
115948
|
+
const tokenValue = typeof params.token === "function" ? await params.token() : params.token;
|
|
115949
|
+
const headers = { "X-Authorization": `Bearer ${tokenValue}`, "Content-Type": "application/json" };
|
|
115950
|
+
const api = async (method, path, body, okStatuses = []) => {
|
|
115951
|
+
const res = await doFetch(`${base}${path}`, {
|
|
115952
|
+
method,
|
|
115953
|
+
headers,
|
|
115954
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
115955
|
+
});
|
|
115956
|
+
if (!res.ok && !okStatuses.includes(res.status)) {
|
|
115957
|
+
const text3 = await res.text().catch(() => "");
|
|
115958
|
+
throw new ManualDeviceError(`Falha na API (${res.status}).`, `${method} ${path} \u2192 ${res.status} ${text3.slice(0, 200)}`);
|
|
115959
|
+
}
|
|
115960
|
+
const text2 = await res.text().catch(() => "");
|
|
115961
|
+
return text2 ? JSON.parse(text2) : null;
|
|
115962
|
+
};
|
|
115963
|
+
const cid = encodeURIComponent(params.customerId);
|
|
115964
|
+
const assets = await api("GET", `/api/customer/${cid}/assets?pageSize=100&page=0&textSearch=MANUAIS`);
|
|
115965
|
+
const asset = (assets?.data || []).find(
|
|
115966
|
+
(a) => String(a?.name || "").toUpperCase().endsWith(MANUAL_ASSET_SUFFIX)
|
|
115967
|
+
);
|
|
115968
|
+
if (!asset) {
|
|
115969
|
+
throw new ManualDeviceError(
|
|
115970
|
+
"Local de dispositivos manuais n\xE3o configurado para este shopping.",
|
|
115971
|
+
`nenhum asset do customer termina em ${MANUAL_ASSET_SUFFIX}`
|
|
115972
|
+
);
|
|
115973
|
+
}
|
|
115974
|
+
const sigla = siglaFromManualAsset(asset.name);
|
|
115975
|
+
if (!sigla) {
|
|
115976
|
+
throw new ManualDeviceError(
|
|
115977
|
+
"Local de dispositivos manuais n\xE3o configurado para este shopping.",
|
|
115978
|
+
`n\xE3o foi poss\xEDvel extrair a sigla de "${asset.name}"`
|
|
115979
|
+
);
|
|
115980
|
+
}
|
|
115981
|
+
const existing = await api(
|
|
115982
|
+
"GET",
|
|
115983
|
+
`/api/customer/${cid}/devices?pageSize=1000&page=0&textSearch=${encodeURIComponent(`${sigla}_LOJA_`)}`
|
|
115984
|
+
);
|
|
115985
|
+
const existingNames = (existing?.data || []).map((d) => String(d?.name || ""));
|
|
115986
|
+
let seq = nextManualSeq(domain, sigla, existingNames);
|
|
115987
|
+
let deviceProfileId;
|
|
115988
|
+
try {
|
|
115989
|
+
const profiles = await api("GET", `/api/deviceProfileInfos?pageSize=50&page=0&textSearch=${encodeURIComponent(profile)}`);
|
|
115990
|
+
const p = (profiles?.data || []).find((x) => x?.name === profile);
|
|
115991
|
+
if (p?.id?.id) deviceProfileId = { id: p.id.id, entityType: "DEVICE_PROFILE" };
|
|
115992
|
+
} catch {
|
|
115993
|
+
}
|
|
115994
|
+
let name = manualDeviceName(domain, sigla, seq);
|
|
115995
|
+
let created = null;
|
|
115996
|
+
for (let attempt = 0; ; attempt++) {
|
|
115997
|
+
try {
|
|
115998
|
+
created = await api("POST", "/api/device", {
|
|
115999
|
+
name,
|
|
116000
|
+
label,
|
|
116001
|
+
...deviceProfileId ? { deviceProfileId } : { type: profile },
|
|
116002
|
+
customerId: { id: params.customerId, entityType: "CUSTOMER" }
|
|
116003
|
+
});
|
|
116004
|
+
break;
|
|
116005
|
+
} catch (err) {
|
|
116006
|
+
const dup = /already exists|já existe/i.test(err?.detail || "");
|
|
116007
|
+
if (!dup || attempt >= 4) throw err;
|
|
116008
|
+
seq += 1;
|
|
116009
|
+
name = manualDeviceName(domain, sigla, seq);
|
|
116010
|
+
}
|
|
116011
|
+
}
|
|
116012
|
+
const deviceId = created?.id?.id;
|
|
116013
|
+
if (!deviceId) throw new ManualDeviceError("O dispositivo n\xE3o foi criado.", "POST /api/device sem id na resposta");
|
|
116014
|
+
try {
|
|
116015
|
+
if (created?.customerId?.id !== params.customerId) {
|
|
116016
|
+
try {
|
|
116017
|
+
await api("POST", `/api/owner/CUSTOMER/${cid}/DEVICE/${deviceId}`);
|
|
116018
|
+
} catch {
|
|
116019
|
+
await api("POST", `/api/customer/${cid}/device/${deviceId}`);
|
|
116020
|
+
}
|
|
116021
|
+
}
|
|
116022
|
+
await api("POST", "/api/relation", {
|
|
116023
|
+
from: { id: asset.id.id, entityType: "ASSET" },
|
|
116024
|
+
to: { id: deviceId, entityType: "DEVICE" },
|
|
116025
|
+
type: "Contains",
|
|
116026
|
+
typeGroup: "COMMON"
|
|
116027
|
+
});
|
|
116028
|
+
await api("POST", `/api/plugins/telemetry/DEVICE/${deviceId}/attributes/SERVER_SCOPE`, {
|
|
116029
|
+
deviceProfile: profile,
|
|
116030
|
+
identifier
|
|
116031
|
+
});
|
|
116032
|
+
} catch (err) {
|
|
116033
|
+
await api("DELETE", `/api/device/${deviceId}`).catch(() => void 0);
|
|
116034
|
+
throw err;
|
|
116035
|
+
}
|
|
116036
|
+
return { deviceId, name, label, identifier, deviceProfile: profile, assetId: asset.id.id, assetName: asset.name };
|
|
116037
|
+
}
|
|
116038
|
+
|
|
116039
|
+
// src/components/premium-modals/manual-device/openManualDeviceModal.ts
|
|
116040
|
+
var DOMAIN_TEXT2 = {
|
|
116041
|
+
energy: { title: "Novo medidor de energia manual", icon: "\u26A1", noun: "Medidor de energia" },
|
|
116042
|
+
water: { title: "Novo hidr\xF4metro manual", icon: "\u{1F4A7}", noun: "Hidr\xF4metro" }
|
|
116043
|
+
};
|
|
116044
|
+
var STYLE_ID15 = "myio-manualdev-styles";
|
|
116045
|
+
function escapeHtml14(v) {
|
|
116046
|
+
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
116047
|
+
}
|
|
116048
|
+
function injectStyles15() {
|
|
116049
|
+
if (document.getElementById(STYLE_ID15)) return;
|
|
116050
|
+
const style = document.createElement("style");
|
|
116051
|
+
style.id = STYLE_ID15;
|
|
116052
|
+
style.textContent = `
|
|
116053
|
+
.myio-manualdev { display: flex; flex-direction: column; gap: 16px; }
|
|
116054
|
+
.myio-manualdev__hint { margin: 0; font-size: 13px; color: #6b7280; line-height: 1.5; }
|
|
116055
|
+
.myio-manualdev__field { display: flex; flex-direction: column; gap: 6px; }
|
|
116056
|
+
.myio-manualdev__label { font-size: 14px; font-weight: 500; color: #333; }
|
|
116057
|
+
.myio-manualdev__input {
|
|
116058
|
+
font-family: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid #ddd;
|
|
116059
|
+
border-radius: 6px; outline: none; color: #111827; background: #fff; box-sizing: border-box; width: 100%;
|
|
116060
|
+
}
|
|
116061
|
+
.myio-manualdev__input:focus { border-color: var(--myio-brand-700, #3e1a7d); box-shadow: 0 0 0 3px rgba(62, 26, 125, 0.12); }
|
|
116062
|
+
.myio-manualdev__input[aria-invalid="true"] { border-color: #dc3545; }
|
|
116063
|
+
.myio-manualdev__input:disabled { background: #f8f9fa; color: #6c757d; }
|
|
116064
|
+
.myio-manualdev__type {
|
|
116065
|
+
display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
|
|
116066
|
+
font-size: 12px; font-weight: 600; color: #3e1a7d; background: #f1ecfa;
|
|
116067
|
+
padding: 4px 10px; border-radius: 999px;
|
|
116068
|
+
}
|
|
116069
|
+
.myio-manualdev__error {
|
|
116070
|
+
margin: 0; font-size: 13px; color: #991b1b; background: #fee2e2; border-radius: 6px; padding: 8px 10px;
|
|
116071
|
+
}
|
|
116072
|
+
.myio-manualdev__detail { display: block; margin-top: 4px; font-size: 11.5px; color: #7f1d1d; opacity: 0.85; word-break: break-word; }
|
|
116073
|
+
.myio-manualdev__ok { text-align: center; padding: 4px 0; }
|
|
116074
|
+
.myio-manualdev__ok-icon { font-size: 34px; line-height: 1; }
|
|
116075
|
+
.myio-manualdev__ok-title { margin: 8px 0 4px; font-size: 16px; font-weight: 700; color: #065f46; }
|
|
116076
|
+
.myio-manualdev__ok-text { margin: 0; font-size: 13px; color: #4b5563; }
|
|
116077
|
+
.myio-manualdev__tech {
|
|
116078
|
+
margin-top: 12px; text-align: left; font-size: 11.5px; color: #6b7280; background: #f9fafb;
|
|
116079
|
+
border: 1px dashed #e5e7eb; border-radius: 6px; padding: 8px 10px; line-height: 1.6;
|
|
116080
|
+
}
|
|
116081
|
+
.myio-manualdev__tech code { font-size: 11.5px; color: #374151; }
|
|
116082
|
+
`;
|
|
116083
|
+
document.head.appendChild(style);
|
|
116084
|
+
}
|
|
116085
|
+
function formHtml(domain, values, error, detail) {
|
|
116086
|
+
const t = DOMAIN_TEXT2[domain];
|
|
116087
|
+
return `
|
|
116088
|
+
<form class="myio-manualdev" novalidate>
|
|
116089
|
+
<p class="myio-manualdev__hint">Cadastre um ponto de leitura manual. Ele aparece nesta lista e n\xE3o entra nos totais nem nos relat\xF3rios.</p>
|
|
116090
|
+
<span class="myio-manualdev__type">${t.icon} ${escapeHtml14(t.noun)} manual</span>
|
|
116091
|
+
<label class="myio-manualdev__field">
|
|
116092
|
+
<span class="myio-manualdev__label">Etiqueta</span>
|
|
116093
|
+
<input class="myio-manualdev__input" name="label" maxlength="80" autocomplete="off"
|
|
116094
|
+
placeholder="Ex.: Burger King" value="${escapeHtml14(values.label)}" />
|
|
116095
|
+
</label>
|
|
116096
|
+
<label class="myio-manualdev__field">
|
|
116097
|
+
<span class="myio-manualdev__label">Identificador</span>
|
|
116098
|
+
<input class="myio-manualdev__input" name="identifier" maxlength="40" autocomplete="off"
|
|
116099
|
+
placeholder="Ex.: STB01010" value="${escapeHtml14(values.identifier)}" />
|
|
116100
|
+
</label>
|
|
116101
|
+
${error ? `<p class="myio-manualdev__error" role="alert">${escapeHtml14(error)}${detail ? `<small class="myio-manualdev__detail">${escapeHtml14(detail)}</small>` : ""}</p>` : ""}
|
|
116102
|
+
<button type="submit" hidden></button>
|
|
116103
|
+
</form>`;
|
|
116104
|
+
}
|
|
116105
|
+
function successHtml(domain, r, tech) {
|
|
116106
|
+
return `
|
|
116107
|
+
<div class="myio-manualdev__ok">
|
|
116108
|
+
<div class="myio-manualdev__ok-icon">\u2705</div>
|
|
116109
|
+
<p class="myio-manualdev__ok-title">${escapeHtml14(DOMAIN_TEXT2[domain].noun)} criado</p>
|
|
116110
|
+
<p class="myio-manualdev__ok-text"><strong>${escapeHtml14(r.label)}</strong> \xB7 ${escapeHtml14(r.identifier)}</p>
|
|
116111
|
+
${tech ? `<div class="myio-manualdev__tech">
|
|
116112
|
+
device <code>${escapeHtml14(r.name)}</code><br/>
|
|
116113
|
+
profile <code>${escapeHtml14(r.deviceProfile)}</code><br/>
|
|
116114
|
+
asset <code>${escapeHtml14(r.assetName)}</code><br/>
|
|
116115
|
+
id <code>${escapeHtml14(r.deviceId)}</code>
|
|
116116
|
+
</div>` : ""}
|
|
116117
|
+
</div>`;
|
|
116118
|
+
}
|
|
116119
|
+
function openManualDeviceModal(params) {
|
|
116120
|
+
const domain = params.domain;
|
|
116121
|
+
if (!MANUAL_DEVICE_PROFILES[domain]) throw new Error(`[openManualDeviceModal] dom\xEDnio inv\xE1lido: ${domain}`);
|
|
116122
|
+
injectStyles15();
|
|
116123
|
+
const values = { label: "", identifier: "" };
|
|
116124
|
+
let busy = false;
|
|
116125
|
+
let created = null;
|
|
116126
|
+
const modal = openStandardModal({
|
|
116127
|
+
title: DOMAIN_TEXT2[domain].title,
|
|
116128
|
+
icon: DOMAIN_TEXT2[domain].icon,
|
|
116129
|
+
bodyHtml: formHtml(domain, values),
|
|
116130
|
+
width: 460,
|
|
116131
|
+
container: params.container,
|
|
116132
|
+
buttons: [
|
|
116133
|
+
{ label: "Cancelar", value: "cancel", variant: "secondary" },
|
|
116134
|
+
{ label: "Criar", value: "create", variant: "primary", closeOnClick: false }
|
|
116135
|
+
],
|
|
116136
|
+
onButton: (v) => {
|
|
116137
|
+
if (v !== "create") return;
|
|
116138
|
+
if (created) {
|
|
116139
|
+
const r = created;
|
|
116140
|
+
modal.close();
|
|
116141
|
+
params.onCreated?.(r);
|
|
116142
|
+
} else {
|
|
116143
|
+
void submit();
|
|
116144
|
+
}
|
|
116145
|
+
}
|
|
116146
|
+
});
|
|
116147
|
+
const bindForm = (focus = true) => {
|
|
116148
|
+
const form = modal.getBodyEl().querySelector("form");
|
|
116149
|
+
form?.addEventListener("submit", (e) => {
|
|
116150
|
+
e.preventDefault();
|
|
116151
|
+
void submit();
|
|
116152
|
+
});
|
|
116153
|
+
if (focus) form?.querySelector('input[name="label"]')?.focus();
|
|
116154
|
+
};
|
|
116155
|
+
bindForm();
|
|
116156
|
+
async function submit() {
|
|
116157
|
+
if (busy || created) return;
|
|
116158
|
+
const body = modal.getBodyEl();
|
|
116159
|
+
values.label = (body.querySelector('input[name="label"]')?.value || "").trim();
|
|
116160
|
+
values.identifier = (body.querySelector('input[name="identifier"]')?.value || "").trim();
|
|
116161
|
+
const missing = !values.label ? "label" : !values.identifier ? "identifier" : null;
|
|
116162
|
+
if (missing) {
|
|
116163
|
+
modal.setBodyHtml(formHtml(domain, values, missing === "label" ? "Informe a etiqueta." : "Informe o identificador."));
|
|
116164
|
+
bindForm(false);
|
|
116165
|
+
const input = body.querySelector(`input[name="${missing}"]`);
|
|
116166
|
+
input?.setAttribute("aria-invalid", "true");
|
|
116167
|
+
input?.focus();
|
|
116168
|
+
return;
|
|
116169
|
+
}
|
|
116170
|
+
busy = true;
|
|
116171
|
+
modal.setButton("create", { disabled: true, label: "Criando\u2026" });
|
|
116172
|
+
modal.setButton("cancel", { disabled: true });
|
|
116173
|
+
body.querySelectorAll("input").forEach((i) => i.disabled = true);
|
|
116174
|
+
try {
|
|
116175
|
+
created = await createManualDevice({ ...params, label: values.label, identifier: values.identifier });
|
|
116176
|
+
modal.setBodyHtml(successHtml(domain, created, !!params.showTechnicalDetails));
|
|
116177
|
+
modal.setButton("cancel", { hidden: true });
|
|
116178
|
+
modal.setButton("create", { disabled: false, label: "Concluir" });
|
|
116179
|
+
} catch (err) {
|
|
116180
|
+
const msg = err instanceof ManualDeviceError ? err.message : "N\xE3o foi poss\xEDvel criar o dispositivo.";
|
|
116181
|
+
const detail = params.showTechnicalDetails ? (err instanceof ManualDeviceError ? err.detail : String(err?.message || err)) || void 0 : void 0;
|
|
116182
|
+
modal.setBodyHtml(formHtml(domain, values, msg, detail));
|
|
116183
|
+
bindForm();
|
|
116184
|
+
modal.setButton("create", { disabled: false, label: "Criar" });
|
|
116185
|
+
modal.setButton("cancel", { disabled: false });
|
|
116186
|
+
} finally {
|
|
116187
|
+
busy = false;
|
|
116188
|
+
}
|
|
116189
|
+
}
|
|
116190
|
+
return modal;
|
|
116191
|
+
}
|
|
116192
|
+
|
|
114713
116193
|
// src/components/myio-gcdr-login/dom.ts
|
|
114714
116194
|
function h2(doc, tag, attrs = {}, ...children) {
|
|
114715
116195
|
const el2 = doc.createElement(tag);
|
|
@@ -116794,22 +118274,22 @@ function openMyioGcdrLoginModal(options) {
|
|
|
116794
118274
|
}
|
|
116795
118275
|
|
|
116796
118276
|
// src/components/img-gallery/ScrollableTabs.ts
|
|
116797
|
-
var
|
|
116798
|
-
var
|
|
116799
|
-
function
|
|
118277
|
+
var STYLE_ID16 = "myio-tabs-styles";
|
|
118278
|
+
var FONT_LINK_ID4 = "myio-dialog-font-nunito";
|
|
118279
|
+
function escapeHtml15(value) {
|
|
116800
118280
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
116801
118281
|
}
|
|
116802
|
-
function
|
|
116803
|
-
if (!document.getElementById(
|
|
118282
|
+
function injectStyles16() {
|
|
118283
|
+
if (!document.getElementById(FONT_LINK_ID4)) {
|
|
116804
118284
|
const link = document.createElement("link");
|
|
116805
|
-
link.id =
|
|
118285
|
+
link.id = FONT_LINK_ID4;
|
|
116806
118286
|
link.rel = "stylesheet";
|
|
116807
118287
|
link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
|
|
116808
118288
|
document.head.appendChild(link);
|
|
116809
118289
|
}
|
|
116810
|
-
if (document.getElementById(
|
|
118290
|
+
if (document.getElementById(STYLE_ID16)) return;
|
|
116811
118291
|
const style = document.createElement("style");
|
|
116812
|
-
style.id =
|
|
118292
|
+
style.id = STYLE_ID16;
|
|
116813
118293
|
style.textContent = `
|
|
116814
118294
|
.myio-tabs {
|
|
116815
118295
|
display: flex;
|
|
@@ -116884,7 +118364,7 @@ function createScrollableTabs(options) {
|
|
|
116884
118364
|
if (typeof document === "undefined") {
|
|
116885
118365
|
throw new Error("[createScrollableTabs] requires a browser environment");
|
|
116886
118366
|
}
|
|
116887
|
-
|
|
118367
|
+
injectStyles16();
|
|
116888
118368
|
const theme = options.theme ?? "light";
|
|
116889
118369
|
const accent = options.accent ?? "#7C3AED";
|
|
116890
118370
|
const showArrows = options.showArrows ?? "auto";
|
|
@@ -116932,7 +118412,7 @@ function createScrollableTabs(options) {
|
|
|
116932
118412
|
btn.setAttribute("role", "tab");
|
|
116933
118413
|
btn.dataset.key = t.key;
|
|
116934
118414
|
if (t.disabled) btn.disabled = true;
|
|
116935
|
-
btn.innerHTML = `${t.icon ? `<span aria-hidden="true">${t.icon}</span>` : ""}<span>${
|
|
118415
|
+
btn.innerHTML = `${t.icon ? `<span aria-hidden="true">${t.icon}</span>` : ""}<span>${escapeHtml15(t.label)}</span>`;
|
|
116936
118416
|
styleTab(btn, t.key === active);
|
|
116937
118417
|
btn.addEventListener("click", () => {
|
|
116938
118418
|
if (t.disabled || t.key === active) return;
|
|
@@ -117017,23 +118497,23 @@ function createScrollableTabs(options) {
|
|
|
117017
118497
|
}
|
|
117018
118498
|
|
|
117019
118499
|
// src/components/img-gallery/ImgGallery.ts
|
|
117020
|
-
var
|
|
117021
|
-
var
|
|
117022
|
-
function
|
|
118500
|
+
var STYLE_ID17 = "myio-gallery-styles";
|
|
118501
|
+
var FONT_LINK_ID5 = "myio-dialog-font-nunito";
|
|
118502
|
+
function escapeHtml16(value) {
|
|
117023
118503
|
return String(value == null ? "" : value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
117024
118504
|
}
|
|
117025
118505
|
var PRM = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
117026
|
-
function
|
|
117027
|
-
if (!document.getElementById(
|
|
118506
|
+
function injectStyles17() {
|
|
118507
|
+
if (!document.getElementById(FONT_LINK_ID5)) {
|
|
117028
118508
|
const link = document.createElement("link");
|
|
117029
|
-
link.id =
|
|
118509
|
+
link.id = FONT_LINK_ID5;
|
|
117030
118510
|
link.rel = "stylesheet";
|
|
117031
118511
|
link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
|
|
117032
118512
|
document.head.appendChild(link);
|
|
117033
118513
|
}
|
|
117034
|
-
if (document.getElementById(
|
|
118514
|
+
if (document.getElementById(STYLE_ID17)) return;
|
|
117035
118515
|
const style = document.createElement("style");
|
|
117036
|
-
style.id =
|
|
118516
|
+
style.id = STYLE_ID17;
|
|
117037
118517
|
style.textContent = `
|
|
117038
118518
|
.myio-gallery {
|
|
117039
118519
|
font-family: 'Nunito', system-ui, sans-serif;
|
|
@@ -117192,7 +118672,7 @@ function createImgGallery(options) {
|
|
|
117192
118672
|
if (typeof document === "undefined") {
|
|
117193
118673
|
throw new Error("[createImgGallery] requires a browser environment");
|
|
117194
118674
|
}
|
|
117195
|
-
|
|
118675
|
+
injectStyles17();
|
|
117196
118676
|
const locale = options.locale === "en-US" ? "en-US" : "pt-BR";
|
|
117197
118677
|
const theme = options.theme ?? "light";
|
|
117198
118678
|
const accent = options.accent ?? "#7C3AED";
|
|
@@ -117243,10 +118723,10 @@ function createImgGallery(options) {
|
|
|
117243
118723
|
root.appendChild(grid);
|
|
117244
118724
|
function detailsHtml(img) {
|
|
117245
118725
|
const lines = [];
|
|
117246
|
-
if (img.filename) lines.push(`<span title="${
|
|
117247
|
-
if (typeof img.sizeBytes === "number") lines.push(`<span>${
|
|
118726
|
+
if (img.filename) lines.push(`<span title="${escapeHtml16(img.filename)}">${escapeHtml16(img.filename)}</span>`);
|
|
118727
|
+
if (typeof img.sizeBytes === "number") lines.push(`<span>${escapeHtml16(formatSize(img.sizeBytes))}</span>`);
|
|
117248
118728
|
const dims = typeof img.width === "number" && typeof img.height === "number" ? `${img.width} \xD7 ${img.height}px` : "";
|
|
117249
|
-
lines.push(`<span data-dims>${
|
|
118729
|
+
lines.push(`<span data-dims>${escapeHtml16(dims)}</span>`);
|
|
117250
118730
|
return lines.join("");
|
|
117251
118731
|
}
|
|
117252
118732
|
function renderDescription(body, img, index) {
|
|
@@ -130831,7 +132311,7 @@ var MODAL_CSS2 = `
|
|
|
130831
132311
|
background: rgba(255, 255, 255, 0.2);
|
|
130832
132312
|
}
|
|
130833
132313
|
`;
|
|
130834
|
-
function
|
|
132314
|
+
function injectStyles18() {
|
|
130835
132315
|
if (document.getElementById(CSS_ID5)) return;
|
|
130836
132316
|
const style = document.createElement("style");
|
|
130837
132317
|
style.id = CSS_ID5;
|
|
@@ -130848,7 +132328,7 @@ var FilterModalComponent = class {
|
|
|
130848
132328
|
showDeviceGrid;
|
|
130849
132329
|
deviceSearchQuery = "";
|
|
130850
132330
|
constructor(options) {
|
|
130851
|
-
|
|
132331
|
+
injectStyles18();
|
|
130852
132332
|
this.options = options;
|
|
130853
132333
|
this.themeMode = options.themeMode || "light";
|
|
130854
132334
|
this.selectedCategories = new Set(
|
|
@@ -131752,7 +133232,7 @@ function createCustomerCardV1(params) {
|
|
|
131752
133232
|
}
|
|
131753
133233
|
|
|
131754
133234
|
// src/components/cards/customer-goals/v1.0.0/styles.ts
|
|
131755
|
-
var
|
|
133235
|
+
var STYLE_ID18 = "myio-customer-goals-card-css";
|
|
131756
133236
|
var CSS4 = `
|
|
131757
133237
|
.myio-cgc{
|
|
131758
133238
|
--cgc-surface:#ffffff;
|
|
@@ -131853,9 +133333,9 @@ var CSS4 = `
|
|
|
131853
133333
|
`;
|
|
131854
133334
|
function injectCustomerGoalsCardStyles() {
|
|
131855
133335
|
if (typeof document === "undefined") return;
|
|
131856
|
-
if (document.getElementById(
|
|
133336
|
+
if (document.getElementById(STYLE_ID18)) return;
|
|
131857
133337
|
const tag = document.createElement("style");
|
|
131858
|
-
tag.id =
|
|
133338
|
+
tag.id = STYLE_ID18;
|
|
131859
133339
|
tag.textContent = CSS4;
|
|
131860
133340
|
document.head.appendChild(tag);
|
|
131861
133341
|
}
|
|
@@ -134705,7 +136185,7 @@ var WATER_FIXTURES = {
|
|
|
134705
136185
|
var DEFAULT_FIXTURES = ENERGY_FIXTURES;
|
|
134706
136186
|
|
|
134707
136187
|
// src/components/metas-guide/openMetasGuide.ts
|
|
134708
|
-
var
|
|
136188
|
+
var STYLE_ID19 = "myio-metas-guide-styles";
|
|
134709
136189
|
var ROOT_ID = "myio-metas-guide-root";
|
|
134710
136190
|
var FALLBACK_THEME = {
|
|
134711
136191
|
accent: "#6c5ce7",
|
|
@@ -134713,7 +136193,7 @@ var FALLBACK_THEME = {
|
|
|
134713
136193
|
accentText: "#ffffff",
|
|
134714
136194
|
mode: "light"
|
|
134715
136195
|
};
|
|
134716
|
-
function
|
|
136196
|
+
function escapeHtml17(value) {
|
|
134717
136197
|
return String(value ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
134718
136198
|
}
|
|
134719
136199
|
var nfInt = new Intl.NumberFormat("pt-BR", { maximumFractionDigits: 0 });
|
|
@@ -134741,7 +136221,7 @@ function legendHtml() {
|
|
|
134741
136221
|
[SERIES_COLORS.orcado, "Or\xE7ado"]
|
|
134742
136222
|
];
|
|
134743
136223
|
return `<div class="myio-mg-legend">${items.map(
|
|
134744
|
-
([c, l]) => `<span class="myio-mg-legend__item"><span class="myio-mg-legend__dot" style="background:${c}" aria-hidden="true"></span>${
|
|
136224
|
+
([c, l]) => `<span class="myio-mg-legend__item"><span class="myio-mg-legend__dot" style="background:${c}" aria-hidden="true"></span>${escapeHtml17(
|
|
134745
136225
|
l
|
|
134746
136226
|
)}</span>`
|
|
134747
136227
|
).join("")}</div>`;
|
|
@@ -134781,7 +136261,7 @@ function miniChartSvg(s) {
|
|
|
134781
136261
|
const pts = data.map((v, i) => `${(i * bandW + bandW / 2).toFixed(1)},${y(v).toFixed(1)}`).join(" ");
|
|
134782
136262
|
return `<polyline points="${pts}" fill="none" stroke="${color}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"></polyline>`;
|
|
134783
136263
|
};
|
|
134784
|
-
return `<svg class="myio-mg-chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Gr\xE1fico ilustrativo de ${
|
|
136264
|
+
return `<svg class="myio-mg-chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Gr\xE1fico ilustrativo de ${escapeHtml17(
|
|
134785
136265
|
s.name
|
|
134786
136266
|
)}" preserveAspectRatio="none">
|
|
134787
136267
|
${bars}
|
|
@@ -134798,8 +136278,8 @@ function kpiRowHtml(s, unit) {
|
|
|
134798
136278
|
];
|
|
134799
136279
|
return `<div class="myio-mg-kpis">${kpis.map(
|
|
134800
136280
|
([label, val, color]) => `<div class="myio-mg-kpi">
|
|
134801
|
-
<span class="myio-mg-kpi__label" style="color:${color}">${
|
|
134802
|
-
<span class="myio-mg-kpi__value">${fmtInt(val)} <small>${
|
|
136281
|
+
<span class="myio-mg-kpi__label" style="color:${color}">${escapeHtml17(label)}</span>
|
|
136282
|
+
<span class="myio-mg-kpi__value">${fmtInt(val)} <small>${escapeHtml17(unit)}</small></span>
|
|
134803
136283
|
</div>`
|
|
134804
136284
|
).join("")}</div>`;
|
|
134805
136285
|
}
|
|
@@ -134807,7 +136287,7 @@ function chipsHtml(s) {
|
|
|
134807
136287
|
const c = computeChips(s);
|
|
134808
136288
|
const chip = (label, ratio) => {
|
|
134809
136289
|
const cls = ratio > 0 ? "is-up" : ratio < 0 ? "is-down" : "is-flat";
|
|
134810
|
-
return `<span class="myio-mg-chip ${cls}">${
|
|
136290
|
+
return `<span class="myio-mg-chip ${cls}">${escapeHtml17(label)} <strong>${escapeHtml17(
|
|
134811
136291
|
fmtPct4(ratio)
|
|
134812
136292
|
)}</strong></span>`;
|
|
134813
136293
|
};
|
|
@@ -134822,7 +136302,7 @@ function miniCardHtml(s, unit, opts) {
|
|
|
134822
136302
|
const showKpis = opts?.kpis !== false;
|
|
134823
136303
|
const showChips = opts?.chips !== false;
|
|
134824
136304
|
return `<div class="myio-mg-card">
|
|
134825
|
-
<h5 class="myio-mg-card__title">${
|
|
136305
|
+
<h5 class="myio-mg-card__title">${escapeHtml17(s.name)}</h5>
|
|
134826
136306
|
${showChart ? legendHtml() + miniChartSvg(s) : ""}
|
|
134827
136307
|
${showKpis ? kpiRowHtml(s, unit) : ""}
|
|
134828
136308
|
${showChips ? chipsHtml(s) : ""}
|
|
@@ -134832,7 +136312,7 @@ function miniSidebarHtml(shoppings, unit, prevY, curY) {
|
|
|
134832
136312
|
const total = deriveTotal({ shoppings });
|
|
134833
136313
|
const row = (name, a, r, o, m, isTotal) => `
|
|
134834
136314
|
<div class="myio-mg-side__row${isTotal ? " is-total" : ""}">
|
|
134835
|
-
<span class="myio-mg-side__name">${
|
|
136315
|
+
<span class="myio-mg-side__name">${escapeHtml17(name)}</span>
|
|
134836
136316
|
<span class="myio-mg-side__vals">
|
|
134837
136317
|
<b style="color:${SERIES_COLORS.aMinus1}">${fmtInt(a)}</b>
|
|
134838
136318
|
<b style="color:${SERIES_COLORS.realizado}">${fmtInt(r)}</b>
|
|
@@ -134843,7 +136323,7 @@ function miniSidebarHtml(shoppings, unit, prevY, curY) {
|
|
|
134843
136323
|
return `<div class="myio-mg-side">
|
|
134844
136324
|
<div class="myio-mg-side__head">
|
|
134845
136325
|
<span>Resumo por shopping</span>
|
|
134846
|
-
<span class="myio-mg-side__unit">${
|
|
136326
|
+
<span class="myio-mg-side__unit">${escapeHtml17(unit)}</span>
|
|
134847
136327
|
</div>
|
|
134848
136328
|
<div class="myio-mg-side__cols">
|
|
134849
136329
|
<span>Shopping</span>
|
|
@@ -134870,10 +136350,10 @@ function miniToolbarHtml(prevY, curY, highlight) {
|
|
|
134870
136350
|
</div>`;
|
|
134871
136351
|
}
|
|
134872
136352
|
function bannerHtml(text2) {
|
|
134873
|
-
return `<p class="myio-mg-banner">${
|
|
136353
|
+
return `<p class="myio-mg-banner">${escapeHtml17(text2)}</p>`;
|
|
134874
136354
|
}
|
|
134875
136355
|
function paras(sentences) {
|
|
134876
|
-
return `<div class="myio-mg-copy">${sentences.map((s) => `<p>${
|
|
136356
|
+
return `<div class="myio-mg-copy">${sentences.map((s) => `<p>${escapeHtml17(s)}</p>`).join("")}</div>`;
|
|
134877
136357
|
}
|
|
134878
136358
|
function buildSections(ctx) {
|
|
134879
136359
|
const { energy, water, curY, prevY } = ctx;
|
|
@@ -134898,8 +136378,8 @@ function buildSections(ctx) {
|
|
|
134898
136378
|
"A r\xE9gua da meta muda por dom\xEDnio: em Energia a refer\xEAncia \xE9 a ENTRADA; em \xC1gua, os hidr\xF4metros.",
|
|
134899
136379
|
"Os n\xFAmeros e a unidade de cada card acompanham o dom\xEDnio selecionado."
|
|
134900
136380
|
]) + miniToolbarHtml(prevY, curY, "domain") + `<div class="myio-mg-two">
|
|
134901
|
-
<div><div class="myio-mg-two__tag">\u26A1 Energia \xB7 ${
|
|
134902
|
-
<div><div class="myio-mg-two__tag">\u{1F4A7} \xC1gua \xB7 ${
|
|
136381
|
+
<div><div class="myio-mg-two__tag">\u26A1 Energia \xB7 ${escapeHtml17(energy.unit)}</div>${miniCardHtml(e0, energy.unit, { chips: false })}</div>
|
|
136382
|
+
<div><div class="myio-mg-two__tag">\u{1F4A7} \xC1gua \xB7 ${escapeHtml17(water.unit)}</div>${miniCardHtml(w0, water.unit, { chips: false })}</div>
|
|
134903
136383
|
</div>`
|
|
134904
136384
|
},
|
|
134905
136385
|
{
|
|
@@ -134970,7 +136450,7 @@ function buildSections(ctx) {
|
|
|
134970
136450
|
]) + `<div class="myio-mg-order">
|
|
134971
136451
|
<span class="myio-mg-order__btn">Data de Inaugura\xE7\xE3o \u2191 \xB7 \u2699\uFE0F</span>
|
|
134972
136452
|
<span class="myio-mg-order__btn">\u25BD Filtros</span>
|
|
134973
|
-
</div><ul class="myio-mg-order__list">${energy.shoppings.slice().sort((a, b) => a.inaugurationDate.localeCompare(b.inaugurationDate)).map((s) => `<li><b>${
|
|
136453
|
+
</div><ul class="myio-mg-order__list">${energy.shoppings.slice().sort((a, b) => a.inaugurationDate.localeCompare(b.inaugurationDate)).map((s) => `<li><b>${escapeHtml17(s.name)}</b> <span>inaugurado em ${escapeHtml17(s.inaugurationDate)}</span></li>`).join("")}</ul>`
|
|
134974
136454
|
},
|
|
134975
136455
|
{
|
|
134976
136456
|
id: "engine",
|
|
@@ -134998,10 +136478,10 @@ function buildSections(ctx) {
|
|
|
134998
136478
|
}
|
|
134999
136479
|
];
|
|
135000
136480
|
}
|
|
135001
|
-
function
|
|
135002
|
-
if (document.getElementById(
|
|
136481
|
+
function injectStyles19() {
|
|
136482
|
+
if (document.getElementById(STYLE_ID19)) return;
|
|
135003
136483
|
const style = document.createElement("style");
|
|
135004
|
-
style.id =
|
|
136484
|
+
style.id = STYLE_ID19;
|
|
135005
136485
|
style.textContent = `
|
|
135006
136486
|
#${ROOT_ID}{position:fixed;inset:0;z-index:100001;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.6);backdrop-filter:blur(4px);font-family:'Nunito',system-ui,sans-serif;}
|
|
135007
136487
|
#${ROOT_ID} *{box-sizing:border-box;}
|
|
@@ -135100,7 +136580,7 @@ function openMetasGuide(options = {}) {
|
|
|
135100
136580
|
const sections = buildSections({ energy, water, curY, prevY });
|
|
135101
136581
|
const total = sections.length;
|
|
135102
136582
|
document.getElementById(ROOT_ID)?.remove();
|
|
135103
|
-
|
|
136583
|
+
injectStyles19();
|
|
135104
136584
|
const previouslyFocused = document.activeElement;
|
|
135105
136585
|
let index = 0;
|
|
135106
136586
|
let closed = false;
|
|
@@ -135109,9 +136589,9 @@ function openMetasGuide(options = {}) {
|
|
|
135109
136589
|
root.innerHTML = `
|
|
135110
136590
|
<div class="myio-mg-modal${theme.mode === "dark" ? " is-dark" : ""}" role="dialog" aria-modal="true"
|
|
135111
136591
|
aria-labelledby="myio-mg-title"
|
|
135112
|
-
style="--mg-accent:${
|
|
136592
|
+
style="--mg-accent:${escapeHtml17(theme.accent)};--mg-accent-dark:${escapeHtml17(
|
|
135113
136593
|
theme.accentDark
|
|
135114
|
-
)};--mg-accent-text:${
|
|
136594
|
+
)};--mg-accent-text:${escapeHtml17(theme.accentText)};">
|
|
135115
136595
|
<div class="myio-mg-header">
|
|
135116
136596
|
<div class="myio-mg-header__l">
|
|
135117
136597
|
<span class="myio-mg-header__logo" aria-hidden="true">\u{1F393}</span>
|
|
@@ -138945,7 +140425,7 @@ var TELEMETRY_GRID_SHOPPING_STYLES = `
|
|
|
138945
140425
|
text-overflow: ellipsis;
|
|
138946
140426
|
}
|
|
138947
140427
|
`;
|
|
138948
|
-
function
|
|
140428
|
+
function injectStyles20(_container) {
|
|
138949
140429
|
const styleId = "telemetry-grid-shopping-styles";
|
|
138950
140430
|
if (document.getElementById(styleId)) {
|
|
138951
140431
|
return;
|
|
@@ -138993,7 +140473,7 @@ var TelemetryGridShoppingView = class {
|
|
|
138993
140473
|
// Render
|
|
138994
140474
|
// =========================================================================
|
|
138995
140475
|
render() {
|
|
138996
|
-
|
|
140476
|
+
injectStyles20(this.root);
|
|
138997
140477
|
this.root.innerHTML = this.buildHTML();
|
|
138998
140478
|
this.cacheElements();
|
|
138999
140479
|
this.bindEvents();
|
|
@@ -140664,7 +142144,7 @@ var TELEMETRY_INFO_SHOPPING_STYLES = `
|
|
|
140664
142144
|
}
|
|
140665
142145
|
}
|
|
140666
142146
|
`;
|
|
140667
|
-
function
|
|
142147
|
+
function injectStyles21(_container) {
|
|
140668
142148
|
const styleId = "telemetry-info-shopping-styles-v2";
|
|
140669
142149
|
if (document.getElementById(styleId)) {
|
|
140670
142150
|
return;
|
|
@@ -140724,7 +142204,7 @@ var TelemetryInfoShoppingView = class _TelemetryInfoShoppingView {
|
|
|
140724
142204
|
// Render
|
|
140725
142205
|
// =========================================================================
|
|
140726
142206
|
render() {
|
|
140727
|
-
|
|
142207
|
+
injectStyles21(this.root);
|
|
140728
142208
|
this.root.innerHTML = this.buildHTML();
|
|
140729
142209
|
this.cacheElements();
|
|
140730
142210
|
this.bindEvents();
|
|
@@ -148779,12 +150259,12 @@ var AlarmsNotificationsPanelView = class {
|
|
|
148779
150259
|
}
|
|
148780
150260
|
const badgeEl = this.root.querySelector("#alarmCountBadge");
|
|
148781
150261
|
if (badgeEl) {
|
|
148782
|
-
const
|
|
150262
|
+
const openCount4 = state6.allAlarms.filter(
|
|
148783
150263
|
(a) => a.state === "OPEN" || a.state === "ESCALATED"
|
|
148784
150264
|
).length;
|
|
148785
|
-
badgeEl.textContent =
|
|
150265
|
+
badgeEl.textContent = openCount4 > 99 ? "99+" : String(openCount4);
|
|
148786
150266
|
badgeEl.style.display = "inline-flex";
|
|
148787
|
-
badgeEl.classList.toggle("is-zero",
|
|
150267
|
+
badgeEl.classList.toggle("is-zero", openCount4 === 0);
|
|
148788
150268
|
}
|
|
148789
150269
|
const loadingOverlay = this.root.querySelector("#loadingOverlay");
|
|
148790
150270
|
if (loadingOverlay) {
|
|
@@ -149105,10 +150585,10 @@ var AlarmsNotificationsPanelView = class {
|
|
|
149105
150585
|
const renderListPanel = (group, items, sel) => {
|
|
149106
150586
|
if (items.length === 0) return '<div class="afm-empty">Nenhum item encontrado</div>';
|
|
149107
150587
|
return items.map((item) => {
|
|
149108
|
-
const
|
|
150588
|
+
const esc10 = this.esc(item);
|
|
149109
150589
|
return `<label class="afm-check-item">
|
|
149110
|
-
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${
|
|
149111
|
-
<span class="afm-check-label">${
|
|
150590
|
+
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${esc10}"${sel.has(item) ? " checked" : ""}>
|
|
150591
|
+
<span class="afm-check-label">${esc10}</span>
|
|
149112
150592
|
</label>`;
|
|
149113
150593
|
}).join("");
|
|
149114
150594
|
};
|
|
@@ -153207,8 +154687,8 @@ function renderDowntimeList(downtimeList) {
|
|
|
153207
154687
|
<div class="downtime-item">
|
|
153208
154688
|
<span class="rank">${index + 1}</span>
|
|
153209
154689
|
<div class="item-info">
|
|
153210
|
-
<span class="item-name">${
|
|
153211
|
-
<span class="item-location">${
|
|
154690
|
+
<span class="item-name">${escapeHtml18(item.name)}</span>
|
|
154691
|
+
<span class="item-location">${escapeHtml18(item.location)}</span>
|
|
153212
154692
|
</div>
|
|
153213
154693
|
<div class="item-metrics">
|
|
153214
154694
|
<span class="downtime-hours">${item.downtime}h</span>
|
|
@@ -153221,7 +154701,7 @@ function renderDowntimeList(downtimeList) {
|
|
|
153221
154701
|
`
|
|
153222
154702
|
).join("");
|
|
153223
154703
|
}
|
|
153224
|
-
function
|
|
154704
|
+
function escapeHtml18(text2) {
|
|
153225
154705
|
const div = document.createElement("div");
|
|
153226
154706
|
div.textContent = text2;
|
|
153227
154707
|
return div.innerHTML;
|
|
@@ -157804,7 +159284,7 @@ function removeSchedulingSharedStyles() {
|
|
|
157804
159284
|
}
|
|
157805
159285
|
|
|
157806
159286
|
// src/components/scheduling-shared/view-helpers.ts
|
|
157807
|
-
function
|
|
159287
|
+
function escapeHtml19(str) {
|
|
157808
159288
|
const div = document.createElement("div");
|
|
157809
159289
|
div.textContent = str;
|
|
157810
159290
|
return div.innerHTML;
|
|
@@ -157965,7 +159445,7 @@ function showConfirmModal(container, title, message) {
|
|
|
157965
159445
|
overlay.innerHTML = `
|
|
157966
159446
|
<div class="${SCHED_CSS_PREFIX}__modal-backdrop"></div>
|
|
157967
159447
|
<div class="${SCHED_CSS_PREFIX}__modal-content">
|
|
157968
|
-
<h3>${
|
|
159448
|
+
<h3>${escapeHtml19(title)}</h3>
|
|
157969
159449
|
<p>${message}</p>
|
|
157970
159450
|
<div class="${SCHED_CSS_PREFIX}__modal-actions">
|
|
157971
159451
|
<button class="${SCHED_CSS_PREFIX}__modal-btn-cancel">Cancelar</button>
|
|
@@ -157999,8 +159479,8 @@ function showNotificationModal(container, type, message, autoCloseMs = 6e3) {
|
|
|
157999
159479
|
overlay.innerHTML = `
|
|
158000
159480
|
<div class="${SCHED_CSS_PREFIX}__modal-backdrop"></div>
|
|
158001
159481
|
<div class="${SCHED_CSS_PREFIX}__modal-content">
|
|
158002
|
-
<h3>${
|
|
158003
|
-
<p>${
|
|
159482
|
+
<h3>${escapeHtml19(title)}</h3>
|
|
159483
|
+
<p>${escapeHtml19(message)}</p>
|
|
158004
159484
|
<div class="${SCHED_CSS_PREFIX}__modal-actions">
|
|
158005
159485
|
<button class="${SCHED_CSS_PREFIX}__modal-btn-close">Fechar</button>
|
|
158006
159486
|
</div>
|
|
@@ -159577,7 +161057,7 @@ var STYLES = `
|
|
|
159577
161057
|
color: var(--dgv6-ink-2);
|
|
159578
161058
|
}
|
|
159579
161059
|
`;
|
|
159580
|
-
function
|
|
161060
|
+
function injectStyles22() {
|
|
159581
161061
|
if (document.getElementById(CSS_ID6)) return;
|
|
159582
161062
|
const style = document.createElement("style");
|
|
159583
161063
|
style.id = CSS_ID6;
|
|
@@ -159616,7 +161096,7 @@ var DeviceGridV6View = class {
|
|
|
159616
161096
|
// Render
|
|
159617
161097
|
// =========================================================================
|
|
159618
161098
|
render() {
|
|
159619
|
-
|
|
161099
|
+
injectStyles22();
|
|
159620
161100
|
this.root.innerHTML = this.buildHTML();
|
|
159621
161101
|
this.cacheElements();
|
|
159622
161102
|
this.bindEvents();
|
|
@@ -161986,7 +163466,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
161986
163466
|
const docTitle = buildActivationReportTitle(deviceName, opts.customerName);
|
|
161987
163467
|
const issuedAt = formatIssuedAt(/* @__PURE__ */ new Date(), locale);
|
|
161988
163468
|
const utilization = data.totalHours > 0 ? (data.totalOnMinutes / (data.totalHours * 60) * 100).toFixed(1) : "0.0";
|
|
161989
|
-
const
|
|
163469
|
+
const esc10 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
161990
163470
|
const htmlContent = `
|
|
161991
163471
|
<!DOCTYPE html>
|
|
161992
163472
|
<html lang="pt-BR">
|
|
@@ -162038,14 +163518,14 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
162038
163518
|
<div class="brand">MyIO BAS</div>
|
|
162039
163519
|
<h1>Relat\xF3rio de Acionamentos</h1>
|
|
162040
163520
|
<div class="meta">
|
|
162041
|
-
<div><b>Dispositivo:</b> ${
|
|
163521
|
+
<div><b>Dispositivo:</b> ${esc10(deviceName)}</div>
|
|
162042
163522
|
<div><b>Per\xEDodo:</b> ${periodStart} \u2014 ${periodEnd}</div>
|
|
162043
163523
|
</div>
|
|
162044
163524
|
</div>
|
|
162045
163525
|
${customerName ? `
|
|
162046
163526
|
<div class="customer-badge">
|
|
162047
163527
|
<div class="label">Cliente</div>
|
|
162048
|
-
<div class="value">${
|
|
163528
|
+
<div class="value">${esc10(customerName)}</div>
|
|
162049
163529
|
</div>` : ""}
|
|
162050
163530
|
</div>
|
|
162051
163531
|
|
|
@@ -162056,7 +163536,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
162056
163536
|
</div>
|
|
162057
163537
|
<div class="summary-card accent-green">
|
|
162058
163538
|
<div class="summary-value">${formatDurationMinutes(data.totalOnMinutes)}</div>
|
|
162059
|
-
<div class="summary-label">Tempo ${
|
|
163539
|
+
<div class="summary-label">Tempo ${esc10(labelOn)}</div>
|
|
162060
163540
|
</div>
|
|
162061
163541
|
<div class="summary-card accent-amber">
|
|
162062
163542
|
<div class="summary-value">${utilization}%</div>
|
|
@@ -162084,7 +163564,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
162084
163564
|
<tr>
|
|
162085
163565
|
<td>${formatDateForExport(seg.startTime, locale)}</td>
|
|
162086
163566
|
<td>${formatDateForExport(seg.endTime, locale)}</td>
|
|
162087
|
-
<td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ?
|
|
163567
|
+
<td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ? esc10(labelOn) : esc10(labelOff)}</span></td>
|
|
162088
163568
|
<td>${formatDurationMinutes(seg.durationMinutes)}</td>
|
|
162089
163569
|
<td>${seg.source === "manual" ? "Manual" : seg.source === "schedule" ? "Agendamento" : seg.source === "automation" ? "Automa\xE7\xE3o" : "Desconhecido"}</td>
|
|
162090
163570
|
</tr>
|
|
@@ -162093,7 +163573,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
162093
163573
|
</table>
|
|
162094
163574
|
|
|
162095
163575
|
<div class="footer">
|
|
162096
|
-
<span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` · ${
|
|
163576
|
+
<span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` · ${esc10(customerName)}` : ""} · <span class="brand">MyIO BAS</span>
|
|
162097
163577
|
</div>
|
|
162098
163578
|
</body>
|
|
162099
163579
|
</html>
|
|
@@ -168083,7 +169563,7 @@ var STYLES2 = `
|
|
|
168083
169563
|
}
|
|
168084
169564
|
#${MODAL_ID5} .gcdr-fail-item:last-child { border-bottom: none; }
|
|
168085
169565
|
`;
|
|
168086
|
-
function
|
|
169566
|
+
function injectStyles23() {
|
|
168087
169567
|
if (document.getElementById(`${MODAL_ID5}-styles`)) return;
|
|
168088
169568
|
const style = document.createElement("style");
|
|
168089
169569
|
style.id = `${MODAL_ID5}-styles`;
|
|
@@ -168192,7 +169672,7 @@ function escHtml4(str) {
|
|
|
168192
169672
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
168193
169673
|
}
|
|
168194
169674
|
async function openGCDRSyncModal(params) {
|
|
168195
|
-
|
|
169675
|
+
injectStyles23();
|
|
168196
169676
|
removeExistingModal();
|
|
168197
169677
|
if (!params.thingsboardToken) {
|
|
168198
169678
|
alert("Token ThingsBoard n\xE3o encontrado. Fa\xE7a login novamente.");
|
|
@@ -168765,7 +170245,7 @@ var STYLES3 = `
|
|
|
168765
170245
|
.abm-confirm-btn--confirm { background: #e67e22; color: #fff; }
|
|
168766
170246
|
.abm-confirm-btn--confirm:hover { background: #cf6d17; }
|
|
168767
170247
|
`;
|
|
168768
|
-
function
|
|
170248
|
+
function injectStyles24() {
|
|
168769
170249
|
if (document.getElementById(`${MODAL_ID6}-styles`)) return;
|
|
168770
170250
|
const style = document.createElement("style");
|
|
168771
170251
|
style.id = `${MODAL_ID6}-styles`;
|
|
@@ -168884,7 +170364,7 @@ function openGranularValueEdit(ruleItem, rule, device, bundle, gcdrTenantId, bas
|
|
|
168884
170364
|
const originalChipsHtml = detailEl.innerHTML;
|
|
168885
170365
|
const baseRuleId = rule.parentRuleId ?? rule.id;
|
|
168886
170366
|
const isOverride = !!rule.parentRuleId;
|
|
168887
|
-
const
|
|
170367
|
+
const formHtml2 = `
|
|
168888
170368
|
<div class="abm-edit-form">
|
|
168889
170369
|
<div class="abm-ef-row">
|
|
168890
170370
|
<span class="abm-ef-label">Valor</span>
|
|
@@ -168899,7 +170379,7 @@ function openGranularValueEdit(ruleItem, rule, device, bundle, gcdrTenantId, bas
|
|
|
168899
170379
|
</div>
|
|
168900
170380
|
</div>
|
|
168901
170381
|
`;
|
|
168902
|
-
detailEl.innerHTML =
|
|
170382
|
+
detailEl.innerHTML = formHtml2;
|
|
168903
170383
|
const form = detailEl.querySelector(".abm-edit-form");
|
|
168904
170384
|
const valueInput = form.querySelector("#abm-ef-value");
|
|
168905
170385
|
const valuePreview = form.querySelector("#abm-ef-value-preview");
|
|
@@ -168972,7 +170452,7 @@ function openFullRuleEdit(ruleItemOrDetail, rule, bundle, gcdrTenantId, baseUrl)
|
|
|
168972
170452
|
const on = editDays[key] === true;
|
|
168973
170453
|
return `<button class="abm-ef-day-btn ${on ? "on" : ""}" data-day-key="${key}" type="button">${label}</button>`;
|
|
168974
170454
|
}).join("");
|
|
168975
|
-
const
|
|
170455
|
+
const formHtml2 = `
|
|
168976
170456
|
<div class="abm-edit-form">
|
|
168977
170457
|
<div class="abm-ef-row" style="align-items:flex-start;">
|
|
168978
170458
|
<span class="abm-ef-label">Descri\xE7\xE3o</span>
|
|
@@ -169002,7 +170482,7 @@ function openFullRuleEdit(ruleItemOrDetail, rule, bundle, gcdrTenantId, baseUrl)
|
|
|
169002
170482
|
</div>
|
|
169003
170483
|
</div>
|
|
169004
170484
|
`;
|
|
169005
|
-
detailEl.innerHTML =
|
|
170485
|
+
detailEl.innerHTML = formHtml2;
|
|
169006
170486
|
const form = detailEl.querySelector(".abm-edit-form");
|
|
169007
170487
|
form.querySelectorAll(".abm-ef-day-btn").forEach((btn) => {
|
|
169008
170488
|
btn.addEventListener("click", () => {
|
|
@@ -169444,7 +170924,7 @@ async function fetchBundle(customerTB_ID, gcdrTenantId, baseUrl) {
|
|
|
169444
170924
|
return json.data;
|
|
169445
170925
|
}
|
|
169446
170926
|
async function openAlarmBundleMapModal(params) {
|
|
169447
|
-
|
|
170927
|
+
injectStyles24();
|
|
169448
170928
|
removeExistingModal2();
|
|
169449
170929
|
if (!params.customerTB_ID) {
|
|
169450
170930
|
alert("Customer TB ID n\xE3o informado. N\xE3o \xE9 poss\xEDvel carregar o mapa de alarmes.");
|
|
@@ -170614,11 +172094,11 @@ function _esc(s) {
|
|
|
170614
172094
|
const str = s == null ? "" : String(s);
|
|
170615
172095
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
170616
172096
|
}
|
|
170617
|
-
var
|
|
172097
|
+
var STYLE_ID20 = "ntw-styles";
|
|
170618
172098
|
function _injectStyles2() {
|
|
170619
|
-
if (document.getElementById(
|
|
172099
|
+
if (document.getElementById(STYLE_ID20)) return;
|
|
170620
172100
|
const s = document.createElement("style");
|
|
170621
|
-
s.id =
|
|
172101
|
+
s.id = STYLE_ID20;
|
|
170622
172102
|
s.textContent = NTW_CSS;
|
|
170623
172103
|
document.head.appendChild(s);
|
|
170624
172104
|
}
|
|
@@ -173319,7 +174799,7 @@ var IMPORTANCE_COLORS4 = {
|
|
|
173319
174799
|
// red
|
|
173320
174800
|
};
|
|
173321
174801
|
var ITEM_TEXT_MAX = 120;
|
|
173322
|
-
function
|
|
174802
|
+
function escapeHtml20(input) {
|
|
173323
174803
|
if (input == null) return "";
|
|
173324
174804
|
return String(input).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
173325
174805
|
}
|
|
@@ -173357,24 +174837,24 @@ function renderAnnotationItemCard(device, annotation, searchTerm) {
|
|
|
173357
174837
|
const domainIcon = DOMAIN_ICONS3[device.domain] ?? DOMAIN_ICONS3.unknown;
|
|
173358
174838
|
const typeIcon = TYPE_ICONS[annotation.type] ?? "\xB7";
|
|
173359
174839
|
const importance = Math.max(1, Math.min(5, annotation.importance || 1));
|
|
173360
|
-
const textEscaped =
|
|
173361
|
-
const deviceLabelEscaped =
|
|
173362
|
-
const author =
|
|
173363
|
-
const when =
|
|
174840
|
+
const textEscaped = escapeHtml20(truncate2(annotation.text || "", ITEM_TEXT_MAX));
|
|
174841
|
+
const deviceLabelEscaped = escapeHtml20(device.label || device.name || device.deviceId);
|
|
174842
|
+
const author = escapeHtml20(annotation.createdBy?.name || "sem autor");
|
|
174843
|
+
const when = escapeHtml20(formatRelative(annotation.createdAt));
|
|
173364
174844
|
const overdueTag = isOverdue(annotation) ? '<span class="myio-annotations-overdue">Vencida</span>' : "";
|
|
173365
174845
|
const text2 = searchTerm ? highlightMatches(textEscaped, searchTerm) : textEscaped;
|
|
173366
174846
|
const deviceLabel = searchTerm ? highlightMatches(deviceLabelEscaped, searchTerm) : deviceLabelEscaped;
|
|
173367
|
-
const identifierEscaped = device.identifier ?
|
|
174847
|
+
const identifierEscaped = device.identifier ? escapeHtml20(device.identifier) : "";
|
|
173368
174848
|
const identifierHighlighted = searchTerm && identifierEscaped ? highlightMatches(identifierEscaped, searchTerm) : identifierEscaped;
|
|
173369
174849
|
const identifierTag = device.identifier ? `<span class="myio-annotations-item-device">${identifierHighlighted}</span>` : "";
|
|
173370
174850
|
return `
|
|
173371
174851
|
<button
|
|
173372
174852
|
class="myio-annotations-item"
|
|
173373
174853
|
type="button"
|
|
173374
|
-
data-device-id="${
|
|
173375
|
-
data-annotation-id="${
|
|
174854
|
+
data-device-id="${escapeHtml20(device.deviceId)}"
|
|
174855
|
+
data-annotation-id="${escapeHtml20(annotation.id)}"
|
|
173376
174856
|
tabindex="0"
|
|
173377
|
-
aria-label="${
|
|
174857
|
+
aria-label="${escapeHtml20(annotation.text)} \u2014 ${deviceLabel}"
|
|
173378
174858
|
>
|
|
173379
174859
|
<span class="myio-annotations-item-icon" aria-hidden="true">${typeIcon}</span>
|
|
173380
174860
|
<div class="myio-annotations-item-body">
|
|
@@ -173581,7 +175061,7 @@ var STYLES4 = `
|
|
|
173581
175061
|
background: #cbd5e1; border-color: #cbd5e1; cursor: not-allowed;
|
|
173582
175062
|
}
|
|
173583
175063
|
`;
|
|
173584
|
-
function
|
|
175064
|
+
function injectStyles25() {
|
|
173585
175065
|
if (typeof document === "undefined") return;
|
|
173586
175066
|
if (document.getElementById(STYLES_ID4)) return;
|
|
173587
175067
|
const el2 = document.createElement("style");
|
|
@@ -173591,7 +175071,7 @@ function injectStyles22() {
|
|
|
173591
175071
|
}
|
|
173592
175072
|
var _activeBackdrop = null;
|
|
173593
175073
|
function openExportModal(options) {
|
|
173594
|
-
|
|
175074
|
+
injectStyles25();
|
|
173595
175075
|
closeExportModal();
|
|
173596
175076
|
const backdrop = document.createElement("div");
|
|
173597
175077
|
backdrop.className = `${MODAL_DOM_ID}-backdrop`;
|
|
@@ -174351,8 +175831,8 @@ var HeaderAnnotationsPanel = class _HeaderAnnotationsPanel {
|
|
|
174351
175831
|
// group header
|
|
174352
175832
|
render: () => `
|
|
174353
175833
|
<header class="myio-annotations-group-header ${groupClass}">
|
|
174354
|
-
${g.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${
|
|
174355
|
-
<span class="myio-annotations-group-label">${
|
|
175834
|
+
${g.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml20(g.icon)}</span>` : ""}
|
|
175835
|
+
<span class="myio-annotations-group-label">${escapeHtml20(g.label)}</span>
|
|
174356
175836
|
<span class="myio-annotations-group-count">${g.totalAnnotations}</span>
|
|
174357
175837
|
</header>`
|
|
174358
175838
|
});
|
|
@@ -174477,9 +175957,9 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
|
|
|
174477
175957
|
}
|
|
174478
175958
|
_renderToolbar(filteredCount, totalCount) {
|
|
174479
175959
|
const sortOptions = SORT_OPTIONS.map(
|
|
174480
|
-
(o) => `<option value="${o.key}" ${o.key === this.sortBy ? "selected" : ""}>${
|
|
175960
|
+
(o) => `<option value="${o.key}" ${o.key === this.sortBy ? "selected" : ""}>${escapeHtml20(o.label)}</option>`
|
|
174481
175961
|
).join("");
|
|
174482
|
-
const term =
|
|
175962
|
+
const term = escapeHtml20(this.filter.searchTerm || "");
|
|
174483
175963
|
const filtersActiveCount = this._activeFilterCount();
|
|
174484
175964
|
const filterIndicator = filtersActiveCount > 0 ? `<span class="myio-annotations-group-count">${filtersActiveCount}</span>` : "";
|
|
174485
175965
|
const showingHtml = filteredCount === totalCount ? `${totalCount} anota\xE7\xF5es` : `${filteredCount} de ${totalCount} anota\xE7\xF5es`;
|
|
@@ -174520,13 +176000,13 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
|
|
|
174520
176000
|
const typesHtml = FILTER_TYPE_OPTIONS.map(
|
|
174521
176001
|
(t) => `<label class="myio-annotations-filter-chip ${this.filter.types.has(t.id) ? "is-on" : ""}">
|
|
174522
176002
|
<input type="checkbox" data-filter="type" value="${t.id}" ${this.filter.types.has(t.id) ? "checked" : ""} />
|
|
174523
|
-
<span>${t.icon} ${
|
|
176003
|
+
<span>${t.icon} ${escapeHtml20(t.label)}</span>
|
|
174524
176004
|
</label>`
|
|
174525
176005
|
).join("");
|
|
174526
176006
|
const statusHtml = FILTER_STATUS_OPTIONS.map(
|
|
174527
176007
|
(s) => `<label class="myio-annotations-filter-chip ${this.filter.statuses.has(s.id) ? "is-on" : ""}">
|
|
174528
176008
|
<input type="checkbox" data-filter="status" value="${s.id}" ${this.filter.statuses.has(s.id) ? "checked" : ""} />
|
|
174529
|
-
<span>${
|
|
176009
|
+
<span>${escapeHtml20(s.label)}</span>
|
|
174530
176010
|
</label>`
|
|
174531
176011
|
).join("");
|
|
174532
176012
|
const impHtml = [1, 2, 3, 4, 5].map(
|
|
@@ -174603,12 +176083,12 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
|
|
|
174603
176083
|
return `
|
|
174604
176084
|
<section class="${groupClass}">
|
|
174605
176085
|
<header class="myio-annotations-group-header" role="button" tabindex="0"
|
|
174606
|
-
data-group-toggle="${
|
|
176086
|
+
data-group-toggle="${escapeHtml20(group.key)}"
|
|
174607
176087
|
aria-expanded="${!isCollapsed}"
|
|
174608
176088
|
title="${isCollapsed ? "Expandir grupo" : "Recolher grupo"}">
|
|
174609
176089
|
<span class="myio-annotations-group-chevron" aria-hidden="true">${isCollapsed ? "\u25B6" : "\u25BC"}</span>
|
|
174610
|
-
${group.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${
|
|
174611
|
-
<span class="myio-annotations-group-label">${
|
|
176090
|
+
${group.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml20(group.icon)}</span>` : ""}
|
|
176091
|
+
<span class="myio-annotations-group-label">${escapeHtml20(group.label)}</span>
|
|
174612
176092
|
<span class="myio-annotations-group-count">${group.totalAnnotations}</span>
|
|
174613
176093
|
</header>
|
|
174614
176094
|
${itemsHtml}
|
|
@@ -175150,7 +176630,7 @@ function prefixForProductType(productType) {
|
|
|
175150
176630
|
if (entry) return entry.prefix;
|
|
175151
176631
|
return `T${productType}`;
|
|
175152
176632
|
}
|
|
175153
|
-
function
|
|
176633
|
+
function pad25(n) {
|
|
175154
176634
|
return String(n).padStart(2, "0");
|
|
175155
176635
|
}
|
|
175156
176636
|
function pad4(n) {
|
|
@@ -175158,9 +176638,9 @@ function pad4(n) {
|
|
|
175158
176638
|
}
|
|
175159
176639
|
function deviceProductCodeToName(value) {
|
|
175160
176640
|
const prefix = prefixForProductType(value.productType);
|
|
175161
|
-
const yy =
|
|
175162
|
-
const mm =
|
|
175163
|
-
const dd =
|
|
176641
|
+
const yy = pad25(value.year % 100);
|
|
176642
|
+
const mm = pad25(value.month);
|
|
176643
|
+
const dd = pad25(value.day);
|
|
175164
176644
|
const unit = value.seq3 * 254 + value.seq;
|
|
175165
176645
|
return `${prefix} ${yy}${mm}${dd}-${pad4(unit)}`;
|
|
175166
176646
|
}
|
|
@@ -175269,7 +176749,7 @@ function validateDeviceProductCode(code) {
|
|
|
175269
176749
|
}
|
|
175270
176750
|
|
|
175271
176751
|
// src/components/cards/central-status/v1.0.0/styles.ts
|
|
175272
|
-
var
|
|
176752
|
+
var STYLE_ID21 = "myio-central-status-card-styles";
|
|
175273
176753
|
var CSS5 = `
|
|
175274
176754
|
.myio-cscard{
|
|
175275
176755
|
--cscard-surface:#ffffff;
|
|
@@ -175572,9 +177052,9 @@ var CSS5 = `
|
|
|
175572
177052
|
`;
|
|
175573
177053
|
function injectCentralStatusCardStyles() {
|
|
175574
177054
|
if (typeof document === "undefined") return;
|
|
175575
|
-
if (document.getElementById(
|
|
177055
|
+
if (document.getElementById(STYLE_ID21)) return;
|
|
175576
177056
|
const tag = document.createElement("style");
|
|
175577
|
-
tag.id =
|
|
177057
|
+
tag.id = STYLE_ID21;
|
|
175578
177058
|
tag.textContent = CSS5;
|
|
175579
177059
|
document.head.appendChild(tag);
|
|
175580
177060
|
}
|
|
@@ -175634,7 +177114,7 @@ function deriveCentralConnectivity(ev, opts) {
|
|
|
175634
177114
|
}
|
|
175635
177115
|
|
|
175636
177116
|
// src/components/cards/central-status/v1.0.0/TimelineModal.ts
|
|
175637
|
-
var
|
|
177117
|
+
var STYLE_ID22 = "myio-cscard-timeline-styles";
|
|
175638
177118
|
var DEFAULT_PERIODS = [1, 7, 30, 90];
|
|
175639
177119
|
function escAttr5(s) {
|
|
175640
177120
|
return String(s ?? "").replace(
|
|
@@ -175643,9 +177123,9 @@ function escAttr5(s) {
|
|
|
175643
177123
|
);
|
|
175644
177124
|
}
|
|
175645
177125
|
function injectTimelineModalStyles() {
|
|
175646
|
-
if (typeof document === "undefined" || document.getElementById(
|
|
177126
|
+
if (typeof document === "undefined" || document.getElementById(STYLE_ID22)) return;
|
|
175647
177127
|
const tag = document.createElement("style");
|
|
175648
|
-
tag.id =
|
|
177128
|
+
tag.id = STYLE_ID22;
|
|
175649
177129
|
tag.textContent = `
|
|
175650
177130
|
.myio-tlmodal{
|
|
175651
177131
|
--tl-online:#3b82f6;
|
|
@@ -176930,9 +178410,12 @@ var version = package_default.version || "0.0.0";
|
|
|
176930
178410
|
IMPORTANCE_COLORS,
|
|
176931
178411
|
IMPORTANCE_LABELS,
|
|
176932
178412
|
IMPORTANCE_LABELS_EN,
|
|
178413
|
+
ImportApiError,
|
|
176933
178414
|
InfoTooltip,
|
|
176934
178415
|
LoadingSpinner,
|
|
176935
178416
|
LogHelper,
|
|
178417
|
+
MANUAL_ASSET_SUFFIX,
|
|
178418
|
+
MANUAL_DEVICE_PROFILES,
|
|
176936
178419
|
MEASUREMENT_DOMAIN_CONFIG,
|
|
176937
178420
|
MENU_SHOPPING_CSS_PREFIX,
|
|
176938
178421
|
METRO_TILE_COLORS,
|
|
@@ -176943,6 +178426,7 @@ var version = package_default.version || "0.0.0";
|
|
|
176943
178426
|
MYIO_ACCENT,
|
|
176944
178427
|
MYIO_CHART_PALETTE,
|
|
176945
178428
|
MYIO_CHART_PALETTE_DARK,
|
|
178429
|
+
ManualDeviceError,
|
|
176946
178430
|
MenuController,
|
|
176947
178431
|
MenuShoppingView,
|
|
176948
178432
|
MenuView,
|
|
@@ -177085,6 +178569,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177085
178569
|
buildMoneyVarianceHTML,
|
|
177086
178570
|
buildMyioIngestionAuth,
|
|
177087
178571
|
buildReportItemsList,
|
|
178572
|
+
buildTemplateCsv,
|
|
177088
178573
|
buildTemplateExport,
|
|
177089
178574
|
buildTicketServiceOrchestrator,
|
|
177090
178575
|
buildVerdictHTML,
|
|
@@ -177184,6 +178669,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177184
178669
|
createLibraryVersionChecker,
|
|
177185
178670
|
createLoadingSpinner,
|
|
177186
178671
|
createLogHelper,
|
|
178672
|
+
createManualDevice,
|
|
177187
178673
|
createMenuComponent,
|
|
177188
178674
|
createMenuShoppingComponent,
|
|
177189
178675
|
createModalFooter,
|
|
@@ -177220,6 +178706,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177220
178706
|
createTbEnvelopeStore,
|
|
177221
178707
|
createTelemetryGridComponent,
|
|
177222
178708
|
createTelemetryGridShoppingComponent,
|
|
178709
|
+
createTelemetryImportApi,
|
|
177223
178710
|
createTelemetryInfoShoppingComponent,
|
|
177224
178711
|
createTicketDetailModal,
|
|
177225
178712
|
createTicketsTab,
|
|
@@ -177282,6 +178769,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177282
178769
|
fetchThingsboardCustomerAttrsFromStorage,
|
|
177283
178770
|
fetchThingsboardCustomerServerScopeAttrs,
|
|
177284
178771
|
fetchTicketsForDevice,
|
|
178772
|
+
filterWellAutomationItems,
|
|
177285
178773
|
findNode,
|
|
177286
178774
|
findValue,
|
|
177287
178775
|
findValueWithDefault,
|
|
@@ -177388,6 +178876,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177388
178876
|
hasSelectedDays,
|
|
177389
178877
|
highlightAnnotationMatches,
|
|
177390
178878
|
indicatorsFromModalData,
|
|
178879
|
+
indicatorsFromSharedWellValves,
|
|
177391
178880
|
initMyIOAuthContext,
|
|
177392
178881
|
initOnOffTimelineTooltips,
|
|
177393
178882
|
injectActionButtonStyles,
|
|
@@ -177459,6 +178948,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177459
178948
|
listDeviceProductTypes,
|
|
177460
178949
|
listDomains,
|
|
177461
178950
|
listGroups,
|
|
178951
|
+
manualDeviceName,
|
|
177462
178952
|
mapConnectionStatus,
|
|
177463
178953
|
mapDeviceStatusToCardStatus,
|
|
177464
178954
|
mapDeviceToConnectionStatus,
|
|
@@ -177467,6 +178957,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177467
178957
|
minutesToMs,
|
|
177468
178958
|
msToMinutes,
|
|
177469
178959
|
myioExportData,
|
|
178960
|
+
nextManualSeq,
|
|
177470
178961
|
nfdNormalizeAnnotationSearch,
|
|
177471
178962
|
normalizeBudgetBlock,
|
|
177472
178963
|
normalizeConnectionStatus,
|
|
@@ -177504,6 +178995,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177504
178995
|
openGoalsPanel,
|
|
177505
178996
|
openHelpModal,
|
|
177506
178997
|
openIntegrationsModal,
|
|
178998
|
+
openManualDeviceModal,
|
|
177507
178999
|
openMeasurementSetupModal,
|
|
177508
179000
|
openMessageDialog,
|
|
177509
179001
|
openMetasGuide,
|
|
@@ -177516,6 +179008,8 @@ var version = package_default.version || "0.0.0";
|
|
|
177516
179008
|
openRealTimeTelemetryModal,
|
|
177517
179009
|
openReportsHub,
|
|
177518
179010
|
openSettingsHubModal,
|
|
179011
|
+
openStandardModal,
|
|
179012
|
+
openTelemetryImportModal,
|
|
177519
179013
|
openTemperatureComparisonModal,
|
|
177520
179014
|
openTemperatureModal,
|
|
177521
179015
|
openTemperatureSettingsModal,
|
|
@@ -177530,6 +179024,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177530
179024
|
panelTermToDeviceCategory,
|
|
177531
179025
|
parseBinaryState,
|
|
177532
179026
|
parseClassificationEntities,
|
|
179027
|
+
parseCsv,
|
|
177533
179028
|
parseGcdrEnergyRoot,
|
|
177534
179029
|
parseGcdrEntityForest,
|
|
177535
179030
|
parseInputDateToDate,
|
|
@@ -177590,6 +179085,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177590
179085
|
resolveSubcategory,
|
|
177591
179086
|
resolveWithFallback,
|
|
177592
179087
|
routeMoneyRender,
|
|
179088
|
+
rowsFromTable,
|
|
177593
179089
|
schedCreateDateInput,
|
|
177594
179090
|
schedCreateNumberInput,
|
|
177595
179091
|
schedCreateSelect,
|
|
@@ -177599,8 +179095,10 @@ var version = package_default.version || "0.0.0";
|
|
|
177599
179095
|
schedShowNotificationModal,
|
|
177600
179096
|
selectBreakdownItems,
|
|
177601
179097
|
setActiveProfile,
|
|
179098
|
+
sharedWellValveIds,
|
|
177602
179099
|
shouldFlashIcon,
|
|
177603
179100
|
shouldVirtualizeAnnotationList,
|
|
179101
|
+
siglaFromManualAsset,
|
|
177604
179102
|
signOf,
|
|
177605
179103
|
slugifyCustomerName,
|
|
177606
179104
|
sortAnnotationGroups,
|
|
@@ -177630,6 +179128,7 @@ var version = package_default.version || "0.0.0";
|
|
|
177630
179128
|
validateDeviceProductName,
|
|
177631
179129
|
validateProfile,
|
|
177632
179130
|
validateTree,
|
|
179131
|
+
valveHistoryFromTelemetry,
|
|
177633
179132
|
version,
|
|
177634
179133
|
waterDeviceStatusIcons,
|
|
177635
179134
|
wireCategoryToPanel,
|