Skip to content

Commit

Permalink
added albums to redirect GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
damongolding committed Jan 20, 2025
1 parent d948031 commit ffb331f
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 27 deletions.
25 changes: 14 additions & 11 deletions frontend/public/assets/css/kiosk.css
Original file line number Diff line number Diff line change
Expand Up @@ -1390,19 +1390,22 @@ form {
background-image: -moz-radial-gradient(50% 100%, 60% 50%, var(--fade-gradient));
background-image: radial-gradient(60% 50% at 50% 100%, var(--fade-gradient));
}
.polling-paused.redirects-open .redirects h2 {
color: #fff;
}
.polling-paused.redirects-open .redirects a {
display: block;
padding: 1.5rem 1rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
text-decoration: none;
color: #fff;
}
display: block;
padding: 1.5rem 1rem;
border-top: 1px solid rgba(255, 255, 255, 0.2);
text-decoration: none;
color: #fff;
}
.polling-paused.redirects-open .redirects a:hover,
.polling-paused.redirects-open .redirects a:focus {
background-color: var(--mint-green);
color: var(--cool-grey);
font-weight: bold;
}
.polling-paused.redirects-open .redirects a:focus {
background-color: var(--mint-green);
color: var(--cool-grey);
font-weight: bold;
}
.frameless.redirects-open #redirects-container {
margin: 0;
width: 100%;
Expand Down
30 changes: 18 additions & 12 deletions frontend/src/css/redirects.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,25 @@
}
}

.redirects a {
display: block;
padding: 1.5rem 1rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
text-decoration: none;
color: #fff;
}
.redirects {
h2 {
color: #fff;
}

a {
display: block;
padding: 1.5rem 1rem;
border-top: 1px solid rgba(255, 255, 255, 0.2);
text-decoration: none;
color: #fff;

.redirects a:hover,
.redirects a:focus {
background-color: var(--mint-green);
color: var(--cool-grey);
font-weight: bold;
&:hover,
&:focus {
background-color: var(--mint-green);
color: var(--cool-grey);
font-weight: bold;
}
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions internal/immich/immich_album.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func (i *ImmichAsset) allAlbums(requestID, deviceID string) (ImmichAlbums, strin
return i.albums(requestID, deviceID, false)
}

// allAlbums retrieves all non-shared albums from Immich.
func (i *ImmichAsset) AllAlbums(requestID, deviceID string) (ImmichAlbums, string, error) {
return i.albums(requestID, deviceID, false)
}

// albumAssets retrieves details and assets for a specific album from Immich.
// Parameters:
// - albumID: The ID of the album to fetch
Expand Down
5 changes: 3 additions & 2 deletions internal/templates/partials/menu.templ
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package partials

import (
"github.com/damongolding/immich-kiosk/internal/common"
"github.com/damongolding/immich-kiosk/internal/config"
"net/url"
)

templ Menu(showModeInfo bool, redirects []config.Redirect, queries url.Values) {
templ Menu(showModeInfo bool, redirects []config.Redirect, queries url.Values, viewData common.ViewData) {
<nav id="navigation-interaction-area">
<div
id="navigation-interaction-area--previous-image"
Expand All @@ -27,7 +28,7 @@ templ Menu(showModeInfo bool, redirects []config.Redirect, queries url.Values) {
</nav>
<div id="more-info" hx-swap-oob="true"></div>
if len(redirects) > 0 {
@Redirects(redirects, queries)
@Redirects(redirects, queries, viewData)
}
<nav class="navigation navigation-hidden">
<div class="navigation--media-buttons rounded">
Expand Down
33 changes: 32 additions & 1 deletion internal/templates/partials/redirects.templ
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
package partials

import (
"fmt"
"github.com/charmbracelet/log"
"github.com/damongolding/immich-kiosk/internal/common"
"github.com/damongolding/immich-kiosk/internal/config"
"github.com/damongolding/immich-kiosk/internal/immich"
"net/url"
)

templ Redirects(redirects []config.Redirect, queries url.Values) {
func allAlbums(viewData common.ViewData) immich.ImmichAlbums {
var albums immich.ImmichAlbums

i := immich.NewImage(viewData.Config)

albums, _, err := i.AllAlbums("", viewData.DeviceID)
if err != nil {
log.Error(err)
return albums
}

return albums
}

templ Redirects(redirects []config.Redirect, queries url.Values, viewData common.ViewData) {
<div id="redirects-container">
<div class="redirects">
<div class="redirects--shadow">
<h2>
Redirects
</h2>
if queries.Has("password") {
<a href={ templ.SafeURL("/?password=" + queries.Get("password")) }>Home</a>
}
Expand All @@ -19,6 +40,16 @@ templ Redirects(redirects []config.Redirect, queries url.Values) {
<a href={ templ.SafeURL(redirect.Name) }>{ redirect.Name }</a>
}
}
<h2>
Albums
</h2>
for _, album := range allAlbums(viewData) {
if queries.Has("password") {
<a href={ templ.SafeURL(fmt.Sprintf("/?album=%s&password=%s", album.ID, queries.Get("password"))) }>{ album.AlbumName } { fmt.Sprintf("Images: %v", album.AssetCount) }</a>
} else {
<a href={ templ.SafeURL(fmt.Sprintf("/?album=%s", album.ID)) }>{ album.AlbumName } { fmt.Sprintf("Images: %v", album.AssetCount) }</a>
}
}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion internal/templates/views/views_home.templ
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ templ Home(viewData common.ViewData) {
</div>
</section>
}
@partials.Menu(viewData.ShowMoreInfo, viewData.Kiosk.Redirects, viewData.Queries)
@partials.Menu(viewData.ShowMoreInfo, viewData.Kiosk.Redirects, viewData.Queries, viewData)
@partials.Params(viewData.Queries)
@partials.Sleep(viewData.SleepStart, viewData.SleepEnd, viewData.DisableSleep)
@partials.History()
Expand Down

0 comments on commit ffb331f

Please sign in to comment.