Skip to content

Commit

Permalink
Add loading indicator for event table
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsusek committed Dec 5, 2018
1 parent bbd6587 commit cc9ba3b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
2 changes: 2 additions & 0 deletions config/elastalert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ writeback_index: praeco_elastalert_status
# sending the alert until this time period has elapsed
alert_time_limit:
days: 2

skip_invalid: True
43 changes: 31 additions & 12 deletions src/components/EventTable.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div v-show="loadedEvents.length" class="event-table">
<div class="event-table">
<el-table
v-loading="eventsLoading && !loadedEvents.length"
ref="table"
:data="loadedEvents"
:border="true"
Expand Down Expand Up @@ -107,7 +108,9 @@ export default {
visibleColumns() {
if (this.loadedEvents.length) {
return Object.keys(this.loadedEvents[0]).sort().filter(col => !this.hidden.includes(col));
return Object.keys(this.loadedEvents[0])
.sort()
.filter(col => !this.hidden.includes(col));
}
return [];
},
Expand Down Expand Up @@ -171,16 +174,25 @@ export default {
},
saveColumns() {
localStorage.setItem('hiddenEventTableColumns', JSON.stringify(this.hidden));
localStorage.setItem(
'hiddenEventTableColumns',
JSON.stringify(this.hidden)
);
},
saveColumnWidths(newWidth, oldWidth, column) {
this.widths[column.property] = newWidth;
localStorage.setItem('eventTableColumnWidths', JSON.stringify(this.widths));
localStorage.setItem(
'eventTableColumnWidths',
JSON.stringify(this.widths)
);
},
loadMore() {
if (!this.eventsLoading && (this.totalEvents === 0 || this.loadedEvents.length < this.totalEvents)) {
if (
!this.eventsLoading &&
(this.totalEvents === 0 || this.loadedEvents.length < this.totalEvents)
) {
this.fetchEvents();
}
},
Expand All @@ -200,7 +212,9 @@ export default {
must: [
{
query_string: {
query: this.$store.getters['config/query/queryString'] || `${this.timeField}:*`
query:
this.$store.getters['config/query/queryString'] ||
`${this.timeField}:*`
}
}
]
Expand Down Expand Up @@ -251,7 +265,8 @@ export default {
this.source = CancelToken.source();
res = await axios.post(
`/api/search/${this.$store.state.config.settings.index}`,
query, { cancelToken: this.source.token }
query,
{ cancelToken: this.source.token }
);
} catch (error) {
if (!axios.isCancel(error)) {
Expand All @@ -262,9 +277,11 @@ export default {
}
if (res && res.data && res.data.hits) {
res.data.hits.hits.map(h => h._source).forEach(event => {
this.loadedEvents.push(event);
});
res.data.hits.hits
.map(h => h._source)
.forEach(event => {
this.loadedEvents.push(event);
});
this.totalEvents = res.data.hits.total;
this.offset += 40;
}
Expand All @@ -288,8 +305,10 @@ export default {
.event-table .el-table td {
color: #212121;
font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono',
'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console",
"Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono",
"Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier,
monospace;
vertical-align: top;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/config/ConfigQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default {
computed: {
eventTableHeight() {
return document.body.clientHeight - 140;
return document.body.clientHeight - 145;
},
queryType: {
Expand Down

0 comments on commit cc9ba3b

Please sign in to comment.