mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
Feature - Implemented virtual scroll on web (#573)
This PR implemented a virtual scroll on the web, as seen in this article. [Building the Google Photos Web UI](https://medium.com/google-design/google-photos-45b714dfbed1)
This commit is contained in:
@@ -38,8 +38,8 @@ part 'model/add_assets_dto.dart';
|
||||
part 'model/add_users_dto.dart';
|
||||
part 'model/admin_signup_response_dto.dart';
|
||||
part 'model/album_response_dto.dart';
|
||||
part 'model/asset_count_by_time_group_dto.dart';
|
||||
part 'model/asset_count_by_time_group_response_dto.dart';
|
||||
part 'model/asset_count_by_time_bucket.dart';
|
||||
part 'model/asset_count_by_time_bucket_response_dto.dart';
|
||||
part 'model/asset_file_upload_response_dto.dart';
|
||||
part 'model/asset_response_dto.dart';
|
||||
part 'model/asset_type_enum.dart';
|
||||
@@ -57,7 +57,8 @@ part 'model/delete_asset_status.dart';
|
||||
part 'model/device_info_response_dto.dart';
|
||||
part 'model/device_type_enum.dart';
|
||||
part 'model/exif_response_dto.dart';
|
||||
part 'model/get_asset_count_by_time_group_dto.dart';
|
||||
part 'model/get_asset_by_time_bucket_dto.dart';
|
||||
part 'model/get_asset_count_by_time_bucket_dto.dart';
|
||||
part 'model/login_credential_dto.dart';
|
||||
part 'model/login_response_dto.dart';
|
||||
part 'model/logout_response_dto.dart';
|
||||
|
||||
@@ -298,16 +298,16 @@ class AssetApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Performs an HTTP 'GET /asset/count-by-date' operation and returns the [Response].
|
||||
/// Performs an HTTP 'POST /asset/time-bucket' operation and returns the [Response].
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [GetAssetCountByTimeGroupDto] getAssetCountByTimeGroupDto (required):
|
||||
Future<Response> getAssetCountByTimeGroupWithHttpInfo(GetAssetCountByTimeGroupDto getAssetCountByTimeGroupDto,) async {
|
||||
/// * [GetAssetByTimeBucketDto] getAssetByTimeBucketDto (required):
|
||||
Future<Response> getAssetByTimeBucketWithHttpInfo(GetAssetByTimeBucketDto getAssetByTimeBucketDto,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/asset/count-by-date';
|
||||
final path = r'/asset/time-bucket';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody = getAssetCountByTimeGroupDto;
|
||||
Object? postBody = getAssetByTimeBucketDto;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@@ -318,7 +318,7 @@ class AssetApi {
|
||||
|
||||
return apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
@@ -329,9 +329,9 @@ class AssetApi {
|
||||
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [GetAssetCountByTimeGroupDto] getAssetCountByTimeGroupDto (required):
|
||||
Future<AssetCountByTimeGroupResponseDto?> getAssetCountByTimeGroup(GetAssetCountByTimeGroupDto getAssetCountByTimeGroupDto,) async {
|
||||
final response = await getAssetCountByTimeGroupWithHttpInfo(getAssetCountByTimeGroupDto,);
|
||||
/// * [GetAssetByTimeBucketDto] getAssetByTimeBucketDto (required):
|
||||
Future<List<AssetResponseDto>?> getAssetByTimeBucket(GetAssetByTimeBucketDto getAssetByTimeBucketDto,) async {
|
||||
final response = await getAssetByTimeBucketWithHttpInfo(getAssetByTimeBucketDto,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
@@ -339,7 +339,57 @@ class AssetApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AssetCountByTimeGroupResponseDto',) as AssetCountByTimeGroupResponseDto;
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, 'List<AssetResponseDto>') as List)
|
||||
.cast<AssetResponseDto>()
|
||||
.toList();
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Performs an HTTP 'POST /asset/count-by-time-bucket' operation and returns the [Response].
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [GetAssetCountByTimeBucketDto] getAssetCountByTimeBucketDto (required):
|
||||
Future<Response> getAssetCountByTimeBucketWithHttpInfo(GetAssetCountByTimeBucketDto getAssetCountByTimeBucketDto,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/asset/count-by-time-bucket';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody = getAssetCountByTimeBucketDto;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
const contentTypes = <String>['application/json'];
|
||||
|
||||
|
||||
return apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
);
|
||||
}
|
||||
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [GetAssetCountByTimeBucketDto] getAssetCountByTimeBucketDto (required):
|
||||
Future<AssetCountByTimeBucketResponseDto?> getAssetCountByTimeBucket(GetAssetCountByTimeBucketDto getAssetCountByTimeBucketDto,) async {
|
||||
final response = await getAssetCountByTimeBucketWithHttpInfo(getAssetCountByTimeBucketDto,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AssetCountByTimeBucketResponseDto',) as AssetCountByTimeBucketResponseDto;
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -200,10 +200,10 @@ class ApiClient {
|
||||
return AdminSignupResponseDto.fromJson(value);
|
||||
case 'AlbumResponseDto':
|
||||
return AlbumResponseDto.fromJson(value);
|
||||
case 'AssetCountByTimeGroupDto':
|
||||
return AssetCountByTimeGroupDto.fromJson(value);
|
||||
case 'AssetCountByTimeGroupResponseDto':
|
||||
return AssetCountByTimeGroupResponseDto.fromJson(value);
|
||||
case 'AssetCountByTimeBucket':
|
||||
return AssetCountByTimeBucket.fromJson(value);
|
||||
case 'AssetCountByTimeBucketResponseDto':
|
||||
return AssetCountByTimeBucketResponseDto.fromJson(value);
|
||||
case 'AssetFileUploadResponseDto':
|
||||
return AssetFileUploadResponseDto.fromJson(value);
|
||||
case 'AssetResponseDto':
|
||||
@@ -238,8 +238,10 @@ class ApiClient {
|
||||
return DeviceTypeEnumTypeTransformer().decode(value);
|
||||
case 'ExifResponseDto':
|
||||
return ExifResponseDto.fromJson(value);
|
||||
case 'GetAssetCountByTimeGroupDto':
|
||||
return GetAssetCountByTimeGroupDto.fromJson(value);
|
||||
case 'GetAssetByTimeBucketDto':
|
||||
return GetAssetByTimeBucketDto.fromJson(value);
|
||||
case 'GetAssetCountByTimeBucketDto':
|
||||
return GetAssetCountByTimeBucketDto.fromJson(value);
|
||||
case 'LoginCredentialDto':
|
||||
return LoginCredentialDto.fromJson(value);
|
||||
case 'LoginResponseDto':
|
||||
|
||||
119
mobile/openapi/lib/model/asset_count_by_time_bucket.dart
Normal file
119
mobile/openapi/lib/model/asset_count_by_time_bucket.dart
Normal file
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// 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 AssetCountByTimeBucket {
|
||||
/// Returns a new [AssetCountByTimeBucket] instance.
|
||||
AssetCountByTimeBucket({
|
||||
required this.timeBucket,
|
||||
required this.count,
|
||||
});
|
||||
|
||||
String timeBucket;
|
||||
|
||||
int count;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is AssetCountByTimeBucket &&
|
||||
other.timeBucket == timeBucket &&
|
||||
other.count == count;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(timeBucket.hashCode) +
|
||||
(count.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'AssetCountByTimeBucket[timeBucket=$timeBucket, count=$count]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
_json[r'timeBucket'] = timeBucket;
|
||||
_json[r'count'] = count;
|
||||
return _json;
|
||||
}
|
||||
|
||||
/// Returns a new [AssetCountByTimeBucket] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static AssetCountByTimeBucket? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "AssetCountByTimeBucket[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "AssetCountByTimeBucket[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return AssetCountByTimeBucket(
|
||||
timeBucket: mapValueOfType<String>(json, r'timeBucket')!,
|
||||
count: mapValueOfType<int>(json, r'count')!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<AssetCountByTimeBucket>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <AssetCountByTimeBucket>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = AssetCountByTimeBucket.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, AssetCountByTimeBucket> mapFromJson(dynamic json) {
|
||||
final map = <String, AssetCountByTimeBucket>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AssetCountByTimeBucket.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of AssetCountByTimeBucket-objects as value to a dart map
|
||||
static Map<String, List<AssetCountByTimeBucket>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<AssetCountByTimeBucket>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AssetCountByTimeBucket.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'timeBucket',
|
||||
'count',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// 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 AssetCountByTimeBucketResponseDto {
|
||||
/// Returns a new [AssetCountByTimeBucketResponseDto] instance.
|
||||
AssetCountByTimeBucketResponseDto({
|
||||
required this.totalCount,
|
||||
this.buckets = const [],
|
||||
});
|
||||
|
||||
int totalCount;
|
||||
|
||||
List<AssetCountByTimeBucket> buckets;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is AssetCountByTimeBucketResponseDto &&
|
||||
other.totalCount == totalCount &&
|
||||
other.buckets == buckets;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(totalCount.hashCode) +
|
||||
(buckets.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'AssetCountByTimeBucketResponseDto[totalCount=$totalCount, buckets=$buckets]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
_json[r'totalCount'] = totalCount;
|
||||
_json[r'buckets'] = buckets;
|
||||
return _json;
|
||||
}
|
||||
|
||||
/// Returns a new [AssetCountByTimeBucketResponseDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static AssetCountByTimeBucketResponseDto? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "AssetCountByTimeBucketResponseDto[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "AssetCountByTimeBucketResponseDto[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return AssetCountByTimeBucketResponseDto(
|
||||
totalCount: mapValueOfType<int>(json, r'totalCount')!,
|
||||
buckets: AssetCountByTimeBucket.listFromJson(json[r'buckets'])!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<AssetCountByTimeBucketResponseDto>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <AssetCountByTimeBucketResponseDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = AssetCountByTimeBucketResponseDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, AssetCountByTimeBucketResponseDto> mapFromJson(dynamic json) {
|
||||
final map = <String, AssetCountByTimeBucketResponseDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AssetCountByTimeBucketResponseDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of AssetCountByTimeBucketResponseDto-objects as value to a dart map
|
||||
static Map<String, List<AssetCountByTimeBucketResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<AssetCountByTimeBucketResponseDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AssetCountByTimeBucketResponseDto.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'totalCount',
|
||||
'buckets',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,32 +13,32 @@ part of openapi.api;
|
||||
class AssetCountByTimeGroupResponseDto {
|
||||
/// Returns a new [AssetCountByTimeGroupResponseDto] instance.
|
||||
AssetCountByTimeGroupResponseDto({
|
||||
required this.totalAssets,
|
||||
this.groups = const [],
|
||||
required this.count,
|
||||
this.buckets = const [],
|
||||
});
|
||||
|
||||
int totalAssets;
|
||||
int count;
|
||||
|
||||
List<AssetCountByTimeGroupDto> groups;
|
||||
List<AssetCountByTimeBucketResponseDto> buckets;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is AssetCountByTimeGroupResponseDto &&
|
||||
other.totalAssets == totalAssets &&
|
||||
other.groups == groups;
|
||||
other.count == count &&
|
||||
other.buckets == buckets;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(totalAssets.hashCode) +
|
||||
(groups.hashCode);
|
||||
(count.hashCode) +
|
||||
(buckets.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'AssetCountByTimeGroupResponseDto[totalAssets=$totalAssets, groups=$groups]';
|
||||
String toString() => 'AssetCountByTimeGroupResponseDto[count=$count, buckets=$buckets]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
_json[r'totalAssets'] = totalAssets;
|
||||
_json[r'groups'] = groups;
|
||||
_json[r'count'] = count;
|
||||
_json[r'buckets'] = buckets;
|
||||
return _json;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ class AssetCountByTimeGroupResponseDto {
|
||||
}());
|
||||
|
||||
return AssetCountByTimeGroupResponseDto(
|
||||
totalAssets: mapValueOfType<int>(json, r'totalAssets')!,
|
||||
groups: AssetCountByTimeGroupDto.listFromJson(json[r'groups'])!,
|
||||
count: mapValueOfType<int>(json, r'count')!,
|
||||
buckets: AssetCountByTimeBucketResponseDto.listFromJson(json[r'buckets'])!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
@@ -112,8 +112,8 @@ class AssetCountByTimeGroupResponseDto {
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'totalAssets',
|
||||
'groups',
|
||||
'count',
|
||||
'buckets',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
113
mobile/openapi/lib/model/get_asset_by_time_bucket_dto.dart
Normal file
113
mobile/openapi/lib/model/get_asset_by_time_bucket_dto.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// 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 GetAssetByTimeBucketDto {
|
||||
/// Returns a new [GetAssetByTimeBucketDto] instance.
|
||||
GetAssetByTimeBucketDto({
|
||||
this.timeBucket = const [],
|
||||
});
|
||||
|
||||
List<String> timeBucket;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is GetAssetByTimeBucketDto &&
|
||||
other.timeBucket == timeBucket;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(timeBucket.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'GetAssetByTimeBucketDto[timeBucket=$timeBucket]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
_json[r'timeBucket'] = timeBucket;
|
||||
return _json;
|
||||
}
|
||||
|
||||
/// Returns a new [GetAssetByTimeBucketDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static GetAssetByTimeBucketDto? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "GetAssetByTimeBucketDto[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "GetAssetByTimeBucketDto[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return GetAssetByTimeBucketDto(
|
||||
timeBucket: json[r'timeBucket'] is List
|
||||
? (json[r'timeBucket'] as List).cast<String>()
|
||||
: const [],
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<GetAssetByTimeBucketDto>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <GetAssetByTimeBucketDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = GetAssetByTimeBucketDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, GetAssetByTimeBucketDto> mapFromJson(dynamic json) {
|
||||
final map = <String, GetAssetByTimeBucketDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = GetAssetByTimeBucketDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of GetAssetByTimeBucketDto-objects as value to a dart map
|
||||
static Map<String, List<GetAssetByTimeBucketDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<GetAssetByTimeBucketDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = GetAssetByTimeBucketDto.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'timeBucket',
|
||||
};
|
||||
}
|
||||
|
||||
111
mobile/openapi/lib/model/get_asset_count_by_time_bucket_dto.dart
Normal file
111
mobile/openapi/lib/model/get_asset_count_by_time_bucket_dto.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// 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 GetAssetCountByTimeBucketDto {
|
||||
/// Returns a new [GetAssetCountByTimeBucketDto] instance.
|
||||
GetAssetCountByTimeBucketDto({
|
||||
required this.timeGroup,
|
||||
});
|
||||
|
||||
TimeGroupEnum timeGroup;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is GetAssetCountByTimeBucketDto &&
|
||||
other.timeGroup == timeGroup;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(timeGroup.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'GetAssetCountByTimeBucketDto[timeGroup=$timeGroup]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
_json[r'timeGroup'] = timeGroup;
|
||||
return _json;
|
||||
}
|
||||
|
||||
/// Returns a new [GetAssetCountByTimeBucketDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static GetAssetCountByTimeBucketDto? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "GetAssetCountByTimeBucketDto[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "GetAssetCountByTimeBucketDto[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return GetAssetCountByTimeBucketDto(
|
||||
timeGroup: TimeGroupEnum.fromJson(json[r'timeGroup'])!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<GetAssetCountByTimeBucketDto>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <GetAssetCountByTimeBucketDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = GetAssetCountByTimeBucketDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, GetAssetCountByTimeBucketDto> mapFromJson(dynamic json) {
|
||||
final map = <String, GetAssetCountByTimeBucketDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = GetAssetCountByTimeBucketDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of GetAssetCountByTimeBucketDto-objects as value to a dart map
|
||||
static Map<String, List<GetAssetCountByTimeBucketDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<GetAssetCountByTimeBucketDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = GetAssetCountByTimeBucketDto.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'timeGroup',
|
||||
};
|
||||
}
|
||||
|
||||
85
mobile/openapi/lib/model/time_bucket_enum.dart
Normal file
85
mobile/openapi/lib/model/time_bucket_enum.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// 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 TimeBucketEnum {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const TimeBucketEnum._(this.value);
|
||||
|
||||
/// The underlying value of this enum member.
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
static const day = TimeBucketEnum._(r'day');
|
||||
static const month = TimeBucketEnum._(r'month');
|
||||
|
||||
/// List of all possible values in this [enum][TimeBucketEnum].
|
||||
static const values = <TimeBucketEnum>[
|
||||
day,
|
||||
month,
|
||||
];
|
||||
|
||||
static TimeBucketEnum? fromJson(dynamic value) => TimeBucketEnumTypeTransformer().decode(value);
|
||||
|
||||
static List<TimeBucketEnum>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <TimeBucketEnum>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = TimeBucketEnum.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [TimeBucketEnum] to String,
|
||||
/// and [decode] dynamic data back to [TimeBucketEnum].
|
||||
class TimeBucketEnumTypeTransformer {
|
||||
factory TimeBucketEnumTypeTransformer() => _instance ??= const TimeBucketEnumTypeTransformer._();
|
||||
|
||||
const TimeBucketEnumTypeTransformer._();
|
||||
|
||||
String encode(TimeBucketEnum data) => data.value;
|
||||
|
||||
/// Decodes a [dynamic value][data] to a TimeBucketEnum.
|
||||
///
|
||||
/// 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.
|
||||
TimeBucketEnum? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data.toString()) {
|
||||
case r'day': return TimeBucketEnum.day;
|
||||
case r'month': return TimeBucketEnum.month;
|
||||
default:
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Singleton [TimeBucketEnumTypeTransformer] instance.
|
||||
static TimeBucketEnumTypeTransformer? _instance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user