myio-js-library 0.1.533 → 0.1.534
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 +133 -33
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +133 -33
- package/dist/myio-js-library.umd.js +133 -33
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -861,7 +861,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
861
861
|
// package.json
|
|
862
862
|
var package_default = {
|
|
863
863
|
name: "myio-js-library",
|
|
864
|
-
version: "0.1.
|
|
864
|
+
version: "0.1.534",
|
|
865
865
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
866
866
|
license: "MIT",
|
|
867
867
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -24515,6 +24515,32 @@ var MyIOToast = (function() {
|
|
|
24515
24515
|
background: rgba(255, 255, 255, 0.45);
|
|
24516
24516
|
}
|
|
24517
24517
|
|
|
24518
|
+
/* "\xD7" button \u2014 force-dismiss this toast, present on EVERY toast regardless
|
|
24519
|
+
of type or auto-hide duration (including sticky duration=0 toasts). */
|
|
24520
|
+
#myio-global-toast-container .myio-toast-close {
|
|
24521
|
+
flex-shrink: 0;
|
|
24522
|
+
margin-left: 10px;
|
|
24523
|
+
width: 20px;
|
|
24524
|
+
height: 20px;
|
|
24525
|
+
display: inline-flex;
|
|
24526
|
+
align-items: center;
|
|
24527
|
+
justify-content: center;
|
|
24528
|
+
border: none;
|
|
24529
|
+
border-radius: 50%;
|
|
24530
|
+
background: transparent;
|
|
24531
|
+
color: #ffffff;
|
|
24532
|
+
opacity: 0.75;
|
|
24533
|
+
font-size: 15px;
|
|
24534
|
+
line-height: 1;
|
|
24535
|
+
cursor: pointer;
|
|
24536
|
+
transition: background 0.2s ease, opacity 0.2s ease;
|
|
24537
|
+
}
|
|
24538
|
+
|
|
24539
|
+
#myio-global-toast-container .myio-toast-close:hover {
|
|
24540
|
+
background: rgba(255, 255, 255, 0.25);
|
|
24541
|
+
opacity: 1;
|
|
24542
|
+
}
|
|
24543
|
+
|
|
24518
24544
|
@media (max-width: 480px) {
|
|
24519
24545
|
#myio-global-toast-container {
|
|
24520
24546
|
top: 10px;
|
|
@@ -24573,6 +24599,12 @@ var MyIOToast = (function() {
|
|
|
24573
24599
|
toastTimeout = null;
|
|
24574
24600
|
removeToast(toastEl);
|
|
24575
24601
|
};
|
|
24602
|
+
const doUpdate = (newMessage) => {
|
|
24603
|
+
const fullMsg = newMessage == null ? "" : String(newMessage);
|
|
24604
|
+
const isLongMsg = fullMsg.length > TOAST_MAX_MESSAGE_LENGTH;
|
|
24605
|
+
msgSpan.textContent = isLongMsg ? fullMsg.slice(0, TOAST_MAX_MESSAGE_LENGTH).trimEnd() + "\u2026" : fullMsg;
|
|
24606
|
+
msgSpan.title = isLongMsg ? "Mensagem truncada \u2014 clique em + para ver tudo" : "";
|
|
24607
|
+
};
|
|
24576
24608
|
if (isLong) {
|
|
24577
24609
|
const meta = TOAST_TYPE_META[type] || TOAST_TYPE_META.info;
|
|
24578
24610
|
const expandBtn = document.createElement("button");
|
|
@@ -24592,6 +24624,16 @@ var MyIOToast = (function() {
|
|
|
24592
24624
|
});
|
|
24593
24625
|
toastEl.appendChild(expandBtn);
|
|
24594
24626
|
}
|
|
24627
|
+
const closeBtn = document.createElement("button");
|
|
24628
|
+
closeBtn.type = "button";
|
|
24629
|
+
closeBtn.className = "myio-toast-close";
|
|
24630
|
+
closeBtn.textContent = "\xD7";
|
|
24631
|
+
closeBtn.setAttribute("aria-label", "Fechar");
|
|
24632
|
+
closeBtn.addEventListener("click", (e) => {
|
|
24633
|
+
e.stopPropagation();
|
|
24634
|
+
doHide();
|
|
24635
|
+
});
|
|
24636
|
+
toastEl.appendChild(closeBtn);
|
|
24595
24637
|
toastContainer.appendChild(toastEl);
|
|
24596
24638
|
while (toastContainer.children.length > MAX_TOASTS) {
|
|
24597
24639
|
removeToast(toastContainer.firstElementChild);
|
|
@@ -24600,7 +24642,7 @@ var MyIOToast = (function() {
|
|
|
24600
24642
|
if (duration > 0) {
|
|
24601
24643
|
toastTimeout = setTimeout(doHide, duration);
|
|
24602
24644
|
}
|
|
24603
|
-
return { hide: doHide };
|
|
24645
|
+
return { hide: doHide, update: doUpdate };
|
|
24604
24646
|
}
|
|
24605
24647
|
function hide() {
|
|
24606
24648
|
if (toastContainer) {
|
|
@@ -95562,6 +95604,12 @@ var TELEMETRY_KEYS_BY_DOMAIN = {
|
|
|
95562
95604
|
temperature: ["temperature"],
|
|
95563
95605
|
remote: ["status"]
|
|
95564
95606
|
};
|
|
95607
|
+
var CHECK_FIX_PRIMARY_TS_KEY = {
|
|
95608
|
+
energy: "consumption",
|
|
95609
|
+
water: "pulses",
|
|
95610
|
+
temperature: "temperature",
|
|
95611
|
+
remote: "status"
|
|
95612
|
+
};
|
|
95565
95613
|
function inferForCheckFix(name) {
|
|
95566
95614
|
const upper = (name || "").toUpperCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
|
|
95567
95615
|
if (upper.includes("COMPRESSOR")) return "COMPRESSOR";
|
|
@@ -95844,7 +95892,7 @@ function getThemeColors5(theme) {
|
|
|
95844
95892
|
}
|
|
95845
95893
|
var i18n = {
|
|
95846
95894
|
pt: {
|
|
95847
|
-
title: "
|
|
95895
|
+
title: "SETUP de Dispositivos",
|
|
95848
95896
|
step1: "Cliente",
|
|
95849
95897
|
step2: "Dispositivo",
|
|
95850
95898
|
step3: "Valida\xE7\xE3o",
|
|
@@ -95875,7 +95923,7 @@ var i18n = {
|
|
|
95875
95923
|
errorSaving: "Erro ao salvar. Tente novamente."
|
|
95876
95924
|
},
|
|
95877
95925
|
en: {
|
|
95878
|
-
title: "
|
|
95926
|
+
title: "Device Setup",
|
|
95879
95927
|
step1: "Customer",
|
|
95880
95928
|
step2: "Device",
|
|
95881
95929
|
step3: "Validation",
|
|
@@ -96031,7 +96079,7 @@ function openUpsellModal(params) {
|
|
|
96031
96079
|
lojasConfig: null,
|
|
96032
96080
|
lojasApplyRelation: true,
|
|
96033
96081
|
customModeModal: { open: false },
|
|
96034
|
-
bulkRelationModal: { open: false, target: "CUSTOMER", selectedAssetId: "", selectedAssetName: "", search: "", newAssetName: "", assetsLoaded: false, overrideCustomerId: "", overrideCustomerName: "", customerSearch: "", customerPickerOpen: false },
|
|
96082
|
+
bulkRelationModal: { open: false, target: "CUSTOMER", selectedAssetId: "", selectedAssetName: "", search: "", newAssetName: "", assetsLoaded: false, overrideCustomerId: "", overrideCustomerName: "", customerSearch: "", customerPickerOpen: false, alsoChangeOwner: false },
|
|
96035
96083
|
checkFixLoading: false,
|
|
96036
96084
|
checkFixReport: null,
|
|
96037
96085
|
checkFixFilter: "all",
|
|
@@ -96546,6 +96594,21 @@ function renderModal4(container, state6, modalId, t, error) {
|
|
|
96546
96594
|
<span style="font-size: 11px; color: ${colors2.textMuted};">${m.sub}</span>
|
|
96547
96595
|
</button>
|
|
96548
96596
|
`).join("")}
|
|
96597
|
+
<button
|
|
96598
|
+
id="${modalId}-custom-mode-assign-owner"
|
|
96599
|
+
style="
|
|
96600
|
+
grid-column: 1 / -1;
|
|
96601
|
+
background: ${colors2.cardBg}; border: 2px solid ${colors2.border};
|
|
96602
|
+
border-radius: 10px; padding: 14px 12px; cursor: pointer; text-align: left;
|
|
96603
|
+
display: flex; flex-direction: column; gap: 4px; transition: border-color 0.15s;
|
|
96604
|
+
"
|
|
96605
|
+
onmouseover="this.style.borderColor='#ef4444'"
|
|
96606
|
+
onmouseout="this.style.borderColor='${colors2.border}'"
|
|
96607
|
+
>
|
|
96608
|
+
<span style="font-size: 22px;">\u{1F464}</span>
|
|
96609
|
+
<span style="font-size: 14px; font-weight: 600; color: ${colors2.text};">Atribuir Owner + For\xE7ar Rela\xE7\xE3o para Owner</span>
|
|
96610
|
+
<span style="font-size: 11px; color: ${colors2.textMuted};">Troca o owner, remove a rela\xE7\xE3o existente e for\xE7a nova rela\xE7\xE3o para o owner atribu\xEDdo \u2014 mant\xE9m o tipo/profile atual do device</span>
|
|
96611
|
+
</button>
|
|
96549
96612
|
</div>
|
|
96550
96613
|
<div style="display: flex; justify-content: flex-end;">
|
|
96551
96614
|
<button id="${modalId}-custom-cancel-bottom" style="
|
|
@@ -96578,11 +96641,11 @@ function renderModal4(container, state6, modalId, t, error) {
|
|
|
96578
96641
|
box-shadow: 0 20px 40px rgba(0,0,0,0.3);
|
|
96579
96642
|
">
|
|
96580
96643
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
|
96581
|
-
<h3 style="margin: 0; color: ${colors2.text}; font-size: 18px; font-weight: 600;"
|
|
96644
|
+
<h3 style="margin: 0; color: ${colors2.text}; font-size: 18px; font-weight: 600;">${rel.alsoChangeOwner ? "\u{1F464} Atribuir Owner + For\xE7ar Rela\xE7\xE3o" : "\u{1F517} For\xE7ar Rela\xE7\xE3o em Lote"}</h3>
|
|
96582
96645
|
<button id="${modalId}-bulk-rel-close" style="background: none; border: none; font-size: 20px; cursor: pointer; color: ${colors2.textMuted}; padding: 4px;">\u2715</button>
|
|
96583
96646
|
</div>
|
|
96584
96647
|
<p style="margin: 0 0 16px; font-size: 13px; color: ${colors2.textMuted};">
|
|
96585
|
-
Remove todas as rela\xE7\xF5es TO existentes dos <strong>${state6.selectedDevices.length}</strong> devices e cria uma nova rela\xE7\xE3o para o destino escolhido
|
|
96648
|
+
${rel.alsoChangeOwner ? `Troca o owner (customerId) dos <strong>${state6.selectedDevices.length}</strong> devices para o customer escolhido, remove as rela\xE7\xF5es TO existentes e cria uma nova rela\xE7\xE3o Customer \u2192 Device. O tipo/profile atual do device n\xE3o \xE9 alterado.` : `Remove todas as rela\xE7\xF5es TO existentes dos <strong>${state6.selectedDevices.length}</strong> devices e cria uma nova rela\xE7\xE3o para o destino escolhido.`}
|
|
96586
96649
|
</p>
|
|
96587
96650
|
|
|
96588
96651
|
<!-- Customer de destino -->
|
|
@@ -96634,7 +96697,8 @@ function renderModal4(container, state6, modalId, t, error) {
|
|
|
96634
96697
|
</div>
|
|
96635
96698
|
</label>
|
|
96636
96699
|
|
|
96637
|
-
<!-- Target: Existing Asset -->
|
|
96700
|
+
<!-- Target: Existing Asset (hidden when reassigning owner \u2014 no ASSET equivalent) -->
|
|
96701
|
+
${rel.alsoChangeOwner ? "" : `
|
|
96638
96702
|
<label style="display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 8px; border: 2px solid ${rel.target === "ASSET_EXISTING" ? "#0a6d5e" : colors2.border}; cursor: pointer; margin-bottom: 8px; flex-direction: column;">
|
|
96639
96703
|
<div style="display: flex; align-items: center; gap: 10px; width: 100%;">
|
|
96640
96704
|
<input type="radio" name="${modalId}-bulk-rel-target" value="ASSET_EXISTING"
|
|
@@ -96680,8 +96744,10 @@ function renderModal4(container, state6, modalId, t, error) {
|
|
|
96680
96744
|
</div>
|
|
96681
96745
|
` : ""}
|
|
96682
96746
|
</label>
|
|
96747
|
+
`}
|
|
96683
96748
|
|
|
96684
|
-
<!-- Target: New Asset -->
|
|
96749
|
+
<!-- Target: New Asset (hidden when reassigning owner \u2014 no ASSET equivalent) -->
|
|
96750
|
+
${rel.alsoChangeOwner ? "" : `
|
|
96685
96751
|
<label style="display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 8px; border: 2px solid ${rel.target === "ASSET_NEW" ? "#0a6d5e" : colors2.border}; cursor: pointer; margin-bottom: 16px; flex-direction: column;">
|
|
96686
96752
|
<div style="display: flex; align-items: center; gap: 10px; width: 100%;">
|
|
96687
96753
|
<input type="radio" name="${modalId}-bulk-rel-target" value="ASSET_NEW"
|
|
@@ -96702,6 +96768,7 @@ function renderModal4(container, state6, modalId, t, error) {
|
|
|
96702
96768
|
</div>
|
|
96703
96769
|
` : ""}
|
|
96704
96770
|
</label>
|
|
96771
|
+
`}
|
|
96705
96772
|
|
|
96706
96773
|
<div style="display: flex; gap: 10px; justify-content: flex-end;">
|
|
96707
96774
|
<button id="${modalId}-bulk-rel-cancel" style="
|
|
@@ -96713,7 +96780,7 @@ function renderModal4(container, state6, modalId, t, error) {
|
|
|
96713
96780
|
background: #0a6d5e; color: white; border: none;
|
|
96714
96781
|
padding: 10px 20px; border-radius: 6px; cursor: pointer;
|
|
96715
96782
|
font-size: 14px; font-weight: 500;
|
|
96716
|
-
" ${rel.target === "ASSET_EXISTING" && !rel.selectedAssetId || rel.target === "ASSET_NEW" && !rel.newAssetName.trim() ? "disabled" : ""}
|
|
96783
|
+
" ${rel.target === "ASSET_EXISTING" && !rel.selectedAssetId || rel.target === "ASSET_NEW" && !rel.newAssetName.trim() ? "disabled" : ""}>${rel.alsoChangeOwner ? "\u{1F464} Atribuir Owner" : "\u{1F517} For\xE7ar"} (${state6.selectedDevices.length} dev)</button>
|
|
96717
96784
|
</div>
|
|
96718
96785
|
</div>
|
|
96719
96786
|
</div>
|
|
@@ -96911,7 +96978,6 @@ function renderCheckFixRow(r, state6, modalId, colors2, dupPairIds, dupIngestion
|
|
|
96911
96978
|
};
|
|
96912
96979
|
const isMismatch = r.status === "mismatch";
|
|
96913
96980
|
const typeActWrong = isMismatch && r.actual.type !== r.inferred.deviceType;
|
|
96914
|
-
const devTypeWrong = isMismatch && r.actual.deviceType !== r.inferred.deviceType;
|
|
96915
96981
|
const devProfWrong = isMismatch && r.actual.deviceProfile !== r.inferred.deviceProfile;
|
|
96916
96982
|
const tsStr = r.telemetry.ts ? new Date(r.telemetry.ts).toLocaleString("pt-BR", { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit" }) : "\u2014";
|
|
96917
96983
|
const unit = {
|
|
@@ -96938,8 +97004,6 @@ function renderCheckFixRow(r, state6, modalId, colors2, dupPairIds, dupIngestion
|
|
|
96938
97004
|
<td ${copyAttr(r.deviceLabel)} style="${cell()} max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:${colors2.textMuted};" title="${r.deviceLabel}">${r.deviceLabel || dash}</td>
|
|
96939
97005
|
<td ${copyAttr(r.inferred.deviceType)} style="${cell(typeActWrong ? "ok" : "none", true)}">${r.inferred.deviceType}</td>
|
|
96940
97006
|
<td ${copyAttr(r.actual.type ?? "")} style="${cell(typeActWrong ? r.typeEqualsProfile ? "warn" : "bad" : "none", true)}" title="${typeActWrong ? `esperado: ${r.inferred.deviceType}` : ""}">${r.actual.type || dash}</td>
|
|
96941
|
-
<td ${copyAttr(r.inferred.deviceType)} style="${cell(devTypeWrong ? "ok" : "none", true)}">${r.inferred.deviceType}</td>
|
|
96942
|
-
<td ${copyAttr(r.actual.deviceType ?? "")} style="${cell(devTypeWrong ? "bad" : "none", true)}" title="${devTypeWrong ? `esperado: ${r.inferred.deviceType}` : ""}">${r.actual.deviceType || dash}</td>
|
|
96943
97007
|
<td ${copyAttr(r.inferred.deviceProfile)} style="${cell(devProfWrong ? "ok" : "none", true)}">${r.inferred.deviceProfile}</td>
|
|
96944
97008
|
<td ${copyAttr(r.actual.deviceProfile ?? "")} style="${cell(devProfWrong ? "bad" : "none", true)}" title="${devProfWrong ? `esperado: ${r.inferred.deviceProfile}` : ""}">${r.actual.deviceProfile || dash}</td>
|
|
96945
97009
|
<td ${copyAttr(r.telemetry.ts ? tsStr : "")} style="${cell()} white-space:nowrap; color:${colors2.textMuted}; font-size:9px;">${tsStr}</td>
|
|
@@ -97289,7 +97353,7 @@ function renderStep2(state6, modalId, colors2, t) {
|
|
|
97289
97353
|
ingCount.forEach((ids) => {
|
|
97290
97354
|
if (ids.length > 1) ids.forEach((id) => dupIngestionIds.add(id));
|
|
97291
97355
|
});
|
|
97292
|
-
const colSpan = multiCol ?
|
|
97356
|
+
const colSpan = multiCol ? 16 : 15;
|
|
97293
97357
|
const cfSortHeader = (field, label, rowspan = 1, extraStyle = "") => {
|
|
97294
97358
|
const isActive = state6.checkFixSort.field === field;
|
|
97295
97359
|
const arrow = isActive ? state6.checkFixSort.order === "asc" ? "\u25B2" : "\u25BC" : "\u25BD";
|
|
@@ -97374,7 +97438,6 @@ function renderStep2(state6, modalId, colors2, t) {
|
|
|
97374
97438
|
<col style="width:95px"/>
|
|
97375
97439
|
<col style="width:70px"/><col style="width:70px"/>
|
|
97376
97440
|
<col style="width:90px"/><col style="width:90px"/>
|
|
97377
|
-
<col style="width:90px"/><col style="width:90px"/>
|
|
97378
97441
|
<col style="width:85px"/>
|
|
97379
97442
|
<col style="width:110px"/>
|
|
97380
97443
|
<col style="width:70px"/>
|
|
@@ -97390,7 +97453,6 @@ function renderStep2(state6, modalId, colors2, t) {
|
|
|
97390
97453
|
${cfSortHeader("name", "Name", 2, "min-width:140px")}
|
|
97391
97454
|
<th rowspan="2" style="${thStyle("min-width:90px")}">Label</th>
|
|
97392
97455
|
<th colspan="2" style="${thStyle("text-align:center")}">TYPE</th>
|
|
97393
|
-
<th colspan="2" style="${thStyle("text-align:center")}">DevType</th>
|
|
97394
97456
|
<th colspan="2" style="${thStyle("text-align:center")}">DevProfile</th>
|
|
97395
97457
|
<th colspan="2" style="${thStyle("text-align:center")}">Last Telemetry</th>
|
|
97396
97458
|
${cfSortHeader("connStatus", "Conn.", 2, "min-width:65px")}
|
|
@@ -97401,7 +97463,6 @@ function renderStep2(state6, modalId, colors2, t) {
|
|
|
97401
97463
|
${cfSortHeader("status", "Result", 2)}
|
|
97402
97464
|
</tr>
|
|
97403
97465
|
<tr>
|
|
97404
|
-
<th style="${thStyle()}">Exp</th><th style="${thStyle()}">Act</th>
|
|
97405
97466
|
<th style="${thStyle()}">Exp</th><th style="${thStyle()}">Act</th>
|
|
97406
97467
|
<th style="${thStyle()}">Exp</th><th style="${thStyle()}">Act</th>
|
|
97407
97468
|
<th style="${thStyle("min-width:80px")}">Date</th>
|
|
@@ -99345,6 +99406,26 @@ function setupEventListeners3(container, state6, modalId, t, onClose) {
|
|
|
99345
99406
|
await loadLojasData(state6, container, modalId, t, onClose);
|
|
99346
99407
|
});
|
|
99347
99408
|
});
|
|
99409
|
+
document.getElementById(`${modalId}-custom-mode-assign-owner`)?.addEventListener("click", () => {
|
|
99410
|
+
if (!state6.selectedCustomer) {
|
|
99411
|
+
alert("Selecione um Customer primeiro no Step 1");
|
|
99412
|
+
return;
|
|
99413
|
+
}
|
|
99414
|
+
state6.customModeModal.open = false;
|
|
99415
|
+
state6.bulkRelationModal.open = true;
|
|
99416
|
+
state6.bulkRelationModal.target = "CUSTOMER";
|
|
99417
|
+
state6.bulkRelationModal.selectedAssetId = "";
|
|
99418
|
+
state6.bulkRelationModal.selectedAssetName = "";
|
|
99419
|
+
state6.bulkRelationModal.search = "";
|
|
99420
|
+
state6.bulkRelationModal.newAssetName = "";
|
|
99421
|
+
state6.bulkRelationModal.overrideCustomerId = "";
|
|
99422
|
+
state6.bulkRelationModal.overrideCustomerName = "";
|
|
99423
|
+
state6.bulkRelationModal.customerSearch = "";
|
|
99424
|
+
state6.bulkRelationModal.customerPickerOpen = false;
|
|
99425
|
+
state6.bulkRelationModal.alsoChangeOwner = true;
|
|
99426
|
+
renderModal4(container, state6, modalId, t);
|
|
99427
|
+
setupEventListeners3(container, state6, modalId, t, onClose);
|
|
99428
|
+
});
|
|
99348
99429
|
document.getElementById(`${modalId}-bulk-sync-ingestion`)?.addEventListener("click", async () => {
|
|
99349
99430
|
if (!state6.selectedCustomer || state6.selectedDevices.length === 0) return;
|
|
99350
99431
|
await handleBulkSyncIngestionId(state6, container, modalId, t, onClose);
|
|
@@ -99375,6 +99456,7 @@ function setupEventListeners3(container, state6, modalId, t, onClose) {
|
|
|
99375
99456
|
state6.bulkRelationModal.overrideCustomerName = "";
|
|
99376
99457
|
state6.bulkRelationModal.customerSearch = "";
|
|
99377
99458
|
state6.bulkRelationModal.customerPickerOpen = false;
|
|
99459
|
+
state6.bulkRelationModal.alsoChangeOwner = false;
|
|
99378
99460
|
renderModal4(container, state6, modalId, t);
|
|
99379
99461
|
setupEventListeners3(container, state6, modalId, t, onClose);
|
|
99380
99462
|
});
|
|
@@ -100086,7 +100168,13 @@ async function handleBatchForceRelation(state6, container, modalId, t, onClose)
|
|
|
100086
100168
|
return;
|
|
100087
100169
|
}
|
|
100088
100170
|
}
|
|
100089
|
-
const confirmMsg = `
|
|
100171
|
+
const confirmMsg = rel.alsoChangeOwner ? `Atribuir owner + for\xE7ar rela\xE7\xE3o para ${devices.length} dispositivos?
|
|
100172
|
+
|
|
100173
|
+
Novo owner: ${fromEntityName}
|
|
100174
|
+
|
|
100175
|
+
Cada device ter\xE1 o owner (customerId) trocado para o customer acima, todas as rela\xE7\xF5es TO existentes ser\xE3o removidas, e uma nova rela\xE7\xE3o Customer \u2192 Device ser\xE1 criada para o mesmo owner. O tipo/profile atual do device N\xC3O ser\xE1 alterado.
|
|
100176
|
+
|
|
100177
|
+
Deseja continuar?` : `For\xE7ar rela\xE7\xE3o para ${devices.length} dispositivos?
|
|
100090
100178
|
|
|
100091
100179
|
Destino: ${fromEntityType} \u2192 ${fromEntityName}
|
|
100092
100180
|
|
|
@@ -100097,7 +100185,7 @@ Deseja continuar?`;
|
|
|
100097
100185
|
state6.bulkRelationModal.open = false;
|
|
100098
100186
|
renderModal4(container, state6, modalId, t);
|
|
100099
100187
|
setupEventListeners3(container, state6, modalId, t, onClose);
|
|
100100
|
-
showBusyProgress("For\xE7ando rela\xE7\xF5es em lote...", devices.length);
|
|
100188
|
+
showBusyProgress(rel.alsoChangeOwner ? "Atribuindo owner em lote..." : "For\xE7ando rela\xE7\xF5es em lote...", devices.length);
|
|
100101
100189
|
let successCount = 0;
|
|
100102
100190
|
let errorCount = 0;
|
|
100103
100191
|
const errors = [];
|
|
@@ -100106,6 +100194,11 @@ Deseja continuar?`;
|
|
|
100106
100194
|
const deviceId = getEntityId(device);
|
|
100107
100195
|
const deviceName = device.label || device.name;
|
|
100108
100196
|
try {
|
|
100197
|
+
if (rel.alsoChangeOwner && fromEntityType === "CUSTOMER") {
|
|
100198
|
+
updateBusyProgress(i + 1, `[${i + 1}/${devices.length}] ${deviceName}: Atualizando owner...`);
|
|
100199
|
+
await changeDeviceOwner(state6, device, fromEntityId);
|
|
100200
|
+
device.customerId = { entityType: "CUSTOMER", id: fromEntityId };
|
|
100201
|
+
}
|
|
100109
100202
|
updateBusyProgress(i + 1, `[${i + 1}/${devices.length}] ${deviceName}: Buscando rela\xE7\xF5es...`);
|
|
100110
100203
|
const relationsResp = await tbFetch(
|
|
100111
100204
|
state6,
|
|
@@ -100146,11 +100239,12 @@ Deseja continuar?`;
|
|
|
100146
100239
|
updateBusyProgress(i + 1);
|
|
100147
100240
|
}
|
|
100148
100241
|
hideBusyProgress();
|
|
100242
|
+
const actionLabel = rel.alsoChangeOwner ? "Owner atribu\xEDdo e rela\xE7\xE3o for\xE7ada" : "Rela\xE7\xF5es for\xE7adas";
|
|
100149
100243
|
if (errorCount === 0) {
|
|
100150
|
-
alert(
|
|
100244
|
+
alert(`${actionLabel} com sucesso para ${successCount} dispositivos!`);
|
|
100151
100245
|
} else {
|
|
100152
100246
|
alert(
|
|
100153
|
-
|
|
100247
|
+
`${actionLabel} para ${successCount} dispositivos.
|
|
100154
100248
|
Erro em ${errorCount} dispositivos:
|
|
100155
100249
|
${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
|
|
100156
100250
|
... e mais ${errors.length - 5} erros` : "")
|
|
@@ -100885,7 +100979,15 @@ async function runCheckFixRoutine(state6, container, modalId, t, onClose, scopeD
|
|
|
100885
100979
|
if (devices.length === 0) return;
|
|
100886
100980
|
const BATCH_SIZE = 5;
|
|
100887
100981
|
const BATCH_DELAY_MS = 1500;
|
|
100888
|
-
|
|
100982
|
+
const customer = state6.selectedCustomer;
|
|
100983
|
+
state6.checkFixReport = {
|
|
100984
|
+
customerName: customer?.name || customer?.title || "",
|
|
100985
|
+
totalDevices: devices.length,
|
|
100986
|
+
records: [],
|
|
100987
|
+
runAt: Date.now()
|
|
100988
|
+
};
|
|
100989
|
+
const progressMessage = (done) => `\u{1F52C} CHECK & FIX: ${done} / ${devices.length} (${Math.round(done / devices.length * 100)}%)`;
|
|
100990
|
+
const toast = MyIOToast.info(progressMessage(0), 0);
|
|
100889
100991
|
const records = [];
|
|
100890
100992
|
for (let i = 0; i < devices.length; i += BATCH_SIZE) {
|
|
100891
100993
|
const batch = devices.slice(i, i + BATCH_SIZE);
|
|
@@ -100925,16 +101027,17 @@ async function runCheckFixRoutine(state6, container, modalId, t, onClose, scopeD
|
|
|
100925
101027
|
);
|
|
100926
101028
|
if (telem.connectionStatus?.[0]) {
|
|
100927
101029
|
connStatus = String(telem.connectionStatus[0].value);
|
|
100928
|
-
telemetryTs = telem.connectionStatus[0].ts;
|
|
100929
101030
|
}
|
|
100930
101031
|
const domainKeys = domain ? TELEMETRY_KEYS_BY_DOMAIN[domain] ?? [] : [];
|
|
100931
101032
|
domainKeys.forEach((key) => {
|
|
100932
101033
|
const entry = telem[key]?.[0];
|
|
100933
101034
|
if (entry) {
|
|
100934
101035
|
telemetryValues[key] = entry.value;
|
|
100935
|
-
if (!telemetryTs || entry.ts > telemetryTs) telemetryTs = entry.ts;
|
|
100936
101036
|
}
|
|
100937
101037
|
});
|
|
101038
|
+
const primaryTsKey = domain ? CHECK_FIX_PRIMARY_TS_KEY[domain] : null;
|
|
101039
|
+
const primaryEntry = primaryTsKey ? telem[primaryTsKey]?.[0] : null;
|
|
101040
|
+
telemetryTs = primaryEntry ? primaryEntry.ts : null;
|
|
100938
101041
|
} catch {
|
|
100939
101042
|
}
|
|
100940
101043
|
let status;
|
|
@@ -100971,19 +101074,16 @@ async function runCheckFixRoutine(state6, container, modalId, t, onClose, scopeD
|
|
|
100971
101074
|
});
|
|
100972
101075
|
const batchResults = await Promise.all(promises);
|
|
100973
101076
|
records.push(...batchResults);
|
|
100974
|
-
|
|
101077
|
+
const done = Math.min(i + BATCH_SIZE, devices.length);
|
|
101078
|
+
state6.checkFixReport.records = records.slice();
|
|
101079
|
+
toast.update(progressMessage(done));
|
|
101080
|
+
renderModal4(container, state6, modalId, t);
|
|
101081
|
+
setupEventListeners3(container, state6, modalId, t, onClose);
|
|
100975
101082
|
if (i + BATCH_SIZE < devices.length) {
|
|
100976
101083
|
await new Promise((resolve) => setTimeout(resolve, BATCH_DELAY_MS));
|
|
100977
101084
|
}
|
|
100978
101085
|
}
|
|
100979
|
-
|
|
100980
|
-
state6.checkFixReport = {
|
|
100981
|
-
customerName: customer?.name || customer?.title || "",
|
|
100982
|
-
totalDevices: devices.length,
|
|
100983
|
-
records,
|
|
100984
|
-
runAt: Date.now()
|
|
100985
|
-
};
|
|
100986
|
-
hideBusyProgress();
|
|
101086
|
+
toast.hide();
|
|
100987
101087
|
}
|
|
100988
101088
|
async function loadValidationData(state6, container, modalId, t, onClose) {
|
|
100989
101089
|
if (!state6.selectedDevice) return;
|
package/dist/index.d.cts
CHANGED
|
@@ -4702,13 +4702,15 @@ declare namespace MyIOToast {
|
|
|
4702
4702
|
* @param {string} message - The message to display
|
|
4703
4703
|
* @param {string} [type='info'] - 'info' | 'success' | 'warning' | 'error'
|
|
4704
4704
|
* @param {number} [duration=3500] - ms before auto-hide; 0 = sticky
|
|
4705
|
-
* @returns {{ hide: () => void }} handle to
|
|
4705
|
+
* @returns {{ hide: () => void, update: (message: string) => void }} handle to
|
|
4706
|
+
* dismiss this specific toast, or mutate its text in place (sticky toasts)
|
|
4706
4707
|
*
|
|
4707
4708
|
* @example
|
|
4708
4709
|
* MyIOToast.show('Failed to save changes', 'error', 5000);
|
|
4709
4710
|
*/
|
|
4710
4711
|
declare function show(message: string, type?: string, duration?: number): {
|
|
4711
4712
|
hide: () => void;
|
|
4713
|
+
update: (message: string) => void;
|
|
4712
4714
|
};
|
|
4713
4715
|
/**
|
|
4714
4716
|
* Dismiss ALL toasts currently on screen.
|
package/dist/index.d.ts
CHANGED
|
@@ -4702,13 +4702,15 @@ declare namespace MyIOToast {
|
|
|
4702
4702
|
* @param {string} message - The message to display
|
|
4703
4703
|
* @param {string} [type='info'] - 'info' | 'success' | 'warning' | 'error'
|
|
4704
4704
|
* @param {number} [duration=3500] - ms before auto-hide; 0 = sticky
|
|
4705
|
-
* @returns {{ hide: () => void }} handle to
|
|
4705
|
+
* @returns {{ hide: () => void, update: (message: string) => void }} handle to
|
|
4706
|
+
* dismiss this specific toast, or mutate its text in place (sticky toasts)
|
|
4706
4707
|
*
|
|
4707
4708
|
* @example
|
|
4708
4709
|
* MyIOToast.show('Failed to save changes', 'error', 5000);
|
|
4709
4710
|
*/
|
|
4710
4711
|
declare function show(message: string, type?: string, duration?: number): {
|
|
4711
4712
|
hide: () => void;
|
|
4713
|
+
update: (message: string) => void;
|
|
4712
4714
|
};
|
|
4713
4715
|
/**
|
|
4714
4716
|
* Dismiss ALL toasts currently on screen.
|