Added feature flags to disable/hide parts not needed (closes #157)

grocy was initally about stock management, so this is always enabled, the rest can be disabled
This commit is contained in:
Bernd Bestel 2019-03-01 19:33:33 +01:00
parent 9974305ad4
commit 32e878afc9
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
4 changed files with 122 additions and 40 deletions

View File

@ -41,6 +41,8 @@ Setting('STOCK_BARCODE_LOOKUP_PLUGIN', 'DemoBarcodeLookupPlugin');
Setting('DISABLE_URL_REWRITING', 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
@ -67,3 +69,19 @@ DefaultUserSetting('show_clock_in_header', false);
# Automatically do the booking using the last price and the amount
# of the shopping list item, if the product has "Default best before days" set
DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false);
# Feature flags
# grocy was initially about "stock management for your household", many other things
# came and still come by, because they are useful - here you can disable the parts
# which you don't need to have a less cluttered UI
# (set the setting to "false" to disable the corresponding part, which should be self explanatory)
Setting('FEATURE_FLAG_SHOPPINGLIST', true);
Setting('FEATURE_FLAG_RECIPES', true);
Setting('FEATURE_FLAG_CHORES', true);
Setting('FEATURE_FLAG_TASKS', true);
Setting('FEATURE_FLAG_BATTERIES', true);
Setting('FEATURE_FLAG_EQUIPMENT', true);
Setting('FEATURE_FLAG_CALENDAR', true);

View File

@ -34,43 +34,64 @@ $app->group('', function()
$this->get('/quantityunit/{quantityunitId}', '\Grocy\Controllers\StockController:QuantityUnitEditForm');
$this->get('/productgroups', '\Grocy\Controllers\StockController:ProductGroupsList');
$this->get('/productgroup/{productGroupId}', '\Grocy\Controllers\StockController:ProductGroupEditForm');
$this->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList');
$this->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm');
$this->get('/stockjournal', '\Grocy\Controllers\StockController:Journal');
// Shopping list routes
if (GROCY_FEATURE_FLAG_SHOPPINGLIST)
{
$this->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList');
$this->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm');
}
// Recipe routes
$this->get('/recipes', '\Grocy\Controllers\RecipesController:Overview');
$this->get('/recipe/{recipeId}', '\Grocy\Controllers\RecipesController:RecipeEditForm');
$this->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm');
if (GROCY_FEATURE_FLAG_RECIPES)
{
$this->get('/recipes', '\Grocy\Controllers\RecipesController:Overview');
$this->get('/recipe/{recipeId}', '\Grocy\Controllers\RecipesController:RecipeEditForm');
$this->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm');
}
// Chore routes
$this->get('/choresoverview', '\Grocy\Controllers\ChoresController:Overview');
$this->get('/choretracking', '\Grocy\Controllers\ChoresController:TrackChoreExecution');
$this->get('/choresjournal', '\Grocy\Controllers\ChoresController:Journal');
$this->get('/chores', '\Grocy\Controllers\ChoresController:ChoresList');
$this->get('/chore/{choreId}', '\Grocy\Controllers\ChoresController:ChoreEditForm');
if (GROCY_FEATURE_FLAG_CHORES)
{
$this->get('/choresoverview', '\Grocy\Controllers\ChoresController:Overview');
$this->get('/choretracking', '\Grocy\Controllers\ChoresController:TrackChoreExecution');
$this->get('/choresjournal', '\Grocy\Controllers\ChoresController:Journal');
$this->get('/chores', '\Grocy\Controllers\ChoresController:ChoresList');
$this->get('/chore/{choreId}', '\Grocy\Controllers\ChoresController:ChoreEditForm');
}
// Battery routes
$this->get('/batteriesoverview', '\Grocy\Controllers\BatteriesController:Overview');
$this->get('/batterytracking', '\Grocy\Controllers\BatteriesController:TrackChargeCycle');
$this->get('/batteriesjournal', '\Grocy\Controllers\BatteriesController:Journal');
$this->get('/batteries', '\Grocy\Controllers\BatteriesController:BatteriesList');
$this->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm');
if (GROCY_FEATURE_FLAG_BATTERIES)
{
$this->get('/batteriesoverview', '\Grocy\Controllers\BatteriesController:Overview');
$this->get('/batterytracking', '\Grocy\Controllers\BatteriesController:TrackChargeCycle');
$this->get('/batteriesjournal', '\Grocy\Controllers\BatteriesController:Journal');
$this->get('/batteries', '\Grocy\Controllers\BatteriesController:BatteriesList');
$this->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm');
}
// Task routes
$this->get('/tasks', '\Grocy\Controllers\TasksController:Overview');
$this->get('/task/{taskId}', '\Grocy\Controllers\TasksController:TaskEditForm');
$this->get('/taskcategories', '\Grocy\Controllers\TasksController:TaskCategoriesList');
$this->get('/taskcategory/{categoryId}', '\Grocy\Controllers\TasksController:TaskCategoryEditForm');
if (GROCY_FEATURE_FLAG_TASKS)
{
$this->get('/tasks', '\Grocy\Controllers\TasksController:Overview');
$this->get('/task/{taskId}', '\Grocy\Controllers\TasksController:TaskEditForm');
$this->get('/taskcategories', '\Grocy\Controllers\TasksController:TaskCategoriesList');
$this->get('/taskcategory/{categoryId}', '\Grocy\Controllers\TasksController:TaskCategoryEditForm');
}
// Equipment routes
$this->get('/equipment', '\Grocy\Controllers\EquipmentController:Overview');
$this->get('/equipment/{equipmentId}', '\Grocy\Controllers\EquipmentController:EditForm');
// Other routes
$this->get('/calendar', '\Grocy\Controllers\CalendarController:Overview');
if (GROCY_FEATURE_FLAG_EQUIPMENT)
{
$this->get('/equipment', '\Grocy\Controllers\EquipmentController:Overview');
$this->get('/equipment/{equipmentId}', '\Grocy\Controllers\EquipmentController:EditForm');
}
// Calendar routes
if (GROCY_FEATURE_FLAG_CALENDAR)
{
$this->get('/calendar', '\Grocy\Controllers\CalendarController:Overview');
}
// OpenAPI routes
$this->get('/api', '\Grocy\Controllers\OpenApiController:DocumentationUi');
@ -120,30 +141,47 @@ $app->group('/api', function()
$this->post('/stock/products/{productId}/consume', '\Grocy\Controllers\StockApiController:ConsumeProduct');
$this->post('/stock/products/{productId}/inventory', '\Grocy\Controllers\StockApiController:InventoryProduct');
$this->post('/stock/products/{productId}/open', '\Grocy\Controllers\StockApiController:OpenProduct');
$this->post('/stock/shoppinglist/add-missing-products', '\Grocy\Controllers\StockApiController:AddMissingProductsToShoppingList');
$this->post('/stock/shoppinglist/clear', '\Grocy\Controllers\StockApiController:ClearShoppingList');
$this->post('/stock/bookings/{bookingId}/undo', '\Grocy\Controllers\StockApiController:UndoBooking');
$this->get('/stock/barcodes/external-lookup', '\Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
// Shopping list
if (GROCY_FEATURE_FLAG_SHOPPINGLIST)
{
$this->post('/stock/shoppinglist/add-missing-products', '\Grocy\Controllers\StockApiController:AddMissingProductsToShoppingList');
$this->post('/stock/shoppinglist/clear', '\Grocy\Controllers\StockApiController:ClearShoppingList');
}
// Recipes
$this->post('/recipes/{recipeId}/add-not-fulfilled-products-to-shoppinglist', '\Grocy\Controllers\RecipesApiController:AddNotFulfilledProductsToShoppingList');
$this->post('/recipes/{recipeId}/consume', '\Grocy\Controllers\RecipesApiController:ConsumeRecipe');
if (GROCY_FEATURE_FLAG_RECIPES)
{
$this->post('/recipes/{recipeId}/add-not-fulfilled-products-to-shoppinglist', '\Grocy\Controllers\RecipesApiController:AddNotFulfilledProductsToShoppingList');
$this->post('/recipes/{recipeId}/consume', '\Grocy\Controllers\RecipesApiController:ConsumeRecipe');
}
// Chores
$this->get('/chores', '\Grocy\Controllers\ChoresApiController:Current');
$this->get('/chores/{choreId}', '\Grocy\Controllers\ChoresApiController:ChoreDetails');
$this->post('/chores/{choreId}/execute', '\Grocy\Controllers\ChoresApiController:TrackChoreExecution');
$this->post('/chores/executions/{executionId}/undo', '\Grocy\Controllers\ChoresApiController:UndoChoreExecution');
if (GROCY_FEATURE_FLAG_CHORES)
{
$this->get('/chores', '\Grocy\Controllers\ChoresApiController:Current');
$this->get('/chores/{choreId}', '\Grocy\Controllers\ChoresApiController:ChoreDetails');
$this->post('/chores/{choreId}/execute', '\Grocy\Controllers\ChoresApiController:TrackChoreExecution');
$this->post('/chores/executions/{executionId}/undo', '\Grocy\Controllers\ChoresApiController:UndoChoreExecution');
}
// Batteries
$this->get('/batteries', '\Grocy\Controllers\BatteriesApiController:Current');
$this->get('/batteries/{batteryId}', '\Grocy\Controllers\BatteriesApiController:BatteryDetails');
$this->post('/batteries/{batteryId}/charge', '\Grocy\Controllers\BatteriesApiController:TrackChargeCycle');
$this->post('/batteries/charge-cycles/{chargeCycleId}/undo', '\Grocy\Controllers\BatteriesApiController:UndoChargeCycle');
if (GROCY_FEATURE_FLAG_BATTERIES)
{
$this->get('/batteries', '\Grocy\Controllers\BatteriesApiController:Current');
$this->get('/batteries/{batteryId}', '\Grocy\Controllers\BatteriesApiController:BatteryDetails');
$this->post('/batteries/{batteryId}/charge', '\Grocy\Controllers\BatteriesApiController:TrackChargeCycle');
$this->post('/batteries/charge-cycles/{chargeCycleId}/undo', '\Grocy\Controllers\BatteriesApiController:UndoChargeCycle');
}
// Tasks
$this->get('/tasks', '\Grocy\Controllers\TasksApiController:Current');
$this->post('/tasks/{taskId}/complete', '\Grocy\Controllers\TasksApiController:MarkTaskAsCompleted');
if (GROCY_FEATURE_FLAG_TASKS)
{
$this->get('/tasks', '\Grocy\Controllers\TasksApiController:Current');
$this->post('/tasks/{taskId}/complete', '\Grocy\Controllers\TasksApiController:MarkTaskAsCompleted');
}
})->add(new ApiKeyAuthMiddleware($appContainer, $appContainer->LoginControllerInstance->GetSessionCookieName(), $appContainer->ApiKeyHeaderName))
->add(JsonMiddleware::class)
->add(new CorsMiddleware([

View File

@ -69,42 +69,54 @@
<span class="nav-link-text">{{ $L('Stock overview') }}</span>
</a>
</li>
@if(GROCY_FEATURE_FLAG_SHOPPINGLIST)
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Shopping list') }}" data-nav-for-page="shoppinglist">
<a class="nav-link discrete-link" href="{{ $U('/shoppinglist') }}">
<i class="fas fa-shopping-cart"></i>
<span class="nav-link-text">{{ $L('Shopping list') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_RECIPES)
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Recipes') }}" data-nav-for-page="recipes">
<a class="nav-link discrete-link" href="{{ $U('/recipes') }}">
<i class="fas fa-cocktail"></i>
<span class="nav-link-text">{{ $L('Recipes') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_CHORES)
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Chores overview') }}" data-nav-for-page="choresoverview">
<a class="nav-link discrete-link" href="{{ $U('/choresoverview') }}">
<i class="fas fa-home"></i>
<span class="nav-link-text">{{ $L('Chores overview') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_TASKS)
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Tasks') }}" data-nav-for-page="tasks">
<a class="nav-link discrete-link" href="{{ $U('/tasks') }}">
<i class="fas fa-tasks"></i>
<span class="nav-link-text">{{ $L('Tasks') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_BATTERIES)
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Batteries overview') }}" data-nav-for-page="batteriesoverview">
<a class="nav-link discrete-link" href="{{ $U('/batteriesoverview') }}">
<i class="fas fa-battery-half"></i>
<span class="nav-link-text">{{ $L('Batteries overview') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_EQUIPMENT)
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Equipment') }}" data-nav-for-page="equipment">
<a class="nav-link discrete-link" href="{{ $U('/equipment') }}">
<i class="fas fa-toolbox"></i>
<span class="nav-link-text">{{ $L('Equipment') }}</span>
</a>
</li>
@endif
<li class="nav-item mt-4" data-toggle="tooltip" data-placement="right" title="{{ $L('Purchase') }}" data-nav-for-page="purchase">
<a class="nav-link discrete-link" href="{{ $U('/purchase') }}">
@ -124,24 +136,30 @@
<span class="nav-link-text">{{ $L('Inventory') }}</span>
</a>
</li>
@if(GROCY_FEATURE_FLAG_CHORES)
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Chore tracking') }}" data-nav-for-page="choretracking">
<a class="nav-link discrete-link" href="{{ $U('/choretracking') }}">
<i class="fas fa-play"></i>
<span class="nav-link-text">{{ $L('Chore tracking') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_BATTERIES)
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Battery tracking') }}" data-nav-for-page="batterytracking">
<a class="nav-link discrete-link" href="{{ $U('/batterytracking') }}">
<i class="fas fa-fire"></i>
<span class="nav-link-text">{{ $L('Battery tracking') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_CALENDAR)
<li class="nav-item mt-4" data-toggle="tooltip" data-placement="right" title="{{ $L('Calendar') }}" data-nav-for-page="calendar">
<a class="nav-link discrete-link" href="{{ $U('/calendar') }}">
<i class="fas fa-calendar-alt"></i>
<span class="nav-link-text">{{ $L('Calendar') }}</span>
</a>
</li>
@endif
<li class="nav-item mt-4" data-toggle="tooltip" data-placement="right" title="{{ $L('Manage master data') }}">
<a class="nav-link nav-link-collapse collapsed discrete-link" data-toggle="collapse" href="#top-nav-manager-master-data">
@ -173,24 +191,30 @@
<span class="nav-link-text">{{ $L('Product groups') }}</span>
</a>
</li>
@if(GROCY_FEATURE_FLAG_CHORES)
<li data-nav-for-page="chores" data-sub-menu-of="#top-nav-manager-master-data">
<a class="nav-link discrete-link" href="{{ $U('/chores') }}">
<i class="fas fa-home"></i>
<span class="nav-link-text">{{ $L('Chores') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_BATTERIES)
<li data-nav-for-page="batteries" data-sub-menu-of="#top-nav-manager-master-data">
<a class="nav-link discrete-link" href="{{ $U('/batteries') }}">
<i class="fas fa-battery-half"></i>
<span class="nav-link-text">{{ $L('Batteries') }}</span>
</a>
</li>
@endif
@if(GROCY_FEATURE_FLAG_TASKS)
<li data-nav-for-page="taskcategories" data-sub-menu-of="#top-nav-manager-master-data">
<a class="nav-link discrete-link" href="{{ $U('/taskcategories') }}">
<i class="fas fa-project-diagram "></i>
<span class="nav-link-text">{{ $L('Task categories') }}</span>
</a>
</li>
@endif
</ul>
</li>
</ul>

View File

@ -43,6 +43,7 @@
</div>
</div>
@if(GROCY_FEATURE_FLAG_SHOPPINGLIST)
<h4 class="mt-2">{{ $L('Shopping list to stock workflow') }}</h4>
<div class="form-group">
@ -52,6 +53,7 @@
</label>
</div>
</div>
@endif
<a href="{{ $U('/products') }}" class="btn btn-success">{{ $L('OK') }}</a>
</div>