Add button to clear POST code logs

Utilize '#LogService.ClearLog' action to provide a possibility for the
user to clear POST code logs.

Change-Id: Iadd94b9ebc93bc81b13ee979962103587c939fc7
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index ca7c4da..d3ea2ee 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -656,12 +656,20 @@
         "button": {
             "exportAll": "Export all"
         },
+        "modal": {
+            "deleteAllTitle": "Delete all logs",
+            "deleteAllMessage": "Are you sure you want to delete all logs? This action cannot be undone."
+        },
         "table": {
             "created": "Created",
             "bootCount": "Boot count",
             "postCode": "POST code",
             "searchLogs": "Search logs",
             "timeStampOffset": "Time stamp offset"
+        },
+        "toast": {
+            "errorDelete": "Error deleting %{count} log. | Error deleting %{count} logs.",
+            "successDelete": "Successfully deleted %{count} log. | Successfully deleted %{count} logs."
         }
     },
     "pageProfileSettings": {
diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json
index 9dd883f..9e0debe 100644
--- a/src/locales/ru-RU.json
+++ b/src/locales/ru-RU.json
@@ -656,12 +656,20 @@
         "button": {
             "exportAll": "Экспортировать всё"
         },
+        "modal": {
+            "deleteAllTitle": "Удалить все логи",
+            "deleteAllMessage": "Вы уверены, что хотите удалить все логи? Действие не может быть отменено."
+        },
         "table": {
             "created": "Создано",
             "bootCount": "Номер загрузки",
             "postCode": "POST код",
             "searchLogs": "Поиск в логах",
             "timeStampOffset": "Временная метка"
+        },
+        "toast": {
+            "errorDelete": "Ошибка удаления %{count} записи. | Ошибка уделения %{count} записей.",
+            "successDelete": "Успешное удаление %{count} записи. | Успешное удаление всех %{count} записей."
         }
     },
     "pageProfileSettings": {
diff --git a/src/store/modules/Logs/PostCodeLogsStore.js b/src/store/modules/Logs/PostCodeLogsStore.js
index ac470ec..836f984 100644
--- a/src/store/modules/Logs/PostCodeLogsStore.js
+++ b/src/store/modules/Logs/PostCodeLogsStore.js
@@ -1,4 +1,5 @@
 import api from '@/store/api';
+import i18n from '@/i18n';
 
 const PostCodeLogsStore = {
   namespaced: true,
@@ -33,6 +34,22 @@
           console.log('POST Codes Log Data:', error);
         });
     },
+    async deleteAllPostCodeLogs({ dispatch }, data) {
+      return await api
+        .post(
+          '/redfish/v1/Systems/system/LogServices/PostCodes/Actions/LogService.ClearLog'
+        )
+        .then(() => dispatch('getPostCodesLogData'))
+        .then(() =>
+          i18n.tc('pagePostCodeLogs.toast.successDelete', data.length)
+        )
+        .catch((error) => {
+          console.log(error);
+          throw new Error(
+            i18n.tc('pagePostCodeLogs.toast.errorDelete', data.length)
+          );
+        });
+    },
   },
 };
 
diff --git a/src/views/Logs/PostCodeLogs/PostCodeLogs.vue b/src/views/Logs/PostCodeLogs/PostCodeLogs.vue
index d116d2e..a68047b 100644
--- a/src/views/Logs/PostCodeLogs/PostCodeLogs.vue
+++ b/src/views/Logs/PostCodeLogs/PostCodeLogs.vue
@@ -22,6 +22,13 @@
     <b-row>
       <b-col xl="12" class="text-right">
         <b-button
+          variant="link"
+          :disabled="allLogs.length === 0"
+          @click="deleteAllLogs"
+        >
+          <icon-delete /> {{ $t('global.action.deleteAll') }}
+        </b-button>
+        <b-button
           variant="primary"
           :disabled="allLogs.length === 0"
           :download="exportFileNameByDate()"
@@ -148,6 +155,7 @@
 </template>
 
 <script>
+import IconDelete from '@carbon/icons-vue/es/trash-can/20';
 import IconDownload from '@carbon/icons-vue/es/download/20';
 import IconExport from '@carbon/icons-vue/es/document--export/20';
 import { omit } from 'lodash';
@@ -181,6 +189,7 @@
 
 export default {
   components: {
+    IconDelete,
     IconExport,
     IconDownload,
     PageTitle,
@@ -305,6 +314,23 @@
     });
   },
   methods: {
+    deleteAllLogs() {
+      this.$bvModal
+        .msgBoxConfirm(this.$t('pageEventLogs.modal.deleteAllMessage'), {
+          title: this.$t('pageEventLogs.modal.deleteAllTitle'),
+          okTitle: this.$t('global.action.delete'),
+          okVariant: 'danger',
+          cancelTitle: this.$t('global.action.cancel'),
+        })
+        .then((deleteConfirmed) => {
+          if (deleteConfirmed) {
+            this.$store
+              .dispatch('postCodeLogs/deleteAllPostCodeLogs', this.allLogs)
+              .then((message) => this.successToast(message))
+              .catch(({ message }) => this.errorToast(message));
+          }
+        });
+    },
     exportAllLogsString() {
       {
         return this.$store.getters['postCodeLogs/allPostCodes'].map(