blob: b73c0b48969461417d0821422aa3ada49e664d96 [file] [log] [blame]
Dixsie Wolmers97d86b32019-12-02 05:07:57 -06001<template>
Dixsie Wolmers6a192d52021-09-02 15:26:58 -05002 <overview-card
3 :data="eventLogData"
4 :disabled="eventLogData.length === 0"
5 :export-button="true"
6 :file-name="exportFileNameByDate()"
7 :title="$t('pageOverview.eventLogs')"
8 :to="`/logs/event-logs`"
9 >
10 <b-row class="mt-3">
11 <b-col sm="6">
12 <dl>
13 <dt>{{ $t('pageOverview.criticalEvents') }}</dt>
14 <dd class="h3">
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050015 {{ dataFormatter(criticalEvents.length) }}
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050016 <status-icon status="danger" />
17 </dd>
18 </dl>
19 </b-col>
20 <b-col sm="6">
21 <dl>
22 <dt>{{ $t('pageOverview.warningEvents') }}</dt>
23 <dd class="h3">
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050024 {{ dataFormatter(warningEvents.length) }}
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050025 <status-icon status="warning" />
26 </dd>
27 </dl>
28 </b-col>
29 </b-row>
30 </overview-card>
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060031</template>
32
33<script>
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050034import OverviewCard from './OverviewCard';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -070035import StatusIcon from '@/components/Global/StatusIcon';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050036import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -070037
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060038export default {
Derick Montague09e45cd2020-01-23 15:45:57 -060039 name: 'Events',
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050040 components: { OverviewCard, StatusIcon },
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050041 mixins: [DataFormatterMixin],
Dixsie Wolmersf65ee342020-01-22 19:47:56 -060042 computed: {
43 eventLogData() {
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050044 return this.$store.getters['eventLog/allEvents'];
45 },
46 criticalEvents() {
47 return this.eventLogData
48 .filter((log) => log.severity === 'Critical')
49 .map((log) => {
50 return log;
51 });
52 },
53 warningEvents() {
54 return this.eventLogData
55 .filter((log) => log.severity === 'Warning')
56 .map((log) => {
57 return log;
58 });
Derick Montague602e98a2020-10-21 16:20:00 -050059 },
Dixsie Wolmersf65ee342020-01-22 19:47:56 -060060 },
Derick Montague09e45cd2020-01-23 15:45:57 -060061 created() {
Yoshie Muranaka598bf7e2020-05-01 12:26:00 -070062 this.$store.dispatch('eventLog/getEventLogData').finally(() => {
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053063 this.$root.$emit('overview-events-complete');
Yoshie Muranaka598bf7e2020-05-01 12:26:00 -070064 });
Derick Montague602e98a2020-10-21 16:20:00 -050065 },
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050066 methods: {
67 exportFileNameByDate() {
68 // Create export file name based on date
69 let date = new Date();
70 date =
71 date.toISOString().slice(0, 10) +
72 '_' +
73 date.toString().split(':').join('-').split(' ')[4];
74 let fileName = 'all_event_logs_';
75 return fileName + date;
76 },
77 },
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060078};
79</script>
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050080
81<style lang="scss" scoped>
82.status-icon {
83 vertical-align: text-top;
84}
85</style>