Skip to content

Commit

Permalink
feat: add options to hide buttons in scene list (xbapps#738)
Browse files Browse the repository at this point in the history
* configure buttons in scene list

* load web option on first load

* match button color

Co-authored-by: crwxaj <crwxaj>
  • Loading branch information
crwxaj authored Jun 16, 2022
1 parent c451e9a commit 12fa731
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 15 deletions.
12 changes: 9 additions & 3 deletions pkg/api/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ type VersionCheckResponse struct {
}

type RequestSaveOptionsWeb struct {
TagSort string `json:"tagSort"`
SceneEdit bool `json:"sceneEdit"`
UpdateCheck bool `json:"updateCheck"`
TagSort string `json:"tagSort"`
SceneWatchlist bool `json:"sceneWatchlist"`
SceneFavourite bool `json:"sceneFavourite"`
SceneWatched bool `json:"sceneWatched"`
SceneEdit bool `json:"sceneEdit"`
UpdateCheck bool `json:"updateCheck"`
}

type RequestSaveOptionsDLNA struct {
Expand Down Expand Up @@ -229,6 +232,9 @@ func (i ConfigResource) saveOptionsWeb(req *restful.Request, resp *restful.Respo
}

config.Config.Web.TagSort = r.TagSort
config.Config.Web.SceneWatchlist = r.SceneWatchlist
config.Config.Web.SceneFavourite = r.SceneFavourite
config.Config.Web.SceneWatched = r.SceneWatched
config.Config.Web.SceneEdit = r.SceneEdit
config.Config.Web.UpdateCheck = r.UpdateCheck
config.SaveConfig()
Expand Down
9 changes: 6 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ type ObjectConfig struct {
Password string `default:"" json:"password"`
} `json:"security"`
Web struct {
TagSort string `default:"by-tag-count" json:"tagSort"`
SceneEdit bool `default:"false" json:"sceneEdit"`
UpdateCheck bool `default:"true" json:"updateCheck"`
TagSort string `default:"by-tag-count" json:"tagSort"`
SceneWatchlist bool `default:"true" json:"sceneWatchlist"`
SceneFavourite bool `default:"true" json:"sceneFavourite"`
SceneWatched bool `default:"false" json:"sceneWatched"`
SceneEdit bool `default:"false" json:"sceneEdit"`
UpdateCheck bool `default:"true" json:"updateCheck"`
} `json:"web"`
Vendor struct {
TPDB struct {
Expand Down
9 changes: 6 additions & 3 deletions pkg/config/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ type ObjectState struct {
BoundIP []string `json:"bound_ip"`
} `json:"server"`
Web struct {
TagSort string `json:"tagSort"`
SceneEdit bool `json:"sceneEdit"`
UpdateCheck bool `json:"updateCheck"`
TagSort string `json:"tagSort"`
SceneWatchlist bool `json:"sceneWatchlist"`
SceneFavourite bool `json:"sceneFavourite"`
SceneWatched bool `json:"sceneWatched"`
SceneEdit bool `json:"sceneEdit"`
UpdateCheck bool `json:"updateCheck"`
} `json:"web"`
DLNA struct {
Running bool `json:"running"`
Expand Down
9 changes: 9 additions & 0 deletions ui/src/store/optionsWeb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const state = {
loading: false,
web: {
tagSort: 'By Tag Count',
sceneWatchlist: true,
sceneFavourite: true,
sceneWatched: false,
sceneEdit: false,
updateCheck: true
}
Expand All @@ -18,6 +21,9 @@ const actions = {
.json()
.then(data => {
state.web.tagSort = data.config.web.tagSort
state.web.sceneWatchlist = data.config.web.sceneWatchlist
state.web.sceneFavourite = data.config.web.sceneFavourite
state.web.sceneWatched = data.config.web.sceneWatched
state.web.sceneEdit = data.config.web.sceneEdit
state.web.updateCheck = data.config.web.updateCheck
state.loading = false
Expand All @@ -29,6 +35,9 @@ const actions = {
.json()
.then(data => {
state.web.tagSort = data.tagSort
state.web.sceneWatchlist = data.sceneWatchlist
state.web.sceneFavourite = data.sceneFavourite
state.web.sceneWatched = data.sceneWatched
state.web.sceneEdit = data.sceneEdit
state.web.updateCheck = data.updateCheck
state.loading = false
Expand Down
47 changes: 44 additions & 3 deletions ui/src/views/options/sections/InterfaceWeb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,26 @@
</div>
</b-field>

<b-field label="Scene Edit in List">
<b-switch v-model="sceneEdit">
Enabled
<b-field label="Buttons in Scene List">
</b-field>
<b-field>
<b-switch v-model="sceneWatchlist" type="is-default">
show Add/Remove from Watchlist button
</b-switch>
</b-field>
<b-field>
<b-switch v-model="sceneFavourite" type="is-danger">
show Add/Remove from Favourites button
</b-switch>
</b-field>
<b-field>
<b-switch v-model="sceneWatched" type="is-dark">
show Toggle Watched Status button
</b-switch>
</b-field>
<b-field>
<b-switch v-model="sceneEdit" type="is-dark">
show Edit Scene button
</b-switch>
</b-field>

Expand Down Expand Up @@ -60,6 +77,30 @@ export default {
this.$store.state.optionsWeb.web.tagSort = value
}
},
sceneWatchlist: {
get () {
return this.$store.state.optionsWeb.web.sceneWatchlist
},
set (value) {
this.$store.state.optionsWeb.web.sceneWatchlist = value
}
},
sceneFavourite: {
get () {
return this.$store.state.optionsWeb.web.sceneFavourite
},
set (value) {
this.$store.state.optionsWeb.web.sceneFavourite = value
}
},
sceneWatched: {
get () {
return this.$store.state.optionsWeb.web.sceneWatched
},
set (value) {
this.$store.state.optionsWeb.web.sceneWatched = value
}
},
sceneEdit: {
get () {
return this.$store.state.optionsWeb.web.sceneEdit
Expand Down
9 changes: 6 additions & 3 deletions ui/src/views/scenes/SceneCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<video v-if="preview && item.has_preview" :src="`/api/dms/preview/${item.scene_id}`" autoplay loop></video>
<div class="overlay align-bottom-left">
<div style="padding: 5px">
<b-tag v-if="item.is_watched && !this.$store.state.optionsWeb.web.sceneWatched">
<b-icon pack="mdi" icon="eye" size="is-small"/>
</b-tag>
<b-tag type="is-info" v-if="videoFilesCount > 1 && !item.is_multipart">
<b-icon pack="mdi" icon="file" size="is-small" style="margin-right:0.1em"/>
{{videoFilesCount}}
Expand All @@ -29,9 +32,9 @@
<div style="padding-top:4px;">
<div class="scene_title">{{item.title}}</div>

<watchlist-button :item="item"/>
<favourite-button :item="item"/>
<watched-button :item="item"/>
<watchlist-button :item="item" v-if="this.$store.state.optionsWeb.web.sceneWatchlist"/>
<favourite-button :item="item" v-if="this.$store.state.optionsWeb.web.sceneFavourite"/>
<watched-button :item="item" v-if="this.$store.state.optionsWeb.web.sceneWatched"/>
<edit-button :item="item" v-if="this.$store.state.optionsWeb.web.sceneEdit" />

<span class="is-pulled-right" style="font-size:11px;text-align:right;">
Expand Down
1 change: 1 addition & 0 deletions ui/src/views/scenes/Scenes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default {
if (to.query !== undefined) {
vm.$store.commit('sceneList/stateFromQuery', to.query)
}
vm.$store.dispatch('optionsWeb/load')
vm.$store.dispatch('sceneList/load', { offset: 0 })
})
},
Expand Down

0 comments on commit 12fa731

Please sign in to comment.