feat(xo-web/downloadLog): use .json extension for JSON values
This commit is contained in:
@@ -591,9 +591,11 @@ export const safeDateFormat = ms => new Date(ms).toISOString().replace(/:/g, '_'
|
||||
// ===================================================================
|
||||
|
||||
export const downloadLog = ({ log, date, type }) => {
|
||||
const isJson = typeof log !== 'string'
|
||||
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = window.URL.createObjectURL(createBlobFromString(log))
|
||||
anchor.download = `${safeDateFormat(date)} - ${type}.log`
|
||||
anchor.href = window.URL.createObjectURL(createBlobFromString(isJson ? JSON.stringify(log, null, 2) : log))
|
||||
anchor.download = `${safeDateFormat(date)} - ${type}.${isJson ? 'json' : 'log'}`
|
||||
anchor.style.display = 'none'
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
|
||||
@@ -29,8 +29,8 @@ export default decorate([
|
||||
effects: {
|
||||
_downloadLog:
|
||||
() =>
|
||||
({ formattedLog }, { log }) =>
|
||||
downloadLog({ log: formattedLog, date: log.start, type: 'backup NG' }),
|
||||
(_, { log }) =>
|
||||
downloadLog({ log, date: log.start, type: 'backup NG' }),
|
||||
restartFailedVms:
|
||||
(_, params) =>
|
||||
async (_, { log: { jobId: id, scheduleId: schedule, tasks, infos } }) => {
|
||||
|
||||
@@ -94,7 +94,7 @@ const INDIVIDUAL_ACTIONS = [
|
||||
label: _('logDownload'),
|
||||
handler: task =>
|
||||
downloadLog({
|
||||
log: JSON.stringify(task, null, 2),
|
||||
log: task,
|
||||
date: task.start,
|
||||
type: 'Metadata restore',
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user