myio-js-library 0.1.587 → 0.1.588
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 +211 -47
- package/dist/index.d.cts +54 -6
- package/dist/index.d.ts +54 -6
- package/dist/index.js +207 -47
- package/dist/myio-js-library.umd.js +207 -47
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -300,6 +300,7 @@ __export(src_exports, {
|
|
|
300
300
|
SIDEBAR_MENU_CSS_PREFIX: () => SIDEBAR_MENU_CSS_PREFIX,
|
|
301
301
|
SOLENOID_CONTROL_CSS_PREFIX: () => SOLENOID_CONTROL_CSS_PREFIX,
|
|
302
302
|
SOLENOID_IMAGES: () => SOLENOID_IMAGES2,
|
|
303
|
+
STANDARD_DEVICE_PROFILES: () => STANDARD_DEVICE_PROFILES,
|
|
303
304
|
STATUS_COLORS: () => STATUS_COLORS,
|
|
304
305
|
STATUS_FRESHNESS_MAX_HOURS: () => STATUS_FRESHNESS_MAX_HOURS,
|
|
305
306
|
STATUS_FRESHNESS_MAX_MS: () => STATUS_FRESHNESS_MAX_MS,
|
|
@@ -793,6 +794,7 @@ __export(src_exports, {
|
|
|
793
794
|
msToMinutes: () => msToMinutes,
|
|
794
795
|
myioExportData: () => myioExportData,
|
|
795
796
|
nextManualSeq: () => nextManualSeq,
|
|
797
|
+
nextStandardSeq: () => nextStandardSeq,
|
|
796
798
|
nfdNormalizeAnnotationSearch: () => nfdNormalize,
|
|
797
799
|
normalizeBudgetBlock: () => normalizeBudgetBlock,
|
|
798
800
|
normalizeConnectionStatus: () => normalizeConnectionStatus,
|
|
@@ -924,6 +926,7 @@ __export(src_exports, {
|
|
|
924
926
|
resolveMoneyRowValues: () => resolveMoneyRowValues,
|
|
925
927
|
resolvePercentDecimals: () => resolvePercentDecimals,
|
|
926
928
|
resolveReportItemStates: () => resolveReportItemStates,
|
|
929
|
+
resolveStandardDeviceName: () => resolveStandardDeviceName,
|
|
927
930
|
resolveSubcategory: () => resolveSubcategory,
|
|
928
931
|
resolveWithFallback: () => resolveWithFallback,
|
|
929
932
|
roundMoney2: () => roundMoney2,
|
|
@@ -946,6 +949,7 @@ __export(src_exports, {
|
|
|
946
949
|
slugifyCustomerName: () => slugifyCustomerName,
|
|
947
950
|
sortAnnotationGroups: () => sortGroups,
|
|
948
951
|
sortDeviceGridDevices: () => sortDevices,
|
|
952
|
+
standardDeviceName: () => standardDeviceName,
|
|
949
953
|
strings: () => strings_exports,
|
|
950
954
|
subtractDecimals: () => subtractDecimals,
|
|
951
955
|
sumItemMoney: () => sumItemMoney,
|
|
@@ -989,7 +993,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
989
993
|
// package.json
|
|
990
994
|
var package_default = {
|
|
991
995
|
name: "myio-js-library",
|
|
992
|
-
version: "0.1.
|
|
996
|
+
version: "0.1.588",
|
|
993
997
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
994
998
|
license: "MIT",
|
|
995
999
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -118627,6 +118631,38 @@ var NAME_PREFIX = {
|
|
|
118627
118631
|
water: "Hidr. "
|
|
118628
118632
|
};
|
|
118629
118633
|
var MANUAL_ASSET_SUFFIX = "_DEVICES_MANUAIS";
|
|
118634
|
+
var STANDARD_DEVICE_PROFILES = {
|
|
118635
|
+
energy: [
|
|
118636
|
+
"3F_MEDIDOR",
|
|
118637
|
+
"ENTRADA",
|
|
118638
|
+
"RELOGIO",
|
|
118639
|
+
"SUBESTACAO",
|
|
118640
|
+
"TRANSFORMADOR",
|
|
118641
|
+
"ELEVADOR",
|
|
118642
|
+
"ESCADA_ROLANTE",
|
|
118643
|
+
"CHILLER",
|
|
118644
|
+
"FANCOIL",
|
|
118645
|
+
"BOMBA_CAG",
|
|
118646
|
+
"BOMBA_HIDRAULICA",
|
|
118647
|
+
"BOMBA_INCENDIO",
|
|
118648
|
+
"BOMBA_POCO",
|
|
118649
|
+
"MOTOR"
|
|
118650
|
+
],
|
|
118651
|
+
water: ["HIDROMETRO", "HIDROMETRO_AREA_COMUM", "HIDROMETRO_SHOPPING", "HIDROMETRO_ENTRADA"]
|
|
118652
|
+
};
|
|
118653
|
+
var standardNameToken = (deviceProfile) => ["3F_MEDIDOR", "HIDROMETRO"].includes(deviceProfile) ? "LOJA" : deviceProfile;
|
|
118654
|
+
function standardDeviceName(domain, sigla, deviceProfile, seq) {
|
|
118655
|
+
return `${NAME_PREFIX[domain]}${sigla}_${standardNameToken(deviceProfile)}_${String(seq).padStart(3, "0")}`;
|
|
118656
|
+
}
|
|
118657
|
+
function nextStandardSeq(domain, sigla, deviceProfile, existingNames) {
|
|
118658
|
+
const esc12 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
118659
|
+
const re = new RegExp(`^${esc12(NAME_PREFIX[domain])}${esc12(sigla)}_${esc12(standardNameToken(deviceProfile))}_(\\d+)$`, "i");
|
|
118660
|
+
const max = existingNames.reduce((acc, n) => {
|
|
118661
|
+
const m = re.exec(String(n || "").trim());
|
|
118662
|
+
return m ? Math.max(acc, Number(m[1])) : acc;
|
|
118663
|
+
}, 0);
|
|
118664
|
+
return max + 1;
|
|
118665
|
+
}
|
|
118630
118666
|
var ManualDeviceError = class extends Error {
|
|
118631
118667
|
constructor(message, detail) {
|
|
118632
118668
|
super(message);
|
|
@@ -118715,10 +118751,36 @@ async function resolveManualDeviceName(params) {
|
|
|
118715
118751
|
deviceProfile: profile
|
|
118716
118752
|
};
|
|
118717
118753
|
}
|
|
118754
|
+
async function resolveStandardDeviceName(params) {
|
|
118755
|
+
const profile = String(params.deviceProfile || "").trim().toUpperCase();
|
|
118756
|
+
if (!MANUAL_DEVICE_PROFILES[params.domain]) throw new ManualDeviceError(`Dom\xEDnio inv\xE1lido: ${params.domain}`);
|
|
118757
|
+
if (!profile) throw new ManualDeviceError("Escolha o tipo do dispositivo.");
|
|
118758
|
+
if (!params.customerId) throw new ManualDeviceError("Cliente n\xE3o identificado.");
|
|
118759
|
+
const api = await buildTbApi(params);
|
|
118760
|
+
const { asset, sigla } = await findManualAsset(api, params.customerId);
|
|
118761
|
+
const token = standardNameToken(profile);
|
|
118762
|
+
const existing = await api(
|
|
118763
|
+
"GET",
|
|
118764
|
+
`/api/customer/${encodeURIComponent(params.customerId)}/devices?pageSize=1000&page=0&textSearch=${encodeURIComponent(`${sigla}_${token}_`)}`
|
|
118765
|
+
);
|
|
118766
|
+
const names = (existing?.data || []).map((d) => String(d?.name || ""));
|
|
118767
|
+
const seq = nextStandardSeq(params.domain, sigla, profile, names);
|
|
118768
|
+
return {
|
|
118769
|
+
name: standardDeviceName(params.domain, sigla, profile, seq),
|
|
118770
|
+
sigla,
|
|
118771
|
+
seq,
|
|
118772
|
+
assetId: asset.id.id,
|
|
118773
|
+
assetName: asset.name,
|
|
118774
|
+
deviceProfile: profile
|
|
118775
|
+
};
|
|
118776
|
+
}
|
|
118718
118777
|
async function createManualDevice(params) {
|
|
118719
118778
|
const domain = params.domain;
|
|
118720
|
-
|
|
118721
|
-
|
|
118779
|
+
if (!MANUAL_DEVICE_PROFILES[domain]) throw new ManualDeviceError(`Dom\xEDnio inv\xE1lido: ${domain}`);
|
|
118780
|
+
const profile = String(params.deviceProfile || "").trim() || MANUAL_DEVICE_PROFILES[domain];
|
|
118781
|
+
if (params.asset && !String(params.name || "").trim()) {
|
|
118782
|
+
throw new ManualDeviceError("Nome do dispositivo n\xE3o reservado.", "asset informado sem name");
|
|
118783
|
+
}
|
|
118722
118784
|
const label = String(params.label || "").trim();
|
|
118723
118785
|
const identifier = String(params.identifier || "").trim();
|
|
118724
118786
|
if (!label) throw new ManualDeviceError("Informe a etiqueta.");
|
|
@@ -118726,7 +118788,7 @@ async function createManualDevice(params) {
|
|
|
118726
118788
|
if (!params.customerId) throw new ManualDeviceError("Cliente n\xE3o identificado.");
|
|
118727
118789
|
const api = await buildTbApi(params);
|
|
118728
118790
|
const cid = encodeURIComponent(params.customerId);
|
|
118729
|
-
const { asset, sigla } = await findManualAsset(api, params.customerId);
|
|
118791
|
+
const { asset, sigla } = params.asset ? { asset: { id: { id: params.asset.id }, name: params.asset.name }, sigla: "" } : await findManualAsset(api, params.customerId);
|
|
118730
118792
|
const fixedName = String(params.name || "").trim();
|
|
118731
118793
|
let seq = fixedName ? 0 : nextManualSeq(domain, sigla, await existingManualNames(api, params.customerId, sigla));
|
|
118732
118794
|
let deviceProfileId;
|
|
@@ -118786,9 +118848,17 @@ async function createManualDevice(params) {
|
|
|
118786
118848
|
}
|
|
118787
118849
|
|
|
118788
118850
|
// src/components/premium-modals/manual-device/openManualDeviceModal.ts
|
|
118851
|
+
var MANUAL_HINT = "Cadastre um ponto de leitura manual. Ele aparece nesta lista e n\xE3o entra nos totais nem nos relat\xF3rios.";
|
|
118852
|
+
var STANDARD_HINT = "Cadastre um medidor ligado \xE0 central. Ele \xE9 criado no GCDR, Ingestion, ThingsBoard e na central.";
|
|
118789
118853
|
var DOMAIN_TEXT2 = {
|
|
118790
|
-
|
|
118791
|
-
|
|
118854
|
+
manual: {
|
|
118855
|
+
energy: { title: "Novo medidor de energia manual", icon: "\u26A1", noun: "Medidor de energia", hint: MANUAL_HINT },
|
|
118856
|
+
water: { title: "Novo hidr\xF4metro manual", icon: "\u{1F4A7}", noun: "Hidr\xF4metro", hint: MANUAL_HINT }
|
|
118857
|
+
},
|
|
118858
|
+
standard: {
|
|
118859
|
+
energy: { title: "Novo medidor de energia", icon: "\u26A1", noun: "Medidor de energia", hint: STANDARD_HINT },
|
|
118860
|
+
water: { title: "Novo hidr\xF4metro", icon: "\u{1F4A7}", noun: "Hidr\xF4metro", hint: STANDARD_HINT }
|
|
118861
|
+
}
|
|
118792
118862
|
};
|
|
118793
118863
|
var STYLE_ID16 = "myio-manualdev-styles";
|
|
118794
118864
|
function escapeHtml16(v) {
|
|
@@ -118847,12 +118917,42 @@ function injectStyles16() {
|
|
|
118847
118917
|
`;
|
|
118848
118918
|
document.head.appendChild(style);
|
|
118849
118919
|
}
|
|
118850
|
-
function
|
|
118851
|
-
|
|
118920
|
+
function selectHtml(name, label, placeholder, opts, value, disabled = false) {
|
|
118921
|
+
return `
|
|
118922
|
+
<label class="myio-manualdev__field">
|
|
118923
|
+
<span class="myio-manualdev__label">${escapeHtml16(label)}</span>
|
|
118924
|
+
<select class="myio-manualdev__input" name="${name}"${disabled ? " disabled" : ""}>
|
|
118925
|
+
<option value="">${escapeHtml16(placeholder)}</option>
|
|
118926
|
+
${opts.map((o) => `<option value="${escapeHtml16(o.value)}"${o.value === value ? " selected" : ""}>${escapeHtml16(o.text)}</option>`).join("")}
|
|
118927
|
+
</select>
|
|
118928
|
+
</label>`;
|
|
118929
|
+
}
|
|
118930
|
+
function extraFieldsHtml(s) {
|
|
118931
|
+
const profile = s.kind === "standard" ? selectHtml("deviceProfile", "Tipo", "Selecione o tipo", s.profiles.map((p) => ({ value: p, text: p })), s.deviceProfile) : "";
|
|
118932
|
+
let central = "";
|
|
118933
|
+
if (s.centrals === null) {
|
|
118934
|
+
central = selectHtml("centralId", "Central", "Carregando centrais\u2026", [], "", true);
|
|
118935
|
+
} else if (s.centrals.length > 1) {
|
|
118936
|
+
central = selectHtml(
|
|
118937
|
+
"centralId",
|
|
118938
|
+
"Central",
|
|
118939
|
+
"Selecione a central",
|
|
118940
|
+
s.centrals.map((c) => ({
|
|
118941
|
+
value: c.id,
|
|
118942
|
+
text: `${c.name || c.id}${typeof c.deviceCount === "number" ? ` \xB7 ${c.deviceCount} devices` : ""}`
|
|
118943
|
+
})),
|
|
118944
|
+
s.centralId
|
|
118945
|
+
);
|
|
118946
|
+
}
|
|
118947
|
+
return profile + central;
|
|
118948
|
+
}
|
|
118949
|
+
function formHtml(s, error, detail) {
|
|
118950
|
+
const t = DOMAIN_TEXT2[s.kind][s.domain];
|
|
118951
|
+
const values = s;
|
|
118852
118952
|
return `
|
|
118853
118953
|
<form class="myio-manualdev" novalidate>
|
|
118854
|
-
<p class="myio-manualdev__hint"
|
|
118855
|
-
<span class="myio-manualdev__type">${t.icon} ${escapeHtml16(t.noun)} manual</span>
|
|
118954
|
+
<p class="myio-manualdev__hint">${escapeHtml16(t.hint)}</p>
|
|
118955
|
+
<span class="myio-manualdev__type">${t.icon} ${escapeHtml16(t.noun)}${s.kind === "manual" ? " manual" : ""}</span>
|
|
118856
118956
|
<label class="myio-manualdev__field">
|
|
118857
118957
|
<span class="myio-manualdev__label">Etiqueta</span>
|
|
118858
118958
|
<input class="myio-manualdev__input" name="label" maxlength="80" autocomplete="off"
|
|
@@ -118863,6 +118963,7 @@ function formHtml(domain, values, error, detail) {
|
|
|
118863
118963
|
<input class="myio-manualdev__input" name="identifier" maxlength="40" autocomplete="off"
|
|
118864
118964
|
placeholder="Ex.: STB01010" value="${escapeHtml16(values.identifier)}" />
|
|
118865
118965
|
</label>
|
|
118966
|
+
${extraFieldsHtml(s)}
|
|
118866
118967
|
${error ? `<p class="myio-manualdev__error" role="alert">${escapeHtml16(error)}${detail ? `<small class="myio-manualdev__detail">${escapeHtml16(detail)}</small>` : ""}</p>` : ""}
|
|
118867
118968
|
<button type="submit" hidden></button>
|
|
118868
118969
|
</form>`;
|
|
@@ -118871,7 +118972,7 @@ function successHtml(domain, r, tech) {
|
|
|
118871
118972
|
return `
|
|
118872
118973
|
<div class="myio-manualdev__ok">
|
|
118873
118974
|
<div class="myio-manualdev__ok-icon">\u2705</div>
|
|
118874
|
-
<p class="myio-manualdev__ok-title">${escapeHtml16(DOMAIN_TEXT2[domain].noun)} criado</p>
|
|
118975
|
+
<p class="myio-manualdev__ok-title">${escapeHtml16(DOMAIN_TEXT2.manual[domain].noun)} criado</p>
|
|
118875
118976
|
<p class="myio-manualdev__ok-text"><strong>${escapeHtml16(r.label)}</strong> \xB7 ${escapeHtml16(r.identifier)}</p>
|
|
118876
118977
|
${tech ? `<div class="myio-manualdev__tech">
|
|
118877
118978
|
device <code>${escapeHtml16(r.name)}</code><br/>
|
|
@@ -118931,18 +119032,51 @@ function progressHtml(steps, message, ok, open = false) {
|
|
|
118931
119032
|
${moreHtml(stepsHtml(steps), open)}
|
|
118932
119033
|
</div>`;
|
|
118933
119034
|
}
|
|
119035
|
+
function initialState(params, kind, loadsCentrals) {
|
|
119036
|
+
const profiles = kind === "standard" ? (params.deviceProfiles?.length ? params.deviceProfiles : STANDARD_DEVICE_PROFILES[params.domain]).slice() : [];
|
|
119037
|
+
const def = String(params.defaultDeviceProfile || "").toUpperCase();
|
|
119038
|
+
return {
|
|
119039
|
+
kind,
|
|
119040
|
+
domain: params.domain,
|
|
119041
|
+
label: "",
|
|
119042
|
+
identifier: "",
|
|
119043
|
+
deviceProfile: profiles.includes(def) ? def : "",
|
|
119044
|
+
centralId: "",
|
|
119045
|
+
profiles,
|
|
119046
|
+
centrals: loadsCentrals ? null : []
|
|
119047
|
+
};
|
|
119048
|
+
}
|
|
119049
|
+
function readForm(body, s) {
|
|
119050
|
+
const val = (name) => (body.querySelector(`[name="${name}"]`)?.value ?? "").trim();
|
|
119051
|
+
s.label = val("label");
|
|
119052
|
+
s.identifier = val("identifier");
|
|
119053
|
+
if (s.kind === "standard") s.deviceProfile = val("deviceProfile");
|
|
119054
|
+
if (s.centrals && s.centrals.length > 1) s.centralId = val("centralId");
|
|
119055
|
+
}
|
|
119056
|
+
function missingField(s) {
|
|
119057
|
+
if (!s.label) return { name: "label", msg: "Informe a etiqueta." };
|
|
119058
|
+
if (!s.identifier) return { name: "identifier", msg: "Informe o identificador." };
|
|
119059
|
+
if (s.kind === "standard" && !s.deviceProfile) return { name: "deviceProfile", msg: "Escolha o tipo." };
|
|
119060
|
+
if (s.centrals === null) return { name: "centralId", msg: "Aguarde o carregamento das centrais." };
|
|
119061
|
+
if (s.centrals.length > 1 && !s.centralId) return { name: "centralId", msg: "Escolha a central." };
|
|
119062
|
+
return null;
|
|
119063
|
+
}
|
|
118934
119064
|
function openManualDeviceModal(params) {
|
|
118935
119065
|
const domain = params.domain;
|
|
118936
119066
|
if (!MANUAL_DEVICE_PROFILES[domain]) throw new Error(`[openManualDeviceModal] dom\xEDnio inv\xE1lido: ${domain}`);
|
|
119067
|
+
const kind = params.kind === "standard" ? "standard" : "manual";
|
|
119068
|
+
if (kind === "standard" && !params.provisioner) {
|
|
119069
|
+
throw new Error('[openManualDeviceModal] kind "standard" exige provisioner');
|
|
119070
|
+
}
|
|
118937
119071
|
injectStyles16();
|
|
118938
|
-
if (params.provisioner) return openProvisionedModal(params, params.provisioner);
|
|
118939
|
-
const
|
|
119072
|
+
if (params.provisioner) return openProvisionedModal(params, params.provisioner, kind);
|
|
119073
|
+
const state6 = initialState(params, "manual", false);
|
|
118940
119074
|
let busy = false;
|
|
118941
119075
|
let created = null;
|
|
118942
119076
|
const modal = openStandardModal({
|
|
118943
|
-
title: DOMAIN_TEXT2[domain].title,
|
|
118944
|
-
icon: DOMAIN_TEXT2[domain].icon,
|
|
118945
|
-
bodyHtml: formHtml(
|
|
119077
|
+
title: DOMAIN_TEXT2.manual[domain].title,
|
|
119078
|
+
icon: DOMAIN_TEXT2.manual[domain].icon,
|
|
119079
|
+
bodyHtml: formHtml(state6),
|
|
118946
119080
|
width: 460,
|
|
118947
119081
|
container: params.container,
|
|
118948
119082
|
buttons: [
|
|
@@ -118972,13 +119106,12 @@ function openManualDeviceModal(params) {
|
|
|
118972
119106
|
async function submit() {
|
|
118973
119107
|
if (busy || created) return;
|
|
118974
119108
|
const body = modal.getBodyEl();
|
|
118975
|
-
|
|
118976
|
-
|
|
118977
|
-
const missing = !values.label ? "label" : !values.identifier ? "identifier" : null;
|
|
119109
|
+
readForm(body, state6);
|
|
119110
|
+
const missing = missingField(state6);
|
|
118978
119111
|
if (missing) {
|
|
118979
|
-
modal.setBodyHtml(formHtml(
|
|
119112
|
+
modal.setBodyHtml(formHtml(state6, missing.msg));
|
|
118980
119113
|
bindForm(false);
|
|
118981
|
-
const input = body.querySelector(`
|
|
119114
|
+
const input = body.querySelector(`[name="${missing.name}"]`);
|
|
118982
119115
|
input?.setAttribute("aria-invalid", "true");
|
|
118983
119116
|
input?.focus();
|
|
118984
119117
|
return;
|
|
@@ -118988,14 +119121,14 @@ function openManualDeviceModal(params) {
|
|
|
118988
119121
|
modal.setButton("cancel", { disabled: true });
|
|
118989
119122
|
body.querySelectorAll("input").forEach((i) => i.disabled = true);
|
|
118990
119123
|
try {
|
|
118991
|
-
created = await createManualDevice({ ...params, label:
|
|
119124
|
+
created = await createManualDevice({ ...params, label: state6.label, identifier: state6.identifier });
|
|
118992
119125
|
modal.setBodyHtml(successHtml(domain, created, !!params.showTechnicalDetails));
|
|
118993
119126
|
modal.setButton("cancel", { hidden: true });
|
|
118994
119127
|
modal.setButton("create", { disabled: false, label: "Concluir" });
|
|
118995
119128
|
} catch (err) {
|
|
118996
119129
|
const msg = err instanceof ManualDeviceError ? err.message : "N\xE3o foi poss\xEDvel criar o dispositivo.";
|
|
118997
119130
|
const detail = params.showTechnicalDetails ? (err instanceof ManualDeviceError ? err.detail : String(err?.message || err)) || void 0 : void 0;
|
|
118998
|
-
modal.setBodyHtml(formHtml(
|
|
119131
|
+
modal.setBodyHtml(formHtml(state6, msg, detail));
|
|
118999
119132
|
bindForm();
|
|
119000
119133
|
modal.setButton("create", { disabled: false, label: "Criar" });
|
|
119001
119134
|
modal.setButton("cancel", { disabled: false });
|
|
@@ -119005,16 +119138,17 @@ function openManualDeviceModal(params) {
|
|
|
119005
119138
|
}
|
|
119006
119139
|
return modal;
|
|
119007
119140
|
}
|
|
119008
|
-
function openProvisionedModal(params, provisioner) {
|
|
119141
|
+
function openProvisionedModal(params, provisioner, kind) {
|
|
119009
119142
|
const domain = params.domain;
|
|
119010
|
-
const
|
|
119143
|
+
const state6 = initialState(params, kind, typeof provisioner.options === "function");
|
|
119011
119144
|
let phase = "form";
|
|
119012
119145
|
let plan = null;
|
|
119013
119146
|
let outcome = null;
|
|
119147
|
+
const text2 = DOMAIN_TEXT2[kind][domain];
|
|
119014
119148
|
const modal = openStandardModal({
|
|
119015
|
-
title:
|
|
119016
|
-
icon:
|
|
119017
|
-
bodyHtml: formHtml(
|
|
119149
|
+
title: text2.title,
|
|
119150
|
+
icon: text2.icon,
|
|
119151
|
+
bodyHtml: formHtml(state6),
|
|
119018
119152
|
width: 560,
|
|
119019
119153
|
container: params.container,
|
|
119020
119154
|
buttons: [
|
|
@@ -119043,37 +119177,63 @@ function openProvisionedModal(params, provisioner) {
|
|
|
119043
119177
|
if (focus) form?.querySelector('input[name="label"]')?.focus();
|
|
119044
119178
|
};
|
|
119045
119179
|
bindForm();
|
|
119046
|
-
function showForm(error, detail) {
|
|
119047
|
-
phase = "form";
|
|
119048
|
-
modal.setBodyHtml(formHtml(domain, values, error, detail));
|
|
119049
|
-
bindForm();
|
|
119050
|
-
modal.setButton("back", { hidden: true });
|
|
119051
|
-
modal.setButton("cancel", { disabled: false, hidden: false });
|
|
119052
|
-
modal.setButton("next", { disabled: false, label: "Revisar" });
|
|
119053
|
-
}
|
|
119054
119180
|
const errorText = (err) => {
|
|
119055
119181
|
const msg = err instanceof ManualDeviceError ? err.message : "N\xE3o foi poss\xEDvel montar o plano.";
|
|
119056
119182
|
const detail = params.showTechnicalDetails ? (err instanceof ManualDeviceError ? err.detail : String(err?.message || err)) || void 0 : void 0;
|
|
119057
119183
|
return { msg, detail };
|
|
119058
119184
|
};
|
|
119185
|
+
if (provisioner.options) {
|
|
119186
|
+
provisioner.options({ domain, kind }).then((o) => {
|
|
119187
|
+
const centrals = Array.isArray(o?.centrals) ? o.centrals : [];
|
|
119188
|
+
if (phase !== "form") {
|
|
119189
|
+
state6.centrals = centrals;
|
|
119190
|
+
return;
|
|
119191
|
+
}
|
|
119192
|
+
readForm(modal.getBodyEl(), state6);
|
|
119193
|
+
state6.centrals = centrals;
|
|
119194
|
+
if (centrals.length === 1) state6.centralId = centrals[0].id;
|
|
119195
|
+
showForm(void 0, void 0, false);
|
|
119196
|
+
}).catch((err) => {
|
|
119197
|
+
state6.centrals = [];
|
|
119198
|
+
if (phase === "form") {
|
|
119199
|
+
readForm(modal.getBodyEl(), state6);
|
|
119200
|
+
const { detail } = errorText(err);
|
|
119201
|
+
showForm("N\xE3o foi poss\xEDvel carregar as centrais.", detail, false);
|
|
119202
|
+
}
|
|
119203
|
+
});
|
|
119204
|
+
}
|
|
119205
|
+
function showForm(error, detail, focus = true) {
|
|
119206
|
+
phase = "form";
|
|
119207
|
+
modal.setBodyHtml(formHtml(state6, error, detail));
|
|
119208
|
+
bindForm(focus);
|
|
119209
|
+
modal.setButton("back", { hidden: true });
|
|
119210
|
+
modal.setButton("cancel", { disabled: false, hidden: false });
|
|
119211
|
+
modal.setButton("next", { disabled: false, label: "Revisar" });
|
|
119212
|
+
}
|
|
119059
119213
|
async function review() {
|
|
119060
119214
|
if (phase !== "form") return;
|
|
119061
119215
|
const body = modal.getBodyEl();
|
|
119062
|
-
|
|
119063
|
-
|
|
119064
|
-
const missing = !values.label ? "label" : !values.identifier ? "identifier" : null;
|
|
119216
|
+
readForm(body, state6);
|
|
119217
|
+
const missing = missingField(state6);
|
|
119065
119218
|
if (missing) {
|
|
119066
|
-
showForm(missing
|
|
119067
|
-
const input = modal.getBodyEl().querySelector(`
|
|
119219
|
+
showForm(missing.msg);
|
|
119220
|
+
const input = modal.getBodyEl().querySelector(`[name="${missing.name}"]`);
|
|
119068
119221
|
input?.setAttribute("aria-invalid", "true");
|
|
119069
119222
|
input?.focus();
|
|
119070
119223
|
return;
|
|
119071
119224
|
}
|
|
119072
119225
|
phase = "planning";
|
|
119073
119226
|
modal.setButton("next", { disabled: true, label: "Revisando\u2026" });
|
|
119074
|
-
body.querySelectorAll("input").forEach((i) => i.disabled = true);
|
|
119227
|
+
body.querySelectorAll("input, select").forEach((i) => i.disabled = true);
|
|
119075
119228
|
try {
|
|
119076
|
-
plan = await provisioner.plan({
|
|
119229
|
+
plan = await provisioner.plan({
|
|
119230
|
+
domain,
|
|
119231
|
+
label: state6.label,
|
|
119232
|
+
identifier: state6.identifier,
|
|
119233
|
+
kind,
|
|
119234
|
+
...kind === "standard" ? { deviceProfile: state6.deviceProfile } : {},
|
|
119235
|
+
...state6.centralId ? { centralId: state6.centralId } : {}
|
|
119236
|
+
});
|
|
119077
119237
|
phase = "plan";
|
|
119078
119238
|
modal.setBodyHtml(planHtml(plan));
|
|
119079
119239
|
modal.setButton("back", { hidden: false, disabled: false });
|
|
@@ -166175,18 +166335,18 @@ function convertTelemetryToTimelineData(telemetry, options) {
|
|
|
166175
166335
|
let segmentStart = null;
|
|
166176
166336
|
if (sorted[0].ts > startTs) {
|
|
166177
166337
|
const firstKnownState = isOnState(sorted[0].value, invertLogic) ? "on" : "off";
|
|
166178
|
-
const
|
|
166338
|
+
const initialState2 = firstKnownState === "on" ? "off" : "on";
|
|
166179
166339
|
segments.push({
|
|
166180
166340
|
startTime: periodStart,
|
|
166181
166341
|
endTime: new Date(sorted[0].ts).toISOString(),
|
|
166182
166342
|
durationMinutes: (sorted[0].ts - startTs) / 6e4,
|
|
166183
|
-
state:
|
|
166343
|
+
state: initialState2,
|
|
166184
166344
|
source: "unknown"
|
|
166185
166345
|
});
|
|
166186
|
-
if (
|
|
166346
|
+
if (initialState2 === "on") {
|
|
166187
166347
|
totalOnMinutes += (sorted[0].ts - startTs) / 6e4;
|
|
166188
166348
|
}
|
|
166189
|
-
previousState =
|
|
166349
|
+
previousState = initialState2;
|
|
166190
166350
|
segmentStart = sorted[0].ts;
|
|
166191
166351
|
} else {
|
|
166192
166352
|
segmentStart = startTs;
|
|
@@ -181413,6 +181573,7 @@ var version = package_default.version || "0.0.0";
|
|
|
181413
181573
|
SIDEBAR_MENU_CSS_PREFIX,
|
|
181414
181574
|
SOLENOID_CONTROL_CSS_PREFIX,
|
|
181415
181575
|
SOLENOID_IMAGES,
|
|
181576
|
+
STANDARD_DEVICE_PROFILES,
|
|
181416
181577
|
STATUS_COLORS,
|
|
181417
181578
|
STATUS_FRESHNESS_MAX_HOURS,
|
|
181418
181579
|
STATUS_FRESHNESS_MAX_MS,
|
|
@@ -181906,6 +182067,7 @@ var version = package_default.version || "0.0.0";
|
|
|
181906
182067
|
msToMinutes,
|
|
181907
182068
|
myioExportData,
|
|
181908
182069
|
nextManualSeq,
|
|
182070
|
+
nextStandardSeq,
|
|
181909
182071
|
nfdNormalizeAnnotationSearch,
|
|
181910
182072
|
normalizeBudgetBlock,
|
|
181911
182073
|
normalizeConnectionStatus,
|
|
@@ -182037,6 +182199,7 @@ var version = package_default.version || "0.0.0";
|
|
|
182037
182199
|
resolveMoneyRowValues,
|
|
182038
182200
|
resolvePercentDecimals,
|
|
182039
182201
|
resolveReportItemStates,
|
|
182202
|
+
resolveStandardDeviceName,
|
|
182040
182203
|
resolveSubcategory,
|
|
182041
182204
|
resolveWithFallback,
|
|
182042
182205
|
roundMoney2,
|
|
@@ -182059,6 +182222,7 @@ var version = package_default.version || "0.0.0";
|
|
|
182059
182222
|
slugifyCustomerName,
|
|
182060
182223
|
sortAnnotationGroups,
|
|
182061
182224
|
sortDeviceGridDevices,
|
|
182225
|
+
standardDeviceName,
|
|
182062
182226
|
strings,
|
|
182063
182227
|
subtractDecimals,
|
|
182064
182228
|
sumItemMoney,
|