diff --git a/internal/api/albums.go b/internal/api/albums.go index 991d32153..2f730b468 100644 --- a/internal/api/albums.go +++ b/internal/api/albums.go @@ -81,7 +81,7 @@ func CreateAlbum(router *gin.RouterGroup, conf *config.Config) { return } - event.Success(fmt.Sprintf("Album %s created", m.AlbumName)) + event.Success(fmt.Sprintf("album \"%s\" created", m.AlbumName)) c.JSON(http.StatusOK, m) }) @@ -116,7 +116,34 @@ func UpdateAlbum(router *gin.RouterGroup, conf *config.Config) { conf.Db().Save(&m) event.Publish("config.updated", event.Data(conf.ClientConfig())) - event.Success(fmt.Sprintf("Album %s updated", m.AlbumName)) + event.Success(fmt.Sprintf("album \"%s\" updated", m.AlbumName)) + + c.JSON(http.StatusOK, m) + }) +} + +// DELETE /api/v1/albums/:uuid +func DeleteAlbum(router *gin.RouterGroup, conf *config.Config) { + router.DELETE("/albums/:uuid", func(c *gin.Context) { + if Unauthorized(c, conf) { + c.AbortWithStatusJSON(http.StatusUnauthorized, ErrUnauthorized) + return + } + + id := c.Param("uuid") + search := photoprism.NewSearch(conf.OriginalsPath(), conf.Db()) + + m, err := search.FindAlbumByUUID(id) + + if err != nil { + c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) + return + } + + conf.Db().Delete(&m) + + event.Publish("config.updated", event.Data(conf.ClientConfig())) + event.Success(fmt.Sprintf("album \"%s\" deleted", m.AlbumName)) c.JSON(http.StatusOK, m) }) diff --git a/internal/form/album.go b/internal/form/album.go index 2f885445c..9b0c6876c 100644 --- a/internal/form/album.go +++ b/internal/form/album.go @@ -1,5 +1,11 @@ package form type Album struct { - AlbumName string `json:"AlbumName"` + AlbumName string `json:"AlbumName"` + AlbumDescription string `json:"AlbumDescription"` + AlbumNotes string `json:"AlbumNotes"` + AlbumFavorite bool `json:"AlbumFavorite"` + AlbumPublic bool `json:"AlbumPublic"` + AlbumOrder string `json:"AlbumOrder"` + AlbumTemplate string `json:"AlbumTemplate"` } diff --git a/internal/photoprism/search.go b/internal/photoprism/search.go index f4ac2813a..651e75962 100644 --- a/internal/photoprism/search.go +++ b/internal/photoprism/search.go @@ -106,8 +106,6 @@ func (s *Search) Photos(f form.PhotoSearch) (results []PhotoSearchResult, err er q = q.Where("labels.label_slug = ? OR LOWER(photo_title) LIKE ? OR files.file_main_color = ?", slugString, likeString, lowerString) } else { - log.Infof("search: label \"%s\"", f.Query) - labelIds = append(labelIds, label.ID) s.db.Where("category_id = ?", label.ID).Find(&categories) @@ -116,6 +114,8 @@ func (s *Search) Photos(f form.PhotoSearch) (results []PhotoSearchResult, err er labelIds = append(labelIds, category.LabelID) } + log.Infof("search: label \"%s\" includes %d categories", label.LabelName, len(labelIds)) + q = q.Where("labels.id IN (?) OR LOWER(photo_title) LIKE ? OR files.file_main_color = ?", labelIds, likeString, lowerString) } @@ -358,7 +358,7 @@ func (s *Search) Labels(f form.LabelSearch) (results []LabelSearchResult, err er labelIds = append(labelIds, category.LabelID) } - log.Infof("search: labels %#v", f.Query) + log.Infof("search: label \"%s\" includes %d categories", label.LabelName, len(labelIds)) q = q.Where("labels.id IN (?) OR LOWER(labels.label_name) LIKE ?", labelIds, likeString) } diff --git a/internal/server/routes.go b/internal/server/routes.go index 0c81e547e..28e59dc86 100644 --- a/internal/server/routes.go +++ b/internal/server/routes.go @@ -45,12 +45,13 @@ func registerRoutes(router *gin.Engine, conf *config.Config) { api.BatchPhotosStory(v1, conf) api.GetAlbum(v1, conf) + api.CreateAlbum(v1, conf) + api.UpdateAlbum(v1, conf) + api.DeleteAlbum(v1, conf) api.GetAlbums(v1, conf) api.LikeAlbum(v1, conf) api.DislikeAlbum(v1, conf) api.AlbumThumbnail(v1, conf) - api.CreateAlbum(v1, conf) - api.UpdateAlbum(v1, conf) api.AddPhotosToAlbum(v1, conf) api.RemovePhotosFromAlbum(v1, conf)