Skip to content

Commit

Permalink
feat: filtering clients and hosts on timeline (#502)
Browse files Browse the repository at this point in the history
* Filtering clients and hosts on timeline

* minor default values fixes, code styling

* some code styling to pass lint
  • Loading branch information
skaparis committed Nov 19, 2023
1 parent e05e805 commit d7c70b4
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/views/Timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
div
h2 Timeline

div.d-flex.justify-content-between.align-items-end
table
tr
th.pr-2
label Host filter:
td
select(v-model="filter_hostname")
option(:value='null') *
option(v-for="host in hosts", :value="host") {{ host }}
th.pr-2
label Client filter:
td
select(v-model="filter_client")
option(:value='null') *
option(v-for="client in clients", :value="client") {{ client }}

input-timeinterval(v-model="daterange", :defaultDuration="timeintervalDefaultDuration", :maxDuration="maxDuration")

div(v-if="buckets !== null")
Expand All @@ -28,9 +44,13 @@ export default {
name: 'Timeline',
data() {
return {
all_buckets: null,
hosts: null,
buckets: null,
daterange: null,
maxDuration: 31 * 24 * 60 * 60,
filter_hostname: null,
filter_client: null,
};
},
computed: {
Expand All @@ -46,16 +66,39 @@ export default {
daterange() {
this.getBuckets();
},
filter_hostname() {
this.getBuckets();
},
filter_client() {
this.getBuckets();
},
},
methods: {
getBuckets: async function () {
if (this.daterange == null) return;
this.buckets = Object.freeze(
this.all_buckets = Object.freeze(
await useBucketsStore().getBucketsWithEvents({
start: this.daterange[0].format(),
end: this.daterange[1].format(),
})
);
this.hosts = this.all_buckets
.map(a => a.hostname)
.filter((value, index, array) => array.indexOf(value) === index);
this.clients = this.all_buckets
.map(a => a.client)
.filter((value, index, array) => array.indexOf(value) === index);
this.buckets = this.all_buckets;
this.buckets = _.filter(
this.buckets,
b => this.filter_hostname == null || b.hostname == this.filter_hostname
);
this.buckets = _.filter(
this.buckets,
b => this.filter_client == null || b.client == this.filter_client
);
},
},
};
Expand Down

1 comment on commit d7c70b4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are screenshots of this commit:

Screenshots using aw-server v0.12.3b11 (click to expand)

Screenshots using aw-server-rust master (click to expand)

Screenshots using aw-server-rust v0.12.3b11 (click to expand)

Please sign in to comment.