Skip to content

Commit 613b51e

Browse files
committed
refactor: refactored event viewer (in Query/Search views) into component, changed use of (broken) aw-timeline to vis-timeline
1 parent f6389ee commit 613b51e

File tree

5 files changed

+59
-58
lines changed

5 files changed

+59
-58
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template lang="pug">
2+
div
3+
div.form-group
4+
select.form-control(v-model="vis_method")
5+
option(value="eventlist") Event List
6+
option(value="timeline") Timeline
7+
option(value="summary") Summary
8+
option(value="raw") Raw JSON
9+
10+
div(v-if="vis_method == 'timeline'")
11+
vis-timeline(:buckets="[{'type': 'search', 'events': events}]")
12+
div(v-if="vis_method == 'eventlist'")
13+
aw-eventlist(:events="events")
14+
div(v-if="vis_method == 'summary'")
15+
input.form-control(type="text" v-model.lazy.trim="summaryKey" placeholder="data key" style="margin-bottom: 1em;")
16+
aw-summary(:fields="events", :colorfunc="colorfunc", :namefunc="namefunc")
17+
div(v-if="vis_method == 'raw'")
18+
pre {{ events }}
19+
</template>
20+
21+
<script>
22+
export default {
23+
name: 'aw-selectable-eventview',
24+
props: {
25+
events: Array,
26+
event_type: { type: String, default: 'currentwindow' },
27+
},
28+
data: function () {
29+
return {
30+
vis_method: 'eventlist',
31+
32+
/* Summary props */
33+
summaryKey: 'title',
34+
colorfunc: null,
35+
namefunc: null,
36+
};
37+
},
38+
mounted: async function () {
39+
this.colorfunc = this.summaryKeyFunc;
40+
this.namefunc = this.summaryKeyFunc;
41+
},
42+
methods: {
43+
summaryKeyFunc: function (e) {
44+
return e.data[this.summaryKey];
45+
},
46+
},
47+
};
48+
</script>

src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Vue.component('input-timeinterval', () => import('./components/InputTimeInterval
4444
Vue.component('aw-header', () => import('./components/Header.vue'));
4545
Vue.component('aw-devonly', () => import('./components/DevOnly.vue'));
4646
Vue.component('aw-selectable-vis', () => import('./components/SelectableVisualization.vue'));
47+
Vue.component('aw-selectable-eventview', () => import('./components/SelectableEventView.vue'));
4748
Vue.component('new-release-notification', () => import('./components/NewReleaseNotification.vue'));
4849
Vue.component('user-satisfaction-poll', () => import('./components/UserSatisfactionPoll.vue'));
4950

src/views/QueryExplorer.vue

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,7 @@ div
2929

3030
hr
3131

32-
div.form-group
33-
select.form-control(v-model="vis_method")
34-
option(value="eventlist") Event List
35-
option(value="timeline") Timeline
36-
option(value="summary") Summary
37-
option(value="raw") Raw JSON
38-
39-
div(v-if="vis_method == 'timeline'")
40-
aw-timeline(type="simple", :event_type="event_type", :events="events")
41-
div(v-if="vis_method == 'eventlist'")
42-
aw-eventlist(:events="events")
43-
div(v-if="vis_method == 'summary'")
44-
input.form-control(type="text" v-model.lazy.trim="summaryKey" placeholder="data key" style="margin-bottom: 1em;")
45-
aw-summary(:fields="events", :colorfunc="colorfunc", :namefunc="namefunc")
46-
div(v-if="vis_method == 'raw'")
47-
pre {{ events }}
48-
32+
aw-selectable-eventview(:events="events", :event_type="event_type")
4933
</template>
5034

5135
<style scoped lang="scss"></style>
@@ -65,19 +49,13 @@ window_events = query_bucket(find_bucket("aw-watcher-window_"));
6549
window_events = filter_period_intersect(window_events, filter_keyvals(afk_events, "status", ["not-afk"]));
6650
merged_events = merge_events_by_keys(window_events, ["app", "title"]);
6751
RETURN = sort_by_duration(merged_events);`,
68-
vis_method: 'eventlist',
6952
event_type: 'currentwindow',
7053
events: [],
7154
today: today.format(),
7255
tomorrow: tomorrow.format(),
7356
error: '',
7457
startdate: today.format('YYYY-MM-DD'),
7558
enddate: tomorrow.format('YYYY-MM-DD'),
76-
77-
/* Summary props */
78-
summaryKey: '',
79-
colorfunc: null,
80-
namefunc: null,
8159
};
8260
},
8361
computed: {
@@ -86,10 +64,6 @@ RETURN = sort_by_duration(merged_events);`,
8664
else return '';
8765
},
8866
},
89-
mounted: function () {
90-
this.colorfunc = this.summaryKeyFunc;
91-
this.namefunc = this.summaryKeyFunc;
92-
},
9367
methods: {
9468
query: async function () {
9569
const query = this.query_code.split(';').map(s => s.trim() + ';');
@@ -102,9 +76,6 @@ RETURN = sort_by_duration(merged_events);`,
10276
this.error = e.response.data.message;
10377
}
10478
},
105-
summaryKeyFunc: function (e) {
106-
return e.data[this.summaryKey];
107-
},
10879
},
10980
};
11081
</script>

src/views/Search.vue

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,7 @@ div
5353
div(v-if="events != null")
5454
hr
5555

56-
div.form-group
57-
select.form-control(v-model="vis_method")
58-
option(value="eventlist") Event List
59-
option(value="timeline") Timeline
60-
option(value="summary") Summary
61-
option(value="raw") Raw JSON
62-
63-
div(v-if="vis_method == 'timeline'")
64-
aw-timeline(type="simple", :event_type="event_type", :events="events")
65-
div(v-if="vis_method == 'eventlist'")
66-
aw-eventlist(:events="events")
67-
div(v-if="vis_method == 'summary'")
68-
input.form-control(type="text" v-model.lazy.trim="summaryKey" placeholder="data key" style="margin-bottom: 1em;")
69-
aw-summary(:fields="events", :colorfunc="colorfunc", :namefunc="namefunc")
70-
div(v-if="vis_method == 'raw'")
71-
pre {{ events }}
56+
aw-selectable-eventview(:events="events")
7257

7358
div
7459
| Didn't find what you were looking for?
@@ -107,16 +92,9 @@ export default {
10792
filter_afk: true,
10893
start: moment().subtract(1, 'day'),
10994
stop: moment().add(1, 'day'),
110-
111-
/* Summary props */
112-
summaryKey: 'title',
113-
colorfunc: null,
114-
namefunc: null,
11595
};
11696
},
11797
mounted: async function () {
118-
this.colorfunc = this.summaryKeyFunc;
119-
this.namefunc = this.summaryKeyFunc;
12098
await this.$store.dispatch('buckets/ensureBuckets');
12199
this.hostname = Object.keys(this.$store.getters['buckets/bucketsByHostname'])[0];
122100
},
@@ -145,9 +123,6 @@ export default {
145123
this.status = null;
146124
}
147125
},
148-
summaryKeyFunc: function (e) {
149-
return e.data[this.summaryKey];
150-
},
151126
},
152127
};
153128
</script>

src/visualizations/EventList.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ div
44
span(slot="header")
55
h4.card-title Events
66
span.pagination-header
7-
| Showing {{ events.length }} events
7+
| Showing {{ displayed_events.length }} events #[span(v-if="events.length > displayed_events.length") (out of {{ events.length }})]
88
b-button(@click="expandList", size="sm", style="float: right;")
99
span(v-if="!isListExpanded")
1010
| Expand list
1111
span(v-else)
1212
| Condense list
1313

1414
ul.event-list(:class="{ 'expand': isListExpanded }")
15-
li(v-for="event in events")
15+
li(v-for="event in displayed_events")
1616
span.event
1717
span.field(:title="event.timestamp")
1818
icon(name="calendar")
@@ -136,8 +136,14 @@ export default {
136136
data: function () {
137137
return {
138138
isListExpanded: false,
139+
limit: 100,
139140
};
140141
},
142+
computed: {
143+
displayed_events: function () {
144+
return this.events.slice(0, this.limit);
145+
},
146+
},
141147
methods: {
142148
expandList: function () {
143149
this.isListExpanded = !this.isListExpanded;

0 commit comments

Comments
 (0)