Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lakhoune committed Oct 8, 2023
1 parent a1f32d8 commit 10cfef7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
26 changes: 21 additions & 5 deletions src/statistics/bot-statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class BotStats extends LitElement {
class="spinner-border position-absolute"
role="status"
style="top:50%;left:50%;"
?hidden="${!this.loading}"
>
<span class="visually-hidden">Loading...</span>
</div>
Expand Down Expand Up @@ -138,7 +139,7 @@ class BotStats extends LitElement {
});
if (botElement) {
const botName = botElement.label.value.value;
this.fetchStatistics(botName, botManagerEndpoint);
this.fetchStatistics(botName);
this.getSuccessMeasureList(botName);
this.fetchMeasureCatalog(botName);
}
Expand Down Expand Up @@ -197,6 +198,7 @@ class BotStats extends LitElement {
const body = await res.json();
const xmlString = body.xml;
const measureNames = parseMeasures(xmlString);
this.measures = measureNames;
return measureNames;
}

Expand Down Expand Up @@ -236,9 +238,23 @@ class BotStats extends LitElement {
}
}

async fetchStatistics(botName, botManagerEndpoint) {
// botManagerEndpoint = "http://social-bot-manager:8080/SBFManager";
const url = `${config.pm4botsEndpoint}/bot/${botName}/petri-net?bot-manager-url=${botManagerEndpoint}`;
async fetchStatistics(botName) {
const botManagerEndpointInput = this.configMap
.get("sbm-endpoint")
.toString();
const pm4botsEndpointInput = this.configMap
.get("pm4bots-endpoint")
.toString();
if (!botManagerEndpointInput || !pm4botsEndpointInput) {
return;
}
let url = joinAbsoluteUrlPath(
pm4botsEndpointInput,
"bot",
botName,
"petri-net"
);
url += `?bot-manager-url=${botManagerEndpointInput}`;
console.log(url);
try {
const response = await fetch(url, {
Expand All @@ -249,9 +265,9 @@ class BotStats extends LitElement {
},
});
if (!response.ok) {
this.loading = false;
return;
}
this.loading = false;
const element = document.getElementById("pm-res");

document.getElementById("pm-res").innerHTML = await response.text();
Expand Down
9 changes: 6 additions & 3 deletions src/statistics/canvas-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@ class CanvasStatsOverlay extends LitElement {
const y = await instance.connect();
this.y = y;
super.firstUpdated();
this.configMap = y.getMap("pm4bots-config");

setTimeout(() => {
const botManagerEndpoint = y.getText("sbfManager").toString();
const botModel = y.getMap("data").get("model");
const botManagerEndpointInput = this.configMap
.get("sbm-endpoint")
.toString();
const botModel = y.getMap("data").get("model");
if (botModel) {
const botElement = Object.values(botModel.nodes).find((node) => {
return node.type === "Bot";
});
if (botElement) {
const botName = botElement.label.value.value;
this.fetchStatistics(botName, botManagerEndpoint);
this.fetchStatistics(botName, botManagerEndpointInput);
}
}
}, 300);
Expand Down

0 comments on commit 10cfef7

Please sign in to comment.