mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 19:44:35 +00:00
feat(log): added time to downloaded log name
This commit is contained in:
@@ -113,7 +113,7 @@ const LogChunk = (props: LogChunkProps) => {
|
|||||||
)}
|
)}
|
||||||
<FileDownloadIcon
|
<FileDownloadIcon
|
||||||
onClick={(evt: SyntheticEvent) => {
|
onClick={(evt: SyntheticEvent) => {
|
||||||
download(evt, rowText, `log.${getLineRange('-')}`)
|
download(evt, rowText, `.${getLineRange('-')}`)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errors && errors.length !== 0 && (
|
{errors && errors.length !== 0 && (
|
||||||
|
|||||||
@@ -102,19 +102,27 @@ export const splitIntoChunks = (log: string, chunkSize = defaultChunkSize) => {
|
|||||||
export const clearErrorsAndWarningsHtmlWrapping = (log: string) =>
|
export const clearErrorsAndWarningsHtmlWrapping = (log: string) =>
|
||||||
log.replace(/^<font[^>]*>/gm, '').replace(/<\/font>/gm, '')
|
log.replace(/^<font[^>]*>/gm, '').replace(/<\/font>/gm, '')
|
||||||
|
|
||||||
export const download = (
|
export const download = (evt: SyntheticEvent, log: string, fileName = '') => {
|
||||||
evt: SyntheticEvent,
|
|
||||||
log: string,
|
|
||||||
fileName = 'log'
|
|
||||||
) => {
|
|
||||||
evt.stopPropagation()
|
evt.stopPropagation()
|
||||||
|
|
||||||
|
const padWithZero = (num: number) => (num < 9 ? `0${num}` : `${num}`)
|
||||||
|
|
||||||
|
const date = new Date()
|
||||||
|
const datePrefix = [
|
||||||
|
date.getFullYear(),
|
||||||
|
padWithZero(date.getMonth() + 1),
|
||||||
|
padWithZero(date.getDate()),
|
||||||
|
padWithZero(date.getHours()),
|
||||||
|
padWithZero(date.getMinutes()),
|
||||||
|
padWithZero(date.getSeconds())
|
||||||
|
].join('')
|
||||||
|
|
||||||
const file = new Blob([log])
|
const file = new Blob([log])
|
||||||
const url = URL.createObjectURL(file)
|
const url = URL.createObjectURL(file)
|
||||||
|
|
||||||
const a = document.createElement('a')
|
const a = document.createElement('a')
|
||||||
a.href = url
|
a.href = url
|
||||||
a.download = `${fileName}.log`
|
a.download = `${datePrefix}${fileName}.log`
|
||||||
document.body.appendChild(a)
|
document.body.appendChild(a)
|
||||||
a.click()
|
a.click()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user