Skip to content

Commit 582e954

Browse files
committed
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 <[email protected]>
1 parent 1ff8e89 commit 582e954

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/locales/en-US.json

+1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
"errorLogStatusUpdate": "Error updating log status.",
283283
"errorResolveLogs": "Error resolving %{count} log. | Error resolving %{count} logs.",
284284
"errorUnresolveLogs": "Error unresolving %{count} log. | Error unresolving %{count} logs.",
285+
"errorDownloadEventEntry": "Error download event log entry.",
285286
"successDelete": "Successfully deleted %{count} log. | Successfully deleted %{count} logs.",
286287
"successResolveLogs": "Successfully resolved %{count} log. | Successfully resolved %{count} logs.",
287288
"successUnresolveLogs": "Successfully unresolved %{count} log. | Successfully unresolved %{count} logs."

src/store/modules/Logs/EventLogStore.js

+16
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,22 @@ const EventLogStore = {
220220
throw new Error(i18n.t('pageEventLogs.toast.errorLogStatusUpdate'));
221221
});
222222
},
223+
async downloadEntry(_, uri) {
224+
return await api
225+
.get(uri)
226+
.then((response) => {
227+
const blob = new Blob([response.data], {
228+
type: response.headers['content-type'],
229+
});
230+
return blob;
231+
})
232+
.catch((error) => {
233+
console.log(error);
234+
throw new Error(
235+
i18n.t('pageEventLogs.toast.errorDownloadEventEntry'),
236+
);
237+
});
238+
},
223239
},
224240
};
225241

src/views/Logs/EventLogs/EventLogs.vue

+15-5
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,7 @@
151151
</dl>
152152
</b-col>
153153
<b-col class="text-nowrap">
154-
<b-button
155-
class="btn btn-secondary float-right"
156-
:href="item.additionalDataUri"
157-
target="_blank"
158-
>
154+
<b-button @click="downloadEntry(item.additionalDataUri)">
159155
<icon-download />{{ $t('pageEventLogs.additionalDataUri') }}
160156
</b-button>
161157
</b-col>
@@ -471,6 +467,20 @@ export default {
471467
});
472468
},
473469
methods: {
470+
downloadEntry(uri) {
471+
let filename = uri?.split('LogServices/')?.[1];
472+
filename.replace(RegExp('/', 'g'), '_');
473+
this.$store
474+
.dispatch('eventLog/downloadEntry', uri)
475+
.then((blob) => {
476+
const link = document.createElement('a');
477+
link.href = URL.createObjectURL(blob);
478+
link.download = filename;
479+
link.click();
480+
URL.revokeObjectURL(link.href);
481+
})
482+
.catch(({ message }) => this.errorToast(message));
483+
},
474484
changelogStatus(row) {
475485
this.$store
476486
.dispatch('eventLog/updateEventLogStatus', {

0 commit comments

Comments
 (0)