gropple/web/data/templates/index.tmpl

115 lines
4.3 KiB
Cheetah
Raw Normal View History

{{ define "content" }}
2021-09-21 08:33:24 +09:30
{{ template "menu.tmpl" . }}
2021-09-26 21:13:33 +09:30
<div x-data="index()" x-init="fetch_data(); fetch_version()">
<p x-cloak x-show="version && version.upgrade_available">
2023-11-20 21:22:48 +10:30
<a href="https://github.com/tardisx/gropple/releases">Upgrade is available</a> -
you have
<span x-text="version.current_version"></span> and
2021-09-26 21:13:33 +09:30
<span x-text="version.github_version"></span>
is available.</p>
<div>
<p>
Drag this bookmarklet: <a href="{{ .BookmarkletURL }}">Gropple</a> to your bookmark bar, and click it
on any page you want to grab the video from.
</p>
<p>
Please note that some adblockers may prevent the bookmarklet from opening the popup window.
</p>
2021-09-26 21:13:33 +09:30
</div>
2021-09-21 17:46:36 +09:30
<table class="pure-table">
<thead>
<tr>
2023-11-20 21:01:50 +10:30
<th>id</th>
<th>filename</th>
<th>url</th>
<th>state</th>
<th>percent</th>
<th>eta</th>
<th>finished</th>
2021-09-21 17:46:36 +09:30
</tr>
</thead>
<tbody>
2021-09-26 12:33:31 +09:30
<template x-for="item in items">
<tr>
2023-11-20 21:01:50 +10:30
<td>
<a class="int-link" @click="show_popup(item)" href="#">
<span x-text="item.id">
</a>
</td>
<td>
2023-11-21 22:05:13 +10:30
<span x-show="item.files && item.files.length == 1">
<span class="filelist" x-text="item.files[0]"></span>
</span>
<span x-data="{open: false}" x-show="item.files && item.files.length > 1">
<span x-text="item.files.length"></span> files...
<button class="pure-button button-small" @click="open = ! open" x-text="open ? 'hide' : 'show'"></button>
<div x-show="open" x-transition>
<ul class="filelist">
<template x-for="file in item.files">
<li x-text="file"></li>
</template>
</ul>
</div>
</span>
<span x-show="! item.files || item.files.length == 0"
2023-11-21 22:05:13 +10:30
x-text="'fetching ' + item.url + '...'">
</span>
</td>
2023-11-20 21:01:50 +10:30
<td><a class="int-link" x-bind:href="item.url">&#x1F517;</a></td>
<td :class="'state-'+item.state" x-text="item.state"></td>
2021-09-26 12:33:31 +09:30
<td x-text="item.percent"></td>
<td x-text="item.eta"></td>
<td x-text="item.finished ? '&#x2714;' : '-'"></td>
2021-09-26 12:33:31 +09:30
</tr>
2023-11-20 21:01:50 +10:30
2021-09-26 12:33:31 +09:30
</template>
2023-11-20 21:01:50 +10:30
</tbody>
</table>
</div>
{{ end }}
{{ define "js" }}
2021-09-26 12:33:31 +09:30
<script>
function index() {
2023-11-20 21:01:50 +10:30
return {
items: [], version: {}, popups: {},
2021-09-26 21:13:33 +09:30
fetch_version() {
fetch('/rest/version')
2021-09-26 21:13:33 +09:30
.then(response => response.json())
.then(info => {
this.version = info;
setTimeout(() => { this.fetch_version() }, 1000 * 60 );
})
.catch(error => {
console.log('failed to fetch version info - will retry');
setTimeout(() => { this.fetch_version() }, 1000 );
});
},
2021-09-26 12:33:31 +09:30
fetch_data() {
2021-09-30 23:55:55 +09:30
fetch('/rest/fetch')
2021-09-26 12:33:31 +09:30
.then(response => response.json())
.then(info => {
2021-09-26 12:48:42 +09:30
// will be null if no downloads yet
if (info) {
this.items = info;
}
2021-09-26 12:33:31 +09:30
setTimeout(() => { this.fetch_data() }, 1000);
})
},
show_popup(item) {
// allegedly you can use the reference to pop the window to the front on subsequent
// clicks, but I can't seem to find a reliable way to do so.
this.popups[item.id] = window.open(item.popup_url, item.id, "width={{ .Config.UI.PopupWidth }},height={{ .Config.UI.PopupHeight }}");
},
}
2021-09-26 12:33:31 +09:30
}
</script>
{{ end }}