Add album name edit dialog #15
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
bfa2bc3cab
commit
c584a79a6f
9 changed files with 94 additions and 8 deletions
|
@ -25,6 +25,12 @@ Api.interceptors.request.use(function (config) {
|
|||
|
||||
Api.interceptors.response.use(function (response) {
|
||||
Notify.ajaxEnd();
|
||||
|
||||
if(typeof response.data == "string") {
|
||||
Notify.error("Request failed - invalid response");
|
||||
console.warn("WARNING: Server returned HTML instead of JSON - API not implemented?")
|
||||
}
|
||||
|
||||
return response;
|
||||
}, function (error) {
|
||||
Notify.ajaxEnd();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</div>
|
||||
</v-card-title>
|
||||
</v-card>
|
||||
<v-layout row wrap>
|
||||
<v-layout row wrap class="p-results">
|
||||
<v-flex
|
||||
v-for="(photo, index) in photos"
|
||||
:key="index"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
:headers="listColumns"
|
||||
:items="photos"
|
||||
hide-actions
|
||||
class="elevation-0 p-photos p-photo-list"
|
||||
class="elevation-0 p-photos p-photo-list p-results"
|
||||
disable-initial-sort
|
||||
item-key="ID"
|
||||
v-model="selected"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</div>
|
||||
</v-card-title>
|
||||
</v-card>
|
||||
<v-layout row wrap>
|
||||
<v-layout row wrap class="p-results">
|
||||
<v-flex
|
||||
v-for="(photo, index) in photos"
|
||||
:key="index"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</div>
|
||||
</v-card-title>
|
||||
</v-card>
|
||||
<v-layout row wrap>
|
||||
<v-layout row wrap class="p-results">
|
||||
<v-flex
|
||||
v-for="(photo, index) in photos"
|
||||
:key="index"
|
||||
|
|
|
@ -47,6 +47,15 @@ main {
|
|||
color: #00B8D4;
|
||||
}
|
||||
|
||||
#photoprism main .p-results a {
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
#photoprism main .p-inline-edit a {
|
||||
color: #333333;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
#photoprism main a.v-tabs__item {
|
||||
color: #546E7A;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</div>
|
||||
</v-card-title>
|
||||
</v-card>
|
||||
<v-layout row wrap>
|
||||
<v-layout row wrap class="p-results">
|
||||
<v-flex
|
||||
v-for="(album, index) in results"
|
||||
:key="index"
|
||||
|
@ -64,7 +64,31 @@
|
|||
</v-img>
|
||||
|
||||
<v-card-actions>
|
||||
{{ album.AlbumName | capitalize }}
|
||||
<v-edit-dialog
|
||||
:return-value.sync="album.AlbumName"
|
||||
lazy
|
||||
@save="onSave(album)"
|
||||
@cancel="onCancel"
|
||||
@open="onDialogOpen"
|
||||
@close="onDialogClose"
|
||||
class="p-inline-edit"
|
||||
>
|
||||
{{ album.AlbumName | capitalize }}
|
||||
<template v-slot:input>
|
||||
<div class="mt-3 title">Change Title</div>
|
||||
</template>
|
||||
<template v-slot:input>
|
||||
<v-text-field
|
||||
v-model="album.AlbumName"
|
||||
:rules="[titleRule]"
|
||||
label="Title"
|
||||
color="secondary-dark"
|
||||
single-line
|
||||
autofocus
|
||||
></v-text-field>
|
||||
</template>
|
||||
</v-edit-dialog>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn icon @click.stop.prevent="album.toggleLike()">
|
||||
<v-icon v-if="album.AlbumFavorite" color="#FFD600">star
|
||||
|
@ -116,6 +140,7 @@
|
|||
filter: filter,
|
||||
lastFilter: {},
|
||||
routeName: routeName,
|
||||
titleRule: v => v.length <= 25 || 'Title too long',
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
@ -230,6 +255,19 @@
|
|||
this.search();
|
||||
})
|
||||
},
|
||||
onSave (album) {
|
||||
console.log('onSave', album);
|
||||
album.update().then(() => this.$notify.success("All changes saved"));
|
||||
},
|
||||
onCancel () {
|
||||
console.log('onCancel', arguments)
|
||||
},
|
||||
onDialogOpen () {
|
||||
console.log('onDialogOpen', arguments)
|
||||
},
|
||||
onDialogClose () {
|
||||
console.log('onDialogClose', arguments)
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.search();
|
||||
|
|
|
@ -41,7 +41,7 @@ func GetAlbums(router *gin.RouterGroup, conf *config.Config) {
|
|||
})
|
||||
}
|
||||
|
||||
type CreateAlbumParams struct {
|
||||
type AlbumParams struct {
|
||||
AlbumName string `json:"AlbumName"`
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ func CreateAlbum(router *gin.RouterGroup, conf *config.Config) {
|
|||
return
|
||||
}
|
||||
|
||||
var params CreateAlbumParams
|
||||
var params AlbumParams
|
||||
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": util.UcFirst(err.Error())})
|
||||
|
@ -72,6 +72,38 @@ func CreateAlbum(router *gin.RouterGroup, conf *config.Config) {
|
|||
})
|
||||
}
|
||||
|
||||
// PUT /api/v1/albums/:uuid
|
||||
func UpdateAlbum(router *gin.RouterGroup, conf *config.Config) {
|
||||
router.PUT("/albums/:uuid", func(c *gin.Context) {
|
||||
if Unauthorized(c, conf) {
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, ErrUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
var params AlbumParams
|
||||
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": util.UcFirst(err.Error())})
|
||||
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
|
||||
}
|
||||
|
||||
m.AlbumName = params.AlbumName
|
||||
conf.Db().Save(&m)
|
||||
|
||||
c.JSON(http.StatusOK, m)
|
||||
})
|
||||
}
|
||||
|
||||
// POST /api/v1/albums/:uuid/like
|
||||
//
|
||||
// Parameters:
|
||||
|
|
|
@ -46,6 +46,7 @@ func registerRoutes(router *gin.Engine, conf *config.Config) {
|
|||
api.DislikeAlbum(v1, conf)
|
||||
api.AlbumThumbnail(v1, conf)
|
||||
api.CreateAlbum(v1, conf)
|
||||
api.UpdateAlbum(v1, conf)
|
||||
|
||||
api.GetSettings(v1, conf)
|
||||
api.SaveSettings(v1, conf)
|
||||
|
|
Loading…
Reference in a new issue