Merge branch 'disableableTVShowNav' into 'master'

tVShows navlink and pages optionally disabled

See merge request lukas/openmediacenter!48
This commit is contained in:
Lukas Heiligenbrunner 2021-06-14 19:37:04 +00:00
commit 95a6a4d407
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} Pasword new server password (-1 if no password set)
* @apiSuccess {bool} DarkMode Darkmode enabled?
* @apiSuccess {bool} TVShowEnabled is are TVShows enabled
*/
AddHandler("loadInitialData", SettingsNode, func(info *HandlerInfo) []byte {
sett := settings.LoadSettings()
@ -63,6 +64,7 @@ func getSettingsFromDB() {
MediacenterName string
VideoPath 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}")
@ -77,6 +79,7 @@ func getSettingsFromDB() {
MediacenterName: sett.MediacenterName,
VideoPath: serverVideoPath,
TVShowPath: serverTVShowPath,
TVShowEnabled: settings.TVShowsEnabled(),
}
str, _ := json.Marshal(res)

View File

@ -3,9 +3,15 @@ package api
import (
"fmt"
"openmediacenter/apiGo/database"
"openmediacenter/apiGo/database/settings"
)
func AddTvshowHandlers() {
// do not add handlers if tvshows not enabled
if !settings.TVShowsEnabled() {
return
}
/**
* @api {post} /api/tvshow [getTVShows]
* @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"
"openmediacenter/apiGo/api"
"openmediacenter/apiGo/database"
settings2 "openmediacenter/apiGo/database/settings"
"openmediacenter/apiGo/static"
"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")
disableTVShowSupport := flag.Bool("DisableTVSupport", false, "Disable the TVShow support and pages")
flag.Parse()
settings2.SetTVShowEnabled(!*disableTVShowSupport)
return &database.DatabaseConfig{
DBHost: *dbhostPtr,
DBPort: *dbPortPtr,

View File

@ -18,6 +18,11 @@ describe('<App/>', function () {
it('are navlinks correct', function () {
const wrapper = shallow(<App/>);
wrapper.setState({password: false});
expect(wrapper.find('.navitem')).toHaveLength(4);
GlobalInfos.setTVShowsEnabled(true);
wrapper.instance().forceUpdate();
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.setTVShowsEnabled(result.TVShowEnabled);
this.setState({
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'}}>
Categories
</NavLink>
{GlobalInfos.isTVShowEnabled() ? (
<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'}}>
Settings
</NavLink>
@ -168,24 +174,31 @@ class App extends React.Component<{}, state> {
<Route path='/categories'>
<CategoryPage />
</Route>
<Route path='/tvshows'>
<TVShowPage />
</Route>
<Route path='/settings'>
<SettingsPage />
</Route>
<Route exact path='/player/:id'>
<Player />
</Route>
<Route exact path='/tvplayer/:id'>
<TVPlayer />
</Route>
<Route exact path='/actors'>
<ActorOverviewPage />
</Route>
<Route path='/actors/:id'>
<ActorPage />
</Route>
{GlobalInfos.isTVShowEnabled() ? (
<Route path='/tvshows'>
<TVShowPage />
</Route>
) : null}
{GlobalInfos.isTVShowEnabled() ? (
<Route exact path='/tvplayer/:id'>
<TVPlayer />
</Route>
) : null}
<Route path='/'>
<HomePage />
</Route>

View File

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

View File

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

View File

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