Dixsie Wolmers | 97d86b3 | 2019-12-02 05:07:57 -0600 | [diff] [blame] | 1 | <template> |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 2 | <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 Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame] | 15 | {{ dataFormatter(criticalEvents.length) }} |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 16 | <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 Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame] | 24 | {{ dataFormatter(warningEvents.length) }} |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 25 | <status-icon status="warning" /> |
| 26 | </dd> |
| 27 | </dl> |
| 28 | </b-col> |
| 29 | </b-row> |
| 30 | </overview-card> |
Dixsie Wolmers | 97d86b3 | 2019-12-02 05:07:57 -0600 | [diff] [blame] | 31 | </template> |
| 32 | |
| 33 | <script> |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 34 | import OverviewCard from './OverviewCard'; |
Yoshie Muranaka | ce9a3ef | 2020-05-06 14:33:22 -0700 | [diff] [blame] | 35 | import StatusIcon from '@/components/Global/StatusIcon'; |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame] | 36 | import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin'; |
Yoshie Muranaka | ce9a3ef | 2020-05-06 14:33:22 -0700 | [diff] [blame] | 37 | |
Dixsie Wolmers | 97d86b3 | 2019-12-02 05:07:57 -0600 | [diff] [blame] | 38 | export default { |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 39 | name: 'Events', |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 40 | components: { OverviewCard, StatusIcon }, |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame] | 41 | mixins: [DataFormatterMixin], |
Dixsie Wolmers | f65ee34 | 2020-01-22 19:47:56 -0600 | [diff] [blame] | 42 | computed: { |
| 43 | eventLogData() { |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 44 | return this.$store.getters['eventLog/allEvents']; |
| 45 | }, |
| 46 | criticalEvents() { |
| 47 | return this.eventLogData |
Glukhov Mikhail | 8890db8 | 2023-03-21 14:11:40 +0300 | [diff] [blame] | 48 | .filter( |
| 49 | (log) => |
| 50 | log.severity === 'Critical' && log.filterByStatus === 'Unresolved' |
| 51 | ) |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 52 | .map((log) => { |
| 53 | return log; |
| 54 | }); |
| 55 | }, |
| 56 | warningEvents() { |
| 57 | return this.eventLogData |
Glukhov Mikhail | 8890db8 | 2023-03-21 14:11:40 +0300 | [diff] [blame] | 58 | .filter( |
| 59 | (log) => |
| 60 | log.severity === 'Warning' && log.filterByStatus === 'Unresolved' |
| 61 | ) |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 62 | .map((log) => { |
| 63 | return log; |
| 64 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 65 | }, |
Dixsie Wolmers | f65ee34 | 2020-01-22 19:47:56 -0600 | [diff] [blame] | 66 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 67 | created() { |
Yoshie Muranaka | 598bf7e | 2020-05-01 12:26:00 -0700 | [diff] [blame] | 68 | this.$store.dispatch('eventLog/getEventLogData').finally(() => { |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 69 | this.$root.$emit('overview-events-complete'); |
Yoshie Muranaka | 598bf7e | 2020-05-01 12:26:00 -0700 | [diff] [blame] | 70 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 71 | }, |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 72 | 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 Wolmers | 97d86b3 | 2019-12-02 05:07:57 -0600 | [diff] [blame] | 84 | }; |
| 85 | </script> |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 86 | |
| 87 | <style lang="scss" scoped> |
| 88 | .status-icon { |
| 89 | vertical-align: text-top; |
| 90 | } |
| 91 | </style> |