diff --git a/apiGo/api/Settings.go b/apiGo/api/Settings.go index 59a1fd7..63210e4 100644 --- a/apiGo/api/Settings.go +++ b/apiGo/api/Settings.go @@ -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) diff --git a/apiGo/api/TVShows.go b/apiGo/api/TVShows.go index 20dae62..7969392 100644 --- a/apiGo/api/TVShows.go +++ b/apiGo/api/TVShows.go @@ -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 diff --git a/apiGo/database/settings/Settings.go b/apiGo/database/settings/Settings.go new file mode 100644 index 0000000..409a071 --- /dev/null +++ b/apiGo/database/settings/Settings.go @@ -0,0 +1,11 @@ +package settings + +var tvShowEnabled bool + +func TVShowsEnabled() bool { + return tvShowEnabled +} + +func SetTVShowEnabled(enabled bool) { + tvShowEnabled = enabled +} diff --git a/apiGo/main.go b/apiGo/main.go index 0b52cb2..80e138c 100644 --- a/apiGo/main.go +++ b/apiGo/main.go @@ -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, diff --git a/src/App.test.js b/src/App.test.js index 6d231a3..57f45ce 100644 --- a/src/App.test.js +++ b/src/App.test.js @@ -18,6 +18,11 @@ describe('', function () { it('are navlinks correct', function () { const wrapper = shallow(); wrapper.setState({password: false}); + expect(wrapper.find('.navitem')).toHaveLength(4); + + GlobalInfos.setTVShowsEnabled(true); + + wrapper.instance().forceUpdate(); expect(wrapper.find('.navitem')).toHaveLength(5); }); diff --git a/src/App.tsx b/src/App.tsx index 563d27f..db339d0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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> { Categories - - TV Shows - + + {GlobalInfos.isTVShowEnabled() ? ( + + TV Shows + + ) : null} + Settings @@ -168,24 +174,31 @@ class App extends React.Component<{}, state> { - - - - - - + + {GlobalInfos.isTVShowEnabled() ? ( + + + + ) : null} + + {GlobalInfos.isTVShowEnabled() ? ( + + + + ) : null} + diff --git a/src/pages/SettingsPage/SettingsPage.tsx b/src/pages/SettingsPage/SettingsPage.tsx index 9835e34..dac2d8b 100644 --- a/src/pages/SettingsPage/SettingsPage.tsx +++ b/src/pages/SettingsPage/SettingsPage.tsx @@ -22,9 +22,11 @@ class SettingsPage extends React.Component {
Movies
- -
TV Shows
-
+ {GlobalInfos.isTVShowEnabled() ? ( + +
TV Shows
+
+ ) : null}
@@ -34,9 +36,11 @@ class SettingsPage extends React.Component { - - - + {GlobalInfos.isTVShowEnabled() ? ( + + + + ) : null} diff --git a/src/types/ApiTypes.ts b/src/types/ApiTypes.ts index 882171f..3c80a26 100644 --- a/src/types/ApiTypes.ts +++ b/src/types/ApiTypes.ts @@ -36,6 +36,7 @@ export namespace SettingsTypes { MediacenterName: string; VideoPath: string; TVShowPath: string; + TVShowEnabled: boolean; } export interface loadGeneralSettingsType { diff --git a/src/utils/GlobalInfos.ts b/src/utils/GlobalInfos.ts index 72e13cc..c3a588b 100644 --- a/src/utils/GlobalInfos.ts +++ b/src/utils/GlobalInfos.ts @@ -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();