Skip to content

Commit

Permalink
feat: Add option to show heatmaps in the scene list (xbapps#1461)
Browse files Browse the repository at this point in the history
* Add script heatmap to scene list as toggleable option (#1)

* 'Improve' CSS

* Actually 'improved' CSS

* fix for some funscripts which fail to generate a heatmap
  • Loading branch information
peter23231 authored Nov 2, 2023
1 parent d82b55e commit 848f4ff
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 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 {
ShowHspFile bool `json:"showHspFile"`
ShowSubtitlesFile bool `json:"showSubtitlesFile"`
SceneTrailerlist bool `json:"sceneTrailerlist"`
ShowScriptHeatmap bool `json:"showScriptHeatmap"`
UpdateCheck bool `json:"updateCheck"`
}

Expand Down Expand Up @@ -379,6 +380,7 @@ func (i ConfigResource) saveOptionsWeb(req *restful.Request, resp *restful.Respo
config.Config.Web.ShowHspFile = r.ShowHspFile
config.Config.Web.ShowSubtitlesFile = r.ShowSubtitlesFile
config.Config.Web.SceneTrailerlist = r.SceneTrailerlist
config.Config.Web.ShowScriptHeatmap = r.ShowScriptHeatmap
config.Config.Web.UpdateCheck = r.UpdateCheck
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 @@ -41,6 +41,7 @@ type ObjectConfig struct {
ShowHspFile bool `default:"true" json:"showHspFile"`
ShowSubtitlesFile bool `default:"true" json:"showSubtitlesFile"`
SceneTrailerlist bool `default:"true" json:"sceneTrailerlist"`
ShowScriptHeatmap bool `default:"true" json:"showScriptHeatmap"`
UpdateCheck bool `default:"true" json:"updateCheck"`
} `json:"web"`
Advanced struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type ObjectState struct {
ShowHspFile bool `json:"showHspFile"`
ShowSubtitlesFile bool `json:"showSubtitlesFile"`
SceneTrailerlist bool `json:"sceneTrailerlist"`
ShowScriptHeatmap bool `json:"showScriptHeatmap"`
UpdateCheck bool `json:"updateCheck"`
} `json:"web"`
DLNA struct {
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 @@ -15,6 +15,7 @@ const state = {
showHspFile: true,
showSubtitlesFile: true,
sceneTrailerlist: true,
showScriptHeatmap: false,
updateCheck: true
}
}
Expand All @@ -39,6 +40,7 @@ const actions = {
state.web.showHspFile = data.config.web.showHspFile
state.web.showSubtitlesFile = data.config.web.showSubtitlesFile
state.web.sceneTrailerlist = data.config.web.sceneTrailerlist
state.web.showScriptHeatmap = data.config.web.showScriptHeatmap
state.web.updateCheck = data.config.web.updateCheck
state.loading = false
})
Expand All @@ -60,6 +62,7 @@ const actions = {
state.web.showHspFile = data.showHspFile
state.web.showSubtitlesFile = data.showSubtitlesFile
state.web.sceneTrailerlist = data.sceneTrailerlist
state.web.showScriptHeatmap = data.showScriptHeatmap
state.web.updateCheck = data.updateCheck
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 @@ -75,6 +75,11 @@
show subtitles File button
</b-switch>
</b-field>
<b-field>
<b-switch v-model="ScriptHeatmap" type="is-dark">
show Script Heatmap
</b-switch>
</b-field>

<b-field label="Automatically Check for Updates">
<b-switch v-model="updateCheck">
Expand Down Expand Up @@ -168,6 +173,14 @@ export default {
this.$store.state.optionsWeb.web.sceneEdit = value
}
},
ScriptHeatmap: {
get () {
return this.$store.state.optionsWeb.web.showScriptHeatmap
},
set (value) {
this.$store.state.optionsWeb.web.showScriptHeatmap = value
}
},
updateCheck: {
get () {
return this.$store.state.optionsWeb.web.updateCheck
Expand Down
25 changes: 25 additions & 0 deletions ui/src/views/scenes/SceneCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
{{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>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -153,6 +158,12 @@ export default {
this.$store.commit('overlay/showDetails', { scene: scene })
}
this.$store.commit('overlay/hideActorDetails')
},
getHeatmapURL (fileId) {
return `/api/dms/heatmap/${fileId}`
},
getFunscript () {
return this.item.file !== null && this.item.file.find(a => a.type === 'script' && a.has_heatmap);
}
}
}
Expand Down Expand Up @@ -204,6 +215,8 @@ export default {
.align-bottom-left {
align-items: flex-end;
justify-content: flex-end;
flex-wrap: wrap;
flex-direction: column
}
.bbox:after {
Expand All @@ -223,4 +236,16 @@ export default {
overflow: hidden;
text-overflow: ellipsis;
}
.heatmapFunscript {
width: auto;
}
.heatmapFunscript img {
border: 1px #888 solid;
width: 100%;
height: 15px;
border-radius: 0.25rem;
}
</style>

0 comments on commit 848f4ff

Please sign in to comment.