feat: add camera feed configuration in settings

And beautify settings page
This commit is contained in:
Youwen Wu 2024-03-16 19:12:08 -07:00
parent ac89c7c966
commit 37286cce05
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
5 changed files with 41 additions and 21 deletions

View file

@ -1,15 +1,16 @@
<script lang="ts"> <script lang="ts">
import AppContainer from '../AppContainer.svelte' import AppContainer from '../AppContainer.svelte'
import CameraContainer from './CameraContainer.svelte' import CameraContainer from './CameraContainer.svelte'
import { settingsStore } from '../../stores/settingsStore'
</script> </script>
<AppContainer <AppContainer
class="px-10 py-20 flex gap-4 w-full backdrop-blur-lg justify-center h-full rounded-3xl shadow-md bg-slate-300 bg-opacity-30" class="px-10 py-20 flex gap-4 w-full backdrop-blur-lg justify-center h-full rounded-3xl shadow-md bg-slate-300 bg-opacity-30"
> >
<div class="my-auto"> <div class="my-auto">
<CameraContainer cameraUrl="camera_url_here" /> <CameraContainer cameraUrl={$settingsStore.frontCameraAddr} />
</div> </div>
<div class="my-auto"> <div class="my-auto">
<CameraContainer cameraUrl="camera_url_here" /> <CameraContainer cameraUrl={$settingsStore.rearCameraAddr} />
</div> </div>
</AppContainer> </AppContainer>

View file

@ -22,17 +22,38 @@
> >
<h1 class="text-5xl font-medium text-slate-100 basis-full">Settings</h1> <h1 class="text-5xl font-medium text-slate-100 basis-full">Settings</h1>
<p class="text-slate-300">Hover over setting names to see helpful tooltips</p> <p class="text-slate-300">Hover over setting names to see helpful tooltips</p>
<h2 class="text-2xl font-medium text-slate-200 mt-4 basis-full">General</h2>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<h2 class="text-2xl font-medium text-slate-200 mt-4 basis-full">General</h2>
<SettingsToggle <SettingsToggle
setting="disableAnnoyances" setting="disableAnnoyances"
tooltip="Disable non-critical popups and audio cues." tooltip="Disable non-critical popups and audio cues."
>Disable Annoyances</SettingsToggle >Disable Annoyances</SettingsToggle
> >
<SettingsSelector
setting="voiceLang"
options={['en-US', 'en-RU', 'en-UK']}
tooltip="Selects the language/locale used for Jankboard voice prompts. Does not affect application language (ie. Jankboard itself will always be in English)."
>Voice Prompt Language</SettingsSelector
>
<h2 class="text-2xl font-medium text-slate-200 mt-4 basis-full">
Camera Configuration
</h2>
<SettingsInput
setting="frontCameraAddr"
tooltip="Set the IP address of the front-facing camera. Input in the format xxx.xxx.xxx.xxx:PORT (eg. 244.178.44.111:8080)"
width="16rem">Front Camera IP</SettingsInput
>
<SettingsInput
setting="rearCameraAddr"
tooltip="Set the IP address of the rear-facing camera. Input in the format xxx.xxx.xxx.xxx:PORT (eg. 244.178.44.111:8080)"
width="16rem">Rear Camera IP</SettingsInput
>
<h2 class="text-2xl font-medium text-slate-200 mt-4 basis-full">Fun</h2>
<SettingsToggle <SettingsToggle
setting="goWoke" setting="sentry"
tooltip="Disables content that could be perceived as offensive for PR and DEI purposes." tooltip="Sentry mode protects the robot and operator from foreign threats (doesn't actually do anything besides add extra voice prompts)"
>Go Woke</SettingsToggle >Sentry Mode</SettingsToggle
> >
<SettingsInput <SettingsInput
setting="randomWeight" setting="randomWeight"
@ -41,16 +62,11 @@
> >
RNG Weight RNG Weight
</SettingsInput> </SettingsInput>
<SettingsSelector <h2 class="text-2xl font-medium text-slate-200 mt-4 basis-full">Secret</h2>
setting="voiceLang"
options={['en-US', 'en-RU', 'en-UK']}
tooltip="Selects the language/locale used for Jankboard voice prompts. Does not affect application language (ie. Jankboard itself will always be in English)."
>Voice Prompt Language</SettingsSelector
>
<SettingsToggle <SettingsToggle
setting="sentry" setting="goWoke"
tooltip="Sentry mode protects the robot and operator from foreign threats." tooltip="Disables content that could be perceived as offensive for PR and DEI purposes."
>Sentry Mode</SettingsToggle >Go Woke</SettingsToggle
> >
<button <button
class="mt-10 px-4 py-2 bg-amber-600 hover:brightness-75 text-medium rounded-lg w-min" class="mt-10 px-4 py-2 bg-amber-600 hover:brightness-75 text-medium rounded-lg w-min"

View file

@ -13,7 +13,6 @@
const handleSubmit = async () => { const handleSubmit = async () => {
await tick() await tick()
// @ts-expect-error
settingsStore.update(setting, value) settingsStore.update(setting, value)
} }

View file

@ -217,7 +217,7 @@ export const infotainmentBootupSequence = async () => {
} }
if (!get(sequenceStore).initializationComplete) { if (!get(sequenceStore).initializationComplete) {
const unsubscribe = sequenceStore.subscribe((data) => { const unsubscribe = sequenceStore.subscribe(data => {
if (data.initializationComplete) { if (data.initializationComplete) {
sequence() sequence()
unsubscribe() unsubscribe()
@ -237,7 +237,7 @@ export const infotainmentBootupSequence = async () => {
*/ */
const waitForInfotainmentBootup = (sequence: () => void) => { const waitForInfotainmentBootup = (sequence: () => void) => {
if (!get(sequenceStore).infotainmentStartedFirstTime) { if (!get(sequenceStore).infotainmentStartedFirstTime) {
const unsubscribe = sequenceStore.subscribe((data) => { const unsubscribe = sequenceStore.subscribe(data => {
if (data.infotainmentStartedFirstTime) { if (data.infotainmentStartedFirstTime) {
sequence() sequence()
unsubscribe() unsubscribe()

View file

@ -11,6 +11,8 @@ export interface SettingsStoreData {
randomWeight: number randomWeight: number
voiceLang: SupportedLanguage voiceLang: SupportedLanguage
sentry: boolean sentry: boolean
frontCameraAddr: string
rearCameraAddr: string
} }
export const defaults: SettingsStoreData = { export const defaults: SettingsStoreData = {
@ -18,8 +20,10 @@ export const defaults: SettingsStoreData = {
goWoke: true, // go woke (for showing parents or other officials where DEI has taken over), disables "offensive" sequences goWoke: true, // go woke (for showing parents or other officials where DEI has taken over), disables "offensive" sequences
fastStartup: false, // skip the loading splash screen (for development purposes. Setting this from within the app has no effect.) fastStartup: false, // skip the loading splash screen (for development purposes. Setting this from within the app has no effect.)
randomWeight: 1, // the weight of random events (multiplied by the original probability) randomWeight: 1, // the weight of random events (multiplied by the original probability)
voiceLang: 'en-US', // locale-specific voice for alerts voiceLang: 'en-UK', // locale-specific voice for alerts
sentry: true, // protect the robot and operator from foreign threats sentry: false, // protect the robot and operator from foreign threats
frontCameraAddr: '',
rearCameraAddr: '',
} }
const createSequenceStore = () => { const createSequenceStore = () => {
@ -30,7 +34,7 @@ const createSequenceStore = () => {
data: keyof SettingsStoreData, data: keyof SettingsStoreData,
newValue: SettingsStoreData[typeof data] newValue: SettingsStoreData[typeof data]
) => { ) => {
update((store) => { update(store => {
// @ts-expect-error // @ts-expect-error
store[data] = newValue store[data] = newValue
return store return store