v6d3musicapi/app/static/operator.js

70 lines
1.8 KiB
JavaScript

aApi({
type: "guilds",
operator: null,
catches: { "not an operator": null, "*": null },
}).then(console.log);
aApi({
type: "sleep",
operator: null,
duration: 1,
echo: {},
time: null,
catches: { "not an operator": null, "*": null },
}).then(console.log);
aApi({
type: "*",
idkey: "target",
idbase: {
type: "*",
requests: {
Count: {},
Concurrency: {},
},
},
operator: null,
requests: {
"v6d3music.api.Api().api": {},
"v6d3music.processing.pool.UnitJob.run": {},
},
catches: { "not an operator": null, "*": null },
time: null,
}).then((value) => console.log(JSON.stringify(value, undefined, 2)));
aApi({
type: "pool",
operator: null,
catches: { "not an operator": null, "*": null },
}).then((value) => console.log(JSON.stringify(value, undefined, 2)));
const elJob = (job) => {
const jobview = document.createElement("div");
jobview.classList.add("jobview");
jobview.innerText = JSON.stringify(job);
return jobview;
};
const elWorker = (worker) => {
const workerview = document.createElement("div");
workerview.classList.add("workerview");
workerview.append(`qsize: ${worker.qsize}`);
workerview.append(elJob(worker.job));
return workerview;
};
const elPool = async () => {
const pool = document.createElement("div");
pool.id = "workerpool";
const workers = await aApi({
type: "pool",
operator: null,
catches: { "not an operator": null, "*": null },
});
if (workers === null || workers.error !== undefined) return null;
for (const worker of workers) {
pool.append(elWorker(worker));
}
return pool;
};
const pageOperator = async () => {
const operation = document.createElement("div");
operation.id = "operation";
operation.append(await elPool());
return operation;
};