Minor Adjustments

This commit is contained in:
Dunemask 2023-03-19 13:53:37 -04:00 committed by dunemask
parent ba8e6ded26
commit a90c28dd76
60 changed files with 8240 additions and 8 deletions

View file

@ -0,0 +1,26 @@
import io from "socket.io-client";
import modes from "../modes.js";
import events from "../events.js";
export { default as events } from "../events.js";
export { default as modes } from "../modes.js";
export default class Viewer {
constructor(url, options = {}) {
this.url = url;
this.mode = modes.VIEW;
this.onLog = options.onLog ?? console.log;
this.onClose = options.onClose ?? (() => {});
}
viewJob(jobId, onLog, onClose) {
onLog = onLog ?? this.onLog.bind(this);
onClose = onClose ?? this.onClose.bind(this);
const sk = io(this.url, {
query: { mode: this.mode, jobId },
});
sk.on(events.JOB_LOG, onLog);
sk.on(events.JOB_CLS, onClose);
return sk;
}
}