Skip to content

Commit

Permalink
Add ablum feature to web (immich-app#352)
Browse files Browse the repository at this point in the history
* Added album page

* Refactor sidebar

* Added album assets count info

* Added album viewer page

* Refactor album sorting

* Fixed incorrectly showing selected asset in album selection

* Improve fetching speed with prefetch

* Refactor to use ImmichThubmnail component for all

* Update to the latest version of Svelte

* Implement fixed app bar in album viewer

* Added shared user avatar

* Correctly get all owned albums, including shared
  • Loading branch information
alextran1502 authored Jul 16, 2022
1 parent 1887b5a commit 7134f93
Show file tree
Hide file tree
Showing 62 changed files with 2,574 additions and 993 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ prod:
docker-compose -f ./docker/docker-compose.yml up --build -V --remove-orphans

prod-scale:
docker-compose -f ./docker/docker-compose.yml up --build -V --scale immich-server=3 --scale immich-microservices=3 --remove-orphans
docker-compose -f ./docker/docker-compose.yml up --build -V --scale immich-server=3 --scale immich-microservices=3 --remove-orphans

api:
cd ./server && npm run api:generate
17 changes: 10 additions & 7 deletions mobile/lib/modules/sharing/ui/month_group_title.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ class MonthGroupTitle extends HookConsumerWidget {
color: Colors.grey,
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
_getSimplifiedMonth(),
style: TextStyle(
fontSize: 24,
color: Theme.of(context).primaryColor,
GestureDetector(
onTap: _handleTitleIconClick,
child: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
_getSimplifiedMonth(),
style: TextStyle(
fontSize: 24,
color: Theme.of(context).primaryColor,
),
),
),
),
Expand Down
31 changes: 22 additions & 9 deletions mobile/lib/modules/sharing/ui/selection_thumbnail_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ class SelectionThumbnailImage extends HookConsumerWidget {
var isAlbumExist = ref.watch(assetSelectionProvider).isAlbumExist;

Widget _buildSelectionIcon(AssetResponseDto asset) {
if (selectedAsset.contains(asset) && !isAlbumExist) {
var isSelected = selectedAsset.map((item) => item.id).contains(asset.id);
var isNewlySelected =
newAssetsForAlbum.map((item) => item.id).contains(asset.id);

if (isSelected && !isAlbumExist) {
return Icon(
Icons.check_circle,
color: Theme.of(context).primaryColor,
);
} else if (selectedAsset.contains(asset) && isAlbumExist) {
} else if (isSelected && isAlbumExist) {
return const Icon(
Icons.check_circle,
color: Color.fromARGB(255, 233, 233, 233),
);
} else if (newAssetsForAlbum.contains(asset) && isAlbumExist) {
} else if (isNewlySelected && isAlbumExist) {
return Icon(
Icons.check_circle,
color: Theme.of(context).primaryColor,
Expand All @@ -50,17 +54,21 @@ class SelectionThumbnailImage extends HookConsumerWidget {
}

BoxBorder drawBorderColor() {
if (selectedAsset.contains(asset) && !isAlbumExist) {
var isSelected = selectedAsset.map((item) => item.id).contains(asset.id);
var isNewlySelected =
newAssetsForAlbum.map((item) => item.id).contains(asset.id);

if (isSelected && !isAlbumExist) {
return Border.all(
color: Theme.of(context).primaryColorLight,
width: 10,
);
} else if (selectedAsset.contains(asset) && isAlbumExist) {
} else if (isSelected && isAlbumExist) {
return Border.all(
color: const Color.fromARGB(255, 190, 190, 190),
width: 10,
);
} else if (newAssetsForAlbum.contains(asset) && isAlbumExist) {
} else if (isNewlySelected && isAlbumExist) {
return Border.all(
color: Theme.of(context).primaryColorLight,
width: 10,
Expand All @@ -71,10 +79,15 @@ class SelectionThumbnailImage extends HookConsumerWidget {

return GestureDetector(
onTap: () {
var isSelected =
selectedAsset.map((item) => item.id).contains(asset.id);
var isNewlySelected =
newAssetsForAlbum.map((item) => item.id).contains(asset.id);

if (isAlbumExist) {
// Operation for existing album
if (!selectedAsset.contains(asset)) {
if (newAssetsForAlbum.contains(asset)) {
if (!isSelected) {
if (isNewlySelected) {
ref
.watch(assetSelectionProvider.notifier)
.removeSelectedAdditionalAssets([asset]);
Expand All @@ -86,7 +99,7 @@ class SelectionThumbnailImage extends HookConsumerWidget {
}
} else {
// Operation for new album
if (selectedAsset.contains(asset)) {
if (isSelected) {
ref
.watch(assetSelectionProvider.notifier)
.removeSelectedNewAssets([asset]);
Expand Down
4 changes: 3 additions & 1 deletion mobile/openapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ doc/ServerPingResponse.md
doc/ServerVersionReponseDto.md
doc/SignUpDto.md
doc/SmartInfoResponseDto.md
doc/ThumbnailFormat.md
doc/UpdateAlbumDto.md
doc/UpdateDeviceInfoDto.md
doc/UpdateUserDto.md
Expand Down Expand Up @@ -90,11 +91,12 @@ lib/model/server_ping_response.dart
lib/model/server_version_reponse_dto.dart
lib/model/sign_up_dto.dart
lib/model/smart_info_response_dto.dart
lib/model/thumbnail_format.dart
lib/model/update_album_dto.dart
lib/model/update_device_info_dto.dart
lib/model/update_user_dto.dart
lib/model/user_count_response_dto.dart
lib/model/user_response_dto.dart
lib/model/validate_access_token_response_dto.dart
pubspec.yaml
test/validate_access_token_response_dto_test.dart
test/thumbnail_format_test.dart
1 change: 1 addition & 0 deletions mobile/openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Class | Method | HTTP request | Description
- [ServerVersionReponseDto](doc//ServerVersionReponseDto.md)
- [SignUpDto](doc//SignUpDto.md)
- [SmartInfoResponseDto](doc//SmartInfoResponseDto.md)
- [ThumbnailFormat](doc//ThumbnailFormat.md)
- [UpdateAlbumDto](doc//UpdateAlbumDto.md)
- [UpdateDeviceInfoDto](doc//UpdateDeviceInfoDto.md)
- [UpdateUserDto](doc//UpdateUserDto.md)
Expand Down
6 changes: 4 additions & 2 deletions mobile/openapi/doc/AssetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ This endpoint does not need any parameter.
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **getAssetThumbnail**
> Object getAssetThumbnail(assetId)
> Object getAssetThumbnail(assetId, format)


Expand All @@ -327,9 +327,10 @@ import 'package:openapi/api.dart';
final api_instance = AssetApi();
final assetId = assetId_example; // String |
final format = ; // ThumbnailFormat |
try {
final result = api_instance.getAssetThumbnail(assetId);
final result = api_instance.getAssetThumbnail(assetId, format);
print(result);
} catch (e) {
print('Exception when calling AssetApi->getAssetThumbnail: $e\n');
Expand All @@ -341,6 +342,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**assetId** | **String**| |
**format** | [**ThumbnailFormat**](.md)| | [optional]

### Return type

Expand Down
14 changes: 14 additions & 0 deletions mobile/openapi/doc/ThumbnailFormat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# openapi.model.ThumbnailFormat

## Load the model package
```dart
import 'package:openapi/api.dart';
```

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


1 change: 1 addition & 0 deletions mobile/openapi/lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ part 'model/server_ping_response.dart';
part 'model/server_version_reponse_dto.dart';
part 'model/sign_up_dto.dart';
part 'model/smart_info_response_dto.dart';
part 'model/thumbnail_format.dart';
part 'model/update_album_dto.dart';
part 'model/update_device_info_dto.dart';
part 'model/update_user_dto.dart';
Expand Down
14 changes: 11 additions & 3 deletions mobile/openapi/lib/api/asset_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ class AssetApi {
/// Parameters:
///
/// * [String] assetId (required):
Future<Response> getAssetThumbnailWithHttpInfo(String assetId,) async {
///
/// * [ThumbnailFormat] format:
Future<Response> getAssetThumbnailWithHttpInfo(String assetId, { ThumbnailFormat? format, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/thumbnail/{assetId}'
.replaceAll('{assetId}', assetId);
Expand All @@ -358,6 +360,10 @@ class AssetApi {
final headerParams = <String, String>{};
final formParams = <String, String>{};

if (format != null) {
queryParams.addAll(_queryParams('', 'format', format));
}

const contentTypes = <String>[];


Expand All @@ -375,8 +381,10 @@ class AssetApi {
/// Parameters:
///
/// * [String] assetId (required):
Future<Object?> getAssetThumbnail(String assetId,) async {
final response = await getAssetThumbnailWithHttpInfo(assetId,);
///
/// * [ThumbnailFormat] format:
Future<Object?> getAssetThumbnail(String assetId, { ThumbnailFormat? format, }) async {
final response = await getAssetThumbnailWithHttpInfo(assetId, format: format, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
Expand Down
2 changes: 2 additions & 0 deletions mobile/openapi/lib/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ class ApiClient {
return SignUpDto.fromJson(value);
case 'SmartInfoResponseDto':
return SmartInfoResponseDto.fromJson(value);
case 'ThumbnailFormat':
return ThumbnailFormatTypeTransformer().decode(value);
case 'UpdateAlbumDto':
return UpdateAlbumDto.fromJson(value);
case 'UpdateDeviceInfoDto':
Expand Down
3 changes: 3 additions & 0 deletions mobile/openapi/lib/api_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ String parameterToString(dynamic value) {
if (value is DeviceTypeEnum) {
return DeviceTypeEnumTypeTransformer().encode(value).toString();
}
if (value is ThumbnailFormat) {
return ThumbnailFormatTypeTransformer().encode(value).toString();
}
return value.toString();
}

Expand Down
85 changes: 85 additions & 0 deletions mobile/openapi/lib/model/thumbnail_format.dart
Original file line number Diff line number Diff line change
@@ -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 ThumbnailFormat {
/// Instantiate a new enum with the provided [value].
const ThumbnailFormat._(this.value);

/// The underlying value of this enum member.
final String value;

@override
String toString() => value;

String toJson() => value;

static const JPEG = ThumbnailFormat._(r'JPEG');
static const WEBP = ThumbnailFormat._(r'WEBP');

/// List of all possible values in this [enum][ThumbnailFormat].
static const values = <ThumbnailFormat>[
JPEG,
WEBP,
];

static ThumbnailFormat? fromJson(dynamic value) => ThumbnailFormatTypeTransformer().decode(value);

static List<ThumbnailFormat>? listFromJson(dynamic json, {bool growable = false,}) {
final result = <ThumbnailFormat>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = ThumbnailFormat.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}

/// Transformation class that can [encode] an instance of [ThumbnailFormat] to String,
/// and [decode] dynamic data back to [ThumbnailFormat].
class ThumbnailFormatTypeTransformer {
factory ThumbnailFormatTypeTransformer() => _instance ??= const ThumbnailFormatTypeTransformer._();

const ThumbnailFormatTypeTransformer._();

String encode(ThumbnailFormat data) => data.value;

/// Decodes a [dynamic value][data] to a ThumbnailFormat.
///
/// 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.
ThumbnailFormat? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data.toString()) {
case r'JPEG': return ThumbnailFormat.JPEG;
case r'WEBP': return ThumbnailFormat.WEBP;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}

/// Singleton [ThumbnailFormatTypeTransformer] instance.
static ThumbnailFormatTypeTransformer? _instance;
}

21 changes: 21 additions & 0 deletions mobile/openapi/test/thumbnail_format_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// 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

import 'package:openapi/api.dart';
import 'package:test/test.dart';

// tests for ThumbnailFormat
void main() {

group('test ThumbnailFormat', () {

});

}
Loading

0 comments on commit 7134f93

Please sign in to comment.