2021-09-21 17:13:30 +09:30
{{ define "content" }}
2021-09-21 19:20:48 +09:30
< div id = "layout" class = "pure-g pure-u-1" x-data = "popup()" x-init = "fetch_data()" >
< h2 > Download started</ h2 >
2021-09-21 08:33:24 +09:30
< p > Fetching < tt > {{ .Url }}</ tt ></ p >
2021-09-21 19:20:48 +09:30
< table class = "pure-table" >
2021-09-21 08:33:24 +09:30
< tr >< th > current filename</ th >< td x-text = "filename" ></ td ></ tr >
< tr >< th > state</ th >< td x-text = "state" ></ td ></ tr >
< tr >< th > progress</ th >< td x-text = "percent" ></ td ></ tr >
< tr >< th > ETA</ th >< td x-text = "eta" ></ td ></ tr >
</ table >
2021-09-21 19:20:48 +09:30
< p > You can close this window and your download will continue. Check the < a href = "/" target = "_gropple_status" > Status page</ a > to see all downloads in progress.</ p >
< div >
< h4 > Logs</ h4 >
< pre x-text = "log" >
</ pre >
</ div >
2021-09-21 08:33:24 +09:30
</ div >
2021-09-21 17:13:30 +09:30
{{ end }}
{{ define "js" }}
2021-09-21 08:33:24 +09:30
< script >
function popup () {
return {
2021-09-21 19:20:48 +09:30
eta : '' , percent : 0.0 , state : '??' , filename : '' , finished : false , log : '' ,
2021-09-21 08:33:24 +09:30
fetch_data () {
2021-09-28 22:09:12 +09:30
fetch ( '/rest/fetch/info/{{ .Id }}' )
2021-09-21 08:33:24 +09:30
. then ( response => response . json ())
. then ( info => {
this . eta = info . eta ;
this . percent = info . percent + "%" ;
this . state = info . state ;
2021-09-21 17:13:30 +09:30
this . finished = info . finished ;
2021-09-21 08:33:24 +09:30
if ( info . files && info . files . length > 0 ) {
this . filename = info . files [ info . files . length - 1 ];
}
2021-09-21 19:20:48 +09:30
if ( info . log && info . log . length > 0 ) {
this . log = info . log . join ( "\n" );
}
2021-09-21 17:13:30 +09:30
console . log ( 'finish?' , this . finished );
if ( ! this . finished ) {
2021-09-21 19:20:48 +09:30
setTimeout (() => { this . fetch_data () }, 1000 );
2021-09-21 08:33:24 +09:30
}
2021-09-21 19:20:48 +09:30
console . log ( 'log' , this . log );
2021-09-21 08:33:24 +09:30
});
},
}
}
</ script >
2021-09-21 17:13:30 +09:30
{{ end }}
2021-09-21 08:33:24 +09:30