add some backend code for photopage

This commit is contained in:
lukas 2021-07-24 21:46:54 +02:00
parent f480df1e1b
commit ec0e76d041
4 changed files with 26 additions and 18 deletions

View File

@ -7,6 +7,7 @@ import (
"gopkg.in/oauth2.v3" "gopkg.in/oauth2.v3"
"net/http" "net/http"
"openmediacenter/apiGo/api/oauth" "openmediacenter/apiGo/api/oauth"
"openmediacenter/apiGo/database/settings"
) )
const APIPREFIX = "/api" const APIPREFIX = "/api"
@ -17,6 +18,7 @@ const (
SettingsNode = iota SettingsNode = iota
ActorNode = iota ActorNode = iota
TVShowNode = iota TVShowNode = iota
PhotoNode = iota
) )
type HandlerInfo struct { type HandlerInfo struct {
@ -47,7 +49,13 @@ func ServerInit() {
http.Handle(APIPREFIX+"/tags", oauth.ValidateToken(handlefunc, TagNode)) http.Handle(APIPREFIX+"/tags", oauth.ValidateToken(handlefunc, TagNode))
http.Handle(APIPREFIX+"/settings", oauth.ValidateToken(handlefunc, SettingsNode)) http.Handle(APIPREFIX+"/settings", oauth.ValidateToken(handlefunc, SettingsNode))
http.Handle(APIPREFIX+"/actor", oauth.ValidateToken(handlefunc, ActorNode)) http.Handle(APIPREFIX+"/actor", oauth.ValidateToken(handlefunc, ActorNode))
// add tvshow endpoint only if tvshows enabled
if settings.TVShowsEnabled() {
http.Handle(APIPREFIX+"/tvshow", oauth.ValidateToken(handlefunc, TVShowNode)) http.Handle(APIPREFIX+"/tvshow", oauth.ValidateToken(handlefunc, TVShowNode))
}
http.Handle(APIPREFIX+"/photos", oauth.ValidateToken(handlefunc, PhotoNode))
// initialize oauth service and add corresponding auth routes // initialize oauth service and add corresponding auth routes
oauth.InitOAuth() oauth.InitOAuth()

15
apiGo/api/Photos.go Normal file
View File

@ -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
})
}

View File

@ -33,6 +33,7 @@ func main() {
api.AddTagHandlers() api.AddTagHandlers()
api.AddActorsHandlers() api.AddActorsHandlers()
api.AddTvshowHandlers() api.AddTvshowHandlers()
api.AddPhotoHandlers()
videoparser.SetupSettingsWebsocket() videoparser.SetupSettingsWebsocket()

View File

@ -38,19 +38,6 @@ export function PhotoPage(): JSX.Element {
target: '_blank' target: '_blank'
} }
} }
},
{
// HTML item:
itemId: 'htmlItem',
html: "<div style='width: 300px; height: 200px; background:pink;'>I am a text block</div>",
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. // The eventsListener will notify you anytime something has happened in the gallery.
const eventsListener = (eventName: unknown, eventData: unknown): void => console.log({eventName, eventData}); 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 ( return (
<ExpandableProGallery <ExpandableProGallery
items={items} items={items}
options={options} options={options}
container={container} container={container}
eventsListener={eventsListener} eventsListener={eventsListener}
scrollingElement={scrollingElement} scrollingElement={window}
viewMode={1} viewMode={1}
/> />
); );