Skip to content

Commit 292d428

Browse files
committed
Refactor frontend code to use newly generated protobuf code
1 parent 671c293 commit 292d428

File tree

107 files changed

+1033
-6409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1033
-6409
lines changed

frontend/package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
1313
},
1414
"dependencies": {
15+
"@bufbuild/protobuf": "^2.2.3",
1516
"@quasar/extras": "^1.16.15",
1617
"dayjs": "^1.11.13",
1718
"format-duration": "^3.0.2",

frontend/src/components/ExternalConnectionStatus.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import {useGcStateStore} from "@/store/gcState";
55
const store = useGcStateStore()
66
77
const numTrackerSource = computed(() => {
8+
if (store.gcState.trackers === undefined) {
9+
return 0
10+
}
811
return Object.keys(store.gcState.trackers!).length
912
})
1013
const numAutoRefs = computed(() => {
14+
if (store.gcState.autoRefState === undefined) {
15+
return 0
16+
}
1117
return Object.keys(store.gcState.autoRefState!).length
1218
})
1319
const warn = computed(() => {

frontend/src/components/MatchStateToolbar.vue

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import TeamBadge from "@/components/common/TeamBadge.vue";
44
import {useMatchStateStore} from "@/store/matchState";
55
import formatDuration from "format-duration";
66
import {stageName} from "@/helpers/texts";
7-
import {Team} from "@/proto/ssl_gc_common";
7+
import type {TeamJson} from "@/proto/state/ssl_gc_common_pb";
8+
import {durationSeconds, formatDurationJson, timestampJsonMs} from "@/helpers";
89
910
const store = useMatchStateStore()
1011
const now = ref(Date.now())
@@ -13,14 +14,14 @@ setInterval(() => {
1314
}, 1000)
1415
1516
const matchDuration = computed(() => {
16-
if (store.matchState.matchTimeStart && store.matchState.matchTimeStart.getTime() > 0) {
17-
return formatDuration(now.value - store.matchState.matchTimeStart.getTime())
17+
if (store.matchState.matchTimeStart && timestampJsonMs(store.matchState.matchTimeStart) > 0) {
18+
return formatDuration(now.value - timestampJsonMs(store.matchState.matchTimeStart!))
1819
}
1920
return "-"
2021
})
2122
const stageTimeLeft = computed(() => {
2223
if (store.matchState.stageTimeLeft) {
23-
return formatDuration(store.matchState.stageTimeLeft.seconds * 1000)
24+
return formatDurationJson(store.matchState.stageTimeLeft)
2425
}
2526
return "-"
2627
})
@@ -32,12 +33,12 @@ const gameState = computed(() => {
3233
})
3334
const currentActionTime = computed(() => {
3435
if (store.matchState.currentActionTimeRemaining
35-
&& store.matchState.currentActionTimeRemaining.seconds > 0) {
36-
return formatDuration(store.matchState.currentActionTimeRemaining.seconds * 1000)
36+
&& durationSeconds(store.matchState.currentActionTimeRemaining) > 0) {
37+
return formatDurationJson(store.matchState.currentActionTimeRemaining)
3738
}
3839
return undefined
3940
})
40-
const goals = (team: Team) => {
41+
const goals = (team: TeamJson) => {
4142
return store.matchState.teamState![team].goals!
4243
}
4344
const statusMessage = computed(() => {
@@ -64,9 +65,9 @@ const statusMessage = computed(() => {
6465
</div>
6566
<div class="col-grow">
6667
Score:
67-
<TeamBadge :team="Team.YELLOW"/>
68-
{{ goals(Team.YELLOW) }} : {{ goals(Team.BLUE) }}
69-
<TeamBadge :team="Team.BLUE"/>
68+
<TeamBadge :team="'YELLOW'"/>
69+
{{ goals('YELLOW') }} : {{ goals('BLUE') }}
70+
<TeamBadge :team="'BLUE'"/>
7071
</div>
7172
<div class="col-grow">
7273
Matching duration: <strong>{{ matchDuration }}</strong>

frontend/src/components/common/NumberInput.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
<script setup lang="ts">
22
3-
import {inject} from "vue";
3+
import {computed, inject} from "vue";
44
import type {Shortcuts} from "@/providers/shortcuts";
55
6-
defineProps<{
7-
modelValue?: number,
6+
const props = defineProps<{
7+
modelValue?: number | bigint | "NaN" | "Infinity" | "-Infinity",
88
label?: string,
99
}>()
1010
11-
const emit = defineEmits<{
12-
(event: 'update:modelValue', payload: number | undefined): void;
13-
}>();
11+
const emit = defineEmits<(event: 'update:modelValue', payload: number | undefined) => void>();
1412
1513
const shortcuts = inject<Shortcuts>('shortcuts')!
1614
const onFocusin = () => shortcuts.disable()
1715
const onFocusout = () => shortcuts.enable()
1816
17+
const modelValueSanitised = computed(() => {
18+
if (props.modelValue === undefined) {
19+
return ''
20+
} else {
21+
return props.modelValue.toString()
22+
}
23+
})
24+
1925
const updateValue = (value: string | number | null) => {
2026
if (value !== null) {
2127
if (typeof value === 'string') {
@@ -35,7 +41,7 @@ const updateValue = (value: string | number | null) => {
3541
dense
3642
:label="label"
3743
type="number"
38-
:model-value="modelValue"
44+
:model-value="modelValueSanitised"
3945
@update:model-value="updateValue"
4046
@focusin="onFocusin"
4147
@focusout="onFocusout"

frontend/src/components/common/OriginIcon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const props = defineProps<{
1515
:name="originIcon(origin)"
1616
:alt="origin"
1717
>
18-
<q-tooltip v-if="props.tooltip === true">
18+
<q-tooltip v-if="props.tooltip">
1919
{{ origin }}
2020
</q-tooltip>
2121
</q-icon>

frontend/src/components/common/TeamBadge.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
<script setup lang="ts">
22
import {computed} from "vue";
3-
import {Team} from "@/proto/ssl_gc_common";
3+
import {type TeamJson} from "@/proto/state/ssl_gc_common_pb";
44
55
const props = defineProps<{
6-
team?: Team,
6+
team?: TeamJson,
77
floating?: boolean,
88
}>()
99
1010
const color = computed(() => {
1111
switch (props.team) {
12-
case Team.YELLOW:
12+
case 'YELLOW':
1313
return "team-yellow"
14-
case Team.BLUE:
14+
case 'BLUE':
1515
return "team-blue"
1616
default:
1717
return ""
1818
}
1919
})
2020
const label = computed(() => {
2121
switch (props.team) {
22-
case Team.YELLOW:
22+
case 'YELLOW':
2323
return "Yellow"
24-
case Team.BLUE:
24+
case 'BLUE':
2525
return "Blue"
2626
default:
2727
return ""
2828
}
2929
})
3030
const shown = computed(() => {
31-
return props.team === Team.YELLOW || props.team === Team.BLUE
31+
return props.team === 'YELLOW' || props.team === 'BLUE'
3232
})
3333
</script>
3434

frontend/src/components/common/TeamInput.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
<script setup lang="ts">
22
import {teamOptions} from "@/helpers";
3-
import type {Team} from "@/proto/ssl_gc_common";
3+
import type {TeamJson} from "@/proto/state/ssl_gc_common_pb";
44
55
defineProps<{
6-
modelValue?: Team,
6+
modelValue?: TeamJson,
77
}>()
88
9-
const emit = defineEmits<{
10-
(event: 'update:modelValue', payload: Team): void;
11-
}>();
9+
const emit = defineEmits<(event: 'update:modelValue', payload: TeamJson) => void>();
1210
13-
const updateValue = (v: Team) => {
11+
const updateValue = (v: TeamJson) => {
1412
emit('update:modelValue', v)
1513
}
1614

frontend/src/components/common/TextInput.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ defineProps<{
99
clearable?: boolean,
1010
}>()
1111
12-
const emit = defineEmits<{
13-
(event: 'update:modelValue', payload: string | undefined): void;
14-
}>();
12+
const emit = defineEmits<(event: 'update:modelValue', payload: string | undefined) => void>();
1513
1614
const shortcuts = inject<Shortcuts>('shortcuts')!
1715
const onFocusin = () => shortcuts.disable()

frontend/src/components/control/CommandButton.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import TeamBadge from "@/components/common/TeamBadge.vue";
33
import type {ManualActions} from "@/providers/manualActions";
44
import {computed, inject} from "vue";
5-
import type {Command_Type} from "@/proto/ssl_gc_state";
6-
import type {Team} from "@/proto/ssl_gc_common";
5+
import type {Command_TypeJson} from "@/proto/state/ssl_gc_state_pb";
6+
import type {TeamJson} from "@/proto/state/ssl_gc_common_pb";
77
import {useUiStateStore} from "@/store/uiState";
88
99
const props = defineProps<{
10-
type: Command_Type,
11-
team?: Team,
10+
type: Command_TypeJson,
11+
team?: TeamJson,
1212
}>()
1313
1414
const manualActions = inject<ManualActions>('command-actions')!

0 commit comments

Comments
 (0)