Skip to content

Commit edf9fba

Browse files
committed
Make online status indicator blue/yellow depending on connected team
1 parent 4e6dd24 commit edf9fba

File tree

10 files changed

+497
-547
lines changed

10 files changed

+497
-547
lines changed

frontend/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/components/StatusBar.vue

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
<script setup lang="ts">
22
import {ApiController} from '../services/ApiController';
3-
import {inject, ref} from 'vue';
3+
import {computed, inject, ref} from 'vue';
4+
import {Team} from "../proto/ssl_gc_common";
45
56
const defaultYellowCardsDue: number[] = []
67
const online = ref(false)
8+
const team = ref(Team.UNKNOWN)
79
const maxRobots = ref(0)
810
const numRobots = ref(0)
911
const yellowCardsDue = ref(defaultYellowCardsDue)
1012
const api = inject<ApiController>('api')
1113
let onlineTimer: NodeJS.Timeout
14+
const onlineStateColor = computed(() => {
15+
if (!online.value) {
16+
return '#ff0000'
17+
} else if (team.value === Team.BLUE) {
18+
return '#4f84f1'
19+
} else if (team.value === Team.YELLOW) {
20+
return '#f7f422'
21+
}
22+
return '#42b983'
23+
})
1224
1325
api?.RegisterStateConsumer((s) => {
1426
online.value = true
27+
team.value = s.team || Team.UNKNOWN
1528
maxRobots.value = s.maxRobots
1629
numRobots.value = s.robotsOnField
1730
yellowCardsDue.value = s.yellowCardsDue.sort((a: number, b: number) => a - b)
@@ -27,7 +40,7 @@ online.value = false
2740
</script>
2841

2942
<template>
30-
<div class="online-state" :class="{online: online, offline: !online}"/>
43+
<div class="online-state" :style="{'background-color': onlineStateColor}"/>
3144

3245
<div class="left-bar">
3346
<div class="left-bar-element">
@@ -64,12 +77,4 @@ online.value = false
6477
right: 0.5em;
6578
top: 0.5em;
6679
}
67-
68-
.online-state.online {
69-
background-color: #42b983;
70-
}
71-
72-
.online-state.offline {
73-
background-color: red;
74-
}
7580
</style>

frontend/src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import App from './App.vue'
33
import router from './router';
44
import {ApiController} from './services/ApiController';
55
import {RemoteControlRequestType, RemoteControlTeamState} from './proto/ssl_gc_rcon_remotecontrol';
6+
import {Team} from "./proto/ssl_gc_common";
67

78
let latestState: RemoteControlTeamState
89
if (import.meta.env.PROD) {
910
latestState = {
11+
team: Team.UNKNOWN,
1012
availableRequests: [],
1113
activeRequests: [],
1214
yellowCardsDue: [],
@@ -21,6 +23,7 @@ if (import.meta.env.PROD) {
2123
}
2224
} else {
2325
latestState = {
26+
team: Team.BLUE,
2427
availableRequests: [
2528
RemoteControlRequestType.CHANGE_KEEPER_ID,
2629
RemoteControlRequestType.CHALLENGE_FLAG,

frontend/src/proto/ssl_gc_common.ts

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable */
2-
import Long from "long";
3-
import * as _m0 from "protobufjs/minimal";
2+
import _m0 from "protobufjs/minimal";
43

54
export const protobufPackage = "";
65

@@ -100,10 +99,7 @@ function createBaseRobotId(): RobotId {
10099
}
101100

102101
export const RobotId = {
103-
encode(
104-
message: RobotId,
105-
writer: _m0.Writer = _m0.Writer.create()
106-
): _m0.Writer {
102+
encode(message: RobotId, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
107103
if (message.id !== 0) {
108104
writer.uint32(8).uint32(message.id);
109105
}
@@ -114,31 +110,37 @@ export const RobotId = {
114110
},
115111

116112
decode(input: _m0.Reader | Uint8Array, length?: number): RobotId {
117-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
113+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
118114
let end = length === undefined ? reader.len : reader.pos + length;
119115
const message = createBaseRobotId();
120116
while (reader.pos < end) {
121117
const tag = reader.uint32();
122118
switch (tag >>> 3) {
123119
case 1:
120+
if (tag != 8) {
121+
break;
122+
}
123+
124124
message.id = reader.uint32();
125-
break;
125+
continue;
126126
case 2:
127+
if (tag != 16) {
128+
break;
129+
}
130+
127131
message.team = reader.int32() as any;
128-
break;
129-
default:
130-
reader.skipType(tag & 7);
131-
break;
132+
continue;
132133
}
134+
if ((tag & 7) == 4 || tag == 0) {
135+
break;
136+
}
137+
reader.skipType(tag & 7);
133138
}
134139
return message;
135140
},
136141

137142
fromJSON(object: any): RobotId {
138-
return {
139-
id: isSet(object.id) ? Number(object.id) : 0,
140-
team: isSet(object.team) ? teamFromJSON(object.team) : 0,
141-
};
143+
return { id: isSet(object.id) ? Number(object.id) : 0, team: isSet(object.team) ? teamFromJSON(object.team) : 0 };
142144
},
143145

144146
toJSON(message: RobotId): unknown {
@@ -148,6 +150,10 @@ export const RobotId = {
148150
return obj;
149151
},
150152

153+
create<I extends Exact<DeepPartial<RobotId>, I>>(base?: I): RobotId {
154+
return RobotId.fromPartial(base ?? {});
155+
},
156+
151157
fromPartial<I extends Exact<DeepPartial<RobotId>, I>>(object: I): RobotId {
152158
const message = createBaseRobotId();
153159
message.id = object.id ?? 0;
@@ -156,41 +162,17 @@ export const RobotId = {
156162
},
157163
};
158164

159-
type Builtin =
160-
| Date
161-
| Function
162-
| Uint8Array
163-
| string
164-
| number
165-
| boolean
166-
| undefined;
167-
168-
export type DeepPartial<T> = T extends Builtin
169-
? T
170-
: T extends Array<infer U>
171-
? Array<DeepPartial<U>>
172-
: T extends ReadonlyArray<infer U>
173-
? ReadonlyArray<DeepPartial<U>>
174-
: T extends { $case: string }
175-
? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & {
176-
$case: T["$case"];
177-
}
178-
: T extends {}
179-
? { [K in keyof T]?: DeepPartial<T[K]> }
165+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
166+
167+
export type DeepPartial<T> = T extends Builtin ? T
168+
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
169+
: T extends { $case: string } ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { $case: T["$case"] }
170+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
180171
: Partial<T>;
181172

182173
type KeysOfUnion<T> = T extends T ? keyof T : never;
183-
export type Exact<P, I extends P> = P extends Builtin
184-
? P
185-
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
186-
Exclude<keyof I, KeysOfUnion<P>>,
187-
never
188-
>;
189-
190-
if (_m0.util.Long !== Long) {
191-
_m0.util.Long = Long as any;
192-
_m0.configure();
193-
}
174+
export type Exact<P, I extends P> = P extends Builtin ? P
175+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
194176

195177
function isSet(value: any): boolean {
196178
return value !== null && value !== undefined;

0 commit comments

Comments
 (0)