summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Zhang <xiazhang@nvidia.com>2024-07-05 12:48:45 +0300
committerxiazhang <xiazhang@nvidia.com>2024-07-26 05:36:41 +0300
commit582e954ecff4edf58c143dc644a21b15005e8109 (patch)
treeddb46fbb83206319b532257add2e37cee5066b24
parent1ff8e89fd2397c468ab0237158e5aeeff2692413 (diff)
downloadwebui-vue-582e954ecff4edf58c143dc644a21b15005e8109.tar.xz
Fix single event entry download
For event entry download, the href not work since the event entry download only work with header of "Accept: application/octet-stream" or the default "*/*", change to click function to make it work. Refer: https://gerrit.openbmc.org/c/openbmc/bmcweb/+/40136 Change-Id: I11051e913bfd71ef081bed93ffcbeeb1edd8c730 Signed-off-by: Sean Zhang <xiazhang@nvidia.com>
-rw-r--r--src/locales/en-US.json1
-rw-r--r--src/store/modules/Logs/EventLogStore.js16
-rw-r--r--src/views/Logs/EventLogs/EventLogs.vue20
3 files changed, 32 insertions, 5 deletions
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index 55ff937f..a4995076 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -282,6 +282,7 @@
"errorLogStatusUpdate": "Error updating log status.",
"errorResolveLogs": "Error resolving %{count} log. | Error resolving %{count} logs.",
"errorUnresolveLogs": "Error unresolving %{count} log. | Error unresolving %{count} logs.",
+ "errorDownloadEventEntry": "Error download event log entry.",
"successDelete": "Successfully deleted %{count} log. | Successfully deleted %{count} logs.",
"successResolveLogs": "Successfully resolved %{count} log. | Successfully resolved %{count} logs.",
"successUnresolveLogs": "Successfully unresolved %{count} log. | Successfully unresolved %{count} logs."
diff --git a/src/store/modules/Logs/EventLogStore.js b/src/store/modules/Logs/EventLogStore.js
index e67da39b..f302dffb 100644
--- a/src/store/modules/Logs/EventLogStore.js
+++ b/src/store/modules/Logs/EventLogStore.js
@@ -220,6 +220,22 @@ const EventLogStore = {
throw new Error(i18n.t('pageEventLogs.toast.errorLogStatusUpdate'));
});
},
+ async downloadEntry(_, uri) {
+ return await api
+ .get(uri)
+ .then((response) => {
+ const blob = new Blob([response.data], {
+ type: response.headers['content-type'],
+ });
+ return blob;
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(
+ i18n.t('pageEventLogs.toast.errorDownloadEventEntry'),
+ );
+ });
+ },
},
};
diff --git a/src/views/Logs/EventLogs/EventLogs.vue b/src/views/Logs/EventLogs/EventLogs.vue
index 0e7c494e..b48bd441 100644
--- a/src/views/Logs/EventLogs/EventLogs.vue
+++ b/src/views/Logs/EventLogs/EventLogs.vue
@@ -151,11 +151,7 @@
</dl>
</b-col>
<b-col class="text-nowrap">
- <b-button
- class="btn btn-secondary float-right"
- :href="item.additionalDataUri"
- target="_blank"
- >
+ <b-button @click="downloadEntry(item.additionalDataUri)">
<icon-download />{{ $t('pageEventLogs.additionalDataUri') }}
</b-button>
</b-col>
@@ -471,6 +467,20 @@ export default {
});
},
methods: {
+ downloadEntry(uri) {
+ let filename = uri?.split('LogServices/')?.[1];
+ filename.replace(RegExp('/', 'g'), '_');
+ this.$store
+ .dispatch('eventLog/downloadEntry', uri)
+ .then((blob) => {
+ const link = document.createElement('a');
+ link.href = URL.createObjectURL(blob);
+ link.download = filename;
+ link.click();
+ URL.revokeObjectURL(link.href);
+ })
+ .catch(({ message }) => this.errorToast(message));
+ },
changelogStatus(row) {
this.$store
.dispatch('eventLog/updateEventLogStatus', {