myio-js-library 0.1.173 → 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.cjs
CHANGED
|
@@ -16785,35 +16785,72 @@ function validateOptions2(options) {
|
|
|
16785
16785
|
}
|
|
16786
16786
|
|
|
16787
16787
|
// src/components/premium-modals/power-limits/types.ts
|
|
16788
|
+
var DOMAINS = [
|
|
16789
|
+
{ value: "energy", label: "Energia", icon: "\u26A1" },
|
|
16790
|
+
{ value: "water", label: "\xC1gua", icon: "\u{1F4A7}" },
|
|
16791
|
+
{ value: "temperature", label: "Temperatura", icon: "\u{1F321}\uFE0F" }
|
|
16792
|
+
];
|
|
16788
16793
|
var DEVICE_TYPES = [
|
|
16789
|
-
{ value: "ELEVADOR", label: "
|
|
16790
|
-
{ value: "ESCADA_ROLANTE", label: "
|
|
16794
|
+
{ value: "ELEVADOR", label: "Elevador" },
|
|
16795
|
+
{ value: "ESCADA_ROLANTE", label: "Escada Rolante" },
|
|
16791
16796
|
{ value: "MOTOR", label: "Motor" },
|
|
16792
|
-
{ value: "BOMBA", label: "
|
|
16797
|
+
{ value: "BOMBA", label: "Bomba" },
|
|
16793
16798
|
{ value: "CHILLER", label: "Chiller" },
|
|
16794
|
-
{ value: "AR_CONDICIONADO", label: "
|
|
16799
|
+
{ value: "AR_CONDICIONADO", label: "Ar Condicionado" },
|
|
16795
16800
|
{ value: "HVAC", label: "HVAC" },
|
|
16796
16801
|
{ value: "FANCOIL", label: "Fancoil" },
|
|
16797
|
-
{ value: "3F_MEDIDOR", label: "
|
|
16802
|
+
{ value: "3F_MEDIDOR", label: "Medidor Trif\xE1sico" }
|
|
16798
16803
|
];
|
|
16799
16804
|
var TELEMETRY_TYPES2 = [
|
|
16800
|
-
{ value: "consumption", label: "
|
|
16801
|
-
{ value: "voltage_a", label: "
|
|
16802
|
-
{ value: "voltage_b", label: "
|
|
16803
|
-
{ value: "voltage_c", label: "
|
|
16804
|
-
{ value: "current_a", label: "
|
|
16805
|
-
{ value: "current_b", label: "
|
|
16806
|
-
{ value: "current_c", label: "
|
|
16807
|
-
{ value: "total_current", label: "Total
|
|
16808
|
-
{ value: "fp_a", label: "
|
|
16809
|
-
{ value: "fp_b", label: "
|
|
16810
|
-
{ value: "fp_c", label: "
|
|
16805
|
+
{ value: "consumption", label: "Pot\xEAncia (kW)", unit: "kW" },
|
|
16806
|
+
{ value: "voltage_a", label: "Tens\xE3o A (V)", unit: "V" },
|
|
16807
|
+
{ value: "voltage_b", label: "Tens\xE3o B (V)", unit: "V" },
|
|
16808
|
+
{ value: "voltage_c", label: "Tens\xE3o C (V)", unit: "V" },
|
|
16809
|
+
{ value: "current_a", label: "Corrente A (A)", unit: "A" },
|
|
16810
|
+
{ value: "current_b", label: "Corrente B (A)", unit: "A" },
|
|
16811
|
+
{ value: "current_c", label: "Corrente C (A)", unit: "A" },
|
|
16812
|
+
{ value: "total_current", label: "Corrente Total (A)", unit: "A" },
|
|
16813
|
+
{ value: "fp_a", label: "Fator de Pot\xEAncia A", unit: "" },
|
|
16814
|
+
{ value: "fp_b", label: "Fator de Pot\xEAncia B", unit: "" },
|
|
16815
|
+
{ value: "fp_c", label: "Fator de Pot\xEAncia C", unit: "" }
|
|
16811
16816
|
];
|
|
16817
|
+
var STATUS_ICONS = {
|
|
16818
|
+
energy: {
|
|
16819
|
+
standBy: "\u{1F50C}",
|
|
16820
|
+
// STANDBY
|
|
16821
|
+
normal: "\u26A1",
|
|
16822
|
+
// POWER_ON
|
|
16823
|
+
alert: "\u26A0\uFE0F",
|
|
16824
|
+
// WARNING
|
|
16825
|
+
failure: "\u{1F6A8}"
|
|
16826
|
+
// FAILURE
|
|
16827
|
+
},
|
|
16828
|
+
water: {
|
|
16829
|
+
standBy: "\u{1F6B0}",
|
|
16830
|
+
// STANDBY
|
|
16831
|
+
normal: "\u{1F4A7}",
|
|
16832
|
+
// POWER_ON
|
|
16833
|
+
alert: "\u26A0\uFE0F",
|
|
16834
|
+
// WARNING
|
|
16835
|
+
failure: "\u{1F6A8}"
|
|
16836
|
+
// FAILURE
|
|
16837
|
+
},
|
|
16838
|
+
temperature: {
|
|
16839
|
+
standBy: "\u{1F321}\uFE0F",
|
|
16840
|
+
// STANDBY
|
|
16841
|
+
normal: "\u{1F321}\uFE0F",
|
|
16842
|
+
// POWER_ON
|
|
16843
|
+
alert: "\u26A0\uFE0F",
|
|
16844
|
+
// WARNING
|
|
16845
|
+
failure: "\u{1F6A8}"
|
|
16846
|
+
// FAILURE
|
|
16847
|
+
}
|
|
16848
|
+
};
|
|
16812
16849
|
var STATUS_CONFIG = {
|
|
16813
16850
|
standBy: { label: "StandBy", color: "#22c55e", bgColor: "rgba(34, 197, 94, 0.1)" },
|
|
16814
16851
|
normal: { label: "Normal", color: "#3b82f6", bgColor: "rgba(59, 130, 246, 0.1)" },
|
|
16815
|
-
alert: { label: "
|
|
16816
|
-
failure: { label: "
|
|
16852
|
+
alert: { label: "Alerta", color: "#f59e0b", bgColor: "rgba(245, 158, 11, 0.1)" },
|
|
16853
|
+
failure: { label: "Falha", color: "#ef4444", bgColor: "rgba(239, 68, 68, 0.1)" }
|
|
16817
16854
|
};
|
|
16818
16855
|
|
|
16819
16856
|
// src/components/premium-modals/power-limits/PowerLimitsModalView.ts
|
|
@@ -16829,12 +16866,43 @@ var PowerLimitsModalView = class {
|
|
|
16829
16866
|
this.formData = {
|
|
16830
16867
|
deviceType: config.deviceType,
|
|
16831
16868
|
telemetryType: config.telemetryType,
|
|
16869
|
+
domain: config.domain,
|
|
16832
16870
|
standby: { baseValue: null, topValue: null },
|
|
16833
16871
|
normal: { baseValue: null, topValue: null },
|
|
16834
16872
|
alert: { baseValue: null, topValue: null },
|
|
16835
16873
|
failure: { baseValue: null, topValue: null }
|
|
16836
16874
|
};
|
|
16837
16875
|
}
|
|
16876
|
+
// Format number with thousand separator (.) and up to 2 decimal places
|
|
16877
|
+
formatNumberForDisplay(value) {
|
|
16878
|
+
if (value === null || value === void 0) return "";
|
|
16879
|
+
const parts = value.toFixed(2).split(".");
|
|
16880
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
16881
|
+
return parts.join(",");
|
|
16882
|
+
}
|
|
16883
|
+
// Parse formatted string back to number
|
|
16884
|
+
parseFormattedNumber(value) {
|
|
16885
|
+
if (!value || value.trim() === "") return null;
|
|
16886
|
+
const normalized = value.replace(/\./g, "").replace(",", ".");
|
|
16887
|
+
const num = parseFloat(normalized);
|
|
16888
|
+
return isNaN(num) ? null : num;
|
|
16889
|
+
}
|
|
16890
|
+
// Handle input formatting on blur
|
|
16891
|
+
formatInputValue(input) {
|
|
16892
|
+
const rawValue = input.value;
|
|
16893
|
+
const parsed = this.parseFormattedNumber(rawValue);
|
|
16894
|
+
if (parsed !== null) {
|
|
16895
|
+
input.value = this.formatNumberForDisplay(parsed);
|
|
16896
|
+
}
|
|
16897
|
+
}
|
|
16898
|
+
// Handle input on focus - show raw value for editing
|
|
16899
|
+
unformatInputValue(input) {
|
|
16900
|
+
const formatted = input.value;
|
|
16901
|
+
const parsed = this.parseFormattedNumber(formatted);
|
|
16902
|
+
if (parsed !== null) {
|
|
16903
|
+
input.value = parsed.toString().replace(".", ",");
|
|
16904
|
+
}
|
|
16905
|
+
}
|
|
16838
16906
|
render(targetContainer) {
|
|
16839
16907
|
this.overlayEl = document.createElement("div");
|
|
16840
16908
|
this.overlayEl.className = "myio-power-limits-overlay";
|
|
@@ -16844,6 +16912,7 @@ var PowerLimitsModalView = class {
|
|
|
16844
16912
|
${this.renderHeader()}
|
|
16845
16913
|
${this.renderSelectors()}
|
|
16846
16914
|
${this.renderStatusCards()}
|
|
16915
|
+
${this.renderToolbar()}
|
|
16847
16916
|
${this.renderLoadingState()}
|
|
16848
16917
|
${this.renderErrorState()}
|
|
16849
16918
|
${this.renderSuccessState()}
|
|
@@ -16860,80 +16929,107 @@ var PowerLimitsModalView = class {
|
|
|
16860
16929
|
}
|
|
16861
16930
|
renderHeader() {
|
|
16862
16931
|
return `
|
|
16863
|
-
<div class="myio-
|
|
16864
|
-
<
|
|
16865
|
-
|
|
16866
|
-
|
|
16867
|
-
|
|
16868
|
-
|
|
16932
|
+
<div class="myio-modal-header">
|
|
16933
|
+
<h2 class="myio-modal-title">\u2699\uFE0F Configura\xE7\xE3o de Limites</h2>
|
|
16934
|
+
<button class="myio-modal-close" id="plm-close-btn" type="button" aria-label="Fechar modal">\xD7</button>
|
|
16935
|
+
</div>
|
|
16936
|
+
`;
|
|
16937
|
+
}
|
|
16938
|
+
renderToolbar() {
|
|
16939
|
+
return `
|
|
16940
|
+
<div class="myio-power-limits-toolbar">
|
|
16941
|
+
<div class="myio-toolbar-actions">
|
|
16942
|
+
<button class="myio-btn myio-btn-secondary" id="plm-reset-btn" type="button">Limpar</button>
|
|
16869
16943
|
<button class="myio-btn myio-btn-primary" id="plm-save-btn" type="button">
|
|
16870
|
-
<span class="myio-btn-text">
|
|
16944
|
+
<span class="myio-btn-text">Salvar</span>
|
|
16871
16945
|
<span class="myio-btn-spinner" style="display: none;"></span>
|
|
16872
16946
|
</button>
|
|
16873
|
-
<button class="myio-btn myio-btn-secondary" id="plm-reset-btn" type="button">Reset</button>
|
|
16874
|
-
<button class="myio-btn myio-btn-close" id="plm-close-btn" type="button" aria-label="Close">×</button>
|
|
16875
16947
|
</div>
|
|
16876
16948
|
</div>
|
|
16877
16949
|
`;
|
|
16878
16950
|
}
|
|
16879
16951
|
renderSelectors() {
|
|
16880
|
-
const
|
|
16881
|
-
|
|
16882
|
-
|
|
16883
|
-
const telemetryOptions = TELEMETRY_TYPES2.map(
|
|
16884
|
-
(tt) => `<option value="${tt.value}" ${tt.value === this.config.telemetryType ? "selected" : ""}>${tt.label}</option>`
|
|
16952
|
+
const domain = this.formData.domain || "energy";
|
|
16953
|
+
const domainOptions = DOMAINS.map(
|
|
16954
|
+
(d) => `<option value="${d.value}" ${d.value === domain ? "selected" : ""}>${d.icon} ${d.label}</option>`
|
|
16885
16955
|
).join("");
|
|
16956
|
+
let deviceTypeContent;
|
|
16957
|
+
let telemetryLabel;
|
|
16958
|
+
switch (domain) {
|
|
16959
|
+
case "temperature":
|
|
16960
|
+
deviceTypeContent = `<div class="myio-fixed-value">Sensor de Temperatura</div>`;
|
|
16961
|
+
telemetryLabel = "Temperatura em Celsius";
|
|
16962
|
+
break;
|
|
16963
|
+
case "water":
|
|
16964
|
+
deviceTypeContent = `<div class="myio-fixed-value">Hidr\xF4metro</div>`;
|
|
16965
|
+
telemetryLabel = "Litros";
|
|
16966
|
+
break;
|
|
16967
|
+
case "energy":
|
|
16968
|
+
default:
|
|
16969
|
+
deviceTypeContent = `<select id="plm-device-type" class="myio-select">
|
|
16970
|
+
${DEVICE_TYPES.map(
|
|
16971
|
+
(dt) => `<option value="${dt.value}" ${dt.value === this.formData.deviceType ? "selected" : ""}>${dt.label}</option>`
|
|
16972
|
+
).join("")}
|
|
16973
|
+
</select>`;
|
|
16974
|
+
telemetryLabel = "Pot\xEAncia (kW)";
|
|
16975
|
+
break;
|
|
16976
|
+
}
|
|
16886
16977
|
return `
|
|
16887
16978
|
<div class="myio-power-limits-selectors">
|
|
16888
16979
|
<div class="myio-form-group">
|
|
16889
|
-
<label for="plm-
|
|
16890
|
-
<select id="plm-
|
|
16891
|
-
${
|
|
16980
|
+
<label for="plm-domain">Dom\xEDnio</label>
|
|
16981
|
+
<select id="plm-domain" class="myio-select">
|
|
16982
|
+
${domainOptions}
|
|
16892
16983
|
</select>
|
|
16893
16984
|
</div>
|
|
16894
16985
|
<div class="myio-form-group">
|
|
16895
|
-
<label
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16986
|
+
<label>Tipo de Dispositivo</label>
|
|
16987
|
+
${deviceTypeContent}
|
|
16988
|
+
</div>
|
|
16989
|
+
<div class="myio-form-group">
|
|
16990
|
+
<label>Tipo de Telemetria</label>
|
|
16991
|
+
<div class="myio-fixed-value">${telemetryLabel}</div>
|
|
16899
16992
|
</div>
|
|
16900
16993
|
</div>
|
|
16901
16994
|
`;
|
|
16902
16995
|
}
|
|
16903
16996
|
renderStatusCards() {
|
|
16904
16997
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
16998
|
+
const domain = this.formData.domain || "energy";
|
|
16999
|
+
const domainIcons = STATUS_ICONS[domain];
|
|
16905
17000
|
const cards = statuses.map((status) => {
|
|
16906
|
-
const
|
|
17001
|
+
const statusKey = status === "standby" ? "standBy" : status;
|
|
17002
|
+
const config = STATUS_CONFIG[statusKey];
|
|
16907
17003
|
const formValues = this.formData[status];
|
|
17004
|
+
const icon = domainIcons[statusKey];
|
|
16908
17005
|
return `
|
|
16909
17006
|
<div class="myio-power-limits-card-item myio-status-${status}" style="--status-color: ${config.color}; --status-bg: ${config.bgColor};">
|
|
16910
17007
|
<div class="myio-card-header">
|
|
17008
|
+
<span class="myio-status-icon">${icon}</span>
|
|
16911
17009
|
<span class="myio-status-indicator"></span>
|
|
16912
17010
|
<span class="myio-status-label">${config.label}</span>
|
|
16913
17011
|
</div>
|
|
16914
17012
|
<div class="myio-card-inputs">
|
|
16915
17013
|
<div class="myio-input-group">
|
|
16916
|
-
<label for="plm-${status}-base">
|
|
17014
|
+
<label for="plm-${status}-base">Limite Inferior</label>
|
|
16917
17015
|
<input
|
|
16918
|
-
type="
|
|
17016
|
+
type="text"
|
|
16919
17017
|
id="plm-${status}-base"
|
|
16920
|
-
class="myio-input"
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
16924
|
-
placeholder="0"
|
|
17018
|
+
class="myio-input myio-formatted-number"
|
|
17019
|
+
inputmode="decimal"
|
|
17020
|
+
value="${this.formatNumberForDisplay(formValues.baseValue)}"
|
|
17021
|
+
placeholder="0,00"
|
|
16925
17022
|
>
|
|
16926
17023
|
</div>
|
|
16927
17024
|
<div class="myio-input-group">
|
|
16928
|
-
<label for="plm-${status}-top">
|
|
17025
|
+
<label for="plm-${status}-top">Limite Superior</label>
|
|
16929
17026
|
<input
|
|
16930
|
-
type="
|
|
17027
|
+
type="text"
|
|
16931
17028
|
id="plm-${status}-top"
|
|
16932
|
-
class="myio-input"
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
placeholder="0"
|
|
17029
|
+
class="myio-input myio-formatted-number"
|
|
17030
|
+
inputmode="decimal"
|
|
17031
|
+
value="${this.formatNumberForDisplay(formValues.topValue)}"
|
|
17032
|
+
placeholder="0,00"
|
|
16937
17033
|
>
|
|
16938
17034
|
</div>
|
|
16939
17035
|
</div>
|
|
@@ -16950,7 +17046,7 @@ var PowerLimitsModalView = class {
|
|
|
16950
17046
|
return `
|
|
16951
17047
|
<div class="myio-power-limits-loading" id="plm-loading" style="display: none;">
|
|
16952
17048
|
<div class="myio-spinner"></div>
|
|
16953
|
-
<span>
|
|
17049
|
+
<span>Carregando configura\xE7\xE3o...</span>
|
|
16954
17050
|
</div>
|
|
16955
17051
|
`;
|
|
16956
17052
|
}
|
|
@@ -16966,7 +17062,7 @@ var PowerLimitsModalView = class {
|
|
|
16966
17062
|
return `
|
|
16967
17063
|
<div class="myio-power-limits-success" id="plm-success" style="display: none;">
|
|
16968
17064
|
<span class="myio-success-icon">✓</span>
|
|
16969
|
-
<span class="myio-success-message">
|
|
17065
|
+
<span class="myio-success-message">Configura\xE7\xE3o salva com sucesso!</span>
|
|
16970
17066
|
</div>
|
|
16971
17067
|
`;
|
|
16972
17068
|
}
|
|
@@ -16984,31 +17080,121 @@ var PowerLimitsModalView = class {
|
|
|
16984
17080
|
saveBtn?.addEventListener("click", () => this.handleSave());
|
|
16985
17081
|
const resetBtn = this.overlayEl.querySelector("#plm-reset-btn");
|
|
16986
17082
|
resetBtn?.addEventListener("click", () => this.handleReset());
|
|
16987
|
-
const
|
|
16988
|
-
|
|
16989
|
-
const value = e.target.value;
|
|
16990
|
-
this.formData.deviceType = value;
|
|
16991
|
-
this.config.onDeviceTypeChange(value);
|
|
16992
|
-
});
|
|
16993
|
-
const telemetrySelect = this.overlayEl.querySelector("#plm-telemetry-type");
|
|
16994
|
-
telemetrySelect?.addEventListener("change", (e) => {
|
|
17083
|
+
const domainSelect = this.overlayEl.querySelector("#plm-domain");
|
|
17084
|
+
domainSelect?.addEventListener("change", (e) => {
|
|
16995
17085
|
const value = e.target.value;
|
|
16996
|
-
this.formData.
|
|
16997
|
-
|
|
17086
|
+
this.formData.domain = value;
|
|
17087
|
+
switch (value) {
|
|
17088
|
+
case "temperature":
|
|
17089
|
+
this.formData.deviceType = "SENSOR_TEMPERATURA";
|
|
17090
|
+
this.formData.telemetryType = "temperature";
|
|
17091
|
+
break;
|
|
17092
|
+
case "water":
|
|
17093
|
+
this.formData.deviceType = "HIDROMETRO";
|
|
17094
|
+
this.formData.telemetryType = "liters";
|
|
17095
|
+
break;
|
|
17096
|
+
case "energy":
|
|
17097
|
+
default:
|
|
17098
|
+
this.formData.telemetryType = "consumption";
|
|
17099
|
+
break;
|
|
17100
|
+
}
|
|
17101
|
+
this.config.onDomainChange(value);
|
|
17102
|
+
this.updateSelectorsUI();
|
|
17103
|
+
this.updateStatusIcons();
|
|
16998
17104
|
});
|
|
17105
|
+
this.setupDeviceTypeListener();
|
|
16999
17106
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
17000
17107
|
statuses.forEach((status) => {
|
|
17001
17108
|
const baseInput = this.overlayEl?.querySelector(`#plm-${status}-base`);
|
|
17002
17109
|
const topInput = this.overlayEl?.querySelector(`#plm-${status}-top`);
|
|
17003
|
-
|
|
17110
|
+
if (baseInput) {
|
|
17111
|
+
baseInput.addEventListener("focus", () => this.unformatInputValue(baseInput));
|
|
17112
|
+
baseInput.addEventListener("blur", () => {
|
|
17113
|
+
this.formData[status].baseValue = this.parseFormattedNumber(baseInput.value);
|
|
17114
|
+
this.formatInputValue(baseInput);
|
|
17115
|
+
});
|
|
17116
|
+
baseInput.addEventListener("keydown", (e) => this.handleNumberKeydown(e));
|
|
17117
|
+
}
|
|
17118
|
+
if (topInput) {
|
|
17119
|
+
topInput.addEventListener("focus", () => this.unformatInputValue(topInput));
|
|
17120
|
+
topInput.addEventListener("blur", () => {
|
|
17121
|
+
this.formData[status].topValue = this.parseFormattedNumber(topInput.value);
|
|
17122
|
+
this.formatInputValue(topInput);
|
|
17123
|
+
});
|
|
17124
|
+
topInput.addEventListener("keydown", (e) => this.handleNumberKeydown(e));
|
|
17125
|
+
}
|
|
17126
|
+
});
|
|
17127
|
+
}
|
|
17128
|
+
// Handle keyboard input to allow only valid number characters
|
|
17129
|
+
handleNumberKeydown(e) {
|
|
17130
|
+
const allowedKeys = ["Backspace", "Delete", "ArrowLeft", "ArrowRight", "Tab", "Home", "End"];
|
|
17131
|
+
const isDigit = /^\d$/.test(e.key);
|
|
17132
|
+
const isComma = e.key === ",";
|
|
17133
|
+
const isAllowedKey = allowedKeys.includes(e.key);
|
|
17134
|
+
const hasCtrl = e.ctrlKey || e.metaKey;
|
|
17135
|
+
if (!isDigit && !isComma && !isAllowedKey && !hasCtrl) {
|
|
17136
|
+
e.preventDefault();
|
|
17137
|
+
}
|
|
17138
|
+
if (isComma) {
|
|
17139
|
+
const input = e.target;
|
|
17140
|
+
if (input.value.includes(",")) {
|
|
17141
|
+
e.preventDefault();
|
|
17142
|
+
}
|
|
17143
|
+
}
|
|
17144
|
+
}
|
|
17145
|
+
// Update status icons when domain changes
|
|
17146
|
+
updateStatusIcons() {
|
|
17147
|
+
const domain = this.formData.domain || "energy";
|
|
17148
|
+
const domainIcons = STATUS_ICONS[domain];
|
|
17149
|
+
const statuses = ["standby", "normal", "alert", "failure"];
|
|
17150
|
+
statuses.forEach((status) => {
|
|
17151
|
+
const statusKey = status === "standby" ? "standBy" : status;
|
|
17152
|
+
const iconEl = this.overlayEl?.querySelector(`.myio-status-${status} .myio-status-icon`);
|
|
17153
|
+
if (iconEl) {
|
|
17154
|
+
iconEl.textContent = domainIcons[statusKey];
|
|
17155
|
+
}
|
|
17156
|
+
});
|
|
17157
|
+
}
|
|
17158
|
+
// Update selectors UI when domain changes
|
|
17159
|
+
updateSelectorsUI() {
|
|
17160
|
+
const selectorsContainer = this.overlayEl?.querySelector(".myio-power-limits-selectors");
|
|
17161
|
+
if (selectorsContainer) {
|
|
17162
|
+
selectorsContainer.outerHTML = this.renderSelectors();
|
|
17163
|
+
const domainSelect = this.overlayEl?.querySelector("#plm-domain");
|
|
17164
|
+
domainSelect?.addEventListener("change", (e) => {
|
|
17004
17165
|
const value = e.target.value;
|
|
17005
|
-
this.formData
|
|
17166
|
+
this.formData.domain = value;
|
|
17167
|
+
switch (value) {
|
|
17168
|
+
case "temperature":
|
|
17169
|
+
this.formData.deviceType = "SENSOR_TEMPERATURA";
|
|
17170
|
+
this.formData.telemetryType = "temperature";
|
|
17171
|
+
break;
|
|
17172
|
+
case "water":
|
|
17173
|
+
this.formData.deviceType = "HIDROMETRO";
|
|
17174
|
+
this.formData.telemetryType = "liters";
|
|
17175
|
+
break;
|
|
17176
|
+
case "energy":
|
|
17177
|
+
default:
|
|
17178
|
+
this.formData.telemetryType = "consumption";
|
|
17179
|
+
break;
|
|
17180
|
+
}
|
|
17181
|
+
this.config.onDomainChange(value);
|
|
17182
|
+
this.updateSelectorsUI();
|
|
17183
|
+
this.updateStatusIcons();
|
|
17006
17184
|
});
|
|
17007
|
-
|
|
17185
|
+
this.setupDeviceTypeListener();
|
|
17186
|
+
}
|
|
17187
|
+
}
|
|
17188
|
+
// Setup device type listener (only for energy/water domains)
|
|
17189
|
+
setupDeviceTypeListener() {
|
|
17190
|
+
const deviceSelect = this.overlayEl?.querySelector("#plm-device-type");
|
|
17191
|
+
if (deviceSelect) {
|
|
17192
|
+
deviceSelect.addEventListener("change", (e) => {
|
|
17008
17193
|
const value = e.target.value;
|
|
17009
|
-
this.formData
|
|
17194
|
+
this.formData.deviceType = value;
|
|
17195
|
+
this.config.onDeviceTypeChange(value);
|
|
17010
17196
|
});
|
|
17011
|
-
}
|
|
17197
|
+
}
|
|
17012
17198
|
}
|
|
17013
17199
|
handleKeyDown = (e) => {
|
|
17014
17200
|
if (e.key === "Escape") {
|
|
@@ -17031,7 +17217,7 @@ var PowerLimitsModalView = class {
|
|
|
17031
17217
|
this.showSuccess();
|
|
17032
17218
|
setTimeout(() => this.hideSuccess(), 3e3);
|
|
17033
17219
|
} catch (error) {
|
|
17034
|
-
this.showError(error.message || "
|
|
17220
|
+
this.showError(error.message || "Falha ao salvar configura\xE7\xE3o");
|
|
17035
17221
|
} finally {
|
|
17036
17222
|
this.isSaving = false;
|
|
17037
17223
|
this.showSaveLoading(false);
|
|
@@ -17055,13 +17241,13 @@ var PowerLimitsModalView = class {
|
|
|
17055
17241
|
const base = this.formData[status].baseValue;
|
|
17056
17242
|
const top = this.formData[status].topValue;
|
|
17057
17243
|
if (base !== null && base < 0) {
|
|
17058
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
17244
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite inferior n\xE3o pode ser negativo`;
|
|
17059
17245
|
}
|
|
17060
17246
|
if (top !== null && top < 0) {
|
|
17061
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
17247
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite superior n\xE3o pode ser negativo`;
|
|
17062
17248
|
}
|
|
17063
17249
|
if (base !== null && top !== null && base > top) {
|
|
17064
|
-
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}:
|
|
17250
|
+
return `${STATUS_CONFIG[status === "standby" ? "standBy" : status].label}: Limite inferior n\xE3o pode ser maior que o limite superior`;
|
|
17065
17251
|
}
|
|
17066
17252
|
}
|
|
17067
17253
|
return null;
|
|
@@ -17130,11 +17316,13 @@ var PowerLimitsModalView = class {
|
|
|
17130
17316
|
setFormData(data) {
|
|
17131
17317
|
if (data.deviceType) this.formData.deviceType = data.deviceType;
|
|
17132
17318
|
if (data.telemetryType) this.formData.telemetryType = data.telemetryType;
|
|
17319
|
+
if (data.domain) this.formData.domain = data.domain;
|
|
17133
17320
|
if (data.standby) this.formData.standby = { ...data.standby };
|
|
17134
17321
|
if (data.normal) this.formData.normal = { ...data.normal };
|
|
17135
17322
|
if (data.alert) this.formData.alert = { ...data.alert };
|
|
17136
17323
|
if (data.failure) this.formData.failure = { ...data.failure };
|
|
17137
17324
|
this.updateInputValues();
|
|
17325
|
+
this.updateStatusIcons();
|
|
17138
17326
|
}
|
|
17139
17327
|
updateInputValues() {
|
|
17140
17328
|
const statuses = ["standby", "normal", "alert", "failure"];
|
|
@@ -17142,16 +17330,16 @@ var PowerLimitsModalView = class {
|
|
|
17142
17330
|
const baseInput = this.overlayEl?.querySelector(`#plm-${status}-base`);
|
|
17143
17331
|
const topInput = this.overlayEl?.querySelector(`#plm-${status}-top`);
|
|
17144
17332
|
if (baseInput) {
|
|
17145
|
-
baseInput.value = this.formData[status].baseValue
|
|
17333
|
+
baseInput.value = this.formatNumberForDisplay(this.formData[status].baseValue);
|
|
17146
17334
|
}
|
|
17147
17335
|
if (topInput) {
|
|
17148
|
-
topInput.value = this.formData[status].topValue
|
|
17336
|
+
topInput.value = this.formatNumberForDisplay(this.formData[status].topValue);
|
|
17149
17337
|
}
|
|
17150
17338
|
});
|
|
17339
|
+
const domainSelect = this.overlayEl?.querySelector("#plm-domain");
|
|
17151
17340
|
const deviceSelect = this.overlayEl?.querySelector("#plm-device-type");
|
|
17152
|
-
|
|
17341
|
+
if (domainSelect) domainSelect.value = this.formData.domain;
|
|
17153
17342
|
if (deviceSelect) deviceSelect.value = this.formData.deviceType;
|
|
17154
|
-
if (telemetrySelect) telemetrySelect.value = this.formData.telemetryType;
|
|
17155
17343
|
}
|
|
17156
17344
|
getStyles() {
|
|
17157
17345
|
const styles = this.config.styles || {};
|
|
@@ -17175,7 +17363,7 @@ var PowerLimitsModalView = class {
|
|
|
17175
17363
|
opacity: 0;
|
|
17176
17364
|
visibility: hidden;
|
|
17177
17365
|
transition: all 0.3s ease;
|
|
17178
|
-
font-family: ${styles.fontFamily || '
|
|
17366
|
+
font-family: ${styles.fontFamily || "'Roboto', Arial, sans-serif"};
|
|
17179
17367
|
}
|
|
17180
17368
|
|
|
17181
17369
|
.myio-power-limits-overlay.active {
|
|
@@ -17185,9 +17373,9 @@ var PowerLimitsModalView = class {
|
|
|
17185
17373
|
|
|
17186
17374
|
.myio-power-limits-card {
|
|
17187
17375
|
background: ${styles.backgroundColor || "#ffffff"};
|
|
17188
|
-
border-radius: ${styles.borderRadius || "
|
|
17376
|
+
border-radius: ${styles.borderRadius || "10px"};
|
|
17189
17377
|
width: 90%;
|
|
17190
|
-
max-width:
|
|
17378
|
+
max-width: 1104px;
|
|
17191
17379
|
max-height: 90vh;
|
|
17192
17380
|
overflow-y: auto;
|
|
17193
17381
|
transform: scale(0.9);
|
|
@@ -17199,36 +17387,55 @@ var PowerLimitsModalView = class {
|
|
|
17199
17387
|
transform: scale(1);
|
|
17200
17388
|
}
|
|
17201
17389
|
|
|
17202
|
-
|
|
17390
|
+
/* Header - ModalPremiumShell pattern */
|
|
17391
|
+
.myio-modal-header {
|
|
17203
17392
|
display: flex;
|
|
17204
17393
|
align-items: center;
|
|
17205
17394
|
justify-content: space-between;
|
|
17206
|
-
padding:
|
|
17207
|
-
background:
|
|
17208
|
-
|
|
17209
|
-
|
|
17395
|
+
padding: 4px 8px;
|
|
17396
|
+
background: ${primaryColor};
|
|
17397
|
+
border-radius: 10px 10px 0 0;
|
|
17398
|
+
min-height: 20px;
|
|
17210
17399
|
}
|
|
17211
17400
|
|
|
17212
|
-
.myio-
|
|
17213
|
-
|
|
17214
|
-
|
|
17215
|
-
|
|
17401
|
+
.myio-modal-title {
|
|
17402
|
+
margin: 6px;
|
|
17403
|
+
font-size: 18px;
|
|
17404
|
+
font-weight: 600;
|
|
17405
|
+
color: white;
|
|
17406
|
+
line-height: 2;
|
|
17216
17407
|
}
|
|
17217
17408
|
|
|
17218
|
-
.myio-
|
|
17409
|
+
.myio-modal-close {
|
|
17410
|
+
background: none;
|
|
17411
|
+
border: none;
|
|
17219
17412
|
font-size: 24px;
|
|
17413
|
+
cursor: pointer;
|
|
17414
|
+
padding: 4px 12px;
|
|
17415
|
+
border-radius: 6px;
|
|
17416
|
+
color: rgba(255, 255, 255, 0.8);
|
|
17417
|
+
transition: background-color 0.2s, color 0.2s;
|
|
17418
|
+
line-height: 1;
|
|
17220
17419
|
}
|
|
17221
17420
|
|
|
17222
|
-
.myio-
|
|
17223
|
-
|
|
17224
|
-
|
|
17225
|
-
margin: 0;
|
|
17421
|
+
.myio-modal-close:hover {
|
|
17422
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
17423
|
+
color: white;
|
|
17226
17424
|
}
|
|
17227
17425
|
|
|
17228
|
-
|
|
17426
|
+
/* Toolbar with Save/Reset buttons */
|
|
17427
|
+
.myio-power-limits-toolbar {
|
|
17428
|
+
display: flex;
|
|
17429
|
+
justify-content: flex-end;
|
|
17430
|
+
padding: 16px 24px;
|
|
17431
|
+
background: #f9fafb;
|
|
17432
|
+
border-top: 1px solid #e5e7eb;
|
|
17433
|
+
}
|
|
17434
|
+
|
|
17435
|
+
.myio-toolbar-actions {
|
|
17229
17436
|
display: flex;
|
|
17230
17437
|
align-items: center;
|
|
17231
|
-
gap:
|
|
17438
|
+
gap: 12px;
|
|
17232
17439
|
}
|
|
17233
17440
|
|
|
17234
17441
|
.myio-btn {
|
|
@@ -17250,33 +17457,21 @@ var PowerLimitsModalView = class {
|
|
|
17250
17457
|
}
|
|
17251
17458
|
|
|
17252
17459
|
.myio-btn-primary {
|
|
17253
|
-
background:
|
|
17254
|
-
color:
|
|
17460
|
+
background: ${primaryColor};
|
|
17461
|
+
color: white;
|
|
17255
17462
|
}
|
|
17256
17463
|
|
|
17257
17464
|
.myio-btn-primary:hover:not(:disabled) {
|
|
17258
|
-
background:
|
|
17465
|
+
background: ${this.lightenColor(primaryColor, -10)};
|
|
17259
17466
|
}
|
|
17260
17467
|
|
|
17261
17468
|
.myio-btn-secondary {
|
|
17262
|
-
background:
|
|
17263
|
-
color:
|
|
17469
|
+
background: #e5e7eb;
|
|
17470
|
+
color: #374151;
|
|
17264
17471
|
}
|
|
17265
17472
|
|
|
17266
17473
|
.myio-btn-secondary:hover:not(:disabled) {
|
|
17267
|
-
background:
|
|
17268
|
-
}
|
|
17269
|
-
|
|
17270
|
-
.myio-btn-close {
|
|
17271
|
-
background: transparent;
|
|
17272
|
-
color: white;
|
|
17273
|
-
font-size: 24px;
|
|
17274
|
-
padding: 4px 8px;
|
|
17275
|
-
line-height: 1;
|
|
17276
|
-
}
|
|
17277
|
-
|
|
17278
|
-
.myio-btn-close:hover {
|
|
17279
|
-
background: rgba(255, 255, 255, 0.1);
|
|
17474
|
+
background: #d1d5db;
|
|
17280
17475
|
}
|
|
17281
17476
|
|
|
17282
17477
|
.myio-btn-spinner {
|
|
@@ -17294,7 +17489,7 @@ var PowerLimitsModalView = class {
|
|
|
17294
17489
|
|
|
17295
17490
|
.myio-power-limits-selectors {
|
|
17296
17491
|
display: grid;
|
|
17297
|
-
grid-template-columns: 1fr 1fr;
|
|
17492
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
17298
17493
|
gap: 16px;
|
|
17299
17494
|
padding: 20px 24px;
|
|
17300
17495
|
background: #f9fafb;
|
|
@@ -17329,6 +17524,15 @@ var PowerLimitsModalView = class {
|
|
|
17329
17524
|
box-shadow: 0 0 0 3px ${this.hexToRgba(primaryColor, 0.1)};
|
|
17330
17525
|
}
|
|
17331
17526
|
|
|
17527
|
+
.myio-fixed-value {
|
|
17528
|
+
padding: 10px 12px;
|
|
17529
|
+
border: 1px solid #e5e7eb;
|
|
17530
|
+
border-radius: 6px;
|
|
17531
|
+
font-size: 14px;
|
|
17532
|
+
background: #f9fafb;
|
|
17533
|
+
color: #6b7280;
|
|
17534
|
+
}
|
|
17535
|
+
|
|
17332
17536
|
.myio-power-limits-grid {
|
|
17333
17537
|
display: grid;
|
|
17334
17538
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -17357,6 +17561,11 @@ var PowerLimitsModalView = class {
|
|
|
17357
17561
|
margin-bottom: 12px;
|
|
17358
17562
|
}
|
|
17359
17563
|
|
|
17564
|
+
.myio-status-icon {
|
|
17565
|
+
font-size: 18px;
|
|
17566
|
+
line-height: 1;
|
|
17567
|
+
}
|
|
17568
|
+
|
|
17360
17569
|
.myio-status-indicator {
|
|
17361
17570
|
width: 12px;
|
|
17362
17571
|
height: 12px;
|
|
@@ -17547,6 +17756,8 @@ var PowerLimitsPersister = class {
|
|
|
17547
17756
|
const defaultFormData = {
|
|
17548
17757
|
deviceType,
|
|
17549
17758
|
telemetryType,
|
|
17759
|
+
domain: "energy",
|
|
17760
|
+
// Default to energy, will be overwritten by caller if needed
|
|
17550
17761
|
standby: { baseValue: null, topValue: null },
|
|
17551
17762
|
normal: { baseValue: null, topValue: null },
|
|
17552
17763
|
alert: { baseValue: null, topValue: null },
|
|
@@ -17716,10 +17927,12 @@ async function openPowerLimitsSetupModal(params) {
|
|
|
17716
17927
|
const persister = new PowerLimitsPersister(params.token, params.tbBaseUrl);
|
|
17717
17928
|
let currentDeviceType = params.deviceType || "ELEVADOR";
|
|
17718
17929
|
let currentTelemetryType = params.telemetryType || "consumption";
|
|
17930
|
+
let currentDomain = params.domain || "energy";
|
|
17719
17931
|
let existingLimits = params.existingMapPower || null;
|
|
17720
17932
|
const view = new PowerLimitsModalView({
|
|
17721
17933
|
deviceType: currentDeviceType,
|
|
17722
17934
|
telemetryType: currentTelemetryType,
|
|
17935
|
+
domain: currentDomain,
|
|
17723
17936
|
styles: params.styles,
|
|
17724
17937
|
locale: params.locale,
|
|
17725
17938
|
onDeviceTypeChange: async (deviceType) => {
|
|
@@ -17730,6 +17943,9 @@ async function openPowerLimitsSetupModal(params) {
|
|
|
17730
17943
|
currentTelemetryType = telemetryType;
|
|
17731
17944
|
await loadFormData();
|
|
17732
17945
|
},
|
|
17946
|
+
onDomainChange: (domain) => {
|
|
17947
|
+
currentDomain = domain;
|
|
17948
|
+
},
|
|
17733
17949
|
onSave: async () => {
|
|
17734
17950
|
const formData = view.getFormData();
|
|
17735
17951
|
const updatedLimits = persister.mergeFormDataIntoLimits(existingLimits, formData);
|
|
@@ -17755,6 +17971,7 @@ async function openPowerLimitsSetupModal(params) {
|
|
|
17755
17971
|
existingLimits = await persister.loadCustomerPowerLimits(params.customerId);
|
|
17756
17972
|
}
|
|
17757
17973
|
const formData = persister.extractFormData(existingLimits, currentDeviceType, currentTelemetryType);
|
|
17974
|
+
formData.domain = currentDomain;
|
|
17758
17975
|
view.setFormData(formData);
|
|
17759
17976
|
} catch (error) {
|
|
17760
17977
|
console.error("[PowerLimitsSetupModal] Error loading form data:", error);
|