forked from OwnZones/orchestration-gui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP! feat: add media & html websocket connections
- Loading branch information
Showing
11 changed files
with
178 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import WebSocket from 'ws'; | ||
|
||
function createWebSocket(): Promise<WebSocket> { | ||
return new Promise((resolve, reject) => { | ||
const ws = new WebSocket(`ws://${process.env.AGILE_WEBSOCKET}`); | ||
ws.on('error', reject); | ||
ws.on('open', () => { | ||
// const send = ws.send.bind(ws); | ||
// ws.send = (message) => { | ||
// console.debug(`[websocket] sending message: ${message}`); | ||
// send(message); | ||
// }; | ||
resolve(ws); | ||
}); | ||
}); | ||
} | ||
|
||
export async function createHtmlWebSocket() { | ||
const ws = await createWebSocket(); | ||
return { | ||
create: (input: number) => { | ||
ws.send(`html create ${input} 1920 1080`); | ||
// delay the loading of the placeholder page to ensure the browser instance is ready | ||
setTimeout(() => { | ||
ws.send( | ||
`html load ${input} ${process.env.NEXTAUTH_URL}/html_input?input=${input}` | ||
); | ||
}, 1000); | ||
}, | ||
close: (input: number) => { | ||
ws.send(`html close ${input}`); | ||
} | ||
}; | ||
} | ||
|
||
export async function createMediaplayerWebSocket() { | ||
const ws = await createWebSocket(); | ||
return { | ||
create: (input: number) => { | ||
ws.send(`media create ${input} ${process.env.MEDIAPLAYER_PLACEHOLDER}`); | ||
ws.send(`media play ${input}`); | ||
}, | ||
close: (input: number) => { | ||
ws.send(`media close ${input}`); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PageProps } from '../../../.next/types/app/html_input/page'; | ||
|
||
export default function HtmlInput({ searchParams: { input } }: PageProps) { | ||
return ( | ||
<div className="fixed top-0 left-0 h-screen w-screen bg-white flex flex-col gap-12 justify-center items-center"> | ||
<p className="text-9xl font-extrabold">HTML INPUT</p> | ||
<p className="text-8xl font-bold">{input}</p> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import { | ||
IconBrowserPlus, | ||
IconPhotoPlus, | ||
IconVideoPlus | ||
} from '@tabler/icons-react'; | ||
import { useTranslate } from '../../i18n/useTranslate'; | ||
|
||
type AddInputProps = { | ||
onClickSource: () => void; | ||
onClickHtml: () => void; | ||
onClickMediaplayer: () => void; | ||
disabled: boolean; | ||
}; | ||
export function AddInput({ | ||
onClickSource, | ||
onClickHtml, | ||
onClickMediaplayer, | ||
disabled | ||
}: AddInputProps) { | ||
const t = useTranslate(); | ||
return ( | ||
<div | ||
className={`bg-zinc-700 aspect-video m-2 p-2 text-p border-2 border-zinc-300 rounded flex flex-col gap-2 justify-center items-center ${ | ||
disabled ? 'opacity-10' : 'opacity-100' | ||
}`} | ||
> | ||
<button | ||
className="flex bg-button-bg p-2 rounded" | ||
onClick={() => { | ||
!disabled && onClickSource(); | ||
}} | ||
> | ||
<IconVideoPlus className="mr-2" /> | ||
<span>{t('production.add_source')}</span> | ||
</button> | ||
<button | ||
className="flex bg-button-bg p-2 rounded" | ||
onClick={() => { | ||
!disabled && onClickHtml(); | ||
}} | ||
> | ||
<IconBrowserPlus className="mr-2" /> | ||
<span>{'Add Html'}</span> | ||
</button> | ||
<button | ||
className="flex bg-button-bg p-2 rounded" | ||
onClick={() => { | ||
!disabled && onClickMediaplayer(); | ||
}} | ||
> | ||
<IconPhotoPlus className="mr-2" /> | ||
<span>{'Add Mediaplayer'}</span> | ||
</button> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters