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 |
| 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 Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 59 | }, |
Dixsie Wolmers | f65ee34 | 2020-01-22 19:47:56 -0600 | [diff] [blame] | 60 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 61 | created() { |
Yoshie Muranaka | 598bf7e | 2020-05-01 12:26:00 -0700 | [diff] [blame] | 62 | this.$store.dispatch('eventLog/getEventLogData').finally(() => { |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 63 | this.$root.$emit('overview-events-complete'); |
Yoshie Muranaka | 598bf7e | 2020-05-01 12:26:00 -0700 | [diff] [blame] | 64 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 65 | }, |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 66 | 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 Wolmers | 97d86b3 | 2019-12-02 05:07:57 -0600 | [diff] [blame] | 78 | }; |
| 79 | </script> |
Dixsie Wolmers | 6a192d5 | 2021-09-02 15:26:58 -0500 | [diff] [blame] | 80 | |
| 81 | <style lang="scss" scoped> |
| 82 | .status-icon { |
| 83 | vertical-align: text-top; |
| 84 | } |
| 85 | </style> |