scouting: Deduplicate action definitions in entry.component.ts
I found it tedious to keep the definitions up-to-date between the .fbs
file and the entry.component.ts file. This patch fixes the issue by
using the generated flatbuffer types everywhere.
I added a helper library to deal with `actionTakenType` properly.
Otherwise the user would have to deal with it manually.
Since Angular templates don't seem to allow manual type casting, I
created a pipe to do it for me.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I5f60e2d7b89978f40b5758bb8d04e800d6de230d
diff --git a/scouting/www/entry/BUILD b/scouting/www/entry/BUILD
index 6bffbf8..24da904 100644
--- a/scouting/www/entry/BUILD
+++ b/scouting/www/entry/BUILD
@@ -1,11 +1,13 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//tools/build_rules:js.bzl", "ng_pkg")
+load("//tools/build_rules:template.bzl", "jinja2_template")
npm_link_all_packages(name = "node_modules")
ng_pkg(
name = "entry",
extra_srcs = [
+ ":action_helper.ts",
"//scouting/www:app_common_css",
],
deps = [
@@ -13,3 +15,24 @@
"//:node_modules/flatbuffers",
],
)
+
+jinja2_template(
+ name = "action_helper.ts",
+ src = "action_helper.jinja2.ts",
+ list_parameters = {
+ # Is there a way to auto-generate the list of actions here? Would be
+ # nice not to have a duplicate list here when they're already known in
+ # the .fbs file.
+ "ACTIONS": [
+ "EndMatchAction",
+ "MobilityAction",
+ "PenaltyAction",
+ "PickupNoteAction",
+ "PlaceNoteAction",
+ "RobotDeathAction",
+ "StartMatchAction",
+ "EndAutoPhaseAction",
+ "EndTeleopPhaseAction",
+ ],
+ },
+)