mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 23:46:35 +00:00
Add an admin switch for place enrichment
Reads fail-open, unlike the three older places_* switches. Those read === 'true', which is why migration 185 had to backfill a row on every existing install; there is nothing here that warrants repeating that. The three hand-rolled toggles next to it move to ToggleSwitch while I am in there - they were bare buttons with an inline transform and no aria-pressed or label, so a screen reader could not tell their state.
This commit is contained in:
@@ -213,6 +213,16 @@ export class AdminController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Get('places-enrich')
|
||||
getPlacesEnrich() { return this.admin.getPlacesEnrich(); }
|
||||
|
||||
@Put('places-enrich')
|
||||
updatePlacesEnrich(@CurrentUser() user: User, @Body() body: AdminFeatureToggleDto, @Req() req: Request) {
|
||||
const result = this.admin.updatePlacesEnrich(body.enabled);
|
||||
this.audit.writeAudit({ userId: user.id, action: 'admin.places_enrich', ip: getClientIp(req), details: { enabled: result.enabled } });
|
||||
return result;
|
||||
}
|
||||
|
||||
@Get('collab-features')
|
||||
getCollabFeatures() { return this.addons.getCollabFeatures(); }
|
||||
|
||||
|
||||
@@ -264,6 +264,8 @@ export class AuthService implements OnModuleInit, OnModuleDestroy {
|
||||
const placesAutocompleteEnabled = placesAutocompleteSetting !== 'false';
|
||||
const placesDetailsSetting = this.db.get<{ value: string }>("SELECT value FROM app_settings WHERE key = 'places_details_enabled'")?.value;
|
||||
const placesDetailsEnabled = placesDetailsSetting !== 'false';
|
||||
const placesEnrichSetting = this.db.get<{ value: string }>("SELECT value FROM app_settings WHERE key = 'places_enrich_enabled'")?.value;
|
||||
const placesEnrichEnabled = placesEnrichSetting !== 'false';
|
||||
const setupComplete = userCount > 0 && !this.db.get("SELECT id FROM users WHERE role = 'admin' AND must_change_password = 1 LIMIT 1");
|
||||
|
||||
return {
|
||||
@@ -302,6 +304,7 @@ export class AuthService implements OnModuleInit, OnModuleDestroy {
|
||||
places_photos_enabled: placesPhotosEnabled,
|
||||
places_autocomplete_enabled: placesAutocompleteEnabled,
|
||||
places_details_enabled: placesDetailsEnabled,
|
||||
places_enrich_enabled: placesEnrichEnabled,
|
||||
permissions: authenticatedUser ? this.permissions.getAllPermissions() : undefined,
|
||||
// Case-sensitive on purpose (legacy parity).
|
||||
dev_mode: readEnv().app.nodeEnv === 'development',
|
||||
|
||||
Reference in New Issue
Block a user