Albums: Delete API #15
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
fa17ff59eb
commit
a32970a888
4 changed files with 42 additions and 8 deletions
|
@ -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)
|
||||
})
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue