From 37e814580acdd5c284625d05a181494cbc0cc466 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 1 Apr 2021 00:39:28 -0400 Subject: [PATCH] Allow filtering events by a tool name in query string param --- src/App.vue | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index 17ad9f9..0e8857c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -64,9 +64,14 @@ export default class App extends Vue { }, }; + toolFilter: string | null = null; + created() { // refresh data every five minutes window.setInterval(this.refresh, 5 * 60 * 1000); + + const urlParams = new URLSearchParams(window.location.search); + this.toolFilter = urlParams.get('tool'); } refresh() { @@ -79,12 +84,16 @@ export default class App extends Vue { }); } - eventDataTransform(eventData: EventInput): EventInput { - const match = eventData.title.match(/([^\/]*) \/ ([^-]*) - (.*)/); + eventDataTransform(eventData: EventInput): EventInput | false { + const match = eventData.title.match(/([^\/]*) \| ([^-]*) - (.*)/); if (match !== null) { - eventData.title = match[3]; + const [, member, shop, tool] = match; + eventData.title = member; + if (this.toolFilter === null || tool.includes(this.toolFilter)) { + return eventData; + } } - return eventData; + return false; } }