From 3227608dae63c1a720648e7d9e7999be4f4135a1 Mon Sep 17 00:00:00 2001
From: lockedmouse <51096617+lockedmouse@users.noreply.github.com>
Date: Sun, 23 May 2021 13:37:30 +0200
Subject: [PATCH] Implement cuepoint deletion, add tooltips (#489)
* Remove unused code
* Add tooltips
* Implement cuepoint deletion
* Sort cuepoints in DeoVR API
---
pkg/api/deovr.go | 4 ++
pkg/api/scenes.go | 40 ++++++++++++++++++-
ui/src/components/EditButton.vue | 3 +-
ui/src/components/FavouriteButton.vue | 3 +-
ui/src/components/WatchlistButton.vue | 3 +-
ui/src/locales/en-GB.json | 2 +-
ui/src/views/files/List.vue | 2 +-
.../sections/OptionsSceneDataScrapers.vue | 2 +-
ui/src/views/scenes/Details.vue | 21 ++++++++--
ui/src/views/scenes/SavedSearch.vue | 2 +-
10 files changed, 70 insertions(+), 12 deletions(-)
diff --git a/pkg/api/deovr.go b/pkg/api/deovr.go
index b83b566de..471a8cf62 100644
--- a/pkg/api/deovr.go
+++ b/pkg/api/deovr.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
+ "sort"
"strconv"
"strings"
@@ -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" ||
diff --git a/pkg/api/scenes.go b/pkg/api/scenes.go
index c8d35758d..87642d397 100644
--- a/pkg/api/scenes.go
+++ b/pkg/api/scenes.go
@@ -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"
@@ -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{}))
@@ -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 {
diff --git a/ui/src/components/EditButton.vue b/ui/src/components/EditButton.vue
index 72233213a..1066328c2 100644
--- a/ui/src/components/EditButton.vue
+++ b/ui/src/components/EditButton.vue
@@ -1,6 +1,7 @@
+ @click="editScene(item)"
+ title="Edit scene details">
diff --git a/ui/src/components/FavouriteButton.vue b/ui/src/components/FavouriteButton.vue
index bddc72f2f..248b27c7b 100644
--- a/ui/src/components/FavouriteButton.vue
+++ b/ui/src/components/FavouriteButton.vue
@@ -1,6 +1,7 @@
+ @click="$store.commit('sceneList/toggleSceneList', {scene_id: item.scene_id, list: 'favourite'})"
+ :title="item.favourite ? 'Remove from favourites' : 'Add to favourites'">
diff --git a/ui/src/components/WatchlistButton.vue b/ui/src/components/WatchlistButton.vue
index 58c190ccd..0faff808b 100644
--- a/ui/src/components/WatchlistButton.vue
+++ b/ui/src/components/WatchlistButton.vue
@@ -1,6 +1,7 @@
+ @click="$store.commit('sceneList/toggleSceneList', {scene_id: item.scene_id, list: 'watchlist'})"
+ :title="item.watchlist ? 'Remove from watchlist' : 'Add to watchlist'">
diff --git a/ui/src/locales/en-GB.json b/ui/src/locales/en-GB.json
index 432489897..1bf47f414 100644
--- a/ui/src/locales/en-GB.json
+++ b/ui/src/locales/en-GB.json
@@ -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"
diff --git a/ui/src/views/files/List.vue b/ui/src/views/files/List.vue
index b64277049..ad05310c9 100644
--- a/ui/src/views/files/List.vue
+++ b/ui/src/views/files/List.vue
@@ -49,7 +49,7 @@
-
diff --git a/ui/src/views/options/sections/OptionsSceneDataScrapers.vue b/ui/src/views/options/sections/OptionsSceneDataScrapers.vue
index 03386789c..2e8f5c6f8 100644
--- a/ui/src/views/options/sections/OptionsSceneDataScrapers.vue
+++ b/ui/src/views/options/sections/OptionsSceneDataScrapers.vue
@@ -38,7 +38,7 @@
- {{$t('Scrape this site')}}
+ {{$t('Run this scraper')}}
{{$t('Force update scenes')}}
diff --git a/ui/src/views/scenes/Details.vue b/ui/src/views/scenes/Details.vue
index 437964547..b10c4a302 100644
--- a/ui/src/views/scenes/Details.vue
+++ b/ui/src/views/scenes/Details.vue
@@ -140,11 +140,14 @@
Add cuepoint
-