@@ -188,33 +188,40 @@ export const downloadLogs = async (
188
188
}
189
189
logsURL += `${ filter } `
190
190
setDownloadInProgress ( true )
191
- const response = await fetch ( logsURL )
192
- try {
193
- const data = await ( response as any ) . blob ( )
191
+ await fetch ( logsURL )
192
+ . then ( async ( response ) => {
193
+ try {
194
+ if ( response . status === 204 ) {
195
+ toast . error ( response . statusText )
196
+ return ;
197
+ }
198
+ console . log ( 'response' , response )
199
+ const data = await ( response as any ) . blob ( )
200
+ // Create a new URL object
201
+ const blobUrl = URL . createObjectURL ( data )
194
202
195
- // Create a new URL object
196
- const blobUrl = URL . createObjectURL ( data )
203
+ // Create a link element
204
+ const a = document . createElement ( 'a' )
205
+ a . href = logsURL
206
+ a . download = `podlogs-${ nodeName } -${ new Date ( ) . getTime ( ) } .log`
197
207
198
- // Create a link element
199
- const a = document . createElement ( 'a' )
200
- a . href = logsURL
201
- a . download = `podlogs-${ nodeName } -${ new Date ( ) . getTime ( ) } .log`
208
+ // Append the link element to the DOM
209
+ document . body . appendChild ( a )
202
210
203
- // Append the link element to the DOM
204
- document . body . appendChild ( a )
211
+ // Programmatically click the link to start the download
212
+ a . click ( )
205
213
206
- // Programmatically click the link to start the download
207
- a . click ( )
208
-
209
- setTimeout ( ( ) => {
210
- URL . revokeObjectURL ( blobUrl )
211
- document . body . removeChild ( a )
212
- } , 0 )
213
- } catch ( e ) {
214
- toast . error ( e )
215
- } finally {
216
- setDownloadInProgress ( false )
217
- }
214
+ setTimeout ( ( ) => {
215
+ URL . revokeObjectURL ( blobUrl )
216
+ document . body . removeChild ( a )
217
+ } , 0 )
218
+ } catch ( e ) {
219
+ toast . error ( e )
220
+ } finally {
221
+ setDownloadInProgress ( false )
222
+ }
223
+ } )
224
+ . catch ( ( e ) => toast . error ( e ) )
218
225
}
219
226
220
227
export const getLogsURL = (
0 commit comments