mirror of
https://github.com/grocy/grocy.git
synced 2025-04-30 01:55:47 +00:00
Merge pull request #290 from nielstholenaar/master
Allow possibility to choose custom homepage
This commit is contained in:
commit
c6420a74ba
@ -46,13 +46,15 @@ Setting('STOCK_BARCODE_LOOKUP_PLUGIN', 'DemoBarcodeLookupPlugin');
|
||||
# set this to true
|
||||
Setting('DISABLE_URL_REWRITING', false);
|
||||
|
||||
# Specify an custom homepage if desired. By default the homepage will be set to the stock overview.
|
||||
# You can chosen one of the following values:
|
||||
# stock, shoppinglist, recipes, chores, tasks, batteries, equipment, calendar
|
||||
Setting('ENTRY_PAGE', 'stock');
|
||||
|
||||
# Set this to true if you want to disable authentication / the login screen,
|
||||
# places where user context is needed will then use the default (first existing) user
|
||||
Setting('DISABLE_AUTH', false);
|
||||
|
||||
|
||||
|
||||
|
||||
# Default user settings
|
||||
# These settings can be changed per user, here the defaults
|
||||
# are defined which are used when the user has not changed the setting so far
|
||||
|
@ -8,14 +8,14 @@ use \Grocy\Services\DemoDataGeneratorService;
|
||||
|
||||
class SystemController extends BaseController
|
||||
{
|
||||
protected $ApplicationService;
|
||||
|
||||
public function __construct(\Slim\Container $container)
|
||||
{
|
||||
parent::__construct($container);
|
||||
$this->ApplicationService = new ApplicationService();
|
||||
}
|
||||
|
||||
protected $ApplicationService;
|
||||
|
||||
public function Root(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
// Schema migration is done here
|
||||
@ -31,6 +31,64 @@ class SystemController extends BaseController
|
||||
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl($this->GetEntryPageRelative()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry page of the application based on the value of the entry page setting.
|
||||
*
|
||||
* We fallback to the about page when no entry page is specified or
|
||||
* when the specified entry page has been disabled.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function GetEntryPageRelative()
|
||||
{
|
||||
if (defined('GROCY_ENTRY_PAGE')) {
|
||||
$entryPage = constant('GROCY_ENTRY_PAGE');
|
||||
} else {
|
||||
$entryPage = 'stock';
|
||||
}
|
||||
|
||||
// Stock
|
||||
if ($entryPage === 'stock' && constant('GROCY_FEATURE_FLAG_STOCK')) {
|
||||
return '/stockoverview';
|
||||
}
|
||||
|
||||
// Shoppinglist
|
||||
if ($entryPage === 'shoppinglist' && constant('GROCY_FEATURE_FLAG_SHOPPINGLIST')) {
|
||||
return '/shoppinglist';
|
||||
}
|
||||
|
||||
// Recipes
|
||||
if ($entryPage === 'recipes' && constant('GROCY_FEATURE_FLAG_RECIPES')) {
|
||||
return '/recipes';
|
||||
}
|
||||
|
||||
// Chores
|
||||
if ($entryPage === 'chores' && constant('GROCY_FEATURE_FLAG_CHORES')) {
|
||||
return '/choresoverview';
|
||||
}
|
||||
|
||||
// Tasks
|
||||
if ($entryPage === 'tasks' && constant('GROCY_FEATURE_FLAG_TASKS')) {
|
||||
return '/tasks';
|
||||
}
|
||||
|
||||
// Batteries
|
||||
if ($entryPage === 'batteries' && constant('GROCY_FEATURE_FLAG_BATTERIES')) {
|
||||
return '/batteriesoverview';
|
||||
}
|
||||
|
||||
if ($entryPage === 'equipment' && constant('GROCY_FEATURE_FLAG_EQUIPMENT')) {
|
||||
return '/equipment';
|
||||
}
|
||||
|
||||
// Calendar
|
||||
if ($entryPage === 'calendar' && constant('GROCY_FEATURE_FLAG_CALENDAR')) {
|
||||
return '/calendar';
|
||||
}
|
||||
|
||||
return '/about';
|
||||
}
|
||||
|
||||
public function About(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'about', [
|
||||
@ -38,24 +96,4 @@ class SystemController extends BaseController
|
||||
'changelog' => $this->ApplicationService->GetChangelog()
|
||||
]);
|
||||
}
|
||||
|
||||
private function GetEntryPageRelative()
|
||||
{
|
||||
$entryPage = '/stockoverview';
|
||||
|
||||
if (!GROCY_FEATURE_FLAG_STOCK)
|
||||
{
|
||||
$entryPage = '/choresoverview';
|
||||
}
|
||||
if (!GROCY_FEATURE_FLAG_CHORES)
|
||||
{
|
||||
$entryPage = '/batteriesoverview';
|
||||
}
|
||||
if (!GROCY_FEATURE_FLAG_BATTERIES)
|
||||
{
|
||||
$entryPage = '/equipment';
|
||||
}
|
||||
|
||||
return $entryPage;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user