myio-js-library 0.1.65 → 0.1.67
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 +61 -17
- package/dist/index.d.cts +3 -0
- package/dist/index.js +61 -17
- package/dist/myio-js-library.umd.js +61 -17
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6599,7 +6599,7 @@ var EnergyModalView = class {
|
|
|
6599
6599
|
clientId: this.config.params.clientId || "ADMIN_DASHBOARD_CLIENT",
|
|
6600
6600
|
clientSecret: this.config.params.clientSecret || "admin_dashboard_secret_2025",
|
|
6601
6601
|
deviceId: ingestionId,
|
|
6602
|
-
readingType: "energy",
|
|
6602
|
+
readingType: this.config.params.readingType || "energy",
|
|
6603
6603
|
startDate: startISO,
|
|
6604
6604
|
endDate: endISO,
|
|
6605
6605
|
granularity,
|
|
@@ -7503,9 +7503,31 @@ var rangeDaysInclusive = (start, end) => {
|
|
|
7503
7503
|
var fmtPt = (n) => new Intl.NumberFormat("pt-BR", { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(n);
|
|
7504
7504
|
|
|
7505
7505
|
// src/components/premium-modals/report-device/DeviceReportModal.ts
|
|
7506
|
+
var DOMAIN_CONFIG = {
|
|
7507
|
+
energy: {
|
|
7508
|
+
endpoint: "energy",
|
|
7509
|
+
unit: "kWh",
|
|
7510
|
+
label: "Consumo (kWh)",
|
|
7511
|
+
formatter: (v) => fmtPt(v)
|
|
7512
|
+
},
|
|
7513
|
+
water: {
|
|
7514
|
+
endpoint: "water",
|
|
7515
|
+
unit: "m\xB3",
|
|
7516
|
+
label: "Consumo (m\xB3)",
|
|
7517
|
+
formatter: (v) => fmtPt(v)
|
|
7518
|
+
},
|
|
7519
|
+
temperature: {
|
|
7520
|
+
endpoint: "temperature",
|
|
7521
|
+
unit: "\xB0C",
|
|
7522
|
+
label: "Temperatura (\xB0C)",
|
|
7523
|
+
formatter: (v) => fmtPt(v)
|
|
7524
|
+
}
|
|
7525
|
+
};
|
|
7506
7526
|
var createDefaultEnergyFetcher = (params) => {
|
|
7507
7527
|
return async ({ baseUrl, ingestionId, startISO, endISO }) => {
|
|
7508
|
-
const
|
|
7528
|
+
const domain = params.domain || "energy";
|
|
7529
|
+
const endpoint = DOMAIN_CONFIG[domain].endpoint;
|
|
7530
|
+
const url = `${baseUrl}/api/v1/telemetry/devices/${ingestionId}/${endpoint}?startTime=${encodeURIComponent(startISO)}&endTime=${encodeURIComponent(endISO)}&granularity=1d&page=1&pageSize=1000&deep=0`;
|
|
7509
7531
|
const token = params.api.ingestionToken;
|
|
7510
7532
|
if (!token) {
|
|
7511
7533
|
throw new Error("ingestionToken is required for Data API calls to data.apps.myio-bas.com");
|
|
@@ -7531,6 +7553,8 @@ var DeviceReportModal = class {
|
|
|
7531
7553
|
clientSecret: params.api.clientSecret,
|
|
7532
7554
|
base: params.api.dataApiBaseUrl
|
|
7533
7555
|
});
|
|
7556
|
+
const domain = params.domain || "energy";
|
|
7557
|
+
this.domainConfig = DOMAIN_CONFIG[domain];
|
|
7534
7558
|
this.energyFetcher = params.fetcher || createDefaultEnergyFetcher(params);
|
|
7535
7559
|
}
|
|
7536
7560
|
modal;
|
|
@@ -7541,6 +7565,7 @@ var DeviceReportModal = class {
|
|
|
7541
7565
|
eventHandlers = {};
|
|
7542
7566
|
dateRangePicker = null;
|
|
7543
7567
|
sortState = { key: null, direction: "asc" };
|
|
7568
|
+
domainConfig;
|
|
7544
7569
|
show() {
|
|
7545
7570
|
this.modal = createModal({
|
|
7546
7571
|
title: `Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`,
|
|
@@ -7703,9 +7728,9 @@ var DeviceReportModal = class {
|
|
|
7703
7728
|
};
|
|
7704
7729
|
container.innerHTML = `
|
|
7705
7730
|
<div style="margin-bottom: 16px; padding: 12px; background: var(--myio-bg); border-radius: 6px;">
|
|
7706
|
-
<strong>Total: ${
|
|
7731
|
+
<strong>Total: ${this.domainConfig.formatter(total)} ${this.domainConfig.unit}</strong>
|
|
7707
7732
|
</div>
|
|
7708
|
-
|
|
7733
|
+
|
|
7709
7734
|
<div style="max-height: 400px; overflow-y: auto; border: 1px solid var(--myio-border); border-radius: 6px;">
|
|
7710
7735
|
<table class="myio-table">
|
|
7711
7736
|
<thead>
|
|
@@ -7715,7 +7740,7 @@ var DeviceReportModal = class {
|
|
|
7715
7740
|
<span style="margin-left: 4px; opacity: ${this.sortState.key === "date" ? "1" : "0.5"};">${getSortIndicator("date")}</span>
|
|
7716
7741
|
</th>
|
|
7717
7742
|
<th style="cursor: pointer; text-align: right;" data-sort="consumption">
|
|
7718
|
-
|
|
7743
|
+
${this.domainConfig.label}
|
|
7719
7744
|
<span style="margin-left: 4px; opacity: ${this.sortState.key === "consumption" ? "1" : "0.5"};">${getSortIndicator("consumption")}</span>
|
|
7720
7745
|
</th>
|
|
7721
7746
|
</tr>
|
|
@@ -7724,7 +7749,7 @@ var DeviceReportModal = class {
|
|
|
7724
7749
|
${this.data.map((row) => `
|
|
7725
7750
|
<tr>
|
|
7726
7751
|
<td>${this.formatDate(row.date)}</td>
|
|
7727
|
-
<td style="text-align: right;">${
|
|
7752
|
+
<td style="text-align: right;">${this.domainConfig.formatter(row.consumption)}</td>
|
|
7728
7753
|
</tr>
|
|
7729
7754
|
`).join("")}
|
|
7730
7755
|
</tbody>
|
|
@@ -7774,9 +7799,9 @@ var DeviceReportModal = class {
|
|
|
7774
7799
|
const csvData = [
|
|
7775
7800
|
["Dispositivo/Loja", this.params.identifier || "N/A", this.params.label || ""],
|
|
7776
7801
|
["DATA EMISS\xC3O", timestamp, ""],
|
|
7777
|
-
["Total",
|
|
7778
|
-
["Data",
|
|
7779
|
-
...this.data.map((row) => [this.formatDate(row.date),
|
|
7802
|
+
["Total", this.domainConfig.formatter(total), this.domainConfig.unit],
|
|
7803
|
+
["Data", this.domainConfig.label, ""],
|
|
7804
|
+
...this.data.map((row) => [this.formatDate(row.date), this.domainConfig.formatter(row.consumption)])
|
|
7780
7805
|
];
|
|
7781
7806
|
const csvContent = toCsv(csvData);
|
|
7782
7807
|
this.downloadCSV(csvContent, `relatorio-${this.params.identifier || "dispositivo"}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`);
|
|
@@ -8633,6 +8658,20 @@ function attachFilterOrderingModal(props) {
|
|
|
8633
8658
|
}
|
|
8634
8659
|
|
|
8635
8660
|
// src/components/premium-modals/report-all/AllReportModal.ts
|
|
8661
|
+
var DOMAIN_CONFIG2 = {
|
|
8662
|
+
energy: {
|
|
8663
|
+
endpoint: "energy",
|
|
8664
|
+
unit: "kWh",
|
|
8665
|
+
label: "Consumption (kWh)",
|
|
8666
|
+
totalLabel: "Total kWh"
|
|
8667
|
+
},
|
|
8668
|
+
water: {
|
|
8669
|
+
endpoint: "water",
|
|
8670
|
+
unit: "m\xB3",
|
|
8671
|
+
label: "Consumo (m\xB3)",
|
|
8672
|
+
totalLabel: "Total m\xB3"
|
|
8673
|
+
}
|
|
8674
|
+
};
|
|
8636
8675
|
var AllReportModal = class {
|
|
8637
8676
|
constructor(params) {
|
|
8638
8677
|
this.params = params;
|
|
@@ -8641,6 +8680,8 @@ var AllReportModal = class {
|
|
|
8641
8680
|
clientSecret: params.api.clientSecret,
|
|
8642
8681
|
base: params.api.dataApiBaseUrl
|
|
8643
8682
|
});
|
|
8683
|
+
const domain = params.domain || "energy";
|
|
8684
|
+
this.domainConfig = DOMAIN_CONFIG2[domain];
|
|
8644
8685
|
this.debugEnabled = params.debug === 1;
|
|
8645
8686
|
this.debugLog("\u{1F680} AllReportModal initialized", {
|
|
8646
8687
|
customerId: params.customerId,
|
|
@@ -8671,6 +8712,8 @@ var AllReportModal = class {
|
|
|
8671
8712
|
currentSortMode = "CONSUMPTION_DESC";
|
|
8672
8713
|
// Debug logging flag - controlled by params.debug
|
|
8673
8714
|
debugEnabled;
|
|
8715
|
+
// Domain configuration
|
|
8716
|
+
domainConfig;
|
|
8674
8717
|
// Debug logging helper
|
|
8675
8718
|
debugLog(message, data) {
|
|
8676
8719
|
console.log(`[AllReportModal DEBUG] ${message}`, data || "");
|
|
@@ -8924,7 +8967,7 @@ var AllReportModal = class {
|
|
|
8924
8967
|
</div>
|
|
8925
8968
|
<div style="text-align: center;">
|
|
8926
8969
|
<div style="font-size: 24px; font-weight: bold; color: var(--myio-primary);">${fmtPt(totalConsumption)}</div>
|
|
8927
|
-
<div style="color: var(--myio-text-muted);"
|
|
8970
|
+
<div style="color: var(--myio-text-muted);">${this.domainConfig.totalLabel}</div>
|
|
8928
8971
|
</div>
|
|
8929
8972
|
<div style="text-align: center;">
|
|
8930
8973
|
<div style="font-size: 24px; font-weight: bold; color: var(--myio-primary);">${fmtPt(totalConsumption / storeCount)}</div>
|
|
@@ -8999,7 +9042,7 @@ var AllReportModal = class {
|
|
|
8999
9042
|
<span style="margin-left: 4px; opacity: ${this.getSortOpacity("name")};">${this.getSortIcon("name")}</span>
|
|
9000
9043
|
</th>
|
|
9001
9044
|
<th style="cursor: pointer; text-align: right; width: 30%;" data-sort="consumption">
|
|
9002
|
-
|
|
9045
|
+
${this.domainConfig.label}
|
|
9003
9046
|
<span style="margin-left: 4px; opacity: ${this.getSortOpacity("consumption")};">${this.getSortIcon("consumption")}</span>
|
|
9004
9047
|
</th>
|
|
9005
9048
|
</tr>
|
|
@@ -9009,7 +9052,7 @@ var AllReportModal = class {
|
|
|
9009
9052
|
<tr>
|
|
9010
9053
|
<td data-label="Identifier" style="font-family: monospace; font-weight: bold; text-transform: uppercase;">${row.identifier}</td>
|
|
9011
9054
|
<td data-label="Name"><strong>${row.name}</strong></td>
|
|
9012
|
-
<td data-label="
|
|
9055
|
+
<td data-label="${this.domainConfig.label}" style="text-align: right; font-weight: bold;">${row.consumption.toFixed(2)}</td>
|
|
9013
9056
|
</tr>
|
|
9014
9057
|
`).join("")}
|
|
9015
9058
|
</tbody>
|
|
@@ -9166,11 +9209,11 @@ var AllReportModal = class {
|
|
|
9166
9209
|
["DATA EMISS\xC3O", timestamp, "", ""],
|
|
9167
9210
|
["RESUMO", "", "", ""],
|
|
9168
9211
|
["Total de Lojas", this.data.length.toString(), "", ""],
|
|
9169
|
-
["Consumo Total", totalConsumption.toFixed(2),
|
|
9170
|
-
["Consumo M\xE9dio por Loja", (totalConsumption / this.data.length).toFixed(2),
|
|
9212
|
+
["Consumo Total", totalConsumption.toFixed(2), this.domainConfig.unit, ""],
|
|
9213
|
+
["Consumo M\xE9dio por Loja", (totalConsumption / this.data.length).toFixed(2), this.domainConfig.unit, ""],
|
|
9171
9214
|
["", "", "", ""],
|
|
9172
9215
|
["DETALHAMENTO POR LOJA", "", "", ""],
|
|
9173
|
-
["Identificador", "Nome",
|
|
9216
|
+
["Identificador", "Nome", this.domainConfig.label, ""],
|
|
9174
9217
|
...sortedData.map((row) => [row.identifier, row.name, row.consumption.toFixed(2), ""])
|
|
9175
9218
|
];
|
|
9176
9219
|
const csvContent = toCsv(csvData);
|
|
@@ -9194,8 +9237,9 @@ var AllReportModal = class {
|
|
|
9194
9237
|
const baseUrl = this.params.api.dataApiBaseUrl || "https://api.data.apps.myio-bas.com";
|
|
9195
9238
|
const startTime = encodeURIComponent(startISO);
|
|
9196
9239
|
const endTime = encodeURIComponent(endISO);
|
|
9197
|
-
const
|
|
9198
|
-
|
|
9240
|
+
const endpoint = this.domainConfig.endpoint;
|
|
9241
|
+
const url = `${baseUrl}/api/v1/telemetry/customers/${this.params.customerId}/${endpoint}/devices/totals?startTime=${startTime}&endTime=${endTime}`;
|
|
9242
|
+
console.log("[AllReportModal] Fetching customer totals:", { url, customerId: this.params.customerId, domain: this.params.domain || "energy" });
|
|
9199
9243
|
const response = await fetch(url, {
|
|
9200
9244
|
method: "GET",
|
|
9201
9245
|
headers: {
|
package/dist/index.d.cts
CHANGED
|
@@ -792,6 +792,7 @@ interface OpenDeviceReportParams {
|
|
|
792
792
|
deviceId?: string;
|
|
793
793
|
identifier?: string;
|
|
794
794
|
label?: string;
|
|
795
|
+
domain?: 'energy' | 'water' | 'temperature';
|
|
795
796
|
ui?: BaseUiCfg;
|
|
796
797
|
api: BaseApiCfg;
|
|
797
798
|
fetcher?: EnergyFetcher;
|
|
@@ -810,6 +811,7 @@ interface StoreItem {
|
|
|
810
811
|
}
|
|
811
812
|
interface OpenAllReportParams {
|
|
812
813
|
customerId: string;
|
|
814
|
+
domain?: 'energy' | 'water';
|
|
813
815
|
ui?: BaseUiCfg;
|
|
814
816
|
api: BaseApiCfg;
|
|
815
817
|
itemsList: StoreItem[];
|
|
@@ -854,6 +856,7 @@ interface OpenDashboardPopupEnergyOptions {
|
|
|
854
856
|
chartsBaseUrl?: string;
|
|
855
857
|
timezone?: string;
|
|
856
858
|
theme?: 'light' | 'dark' | string;
|
|
859
|
+
readingType?: 'energy' | 'water' | 'tank';
|
|
857
860
|
granularity?: '1d' | '1h' | '15m';
|
|
858
861
|
closeOnEsc?: boolean;
|
|
859
862
|
zIndex?: number;
|
package/dist/index.js
CHANGED
|
@@ -6525,7 +6525,7 @@ var EnergyModalView = class {
|
|
|
6525
6525
|
clientId: this.config.params.clientId || "ADMIN_DASHBOARD_CLIENT",
|
|
6526
6526
|
clientSecret: this.config.params.clientSecret || "admin_dashboard_secret_2025",
|
|
6527
6527
|
deviceId: ingestionId,
|
|
6528
|
-
readingType: "energy",
|
|
6528
|
+
readingType: this.config.params.readingType || "energy",
|
|
6529
6529
|
startDate: startISO,
|
|
6530
6530
|
endDate: endISO,
|
|
6531
6531
|
granularity,
|
|
@@ -7429,9 +7429,31 @@ var rangeDaysInclusive = (start, end) => {
|
|
|
7429
7429
|
var fmtPt = (n) => new Intl.NumberFormat("pt-BR", { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(n);
|
|
7430
7430
|
|
|
7431
7431
|
// src/components/premium-modals/report-device/DeviceReportModal.ts
|
|
7432
|
+
var DOMAIN_CONFIG = {
|
|
7433
|
+
energy: {
|
|
7434
|
+
endpoint: "energy",
|
|
7435
|
+
unit: "kWh",
|
|
7436
|
+
label: "Consumo (kWh)",
|
|
7437
|
+
formatter: (v) => fmtPt(v)
|
|
7438
|
+
},
|
|
7439
|
+
water: {
|
|
7440
|
+
endpoint: "water",
|
|
7441
|
+
unit: "m\xB3",
|
|
7442
|
+
label: "Consumo (m\xB3)",
|
|
7443
|
+
formatter: (v) => fmtPt(v)
|
|
7444
|
+
},
|
|
7445
|
+
temperature: {
|
|
7446
|
+
endpoint: "temperature",
|
|
7447
|
+
unit: "\xB0C",
|
|
7448
|
+
label: "Temperatura (\xB0C)",
|
|
7449
|
+
formatter: (v) => fmtPt(v)
|
|
7450
|
+
}
|
|
7451
|
+
};
|
|
7432
7452
|
var createDefaultEnergyFetcher = (params) => {
|
|
7433
7453
|
return async ({ baseUrl, ingestionId, startISO, endISO }) => {
|
|
7434
|
-
const
|
|
7454
|
+
const domain = params.domain || "energy";
|
|
7455
|
+
const endpoint = DOMAIN_CONFIG[domain].endpoint;
|
|
7456
|
+
const url = `${baseUrl}/api/v1/telemetry/devices/${ingestionId}/${endpoint}?startTime=${encodeURIComponent(startISO)}&endTime=${encodeURIComponent(endISO)}&granularity=1d&page=1&pageSize=1000&deep=0`;
|
|
7435
7457
|
const token = params.api.ingestionToken;
|
|
7436
7458
|
if (!token) {
|
|
7437
7459
|
throw new Error("ingestionToken is required for Data API calls to data.apps.myio-bas.com");
|
|
@@ -7457,6 +7479,8 @@ var DeviceReportModal = class {
|
|
|
7457
7479
|
clientSecret: params.api.clientSecret,
|
|
7458
7480
|
base: params.api.dataApiBaseUrl
|
|
7459
7481
|
});
|
|
7482
|
+
const domain = params.domain || "energy";
|
|
7483
|
+
this.domainConfig = DOMAIN_CONFIG[domain];
|
|
7460
7484
|
this.energyFetcher = params.fetcher || createDefaultEnergyFetcher(params);
|
|
7461
7485
|
}
|
|
7462
7486
|
modal;
|
|
@@ -7467,6 +7491,7 @@ var DeviceReportModal = class {
|
|
|
7467
7491
|
eventHandlers = {};
|
|
7468
7492
|
dateRangePicker = null;
|
|
7469
7493
|
sortState = { key: null, direction: "asc" };
|
|
7494
|
+
domainConfig;
|
|
7470
7495
|
show() {
|
|
7471
7496
|
this.modal = createModal({
|
|
7472
7497
|
title: `Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`,
|
|
@@ -7629,9 +7654,9 @@ var DeviceReportModal = class {
|
|
|
7629
7654
|
};
|
|
7630
7655
|
container.innerHTML = `
|
|
7631
7656
|
<div style="margin-bottom: 16px; padding: 12px; background: var(--myio-bg); border-radius: 6px;">
|
|
7632
|
-
<strong>Total: ${
|
|
7657
|
+
<strong>Total: ${this.domainConfig.formatter(total)} ${this.domainConfig.unit}</strong>
|
|
7633
7658
|
</div>
|
|
7634
|
-
|
|
7659
|
+
|
|
7635
7660
|
<div style="max-height: 400px; overflow-y: auto; border: 1px solid var(--myio-border); border-radius: 6px;">
|
|
7636
7661
|
<table class="myio-table">
|
|
7637
7662
|
<thead>
|
|
@@ -7641,7 +7666,7 @@ var DeviceReportModal = class {
|
|
|
7641
7666
|
<span style="margin-left: 4px; opacity: ${this.sortState.key === "date" ? "1" : "0.5"};">${getSortIndicator("date")}</span>
|
|
7642
7667
|
</th>
|
|
7643
7668
|
<th style="cursor: pointer; text-align: right;" data-sort="consumption">
|
|
7644
|
-
|
|
7669
|
+
${this.domainConfig.label}
|
|
7645
7670
|
<span style="margin-left: 4px; opacity: ${this.sortState.key === "consumption" ? "1" : "0.5"};">${getSortIndicator("consumption")}</span>
|
|
7646
7671
|
</th>
|
|
7647
7672
|
</tr>
|
|
@@ -7650,7 +7675,7 @@ var DeviceReportModal = class {
|
|
|
7650
7675
|
${this.data.map((row) => `
|
|
7651
7676
|
<tr>
|
|
7652
7677
|
<td>${this.formatDate(row.date)}</td>
|
|
7653
|
-
<td style="text-align: right;">${
|
|
7678
|
+
<td style="text-align: right;">${this.domainConfig.formatter(row.consumption)}</td>
|
|
7654
7679
|
</tr>
|
|
7655
7680
|
`).join("")}
|
|
7656
7681
|
</tbody>
|
|
@@ -7700,9 +7725,9 @@ var DeviceReportModal = class {
|
|
|
7700
7725
|
const csvData = [
|
|
7701
7726
|
["Dispositivo/Loja", this.params.identifier || "N/A", this.params.label || ""],
|
|
7702
7727
|
["DATA EMISS\xC3O", timestamp, ""],
|
|
7703
|
-
["Total",
|
|
7704
|
-
["Data",
|
|
7705
|
-
...this.data.map((row) => [this.formatDate(row.date),
|
|
7728
|
+
["Total", this.domainConfig.formatter(total), this.domainConfig.unit],
|
|
7729
|
+
["Data", this.domainConfig.label, ""],
|
|
7730
|
+
...this.data.map((row) => [this.formatDate(row.date), this.domainConfig.formatter(row.consumption)])
|
|
7706
7731
|
];
|
|
7707
7732
|
const csvContent = toCsv(csvData);
|
|
7708
7733
|
this.downloadCSV(csvContent, `relatorio-${this.params.identifier || "dispositivo"}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`);
|
|
@@ -8559,6 +8584,20 @@ function attachFilterOrderingModal(props) {
|
|
|
8559
8584
|
}
|
|
8560
8585
|
|
|
8561
8586
|
// src/components/premium-modals/report-all/AllReportModal.ts
|
|
8587
|
+
var DOMAIN_CONFIG2 = {
|
|
8588
|
+
energy: {
|
|
8589
|
+
endpoint: "energy",
|
|
8590
|
+
unit: "kWh",
|
|
8591
|
+
label: "Consumption (kWh)",
|
|
8592
|
+
totalLabel: "Total kWh"
|
|
8593
|
+
},
|
|
8594
|
+
water: {
|
|
8595
|
+
endpoint: "water",
|
|
8596
|
+
unit: "m\xB3",
|
|
8597
|
+
label: "Consumo (m\xB3)",
|
|
8598
|
+
totalLabel: "Total m\xB3"
|
|
8599
|
+
}
|
|
8600
|
+
};
|
|
8562
8601
|
var AllReportModal = class {
|
|
8563
8602
|
constructor(params) {
|
|
8564
8603
|
this.params = params;
|
|
@@ -8567,6 +8606,8 @@ var AllReportModal = class {
|
|
|
8567
8606
|
clientSecret: params.api.clientSecret,
|
|
8568
8607
|
base: params.api.dataApiBaseUrl
|
|
8569
8608
|
});
|
|
8609
|
+
const domain = params.domain || "energy";
|
|
8610
|
+
this.domainConfig = DOMAIN_CONFIG2[domain];
|
|
8570
8611
|
this.debugEnabled = params.debug === 1;
|
|
8571
8612
|
this.debugLog("\u{1F680} AllReportModal initialized", {
|
|
8572
8613
|
customerId: params.customerId,
|
|
@@ -8597,6 +8638,8 @@ var AllReportModal = class {
|
|
|
8597
8638
|
currentSortMode = "CONSUMPTION_DESC";
|
|
8598
8639
|
// Debug logging flag - controlled by params.debug
|
|
8599
8640
|
debugEnabled;
|
|
8641
|
+
// Domain configuration
|
|
8642
|
+
domainConfig;
|
|
8600
8643
|
// Debug logging helper
|
|
8601
8644
|
debugLog(message, data) {
|
|
8602
8645
|
console.log(`[AllReportModal DEBUG] ${message}`, data || "");
|
|
@@ -8850,7 +8893,7 @@ var AllReportModal = class {
|
|
|
8850
8893
|
</div>
|
|
8851
8894
|
<div style="text-align: center;">
|
|
8852
8895
|
<div style="font-size: 24px; font-weight: bold; color: var(--myio-primary);">${fmtPt(totalConsumption)}</div>
|
|
8853
|
-
<div style="color: var(--myio-text-muted);"
|
|
8896
|
+
<div style="color: var(--myio-text-muted);">${this.domainConfig.totalLabel}</div>
|
|
8854
8897
|
</div>
|
|
8855
8898
|
<div style="text-align: center;">
|
|
8856
8899
|
<div style="font-size: 24px; font-weight: bold; color: var(--myio-primary);">${fmtPt(totalConsumption / storeCount)}</div>
|
|
@@ -8925,7 +8968,7 @@ var AllReportModal = class {
|
|
|
8925
8968
|
<span style="margin-left: 4px; opacity: ${this.getSortOpacity("name")};">${this.getSortIcon("name")}</span>
|
|
8926
8969
|
</th>
|
|
8927
8970
|
<th style="cursor: pointer; text-align: right; width: 30%;" data-sort="consumption">
|
|
8928
|
-
|
|
8971
|
+
${this.domainConfig.label}
|
|
8929
8972
|
<span style="margin-left: 4px; opacity: ${this.getSortOpacity("consumption")};">${this.getSortIcon("consumption")}</span>
|
|
8930
8973
|
</th>
|
|
8931
8974
|
</tr>
|
|
@@ -8935,7 +8978,7 @@ var AllReportModal = class {
|
|
|
8935
8978
|
<tr>
|
|
8936
8979
|
<td data-label="Identifier" style="font-family: monospace; font-weight: bold; text-transform: uppercase;">${row.identifier}</td>
|
|
8937
8980
|
<td data-label="Name"><strong>${row.name}</strong></td>
|
|
8938
|
-
<td data-label="
|
|
8981
|
+
<td data-label="${this.domainConfig.label}" style="text-align: right; font-weight: bold;">${row.consumption.toFixed(2)}</td>
|
|
8939
8982
|
</tr>
|
|
8940
8983
|
`).join("")}
|
|
8941
8984
|
</tbody>
|
|
@@ -9092,11 +9135,11 @@ var AllReportModal = class {
|
|
|
9092
9135
|
["DATA EMISS\xC3O", timestamp, "", ""],
|
|
9093
9136
|
["RESUMO", "", "", ""],
|
|
9094
9137
|
["Total de Lojas", this.data.length.toString(), "", ""],
|
|
9095
|
-
["Consumo Total", totalConsumption.toFixed(2),
|
|
9096
|
-
["Consumo M\xE9dio por Loja", (totalConsumption / this.data.length).toFixed(2),
|
|
9138
|
+
["Consumo Total", totalConsumption.toFixed(2), this.domainConfig.unit, ""],
|
|
9139
|
+
["Consumo M\xE9dio por Loja", (totalConsumption / this.data.length).toFixed(2), this.domainConfig.unit, ""],
|
|
9097
9140
|
["", "", "", ""],
|
|
9098
9141
|
["DETALHAMENTO POR LOJA", "", "", ""],
|
|
9099
|
-
["Identificador", "Nome",
|
|
9142
|
+
["Identificador", "Nome", this.domainConfig.label, ""],
|
|
9100
9143
|
...sortedData.map((row) => [row.identifier, row.name, row.consumption.toFixed(2), ""])
|
|
9101
9144
|
];
|
|
9102
9145
|
const csvContent = toCsv(csvData);
|
|
@@ -9120,8 +9163,9 @@ var AllReportModal = class {
|
|
|
9120
9163
|
const baseUrl = this.params.api.dataApiBaseUrl || "https://api.data.apps.myio-bas.com";
|
|
9121
9164
|
const startTime = encodeURIComponent(startISO);
|
|
9122
9165
|
const endTime = encodeURIComponent(endISO);
|
|
9123
|
-
const
|
|
9124
|
-
|
|
9166
|
+
const endpoint = this.domainConfig.endpoint;
|
|
9167
|
+
const url = `${baseUrl}/api/v1/telemetry/customers/${this.params.customerId}/${endpoint}/devices/totals?startTime=${startTime}&endTime=${endTime}`;
|
|
9168
|
+
console.log("[AllReportModal] Fetching customer totals:", { url, customerId: this.params.customerId, domain: this.params.domain || "energy" });
|
|
9125
9169
|
const response = await fetch(url, {
|
|
9126
9170
|
method: "GET",
|
|
9127
9171
|
headers: {
|
|
@@ -6514,7 +6514,7 @@
|
|
|
6514
6514
|
clientId: this.config.params.clientId || "ADMIN_DASHBOARD_CLIENT",
|
|
6515
6515
|
clientSecret: this.config.params.clientSecret || "admin_dashboard_secret_2025",
|
|
6516
6516
|
deviceId: ingestionId,
|
|
6517
|
-
readingType: "energy",
|
|
6517
|
+
readingType: this.config.params.readingType || "energy",
|
|
6518
6518
|
startDate: startISO,
|
|
6519
6519
|
endDate: endISO,
|
|
6520
6520
|
granularity,
|
|
@@ -7418,9 +7418,31 @@
|
|
|
7418
7418
|
var fmtPt = (n) => new Intl.NumberFormat("pt-BR", { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(n);
|
|
7419
7419
|
|
|
7420
7420
|
// src/components/premium-modals/report-device/DeviceReportModal.ts
|
|
7421
|
+
var DOMAIN_CONFIG = {
|
|
7422
|
+
energy: {
|
|
7423
|
+
endpoint: "energy",
|
|
7424
|
+
unit: "kWh",
|
|
7425
|
+
label: "Consumo (kWh)",
|
|
7426
|
+
formatter: (v) => fmtPt(v)
|
|
7427
|
+
},
|
|
7428
|
+
water: {
|
|
7429
|
+
endpoint: "water",
|
|
7430
|
+
unit: "m\xB3",
|
|
7431
|
+
label: "Consumo (m\xB3)",
|
|
7432
|
+
formatter: (v) => fmtPt(v)
|
|
7433
|
+
},
|
|
7434
|
+
temperature: {
|
|
7435
|
+
endpoint: "temperature",
|
|
7436
|
+
unit: "\xB0C",
|
|
7437
|
+
label: "Temperatura (\xB0C)",
|
|
7438
|
+
formatter: (v) => fmtPt(v)
|
|
7439
|
+
}
|
|
7440
|
+
};
|
|
7421
7441
|
var createDefaultEnergyFetcher = (params) => {
|
|
7422
7442
|
return async ({ baseUrl, ingestionId, startISO, endISO }) => {
|
|
7423
|
-
const
|
|
7443
|
+
const domain = params.domain || "energy";
|
|
7444
|
+
const endpoint = DOMAIN_CONFIG[domain].endpoint;
|
|
7445
|
+
const url = `${baseUrl}/api/v1/telemetry/devices/${ingestionId}/${endpoint}?startTime=${encodeURIComponent(startISO)}&endTime=${encodeURIComponent(endISO)}&granularity=1d&page=1&pageSize=1000&deep=0`;
|
|
7424
7446
|
const token = params.api.ingestionToken;
|
|
7425
7447
|
if (!token) {
|
|
7426
7448
|
throw new Error("ingestionToken is required for Data API calls to data.apps.myio-bas.com");
|
|
@@ -7446,6 +7468,8 @@
|
|
|
7446
7468
|
clientSecret: params.api.clientSecret,
|
|
7447
7469
|
base: params.api.dataApiBaseUrl
|
|
7448
7470
|
});
|
|
7471
|
+
const domain = params.domain || "energy";
|
|
7472
|
+
this.domainConfig = DOMAIN_CONFIG[domain];
|
|
7449
7473
|
this.energyFetcher = params.fetcher || createDefaultEnergyFetcher(params);
|
|
7450
7474
|
}
|
|
7451
7475
|
modal;
|
|
@@ -7456,6 +7480,7 @@
|
|
|
7456
7480
|
eventHandlers = {};
|
|
7457
7481
|
dateRangePicker = null;
|
|
7458
7482
|
sortState = { key: null, direction: "asc" };
|
|
7483
|
+
domainConfig;
|
|
7459
7484
|
show() {
|
|
7460
7485
|
this.modal = createModal({
|
|
7461
7486
|
title: `Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`,
|
|
@@ -7618,9 +7643,9 @@
|
|
|
7618
7643
|
};
|
|
7619
7644
|
container.innerHTML = `
|
|
7620
7645
|
<div style="margin-bottom: 16px; padding: 12px; background: var(--myio-bg); border-radius: 6px;">
|
|
7621
|
-
<strong>Total: ${
|
|
7646
|
+
<strong>Total: ${this.domainConfig.formatter(total)} ${this.domainConfig.unit}</strong>
|
|
7622
7647
|
</div>
|
|
7623
|
-
|
|
7648
|
+
|
|
7624
7649
|
<div style="max-height: 400px; overflow-y: auto; border: 1px solid var(--myio-border); border-radius: 6px;">
|
|
7625
7650
|
<table class="myio-table">
|
|
7626
7651
|
<thead>
|
|
@@ -7630,7 +7655,7 @@
|
|
|
7630
7655
|
<span style="margin-left: 4px; opacity: ${this.sortState.key === "date" ? "1" : "0.5"};">${getSortIndicator("date")}</span>
|
|
7631
7656
|
</th>
|
|
7632
7657
|
<th style="cursor: pointer; text-align: right;" data-sort="consumption">
|
|
7633
|
-
|
|
7658
|
+
${this.domainConfig.label}
|
|
7634
7659
|
<span style="margin-left: 4px; opacity: ${this.sortState.key === "consumption" ? "1" : "0.5"};">${getSortIndicator("consumption")}</span>
|
|
7635
7660
|
</th>
|
|
7636
7661
|
</tr>
|
|
@@ -7639,7 +7664,7 @@
|
|
|
7639
7664
|
${this.data.map((row) => `
|
|
7640
7665
|
<tr>
|
|
7641
7666
|
<td>${this.formatDate(row.date)}</td>
|
|
7642
|
-
<td style="text-align: right;">${
|
|
7667
|
+
<td style="text-align: right;">${this.domainConfig.formatter(row.consumption)}</td>
|
|
7643
7668
|
</tr>
|
|
7644
7669
|
`).join("")}
|
|
7645
7670
|
</tbody>
|
|
@@ -7689,9 +7714,9 @@
|
|
|
7689
7714
|
const csvData = [
|
|
7690
7715
|
["Dispositivo/Loja", this.params.identifier || "N/A", this.params.label || ""],
|
|
7691
7716
|
["DATA EMISS\xC3O", timestamp, ""],
|
|
7692
|
-
["Total",
|
|
7693
|
-
["Data",
|
|
7694
|
-
...this.data.map((row) => [this.formatDate(row.date),
|
|
7717
|
+
["Total", this.domainConfig.formatter(total), this.domainConfig.unit],
|
|
7718
|
+
["Data", this.domainConfig.label, ""],
|
|
7719
|
+
...this.data.map((row) => [this.formatDate(row.date), this.domainConfig.formatter(row.consumption)])
|
|
7695
7720
|
];
|
|
7696
7721
|
const csvContent = toCsv(csvData);
|
|
7697
7722
|
this.downloadCSV(csvContent, `relatorio-${this.params.identifier || "dispositivo"}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`);
|
|
@@ -8548,6 +8573,20 @@
|
|
|
8548
8573
|
}
|
|
8549
8574
|
|
|
8550
8575
|
// src/components/premium-modals/report-all/AllReportModal.ts
|
|
8576
|
+
var DOMAIN_CONFIG2 = {
|
|
8577
|
+
energy: {
|
|
8578
|
+
endpoint: "energy",
|
|
8579
|
+
unit: "kWh",
|
|
8580
|
+
label: "Consumption (kWh)",
|
|
8581
|
+
totalLabel: "Total kWh"
|
|
8582
|
+
},
|
|
8583
|
+
water: {
|
|
8584
|
+
endpoint: "water",
|
|
8585
|
+
unit: "m\xB3",
|
|
8586
|
+
label: "Consumo (m\xB3)",
|
|
8587
|
+
totalLabel: "Total m\xB3"
|
|
8588
|
+
}
|
|
8589
|
+
};
|
|
8551
8590
|
var AllReportModal = class {
|
|
8552
8591
|
constructor(params) {
|
|
8553
8592
|
this.params = params;
|
|
@@ -8556,6 +8595,8 @@
|
|
|
8556
8595
|
clientSecret: params.api.clientSecret,
|
|
8557
8596
|
base: params.api.dataApiBaseUrl
|
|
8558
8597
|
});
|
|
8598
|
+
const domain = params.domain || "energy";
|
|
8599
|
+
this.domainConfig = DOMAIN_CONFIG2[domain];
|
|
8559
8600
|
this.debugEnabled = params.debug === 1;
|
|
8560
8601
|
this.debugLog("\u{1F680} AllReportModal initialized", {
|
|
8561
8602
|
customerId: params.customerId,
|
|
@@ -8586,6 +8627,8 @@
|
|
|
8586
8627
|
currentSortMode = "CONSUMPTION_DESC";
|
|
8587
8628
|
// Debug logging flag - controlled by params.debug
|
|
8588
8629
|
debugEnabled;
|
|
8630
|
+
// Domain configuration
|
|
8631
|
+
domainConfig;
|
|
8589
8632
|
// Debug logging helper
|
|
8590
8633
|
debugLog(message, data) {
|
|
8591
8634
|
console.log(`[AllReportModal DEBUG] ${message}`, data || "");
|
|
@@ -8839,7 +8882,7 @@
|
|
|
8839
8882
|
</div>
|
|
8840
8883
|
<div style="text-align: center;">
|
|
8841
8884
|
<div style="font-size: 24px; font-weight: bold; color: var(--myio-primary);">${fmtPt(totalConsumption)}</div>
|
|
8842
|
-
<div style="color: var(--myio-text-muted);"
|
|
8885
|
+
<div style="color: var(--myio-text-muted);">${this.domainConfig.totalLabel}</div>
|
|
8843
8886
|
</div>
|
|
8844
8887
|
<div style="text-align: center;">
|
|
8845
8888
|
<div style="font-size: 24px; font-weight: bold; color: var(--myio-primary);">${fmtPt(totalConsumption / storeCount)}</div>
|
|
@@ -8914,7 +8957,7 @@
|
|
|
8914
8957
|
<span style="margin-left: 4px; opacity: ${this.getSortOpacity("name")};">${this.getSortIcon("name")}</span>
|
|
8915
8958
|
</th>
|
|
8916
8959
|
<th style="cursor: pointer; text-align: right; width: 30%;" data-sort="consumption">
|
|
8917
|
-
|
|
8960
|
+
${this.domainConfig.label}
|
|
8918
8961
|
<span style="margin-left: 4px; opacity: ${this.getSortOpacity("consumption")};">${this.getSortIcon("consumption")}</span>
|
|
8919
8962
|
</th>
|
|
8920
8963
|
</tr>
|
|
@@ -8924,7 +8967,7 @@
|
|
|
8924
8967
|
<tr>
|
|
8925
8968
|
<td data-label="Identifier" style="font-family: monospace; font-weight: bold; text-transform: uppercase;">${row.identifier}</td>
|
|
8926
8969
|
<td data-label="Name"><strong>${row.name}</strong></td>
|
|
8927
|
-
<td data-label="
|
|
8970
|
+
<td data-label="${this.domainConfig.label}" style="text-align: right; font-weight: bold;">${row.consumption.toFixed(2)}</td>
|
|
8928
8971
|
</tr>
|
|
8929
8972
|
`).join("")}
|
|
8930
8973
|
</tbody>
|
|
@@ -9081,11 +9124,11 @@
|
|
|
9081
9124
|
["DATA EMISS\xC3O", timestamp, "", ""],
|
|
9082
9125
|
["RESUMO", "", "", ""],
|
|
9083
9126
|
["Total de Lojas", this.data.length.toString(), "", ""],
|
|
9084
|
-
["Consumo Total", totalConsumption.toFixed(2),
|
|
9085
|
-
["Consumo M\xE9dio por Loja", (totalConsumption / this.data.length).toFixed(2),
|
|
9127
|
+
["Consumo Total", totalConsumption.toFixed(2), this.domainConfig.unit, ""],
|
|
9128
|
+
["Consumo M\xE9dio por Loja", (totalConsumption / this.data.length).toFixed(2), this.domainConfig.unit, ""],
|
|
9086
9129
|
["", "", "", ""],
|
|
9087
9130
|
["DETALHAMENTO POR LOJA", "", "", ""],
|
|
9088
|
-
["Identificador", "Nome",
|
|
9131
|
+
["Identificador", "Nome", this.domainConfig.label, ""],
|
|
9089
9132
|
...sortedData.map((row) => [row.identifier, row.name, row.consumption.toFixed(2), ""])
|
|
9090
9133
|
];
|
|
9091
9134
|
const csvContent = toCsv(csvData);
|
|
@@ -9109,8 +9152,9 @@
|
|
|
9109
9152
|
const baseUrl = this.params.api.dataApiBaseUrl || "https://api.data.apps.myio-bas.com";
|
|
9110
9153
|
const startTime = encodeURIComponent(startISO);
|
|
9111
9154
|
const endTime = encodeURIComponent(endISO);
|
|
9112
|
-
const
|
|
9113
|
-
|
|
9155
|
+
const endpoint = this.domainConfig.endpoint;
|
|
9156
|
+
const url = `${baseUrl}/api/v1/telemetry/customers/${this.params.customerId}/${endpoint}/devices/totals?startTime=${startTime}&endTime=${endTime}`;
|
|
9157
|
+
console.log("[AllReportModal] Fetching customer totals:", { url, customerId: this.params.customerId, domain: this.params.domain || "energy" });
|
|
9114
9158
|
const response = await fetch(url, {
|
|
9115
9159
|
method: "GET",
|
|
9116
9160
|
headers: {
|