Allow filtering events by a tool name in query string param

This commit is contained in:
Adam Goldsmith 2021-04-01 00:39:28 -04:00
parent 542f5d8bf1
commit 37e814580a

View File

@ -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,13 +84,17 @@ 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 false;
}
}
</script>