blob: af7e2945b2f88d48d6fd481a5d77cba56c2dce7d [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
Glukhov Mikhail8890db82023-03-21 14:11:40 +030048 .filter(
49 (log) =>
50 log.severity === 'Critical' && log.filterByStatus === 'Unresolved'
51 )
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050052 .map((log) => {
53 return log;
54 });
55 },
56 warningEvents() {
57 return this.eventLogData
Glukhov Mikhail8890db82023-03-21 14:11:40 +030058 .filter(
59 (log) =>
60 log.severity === 'Warning' && log.filterByStatus === 'Unresolved'
61 )
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050062 .map((log) => {
63 return log;
64 });
Derick Montague602e98a2020-10-21 16:20:00 -050065 },
Dixsie Wolmersf65ee342020-01-22 19:47:56 -060066 },
Derick Montague09e45cd2020-01-23 15:45:57 -060067 created() {
Yoshie Muranaka598bf7e2020-05-01 12:26:00 -070068 this.$store.dispatch('eventLog/getEventLogData').finally(() => {
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053069 this.$root.$emit('overview-events-complete');
Yoshie Muranaka598bf7e2020-05-01 12:26:00 -070070 });
Derick Montague602e98a2020-10-21 16:20:00 -050071 },
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050072 methods: {
73 exportFileNameByDate() {
74 // Create export file name based on date
75 let date = new Date();
76 date =
77 date.toISOString().slice(0, 10) +
78 '_' +
79 date.toString().split(':').join('-').split(' ')[4];
80 let fileName = 'all_event_logs_';
81 return fileName + date;
82 },
83 },
Dixsie Wolmers97d86b32019-12-02 05:07:57 -060084};
85</script>
Dixsie Wolmers6a192d52021-09-02 15:26:58 -050086
87<style lang="scss" scoped>
88.status-icon {
89 vertical-align: text-top;
90}
91</style>