From ec0e76d0419fcd9c0e4ca2099e984d10674db6fd Mon Sep 17 00:00:00 2001 From: lukas Date: Sat, 24 Jul 2021 21:46:54 +0200 Subject: [PATCH] add some backend code for photopage --- apiGo/api/ApiBase.go | 10 +++++++++- apiGo/api/Photos.go | 15 +++++++++++++++ apiGo/main.go | 1 + src/pages/PhotoPage/PhotoPage.tsx | 18 +----------------- 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 apiGo/api/Photos.go diff --git a/apiGo/api/ApiBase.go b/apiGo/api/ApiBase.go index 5120559..45ae536 100644 --- a/apiGo/api/ApiBase.go +++ b/apiGo/api/ApiBase.go @@ -7,6 +7,7 @@ import ( "gopkg.in/oauth2.v3" "net/http" "openmediacenter/apiGo/api/oauth" + "openmediacenter/apiGo/database/settings" ) const APIPREFIX = "/api" @@ -17,6 +18,7 @@ const ( SettingsNode = iota ActorNode = iota TVShowNode = iota + PhotoNode = iota ) type HandlerInfo struct { @@ -47,7 +49,13 @@ func ServerInit() { http.Handle(APIPREFIX+"/tags", oauth.ValidateToken(handlefunc, TagNode)) http.Handle(APIPREFIX+"/settings", oauth.ValidateToken(handlefunc, SettingsNode)) http.Handle(APIPREFIX+"/actor", oauth.ValidateToken(handlefunc, ActorNode)) - http.Handle(APIPREFIX+"/tvshow", oauth.ValidateToken(handlefunc, TVShowNode)) + + // add tvshow endpoint only if tvshows enabled + if settings.TVShowsEnabled() { + http.Handle(APIPREFIX+"/tvshow", oauth.ValidateToken(handlefunc, TVShowNode)) + } + + http.Handle(APIPREFIX+"/photos", oauth.ValidateToken(handlefunc, PhotoNode)) // initialize oauth service and add corresponding auth routes oauth.InitOAuth() diff --git a/apiGo/api/Photos.go b/apiGo/api/Photos.go new file mode 100644 index 0000000..fd4eabe --- /dev/null +++ b/apiGo/api/Photos.go @@ -0,0 +1,15 @@ +package api + +func AddPhotoHandlers() { + /** + * @api {post} /api/photos [getPhotos] + * @apiDescription get all available pictures + * @apiName getPhotos + * @apiGroup Photos + * + * @apiSuccess {string} result 'success' if successfully or error message if not + */ + AddHandler("getPhotos", PhotoNode, func(info *HandlerInfo) []byte { + return nil + }) +} diff --git a/apiGo/main.go b/apiGo/main.go index 80e138c..d09f9a4 100644 --- a/apiGo/main.go +++ b/apiGo/main.go @@ -33,6 +33,7 @@ func main() { api.AddTagHandlers() api.AddActorsHandlers() api.AddTvshowHandlers() + api.AddPhotoHandlers() videoparser.SetupSettingsWebsocket() diff --git a/src/pages/PhotoPage/PhotoPage.tsx b/src/pages/PhotoPage/PhotoPage.tsx index 3ffedbe..c6ffc13 100644 --- a/src/pages/PhotoPage/PhotoPage.tsx +++ b/src/pages/PhotoPage/PhotoPage.tsx @@ -38,19 +38,6 @@ export function PhotoPage(): JSX.Element { target: '_blank' } } - }, - { - // HTML item: - itemId: 'htmlItem', - html: "
I am a text block
", - metadata: { - type: 'text', - height: 200, - width: 300, - title: 'sample-title', - description: 'sample-description', - backgroundColor: 'pink' - } } ]; @@ -73,16 +60,13 @@ export function PhotoPage(): JSX.Element { // The eventsListener will notify you anytime something has happened in the gallery. const eventsListener = (eventName: unknown, eventData: unknown): void => console.log({eventName, eventData}); - // The scrollingElement is usually the window, if you are scrolling inside another element, suplly it here - const scrollingElement = window; - return ( );