make tvshow navlink and pages and backend disableable with a command line parameter

This commit is contained in:
lukas 2021-06-08 21:55:54 +02:00
parent f7b7df5934
commit a60f5a30b8
9 changed files with 72 additions and 15 deletions

View File

@ -53,6 +53,7 @@ func getSettingsFromDB() {
* @apiSuccess {string} MediacenterName overall name of the mediacenter * @apiSuccess {string} MediacenterName overall name of the mediacenter
* @apiSuccess {string} Pasword new server password (-1 if no password set) * @apiSuccess {string} Pasword new server password (-1 if no password set)
* @apiSuccess {bool} DarkMode Darkmode enabled? * @apiSuccess {bool} DarkMode Darkmode enabled?
* @apiSuccess {bool} TVShowEnabled is are TVShows enabled
*/ */
AddHandler("loadInitialData", SettingsNode, func(info *HandlerInfo) []byte { AddHandler("loadInitialData", SettingsNode, func(info *HandlerInfo) []byte {
sett := settings.LoadSettings() sett := settings.LoadSettings()
@ -63,6 +64,7 @@ func getSettingsFromDB() {
MediacenterName string MediacenterName string
VideoPath string VideoPath string
TVShowPath string TVShowPath string
TVShowEnabled bool
} }
regexMatchUrl := regexp.MustCompile("^http(|s)://([0-9]){1,3}\\.([0-9]){1,3}\\.([0-9]){1,3}\\.([0-9]){1,3}:[0-9]{1,5}") regexMatchUrl := regexp.MustCompile("^http(|s)://([0-9]){1,3}\\.([0-9]){1,3}\\.([0-9]){1,3}\\.([0-9]){1,3}:[0-9]{1,5}")
@ -77,6 +79,7 @@ func getSettingsFromDB() {
MediacenterName: sett.MediacenterName, MediacenterName: sett.MediacenterName,
VideoPath: serverVideoPath, VideoPath: serverVideoPath,
TVShowPath: serverTVShowPath, TVShowPath: serverTVShowPath,
TVShowEnabled: settings.TVShowsEnabled(),
} }
str, _ := json.Marshal(res) str, _ := json.Marshal(res)

View File

@ -3,9 +3,15 @@ package api
import ( import (
"fmt" "fmt"
"openmediacenter/apiGo/database" "openmediacenter/apiGo/database"
"openmediacenter/apiGo/database/settings"
) )
func AddTvshowHandlers() { func AddTvshowHandlers() {
// do not add handlers if tvshows not enabled
if !settings.TVShowsEnabled() {
return
}
/** /**
* @api {post} /api/tvshow [getTVShows] * @api {post} /api/tvshow [getTVShows]
* @apiDescription get all available tv shows * @apiDescription get all available tv shows

View File

@ -0,0 +1,11 @@
package settings
var tvShowEnabled bool
func TVShowsEnabled() bool {
return tvShowEnabled
}
func SetTVShowEnabled(enabled bool) {
tvShowEnabled = enabled
}

View File

@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"openmediacenter/apiGo/api" "openmediacenter/apiGo/api"
"openmediacenter/apiGo/database" "openmediacenter/apiGo/database"
settings2 "openmediacenter/apiGo/database/settings"
"openmediacenter/apiGo/static" "openmediacenter/apiGo/static"
"openmediacenter/apiGo/videoparser" "openmediacenter/apiGo/videoparser"
) )
@ -55,8 +56,12 @@ func handleCommandLineArguments() (*database.DatabaseConfig, bool, *string) {
pathPrefix := flag.String("ReindexPrefix", "/var/www/openmediacenter", "Prefix path for videos to reindex") pathPrefix := flag.String("ReindexPrefix", "/var/www/openmediacenter", "Prefix path for videos to reindex")
disableTVShowSupport := flag.Bool("DisableTVSupport", false, "Disable the TVShow support and pages")
flag.Parse() flag.Parse()
settings2.SetTVShowEnabled(!*disableTVShowSupport)
return &database.DatabaseConfig{ return &database.DatabaseConfig{
DBHost: *dbhostPtr, DBHost: *dbhostPtr,
DBPort: *dbPortPtr, DBPort: *dbPortPtr,

View File

@ -18,6 +18,11 @@ describe('<App/>', function () {
it('are navlinks correct', function () { it('are navlinks correct', function () {
const wrapper = shallow(<App/>); const wrapper = shallow(<App/>);
wrapper.setState({password: false}); wrapper.setState({password: false});
expect(wrapper.find('.navitem')).toHaveLength(4);
GlobalInfos.setTVShowsEnabled(true);
wrapper.instance().forceUpdate();
expect(wrapper.find('.navitem')).toHaveLength(5); expect(wrapper.find('.navitem')).toHaveLength(5);
}); });

View File

@ -86,6 +86,8 @@ class App extends React.Component<{}, state> {
GlobalInfos.setVideoPaths(result.VideoPath, result.TVShowPath); GlobalInfos.setVideoPaths(result.VideoPath, result.TVShowPath);
GlobalInfos.setTVShowsEnabled(result.TVShowEnabled);
this.setState({ this.setState({
mediacentername: result.MediacenterName mediacentername: result.MediacenterName
}); });
@ -146,9 +148,13 @@ class App extends React.Component<{}, state> {
<NavLink className={[style.navitem, themeStyle.navitem].join(' ')} to={'/categories'} activeStyle={{opacity: '0.85'}}> <NavLink className={[style.navitem, themeStyle.navitem].join(' ')} to={'/categories'} activeStyle={{opacity: '0.85'}}>
Categories Categories
</NavLink> </NavLink>
<NavLink className={[style.navitem, themeStyle.navitem].join(' ')} to={'/tvshows'} activeStyle={{opacity: '0.85'}}>
TV Shows {GlobalInfos.isTVShowEnabled() ? (
</NavLink> <NavLink className={[style.navitem, themeStyle.navitem].join(' ')} to={'/tvshows'} activeStyle={{opacity: '0.85'}}>
TV Shows
</NavLink>
) : null}
<NavLink className={[style.navitem, themeStyle.navitem].join(' ')} to={'/settings'} activeStyle={{opacity: '0.85'}}> <NavLink className={[style.navitem, themeStyle.navitem].join(' ')} to={'/settings'} activeStyle={{opacity: '0.85'}}>
Settings Settings
</NavLink> </NavLink>
@ -168,24 +174,31 @@ class App extends React.Component<{}, state> {
<Route path='/categories'> <Route path='/categories'>
<CategoryPage /> <CategoryPage />
</Route> </Route>
<Route path='/tvshows'>
<TVShowPage />
</Route>
<Route path='/settings'> <Route path='/settings'>
<SettingsPage /> <SettingsPage />
</Route> </Route>
<Route exact path='/player/:id'> <Route exact path='/player/:id'>
<Player /> <Player />
</Route> </Route>
<Route exact path='/tvplayer/:id'>
<TVPlayer />
</Route>
<Route exact path='/actors'> <Route exact path='/actors'>
<ActorOverviewPage /> <ActorOverviewPage />
</Route> </Route>
<Route path='/actors/:id'> <Route path='/actors/:id'>
<ActorPage /> <ActorPage />
</Route> </Route>
{GlobalInfos.isTVShowEnabled() ? (
<Route path='/tvshows'>
<TVShowPage />
</Route>
) : null}
{GlobalInfos.isTVShowEnabled() ? (
<Route exact path='/tvplayer/:id'>
<TVPlayer />
</Route>
) : null}
<Route path='/'> <Route path='/'>
<HomePage /> <HomePage />
</Route> </Route>

View File

@ -22,9 +22,11 @@ class SettingsPage extends React.Component {
<NavLink to='/settings/movies'> <NavLink to='/settings/movies'>
<div className={style.SettingSidebarElement}>Movies</div> <div className={style.SettingSidebarElement}>Movies</div>
</NavLink> </NavLink>
<NavLink to='/settings/tv'> {GlobalInfos.isTVShowEnabled() ? (
<div className={style.SettingSidebarElement}>TV Shows</div> <NavLink to='/settings/tv'>
</NavLink> <div className={style.SettingSidebarElement}>TV Shows</div>
</NavLink>
) : null}
</div> </div>
<div className={style.SettingsContent}> <div className={style.SettingsContent}>
<Switch> <Switch>
@ -34,9 +36,11 @@ class SettingsPage extends React.Component {
<Route path='/settings/movies'> <Route path='/settings/movies'>
<MovieSettings /> <MovieSettings />
</Route> </Route>
<Route path='/settings/tv'> {GlobalInfos.isTVShowEnabled() ? (
<span /> <Route path='/settings/tv'>
</Route> <span />
</Route>
) : null}
<Route path='/settings'> <Route path='/settings'>
<Redirect to='/settings/general' /> <Redirect to='/settings/general' />
</Route> </Route>

View File

@ -36,6 +36,7 @@ export namespace SettingsTypes {
MediacenterName: string; MediacenterName: string;
VideoPath: string; VideoPath: string;
TVShowPath: string; TVShowPath: string;
TVShowEnabled: boolean;
} }
export interface loadGeneralSettingsType { export interface loadGeneralSettingsType {

View File

@ -9,6 +9,7 @@ class StaticInfos {
private darktheme: boolean = true; private darktheme: boolean = true;
private videopath: string = ''; private videopath: string = '';
private tvshowpath: string = ''; private tvshowpath: string = '';
private TVShowsEnabled: boolean = false;
/** /**
* check if the current theme is the dark theme * check if the current theme is the dark theme
@ -71,6 +72,14 @@ class StaticInfos {
* load the Password page manually * load the Password page manually
*/ */
loadPasswordPage: ((callback?: () => void) => void) | undefined = undefined; loadPasswordPage: ((callback?: () => void) => void) | undefined = undefined;
setTVShowsEnabled(TVShowEnabled: boolean): void {
this.TVShowsEnabled = TVShowEnabled;
}
isTVShowEnabled(): boolean {
return this.TVShowsEnabled;
}
} }
export default new StaticInfos(); export default new StaticInfos();