Skip to content

Commit 3c62fb0

Browse files
committed
Load the pipeline information and store ids and nicknames
1 parent ec1eb7c commit 3c62fb0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

dashboard/assets/scripts/dashboard.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class JobsRenderer {
309309
this.mouseInside = null;
310310
this.numCrawls = byId("num-crawls");
311311
this._aligned = true;
312+
this.pipelines = {};
312313
}
313314

314315
_getNextJobInSorted(ident) {
@@ -325,6 +326,10 @@ class JobsRenderer {
325326
return h("div");
326327
}
327328

329+
updatePipelines(pipelines) {
330+
this.pipelines = pipelines;
331+
}
332+
328333
_createLogContainer(jobData) {
329334
const ident = jobData.ident;
330335
const beforeJob = this._getNextJobInSorted(ident);
@@ -1093,6 +1098,8 @@ class Dashboard {
10931098
this.contextMenuRenderer,
10941099
);
10951100

1101+
this.loadPipelines();
1102+
10961103
document.onkeypress = (ev) => this.keyPress(ev);
10971104

10981105
// Adjust help text based on URL
@@ -1192,6 +1199,31 @@ ${String(kbPerSec).padStart(3, "0")} KB/s`;
11921199
}
11931200
}
11941201

1202+
loadPipelines() {
1203+
return new Promise((resolve, reject) => {
1204+
const xhr = new XMLHttpRequest();
1205+
xhr.onload = () => {
1206+
try {
1207+
let pipelines = {};
1208+
const json = JSON.parse(xhr.responseText).pipelines;
1209+
for (const pipeline of json) {
1210+
pipelines[pipeline.id] = pipeline.nickname;
1211+
}
1212+
this.jobsRenderer.updatePipelines(pipelines);
1213+
} catch (e) {
1214+
console.log("Failed to load /pipelines data: ", e);
1215+
}
1216+
resolve();
1217+
};
1218+
xhr.onerror = (ev) => {
1219+
reject(ev);
1220+
};
1221+
xhr.open("GET", `//${this.host}${this.port}/pipelines`);
1222+
xhr.setRequestHeader("Accept", "application/json");
1223+
xhr.send("");
1224+
});
1225+
}
1226+
11951227
loadRecent() {
11961228
return new Promise((resolve, reject) => {
11971229
byId("meta-info").textContent = "Requesting recent data";

0 commit comments

Comments
 (0)