frontend changes
-smaller thumbnails -GPU acceleration -lazy loading/ rendering only visible elements -cover grid shows album tracks on click
This commit is contained in:
@@ -1,38 +1,6 @@
|
||||
package library
|
||||
|
||||
templ (d Directory) ToFormElement() {
|
||||
<script>
|
||||
function selectLibraryDirectory(pElement) {
|
||||
try {
|
||||
window.DirectoryPicker()
|
||||
.then((result) => {
|
||||
if (result.length != 0) {
|
||||
pElement.value = result;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("error with directory picker: " + err);
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
function scanLibrary(button) {
|
||||
button.disabled = true;
|
||||
button.textContent = "Scanning...";
|
||||
window.Scan()
|
||||
.then(() => {
|
||||
button.textContent = "Scan Library";
|
||||
button.disabled = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("error scanning library: " + err);
|
||||
button.textContent = "Scan Library";
|
||||
button.disabled = false;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<button type="button" onclick="selectLibraryDirectory(this.nextElementSibling)">Select</button>
|
||||
<input type="text" name="library.directory" value={ d } readonly/>
|
||||
<button type="button" onclick="scanLibrary(this)">Scan Library</button>
|
||||
|
||||
@@ -29,14 +29,14 @@ func (d Directory) ToFormElement() templ.Component {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<script>\n function selectLibraryDirectory(pElement) {\n try {\n window.DirectoryPicker()\n .then((result) => {\n if (result.length != 0) {\n pElement.value = result;\n }\n })\n .catch((err) => {\n console.error(\"error with directory picker: \" + err);\n });\n }\n catch (err) {\n console.error(err);\n }\n }\n function scanLibrary(button) {\n button.disabled = true;\n button.textContent = \"Scanning...\";\n window.Scan()\n .then(() => {\n button.textContent = \"Scan Library\";\n button.disabled = false;\n })\n .catch((err) => {\n console.error(\"error scanning library: \" + err);\n button.textContent = \"Scan Library\";\n button.disabled = false;\n });\n }\n </script><button type=\"button\" onclick=\"selectLibraryDirectory(this.nextElementSibling)\">Select</button> <input type=\"text\" name=\"library.directory\" value=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<button type=\"button\" onclick=\"selectLibraryDirectory(this.nextElementSibling)\">Select</button> <input type=\"text\" name=\"library.directory\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(d)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `library/config.templ`, Line: 37, Col: 54}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `library/config.templ`, Line: 5, Col: 54}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
const (
|
||||
// thumbnailMaxSize is the maximum width/height for generated thumbnails.
|
||||
thumbnailMaxSize = 256
|
||||
thumbnailMaxSize = 200
|
||||
// thumbnailQuality is the JPEG encoding quality for thumbnails.
|
||||
thumbnailQuality = 80
|
||||
// thumbnailSuffix is appended to the content hash for thumbnail filenames.
|
||||
|
||||
@@ -19,6 +19,8 @@ type Track struct {
|
||||
ArtistName string
|
||||
TrackLength string
|
||||
FilePath string
|
||||
TrackNumber int64
|
||||
DiscNumber int64
|
||||
}
|
||||
|
||||
// Album represents an album for the cover grid display.
|
||||
@@ -82,10 +84,15 @@ func (l *Library) GetAlbumTracks(albumID int64) ([]Track, error) {
|
||||
|
||||
for _, row := range rows {
|
||||
tracks = append(tracks, Track{
|
||||
TrackName: row.Title,
|
||||
ArtistName: row.ArtistName,
|
||||
TrackLength: strconv.FormatInt(row.LengthMilliseconds, 10),
|
||||
TrackName: row.Title,
|
||||
ArtistName: row.ArtistName,
|
||||
TrackLength: strconv.FormatInt(
|
||||
row.LengthMilliseconds,
|
||||
10,
|
||||
),
|
||||
FilePath: row.FilePath,
|
||||
TrackNumber: row.TrackNumber.Int64,
|
||||
DiscNumber: row.DiscNumber.Int64,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user