Skip to content

Commit b371d01

Browse files
committed
Update UI that Single and Multiple instance commands are correctly supported
1 parent ad81c00 commit b371d01

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed

assets/webconfig/js/hyperion.js

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function initWebSocket() {
173173
}
174174
}
175175

176-
function sendToHyperion(command, subcommand, msg) {
176+
function sendToHyperion(command, subcommand, msg, instanceIds = null) {
177177
const tan = Math.floor(Math.random() * 1000); // Generate a transaction number
178178

179179
// Build the base object
@@ -187,6 +187,11 @@ function sendToHyperion(command, subcommand, msg) {
187187
message.subcommand = subcommand;
188188
}
189189

190+
// Add the instanceID(s) the command is to be applied to
191+
if (instanceIds != null) {
192+
message.instance = instanceIds;
193+
}
194+
190195
// Merge the msg object into the final message if provided
191196
if (msg && typeof msg === "object") {
192197
Object.assign(message, msg);
@@ -289,26 +294,26 @@ function requestTokenDelete(id) {
289294
}
290295

291296
function requestInstanceRename(instance, name) {
292-
sendToHyperion("instance", "saveName", { instance: Number(instance), name });
297+
sendToHyperion("instance", "saveName", { name }, Number(instance));
293298
}
294299

295300
function requestInstanceStartStop(instance, start) {
296301
if (start)
297-
sendToHyperion("instance", "startInstance", { instance: Number(instance) });
302+
sendToHyperion("instance", "startInstance", {}, Number(instance));
298303
else
299-
sendToHyperion("instance", "stopInstance", { instance: Number(instance) });
304+
sendToHyperion("instance", "stopInstance", {}, Number(instance));
300305
}
301306

302307
function requestInstanceDelete(instance) {
303-
sendToHyperion("instance", "deleteInstance", { instance: Number(instance) });
308+
sendToHyperion("instance", "deleteInstance", {}, Number(instance));
304309
}
305310

306311
function requestInstanceCreate(name) {
307312
sendToHyperion("instance", "createInstance", { name });
308313
}
309314

310315
function requestInstanceSwitch(instance) {
311-
sendToHyperion("instance", "switchTo", { instance: Number(instance) });
316+
sendToHyperion("instance", "switchTo", {}, Number(instance));
312317
}
313318

314319
function requestServerInfo(instance) {
@@ -325,12 +330,8 @@ function requestServerInfo(instance) {
325330
"event-update"
326331
]
327332
};
328-
329-
if (instance !== null && instance !== undefined && !isNaN(Number(instance))) {
330-
data.instance = Number(instance);
331-
}
332333

333-
sendToHyperion("serverinfo", "getInfo", data);
334+
sendToHyperion("serverinfo", "getInfo", data, Number(instance));
334335
return Promise.resolve();
335336
}
336337

@@ -394,62 +395,62 @@ function requestServerConfigReload() {
394395
sendToHyperion("config", "reload");
395396
}
396397

397-
function requestLedColorsStart() {
398+
function requestLedColorsStart(instanceId = window.currentHyperionInstance) {
398399
window.ledStreamActive = true;
399-
sendToHyperion("ledcolors", "ledstream-start");
400+
sendToHyperion("ledcolors", "ledstream-start", {} , instanceId);
400401
}
401402

402-
function requestLedColorsStop() {
403+
function requestLedColorsStop(instanceId = window.currentHyperionInstance) {
403404
window.ledStreamActive = false;
404-
sendToHyperion("ledcolors", "ledstream-stop");
405+
sendToHyperion("ledcolors", "ledstream-stop", {} , instanceId);
405406
}
406407

407-
function requestLedImageStart() {
408+
function requestLedImageStart(instanceId = window.currentHyperionInstance) {
408409
window.imageStreamActive = true;
409-
sendToHyperion("ledcolors", "imagestream-start");
410+
sendToHyperion("ledcolors", "imagestream-start", {} , instanceId);
410411
}
411412

412-
function requestLedImageStop() {
413+
function requestLedImageStop(instanceId = window.currentHyperionInstance) {
413414
window.imageStreamActive = false;
414-
sendToHyperion("ledcolors", "imagestream-stop");
415+
sendToHyperion("ledcolors", "imagestream-stop", {} , instanceId);
415416
}
416417

417-
function requestPriorityClear(priority) {
418+
function requestPriorityClear(priority, instanceIds = [window.currentHyperionInstance]) {
418419
if (typeof priority !== 'number')
419420
priority = INPUT.FG_PRIORITY;
420421

421422
$(window.hyperion).trigger({ type: "stopBrowerScreenCapture" });
422-
sendToHyperion("clear", "", { priority });
423+
sendToHyperion("clear", "", { priority }, instanceIds);
423424
}
424425

425-
function requestClearAll() {
426+
function requestClearAll(instanceIds = [window.currentHyperionInstance]) {
426427
$(window.hyperion).trigger({ type: "stopBrowerScreenCapture" });
427-
requestPriorityClear(-1)
428+
requestPriorityClear(-1, instanceIds)
428429
}
429430

430-
function requestPlayEffect(name, duration) {
431+
function requestPlayEffect(name, duration, instanceIds = [window.currentHyperionInstance]) {
431432
$(window.hyperion).trigger({ type: "stopBrowerScreenCapture" });
432433
const data = {
433434
effect: { name },
434435
priority: INPUT.FG_PRIORITY,
435436
duration: validateDuration(duration),
436437
origin: INPUT.ORIGIN,
437438
};
438-
sendToHyperion("effect", "", data);
439+
sendToHyperion("effect", "", data, instanceIds);
439440
}
440441

441-
function requestSetColor(r, g, b, duration) {
442+
function requestSetColor(r, g, b, duration, instanceIds = [window.currentHyperionInstance]) {
442443
$(window.hyperion).trigger({ type: "stopBrowerScreenCapture" });
443444
const data = {
444445
color: [r, g, b],
445446
priority: INPUT.FG_PRIORITY,
446447
duration: validateDuration(duration),
447448
origin: INPUT.ORIGIN
448449
};
449-
sendToHyperion("color", "", data);
450+
sendToHyperion("color", "", data, instanceIds);
450451
}
451452

452-
function requestSetImage(imagedata, duration, name) {
453+
function requestSetImage(imagedata, duration, name, instanceIds = [window.currentHyperionInstance]) {
453454
const data = {
454455
imagedata,
455456
priority: INPUT.FG_PRIORITY,
@@ -458,18 +459,18 @@ function requestSetImage(imagedata, duration, name) {
458459
origin: INPUT.ORIGIN,
459460
name
460461
};
461-
sendToHyperion("image", "", data);
462+
sendToHyperion("image", "", data, instanceIds);
462463
}
463464

464-
function requestSetComponentState(component, state) {
465-
sendToHyperion("componentstate", "", { componentstate: { component, state } });
465+
function requestSetComponentState(component, state, instanceIds = [window.currentHyperionInstance]) {
466+
sendToHyperion("componentstate", "", { componentstate: { component, state } }, instanceIds);
466467
}
467468

468-
function requestSetSource(priority) {
469+
function requestSetSource(priority, instanceIds = [window.currentHyperionInstance]) {
469470
if (priority == "auto")
470-
sendToHyperion("sourceselect", "", { auto: true });
471+
sendToHyperion("sourceselect", "", { auto: true }, instanceIds);
471472
else
472-
sendToHyperion("sourceselect", "", { priority });
473+
sendToHyperion("sourceselect", "", { priority }, instanceIds);
473474
}
474475

475476
// Function to transform the legacy config into thee new API format
@@ -539,15 +540,15 @@ function requestWriteEffect(name, script, args, imageData) {
539540
sendToHyperion("create-effect", "", data);
540541
}
541542

542-
function requestTestEffect(name, pythonScript, args, imageData) {
543+
function requestTestEffect(name, pythonScript, args, imageData, instanceIds = [window.currentHyperionInstance]) {
543544
const data = {
544545
effect: { name, args },
545546
priority: INPUT.FG_PRIORITY,
546547
origin: INPUT.ORIGIN,
547548
pythonScript,
548549
imageData
549550
};
550-
sendToHyperion("effect", "", data);
551+
sendToHyperion("effect", "", data, instanceIds);
551552
}
552553

553554
function requestDeleteEffect(name) {
@@ -564,19 +565,19 @@ function requestLoggingStop() {
564565
sendToHyperion("logging", "stop");
565566
}
566567

567-
function requestMappingType(mappingType) {
568-
sendToHyperion("processing", "", { mappingType });
568+
function requestMappingType(mappingType, instanceIds = [window.currentHyperionInstance]) {
569+
sendToHyperion("processing", "", { mappingType }, instanceIds);
569570
}
570571

571572
function requestVideoMode(newMode) {
572573
sendToHyperion("videomode", "", { videoMode: newMode });
573574
}
574575

575-
function requestAdjustment(type, value, complete) {
576+
function requestAdjustment(type, value, complete, instanceIds = [window.currentHyperionInstance]) {
576577
if (complete === true)
577-
sendToHyperion("adjustment", "", { adjustment: type });
578+
sendToHyperion("adjustment", "", { adjustment: type }, useCurrentInstance);
578579
else
579-
sendToHyperion("adjustment", "", { adjustment: { [type]: value } });
580+
sendToHyperion("adjustment", "", { adjustment: { [type]: value } }, instanceIds);
580581
}
581582

582583
async function requestLedDeviceDiscovery(ledDeviceType, params) {

0 commit comments

Comments
 (0)