feat: add toggle to display remote control

This commit is contained in:
Fritz Heiden 2025-04-14 23:56:51 +02:00
parent 23245dd549
commit e09d42ecf6

View File

@ -4,6 +4,7 @@ import {
createResource, createResource,
createSignal, createSignal,
onCleanup, onCleanup,
Show,
} from "solid-js"; } from "solid-js";
import WebRTCService from "../../services/webrtc-service"; import WebRTCService from "../../services/webrtc-service";
import Integration from "../../data/integration"; import Integration from "../../data/integration";
@ -37,8 +38,15 @@ function IntegrationView(props) {
initialValue: [], initialValue: [],
}); });
const [selectedRemote, setSelectedRemote] = createSignal(); const [selectedRemote, setSelectedRemote] = createSignal();
const [remoteControlVisible, setRemoteControlVisible] = createSignal(false);
createEffect(() => handleRemoteSelected(availableRemotes().shift()?.getId())); createEffect(() =>
handleRemoteSelected(
availableRemotes()
.find(() => true)
?.getId()
)
);
createEffect(() => { createEffect(() => {
let url = UrlUtils.getUrl(); let url = UrlUtils.getUrl();
@ -90,6 +98,10 @@ function IntegrationView(props) {
RemoteService.sendCommand(command); RemoteService.sendCommand(command);
} }
function toggleRemoteControl() {
setRemoteControlVisible(!remoteControlVisible());
}
return ( return (
<div <div
class={ class={
@ -125,29 +137,41 @@ function IntegrationView(props) {
</div> </div>
</div> </div>
<div class="flex-fill d-flex flex-row overflow-hidden"> <div class="flex-fill d-flex flex-row overflow-hidden">
<div class="flex-fill rounded overflow-hidden"> <div
class="flex-fill rounded overflow-hidden"
style="position:relative;"
>
<video <video
ref={videoElement} ref={videoElement}
class="w-100 h-100" class="w-100 h-100"
style="background-color: #000" style="background-color: #000"
></video> ></video>
</div> <button
<div class="d-flex flex-column ps-3"> class="btn btn-dark mt-2 me-2"
<select style="transform: rotate(180deg);position:absolute;top:0;right:0;z-index:1000;"
class="form-select mb-3" onClick={toggleRemoteControl}
onChange={(e) => handleRemoteSelected(e.target.value)}
> >
{availableRemotes().map((remote, index) => ( <i class="bi bi-building"></i>
<option value={remote.getId()} selected={index === 0}> </button>
{remote.getTitle()}
</option>
))}
</select>
<RemoteControl
onCommand={handleRemoteButtonPressed}
remote={selectedRemote()}
/>
</div> </div>
<Show when={remoteControlVisible()}>
<div class="d-flex flex-column ps-3">
<select
class="form-select mb-3"
onChange={(e) => handleRemoteSelected(e.target.value)}
>
{availableRemotes().map((remote, index) => (
<option value={remote.getId()} selected={index === 0}>
{remote.getTitle()}
</option>
))}
</select>
<RemoteControl
onCommand={handleRemoteButtonPressed}
remote={selectedRemote()}
/>
</div>
</Show>
</div> </div>
</div> </div>
); );