feat(server, web)!: Move reverse geocoding settings to the UI (#4222)

* feat: reverse geocoding settings

* chore: open api

* re-init geocoder if precision has been updated

* update docs

* chore: update verbiage

* fix: re-init logic

* fix: reset to default

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Daniel Dietzler
2023-09-26 09:03:57 +02:00
committed by GitHub
parent 7bc6e9ef64
commit 9bada51d56
37 changed files with 652 additions and 79 deletions

View File

@@ -80,6 +80,7 @@ part 'model/check_duplicate_asset_dto.dart';
part 'model/check_duplicate_asset_response_dto.dart';
part 'model/check_existing_assets_dto.dart';
part 'model/check_existing_assets_response_dto.dart';
part 'model/cities_file.dart';
part 'model/classification_config.dart';
part 'model/colorspace.dart';
part 'model/create_album_dto.dart';
@@ -154,6 +155,7 @@ part 'model/system_config_machine_learning_dto.dart';
part 'model/system_config_map_dto.dart';
part 'model/system_config_o_auth_dto.dart';
part 'model/system_config_password_login_dto.dart';
part 'model/system_config_reverse_geocoding_dto.dart';
part 'model/system_config_storage_template_dto.dart';
part 'model/system_config_template_storage_option_dto.dart';
part 'model/system_config_thumbnail_dto.dart';

View File

@@ -251,6 +251,8 @@ class ApiClient {
return CheckExistingAssetsDto.fromJson(value);
case 'CheckExistingAssetsResponseDto':
return CheckExistingAssetsResponseDto.fromJson(value);
case 'CitiesFile':
return CitiesFileTypeTransformer().decode(value);
case 'ClassificationConfig':
return ClassificationConfig.fromJson(value);
case 'Colorspace':
@@ -399,6 +401,8 @@ class ApiClient {
return SystemConfigOAuthDto.fromJson(value);
case 'SystemConfigPasswordLoginDto':
return SystemConfigPasswordLoginDto.fromJson(value);
case 'SystemConfigReverseGeocodingDto':
return SystemConfigReverseGeocodingDto.fromJson(value);
case 'SystemConfigStorageTemplateDto':
return SystemConfigStorageTemplateDto.fromJson(value);
case 'SystemConfigTemplateStorageOptionDto':

View File

@@ -70,6 +70,9 @@ String parameterToString(dynamic value) {
if (value is CQMode) {
return CQModeTypeTransformer().encode(value).toString();
}
if (value is CitiesFile) {
return CitiesFileTypeTransformer().encode(value).toString();
}
if (value is Colorspace) {
return ColorspaceTypeTransformer().encode(value).toString();
}

View File

@@ -0,0 +1,91 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class CitiesFile {
/// Instantiate a new enum with the provided [value].
const CitiesFile._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const cities15000 = CitiesFile._(r'cities15000');
static const cities5000 = CitiesFile._(r'cities5000');
static const cities1000 = CitiesFile._(r'cities1000');
static const cities500 = CitiesFile._(r'cities500');
/// List of all possible values in this [enum][CitiesFile].
static const values = <CitiesFile>[
cities15000,
cities5000,
cities1000,
cities500,
];
static CitiesFile? fromJson(dynamic value) => CitiesFileTypeTransformer().decode(value);
static List<CitiesFile>? listFromJson(dynamic json, {bool growable = false,}) {
final result = <CitiesFile>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = CitiesFile.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [CitiesFile] to String,
/// and [decode] dynamic data back to [CitiesFile].
class CitiesFileTypeTransformer {
factory CitiesFileTypeTransformer() => _instance ??= const CitiesFileTypeTransformer._();
const CitiesFileTypeTransformer._();
String encode(CitiesFile data) => data.value;
/// Decodes a [dynamic value][data] to a CitiesFile.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
CitiesFile? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'cities15000': return CitiesFile.cities15000;
case r'cities5000': return CitiesFile.cities5000;
case r'cities1000': return CitiesFile.cities1000;
case r'cities500': return CitiesFile.cities500;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [CitiesFileTypeTransformer] instance.
static CitiesFileTypeTransformer? _instance;
}

View File

@@ -20,6 +20,7 @@ class ServerFeaturesDto {
required this.oauth,
required this.oauthAutoLaunch,
required this.passwordLogin,
required this.reverseGeocoding,
required this.search,
required this.sidecar,
required this.tagImage,
@@ -39,6 +40,8 @@ class ServerFeaturesDto {
bool passwordLogin;
bool reverseGeocoding;
bool search;
bool sidecar;
@@ -54,6 +57,7 @@ class ServerFeaturesDto {
other.oauth == oauth &&
other.oauthAutoLaunch == oauthAutoLaunch &&
other.passwordLogin == passwordLogin &&
other.reverseGeocoding == reverseGeocoding &&
other.search == search &&
other.sidecar == sidecar &&
other.tagImage == tagImage;
@@ -68,12 +72,13 @@ class ServerFeaturesDto {
(oauth.hashCode) +
(oauthAutoLaunch.hashCode) +
(passwordLogin.hashCode) +
(reverseGeocoding.hashCode) +
(search.hashCode) +
(sidecar.hashCode) +
(tagImage.hashCode);
@override
String toString() => 'ServerFeaturesDto[clipEncode=$clipEncode, configFile=$configFile, facialRecognition=$facialRecognition, map=$map, oauth=$oauth, oauthAutoLaunch=$oauthAutoLaunch, passwordLogin=$passwordLogin, search=$search, sidecar=$sidecar, tagImage=$tagImage]';
String toString() => 'ServerFeaturesDto[clipEncode=$clipEncode, configFile=$configFile, facialRecognition=$facialRecognition, map=$map, oauth=$oauth, oauthAutoLaunch=$oauthAutoLaunch, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, search=$search, sidecar=$sidecar, tagImage=$tagImage]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -84,6 +89,7 @@ class ServerFeaturesDto {
json[r'oauth'] = this.oauth;
json[r'oauthAutoLaunch'] = this.oauthAutoLaunch;
json[r'passwordLogin'] = this.passwordLogin;
json[r'reverseGeocoding'] = this.reverseGeocoding;
json[r'search'] = this.search;
json[r'sidecar'] = this.sidecar;
json[r'tagImage'] = this.tagImage;
@@ -105,6 +111,7 @@ class ServerFeaturesDto {
oauth: mapValueOfType<bool>(json, r'oauth')!,
oauthAutoLaunch: mapValueOfType<bool>(json, r'oauthAutoLaunch')!,
passwordLogin: mapValueOfType<bool>(json, r'passwordLogin')!,
reverseGeocoding: mapValueOfType<bool>(json, r'reverseGeocoding')!,
search: mapValueOfType<bool>(json, r'search')!,
sidecar: mapValueOfType<bool>(json, r'sidecar')!,
tagImage: mapValueOfType<bool>(json, r'tagImage')!,
@@ -162,6 +169,7 @@ class ServerFeaturesDto {
'oauth',
'oauthAutoLaunch',
'passwordLogin',
'reverseGeocoding',
'search',
'sidecar',
'tagImage',

View File

@@ -19,6 +19,7 @@ class SystemConfigDto {
required this.map,
required this.oauth,
required this.passwordLogin,
required this.reverseGeocoding,
required this.storageTemplate,
required this.thumbnail,
});
@@ -35,6 +36,8 @@ class SystemConfigDto {
SystemConfigPasswordLoginDto passwordLogin;
SystemConfigReverseGeocodingDto reverseGeocoding;
SystemConfigStorageTemplateDto storageTemplate;
SystemConfigThumbnailDto thumbnail;
@@ -47,6 +50,7 @@ class SystemConfigDto {
other.map == map &&
other.oauth == oauth &&
other.passwordLogin == passwordLogin &&
other.reverseGeocoding == reverseGeocoding &&
other.storageTemplate == storageTemplate &&
other.thumbnail == thumbnail;
@@ -59,11 +63,12 @@ class SystemConfigDto {
(map.hashCode) +
(oauth.hashCode) +
(passwordLogin.hashCode) +
(reverseGeocoding.hashCode) +
(storageTemplate.hashCode) +
(thumbnail.hashCode);
@override
String toString() => 'SystemConfigDto[ffmpeg=$ffmpeg, job=$job, machineLearning=$machineLearning, map=$map, oauth=$oauth, passwordLogin=$passwordLogin, storageTemplate=$storageTemplate, thumbnail=$thumbnail]';
String toString() => 'SystemConfigDto[ffmpeg=$ffmpeg, job=$job, machineLearning=$machineLearning, map=$map, oauth=$oauth, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, storageTemplate=$storageTemplate, thumbnail=$thumbnail]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -73,6 +78,7 @@ class SystemConfigDto {
json[r'map'] = this.map;
json[r'oauth'] = this.oauth;
json[r'passwordLogin'] = this.passwordLogin;
json[r'reverseGeocoding'] = this.reverseGeocoding;
json[r'storageTemplate'] = this.storageTemplate;
json[r'thumbnail'] = this.thumbnail;
return json;
@@ -92,6 +98,7 @@ class SystemConfigDto {
map: SystemConfigMapDto.fromJson(json[r'map'])!,
oauth: SystemConfigOAuthDto.fromJson(json[r'oauth'])!,
passwordLogin: SystemConfigPasswordLoginDto.fromJson(json[r'passwordLogin'])!,
reverseGeocoding: SystemConfigReverseGeocodingDto.fromJson(json[r'reverseGeocoding'])!,
storageTemplate: SystemConfigStorageTemplateDto.fromJson(json[r'storageTemplate'])!,
thumbnail: SystemConfigThumbnailDto.fromJson(json[r'thumbnail'])!,
);
@@ -147,6 +154,7 @@ class SystemConfigDto {
'map',
'oauth',
'passwordLogin',
'reverseGeocoding',
'storageTemplate',
'thumbnail',
};

View File

@@ -0,0 +1,106 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class SystemConfigReverseGeocodingDto {
/// Returns a new [SystemConfigReverseGeocodingDto] instance.
SystemConfigReverseGeocodingDto({
required this.citiesFileOverride,
required this.enabled,
});
CitiesFile citiesFileOverride;
bool enabled;
@override
bool operator ==(Object other) => identical(this, other) || other is SystemConfigReverseGeocodingDto &&
other.citiesFileOverride == citiesFileOverride &&
other.enabled == enabled;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(citiesFileOverride.hashCode) +
(enabled.hashCode);
@override
String toString() => 'SystemConfigReverseGeocodingDto[citiesFileOverride=$citiesFileOverride, enabled=$enabled]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'citiesFileOverride'] = this.citiesFileOverride;
json[r'enabled'] = this.enabled;
return json;
}
/// Returns a new [SystemConfigReverseGeocodingDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SystemConfigReverseGeocodingDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return SystemConfigReverseGeocodingDto(
citiesFileOverride: CitiesFile.fromJson(json[r'citiesFileOverride'])!,
enabled: mapValueOfType<bool>(json, r'enabled')!,
);
}
return null;
}
static List<SystemConfigReverseGeocodingDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SystemConfigReverseGeocodingDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SystemConfigReverseGeocodingDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SystemConfigReverseGeocodingDto> mapFromJson(dynamic json) {
final map = <String, SystemConfigReverseGeocodingDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SystemConfigReverseGeocodingDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SystemConfigReverseGeocodingDto-objects as value to a dart map
static Map<String, List<SystemConfigReverseGeocodingDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SystemConfigReverseGeocodingDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SystemConfigReverseGeocodingDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'citiesFileOverride',
'enabled',
};
}