Skip to content

Commit

Permalink
feat: add option to show all heatmaps in scene list (xbapps#1517)
Browse files Browse the repository at this point in the history
Co-authored-by: Alderamin <alderamin49ly@gmail.com>
  • Loading branch information
Alderamin49ly and Alderamin authored Nov 28, 2023
1 parent 764858f commit 8b2c1c8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
2 changes: 2 additions & 0 deletions pkg/api/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type RequestSaveOptionsWeb struct {
ShowSubtitlesFile bool `json:"showSubtitlesFile"`
SceneTrailerlist bool `json:"sceneTrailerlist"`
ShowScriptHeatmap bool `json:"showScriptHeatmap"`
ShowAllHeatmaps bool `json:"showAllHeatmaps"`
UpdateCheck bool `json:"updateCheck"`
IsAvailOpacity int `json:"isAvailOpacity"`
}
Expand Down Expand Up @@ -381,6 +382,7 @@ func (i ConfigResource) saveOptionsWeb(req *restful.Request, resp *restful.Respo
config.Config.Web.ShowSubtitlesFile = r.ShowSubtitlesFile
config.Config.Web.SceneTrailerlist = r.SceneTrailerlist
config.Config.Web.ShowScriptHeatmap = r.ShowScriptHeatmap
config.Config.Web.ShowAllHeatmaps = r.ShowAllHeatmaps
config.Config.Web.UpdateCheck = r.UpdateCheck
config.Config.Web.IsAvailOpacity = r.IsAvailOpacity
config.SaveConfig()
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type ObjectConfig struct {
ShowSubtitlesFile bool `default:"true" json:"showSubtitlesFile"`
SceneTrailerlist bool `default:"true" json:"sceneTrailerlist"`
ShowScriptHeatmap bool `default:"true" json:"showScriptHeatmap"`
ShowAllHeatmaps bool `default:"false" json:"showAllHeatmaps"`
UpdateCheck bool `default:"true" json:"updateCheck"`
IsAvailOpacity int `default:"40" json:"isAvailOpacity"`
} `json:"web"`
Expand Down
1 change: 1 addition & 0 deletions pkg/config/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type ObjectState struct {
ShowSubtitlesFile bool `json:"showSubtitlesFile"`
SceneTrailerlist bool `json:"sceneTrailerlist"`
ShowScriptHeatmap bool `json:"showScriptHeatmap"`
ShowAllHeatmaps bool `json:"showAllHeatmaps"`
UpdateCheck bool `json:"updateCheck"`
IsAvailOpacity int `json:"isAvailOpacity"`
} `json:"web"`
Expand Down
3 changes: 3 additions & 0 deletions ui/src/store/optionsWeb.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const state = {
updateCheck: true,
isAvailOpacity: 40,
showScriptHeatmap: false,
showAllHeatmaps: false,
updateCheck: true
}
}
Expand All @@ -43,6 +44,7 @@ const actions = {
state.web.showSubtitlesFile = data.config.web.showSubtitlesFile
state.web.sceneTrailerlist = data.config.web.sceneTrailerlist
state.web.showScriptHeatmap = data.config.web.showScriptHeatmap
state.web.showAllHeatmaps = data.config.web.showAllHeatmaps
state.web.updateCheck = data.config.web.updateCheck
state.web.isAvailOpacity = data.config.web.isAvailOpacity
state.loading = false
Expand All @@ -66,6 +68,7 @@ const actions = {
state.web.showSubtitlesFile = data.showSubtitlesFile
state.web.sceneTrailerlist = data.sceneTrailerlist
state.web.showScriptHeatmap = data.showScriptHeatmap
state.web.showAllHeatmaps = data.showAllHeatmaps
state.web.updateCheck = data.updateCheck
state.web.isAvailOpacity = data.isAvailOpacity
state.loading = false
Expand Down
13 changes: 13 additions & 0 deletions ui/src/views/options/sections/InterfaceWeb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
show Script Heatmap
</b-switch>
</b-field>
<b-field v-if="ScriptHeatmap">
<b-switch v-model="AllHeatmaps" type="is-dark">
show All Heatmaps
</b-switch>
</b-field>
<b-field label="Opacity of unavailable scenes">
<div class="columns">
<div class="column is-two-thirds">
Expand Down Expand Up @@ -188,6 +193,14 @@ export default {
this.$store.state.optionsWeb.web.showScriptHeatmap = value
}
},
AllHeatmaps: {
get () {
return this.$store.state.optionsWeb.web.showAllHeatmaps
},
set (value) {
this.$store.state.optionsWeb.web.showAllHeatmaps = value
}
},
updateCheck: {
get () {
return this.$store.state.optionsWeb.web.updateCheck
Expand Down
28 changes: 16 additions & 12 deletions ui/src/views/scenes/SceneCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
{{item.duration}}m
</b-tag>
</div>
<div v-if="this.$store.state.optionsWeb.web.showScriptHeatmap && (f = getFunscript())" style="padding: 0px 5px 5px">
<div v-if="f.has_heatmap" class="heatmapFunscript">
<img :src="getHeatmapURL(f.id)"/>
<div v-if="this.$store.state.optionsWeb.web.showScriptHeatmap && (files = getFunscripts(this.$store.state.optionsWeb.web.showAllHeatmaps))" style="padding: 0px 5px 5px">
<div v-if="files.length" class="heatmapFunscript">
<img v-for="file in files" :src="getHeatmapURL(file.id)"/>
</div>
</div>
</div>
Expand Down Expand Up @@ -168,17 +168,21 @@ export default {
getHeatmapURL (fileId) {
return `/api/dms/heatmap/${fileId}`
},
getFunscript() {
if (this.item.file !== null) {
let script;
if (script = this.item.file.find((a) => a.type === 'script' && a.has_heatmap && a.is_selected_script)) {
return script
}
if (script = this.item.file.find((a) => a.type === 'script' && a.has_heatmap)) {
return script
getFunscripts (showAll) {
if (showAll) {
return this.item.file !== null && this.item.file.filter(a => a.type === 'script' && a.has_heatmap);
} else {
if (this.item.file !== null) {
let script;
if (script = this.item.file.find((a) => a.type === 'script' && a.has_heatmap && a.is_selected_script)) {
return [script]
}
if (script = this.item.file.find((a) => a.type === 'script' && a.has_heatmap)) {
return [script]
}
}
return false;
}
return false;
}
}
}
Expand Down

0 comments on commit 8b2c1c8

Please sign in to comment.