myio-js-library 0.1.174 → 0.1.177
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 +334 -117
- package/dist/index.d.cts +22 -18
- package/dist/index.js +334 -117
- package/dist/myio-js-library.umd.js +334 -117
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
|
@@ -16457,35 +16457,72 @@ ${rangeText}`;
|
|
|
16457
16457
|
}
|
|
16458
16458
|
|
|
16459
16459
|
// src/components/premium-modals/power-limits/types.ts
|
|
16460
|
+
var DOMAINS = [
|
|
16461
|
+
{ value: "energy", label: "Energia", icon: "\u26A1" },
|
|
16462
|
+
{ value: "water", label: "\xC1gua", icon: "\u{1F4A7}" },
|
|
16463
|
+
{ value: "temperature", label: "Temperatura", icon: "\u{1F321}\uFE0F" }
|
|
16464
|
+
];
|
|
16460
16465
|
var DEVICE_TYPES = [
|
|
16461
|
-
{ value: "ELEVADOR", label: "
|
|
16462
|
-
{ value: "ESCADA_ROLANTE", label: "
|
|
16466
|
+
{ value: "ELEVADOR", label: "Elevador" },
|
|
16467
|
+
{ value: "ESCADA_ROLANTE", label: "Escada Rolante" },
|
|
16463
16468
|
{ value: "MOTOR", label: "Motor" },
|
|
16464
|
-
{ value: "BOMBA", label: "
|
|
16469
|
+
{ value: "BOMBA", label: "Bomba" },
|
|
16465
16470
|
{ value: "CHILLER", label: "Chiller" },
|
|
16466
|
-
{ value: "AR_CONDICIONADO", label: "
|
|
16471
|
+
{ value: "AR_CONDICIONADO", label: "Ar Condicionado" },
|
|
16467
16472
|
{ value: "HVAC", label: "HVAC" },
|
|
16468
16473
|
{ value: "FANCOIL", label: "Fancoil" },
|
|
16469
|
-
{ value: "3F_MEDIDOR", label: "
|
|
16474
|
+
{ value: "3F_MEDIDOR", label: "Medidor Trif\xE1sico" }
|
|
16470
16475
|
];
|
|
16471
16476
|
var TELEMETRY_TYPES2 = [
|
|
16472
|
-
{ value: "consumption", label: "
|
|
16473
|
-
{ value: "voltage_a", label: "
|
|
16474
|
-
{ value: "voltage_b", label: "
|
|
16475
|
-
{ value: "voltage_c", label: "
|
|
16476
|
-
{ value: "current_a", label: "
|
|
16477
|
-
{ value: "current_b", label: "
|
|
16478
|
-
{ value: "current_c", label: "
|
|
16479
|
-
{ value: "total_current", label: "Total
|
|
16480
|
-
{ value: "fp_a", label: "
|
|
16481
|
-
{ value: "fp_b", label: "
|
|
16482
|
-
{ value: "fp_c", label: "
|
|
16477
|
+
{ value: "consumption", label: "Pot\xEAncia (kW)", unit: "kW" },
|
|
16478
|
+
{ value: "voltage_a", label: "Tens\xE3o A (V)", unit: "V" },
|
|
16479
|
+
{ value: "voltage_b", label: "Tens\xE3o B (V)", unit: "V" },
|
|
16480
|
+
{ value: "voltage_c", label: "Tens\xE3o C (V)", unit: "V" },
|
|
16481
|
+
{ value: "current_a", label: "Corrente A (A)", unit: "A" },
|
|
16482
|
+
{ value: "current_b", label: "Corrente B (A)", unit: "A" },
|
|
16483
|
+
{ value: "current_c", label: "Corrente C (A)", unit: "A" },
|
|
16484
|
+
{ value: "total_current", label: "Corrente Total (A)", unit: "A" },
|
|
16485
|
+
{ value: "fp_a", label: "Fator de Pot\xEAncia A", unit: "" },
|
|
16486
|
+
{ value: "fp_b", label: "Fator de Pot\xEAncia B", unit: "" },
|
|
16487
|
+
{ value: "fp_c", label: "Fator de Pot\xEAncia C", unit: "" }
|
|
16483
16488
|
];
|
|
16489
|
+
var STATUS_ICONS = {
|
|
16490
|
+
energy: {
|
|
16491
|
+
standBy: "\u{1F50C}",
|
|
16492
|
+
// STANDBY
|
|
16493
|
+
normal: "\u26A1",
|
|
16494
|
+
// POWER_ON
|
|
16495
|
+
alert: "\u26A0\uFE0F",
|
|
16496
|
+
// WARNING
|
|
16497
|
+
failure: "\u{1F6A8}"
|
|
16498
|
+
// FAILURE
|
|
16499
|
+
},
|
|
16500
|
+
water: {
|
|
16501
|
+
standBy: "\u{1F6B0}",
|
|
16502
|
+
// STANDBY
|
|
16503
|
+
normal: "\u{1F4A7}",
|
|
16504
|
+
// POWER_ON
|
|
16505
|
+
alert: "\u26A0\uFE0F",
|
|
16506
|
+
// WARNING
|
|
16507
|
+
failure: "\u{1F6A8}"
|
|
16508
|
+
// FAILURE
|
|
16509
|
+
},
|
|
16510
|
+
temperature: {
|
|
16511
|
+
standBy: "\u{1F321}\uFE0F",
|
|
16512
|
+
// STANDBY
|
|
16513
|
+
normal: "\u{1F321}\uFE0F",
|
|
16514
|
+
// POWER_ON
|
|
16515
|
+
alert: "\u26A0\uFE0F",
|
|
16516
|
+
// WARNING
|
|
16517
|
+
failure: "\u{1F6A8}"
|
|
16518
|
+
// FAILURE
|
|
16519
|
+
}
|
|
16520
|
+
};
|
|
16484
16521
|
var STATUS_CONFIG = {
|
|
16485
16522
|
standBy: { label: "StandBy", color: "#22c55e", bgColor: "rgba(34, 197, 94, 0.1)" },
|
|
16486
16523
|
normal: { label: "Normal", color: "#3b82f6", bgColor: "rgba(59, 130, 246, 0.1)" },
|
|
16487
|
-
alert: { label: "
|
|
16488
|
-
failure: { label: "
|
|
16524
|
+
alert: { label: "Alerta", color: "#f59e0b", bgColor: "rgba(245, 158, 11, 0.1)" },
|
|
16525
|
+
failure: { label: "Falha", color: "#ef4444", bgColor: "rgba(239, 68, 68, 0.1)" }
|
|
16489
16526
|
};
|
|
16490
16527
|
|
|
16491
16528
|
// src/components/premium-modals/power-limits/PowerLimitsModalView.ts
|
|
@@ -16501,12 +16538,43 @@ ${rangeText}`;
|
|
|
16501
16538
|
this.formData = {
|
|
16502
16539
|
deviceType: config.deviceType,
|
|
16503
16540
|
telemetryType: config.telemetryType,
|
|
16541
|
+
domain: config.domain,
|
|
16504
16542
|
standby: { baseValue: null, topValue: null },
|
|
16505
16543
|
normal: { baseValue: null, topValue: null },
|
|
16506
16544
|
alert: { baseValue: null, topValue: null },
|
|
16507
16545
|
failure: { baseValue: null, topValue: null }
|
|
16508
16546
|
};
|
|
16509
16547
|
}
|
|
16548
|
+
// Format number with thousand separator (.) and up to 2 decimal places
|
|
16549
|
+
formatNumberForDisplay(value) {
|
|
16550
|
+
if (value === null || value === void 0) return "";
|
|
16551
|
+
const parts = value.toFixed(2).split(".");
|
|
16552
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
16553
|
+
return parts.join(",");
|
|
16554
|
+
}
|
|
16555
|
+
// Parse formatted string back to number
|
|
16556
|
+
parseFormattedNumber(value) {
|
|
16557
|
+
if (!value || value.trim() === "") return null;
|
|
16558
|
+
const normalized = value.replace(/\./g, "").replace(",", ".");
|
|
16559
|
+
const num = parseFloat(normalized);
|
|
16560
|
+
return isNaN(num) ? null : num;
|
|
16561
|
+
}
|
|
16562
|
+
// Handle input formatting on blur
|
|
16563
|
+
formatInputValue(input) {
|
|
16564
|
+
const rawValue = input.value;
|
|
16565
|
+
const parsed = this.parseFormattedNumber(rawValue);
|
|
16566
|
+
if (parsed !== null) {
|
|
16567
|
+
input.value = this.formatNumberForDisplay(parsed);
|
|
16568
|
+
}
|
|
16569
|
+
}
|
|
16570
|
+
// Handle input on focus - show raw value for editing
|
|
16571
|
+
unformatInputValue(input) {
|
|
16572
|
+
const formatted = input.value;
|
|
16573
|
+
const parsed = this.parseFormattedNumber(formatted);
|
|
16574
|
+
if (parsed !== null) {
|
|
16575
|
+
input.value = parsed.toString().replace(".", ",");
|
|
16576
|
+
}
|
|
16577
|
+
}
|
|
16510
16578
|
render(targetContainer) {
|
|
16511
16579
|
this.overlayEl = document.createElement("div");
|
|
16512
16580
|
this.overlayEl.className = "myio-power-limits-overlay";
|
|
@@ -16516,6 +16584,7 @@ ${rangeText}`;
|
|
|
16516
16584
|
${this.renderHeader()}
|
|
16517
16585
|
${this.renderSelectors()}
|
|
16518
16586
|
${this.renderStatusCards()}
|
|
16587
|
+
${this.renderToolbar()}
|
|
16519
16588
|
${this.renderLoadingState()}
|
|
16520
16589
|
${this.renderErrorState()}
|
|
16521
16590
|
${this.renderSuccessState()}
|
|
@@ -16532,80 +16601,107 @@ ${rangeText}`;
|
|
|
16532
16601
|
}
|
|
16533
16602
|
renderHeader() {
|
|
16534
16603
|
return `
|
|
16535
|
-
<div class="myio-
|
|
16536
|
-
<
|
|
16537
|
-
|
|
16538
|
-
|
|
16539
|
-
|
|
16540
|
-
|
|
16604
|
+
<div class="myio-modal-header">
|
|
16605
|
+
<h2 class="myio-modal-title">\u2699\uFE0F Configura\xE7\xE3o de Limites</h2>
|
|
16606
|
+
<button class="myio-modal-close" id="plm-close-btn" type="button" aria-label="Fechar modal">\xD7</button>
|
|
16607
|
+
</div>
|
|
16608
|
+
`;
|
|
16609
|
+
}
|
|
16610
|
+
renderToolbar() {
|
|
16611
|
+
return `
|
|
16612
|
+
<div class="myio-power-limits-toolbar">
|
|
16613
|
+
<div class="myio-toolbar-actions">
|
|
16614
|
+
<button class="myio-btn myio-btn-secondary" id="plm-reset-btn" type="button">Limpar</button>
|
|
16541
16615
|
<button class="myio-btn myio-btn-primary" id="plm-save-btn" type="button">
|
|
16542
|
-
<span class="myio-btn-text">
|
|
16616
|
+
<span class="myio-btn-text">Salvar</span>
|
|
16543
16617
|
<span class="myio-btn-spinner" style="display: none;"></span>
|
|
16544
16618
|
</button>
|
|
16545
|
-
<button class="myio-btn myio-btn-secondary" id="plm-reset-btn" type="button">Reset</button>
|
|
16546
|
-
<button class="myio-btn myio-btn-close" id="plm-close-btn" type="button" aria-label="Close">×</button>
|
|
16547
16619
|
</div>
|
|
16548
16620
|
</div>
|
|
16549
16621
|
`;
|
|
16550
16622
|
}
|
|
16551
16623
|
renderSelectors() {
|
|
16552
|
-
const
|
|
16553
|
-
|
|
16554
|
-
|
|
16555
|
-
const telemetryOptions = TELEMETRY_TYPES2.map(
|
|
16556
|
-
(tt) => `<option value="${tt.value}" ${tt.value === this.config.telemetryType ? "selected" : ""}>${tt.label}</option>`
|
|
16624
|
+
const domain = this.formData.domain || "energy";
|
|
16625
|
+
const domainOptions = DOMAINS.map(
|
|
16626
|
+
(d) => `<option value="${d.value}" ${d.value === domain ? "selected" : ""}>${d.icon} ${d.label}</option>`
|
|
16557
16627
|
).join("");
|
|
16628
|
+
let deviceTypeContent;
|
|
16629
|
+
let telemetryLabel;
|
|
16630
|
+
switch (domain) {
|
|
16631
|
+
case "temperature":
|
|
16632
|
+
deviceTypeContent = `<div class="myio-fixed-value">Sensor de Temperatura</div>`;
|
|
16633
|
+
telemetryLabel = "Temperatura em Celsius";
|
|
16634
|
+
break;
|
|
16635
|
+
case "water":
|
|
16636
|
+
deviceTypeContent = `<div class="myio-fixed-value">Hidr\xF4metro</div>`;
|
|
16637
|
+
telemetryLabel = "Litros";
|
|
16638
|
+
break;
|
|
16639
|
+
case "energy":
|
|
16640
|
+
default:
|
|
16641
|
+
deviceTypeContent = `<select id="plm-device-type" class="myio-select">
|
|
16642
|
+
${DEVICE_TYPES.map(
|
|
16643
|
+
(dt) => `<option value="${dt.value}" ${dt.value === this.formData.deviceType ? "selected" : ""}>${dt.label}</option>`
|
|
16644
|
+
).join("")}
|
|
16645
|
+
</select>`;
|
|
16646
|
+
telemetryLabel = "Pot\xEAncia (kW)";
|
|
16647
|
+
break;
|
|
16648
|
+
}
|
|
16558
16649
|
return `
|
|
16559
16650
|
<div class="myio-power-limits-selectors">
|
|
16560
16651
|
<div class="myio-form-group">
|
|
16561
|
-
<label for="plm-
|
|
16562
|
-
<select id="plm-
|
|
16563
|
-
${
|
|
16652
|
+
<label for="plm-domain">Dom\xEDnio</label>
|
|
16653
|
+
<select id="plm-domain" class="myio-select">
|
|
16654
|
+
${domainOptions}
|
|
16564
16655
|
</select>
|
|
16565
16656
|
</div>
|
|
16566
16657
|
<div class="myio-form-group">
|
|
16567
|
-
<label
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
|
|
16658
|
+
<label>Tipo de Dispositivo</label>
|
|
16659
|
+
${deviceTypeContent}
|
|
16660
|
+
</div>
|
|
16661
|
+
<div class="myio-form-group">
|
|
16662
|
+
<label>Tipo de Telemetria</label>
|
|
16663
|
+
<div class="myio-fixed-value">${telemetryLabel}</div>
|
|
16571
16664
|
</div>
|
|
16572
16665
|
</div>
|
|
16573
16666
|
`;
|
|
16574
16667
|
}
|
|
16575
16668
|
renderStatusCards() {
|
|
16576
16669
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
16670
|
+
const domain = this.formData.domain || "energy";
|
|
16671
|
+
const domainIcons = STATUS_ICONS[domain];
|
|
16577
16672
|
const cards = statuses.map((status) => {
|
|
16578
|
-
const
|
|
16673
|
+
const statusKey = status === "standby" ? "standBy" : status;
|
|
16674
|
+
const config = STATUS_CONFIG[statusKey];
|
|
16579
16675
|
const formValues = this.formData[status];
|
|
16676
|
+
const icon = domainIcons[statusKey];
|
|
16580
16677
|
return `
|
|
16581
16678
|
<div class="myio-power-limits-card-item myio-status-${status}" style="--status-color: ${config.color}; --status-bg: ${config.bgColor};">
|
|
16582
16679
|
<div class="myio-card-header">
|
|
16680
|
+
<span class="myio-status-icon">${icon}</span>
|
|
16583
16681
|
<span class="myio-status-indicator"></span>
|
|
16584
16682
|
<span class="myio-status-label">${config.label}</span>
|
|
16585
16683
|
</div>
|
|
16586
16684
|
<div class="myio-card-inputs">
|
|
16587
16685
|
<div class="myio-input-group">
|
|
16588
|
-
<label for="plm-${status}-base">
|
|
16686
|
+
<label for="plm-${status}-base">Limite Inferior</label>
|
|
16589
16687
|
<input
|
|
16590
|
-
type="
|
|
16688
|
+
type="text"
|
|
16591
16689
|
id="plm-${status}-base"
|
|
16592
|
-
class="myio-input"
|
|
16593
|
-
|
|
16594
|
-
|
|
16595
|
-
|
|
16596
|
-
placeholder="0"
|
|
16690
|
+
class="myio-input myio-formatted-number"
|
|
16691
|
+
inputmode="decimal"
|
|
16692
|
+
value="${this.formatNumberForDisplay(formValues.baseValue)}"
|
|
16693
|
+
placeholder="0,00"
|
|
16597
16694
|
>
|
|
16598
16695
|
</div>
|
|
16599
16696
|
<div class="myio-input-group">
|
|
16600
|
-
<label for="plm-${status}-top">
|
|
16697
|
+
<label for="plm-${status}-top">Limite Superior</label>
|
|
16601
16698
|
<input
|
|
16602
|
-
type="
|
|
16699
|
+
type="text"
|
|
16603
16700
|
id="plm-${status}-top"
|
|
16604
|
-
class="myio-input"
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
|
|
16608
|
-
placeholder="0"
|
|
16701
|
+
class="myio-input myio-formatted-number"
|
|
16702
|
+
inputmode="decimal"
|
|
16703
|
+
value="${this.formatNumberForDisplay(formValues.topValue)}"
|
|
16704
|
+
placeholder="0,00"
|
|
16609
16705
|
>
|
|
16610
16706
|
</div>
|
|
16611
16707
|
</div>
|
|
@@ -16622,7 +16718,7 @@ ${rangeText}`;
|
|
|
16622
16718
|
return `
|
|
16623
16719
|
<div class="myio-power-limits-loading" id="plm-loading" style="display: none;">
|
|
16624
16720
|
<div class="myio-spinner"></div>
|
|
16625
|
-
<span>
|
|
16721
|
+
<span>Carregando configura\xE7\xE3o...</span>
|
|
16626
16722
|
</div>
|
|
16627
16723
|
`;
|
|
16628
16724
|
}
|
|
@@ -16638,7 +16734,7 @@ ${rangeText}`;
|
|
|
16638
16734
|
return `
|
|
16639
16735
|
<div class="myio-power-limits-success" id="plm-success" style="display: none;">
|
|
16640
16736
|
<span class="myio-success-icon">✓</span>
|
|
16641
|
-
<span class="myio-success-message">
|
|
16737
|
+
<span class="myio-success-message">Configura\xE7\xE3o salva com sucesso!</span>
|
|
16642
16738
|
</div>
|
|
16643
16739
|
`;
|
|
16644
16740
|
}
|
|
@@ -16656,31 +16752,121 @@ ${rangeText}`;
|
|
|
16656
16752
|
saveBtn?.addEventListener("click", () => this.handleSave());
|
|
16657
16753
|
const resetBtn = this.overlayEl.querySelector("#plm-reset-btn");
|
|
16658
16754
|
resetBtn?.addEventListener("click", () => this.handleReset());
|
|
16659
|
-
const
|
|
16660
|
-
|
|
16661
|
-
const value = e.target.value;
|
|
16662
|
-
this.formData.deviceType = value;
|
|
16663
|
-
this.config.onDeviceTypeChange(value);
|
|
16664
|
-
});
|
|
16665
|
-
const telemetrySelect = this.overlayEl.querySelector("#plm-telemetry-type");
|
|
16666
|
-
telemetrySelect?.addEventListener("change", (e) => {
|
|
16755
|
+
const domainSelect = this.overlayEl.querySelector("#plm-domain");
|
|
16756
|
+
domainSelect?.addEventListener("change", (e) => {
|
|
16667
16757
|
const value = e.target.value;
|
|
16668
|
-
this.formData.
|
|
16669
|
-
|
|
16758
|
+
this.formData.domain = value;
|
|
16759
|
+
switch (value) {
|
|
16760
|
+
case "temperature":
|
|
16761
|
+
this.formData.deviceType = "SENSOR_TEMPERATURA";
|
|
16762
|
+
this.formData.telemetryType = "temperature";
|
|
16763
|
+
break;
|
|
16764
|
+
case "water":
|
|
16765
|
+
this.formData.deviceType = "HIDROMETRO";
|
|
16766
|
+
this.formData.telemetryType = "liters";
|
|
16767
|
+
break;
|
|
16768
|
+
case "energy":
|
|
16769
|
+
default:
|
|
16770
|
+
this.formData.telemetryType = "consumption";
|
|
16771
|
+
break;
|
|
16772
|
+
}
|
|
16773
|
+
this.config.onDomainChange(value);
|
|
16774
|
+
this.updateSelectorsUI();
|
|
16775
|
+
this.updateStatusIcons();
|
|
16670
16776
|
});
|
|
16777
|
+
this.setupDeviceTypeListener();
|
|
16671
16778
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
16672
16779
|
statuses.forEach((status) => {
|
|
16673
16780
|
const baseInput = this.overlayEl?.querySelector(`#plm-${status}-base`);
|
|
16674
16781
|
const topInput = this.overlayEl?.querySelector(`#plm-${status}-top`);
|
|
16675
|
-
|
|
16782
|
+
if (baseInput) {
|
|
16783
|
+
baseInput.addEventListener("focus", () => this.unformatInputValue(baseInput));
|
|
16784
|
+
baseInput.addEventListener("blur", () => {
|
|
16785
|
+
this.formData[status].baseValue = this.parseFormattedNumber(baseInput.value);
|
|
16786
|
+
this.formatInputValue(baseInput);
|
|
16787
|
+
});
|
|
16788
|
+
baseInput.addEventListener("keydown", (e) => this.handleNumberKeydown(e));
|
|
16789
|
+
}
|
|
16790
|
+
if (topInput) {
|
|
16791
|
+
topInput.addEventListener("focus", () => this.unformatInputValue(topInput));
|
|
16792
|
+
topInput.addEventListener("blur", () => {
|
|
16793
|
+
this.formData[status].topValue = this.parseFormattedNumber(topInput.value);
|
|
16794
|
+
this.formatInputValue(topInput);
|
|
16795
|
+
});
|
|
16796
|
+
topInput.addEventListener("keydown", (e) => this.handleNumberKeydown(e));
|
|
16797
|
+
}
|
|
16798
|
+
});
|
|
16799
|
+
}
|
|
16800
|
+
// Handle keyboard input to allow only valid number characters
|
|
16801
|
+
handleNumberKeydown(e) {
|
|
16802
|
+
const allowedKeys = ["Backspace", "Delete", "ArrowLeft", "ArrowRight", "Tab", "Home", "End"];
|
|
16803
|
+
const isDigit = /^\d$/.test(e.key);
|
|
16804
|
+
const isComma = e.key === ",";
|
|
16805
|
+
const isAllowedKey = allowedKeys.includes(e.key);
|
|
16806
|
+
const hasCtrl = e.ctrlKey || e.metaKey;
|
|
16807
|
+
if (!isDigit && !isComma && !isAllowedKey && !hasCtrl) {
|
|
16808
|
+
e.preventDefault();
|
|
16809
|
+
}
|
|
16810
|
+
if (isComma) {
|
|
16811
|
+
const input = e.target;
|
|
16812
|
+
if (input.value.includes(",")) {
|
|
16813
|
+
e.preventDefault();
|
|
16814
|
+
}
|
|
16815
|
+
}
|
|
16816
|
+
}
|
|
16817
|
+
// Update status icons when domain changes
|
|
16818
|
+
updateStatusIcons() {
|
|
16819
|
+
const domain = this.formData.domain || "energy";
|
|
16820
|
+
const domainIcons = STATUS_ICONS[domain];
|
|
16821
|
+
const statuses = ["standby", "normal", "alert", "failure"];
|
|
16822
|
+
statuses.forEach((status) => {
|
|
16823
|
+
const statusKey = status === "standby" ? "standBy" : status;
|
|
16824
|
+
const iconEl = this.overlayEl?.querySelector(`.myio-status-${status} .myio-status-icon`);
|
|
16825
|
+
if (iconEl) {
|
|
16826
|
+
iconEl.textContent = domainIcons[statusKey];
|
|
16827
|
+
}
|
|
16828
|
+
});
|
|
16829
|
+
}
|
|
16830
|
+
// Update selectors UI when domain changes
|
|
16831
|
+
updateSelectorsUI() {
|
|
16832
|
+
const selectorsContainer = this.overlayEl?.querySelector(".myio-power-limits-selectors");
|
|
16833
|
+
if (selectorsContainer) {
|
|
16834
|
+
selectorsContainer.outerHTML = this.renderSelectors();
|
|
16835
|
+
const domainSelect = this.overlayEl?.querySelector("#plm-domain");
|
|
16836
|
+
domainSelect?.addEventListener("change", (e) => {
|
|
16676
16837
|
const value = e.target.value;
|
|
16677
|
-
this.formData
|
|
16838
|
+
this.formData.domain = value;
|
|
16839
|
+
switch (value) {
|
|
16840
|
+
case "temperature":
|
|
16841
|
+
this.formData.deviceType = "SENSOR_TEMPERATURA";
|
|
16842
|
+
this.formData.telemetryType = "temperature";
|
|
16843
|
+
break;
|
|
16844
|
+
case "water":
|
|
16845
|
+
this.formData.deviceType = "HIDROMETRO";
|
|
16846
|
+
this.formData.telemetryType = "liters";
|
|
16847
|
+
break;
|
|
16848
|
+
case "energy":
|
|
16849
|
+
default:
|
|
16850
|
+
this.formData.telemetryType = "consumption";
|
|
16851
|
+
break;
|
|
16852
|
+
}
|
|
16853
|
+
this.config.onDomainChange(value);
|
|
16854
|
+
this.updateSelectorsUI();
|
|
16855
|
+
this.updateStatusIcons();
|
|
16678
16856
|
});
|
|
16679
|
-
|
|
16857
|
+
this.setupDeviceTypeListener();
|
|
16858
|
+
}
|
|
16859
|
+
}
|
|
16860
|
+
// Setup device type listener (only for energy/water domains)
|
|
16861
|
+
setupDeviceTypeListener() {
|
|
16862
|
+
const deviceSelect = this.overlayEl?.querySelector("#plm-device-type");
|
|
16863
|
+
if (deviceSelect) {
|
|
16864
|
+
deviceSelect.addEventListener("change", (e) => {
|
|
16680
16865
|
const value = e.target.value;
|
|
16681
|
-
this.formData
|
|
16866
|
+
this.formData.deviceType = value;
|
|
16867
|
+
this.config.onDeviceTypeChange(value);
|
|
16682
16868
|
});
|
|
16683
|
-
}
|
|
16869
|
+
}
|
|
16684
16870
|
}
|
|
16685
16871
|
handleKeyDown = (e) => {
|
|
16686
16872
|
if (e.key === "Escape") {
|
|
@@ -16703,7 +16889,7 @@ ${rangeText}`;
|
|
|
16703
16889
|
this.showSuccess();
|
|
16704
16890
|
setTimeout(() => this.hideSuccess(), 3e3);
|
|
16705
16891
|
} catch (error) {
|
|
16706
|
-
this.showError(error.message || "
|
|
16892
|
+
this.showError(error.message || "Falha ao salvar configura\xE7\xE3o");
|
|
16707
16893
|
} finally {
|
|
16708
16894
|
this.isSaving = false;
|
|
16709
16895
|
this.showSaveLoading(false);
|
|
@@ -16727,13 +16913,13 @@ ${rangeText}`;
|
|
|
16727
16913
|
const base = this.formData[status].baseValue;
|
|
16728
16914
|
const top = this.formData[status].topValue;
|
|
16729
16915
|
if (base !== null && base < 0) {
|
|
16730
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
16916
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite inferior n\xE3o pode ser negativo`;
|
|
16731
16917
|
}
|
|
16732
16918
|
if (top !== null && top < 0) {
|
|
16733
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
16919
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite superior n\xE3o pode ser negativo`;
|
|
16734
16920
|
}
|
|
16735
16921
|
if (base !== null && top !== null && base > top) {
|
|
16736
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
16922
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite inferior n\xE3o pode ser maior que o limite superior`;
|
|
16737
16923
|
}
|
|
16738
16924
|
}
|
|
16739
16925
|
return null;
|
|
@@ -16802,11 +16988,13 @@ ${rangeText}`;
|
|
|
16802
16988
|
setFormData(data) {
|
|
16803
16989
|
if (data.deviceType) this.formData.deviceType = data.deviceType;
|
|
16804
16990
|
if (data.telemetryType) this.formData.telemetryType = data.telemetryType;
|
|
16991
|
+
if (data.domain) this.formData.domain = data.domain;
|
|
16805
16992
|
if (data.standby) this.formData.standby = { ...data.standby };
|
|
16806
16993
|
if (data.normal) this.formData.normal = { ...data.normal };
|
|
16807
16994
|
if (data.alert) this.formData.alert = { ...data.alert };
|
|
16808
16995
|
if (data.failure) this.formData.failure = { ...data.failure };
|
|
16809
16996
|
this.updateInputValues();
|
|
16997
|
+
this.updateStatusIcons();
|
|
16810
16998
|
}
|
|
16811
16999
|
updateInputValues() {
|
|
16812
17000
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
@@ -16814,16 +17002,16 @@ ${rangeText}`;
|
|
|
16814
17002
|
const baseInput = this.overlayEl?.querySelector(`#plm-${status}-base`);
|
|
16815
17003
|
const topInput = this.overlayEl?.querySelector(`#plm-${status}-top`);
|
|
16816
17004
|
if (baseInput) {
|
|
16817
|
-
baseInput.value = this.formData[status].baseValue
|
|
17005
|
+
baseInput.value = this.formatNumberForDisplay(this.formData[status].baseValue);
|
|
16818
17006
|
}
|
|
16819
17007
|
if (topInput) {
|
|
16820
|
-
topInput.value = this.formData[status].topValue
|
|
17008
|
+
topInput.value = this.formatNumberForDisplay(this.formData[status].topValue);
|
|
16821
17009
|
}
|
|
16822
17010
|
});
|
|
17011
|
+
const domainSelect = this.overlayEl?.querySelector("#plm-domain");
|
|
16823
17012
|
const deviceSelect = this.overlayEl?.querySelector("#plm-device-type");
|
|
16824
|
-
|
|
17013
|
+
if (domainSelect) domainSelect.value = this.formData.domain;
|
|
16825
17014
|
if (deviceSelect) deviceSelect.value = this.formData.deviceType;
|
|
16826
|
-
if (telemetrySelect) telemetrySelect.value = this.formData.telemetryType;
|
|
16827
17015
|
}
|
|
16828
17016
|
getStyles() {
|
|
16829
17017
|
const styles = this.config.styles || {};
|
|
@@ -16847,7 +17035,7 @@ ${rangeText}`;
|
|
|
16847
17035
|
opacity: 0;
|
|
16848
17036
|
visibility: hidden;
|
|
16849
17037
|
transition: all 0.3s ease;
|
|
16850
|
-
font-family: ${styles.fontFamily || '
|
|
17038
|
+
font-family: ${styles.fontFamily || "'Roboto', Arial, sans-serif"};
|
|
16851
17039
|
}
|
|
16852
17040
|
|
|
16853
17041
|
.myio-power-limits-overlay.active {
|
|
@@ -16857,9 +17045,9 @@ ${rangeText}`;
|
|
|
16857
17045
|
|
|
16858
17046
|
.myio-power-limits-card {
|
|
16859
17047
|
background: ${styles.backgroundColor || "#ffffff"};
|
|
16860
|
-
border-radius: ${styles.borderRadius || "
|
|
17048
|
+
border-radius: ${styles.borderRadius || "10px"};
|
|
16861
17049
|
width: 90%;
|
|
16862
|
-
max-width:
|
|
17050
|
+
max-width: 1104px;
|
|
16863
17051
|
max-height: 90vh;
|
|
16864
17052
|
overflow-y: auto;
|
|
16865
17053
|
transform: scale(0.9);
|
|
@@ -16871,36 +17059,55 @@ ${rangeText}`;
|
|
|
16871
17059
|
transform: scale(1);
|
|
16872
17060
|
}
|
|
16873
17061
|
|
|
16874
|
-
|
|
17062
|
+
/* Header - ModalPremiumShell pattern */
|
|
17063
|
+
.myio-modal-header {
|
|
16875
17064
|
display: flex;
|
|
16876
17065
|
align-items: center;
|
|
16877
17066
|
justify-content: space-between;
|
|
16878
|
-
padding:
|
|
16879
|
-
background:
|
|
16880
|
-
|
|
16881
|
-
|
|
17067
|
+
padding: 4px 8px;
|
|
17068
|
+
background: ${primaryColor};
|
|
17069
|
+
border-radius: 10px 10px 0 0;
|
|
17070
|
+
min-height: 20px;
|
|
16882
17071
|
}
|
|
16883
17072
|
|
|
16884
|
-
.myio-
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
17073
|
+
.myio-modal-title {
|
|
17074
|
+
margin: 6px;
|
|
17075
|
+
font-size: 18px;
|
|
17076
|
+
font-weight: 600;
|
|
17077
|
+
color: white;
|
|
17078
|
+
line-height: 2;
|
|
16888
17079
|
}
|
|
16889
17080
|
|
|
16890
|
-
.myio-
|
|
17081
|
+
.myio-modal-close {
|
|
17082
|
+
background: none;
|
|
17083
|
+
border: none;
|
|
16891
17084
|
font-size: 24px;
|
|
17085
|
+
cursor: pointer;
|
|
17086
|
+
padding: 4px 12px;
|
|
17087
|
+
border-radius: 6px;
|
|
17088
|
+
color: rgba(255, 255, 255, 0.8);
|
|
17089
|
+
transition: background-color 0.2s, color 0.2s;
|
|
17090
|
+
line-height: 1;
|
|
16892
17091
|
}
|
|
16893
17092
|
|
|
16894
|
-
.myio-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
margin: 0;
|
|
17093
|
+
.myio-modal-close:hover {
|
|
17094
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
17095
|
+
color: white;
|
|
16898
17096
|
}
|
|
16899
17097
|
|
|
16900
|
-
|
|
17098
|
+
/* Toolbar with Save/Reset buttons */
|
|
17099
|
+
.myio-power-limits-toolbar {
|
|
17100
|
+
display: flex;
|
|
17101
|
+
justify-content: flex-end;
|
|
17102
|
+
padding: 16px 24px;
|
|
17103
|
+
background: #f9fafb;
|
|
17104
|
+
border-top: 1px solid #e5e7eb;
|
|
17105
|
+
}
|
|
17106
|
+
|
|
17107
|
+
.myio-toolbar-actions {
|
|
16901
17108
|
display: flex;
|
|
16902
17109
|
align-items: center;
|
|
16903
|
-
gap:
|
|
17110
|
+
gap: 12px;
|
|
16904
17111
|
}
|
|
16905
17112
|
|
|
16906
17113
|
.myio-btn {
|
|
@@ -16922,33 +17129,21 @@ ${rangeText}`;
|
|
|
16922
17129
|
}
|
|
16923
17130
|
|
|
16924
17131
|
.myio-btn-primary {
|
|
16925
|
-
background:
|
|
16926
|
-
color:
|
|
17132
|
+
background: ${primaryColor};
|
|
17133
|
+
color: white;
|
|
16927
17134
|
}
|
|
16928
17135
|
|
|
16929
17136
|
.myio-btn-primary:hover:not(:disabled) {
|
|
16930
|
-
background:
|
|
17137
|
+
background: ${this.lightenColor(primaryColor, -10)};
|
|
16931
17138
|
}
|
|
16932
17139
|
|
|
16933
17140
|
.myio-btn-secondary {
|
|
16934
|
-
background:
|
|
16935
|
-
color:
|
|
17141
|
+
background: #e5e7eb;
|
|
17142
|
+
color: #374151;
|
|
16936
17143
|
}
|
|
16937
17144
|
|
|
16938
17145
|
.myio-btn-secondary:hover:not(:disabled) {
|
|
16939
|
-
background:
|
|
16940
|
-
}
|
|
16941
|
-
|
|
16942
|
-
.myio-btn-close {
|
|
16943
|
-
background: transparent;
|
|
16944
|
-
color: white;
|
|
16945
|
-
font-size: 24px;
|
|
16946
|
-
padding: 4px 8px;
|
|
16947
|
-
line-height: 1;
|
|
16948
|
-
}
|
|
16949
|
-
|
|
16950
|
-
.myio-btn-close:hover {
|
|
16951
|
-
background: rgba(255, 255, 255, 0.1);
|
|
17146
|
+
background: #d1d5db;
|
|
16952
17147
|
}
|
|
16953
17148
|
|
|
16954
17149
|
.myio-btn-spinner {
|
|
@@ -16966,7 +17161,7 @@ ${rangeText}`;
|
|
|
16966
17161
|
|
|
16967
17162
|
.myio-power-limits-selectors {
|
|
16968
17163
|
display: grid;
|
|
16969
|
-
grid-template-columns: 1fr 1fr;
|
|
17164
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
16970
17165
|
gap: 16px;
|
|
16971
17166
|
padding: 20px 24px;
|
|
16972
17167
|
background: #f9fafb;
|
|
@@ -17001,6 +17196,15 @@ ${rangeText}`;
|
|
|
17001
17196
|
box-shadow: 0 0 0 3px ${this.hexToRgba(primaryColor, 0.1)};
|
|
17002
17197
|
}
|
|
17003
17198
|
|
|
17199
|
+
.myio-fixed-value {
|
|
17200
|
+
padding: 10px 12px;
|
|
17201
|
+
border: 1px solid #e5e7eb;
|
|
17202
|
+
border-radius: 6px;
|
|
17203
|
+
font-size: 14px;
|
|
17204
|
+
background: #f9fafb;
|
|
17205
|
+
color: #6b7280;
|
|
17206
|
+
}
|
|
17207
|
+
|
|
17004
17208
|
.myio-power-limits-grid {
|
|
17005
17209
|
display: grid;
|
|
17006
17210
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -17029,6 +17233,11 @@ ${rangeText}`;
|
|
|
17029
17233
|
margin-bottom: 12px;
|
|
17030
17234
|
}
|
|
17031
17235
|
|
|
17236
|
+
.myio-status-icon {
|
|
17237
|
+
font-size: 18px;
|
|
17238
|
+
line-height: 1;
|
|
17239
|
+
}
|
|
17240
|
+
|
|
17032
17241
|
.myio-status-indicator {
|
|
17033
17242
|
width: 12px;
|
|
17034
17243
|
height: 12px;
|
|
@@ -17219,6 +17428,8 @@ ${rangeText}`;
|
|
|
17219
17428
|
const defaultFormData = {
|
|
17220
17429
|
deviceType,
|
|
17221
17430
|
telemetryType,
|
|
17431
|
+
domain: "energy",
|
|
17432
|
+
// Default to energy, will be overwritten by caller if needed
|
|
17222
17433
|
standby: { baseValue: null, topValue: null },
|
|
17223
17434
|
normal: { baseValue: null, topValue: null },
|
|
17224
17435
|
alert: { baseValue: null, topValue: null },
|
|
@@ -17388,10 +17599,12 @@ ${rangeText}`;
|
|
|
17388
17599
|
const persister = new PowerLimitsPersister(params.token, params.tbBaseUrl);
|
|
17389
17600
|
let currentDeviceType = params.deviceType || "ELEVADOR";
|
|
17390
17601
|
let currentTelemetryType = params.telemetryType || "consumption";
|
|
17602
|
+
let currentDomain = params.domain || "energy";
|
|
17391
17603
|
let existingLimits = params.existingMapPower || null;
|
|
17392
17604
|
const view = new PowerLimitsModalView({
|
|
17393
17605
|
deviceType: currentDeviceType,
|
|
17394
17606
|
telemetryType: currentTelemetryType,
|
|
17607
|
+
domain: currentDomain,
|
|
17395
17608
|
styles: params.styles,
|
|
17396
17609
|
locale: params.locale,
|
|
17397
17610
|
onDeviceTypeChange: async (deviceType) => {
|
|
@@ -17402,6 +17615,9 @@ ${rangeText}`;
|
|
|
17402
17615
|
currentTelemetryType = telemetryType;
|
|
17403
17616
|
await loadFormData();
|
|
17404
17617
|
},
|
|
17618
|
+
onDomainChange: (domain) => {
|
|
17619
|
+
currentDomain = domain;
|
|
17620
|
+
},
|
|
17405
17621
|
onSave: async () => {
|
|
17406
17622
|
const formData = view.getFormData();
|
|
17407
17623
|
const updatedLimits = persister.mergeFormDataIntoLimits(existingLimits, formData);
|
|
@@ -17427,6 +17643,7 @@ ${rangeText}`;
|
|
|
17427
17643
|
existingLimits = await persister.loadCustomerPowerLimits(params.customerId);
|
|
17428
17644
|
}
|
|
17429
17645
|
const formData = persister.extractFormData(existingLimits, currentDeviceType, currentTelemetryType);
|
|
17646
|
+
formData.domain = currentDomain;
|
|
17430
17647
|
view.setFormData(formData);
|
|
17431
17648
|
} catch (error) {
|
|
17432
17649
|
console.error("[PowerLimitsSetupModal] Error loading form data:", error);
|