-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
258 additions
and
61 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,50 @@ | ||
import { type Ref, ref, watch } from 'vue' | ||
import { useFetch, useTimeoutPoll } from '@vueuse/core' | ||
import type { ServoCurrentHeatInfoConfig } from './stream-pools' | ||
|
||
export interface ServoHeatPoolInfo { | ||
PROGRAM: 'ON' | '' | ||
Station: number | ||
HeatNumber: string | ||
Event: string | ||
Team: string | ||
TeamCountryCode: string | ||
TeamCountryName: string | ||
TeamCountryFlagUrl: string | ||
[nameKey: `Part${number}`]: string | ||
[lastNameKey: `Part${number}_Last`]: string | ||
} | ||
|
||
export function useHeatInfo (settings: Ref<ServoCurrentHeatInfoConfig | undefined>) { | ||
const servoPollUrl = ref<string>('') | ||
|
||
const servoCurrentHeatFetch = useFetch(servoPollUrl, { | ||
headers: { | ||
accept: 'application/json' | ||
} | ||
}, { | ||
immediate: false | ||
}).get().json<ServoHeatPoolInfo[]>() | ||
|
||
const servoPoll = useTimeoutPoll(() => { | ||
servoCurrentHeatFetch.execute() | ||
}, 10_000, { immediate: false }) | ||
|
||
watch(() => settings.value, heatInfoConfig => { | ||
// start by just disabling all polling | ||
servoPoll.pause() | ||
|
||
if (heatInfoConfig?.system === 'servo' && heatInfoConfig.competitionId != null) { | ||
let url | ||
try { | ||
url = new URL(`/api/v1/competitions/${heatInfoConfig.competitionId}/info/current`, heatInfoConfig.baseUrl as string) | ||
} catch { | ||
return | ||
} | ||
servoPollUrl.value = url.href | ||
servoPoll.resume() | ||
} | ||
}, { immediate: true }) | ||
|
||
return servoCurrentHeatFetch | ||
} |
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,13 @@ | ||
import { useLocalStorage } from '@vueuse/core' | ||
import type { ServoCurrentHeatInfoConfig } from './stream-pools' | ||
|
||
export interface OnFloorWallSettings { | ||
heatInfo?: ServoCurrentHeatInfoConfig | ||
background?: string | ||
} | ||
|
||
const settings = useLocalStorage<OnFloorWallSettings>('rs-on-floor-wall-settings', {}) | ||
|
||
export function useOnFloorWallSettings () { | ||
return settings | ||
} |
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
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,76 @@ | ||
<template> | ||
<div class="mb-4 mx-auto container flex justify-between"> | ||
<div /> | ||
<button-link | ||
:to="`/on-floor-wall/${settings.heatInfo?.system}/${settings.heatInfo?.competitionId}?theme=${theme}`" | ||
:disabled="settings.heatInfo?.system == null || settings.heatInfo?.competitionId == null" | ||
> | ||
Display | ||
</button-link> | ||
</div> | ||
<section class="container mx-auto"> | ||
<h2 class="text-xl"> | ||
Heat Info | ||
</h2> | ||
<div> | ||
<select-field | ||
:model-value="settings.heatInfo?.system" | ||
label="Heat Info System" | ||
:data-list="['servo']" | ||
@update:model-value="setCurrentHeatInfoSystem($event as string)" | ||
/> | ||
<text-field | ||
v-if="settings.heatInfo?.system === 'servo'" | ||
v-model="settings.heatInfo.baseUrl" | ||
label="Servo Scoring Base URL" | ||
type="url" | ||
/> | ||
<number-field | ||
v-if="settings.heatInfo?.system === 'servo'" | ||
v-model="settings.heatInfo.competitionId" | ||
label="Servo Scoring Competition ID" | ||
:min="0" | ||
:step="1" | ||
/> | ||
</div> | ||
</section> | ||
<section class="mx-auto container flex justify-center mt-8"> | ||
<div> | ||
<photo-picker | ||
v-model="settings.background" | ||
label="Background image" | ||
/> | ||
</div> | ||
</section> | ||
</template> | ||
<script lang="ts" setup> | ||
import countries from '../assets/countries.json' | ||
import { SelectField, NumberField, TextField, ButtonLink } from '@ropescore/components' | ||
import { useHead } from '@vueuse/head' | ||
import PhotoPicker from '../components/PhotoPicker.vue' | ||
import { useTheme } from '../hooks/theme' | ||
import { useOnFloorWallSettings } from '../hooks/on-floor-wall' | ||
useHead({ | ||
title: 'On Floor Wall' | ||
}) | ||
const theme = useTheme() | ||
const settings = useOnFloorWallSettings() | ||
const countriesList = countries.map(c => ({ text: c.name, value: c.code })) | ||
function setCurrentHeatInfoSystem (system: string | undefined) { | ||
if (system === 'servo' && settings.value.heatInfo?.system !== 'servo') { | ||
settings.value.heatInfo = { | ||
system: 'servo', | ||
baseUrl: 'https://scoring.ijru.sport' | ||
} | ||
} else { | ||
settings.value.heatInfo = undefined | ||
} | ||
} | ||
</script> |
Oops, something went wrong.