Albums: Hide empty folder albums after re-indexing #684
This commit is contained in:
parent
94b990290b
commit
466a1bc3dd
12 changed files with 113 additions and 22 deletions
|
@ -59,7 +59,7 @@
|
|||
@click.stop="dialog.album = true"
|
||||
class="action-clone"
|
||||
>
|
||||
<v-icon>folder</v-icon>
|
||||
<v-icon>folder_special</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
fab dark small
|
||||
|
|
78
frontend/src/component/album/icon.vue
Normal file
78
frontend/src/component/album/icon.vue
Normal file
|
@ -0,0 +1,78 @@
|
|||
<template>
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 37.066 37.066" style="enable-background:new 0 0 37.066 37.066;" xml:space="preserve">
|
||||
<g style="fill: currentcolor">
|
||||
<path d="M36.786,12.556L15.787,2.525c-0.246-0.117-0.539-0.014-0.655,0.228l-4.569,9.565h2.488l3.357-7.03l18.204,8.697
|
||||
l-5.693,11.917l-3.203-1.533v6.301l1.967,0.942c0.246,0.116,0.539,0.012,0.654-0.232l8.682-18.171
|
||||
C37.133,12.966,37.032,12.672,36.786,12.556z"/>
|
||||
<path d="M23.764,13.473H0.492C0.221,13.473,0,13.693,0,13.962V34.1c0,0.271,0.221,0.49,0.492,0.49h23.272
|
||||
c0.273,0,0.49-0.219,0.49-0.49V13.962C24.254,13.693,24.038,13.473,23.764,13.473z M22.418,28.905H2.246V15.7h20.172
|
||||
C22.418,15.7,22.418,28.905,22.418,28.905z"/>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'album_icon',
|
||||
};
|
||||
</script>
|
|
@ -39,7 +39,7 @@
|
|||
@click.stop="dialog.album = true"
|
||||
class="action-album"
|
||||
>
|
||||
<v-icon>folder</v-icon>
|
||||
<v-icon>folder_special</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
@click.stop="dialog.album = true"
|
||||
class="action-album"
|
||||
>
|
||||
<v-icon>folder</v-icon>
|
||||
<v-icon>folder_special</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
fab dark small
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
|
||||
<v-list-tile v-if="mini" to="/albums" @click="" class="nav-albums">
|
||||
<v-list-tile-action>
|
||||
<v-icon>folder</v-icon>
|
||||
<v-icon>folder_special</v-icon>
|
||||
</v-list-tile-action>
|
||||
|
||||
<v-list-tile-content>
|
||||
|
@ -185,7 +185,7 @@
|
|||
</v-list-tile-content>
|
||||
</v-list-tile>
|
||||
|
||||
<v-list-group v-if="!mini" prepend-icon="folder" no-action>
|
||||
<v-list-group v-if="!mini" prepend-icon="folder_special" no-action>
|
||||
<v-list-tile slot="activator" to="/albums" @click.stop="" class="nav-albums">
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title>
|
||||
|
@ -195,15 +195,6 @@
|
|||
</v-list-tile-content>
|
||||
</v-list-tile>
|
||||
|
||||
<v-list-tile to="/folders" class="nav-folders">
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title>
|
||||
<translate key="Folders">Folders</translate>
|
||||
<span v-show="config.count.folders > 0"
|
||||
class="nav-count">{{ config.count.folders }}</span></v-list-tile-title>
|
||||
</v-list-tile-content>
|
||||
</v-list-tile>
|
||||
|
||||
<v-list-tile to="/unsorted" class="nav-unsorted">
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title>
|
||||
|
@ -213,6 +204,20 @@
|
|||
</v-list-tile>
|
||||
</v-list-group>
|
||||
|
||||
<v-list-tile :to="{ name: 'folders' }" @click="" class="nav-folders">
|
||||
<v-list-tile-action>
|
||||
<v-icon>folder</v-icon>
|
||||
</v-list-tile-action>
|
||||
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title>
|
||||
<translate key="Folders">Folders</translate>
|
||||
<span v-show="config.count.folders > 0"
|
||||
class="nav-count">{{ config.count.folders }}</span>
|
||||
</v-list-tile-title>
|
||||
</v-list-tile-content>
|
||||
</v-list-tile>
|
||||
|
||||
<v-list-tile :to="{ name: 'calendar' }" @click="" class="nav-calendar">
|
||||
<v-list-tile-action>
|
||||
<v-icon>date_range</v-icon>
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
v-if="context !== 'archive'"
|
||||
class="action-album"
|
||||
>
|
||||
<v-icon>folder</v-icon>
|
||||
<v-icon>folder_special</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
fab dark small
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<v-layout row wrap>
|
||||
<v-flex xs3 text-xs-center>
|
||||
<v-icon size="54" color="secondary-dark lighten-1" v-if="!album">create_new_folder</v-icon>
|
||||
<v-icon size="54" color="secondary-dark lighten-1" v-else>folder</v-icon>
|
||||
<v-icon size="54" color="secondary-dark lighten-1" v-else>folder_special</v-icon>
|
||||
</v-flex>
|
||||
<v-flex xs9 text-xs-left align-self-center>
|
||||
<v-autocomplete
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
class="v-chip--select-multi"
|
||||
@input="data.parent.selectItem(data.item)"
|
||||
>
|
||||
<v-icon class="pr-1">folder</v-icon>
|
||||
<v-icon class="pr-1">folder_special</v-icon>
|
||||
{{ data.item.Title ? data.item.Title : data.item | truncate(40) }}
|
||||
</v-chip>
|
||||
</template>
|
||||
|
|
|
@ -41,6 +41,7 @@ type Album struct {
|
|||
AlbumFilter string `gorm:"type:VARBINARY(1024);" json:"Filter" yaml:"Filter,omitempty"`
|
||||
AlbumOrder string `gorm:"type:VARBINARY(32);" json:"Order" yaml:"Order,omitempty"`
|
||||
AlbumTemplate string `gorm:"type:VARBINARY(255);" json:"Template" yaml:"Template,omitempty"`
|
||||
AlbumPath string `gorm:"type:VARBINARY(768);" json:"Path" yaml:"-"`
|
||||
AlbumCountry string `gorm:"type:VARBINARY(2);index:idx_albums_country_year_month;default:'zz'" json:"Country" yaml:"Country,omitempty"`
|
||||
AlbumYear int `gorm:"index:idx_albums_country_year_month;" json:"Year" yaml:"Year,omitempty"`
|
||||
AlbumMonth int `gorm:"index:idx_albums_country_year_month;" json:"Month" yaml:"Month,omitempty"`
|
||||
|
@ -118,7 +119,7 @@ func NewAlbum(albumTitle, albumType string) *Album {
|
|||
}
|
||||
|
||||
// NewFolderAlbum creates a new folder album.
|
||||
func NewFolderAlbum(albumTitle, albumSlug, albumFilter string) *Album {
|
||||
func NewFolderAlbum(albumTitle, albumSlug, albumPath, albumFilter string) *Album {
|
||||
if albumTitle == "" || albumSlug == "" || albumFilter == "" {
|
||||
return nil
|
||||
}
|
||||
|
@ -130,6 +131,7 @@ func NewFolderAlbum(albumTitle, albumSlug, albumFilter string) *Album {
|
|||
AlbumType: AlbumFolder,
|
||||
AlbumTitle: albumTitle,
|
||||
AlbumSlug: albumSlug,
|
||||
AlbumPath: albumPath,
|
||||
AlbumFilter: albumFilter,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
|
|
|
@ -165,7 +165,7 @@ func TestAddPhotoToAlbums(t *testing.T) {
|
|||
|
||||
func TestNewFolderAlbum(t *testing.T) {
|
||||
t.Run("name Christmas 2018", func(t *testing.T) {
|
||||
album := NewFolderAlbum("Dogs", "dogs", "label:dog")
|
||||
album := NewFolderAlbum("Dogs", "dogs", "dogs", "label:dog")
|
||||
assert.Equal(t, "Dogs", album.AlbumTitle)
|
||||
assert.Equal(t, "dogs", album.AlbumSlug)
|
||||
assert.Equal(t, AlbumFolder, album.AlbumType)
|
||||
|
@ -173,7 +173,7 @@ func TestNewFolderAlbum(t *testing.T) {
|
|||
assert.Equal(t, "label:dog", album.AlbumFilter)
|
||||
})
|
||||
t.Run("title empty", func(t *testing.T) {
|
||||
album := NewFolderAlbum("", "dogs", "label:dog")
|
||||
album := NewFolderAlbum("", "dogs", "dogs", "label:dog")
|
||||
assert.Nil(t, album)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -76,17 +76,19 @@ func (m *Moments) Start() (err error) {
|
|||
if a.DeletedAt != nil {
|
||||
// Nothing to do.
|
||||
log.Tracef("moments: %s was deleted (%s)", txt.Quote(a.AlbumTitle), a.AlbumFilter)
|
||||
} else if err := a.Update("AlbumPath", mom.Path); err != nil {
|
||||
log.Errorf("moments: %s (update folder album)", err.Error())
|
||||
} else {
|
||||
log.Tracef("moments: %s already exists (%s)", txt.Quote(a.AlbumTitle), a.AlbumFilter)
|
||||
}
|
||||
} else if a := entity.NewFolderAlbum(mom.Title(), mom.Slug(), f.Serialize()); a != nil {
|
||||
} else if a := entity.NewFolderAlbum(mom.Title(), mom.Slug(), mom.Path, f.Serialize()); a != nil {
|
||||
a.AlbumYear = mom.FolderYear
|
||||
a.AlbumMonth = mom.FolderMonth
|
||||
a.AlbumDay = mom.FolderDay
|
||||
a.AlbumCountry = mom.FolderCountry
|
||||
|
||||
if err := a.Create(); err != nil {
|
||||
log.Errorf("moments: %s", err)
|
||||
log.Errorf("moments: %s (create folder album)", err)
|
||||
} else {
|
||||
log.Infof("moments: added %s (%s)", txt.Quote(a.AlbumTitle), a.AlbumFilter)
|
||||
}
|
||||
|
@ -94,6 +96,8 @@ func (m *Moments) Start() (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// PhotoPath
|
||||
|
||||
// All years and months.
|
||||
if results, err := query.MomentsTime(1); err != nil {
|
||||
log.Errorf("moments: %s", err.Error())
|
||||
|
|
|
@ -28,6 +28,7 @@ type AlbumResult struct {
|
|||
AlbumFilter string `json:"Filter"`
|
||||
AlbumOrder string `json:"Order"`
|
||||
AlbumTemplate string `json:"Template"`
|
||||
AlbumPath string `json:"Path"`
|
||||
AlbumCountry string `json:"Country"`
|
||||
AlbumYear int `json:"Year"`
|
||||
AlbumMonth int `json:"Month"`
|
||||
|
@ -112,6 +113,7 @@ func AlbumSearch(f form.AlbumSearch) (results AlbumResults, err error) {
|
|||
Select("albums.*, cp.photo_count, cl.link_count").
|
||||
Joins("LEFT JOIN (SELECT album_uid, count(photo_uid) AS photo_count FROM photos_albums WHERE hidden = 0 GROUP BY album_uid) AS cp ON cp.album_uid = albums.album_uid").
|
||||
Joins("LEFT JOIN (SELECT share_uid, count(share_uid) AS link_count FROM links GROUP BY share_uid) AS cl ON cl.share_uid = albums.album_uid").
|
||||
Where("albums.album_type <> 'folder' OR albums.album_path IS NULL OR albums.album_path IN (SELECT photos.photo_path FROM photos WHERE photos.deleted_at IS NULL)").
|
||||
Where("albums.deleted_at IS NULL")
|
||||
|
||||
if f.ID != "" {
|
||||
|
|
Loading…
Reference in a new issue