Skip to content

Commit d7c70b4

Browse files
authored
feat: filtering clients and hosts on timeline (#502)
* Filtering clients and hosts on timeline * minor default values fixes, code styling * some code styling to pass lint
1 parent e05e805 commit d7c70b4

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/views/Timeline.vue

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
div
33
h2 Timeline
44

5+
div.d-flex.justify-content-between.align-items-end
6+
table
7+
tr
8+
th.pr-2
9+
label Host filter:
10+
td
11+
select(v-model="filter_hostname")
12+
option(:value='null') *
13+
option(v-for="host in hosts", :value="host") {{ host }}
14+
th.pr-2
15+
label Client filter:
16+
td
17+
select(v-model="filter_client")
18+
option(:value='null') *
19+
option(v-for="client in clients", :value="client") {{ client }}
20+
521
input-timeinterval(v-model="daterange", :defaultDuration="timeintervalDefaultDuration", :maxDuration="maxDuration")
622

723
div(v-if="buckets !== null")
@@ -28,9 +44,13 @@ export default {
2844
name: 'Timeline',
2945
data() {
3046
return {
47+
all_buckets: null,
48+
hosts: null,
3149
buckets: null,
3250
daterange: null,
3351
maxDuration: 31 * 24 * 60 * 60,
52+
filter_hostname: null,
53+
filter_client: null,
3454
};
3555
},
3656
computed: {
@@ -46,16 +66,39 @@ export default {
4666
daterange() {
4767
this.getBuckets();
4868
},
69+
filter_hostname() {
70+
this.getBuckets();
71+
},
72+
filter_client() {
73+
this.getBuckets();
74+
},
4975
},
5076
methods: {
5177
getBuckets: async function () {
5278
if (this.daterange == null) return;
53-
this.buckets = Object.freeze(
79+
80+
this.all_buckets = Object.freeze(
5481
await useBucketsStore().getBucketsWithEvents({
5582
start: this.daterange[0].format(),
5683
end: this.daterange[1].format(),
5784
})
5885
);
86+
87+
this.hosts = this.all_buckets
88+
.map(a => a.hostname)
89+
.filter((value, index, array) => array.indexOf(value) === index);
90+
this.clients = this.all_buckets
91+
.map(a => a.client)
92+
.filter((value, index, array) => array.indexOf(value) === index);
93+
this.buckets = this.all_buckets;
94+
this.buckets = _.filter(
95+
this.buckets,
96+
b => this.filter_hostname == null || b.hostname == this.filter_hostname
97+
);
98+
this.buckets = _.filter(
99+
this.buckets,
100+
b => this.filter_client == null || b.client == this.filter_client
101+
);
59102
},
60103
},
61104
};

0 commit comments

Comments
 (0)