1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-26 10:50:29 +02:00

Merge branch 'main' of github.com:immich-app/immich

This commit is contained in:
Alex Tran 2023-03-28 13:45:53 -05:00
commit 10ccbeab35
49 changed files with 304 additions and 86 deletions

View File

@ -258,5 +258,9 @@
"motion_photos_page_title": "Motion Photos", "motion_photos_page_title": "Motion Photos",
"search_page_motion_photos": "Motion Photos", "search_page_motion_photos": "Motion Photos",
"search_page_recently_added": "Recently added", "search_page_recently_added": "Recently added",
"search_page_categories": "Categories" "search_page_categories": "Categories",
"search_page_screenshots": "Screenshots",
"search_page_selfies": "Selfies",
"search_suggestion_list_smart_search_hint_1": "Smart search is enabled by default, to search for metadata use the syntax ",
"search_suggestion_list_smart_search_hint_2": "m:your-search-term"
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 KiB

View File

@ -243,6 +243,7 @@ class BackupService {
); );
req.headers["Authorization"] = req.headers["Authorization"] =
"Bearer ${Store.get(StoreKey.accessToken)}"; "Bearer ${Store.get(StoreKey.accessToken)}";
req.headers["Transfer-Encoding"] = "chunked";
req.fields['deviceAssetId'] = entity.id; req.fields['deviceAssetId'] = entity.id;
req.fields['deviceId'] = deviceId; req.fields['deviceId'] = deviceId;

View File

@ -454,6 +454,10 @@ class EmailInput extends StatelessWidget {
labelText: 'login_form_label_email'.tr(), labelText: 'login_form_label_email'.tr(),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
hintText: 'login_form_email_hint'.tr(), hintText: 'login_form_email_hint'.tr(),
hintStyle: const TextStyle(
fontWeight: FontWeight.normal,
fontSize: 14,
),
), ),
validator: _validateInput, validator: _validateInput,
autovalidateMode: AutovalidateMode.always, autovalidateMode: AutovalidateMode.always,
@ -487,6 +491,10 @@ class PasswordInput extends StatelessWidget {
labelText: 'login_form_label_password'.tr(), labelText: 'login_form_label_password'.tr(),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
hintText: 'login_form_password_hint'.tr(), hintText: 'login_form_password_hint'.tr(),
hintStyle: const TextStyle(
fontWeight: FontWeight.normal,
fontSize: 14,
),
), ),
autofillHints: const [AutofillHints.password], autofillHints: const [AutofillHints.password],
keyboardType: TextInputType.text, keyboardType: TextInputType.text,

View File

@ -18,7 +18,7 @@ class SearchResultPageNotifier extends StateNotifier<SearchResultPageState> {
final SearchService _searchService; final SearchService _searchService;
void search(String searchTerm) async { void search(String searchTerm, {bool clipEnable = true}) async {
state = state.copyWith( state = state.copyWith(
searchResult: [], searchResult: [],
isError: false, isError: false,
@ -26,7 +26,10 @@ class SearchResultPageNotifier extends StateNotifier<SearchResultPageState> {
isSuccess: false, isSuccess: false,
); );
List<Asset>? assets = await _searchService.searchAsset(searchTerm); List<Asset>? assets = await _searchService.searchAsset(
searchTerm,
clipEnable: clipEnable,
);
if (assets != null) { if (assets != null) {
state = state.copyWith( state = state.copyWith(

View File

@ -29,11 +29,16 @@ class SearchService {
} }
} }
Future<List<Asset>?> searchAsset(String searchTerm) async { Future<List<Asset>?> searchAsset(
String searchTerm, {
bool clipEnable = true,
}) async {
// TODO search in local DB: 1. when offline, 2. to find local assets // TODO search in local DB: 1. when offline, 2. to find local assets
try { try {
final SearchResponseDto? results = await _apiService.searchApi final SearchResponseDto? results = await _apiService.searchApi.search(
.search(query: searchTerm, clip: true); query: searchTerm,
clip: clipEnable,
);
if (results == null) { if (results == null) {
return null; return null;
} }

View File

@ -19,7 +19,6 @@ class CuratedRow extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Guard empty [content] // Guard empty [content]
if (content.isEmpty) { if (content.isEmpty) {
// Return empty thumbnail // Return empty thumbnail

View File

@ -22,8 +22,7 @@ class ExploreGrid extends StatelessWidget {
width: 100, width: 100,
child: ThumbnailWithInfo( child: ThumbnailWithInfo(
textInfo: '', textInfo: '',
onTap: () { onTap: () {},
},
), ),
), ),
); );
@ -42,9 +41,10 @@ class ExploreGrid extends StatelessWidget {
return ThumbnailWithInfo( return ThumbnailWithInfo(
imageUrl: thumbnailRequestUrl, imageUrl: thumbnailRequestUrl,
textInfo: content.label, textInfo: content.label,
borderRadius: 0,
onTap: () { onTap: () {
AutoRouter.of(context).push( AutoRouter.of(context).push(
SearchResultRoute(searchTerm: content.label), SearchResultRoute(searchTerm: 'm:${content.label}'),
); );
}, },
); );
@ -52,5 +52,4 @@ class ExploreGrid extends StatelessWidget {
itemCount: curatedContent.length, itemCount: curatedContent.length,
); );
} }
} }

View File

@ -30,7 +30,10 @@ class SearchBar extends HookConsumerWidget with PreferredSizeWidget {
}, },
icon: const Icon(Icons.arrow_back_ios_rounded), icon: const Icon(Icons.arrow_back_ios_rounded),
) )
: const Icon(Icons.search_rounded), : const Icon(
Icons.search_rounded,
size: 20,
),
title: TextField( title: TextField(
controller: searchTermController, controller: searchTermController,
focusNode: searchFocusNode, focusNode: searchFocusNode,
@ -55,6 +58,8 @@ class SearchBar extends HookConsumerWidget with PreferredSizeWidget {
hintText: 'search_bar_hint'.tr(), hintText: 'search_bar_hint'.tr(),
hintStyle: Theme.of(context).textTheme.titleSmall?.copyWith( hintStyle: Theme.of(context).textTheme.titleSmall?.copyWith(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5), color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
fontWeight: FontWeight.w500,
fontSize: 14,
), ),
enabledBorder: const UnderlineInputBorder( enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(color: Colors.transparent), borderSide: BorderSide(color: Colors.transparent),

View File

@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/modules/home/ui/asset_grid/thumbnail_image.dart';
import 'package:immich_mobile/shared/models/asset.dart';
class SearchResultGrid extends HookConsumerWidget {
const SearchResultGrid({super.key, required this.assets});
final List<Asset> assets;
@override
Widget build(BuildContext context, WidgetRef ref) {
return GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 1,
crossAxisSpacing: 4,
mainAxisSpacing: 4,
),
itemCount: assets.length,
itemBuilder: (context, index) {
final asset = assets[index];
return ThumbnailImage(
asset: asset,
assetList: assets,
useGrayBoxPlaceholder: true,
);
},
);
}
}

View File

@ -1,3 +1,4 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/modules/search/providers/search_page_state.provider.dart'; import 'package:immich_mobile/modules/search/providers/search_page_state.provider.dart';
@ -12,6 +13,7 @@ class SearchSuggestionList extends ConsumerWidget {
final searchTerm = ref.watch(searchPageStateProvider).searchTerm; final searchTerm = ref.watch(searchPageStateProvider).searchTerm;
final searchSuggestion = final searchSuggestion =
ref.watch(searchPageStateProvider).searchSuggestion; ref.watch(searchPageStateProvider).searchSuggestion;
var isDarkTheme = Theme.of(context).brightness == Brightness.dark;
return Container( return Container(
color: searchTerm.isEmpty color: searchTerm.isEmpty
@ -19,13 +21,38 @@ class SearchSuggestionList extends ConsumerWidget {
: Theme.of(context).scaffoldBackgroundColor, : Theme.of(context).scaffoldBackgroundColor,
child: CustomScrollView( child: CustomScrollView(
slivers: [ slivers: [
SliverToBoxAdapter(
child: Container(
color: isDarkTheme ? Colors.grey[800] : Colors.grey[100],
child: Padding(
padding: const EdgeInsets.all(16.0),
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: 'search_suggestion_list_smart_search_hint_1'.tr(),
style: Theme.of(context).textTheme.bodyMedium,
),
TextSpan(
text: 'search_suggestion_list_smart_search_hint_2'.tr(),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
)
],
),
),
),
),
),
SliverFillRemaining( SliverFillRemaining(
hasScrollBody: true, hasScrollBody: true,
child: ListView.builder( child: ListView.builder(
itemBuilder: ((context, index) { itemBuilder: ((context, index) {
return ListTile( return ListTile(
onTap: () { onTap: () {
onSubmitted(searchSuggestion[index]); onSubmitted("m:${searchSuggestion[index]}");
}, },
title: Text(searchSuggestion[index]), title: Text(searchSuggestion[index]),
); );

View File

@ -1,13 +1,16 @@
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:immich_mobile/shared/models/store.dart'; import 'package:immich_mobile/shared/models/store.dart';
import 'package:immich_mobile/utils/capitalize_first_letter.dart';
// ignore: must_be_immutable
class ThumbnailWithInfo extends StatelessWidget { class ThumbnailWithInfo extends StatelessWidget {
const ThumbnailWithInfo({ ThumbnailWithInfo({
Key? key, Key? key,
required this.textInfo, required this.textInfo,
this.imageUrl, this.imageUrl,
this.noImageIcon, this.noImageIcon,
this.borderRadius = 10,
required this.onTap, required this.onTap,
}) : super(key: key); }) : super(key: key);
@ -15,6 +18,7 @@ class ThumbnailWithInfo extends StatelessWidget {
final String? imageUrl; final String? imageUrl;
final Function onTap; final Function onTap;
final IconData? noImageIcon; final IconData? noImageIcon;
double borderRadius;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -29,12 +33,12 @@ class ThumbnailWithInfo extends StatelessWidget {
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25), borderRadius: BorderRadius.circular(borderRadius),
color: isDarkMode ? Colors.grey[900] : Colors.grey[100], color: isDarkMode ? Colors.grey[900] : Colors.grey[100],
), ),
child: imageUrl != null child: imageUrl != null
? ClipRRect( ? ClipRRect(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(borderRadius),
child: CachedNetworkImage( child: CachedNetworkImage(
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
@ -55,15 +59,32 @@ class ThumbnailWithInfo extends StatelessWidget {
), ),
), ),
), ),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(borderRadius),
color: Colors.white,
gradient: LinearGradient(
begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter,
colors: [
Colors.grey.withOpacity(0.0),
textInfo == ''
? Colors.black.withOpacity(0.1)
: Colors.black.withOpacity(0.5),
],
stops: const [0.0, 1.0],
),
),
),
Positioned( Positioned(
bottom: 12, bottom: 12,
left: 14, left: 14,
child: Text( child: Text(
textInfo, textInfo == '' ? textInfo : textInfo.capitalizeFirstLetter(),
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 12, fontSize: 14,
), ),
), ),
), ),

View File

@ -27,6 +27,7 @@ class SearchPage extends HookConsumerWidget {
ref.watch(getCuratedObjectProvider); ref.watch(getCuratedObjectProvider);
var isDarkTheme = Theme.of(context).brightness == Brightness.dark; var isDarkTheme = Theme.of(context).brightness == Brightness.dark;
double imageSize = MediaQuery.of(context).size.width / 3; double imageSize = MediaQuery.of(context).size.width / 3;
TextStyle categoryTitleStyle = const TextStyle( TextStyle categoryTitleStyle = const TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 14.0, fontSize: 14.0,
@ -46,7 +47,11 @@ class SearchPage extends HookConsumerWidget {
searchFocusNode.unfocus(); searchFocusNode.unfocus();
ref.watch(searchPageStateProvider.notifier).disableSearch(); ref.watch(searchPageStateProvider.notifier).disableSearch();
AutoRouter.of(context).push(SearchResultRoute(searchTerm: searchTerm)); AutoRouter.of(context).push(
SearchResultRoute(
searchTerm: searchTerm,
),
);
} }
buildPlaces() { buildPlaces() {
@ -67,7 +72,9 @@ class SearchPage extends HookConsumerWidget {
imageSize: imageSize, imageSize: imageSize,
onTap: (content, index) { onTap: (content, index) {
AutoRouter.of(context).push( AutoRouter.of(context).push(
SearchResultRoute(searchTerm: content.label), SearchResultRoute(
searchTerm: 'm:${content.label}',
),
); );
}, },
), ),
@ -99,7 +106,9 @@ class SearchPage extends HookConsumerWidget {
imageSize: imageSize, imageSize: imageSize,
onTap: (content, index) { onTap: (content, index) {
AutoRouter.of(context).push( AutoRouter.of(context).push(
SearchResultRoute(searchTerm: content.label), SearchResultRoute(
searchTerm: 'm:${content.label}',
),
); );
}, },
), ),
@ -131,7 +140,7 @@ class SearchPage extends HookConsumerWidget {
children: [ children: [
Text( Text(
"search_page_places", "search_page_places",
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleSmall,
).tr(), ).tr(),
TextButton( TextButton(
child: Text( child: Text(
@ -162,7 +171,7 @@ class SearchPage extends HookConsumerWidget {
children: [ children: [
Text( Text(
"search_page_things", "search_page_things",
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleSmall,
).tr(), ).tr(),
TextButton( TextButton(
child: Text( child: Text(
@ -186,7 +195,7 @@ class SearchPage extends HookConsumerWidget {
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text( child: Text(
'search_page_your_activity', 'search_page_your_activity',
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleSmall,
).tr(), ).tr(),
), ),
ListTile( ListTile(
@ -201,13 +210,7 @@ class SearchPage extends HookConsumerWidget {
const FavoritesRoute(), const FavoritesRoute(),
), ),
), ),
const Padding( const CategoryDivider(),
padding: EdgeInsets.only(
left: 72,
right: 16,
),
child: Divider(),
),
ListTile( ListTile(
leading: Icon( leading: Icon(
Icons.schedule_outlined, Icons.schedule_outlined,
@ -226,9 +229,36 @@ class SearchPage extends HookConsumerWidget {
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text( child: Text(
'search_page_categories', 'search_page_categories',
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleSmall,
).tr(), ).tr(),
), ),
ListTile(
title: Text('Screenshots', style: categoryTitleStyle).tr(),
leading: Icon(
Icons.screenshot,
color: categoryIconColor,
),
onTap: () => AutoRouter.of(context).push(
SearchResultRoute(
searchTerm: 'screenshots',
),
),
),
const CategoryDivider(),
ListTile(
title: Text('search_page_selfies', style: categoryTitleStyle)
.tr(),
leading: Icon(
Icons.photo_camera_front_outlined,
color: categoryIconColor,
),
onTap: () => AutoRouter.of(context).push(
SearchResultRoute(
searchTerm: 'selfies',
),
),
),
const CategoryDivider(),
ListTile( ListTile(
title: Text('search_page_videos', style: categoryTitleStyle) title: Text('search_page_videos', style: categoryTitleStyle)
.tr(), .tr(),
@ -240,13 +270,7 @@ class SearchPage extends HookConsumerWidget {
const AllVideosRoute(), const AllVideosRoute(),
), ),
), ),
const Padding( const CategoryDivider(),
padding: EdgeInsets.only(
left: 72,
right: 16,
),
child: Divider(),
),
ListTile( ListTile(
title: Text( title: Text(
'search_page_motion_photos', 'search_page_motion_photos',
@ -270,3 +294,20 @@ class SearchPage extends HookConsumerWidget {
); );
} }
} }
class CategoryDivider extends StatelessWidget {
const CategoryDivider({super.key});
@override
Widget build(BuildContext context) {
return const Padding(
padding: EdgeInsets.only(
left: 72,
right: 16,
),
child: Divider(
height: 0,
),
);
}
}

View File

@ -6,12 +6,30 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/modules/home/ui/asset_grid/immich_asset_grid.dart'; import 'package:immich_mobile/modules/home/ui/asset_grid/immich_asset_grid.dart';
import 'package:immich_mobile/modules/search/providers/search_page_state.provider.dart'; import 'package:immich_mobile/modules/search/providers/search_page_state.provider.dart';
import 'package:immich_mobile/modules/search/providers/search_result_page.provider.dart'; import 'package:immich_mobile/modules/search/providers/search_result_page.provider.dart';
import 'package:immich_mobile/modules/search/ui/search_result_grid.dart';
import 'package:immich_mobile/modules/search/ui/search_suggestion_list.dart'; import 'package:immich_mobile/modules/search/ui/search_suggestion_list.dart';
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart'; import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
class SearchType {
SearchType({required this.isClip, required this.searchTerm});
final bool isClip;
final String searchTerm;
}
SearchType _getSearchType(String searchTerm) {
if (searchTerm.startsWith('m:')) {
return SearchType(isClip: false, searchTerm: searchTerm.substring(2));
} else {
return SearchType(isClip: true, searchTerm: searchTerm);
}
}
class SearchResultPage extends HookConsumerWidget { class SearchResultPage extends HookConsumerWidget {
const SearchResultPage({Key? key, required this.searchTerm}) const SearchResultPage({
: super(key: key); Key? key,
required this.searchTerm,
}) : super(key: key);
final String searchTerm; final String searchTerm;
@ -20,6 +38,8 @@ class SearchResultPage extends HookConsumerWidget {
final searchTermController = useTextEditingController(text: ""); final searchTermController = useTextEditingController(text: "");
final isNewSearch = useState(false); final isNewSearch = useState(false);
final currentSearchTerm = useState(searchTerm); final currentSearchTerm = useState(searchTerm);
final isDarkTheme = Theme.of(context).brightness == Brightness.dark;
final isDisplayDateGroup = useState(true);
FocusNode? searchFocusNode; FocusNode? searchFocusNode;
@ -27,9 +47,16 @@ class SearchResultPage extends HookConsumerWidget {
() { () {
searchFocusNode = FocusNode(); searchFocusNode = FocusNode();
var searchType = _getSearchType(searchTerm);
searchType.isClip
? isDisplayDateGroup.value = false
: isDisplayDateGroup.value = true;
Future.delayed( Future.delayed(
Duration.zero, Duration.zero,
() => ref.read(searchResultPageProvider.notifier).search(searchTerm), () => ref
.read(searchResultPageProvider.notifier)
.search(searchType.searchTerm, clipEnable: searchType.isClip),
); );
return () => searchFocusNode?.dispose(); return () => searchFocusNode?.dispose();
}, },
@ -41,7 +68,15 @@ class SearchResultPage extends HookConsumerWidget {
searchFocusNode?.unfocus(); searchFocusNode?.unfocus();
isNewSearch.value = false; isNewSearch.value = false;
currentSearchTerm.value = newSearchTerm; currentSearchTerm.value = newSearchTerm;
ref.watch(searchResultPageProvider.notifier).search(newSearchTerm);
var searchType = _getSearchType(newSearchTerm);
searchType.isClip
? isDisplayDateGroup.value = false
: isDisplayDateGroup.value = true;
ref
.watch(searchResultPageProvider.notifier)
.search(searchType.searchTerm, clipEnable: searchType.isClip);
} }
buildTextField() { buildTextField() {
@ -74,6 +109,12 @@ class SearchResultPage extends HookConsumerWidget {
focusedBorder: const UnderlineInputBorder( focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(color: Colors.transparent), borderSide: BorderSide(color: Colors.transparent),
), ),
hintStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16.0,
color:
isDarkTheme ? Colors.grey[500] : Colors.black.withOpacity(0.5),
),
), ),
); );
} }
@ -121,11 +162,16 @@ class SearchResultPage extends HookConsumerWidget {
return const Center(child: ImmichLoadingIndicator()); return const Center(child: ImmichLoadingIndicator());
} }
if (searchResultPageState.isSuccess) { if (searchResultPageState.isSuccess) {
return ImmichAssetGrid( if (isDisplayDateGroup.value) {
return ImmichAssetGrid(
assets: allSearchAssets, assets: allSearchAssets,
); );
} else {
return SearchResultGrid(
assets: allSearchAssets,
);
}
} }
return const SizedBox(); return const SizedBox();

View File

@ -144,14 +144,9 @@ class _$AppRouter extends RootStackRouter {
); );
}, },
RecentlyAddedRoute.name: (routeData) { RecentlyAddedRoute.name: (routeData) {
return CustomPage<dynamic>( return MaterialPageX<dynamic>(
routeData: routeData, routeData: routeData,
child: const RecentlyAddedPage(), child: const RecentlyAddedPage(),
transitionsBuilder: TransitionsBuilders.noTransition,
durationInMilliseconds: 200,
reverseDurationInMilliseconds: 200,
opaque: true,
barrierDismissible: false,
); );
}, },
AssetSelectionRoute.name: (routeData) { AssetSelectionRoute.name: (routeData) {

View File

@ -79,6 +79,7 @@ ThemeData immichLightTheme = ThemeData(
), ),
titleSmall: TextStyle( titleSmall: TextStyle(
fontSize: 16.0, fontSize: 16.0,
fontWeight: FontWeight.bold,
), ),
titleMedium: TextStyle( titleMedium: TextStyle(
fontSize: 18.0, fontSize: 18.0,
@ -176,6 +177,7 @@ ThemeData immichDarkTheme = ThemeData(
), ),
titleSmall: const TextStyle( titleSmall: const TextStyle(
fontSize: 16.0, fontSize: 16.0,
fontWeight: FontWeight.bold,
), ),
titleMedium: const TextStyle( titleMedium: const TextStyle(
fontSize: 18.0, fontSize: 18.0,
@ -185,7 +187,6 @@ ThemeData immichDarkTheme = ThemeData(
fontSize: 26.0, fontSize: 26.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
cardColor: Colors.grey[900], cardColor: Colors.grey[900],
elevatedButtonTheme: ElevatedButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(

Binary file not shown.

View File

@ -187,6 +187,16 @@ class MockAssetNotifier extends _i1.Mock implements _i2.AssetNotifier {
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>); ) as _i5.Future<void>);
@override @override
_i5.Future<void> getAllAsset({bool? clear = false}) => (super.noSuchMethod(
Invocation.method(
#getAllAsset,
[],
{#clear: clear},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);
@override
_i5.Future<void> clearAllAsset() => (super.noSuchMethod( _i5.Future<void> clearAllAsset() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#clearAllAsset, #clearAllAsset,

View File

@ -6,11 +6,7 @@ import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from './comma
import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/reset-admin-password.command'; import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/reset-admin-password.command';
@Module({ @Module({
imports: [ imports: [DomainModule.register({ imports: [InfraModule] })],
DomainModule.register({
imports: [InfraModule],
}),
],
providers: [ providers: [
ResetAdminPasswordCommand, ResetAdminPasswordCommand,
PromptPasswordQuestions, PromptPasswordQuestions,

View File

@ -1,4 +1,5 @@
import { AlbumEntity, AssetEntity, dataSource, UserEntity } from '@app/infra'; import { AlbumEntity, AssetEntity, UserEntity } from '@app/infra/db/entities';
import { dataSource } from '@app/infra/db/config';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm'; import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';

View File

@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { AlbumService } from './album.service'; import { AlbumService } from './album.service';
import { AlbumController } from './album.controller'; import { AlbumController } from './album.controller';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { AlbumEntity, AssetEntity } from '@app/infra'; import { AlbumEntity, AssetEntity } from '@app/infra/db/entities';
import { AlbumRepository, IAlbumRepository } from './album-repository'; import { AlbumRepository, IAlbumRepository } from './album-repository';
import { DownloadModule } from '../../modules/download/download.module'; import { DownloadModule } from '../../modules/download/download.module';

View File

@ -1,7 +1,7 @@
import { AlbumService } from './album.service'; import { AlbumService } from './album.service';
import { AuthUserDto } from '../../decorators/auth-user.decorator'; import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { BadRequestException, NotFoundException, ForbiddenException } from '@nestjs/common'; import { BadRequestException, NotFoundException, ForbiddenException } from '@nestjs/common';
import { AlbumEntity, UserEntity } from '@app/infra'; import { AlbumEntity, UserEntity } from '@app/infra/db/entities';
import { AlbumResponseDto, ICryptoRepository, IJobRepository, JobName, mapUser } from '@app/domain'; import { AlbumResponseDto, ICryptoRepository, IJobRepository, JobName, mapUser } from '@app/domain';
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto'; import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
import { IAlbumRepository } from './album-repository'; import { IAlbumRepository } from './album-repository';

View File

@ -1,7 +1,7 @@
import { BadRequestException, Inject, Injectable, NotFoundException, ForbiddenException, Logger } from '@nestjs/common'; import { BadRequestException, Inject, Injectable, NotFoundException, ForbiddenException, Logger } from '@nestjs/common';
import { AuthUserDto } from '../../decorators/auth-user.decorator'; import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { CreateAlbumDto } from './dto/create-album.dto'; import { CreateAlbumDto } from './dto/create-album.dto';
import { AlbumEntity, SharedLinkType } from '@app/infra'; import { AlbumEntity, SharedLinkType } from '@app/infra/db/entities';
import { AddUsersDto } from './dto/add-users.dto'; import { AddUsersDto } from './dto/add-users.dto';
import { RemoveAssetsDto } from './dto/remove-assets.dto'; import { RemoveAssetsDto } from './dto/remove-assets.dto';
import { UpdateAlbumDto } from './dto/update-album.dto'; import { UpdateAlbumDto } from './dto/update-album.dto';

View File

@ -1,6 +1,6 @@
import { SearchPropertiesDto } from './dto/search-properties.dto'; import { SearchPropertiesDto } from './dto/search-properties.dto';
import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto'; import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto';
import { AssetEntity, AssetType } from '@app/infra'; import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm'; import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm/repository/Repository'; import { Repository } from 'typeorm/repository/Repository';

View File

@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { AssetService } from './asset.service'; import { AssetService } from './asset.service';
import { AssetController } from './asset.controller'; import { AssetController } from './asset.controller';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { AssetEntity } from '@app/infra'; import { AssetEntity } from '@app/infra/db/entities';
import { AssetRepository, IAssetRepository } from './asset-repository'; import { AssetRepository, IAssetRepository } from './asset-repository';
import { DownloadModule } from '../../modules/download/download.module'; import { DownloadModule } from '../../modules/download/download.module';
import { TagModule } from '../tag/tag.module'; import { TagModule } from '../tag/tag.module';

View File

@ -1,7 +1,7 @@
import { IAssetRepository } from './asset-repository'; import { IAssetRepository } from './asset-repository';
import { AssetService } from './asset.service'; import { AssetService } from './asset.service';
import { QueryFailedError, Repository } from 'typeorm'; import { QueryFailedError, Repository } from 'typeorm';
import { AssetEntity, AssetType } from '@app/infra'; import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { CreateAssetDto } from './dto/create-asset.dto'; import { CreateAssetDto } from './dto/create-asset.dto';
import { AssetCountByTimeBucket } from './response-dto/asset-count-by-time-group-response.dto'; import { AssetCountByTimeBucket } from './response-dto/asset-count-by-time-group-response.dto';
import { TimeGroupEnum } from './dto/get-asset-count-by-time-bucket.dto'; import { TimeGroupEnum } from './dto/get-asset-count-by-time-bucket.dto';

View File

@ -12,7 +12,7 @@ import {
import { InjectRepository } from '@nestjs/typeorm'; import { InjectRepository } from '@nestjs/typeorm';
import { QueryFailedError, Repository } from 'typeorm'; import { QueryFailedError, Repository } from 'typeorm';
import { AuthUserDto } from '../../decorators/auth-user.decorator'; import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { AssetEntity, AssetType, SharedLinkType, SystemConfig } from '@app/infra'; import { AssetEntity, AssetType, SharedLinkType, SystemConfig } from '@app/infra/db/entities';
import { constants, createReadStream, stat } from 'fs'; import { constants, createReadStream, stat } from 'fs';
import { ServeFileDto } from './dto/serve-file.dto'; import { ServeFileDto } from './dto/serve-file.dto';
import { Response as Res } from 'express'; import { Response as Res } from 'express';

View File

@ -1,4 +1,4 @@
import { AssetType } from '@app/infra'; import { AssetType } from '@app/infra/db/entities';
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator'; import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator';
import { ImmichFile } from '../../../config/asset-upload.config'; import { ImmichFile } from '../../../config/asset-upload.config';

View File

@ -1,4 +1,4 @@
import { TagType } from '@app/infra'; import { TagType } from '@app/infra/db/entities';
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsNotEmpty, IsString } from 'class-validator'; import { IsEnum, IsNotEmpty, IsString } from 'class-validator';

View File

@ -1,7 +1,7 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { TagService } from './tag.service'; import { TagService } from './tag.service';
import { TagController } from './tag.controller'; import { TagController } from './tag.controller';
import { TagEntity } from '@app/infra'; import { TagEntity } from '@app/infra/db/entities';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { TagRepository, ITagRepository } from './tag.repository'; import { TagRepository, ITagRepository } from './tag.repository';

View File

@ -1,4 +1,4 @@
import { TagEntity, TagType } from '@app/infra'; import { TagEntity, TagType } from '@app/infra/db/entities';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm'; import { InjectRepository } from '@nestjs/typeorm';
import { In, Repository } from 'typeorm'; import { In, Repository } from 'typeorm';

View File

@ -1,4 +1,4 @@
import { TagEntity, TagType, UserEntity } from '@app/infra'; import { TagEntity, TagType, UserEntity } from '@app/infra/db/entities';
import { AuthUserDto } from '../../decorators/auth-user.decorator'; import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { ITagRepository } from './tag.repository'; import { ITagRepository } from './tag.repository';
import { TagService } from './tag.service'; import { TagService } from './tag.service';

View File

@ -1,4 +1,4 @@
import { TagEntity } from '@app/infra'; import { TagEntity } from '@app/infra/db/entities';
import { BadRequestException, Inject, Injectable, Logger } from '@nestjs/common'; import { BadRequestException, Inject, Injectable, Logger } from '@nestjs/common';
import { AuthUserDto } from '../../decorators/auth-user.decorator'; import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { CreateTagDto } from './dto/create-tag.dto'; import { CreateTagDto } from './dto/create-tag.dto';

View File

@ -1,7 +1,5 @@
import { immichAppConfig } from '@app/domain';
import { Module, OnModuleInit } from '@nestjs/common'; import { Module, OnModuleInit } from '@nestjs/common';
import { AssetModule } from './api-v1/asset/asset.module'; import { AssetModule } from './api-v1/asset/asset.module';
import { ConfigModule } from '@nestjs/config';
import { AlbumModule } from './api-v1/album/album.module'; import { AlbumModule } from './api-v1/album/album.module';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { ScheduleModule } from '@nestjs/schedule'; import { ScheduleModule } from '@nestjs/schedule';
@ -27,7 +25,6 @@ import { AppCronJobs } from './app.cron-jobs';
@Module({ @Module({
imports: [ imports: [
ConfigModule.forRoot(immichAppConfig),
DomainModule.register({ imports: [InfraModule] }), DomainModule.register({ imports: [InfraModule] }),
AssetModule, AssetModule,
AlbumModule, AlbumModule,

View File

@ -1,4 +1,4 @@
import { AssetEntity } from '@app/infra'; import { AssetEntity } from '@app/infra/db/entities';
import { BadRequestException, Injectable, InternalServerErrorException, Logger, StreamableFile } from '@nestjs/common'; import { BadRequestException, Injectable, InternalServerErrorException, Logger, StreamableFile } from '@nestjs/common';
import archiver from 'archiver'; import archiver from 'archiver';
import { extname } from 'path'; import { extname } from 'path';

View File

@ -1,8 +1,7 @@
import { immichAppConfig } from '@app/domain';
import { DomainModule } from '@app/domain'; import { DomainModule } from '@app/domain';
import { ExifEntity, InfraModule } from '@app/infra'; import { InfraModule } from '@app/infra';
import { ExifEntity } from '@app/infra/db/entities';
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { import {
BackgroundTaskProcessor, BackgroundTaskProcessor,
@ -17,7 +16,7 @@ import { VideoTranscodeProcessor } from './processors/video-transcode.processor'
@Module({ @Module({
imports: [ imports: [
ConfigModule.forRoot(immichAppConfig), //
DomainModule.register({ imports: [InfraModule] }), DomainModule.register({ imports: [InfraModule] }),
TypeOrmModule.forFeature([ExifEntity]), TypeOrmModule.forFeature([ExifEntity]),
], ],

View File

@ -10,7 +10,7 @@ import {
QueueName, QueueName,
WithoutProperty, WithoutProperty,
} from '@app/domain'; } from '@app/domain';
import { AssetEntity, AssetType, ExifEntity } from '@app/infra'; import { AssetEntity, AssetType, ExifEntity } from '@app/infra/db/entities';
import { Process, Processor } from '@nestjs/bull'; import { Process, Processor } from '@nestjs/bull';
import { Inject, Logger } from '@nestjs/common'; import { Inject, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';

View File

@ -11,7 +11,7 @@ import {
SystemConfigService, SystemConfigService,
WithoutProperty, WithoutProperty,
} from '@app/domain'; } from '@app/domain';
import { AssetEntity, AssetType } from '@app/infra'; import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { Process, Processor } from '@nestjs/bull'; import { Process, Processor } from '@nestjs/bull';
import { Inject, Logger } from '@nestjs/common'; import { Inject, Logger } from '@nestjs/common';
import { Job } from 'bull'; import { Job } from 'bull';

View File

@ -4141,6 +4141,7 @@
"enum": [ "enum": [
"start", "start",
"pause", "pause",
"resume",
"empty" "empty"
] ]
}, },

View File

@ -1,4 +1,4 @@
import { AlbumEntity } from '@app/infra'; import { AlbumEntity } from '@app/infra/db/entities';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { IAssetRepository } from '../asset'; import { IAssetRepository } from '../asset';
import { AuthUserDto } from '../auth'; import { AuthUserDto } from '../auth';

View File

@ -1,4 +1,4 @@
import { DynamicModule, Global, Module, ModuleMetadata, Provider } from '@nestjs/common'; import { DynamicModule, Global, Module, ModuleMetadata, OnApplicationShutdown, Provider } from '@nestjs/common';
import { AlbumService } from './album'; import { AlbumService } from './album';
import { APIKeyService } from './api-key'; import { APIKeyService } from './api-key';
import { AssetService } from './asset'; import { AssetService } from './asset';
@ -44,7 +44,9 @@ const providers: Provider[] = [
@Global() @Global()
@Module({}) @Module({})
export class DomainModule { export class DomainModule implements OnApplicationShutdown {
constructor(private searchService: SearchService) {}
static register(options: Pick<ModuleMetadata, 'imports'>): DynamicModule { static register(options: Pick<ModuleMetadata, 'imports'>): DynamicModule {
return { return {
module: DomainModule, module: DomainModule,
@ -53,4 +55,8 @@ export class DomainModule {
exports: [...providers], exports: [...providers],
}; };
} }
onApplicationShutdown() {
this.searchService.teardown();
}
} }

View File

@ -12,6 +12,7 @@ export enum QueueName {
export enum JobCommand { export enum JobCommand {
START = 'start', START = 'start',
PAUSE = 'pause', PAUSE = 'pause',
RESUME = 'resume',
EMPTY = 'empty', EMPTY = 'empty',
} }

View File

@ -69,6 +69,7 @@ export const IJobRepository = 'IJobRepository';
export interface IJobRepository { export interface IJobRepository {
queue(item: JobItem): Promise<void>; queue(item: JobItem): Promise<void>;
pause(name: QueueName): Promise<void>; pause(name: QueueName): Promise<void>;
resume(name: QueueName): Promise<void>;
empty(name: QueueName): Promise<void>; empty(name: QueueName): Promise<void>;
isActive(name: QueueName): Promise<boolean>; isActive(name: QueueName): Promise<boolean>;
getJobCounts(name: QueueName): Promise<JobCounts>; getJobCounts(name: QueueName): Promise<JobCounts>;

View File

@ -93,6 +93,12 @@ describe(JobService.name, () => {
expect(jobMock.pause).toHaveBeenCalledWith(QueueName.METADATA_EXTRACTION); expect(jobMock.pause).toHaveBeenCalledWith(QueueName.METADATA_EXTRACTION);
}); });
it('should handle a resume command', async () => {
await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.RESUME, force: false });
expect(jobMock.resume).toHaveBeenCalledWith(QueueName.METADATA_EXTRACTION);
});
it('should handle an empty command', async () => { it('should handle an empty command', async () => {
await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.EMPTY, force: false }); await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.EMPTY, force: false });

View File

@ -21,6 +21,9 @@ export class JobService {
case JobCommand.PAUSE: case JobCommand.PAUSE:
return this.jobRepository.pause(queueName); return this.jobRepository.pause(queueName);
case JobCommand.RESUME:
return this.jobRepository.resume(queueName);
case JobCommand.EMPTY: case JobCommand.EMPTY:
return this.jobRepository.empty(queueName); return this.jobRepository.empty(queueName);
} }

View File

@ -4,6 +4,7 @@ export const newJobRepositoryMock = (): jest.Mocked<IJobRepository> => {
return { return {
empty: jest.fn(), empty: jest.fn(),
pause: jest.fn(), pause: jest.fn(),
resume: jest.fn(),
queue: jest.fn().mockImplementation(() => Promise.resolve()), queue: jest.fn().mockImplementation(() => Promise.resolve()),
isActive: jest.fn(), isActive: jest.fn(),
getJobCounts: jest.fn(), getJobCounts: jest.fn(),

View File

@ -8,6 +8,7 @@ import {
IKeyRepository, IKeyRepository,
IMachineLearningRepository, IMachineLearningRepository,
IMediaRepository, IMediaRepository,
immichAppConfig,
ISearchRepository, ISearchRepository,
ISharedLinkRepository, ISharedLinkRepository,
ISmartInfoRepository, ISmartInfoRepository,
@ -19,6 +20,7 @@ import {
} from '@app/domain'; } from '@app/domain';
import { BullModule } from '@nestjs/bull'; import { BullModule } from '@nestjs/bull';
import { Global, Module, Provider } from '@nestjs/common'; import { Global, Module, Provider } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { CryptoRepository } from './auth/crypto.repository'; import { CryptoRepository } from './auth/crypto.repository';
import { CommunicationGateway, CommunicationRepository } from './communication'; import { CommunicationGateway, CommunicationRepository } from './communication';
@ -71,6 +73,8 @@ const providers: Provider[] = [
@Global() @Global()
@Module({ @Module({
imports: [ imports: [
ConfigModule.forRoot(immichAppConfig),
TypeOrmModule.forRoot(databaseConfig), TypeOrmModule.forRoot(databaseConfig),
TypeOrmModule.forFeature([ TypeOrmModule.forFeature([
AssetEntity, AssetEntity,
@ -83,6 +87,7 @@ const providers: Provider[] = [
SystemConfigEntity, SystemConfigEntity,
UserTokenEntity, UserTokenEntity,
]), ]),
BullModule.forRootAsync({ BullModule.forRootAsync({
useFactory: async () => ({ useFactory: async () => ({
prefix: 'immich_bull', prefix: 'immich_bull',

View File

@ -45,6 +45,10 @@ export class JobRepository implements IJobRepository {
return this.queueMap[name].pause(); return this.queueMap[name].pause();
} }
resume(name: QueueName) {
return this.queueMap[name].resume();
}
empty(name: QueueName) { empty(name: QueueName) {
return this.queueMap[name].empty(); return this.queueMap[name].empty();
} }

View File

@ -1222,6 +1222,7 @@ export interface GetAssetCountByTimeBucketDto {
export const JobCommand = { export const JobCommand = {
Start: 'start', Start: 'start',
Pause: 'pause', Pause: 'pause',
Resume: 'resume',
Empty: 'empty' Empty: 'empty'
} as const; } as const;