Files
gonic/assets/pages/home.tmpl
2020-01-27 17:02:53 +00:00

134 lines
5.1 KiB
Cheetah

{{ define "user" }}
<div class="padded box">
<div class="box-title">
<i class="mdi mdi-chart-arc"></i> stats
</div>
<div class="block-right">
<table id="stats" class="text-right">
<tr>
<td>artists:</td> <td>{{ .ArtistCount }}</td>
</tr>
<tr>
<td>albums:</td> <td>{{ .AlbumCount }}</td>
</tr>
<tr>
<td>tracks:</td> <td>{{ .TrackCount }}</td>
</tr>
</table>
</div>
</div>
<div class="padded box">
<div class="box-title">
<i class="mdi mdi-lastfm"></i> last.fm
</div>
<div class="text-right">
{{ if .User.IsAdmin }}
<p class="light">you can get an api key <a href="https://www.last.fm/api/account/create" target="_blank">here</a></p>
<a href="{{ path "/admin/update_lastfm_api_key" }}">update api key</a><br/>
{{ end }}
{{ if .CurrentLastFMAPIKey }}
<span class="light">current status</span>
{{ if .User.LastFMSession }}
linked
<span class="light">&#124;</span>
<a href="{{ path "/admin/unlink_lastfm_do" }}">unlink</a><br/>
{{ else }}
<span class="angry">unlinked</span>
{{ $cbPath := path "/admin/link_lastfm_do" }}
{{ $cbURL := printf "%s%s" .RequestRoot $cbPath }}
<a href="https://www.last.fm/api/auth/?api_key={{ .CurrentLastFMAPIKey }}&cb={{ $cbURL }}">link</a><br/>
{{ end }}
{{ else if not .User.IsAdmin }}
<span class="light">api key not set. please ask your admin to set it</span>
{{ end }}
</div>
</div>
<div class="padded box">
{{ if .User.IsAdmin }}
{{/* admin panel to manage all users */}}
<div class="box-title">
<i class="mdi mdi-account-multiple"></i> users
</div>
<div class="text-right">
{{ range $user := .AllUsers }}
<i>{{ $user.Name }}</i>
<span class="light no-small">{{ $user.CreatedAt.Format "jan 02, 2006" }}</span>
<span class="light">&#124;</span>
<a href="{{ printf "/admin/change_password?user=%s" $user.Name | path }}">change password</a>
<span class="light">&#124;</span>
<a href="{{ printf "/admin/delete_user?user=%s" $user.Name | path }}">delete</a><br/>
{{ end }}
<a href="{{ path "/admin/create_user" }}" class="button">create new</a>
</div>
{{ else }}
{{/* user panel to manage themselves */}}
<div class="box-title">
<i class="mdi mdi-account"></i> your account
</div>
<div class="text-right">
<a href="{{ path "/admin/change_own_password" }}" class="button">change password</a>
</div>
{{ end }}
</div>
<div class="padded box">
<div class="box-title">
<i class="mdi mdi-folder-multiple"></i> recent folders
</div>
<div class="block-right text-right">
{{ if eq (len .RecentFolders) 0 }}
<span class="light">no folders yet</span>
{{ end }}
<table id="recent-folders">
{{ range $folder := .RecentFolders }}
<tr>
<td class="text-right">{{ $folder.RightPath }}</td>
<td class="no-small"><span class="light" title="{{ $folder.ModifiedAt }}">{{ $folder.ModifiedAt | humanDate }}</span></td>
</tr>
{{ end }}
</table>
{{- if not .IsScanning -}}
<a href="{{ path "/admin/start_scan_do" }}">start scan</a>
{{- if not .LastScanTime.IsZero -}}
<br>
<span class="light" title="{{ .LastScanTime }}">scanned {{ .LastScanTime | humanDate }}</span>
{{ end }}
{{ end }}
</div>
</div>
<div class="padded box">
<div class="box-title">
<i class="mdi mdi-playlist-music"></i> playlists
</div>
<div class="block-right text-right">
{{ if eq (len .Playlists) 0 }}
<span class="light">no playlists yet</span>
{{ end }}
<table id="recent-playlists">
{{ range $playlist := .Playlists }}
<tr>
<td class="text-right">{{ $playlist.Name }}</td>
<td><span class="light">({{ $playlist.TrackCount }} tracks)</span></td>
<td class="no-small"><span class="light" title="{{ $playlist.CreatedAt }}">{{ $playlist.CreatedAt | humanDate }}</span></td>
</tr>
{{ end }}
</table>
<form
id="playlist-upload-form"
enctype="multipart/form-data"
action="{{ path "/admin/upload_playlist_do" }}"
method="post"
>
<label for="playlist-upload-input">
<a>upload m3u8 files</a>
</label>
<input id="playlist-upload-input" name="playlist-files" type="file" multiple />
</form>
<script>
document.getElementById("playlist-upload-input").onchange = (e) => {
document.getElementById("playlist-upload-form").submit();
}
</script>
</div>
</div>
{{ end }}