Skip to content

Commit

Permalink
Implement cuepoint deletion, add tooltips (#489)
Browse files Browse the repository at this point in the history
* Remove unused code

* Add tooltips

* Implement cuepoint deletion

* Sort cuepoints in DeoVR API
  • Loading branch information
lockedmouse authored May 23, 2021
1 parent ca65a6a commit 3227608
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 12 deletions.
4 changes: 4 additions & 0 deletions pkg/api/deovr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"sort"
"strconv"
"strings"

Expand Down Expand Up @@ -315,6 +316,9 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
Name: scene.Cuepoints[i].Name,
})
}
sort.Slice(cuepoints, func(i, j int) bool {
return cuepoints[i].TS < cuepoints[j].TS
})

if videoFiles[0].VideoProjection == "mkx200" ||
videoFiles[0].VideoProjection == "mkx220" ||
Expand Down
40 changes: 39 additions & 1 deletion pkg/api/scenes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/go-test/deep"
"github.com/jinzhu/gorm"
"github.com/xbapps/xbvr/pkg/tasks"

"github.com/blevesearch/bleve"
Expand Down Expand Up @@ -85,7 +86,11 @@ func (i SceneResource) WebService() *restful.WebService {
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(ResponseGetScenes{}))

ws.Route(ws.POST("/cuepoint/{scene-id}").To(i.addSceneCuepoint).
ws.Route(ws.POST("/{scene-id}/cuepoint").To(i.addSceneCuepoint).
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(models.Scene{}))

ws.Route(ws.DELETE("/{scene-id}/cuepoint/{cuepoint-id}").To(i.deleteSceneCuepoint).
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(models.Scene{}))

Expand Down Expand Up @@ -332,6 +337,39 @@ func (i SceneResource) addSceneCuepoint(req *restful.Request, resp *restful.Resp
resp.WriteHeaderAndEntity(http.StatusOK, scene)
}

func (i SceneResource) deleteSceneCuepoint(req *restful.Request, resp *restful.Response) {
sceneId, err := strconv.Atoi(req.PathParameter("scene-id"))
if err != nil {
log.Error(err)
return
}

cuepointId, err := strconv.Atoi(req.PathParameter("cuepoint-id"))
if err != nil {
log.Error(err)
return
}

db, _ := models.GetDB()

cuepoint := models.SceneCuepoint{}
err = db.First(&cuepoint, cuepointId).Error

if err == gorm.ErrRecordNotFound {
resp.WriteHeader(http.StatusNotFound)
return
}

db.Where("id = ? AND scene_id = ?", cuepointId, sceneId).Delete(models.SceneCuepoint{})
db.Delete(&cuepoint)

var scene models.Scene
err = scene.GetIfExistByPK(uint(sceneId))
defer db.Close()

resp.WriteHeaderAndEntity(http.StatusOK, scene)
}

func (i SceneResource) rateScene(req *restful.Request, resp *restful.Response) {
sceneId, err := strconv.Atoi(req.PathParameter("scene-id"))
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/EditButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<a class="button is-dark is-outlined is-small"
@click="editScene(item)">
@click="editScene(item)"
title="Edit scene details">
<b-icon pack="mdi" icon="lead-pencil" size="is-small" />
</a>
</template>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/FavouriteButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<a :class="buttonClass"
@click="$store.commit('sceneList/toggleSceneList', {scene_id: item.scene_id, list: 'favourite'})">
@click="$store.commit('sceneList/toggleSceneList', {scene_id: item.scene_id, list: 'favourite'})"
:title="item.favourite ? 'Remove from favourites' : 'Add to favourites'">
<b-icon pack="mdi" :icon="item.favourite ? 'heart' : 'heart-outline'" size="is-small"/>
</a>
</template>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/WatchlistButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<a :class="buttonClass"
@click="$store.commit('sceneList/toggleSceneList', {scene_id: item.scene_id, list: 'watchlist'})">
@click="$store.commit('sceneList/toggleSceneList', {scene_id: item.scene_id, list: 'watchlist'})"
:title="item.watchlist ? 'Remove from watchlist' : 'Add to watchlist'">
<b-icon pack="mdi" :icon="item.watchlist ? 'calendar-check' : 'calendar-blank'" size="is-small"/>
</a>
</template>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"Run selected scrapers": "Run selected scrapers",
"Never scraped": "Never scraped",
"Scraping now...": "Scraping now...",
"Scrape this site": "Scrape this site",
"Run this scraper": "Run this scraper",
"Force update scenes": "Force update scenes",
"JAVR scraper": "JAVR scraper",
"Go": "Go"
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/files/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>
</b-table-column>
<b-table-column style="white-space: nowrap;">
<button class="button is-danger is-outlined" @click='removeFile(props.row)'>
<button class="button is-danger is-outlined" @click='removeFile(props.row)' title='Delete file from disk'>
<b-icon pack="fas" icon="trash"></b-icon>
</button>
</b-table-column>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/options/sections/OptionsSceneDataScrapers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<b-icon icon="dots-vertical"></b-icon>
</template>
<b-dropdown-item aria-role="listitem" @click="taskScrape(item.id)">
{{$t('Scrape this site')}}
{{$t('Run this scraper')}}
</b-dropdown-item>
<b-dropdown-item aria-role="listitem" @click="forceSiteUpdate(item.name)">
{{$t('Force update scenes')}}
Expand Down
21 changes: 17 additions & 4 deletions ui/src/views/scenes/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@
<b-button @click="addCuepoint">Add cuepoint</b-button>
</b-field>
</div>
<div class="content is-small">
<div class="content cuepoint-list">
<ul>
<li v-for="(c, idx) in sortedCuepoints" :key="idx">
<code>{{ humanizeSeconds(c.time_start) }}</code> -
<a @click="playCuepoint(c)"><strong>{{ c.name }}</strong></a>
<button class="button is-danger is-outlined is-small" @click="deleteCuepoint(c)" title="Delete cuepoint">
<b-icon pack="fas" icon="trash" />
</button>
</li>
</ul>
</div>
Expand Down Expand Up @@ -192,7 +195,7 @@
<script>
import ky from 'ky'
import videojs from 'video.js'
import vr from 'videojs-vr/dist/videojs-vr.min.js'
import 'videojs-vr/dist/videojs-vr.min.js'
import { format, formatDistance, parseISO } from 'date-fns'
import prettyBytes from 'pretty-bytes'
import VueLoadImage from 'vue-load-image'
Expand Down Expand Up @@ -304,7 +307,7 @@ export default {
updatePlayer (src, projection) {
this.player.reset()
const vr = this.player.vr({
/* const vr = */ this.player.vr({
projection: projection,
forceCardboard: false
})
Expand Down Expand Up @@ -402,7 +405,7 @@ export default {
if (this.tagPosition !== '' && this.tagAct !== '') {
name = `${this.tagPosition}-${this.tagAct}`
}
ky.post(`/api/scene/cuepoint/${this.item.id}`, {
ky.post(`/api/scene/${this.item.id}/cuepoint`, {
json: {
name: name,
time_start: this.player.currentTime()
Expand All @@ -411,6 +414,12 @@ export default {
this.$store.commit('overlay/showDetails', { scene: data })
})
},
deleteCuepoint (cuepoint) {
ky.delete(`/api/scene/${this.item.id}/cuepoint/${cuepoint.id}`)
.json().then(data => {
this.$store.commit('overlay/showDetails', { scene: data })
})
},
close () {
this.player.dispose()
this.$store.commit('overlay/hideDetails')
Expand Down Expand Up @@ -563,6 +572,10 @@ span.is-active img {
color: #b0b0b0;
}
.cuepoint-list li > button {
margin-left: 7px;
}
.heatmapFunscript {
width: 100%;
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/scenes/SavedSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</optgroup>
</b-select>

<b-tooltip position="is-bottom" label="Save" :delay="200">
<b-tooltip position="is-bottom" label="Save as new" :delay="200">
<button class="button is-small is-outlined" @click="showNewDialog">
<b-icon pack="mdi" icon="content-save-outline"></b-icon>
</button>
Expand Down

0 comments on commit 3227608

Please sign in to comment.