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
package/dist/index.js
CHANGED
|
@@ -16640,35 +16640,72 @@ function validateOptions2(options) {
|
|
|
16640
16640
|
}
|
|
16641
16641
|
|
|
16642
16642
|
// src/components/premium-modals/power-limits/types.ts
|
|
16643
|
+
var DOMAINS = [
|
|
16644
|
+
{ value: "energy", label: "Energia", icon: "\u26A1" },
|
|
16645
|
+
{ value: "water", label: "\xC1gua", icon: "\u{1F4A7}" },
|
|
16646
|
+
{ value: "temperature", label: "Temperatura", icon: "\u{1F321}\uFE0F" }
|
|
16647
|
+
];
|
|
16643
16648
|
var DEVICE_TYPES = [
|
|
16644
|
-
{ value: "ELEVADOR", label: "
|
|
16645
|
-
{ value: "ESCADA_ROLANTE", label: "
|
|
16649
|
+
{ value: "ELEVADOR", label: "Elevador" },
|
|
16650
|
+
{ value: "ESCADA_ROLANTE", label: "Escada Rolante" },
|
|
16646
16651
|
{ value: "MOTOR", label: "Motor" },
|
|
16647
|
-
{ value: "BOMBA", label: "
|
|
16652
|
+
{ value: "BOMBA", label: "Bomba" },
|
|
16648
16653
|
{ value: "CHILLER", label: "Chiller" },
|
|
16649
|
-
{ value: "AR_CONDICIONADO", label: "
|
|
16654
|
+
{ value: "AR_CONDICIONADO", label: "Ar Condicionado" },
|
|
16650
16655
|
{ value: "HVAC", label: "HVAC" },
|
|
16651
16656
|
{ value: "FANCOIL", label: "Fancoil" },
|
|
16652
|
-
{ value: "3F_MEDIDOR", label: "
|
|
16657
|
+
{ value: "3F_MEDIDOR", label: "Medidor Trif\xE1sico" }
|
|
16653
16658
|
];
|
|
16654
16659
|
var TELEMETRY_TYPES2 = [
|
|
16655
|
-
{ value: "consumption", label: "
|
|
16656
|
-
{ value: "voltage_a", label: "
|
|
16657
|
-
{ value: "voltage_b", label: "
|
|
16658
|
-
{ value: "voltage_c", label: "
|
|
16659
|
-
{ value: "current_a", label: "
|
|
16660
|
-
{ value: "current_b", label: "
|
|
16661
|
-
{ value: "current_c", label: "
|
|
16662
|
-
{ value: "total_current", label: "Total
|
|
16663
|
-
{ value: "fp_a", label: "
|
|
16664
|
-
{ value: "fp_b", label: "
|
|
16665
|
-
{ value: "fp_c", label: "
|
|
16660
|
+
{ value: "consumption", label: "Pot\xEAncia (kW)", unit: "kW" },
|
|
16661
|
+
{ value: "voltage_a", label: "Tens\xE3o A (V)", unit: "V" },
|
|
16662
|
+
{ value: "voltage_b", label: "Tens\xE3o B (V)", unit: "V" },
|
|
16663
|
+
{ value: "voltage_c", label: "Tens\xE3o C (V)", unit: "V" },
|
|
16664
|
+
{ value: "current_a", label: "Corrente A (A)", unit: "A" },
|
|
16665
|
+
{ value: "current_b", label: "Corrente B (A)", unit: "A" },
|
|
16666
|
+
{ value: "current_c", label: "Corrente C (A)", unit: "A" },
|
|
16667
|
+
{ value: "total_current", label: "Corrente Total (A)", unit: "A" },
|
|
16668
|
+
{ value: "fp_a", label: "Fator de Pot\xEAncia A", unit: "" },
|
|
16669
|
+
{ value: "fp_b", label: "Fator de Pot\xEAncia B", unit: "" },
|
|
16670
|
+
{ value: "fp_c", label: "Fator de Pot\xEAncia C", unit: "" }
|
|
16666
16671
|
];
|
|
16672
|
+
var STATUS_ICONS = {
|
|
16673
|
+
energy: {
|
|
16674
|
+
standBy: "\u{1F50C}",
|
|
16675
|
+
// STANDBY
|
|
16676
|
+
normal: "\u26A1",
|
|
16677
|
+
// POWER_ON
|
|
16678
|
+
alert: "\u26A0\uFE0F",
|
|
16679
|
+
// WARNING
|
|
16680
|
+
failure: "\u{1F6A8}"
|
|
16681
|
+
// FAILURE
|
|
16682
|
+
},
|
|
16683
|
+
water: {
|
|
16684
|
+
standBy: "\u{1F6B0}",
|
|
16685
|
+
// STANDBY
|
|
16686
|
+
normal: "\u{1F4A7}",
|
|
16687
|
+
// POWER_ON
|
|
16688
|
+
alert: "\u26A0\uFE0F",
|
|
16689
|
+
// WARNING
|
|
16690
|
+
failure: "\u{1F6A8}"
|
|
16691
|
+
// FAILURE
|
|
16692
|
+
},
|
|
16693
|
+
temperature: {
|
|
16694
|
+
standBy: "\u{1F321}\uFE0F",
|
|
16695
|
+
// STANDBY
|
|
16696
|
+
normal: "\u{1F321}\uFE0F",
|
|
16697
|
+
// POWER_ON
|
|
16698
|
+
alert: "\u26A0\uFE0F",
|
|
16699
|
+
// WARNING
|
|
16700
|
+
failure: "\u{1F6A8}"
|
|
16701
|
+
// FAILURE
|
|
16702
|
+
}
|
|
16703
|
+
};
|
|
16667
16704
|
var STATUS_CONFIG = {
|
|
16668
16705
|
standBy: { label: "StandBy", color: "#22c55e", bgColor: "rgba(34, 197, 94, 0.1)" },
|
|
16669
16706
|
normal: { label: "Normal", color: "#3b82f6", bgColor: "rgba(59, 130, 246, 0.1)" },
|
|
16670
|
-
alert: { label: "
|
|
16671
|
-
failure: { label: "
|
|
16707
|
+
alert: { label: "Alerta", color: "#f59e0b", bgColor: "rgba(245, 158, 11, 0.1)" },
|
|
16708
|
+
failure: { label: "Falha", color: "#ef4444", bgColor: "rgba(239, 68, 68, 0.1)" }
|
|
16672
16709
|
};
|
|
16673
16710
|
|
|
16674
16711
|
// src/components/premium-modals/power-limits/PowerLimitsModalView.ts
|
|
@@ -16684,12 +16721,43 @@ var PowerLimitsModalView = class {
|
|
|
16684
16721
|
this.formData = {
|
|
16685
16722
|
deviceType: config.deviceType,
|
|
16686
16723
|
telemetryType: config.telemetryType,
|
|
16724
|
+
domain: config.domain,
|
|
16687
16725
|
standby: { baseValue: null, topValue: null },
|
|
16688
16726
|
normal: { baseValue: null, topValue: null },
|
|
16689
16727
|
alert: { baseValue: null, topValue: null },
|
|
16690
16728
|
failure: { baseValue: null, topValue: null }
|
|
16691
16729
|
};
|
|
16692
16730
|
}
|
|
16731
|
+
// Format number with thousand separator (.) and up to 2 decimal places
|
|
16732
|
+
formatNumberForDisplay(value) {
|
|
16733
|
+
if (value === null || value === void 0) return "";
|
|
16734
|
+
const parts = value.toFixed(2).split(".");
|
|
16735
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
16736
|
+
return parts.join(",");
|
|
16737
|
+
}
|
|
16738
|
+
// Parse formatted string back to number
|
|
16739
|
+
parseFormattedNumber(value) {
|
|
16740
|
+
if (!value || value.trim() === "") return null;
|
|
16741
|
+
const normalized = value.replace(/\./g, "").replace(",", ".");
|
|
16742
|
+
const num = parseFloat(normalized);
|
|
16743
|
+
return isNaN(num) ? null : num;
|
|
16744
|
+
}
|
|
16745
|
+
// Handle input formatting on blur
|
|
16746
|
+
formatInputValue(input) {
|
|
16747
|
+
const rawValue = input.value;
|
|
16748
|
+
const parsed = this.parseFormattedNumber(rawValue);
|
|
16749
|
+
if (parsed !== null) {
|
|
16750
|
+
input.value = this.formatNumberForDisplay(parsed);
|
|
16751
|
+
}
|
|
16752
|
+
}
|
|
16753
|
+
// Handle input on focus - show raw value for editing
|
|
16754
|
+
unformatInputValue(input) {
|
|
16755
|
+
const formatted = input.value;
|
|
16756
|
+
const parsed = this.parseFormattedNumber(formatted);
|
|
16757
|
+
if (parsed !== null) {
|
|
16758
|
+
input.value = parsed.toString().replace(".", ",");
|
|
16759
|
+
}
|
|
16760
|
+
}
|
|
16693
16761
|
render(targetContainer) {
|
|
16694
16762
|
this.overlayEl = document.createElement("div");
|
|
16695
16763
|
this.overlayEl.className = "myio-power-limits-overlay";
|
|
@@ -16699,6 +16767,7 @@ var PowerLimitsModalView = class {
|
|
|
16699
16767
|
${this.renderHeader()}
|
|
16700
16768
|
${this.renderSelectors()}
|
|
16701
16769
|
${this.renderStatusCards()}
|
|
16770
|
+
${this.renderToolbar()}
|
|
16702
16771
|
${this.renderLoadingState()}
|
|
16703
16772
|
${this.renderErrorState()}
|
|
16704
16773
|
${this.renderSuccessState()}
|
|
@@ -16715,80 +16784,107 @@ var PowerLimitsModalView = class {
|
|
|
16715
16784
|
}
|
|
16716
16785
|
renderHeader() {
|
|
16717
16786
|
return `
|
|
16718
|
-
<div class="myio-
|
|
16719
|
-
<
|
|
16720
|
-
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
|
|
16787
|
+
<div class="myio-modal-header">
|
|
16788
|
+
<h2 class="myio-modal-title">\u2699\uFE0F Configura\xE7\xE3o de Limites</h2>
|
|
16789
|
+
<button class="myio-modal-close" id="plm-close-btn" type="button" aria-label="Fechar modal">\xD7</button>
|
|
16790
|
+
</div>
|
|
16791
|
+
`;
|
|
16792
|
+
}
|
|
16793
|
+
renderToolbar() {
|
|
16794
|
+
return `
|
|
16795
|
+
<div class="myio-power-limits-toolbar">
|
|
16796
|
+
<div class="myio-toolbar-actions">
|
|
16797
|
+
<button class="myio-btn myio-btn-secondary" id="plm-reset-btn" type="button">Limpar</button>
|
|
16724
16798
|
<button class="myio-btn myio-btn-primary" id="plm-save-btn" type="button">
|
|
16725
|
-
<span class="myio-btn-text">
|
|
16799
|
+
<span class="myio-btn-text">Salvar</span>
|
|
16726
16800
|
<span class="myio-btn-spinner" style="display: none;"></span>
|
|
16727
16801
|
</button>
|
|
16728
|
-
<button class="myio-btn myio-btn-secondary" id="plm-reset-btn" type="button">Reset</button>
|
|
16729
|
-
<button class="myio-btn myio-btn-close" id="plm-close-btn" type="button" aria-label="Close">×</button>
|
|
16730
16802
|
</div>
|
|
16731
16803
|
</div>
|
|
16732
16804
|
`;
|
|
16733
16805
|
}
|
|
16734
16806
|
renderSelectors() {
|
|
16735
|
-
const
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
const telemetryOptions = TELEMETRY_TYPES2.map(
|
|
16739
|
-
(tt) => `<option value="${tt.value}" ${tt.value === this.config.telemetryType ? "selected" : ""}>${tt.label}</option>`
|
|
16807
|
+
const domain = this.formData.domain || "energy";
|
|
16808
|
+
const domainOptions = DOMAINS.map(
|
|
16809
|
+
(d) => `<option value="${d.value}" ${d.value === domain ? "selected" : ""}>${d.icon} ${d.label}</option>`
|
|
16740
16810
|
).join("");
|
|
16811
|
+
let deviceTypeContent;
|
|
16812
|
+
let telemetryLabel;
|
|
16813
|
+
switch (domain) {
|
|
16814
|
+
case "temperature":
|
|
16815
|
+
deviceTypeContent = `<div class="myio-fixed-value">Sensor de Temperatura</div>`;
|
|
16816
|
+
telemetryLabel = "Temperatura em Celsius";
|
|
16817
|
+
break;
|
|
16818
|
+
case "water":
|
|
16819
|
+
deviceTypeContent = `<div class="myio-fixed-value">Hidr\xF4metro</div>`;
|
|
16820
|
+
telemetryLabel = "Litros";
|
|
16821
|
+
break;
|
|
16822
|
+
case "energy":
|
|
16823
|
+
default:
|
|
16824
|
+
deviceTypeContent = `<select id="plm-device-type" class="myio-select">
|
|
16825
|
+
${DEVICE_TYPES.map(
|
|
16826
|
+
(dt) => `<option value="${dt.value}" ${dt.value === this.formData.deviceType ? "selected" : ""}>${dt.label}</option>`
|
|
16827
|
+
).join("")}
|
|
16828
|
+
</select>`;
|
|
16829
|
+
telemetryLabel = "Pot\xEAncia (kW)";
|
|
16830
|
+
break;
|
|
16831
|
+
}
|
|
16741
16832
|
return `
|
|
16742
16833
|
<div class="myio-power-limits-selectors">
|
|
16743
16834
|
<div class="myio-form-group">
|
|
16744
|
-
<label for="plm-
|
|
16745
|
-
<select id="plm-
|
|
16746
|
-
${
|
|
16835
|
+
<label for="plm-domain">Dom\xEDnio</label>
|
|
16836
|
+
<select id="plm-domain" class="myio-select">
|
|
16837
|
+
${domainOptions}
|
|
16747
16838
|
</select>
|
|
16748
16839
|
</div>
|
|
16749
16840
|
<div class="myio-form-group">
|
|
16750
|
-
<label
|
|
16751
|
-
|
|
16752
|
-
|
|
16753
|
-
|
|
16841
|
+
<label>Tipo de Dispositivo</label>
|
|
16842
|
+
${deviceTypeContent}
|
|
16843
|
+
</div>
|
|
16844
|
+
<div class="myio-form-group">
|
|
16845
|
+
<label>Tipo de Telemetria</label>
|
|
16846
|
+
<div class="myio-fixed-value">${telemetryLabel}</div>
|
|
16754
16847
|
</div>
|
|
16755
16848
|
</div>
|
|
16756
16849
|
`;
|
|
16757
16850
|
}
|
|
16758
16851
|
renderStatusCards() {
|
|
16759
16852
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
16853
|
+
const domain = this.formData.domain || "energy";
|
|
16854
|
+
const domainIcons = STATUS_ICONS[domain];
|
|
16760
16855
|
const cards = statuses.map((status) => {
|
|
16761
|
-
const
|
|
16856
|
+
const statusKey = status === "standby" ? "standBy" : status;
|
|
16857
|
+
const config = STATUS_CONFIG[statusKey];
|
|
16762
16858
|
const formValues = this.formData[status];
|
|
16859
|
+
const icon = domainIcons[statusKey];
|
|
16763
16860
|
return `
|
|
16764
16861
|
<div class="myio-power-limits-card-item myio-status-${status}" style="--status-color: ${config.color}; --status-bg: ${config.bgColor};">
|
|
16765
16862
|
<div class="myio-card-header">
|
|
16863
|
+
<span class="myio-status-icon">${icon}</span>
|
|
16766
16864
|
<span class="myio-status-indicator"></span>
|
|
16767
16865
|
<span class="myio-status-label">${config.label}</span>
|
|
16768
16866
|
</div>
|
|
16769
16867
|
<div class="myio-card-inputs">
|
|
16770
16868
|
<div class="myio-input-group">
|
|
16771
|
-
<label for="plm-${status}-base">
|
|
16869
|
+
<label for="plm-${status}-base">Limite Inferior</label>
|
|
16772
16870
|
<input
|
|
16773
|
-
type="
|
|
16871
|
+
type="text"
|
|
16774
16872
|
id="plm-${status}-base"
|
|
16775
|
-
class="myio-input"
|
|
16776
|
-
|
|
16777
|
-
|
|
16778
|
-
|
|
16779
|
-
placeholder="0"
|
|
16873
|
+
class="myio-input myio-formatted-number"
|
|
16874
|
+
inputmode="decimal"
|
|
16875
|
+
value="${this.formatNumberForDisplay(formValues.baseValue)}"
|
|
16876
|
+
placeholder="0,00"
|
|
16780
16877
|
>
|
|
16781
16878
|
</div>
|
|
16782
16879
|
<div class="myio-input-group">
|
|
16783
|
-
<label for="plm-${status}-top">
|
|
16880
|
+
<label for="plm-${status}-top">Limite Superior</label>
|
|
16784
16881
|
<input
|
|
16785
|
-
type="
|
|
16882
|
+
type="text"
|
|
16786
16883
|
id="plm-${status}-top"
|
|
16787
|
-
class="myio-input"
|
|
16788
|
-
|
|
16789
|
-
|
|
16790
|
-
|
|
16791
|
-
placeholder="0"
|
|
16884
|
+
class="myio-input myio-formatted-number"
|
|
16885
|
+
inputmode="decimal"
|
|
16886
|
+
value="${this.formatNumberForDisplay(formValues.topValue)}"
|
|
16887
|
+
placeholder="0,00"
|
|
16792
16888
|
>
|
|
16793
16889
|
</div>
|
|
16794
16890
|
</div>
|
|
@@ -16805,7 +16901,7 @@ var PowerLimitsModalView = class {
|
|
|
16805
16901
|
return `
|
|
16806
16902
|
<div class="myio-power-limits-loading" id="plm-loading" style="display: none;">
|
|
16807
16903
|
<div class="myio-spinner"></div>
|
|
16808
|
-
<span>
|
|
16904
|
+
<span>Carregando configura\xE7\xE3o...</span>
|
|
16809
16905
|
</div>
|
|
16810
16906
|
`;
|
|
16811
16907
|
}
|
|
@@ -16821,7 +16917,7 @@ var PowerLimitsModalView = class {
|
|
|
16821
16917
|
return `
|
|
16822
16918
|
<div class="myio-power-limits-success" id="plm-success" style="display: none;">
|
|
16823
16919
|
<span class="myio-success-icon">✓</span>
|
|
16824
|
-
<span class="myio-success-message">
|
|
16920
|
+
<span class="myio-success-message">Configura\xE7\xE3o salva com sucesso!</span>
|
|
16825
16921
|
</div>
|
|
16826
16922
|
`;
|
|
16827
16923
|
}
|
|
@@ -16839,31 +16935,121 @@ var PowerLimitsModalView = class {
|
|
|
16839
16935
|
saveBtn?.addEventListener("click", () => this.handleSave());
|
|
16840
16936
|
const resetBtn = this.overlayEl.querySelector("#plm-reset-btn");
|
|
16841
16937
|
resetBtn?.addEventListener("click", () => this.handleReset());
|
|
16842
|
-
const
|
|
16843
|
-
|
|
16844
|
-
const value = e.target.value;
|
|
16845
|
-
this.formData.deviceType = value;
|
|
16846
|
-
this.config.onDeviceTypeChange(value);
|
|
16847
|
-
});
|
|
16848
|
-
const telemetrySelect = this.overlayEl.querySelector("#plm-telemetry-type");
|
|
16849
|
-
telemetrySelect?.addEventListener("change", (e) => {
|
|
16938
|
+
const domainSelect = this.overlayEl.querySelector("#plm-domain");
|
|
16939
|
+
domainSelect?.addEventListener("change", (e) => {
|
|
16850
16940
|
const value = e.target.value;
|
|
16851
|
-
this.formData.
|
|
16852
|
-
|
|
16941
|
+
this.formData.domain = value;
|
|
16942
|
+
switch (value) {
|
|
16943
|
+
case "temperature":
|
|
16944
|
+
this.formData.deviceType = "SENSOR_TEMPERATURA";
|
|
16945
|
+
this.formData.telemetryType = "temperature";
|
|
16946
|
+
break;
|
|
16947
|
+
case "water":
|
|
16948
|
+
this.formData.deviceType = "HIDROMETRO";
|
|
16949
|
+
this.formData.telemetryType = "liters";
|
|
16950
|
+
break;
|
|
16951
|
+
case "energy":
|
|
16952
|
+
default:
|
|
16953
|
+
this.formData.telemetryType = "consumption";
|
|
16954
|
+
break;
|
|
16955
|
+
}
|
|
16956
|
+
this.config.onDomainChange(value);
|
|
16957
|
+
this.updateSelectorsUI();
|
|
16958
|
+
this.updateStatusIcons();
|
|
16853
16959
|
});
|
|
16960
|
+
this.setupDeviceTypeListener();
|
|
16854
16961
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
16855
16962
|
statuses.forEach((status) => {
|
|
16856
16963
|
const baseInput = this.overlayEl?.querySelector(`#plm-${status}-base`);
|
|
16857
16964
|
const topInput = this.overlayEl?.querySelector(`#plm-${status}-top`);
|
|
16858
|
-
|
|
16965
|
+
if (baseInput) {
|
|
16966
|
+
baseInput.addEventListener("focus", () => this.unformatInputValue(baseInput));
|
|
16967
|
+
baseInput.addEventListener("blur", () => {
|
|
16968
|
+
this.formData[status].baseValue = this.parseFormattedNumber(baseInput.value);
|
|
16969
|
+
this.formatInputValue(baseInput);
|
|
16970
|
+
});
|
|
16971
|
+
baseInput.addEventListener("keydown", (e) => this.handleNumberKeydown(e));
|
|
16972
|
+
}
|
|
16973
|
+
if (topInput) {
|
|
16974
|
+
topInput.addEventListener("focus", () => this.unformatInputValue(topInput));
|
|
16975
|
+
topInput.addEventListener("blur", () => {
|
|
16976
|
+
this.formData[status].topValue = this.parseFormattedNumber(topInput.value);
|
|
16977
|
+
this.formatInputValue(topInput);
|
|
16978
|
+
});
|
|
16979
|
+
topInput.addEventListener("keydown", (e) => this.handleNumberKeydown(e));
|
|
16980
|
+
}
|
|
16981
|
+
});
|
|
16982
|
+
}
|
|
16983
|
+
// Handle keyboard input to allow only valid number characters
|
|
16984
|
+
handleNumberKeydown(e) {
|
|
16985
|
+
const allowedKeys = ["Backspace", "Delete", "ArrowLeft", "ArrowRight", "Tab", "Home", "End"];
|
|
16986
|
+
const isDigit = /^\d$/.test(e.key);
|
|
16987
|
+
const isComma = e.key === ",";
|
|
16988
|
+
const isAllowedKey = allowedKeys.includes(e.key);
|
|
16989
|
+
const hasCtrl = e.ctrlKey || e.metaKey;
|
|
16990
|
+
if (!isDigit && !isComma && !isAllowedKey && !hasCtrl) {
|
|
16991
|
+
e.preventDefault();
|
|
16992
|
+
}
|
|
16993
|
+
if (isComma) {
|
|
16994
|
+
const input = e.target;
|
|
16995
|
+
if (input.value.includes(",")) {
|
|
16996
|
+
e.preventDefault();
|
|
16997
|
+
}
|
|
16998
|
+
}
|
|
16999
|
+
}
|
|
17000
|
+
// Update status icons when domain changes
|
|
17001
|
+
updateStatusIcons() {
|
|
17002
|
+
const domain = this.formData.domain || "energy";
|
|
17003
|
+
const domainIcons = STATUS_ICONS[domain];
|
|
17004
|
+
const statuses = ["standby", "normal", "alert", "failure"];
|
|
17005
|
+
statuses.forEach((status) => {
|
|
17006
|
+
const statusKey = status === "standby" ? "standBy" : status;
|
|
17007
|
+
const iconEl = this.overlayEl?.querySelector(`.myio-status-${status} .myio-status-icon`);
|
|
17008
|
+
if (iconEl) {
|
|
17009
|
+
iconEl.textContent = domainIcons[statusKey];
|
|
17010
|
+
}
|
|
17011
|
+
});
|
|
17012
|
+
}
|
|
17013
|
+
// Update selectors UI when domain changes
|
|
17014
|
+
updateSelectorsUI() {
|
|
17015
|
+
const selectorsContainer = this.overlayEl?.querySelector(".myio-power-limits-selectors");
|
|
17016
|
+
if (selectorsContainer) {
|
|
17017
|
+
selectorsContainer.outerHTML = this.renderSelectors();
|
|
17018
|
+
const domainSelect = this.overlayEl?.querySelector("#plm-domain");
|
|
17019
|
+
domainSelect?.addEventListener("change", (e) => {
|
|
16859
17020
|
const value = e.target.value;
|
|
16860
|
-
this.formData
|
|
17021
|
+
this.formData.domain = value;
|
|
17022
|
+
switch (value) {
|
|
17023
|
+
case "temperature":
|
|
17024
|
+
this.formData.deviceType = "SENSOR_TEMPERATURA";
|
|
17025
|
+
this.formData.telemetryType = "temperature";
|
|
17026
|
+
break;
|
|
17027
|
+
case "water":
|
|
17028
|
+
this.formData.deviceType = "HIDROMETRO";
|
|
17029
|
+
this.formData.telemetryType = "liters";
|
|
17030
|
+
break;
|
|
17031
|
+
case "energy":
|
|
17032
|
+
default:
|
|
17033
|
+
this.formData.telemetryType = "consumption";
|
|
17034
|
+
break;
|
|
17035
|
+
}
|
|
17036
|
+
this.config.onDomainChange(value);
|
|
17037
|
+
this.updateSelectorsUI();
|
|
17038
|
+
this.updateStatusIcons();
|
|
16861
17039
|
});
|
|
16862
|
-
|
|
17040
|
+
this.setupDeviceTypeListener();
|
|
17041
|
+
}
|
|
17042
|
+
}
|
|
17043
|
+
// Setup device type listener (only for energy/water domains)
|
|
17044
|
+
setupDeviceTypeListener() {
|
|
17045
|
+
const deviceSelect = this.overlayEl?.querySelector("#plm-device-type");
|
|
17046
|
+
if (deviceSelect) {
|
|
17047
|
+
deviceSelect.addEventListener("change", (e) => {
|
|
16863
17048
|
const value = e.target.value;
|
|
16864
|
-
this.formData
|
|
17049
|
+
this.formData.deviceType = value;
|
|
17050
|
+
this.config.onDeviceTypeChange(value);
|
|
16865
17051
|
});
|
|
16866
|
-
}
|
|
17052
|
+
}
|
|
16867
17053
|
}
|
|
16868
17054
|
handleKeyDown = (e) => {
|
|
16869
17055
|
if (e.key === "Escape") {
|
|
@@ -16886,7 +17072,7 @@ var PowerLimitsModalView = class {
|
|
|
16886
17072
|
this.showSuccess();
|
|
16887
17073
|
setTimeout(() => this.hideSuccess(), 3e3);
|
|
16888
17074
|
} catch (error) {
|
|
16889
|
-
this.showError(error.message || "
|
|
17075
|
+
this.showError(error.message || "Falha ao salvar configura\xE7\xE3o");
|
|
16890
17076
|
} finally {
|
|
16891
17077
|
this.isSaving = false;
|
|
16892
17078
|
this.showSaveLoading(false);
|
|
@@ -16910,13 +17096,13 @@ var PowerLimitsModalView = class {
|
|
|
16910
17096
|
const base = this.formData[status].baseValue;
|
|
16911
17097
|
const top = this.formData[status].topValue;
|
|
16912
17098
|
if (base !== null && base < 0) {
|
|
16913
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
17099
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite inferior n\xE3o pode ser negativo`;
|
|
16914
17100
|
}
|
|
16915
17101
|
if (top !== null && top < 0) {
|
|
16916
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
17102
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite superior n\xE3o pode ser negativo`;
|
|
16917
17103
|
}
|
|
16918
17104
|
if (base !== null && top !== null && base > top) {
|
|
16919
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
17105
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite inferior n\xE3o pode ser maior que o limite superior`;
|
|
16920
17106
|
}
|
|
16921
17107
|
}
|
|
16922
17108
|
return null;
|
|
@@ -16985,11 +17171,13 @@ var PowerLimitsModalView = class {
|
|
|
16985
17171
|
setFormData(data) {
|
|
16986
17172
|
if (data.deviceType) this.formData.deviceType = data.deviceType;
|
|
16987
17173
|
if (data.telemetryType) this.formData.telemetryType = data.telemetryType;
|
|
17174
|
+
if (data.domain) this.formData.domain = data.domain;
|
|
16988
17175
|
if (data.standby) this.formData.standby = { ...data.standby };
|
|
16989
17176
|
if (data.normal) this.formData.normal = { ...data.normal };
|
|
16990
17177
|
if (data.alert) this.formData.alert = { ...data.alert };
|
|
16991
17178
|
if (data.failure) this.formData.failure = { ...data.failure };
|
|
16992
17179
|
this.updateInputValues();
|
|
17180
|
+
this.updateStatusIcons();
|
|
16993
17181
|
}
|
|
16994
17182
|
updateInputValues() {
|
|
16995
17183
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
@@ -16997,16 +17185,16 @@ var PowerLimitsModalView = class {
|
|
|
16997
17185
|
const baseInput = this.overlayEl?.querySelector(`#plm-${status}-base`);
|
|
16998
17186
|
const topInput = this.overlayEl?.querySelector(`#plm-${status}-top`);
|
|
16999
17187
|
if (baseInput) {
|
|
17000
|
-
baseInput.value = this.formData[status].baseValue
|
|
17188
|
+
baseInput.value = this.formatNumberForDisplay(this.formData[status].baseValue);
|
|
17001
17189
|
}
|
|
17002
17190
|
if (topInput) {
|
|
17003
|
-
topInput.value = this.formData[status].topValue
|
|
17191
|
+
topInput.value = this.formatNumberForDisplay(this.formData[status].topValue);
|
|
17004
17192
|
}
|
|
17005
17193
|
});
|
|
17194
|
+
const domainSelect = this.overlayEl?.querySelector("#plm-domain");
|
|
17006
17195
|
const deviceSelect = this.overlayEl?.querySelector("#plm-device-type");
|
|
17007
|
-
|
|
17196
|
+
if (domainSelect) domainSelect.value = this.formData.domain;
|
|
17008
17197
|
if (deviceSelect) deviceSelect.value = this.formData.deviceType;
|
|
17009
|
-
if (telemetrySelect) telemetrySelect.value = this.formData.telemetryType;
|
|
17010
17198
|
}
|
|
17011
17199
|
getStyles() {
|
|
17012
17200
|
const styles = this.config.styles || {};
|
|
@@ -17030,7 +17218,7 @@ var PowerLimitsModalView = class {
|
|
|
17030
17218
|
opacity: 0;
|
|
17031
17219
|
visibility: hidden;
|
|
17032
17220
|
transition: all 0.3s ease;
|
|
17033
|
-
font-family: ${styles.fontFamily || '
|
|
17221
|
+
font-family: ${styles.fontFamily || "'Roboto', Arial, sans-serif"};
|
|
17034
17222
|
}
|
|
17035
17223
|
|
|
17036
17224
|
.myio-power-limits-overlay.active {
|
|
@@ -17040,9 +17228,9 @@ var PowerLimitsModalView = class {
|
|
|
17040
17228
|
|
|
17041
17229
|
.myio-power-limits-card {
|
|
17042
17230
|
background: ${styles.backgroundColor || "#ffffff"};
|
|
17043
|
-
border-radius: ${styles.borderRadius || "
|
|
17231
|
+
border-radius: ${styles.borderRadius || "10px"};
|
|
17044
17232
|
width: 90%;
|
|
17045
|
-
max-width:
|
|
17233
|
+
max-width: 1104px;
|
|
17046
17234
|
max-height: 90vh;
|
|
17047
17235
|
overflow-y: auto;
|
|
17048
17236
|
transform: scale(0.9);
|
|
@@ -17054,36 +17242,55 @@ var PowerLimitsModalView = class {
|
|
|
17054
17242
|
transform: scale(1);
|
|
17055
17243
|
}
|
|
17056
17244
|
|
|
17057
|
-
|
|
17245
|
+
/* Header - ModalPremiumShell pattern */
|
|
17246
|
+
.myio-modal-header {
|
|
17058
17247
|
display: flex;
|
|
17059
17248
|
align-items: center;
|
|
17060
17249
|
justify-content: space-between;
|
|
17061
|
-
padding:
|
|
17062
|
-
background:
|
|
17063
|
-
|
|
17064
|
-
|
|
17250
|
+
padding: 4px 8px;
|
|
17251
|
+
background: ${primaryColor};
|
|
17252
|
+
border-radius: 10px 10px 0 0;
|
|
17253
|
+
min-height: 20px;
|
|
17065
17254
|
}
|
|
17066
17255
|
|
|
17067
|
-
.myio-
|
|
17068
|
-
|
|
17069
|
-
|
|
17070
|
-
|
|
17256
|
+
.myio-modal-title {
|
|
17257
|
+
margin: 6px;
|
|
17258
|
+
font-size: 18px;
|
|
17259
|
+
font-weight: 600;
|
|
17260
|
+
color: white;
|
|
17261
|
+
line-height: 2;
|
|
17071
17262
|
}
|
|
17072
17263
|
|
|
17073
|
-
.myio-
|
|
17264
|
+
.myio-modal-close {
|
|
17265
|
+
background: none;
|
|
17266
|
+
border: none;
|
|
17074
17267
|
font-size: 24px;
|
|
17268
|
+
cursor: pointer;
|
|
17269
|
+
padding: 4px 12px;
|
|
17270
|
+
border-radius: 6px;
|
|
17271
|
+
color: rgba(255, 255, 255, 0.8);
|
|
17272
|
+
transition: background-color 0.2s, color 0.2s;
|
|
17273
|
+
line-height: 1;
|
|
17075
17274
|
}
|
|
17076
17275
|
|
|
17077
|
-
.myio-
|
|
17078
|
-
|
|
17079
|
-
|
|
17080
|
-
margin: 0;
|
|
17276
|
+
.myio-modal-close:hover {
|
|
17277
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
17278
|
+
color: white;
|
|
17081
17279
|
}
|
|
17082
17280
|
|
|
17083
|
-
|
|
17281
|
+
/* Toolbar with Save/Reset buttons */
|
|
17282
|
+
.myio-power-limits-toolbar {
|
|
17283
|
+
display: flex;
|
|
17284
|
+
justify-content: flex-end;
|
|
17285
|
+
padding: 16px 24px;
|
|
17286
|
+
background: #f9fafb;
|
|
17287
|
+
border-top: 1px solid #e5e7eb;
|
|
17288
|
+
}
|
|
17289
|
+
|
|
17290
|
+
.myio-toolbar-actions {
|
|
17084
17291
|
display: flex;
|
|
17085
17292
|
align-items: center;
|
|
17086
|
-
gap:
|
|
17293
|
+
gap: 12px;
|
|
17087
17294
|
}
|
|
17088
17295
|
|
|
17089
17296
|
.myio-btn {
|
|
@@ -17105,33 +17312,21 @@ var PowerLimitsModalView = class {
|
|
|
17105
17312
|
}
|
|
17106
17313
|
|
|
17107
17314
|
.myio-btn-primary {
|
|
17108
|
-
background:
|
|
17109
|
-
color:
|
|
17315
|
+
background: ${primaryColor};
|
|
17316
|
+
color: white;
|
|
17110
17317
|
}
|
|
17111
17318
|
|
|
17112
17319
|
.myio-btn-primary:hover:not(:disabled) {
|
|
17113
|
-
background:
|
|
17320
|
+
background: ${this.lightenColor(primaryColor, -10)};
|
|
17114
17321
|
}
|
|
17115
17322
|
|
|
17116
17323
|
.myio-btn-secondary {
|
|
17117
|
-
background:
|
|
17118
|
-
color:
|
|
17324
|
+
background: #e5e7eb;
|
|
17325
|
+
color: #374151;
|
|
17119
17326
|
}
|
|
17120
17327
|
|
|
17121
17328
|
.myio-btn-secondary:hover:not(:disabled) {
|
|
17122
|
-
background:
|
|
17123
|
-
}
|
|
17124
|
-
|
|
17125
|
-
.myio-btn-close {
|
|
17126
|
-
background: transparent;
|
|
17127
|
-
color: white;
|
|
17128
|
-
font-size: 24px;
|
|
17129
|
-
padding: 4px 8px;
|
|
17130
|
-
line-height: 1;
|
|
17131
|
-
}
|
|
17132
|
-
|
|
17133
|
-
.myio-btn-close:hover {
|
|
17134
|
-
background: rgba(255, 255, 255, 0.1);
|
|
17329
|
+
background: #d1d5db;
|
|
17135
17330
|
}
|
|
17136
17331
|
|
|
17137
17332
|
.myio-btn-spinner {
|
|
@@ -17149,7 +17344,7 @@ var PowerLimitsModalView = class {
|
|
|
17149
17344
|
|
|
17150
17345
|
.myio-power-limits-selectors {
|
|
17151
17346
|
display: grid;
|
|
17152
|
-
grid-template-columns: 1fr 1fr;
|
|
17347
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
17153
17348
|
gap: 16px;
|
|
17154
17349
|
padding: 20px 24px;
|
|
17155
17350
|
background: #f9fafb;
|
|
@@ -17184,6 +17379,15 @@ var PowerLimitsModalView = class {
|
|
|
17184
17379
|
box-shadow: 0 0 0 3px ${this.hexToRgba(primaryColor, 0.1)};
|
|
17185
17380
|
}
|
|
17186
17381
|
|
|
17382
|
+
.myio-fixed-value {
|
|
17383
|
+
padding: 10px 12px;
|
|
17384
|
+
border: 1px solid #e5e7eb;
|
|
17385
|
+
border-radius: 6px;
|
|
17386
|
+
font-size: 14px;
|
|
17387
|
+
background: #f9fafb;
|
|
17388
|
+
color: #6b7280;
|
|
17389
|
+
}
|
|
17390
|
+
|
|
17187
17391
|
.myio-power-limits-grid {
|
|
17188
17392
|
display: grid;
|
|
17189
17393
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -17212,6 +17416,11 @@ var PowerLimitsModalView = class {
|
|
|
17212
17416
|
margin-bottom: 12px;
|
|
17213
17417
|
}
|
|
17214
17418
|
|
|
17419
|
+
.myio-status-icon {
|
|
17420
|
+
font-size: 18px;
|
|
17421
|
+
line-height: 1;
|
|
17422
|
+
}
|
|
17423
|
+
|
|
17215
17424
|
.myio-status-indicator {
|
|
17216
17425
|
width: 12px;
|
|
17217
17426
|
height: 12px;
|
|
@@ -17402,6 +17611,8 @@ var PowerLimitsPersister = class {
|
|
|
17402
17611
|
const defaultFormData = {
|
|
17403
17612
|
deviceType,
|
|
17404
17613
|
telemetryType,
|
|
17614
|
+
domain: "energy",
|
|
17615
|
+
// Default to energy, will be overwritten by caller if needed
|
|
17405
17616
|
standby: { baseValue: null, topValue: null },
|
|
17406
17617
|
normal: { baseValue: null, topValue: null },
|
|
17407
17618
|
alert: { baseValue: null, topValue: null },
|
|
@@ -17571,10 +17782,12 @@ async function openPowerLimitsSetupModal(params) {
|
|
|
17571
17782
|
const persister = new PowerLimitsPersister(params.token, params.tbBaseUrl);
|
|
17572
17783
|
let currentDeviceType = params.deviceType || "ELEVADOR";
|
|
17573
17784
|
let currentTelemetryType = params.telemetryType || "consumption";
|
|
17785
|
+
let currentDomain = params.domain || "energy";
|
|
17574
17786
|
let existingLimits = params.existingMapPower || null;
|
|
17575
17787
|
const view = new PowerLimitsModalView({
|
|
17576
17788
|
deviceType: currentDeviceType,
|
|
17577
17789
|
telemetryType: currentTelemetryType,
|
|
17790
|
+
domain: currentDomain,
|
|
17578
17791
|
styles: params.styles,
|
|
17579
17792
|
locale: params.locale,
|
|
17580
17793
|
onDeviceTypeChange: async (deviceType) => {
|
|
@@ -17585,6 +17798,9 @@ async function openPowerLimitsSetupModal(params) {
|
|
|
17585
17798
|
currentTelemetryType = telemetryType;
|
|
17586
17799
|
await loadFormData();
|
|
17587
17800
|
},
|
|
17801
|
+
onDomainChange: (domain) => {
|
|
17802
|
+
currentDomain = domain;
|
|
17803
|
+
},
|
|
17588
17804
|
onSave: async () => {
|
|
17589
17805
|
const formData = view.getFormData();
|
|
17590
17806
|
const updatedLimits = persister.mergeFormDataIntoLimits(existingLimits, formData);
|
|
@@ -17610,6 +17826,7 @@ async function openPowerLimitsSetupModal(params) {
|
|
|
17610
17826
|
existingLimits = await persister.loadCustomerPowerLimits(params.customerId);
|
|
17611
17827
|
}
|
|
17612
17828
|
const formData = persister.extractFormData(existingLimits, currentDeviceType, currentTelemetryType);
|
|
17829
|
+
formData.domain = currentDomain;
|
|
17613
17830
|
view.setFormData(formData);
|
|
17614
17831
|
} catch (error) {
|
|
17615
17832
|
console.error("[PowerLimitsSetupModal] Error loading form data:", error);
|