AI Assistant widget (#1115)

* feat: add assistan widget

* feat: remove gtm

* feat: assistant - minify js, add option UI

* feat: assistant - ability to toggle assistant

* chore: update version to 1.102.00

* chore: resolve version conflict

* chore: cleanup

* chore: cleanup

* feat: ai widget - improve style

---------

Co-authored-by: Azgaar <azgaar.fmg@yandex.com>
This commit is contained in:
Azgaar 2024-09-22 14:59:53 +02:00 committed by GitHub
parent 97e504d2aa
commit e25f231697
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 64 additions and 9 deletions

28
main.js
View file

@ -317,7 +317,8 @@ async function generateMapOnLoad() {
applyLayersPreset(); // apply saved layers preset and reder layers
drawLayers();
fitMapToScreen();
focusOn(); // focus on point, cell or burg from MFCG based on url searchParams
focusOn(); // based on searchParams focus on point, cell or burg from MFCG
toggleAssistant();
}
// focus on coordinates, cell or burg provided in searchParams
@ -367,6 +368,31 @@ function focusOn() {
}
}
let isAssistantLoaded = false;
function toggleAssistant() {
const assistantContainer = byId("chat-widget-container");
const showAssistant = byId("azgaarAssistant").value === "show";
if (showAssistant) {
if (isAssistantLoaded) {
assistantContainer.style.display = "block";
} else {
import("./libs/openwidget.min.js").then(() => {
isAssistantLoaded = true;
setTimeout(() => {
const bubble = byId("chat-widget-minimized");
if (bubble) {
bubble.dataset.tip = "Click to open the Assistant";
bubble.on("mouseover", showDataTip);
}
}, 5000);
});
}
} else if (isAssistantLoaded) {
assistantContainer.style.display = "none";
}
}
// find burg for MFCG and focus on it
function findBurgForMFCG(params) {
const cells = pack.cells,