added preloads page

This commit is contained in:
ston1th 2022-03-23 01:09:12 +01:00
commit 333d5cb149
6 changed files with 235 additions and 75 deletions

View file

@ -11,7 +11,6 @@ var (
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#222222">
<meta name="description" content="cachefs">
<title>cachefs | {{.Base}}</title>
<style>
body {
font: 20px Helvetica, sans-serif;
@ -102,11 +101,18 @@ td {
.green {
background-color: #4caf50;
}
.status-yellow {
color: #f39c12;
}
.status-green {
color: #4caf50;
}
span {
color: #b2b2b2;
font-size: 15px;
}
</style>
<title>cachefs | {{.Base}}</title>
</head>`
index = template.Must(template.New("index").Parse(indexHead + `<body>
@ -114,7 +120,7 @@ span {
<pre>[v]: show video
[n]: skip file caching
[p]: preload file
[s]: stop preloading</pre>
<a href="/?o=preloads">[Preloads]</a></pre>
<table>
<tr class="listitem">
<td class="listpath up"><a href="../">../</a></td>
@ -132,7 +138,33 @@ span {
<tr class="listitem">
<td class="listpath"><a id="{{$s.Anchor}}" href="{{$s.URI}}">{{$s.Name}}</a></td>
<td class="listoptions">
{{if ge $s.Status 0}}<span>{{$s.Status}}%</span>{{end}}<a href="{{$s.URI}}?o=v">[v]</a><a href="{{$s.URI}}?o=n">[n]</a><a href="{{$s.URI}}?o=p">[p]</a><a href="{{$s.URI}}?o=s">[s]</a>
{{if ge $s.Status 0}}<span>{{$s.Status}}%</span>{{end}}<a href="{{$s.URI}}?o=v">[v]</a><a href="{{$s.URI}}?o=n">[n]</a><a href="{{$s.URI}}?o=p">[p]</a>
</td>
</tr>
<tr class="spacer"><td colspan="2">
{{if ge $s.Status 0}}
<div class="spacer {{if le $s.Status 35}}red{{else if le $s.Status 65}}yellow{{else}}green{{end}}" style="width: {{$s.Status}}%;"></div>
{{end -}}
</td></tr>
{{end -}}
</table>
</article>
</body>
</html>`))
preloads = template.Must(template.New("preloads").Parse(indexHead + `<body>
<article>
<pre>[v]: show video
[s]: stop preloading</pre>
<table>
<tr class="listitem">
<td class="listpath up"><a href="/">/</a></td>
<td class="listoptions">[dir]</td>
</tr>
{{range $s := .Files -}}
<tr class="listitem">
<td class="listpath"><a href="{{$s.URI}}">{{$s.Name}}</a></td>
<td class="listoptions">
{{if ge $s.Status 0}}<span>{{$s.Status}}%</span>{{end}}<span class="status-{{if $s.Running}}green">[running{{else}}yellow">[queued{{end}}]</span><a href="{{$s.URI}}?o=v">[v]</a><a href="{{$s.Name}}?o=s">[s]</a>
</td>
</tr>
<tr class="spacer"><td colspan="2">