You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-07-07 06:16:05 +02:00
asset count instead of statistics
This commit is contained in:
3
mobile/openapi/README.md
generated
3
mobile/openapi/README.md
generated
@ -130,8 +130,8 @@ Class | Method | HTTP request | Description
|
|||||||
*LibrariesApi* | [**createLibrary**](doc//LibrariesApi.md#createlibrary) | **POST** /libraries |
|
*LibrariesApi* | [**createLibrary**](doc//LibrariesApi.md#createlibrary) | **POST** /libraries |
|
||||||
*LibrariesApi* | [**deleteLibrary**](doc//LibrariesApi.md#deletelibrary) | **DELETE** /libraries/{id} |
|
*LibrariesApi* | [**deleteLibrary**](doc//LibrariesApi.md#deletelibrary) | **DELETE** /libraries/{id} |
|
||||||
*LibrariesApi* | [**getAllLibraries**](doc//LibrariesApi.md#getalllibraries) | **GET** /libraries |
|
*LibrariesApi* | [**getAllLibraries**](doc//LibrariesApi.md#getalllibraries) | **GET** /libraries |
|
||||||
|
*LibrariesApi* | [**getAssetCount**](doc//LibrariesApi.md#getassetcount) | **GET** /libraries/{id}/count |
|
||||||
*LibrariesApi* | [**getLibrary**](doc//LibrariesApi.md#getlibrary) | **GET** /libraries/{id} |
|
*LibrariesApi* | [**getLibrary**](doc//LibrariesApi.md#getlibrary) | **GET** /libraries/{id} |
|
||||||
*LibrariesApi* | [**getLibraryStatistics**](doc//LibrariesApi.md#getlibrarystatistics) | **GET** /libraries/{id}/statistics |
|
|
||||||
*LibrariesApi* | [**scanLibrary**](doc//LibrariesApi.md#scanlibrary) | **POST** /libraries/{id}/scan |
|
*LibrariesApi* | [**scanLibrary**](doc//LibrariesApi.md#scanlibrary) | **POST** /libraries/{id}/scan |
|
||||||
*LibrariesApi* | [**updateLibrary**](doc//LibrariesApi.md#updatelibrary) | **PUT** /libraries/{id} |
|
*LibrariesApi* | [**updateLibrary**](doc//LibrariesApi.md#updatelibrary) | **PUT** /libraries/{id} |
|
||||||
*LibrariesApi* | [**validate**](doc//LibrariesApi.md#validate) | **POST** /libraries/{id}/validate |
|
*LibrariesApi* | [**validate**](doc//LibrariesApi.md#validate) | **POST** /libraries/{id}/validate |
|
||||||
@ -337,7 +337,6 @@ Class | Method | HTTP request | Description
|
|||||||
- [JobSettingsDto](doc//JobSettingsDto.md)
|
- [JobSettingsDto](doc//JobSettingsDto.md)
|
||||||
- [JobStatusDto](doc//JobStatusDto.md)
|
- [JobStatusDto](doc//JobStatusDto.md)
|
||||||
- [LibraryResponseDto](doc//LibraryResponseDto.md)
|
- [LibraryResponseDto](doc//LibraryResponseDto.md)
|
||||||
- [LibraryStatsResponseDto](doc//LibraryStatsResponseDto.md)
|
|
||||||
- [LicenseKeyDto](doc//LicenseKeyDto.md)
|
- [LicenseKeyDto](doc//LicenseKeyDto.md)
|
||||||
- [LicenseResponseDto](doc//LicenseResponseDto.md)
|
- [LicenseResponseDto](doc//LicenseResponseDto.md)
|
||||||
- [LogLevel](doc//LogLevel.md)
|
- [LogLevel](doc//LogLevel.md)
|
||||||
|
1
mobile/openapi/lib/api.dart
generated
1
mobile/openapi/lib/api.dart
generated
@ -150,7 +150,6 @@ part 'model/job_name.dart';
|
|||||||
part 'model/job_settings_dto.dart';
|
part 'model/job_settings_dto.dart';
|
||||||
part 'model/job_status_dto.dart';
|
part 'model/job_status_dto.dart';
|
||||||
part 'model/library_response_dto.dart';
|
part 'model/library_response_dto.dart';
|
||||||
part 'model/library_stats_response_dto.dart';
|
|
||||||
part 'model/license_key_dto.dart';
|
part 'model/license_key_dto.dart';
|
||||||
part 'model/license_response_dto.dart';
|
part 'model/license_response_dto.dart';
|
||||||
part 'model/log_level.dart';
|
part 'model/log_level.dart';
|
||||||
|
96
mobile/openapi/lib/api/libraries_api.dart
generated
96
mobile/openapi/lib/api/libraries_api.dart
generated
@ -147,6 +147,54 @@ class LibrariesApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Performs an HTTP 'GET /libraries/{id}/count' operation and returns the [Response].
|
||||||
|
/// Parameters:
|
||||||
|
///
|
||||||
|
/// * [String] id (required):
|
||||||
|
Future<Response> getAssetCountWithHttpInfo(String id,) async {
|
||||||
|
// ignore: prefer_const_declarations
|
||||||
|
final path = r'/libraries/{id}/count'
|
||||||
|
.replaceAll('{id}', id);
|
||||||
|
|
||||||
|
// ignore: prefer_final_locals
|
||||||
|
Object? postBody;
|
||||||
|
|
||||||
|
final queryParams = <QueryParam>[];
|
||||||
|
final headerParams = <String, String>{};
|
||||||
|
final formParams = <String, String>{};
|
||||||
|
|
||||||
|
const contentTypes = <String>[];
|
||||||
|
|
||||||
|
|
||||||
|
return apiClient.invokeAPI(
|
||||||
|
path,
|
||||||
|
'GET',
|
||||||
|
queryParams,
|
||||||
|
postBody,
|
||||||
|
headerParams,
|
||||||
|
formParams,
|
||||||
|
contentTypes.isEmpty ? null : contentTypes.first,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parameters:
|
||||||
|
///
|
||||||
|
/// * [String] id (required):
|
||||||
|
Future<num?> getAssetCount(String id,) async {
|
||||||
|
final response = await getAssetCountWithHttpInfo(id,);
|
||||||
|
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), 'num',) as num;
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// Performs an HTTP 'GET /libraries/{id}' operation and returns the [Response].
|
/// Performs an HTTP 'GET /libraries/{id}' operation and returns the [Response].
|
||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
@ -195,54 +243,6 @@ class LibrariesApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs an HTTP 'GET /libraries/{id}/statistics' operation and returns the [Response].
|
|
||||||
/// Parameters:
|
|
||||||
///
|
|
||||||
/// * [String] id (required):
|
|
||||||
Future<Response> getLibraryStatisticsWithHttpInfo(String id,) async {
|
|
||||||
// ignore: prefer_const_declarations
|
|
||||||
final path = r'/libraries/{id}/statistics'
|
|
||||||
.replaceAll('{id}', id);
|
|
||||||
|
|
||||||
// ignore: prefer_final_locals
|
|
||||||
Object? postBody;
|
|
||||||
|
|
||||||
final queryParams = <QueryParam>[];
|
|
||||||
final headerParams = <String, String>{};
|
|
||||||
final formParams = <String, String>{};
|
|
||||||
|
|
||||||
const contentTypes = <String>[];
|
|
||||||
|
|
||||||
|
|
||||||
return apiClient.invokeAPI(
|
|
||||||
path,
|
|
||||||
'GET',
|
|
||||||
queryParams,
|
|
||||||
postBody,
|
|
||||||
headerParams,
|
|
||||||
formParams,
|
|
||||||
contentTypes.isEmpty ? null : contentTypes.first,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parameters:
|
|
||||||
///
|
|
||||||
/// * [String] id (required):
|
|
||||||
Future<LibraryStatsResponseDto?> getLibraryStatistics(String id,) async {
|
|
||||||
final response = await getLibraryStatisticsWithHttpInfo(id,);
|
|
||||||
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), 'LibraryStatsResponseDto',) as LibraryStatsResponseDto;
|
|
||||||
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Performs an HTTP 'POST /libraries/{id}/scan' operation and returns the [Response].
|
/// Performs an HTTP 'POST /libraries/{id}/scan' operation and returns the [Response].
|
||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
|
2
mobile/openapi/lib/api_client.dart
generated
2
mobile/openapi/lib/api_client.dart
generated
@ -354,8 +354,6 @@ class ApiClient {
|
|||||||
return JobStatusDto.fromJson(value);
|
return JobStatusDto.fromJson(value);
|
||||||
case 'LibraryResponseDto':
|
case 'LibraryResponseDto':
|
||||||
return LibraryResponseDto.fromJson(value);
|
return LibraryResponseDto.fromJson(value);
|
||||||
case 'LibraryStatsResponseDto':
|
|
||||||
return LibraryStatsResponseDto.fromJson(value);
|
|
||||||
case 'LicenseKeyDto':
|
case 'LicenseKeyDto':
|
||||||
return LicenseKeyDto.fromJson(value);
|
return LicenseKeyDto.fromJson(value);
|
||||||
case 'LicenseResponseDto':
|
case 'LicenseResponseDto':
|
||||||
|
123
mobile/openapi/lib/model/library_stats_response_dto.dart
generated
123
mobile/openapi/lib/model/library_stats_response_dto.dart
generated
@ -1,123 +0,0 @@
|
|||||||
//
|
|
||||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
|
||||||
//
|
|
||||||
// @dart=2.18
|
|
||||||
|
|
||||||
// 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 LibraryStatsResponseDto {
|
|
||||||
/// Returns a new [LibraryStatsResponseDto] instance.
|
|
||||||
LibraryStatsResponseDto({
|
|
||||||
this.photos = 0,
|
|
||||||
this.total = 0,
|
|
||||||
this.usage = 0,
|
|
||||||
this.videos = 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
int photos;
|
|
||||||
|
|
||||||
int total;
|
|
||||||
|
|
||||||
int usage;
|
|
||||||
|
|
||||||
int videos;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) => identical(this, other) || other is LibraryStatsResponseDto &&
|
|
||||||
other.photos == photos &&
|
|
||||||
other.total == total &&
|
|
||||||
other.usage == usage &&
|
|
||||||
other.videos == videos;
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode =>
|
|
||||||
// ignore: unnecessary_parenthesis
|
|
||||||
(photos.hashCode) +
|
|
||||||
(total.hashCode) +
|
|
||||||
(usage.hashCode) +
|
|
||||||
(videos.hashCode);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() => 'LibraryStatsResponseDto[photos=$photos, total=$total, usage=$usage, videos=$videos]';
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final json = <String, dynamic>{};
|
|
||||||
json[r'photos'] = this.photos;
|
|
||||||
json[r'total'] = this.total;
|
|
||||||
json[r'usage'] = this.usage;
|
|
||||||
json[r'videos'] = this.videos;
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a new [LibraryStatsResponseDto] instance and imports its values from
|
|
||||||
/// [value] if it's a [Map], null otherwise.
|
|
||||||
// ignore: prefer_constructors_over_static_methods
|
|
||||||
static LibraryStatsResponseDto? fromJson(dynamic value) {
|
|
||||||
upgradeDto(value, "LibraryStatsResponseDto");
|
|
||||||
if (value is Map) {
|
|
||||||
final json = value.cast<String, dynamic>();
|
|
||||||
|
|
||||||
return LibraryStatsResponseDto(
|
|
||||||
photos: mapValueOfType<int>(json, r'photos')!,
|
|
||||||
total: mapValueOfType<int>(json, r'total')!,
|
|
||||||
usage: mapValueOfType<int>(json, r'usage')!,
|
|
||||||
videos: mapValueOfType<int>(json, r'videos')!,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<LibraryStatsResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
|
|
||||||
final result = <LibraryStatsResponseDto>[];
|
|
||||||
if (json is List && json.isNotEmpty) {
|
|
||||||
for (final row in json) {
|
|
||||||
final value = LibraryStatsResponseDto.fromJson(row);
|
|
||||||
if (value != null) {
|
|
||||||
result.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toList(growable: growable);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Map<String, LibraryStatsResponseDto> mapFromJson(dynamic json) {
|
|
||||||
final map = <String, LibraryStatsResponseDto>{};
|
|
||||||
if (json is Map && json.isNotEmpty) {
|
|
||||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
|
||||||
for (final entry in json.entries) {
|
|
||||||
final value = LibraryStatsResponseDto.fromJson(entry.value);
|
|
||||||
if (value != null) {
|
|
||||||
map[entry.key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
// maps a json object with a list of LibraryStatsResponseDto-objects as value to a dart map
|
|
||||||
static Map<String, List<LibraryStatsResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
|
||||||
final map = <String, List<LibraryStatsResponseDto>>{};
|
|
||||||
if (json is Map && json.isNotEmpty) {
|
|
||||||
// ignore: parameter_assignments
|
|
||||||
json = json.cast<String, dynamic>();
|
|
||||||
for (final entry in json.entries) {
|
|
||||||
map[entry.key] = LibraryStatsResponseDto.listFromJson(entry.value, growable: growable,);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The list of required keys that must be present in a JSON.
|
|
||||||
static const requiredKeys = <String>{
|
|
||||||
'photos',
|
|
||||||
'total',
|
|
||||||
'usage',
|
|
||||||
'videos',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -2853,9 +2853,9 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/libraries/{id}/scan": {
|
"/libraries/{id}/count": {
|
||||||
"post": {
|
"get": {
|
||||||
"operationId": "scanLibrary",
|
"operationId": "getAssetCount",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -2868,7 +2868,14 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2888,9 +2895,9 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/libraries/{id}/statistics": {
|
"/libraries/{id}/scan": {
|
||||||
"get": {
|
"post": {
|
||||||
"operationId": "getLibraryStatistics",
|
"operationId": "scanLibrary",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -2903,14 +2910,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"204": {
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/LibraryStatsResponseDto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -9464,34 +9464,6 @@
|
|||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"LibraryStatsResponseDto": {
|
|
||||||
"properties": {
|
|
||||||
"photos": {
|
|
||||||
"default": 0,
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"total": {
|
|
||||||
"default": 0,
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"usage": {
|
|
||||||
"default": 0,
|
|
||||||
"format": "int64",
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"videos": {
|
|
||||||
"default": 0,
|
|
||||||
"type": "integer"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"photos",
|
|
||||||
"total",
|
|
||||||
"usage",
|
|
||||||
"videos"
|
|
||||||
],
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"LicenseKeyDto": {
|
"LicenseKeyDto": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"activationKey": {
|
"activationKey": {
|
||||||
|
@ -574,12 +574,6 @@ export type UpdateLibraryDto = {
|
|||||||
importPaths?: string[];
|
importPaths?: string[];
|
||||||
name?: string;
|
name?: string;
|
||||||
};
|
};
|
||||||
export type LibraryStatsResponseDto = {
|
|
||||||
photos: number;
|
|
||||||
total: number;
|
|
||||||
usage: number;
|
|
||||||
videos: number;
|
|
||||||
};
|
|
||||||
export type ValidateLibraryDto = {
|
export type ValidateLibraryDto = {
|
||||||
exclusionPatterns?: string[];
|
exclusionPatterns?: string[];
|
||||||
importPaths?: string[];
|
importPaths?: string[];
|
||||||
@ -2099,6 +2093,16 @@ export function updateLibrary({ id, updateLibraryDto }: {
|
|||||||
body: updateLibraryDto
|
body: updateLibraryDto
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
export function getAssetCount({ id }: {
|
||||||
|
id: string;
|
||||||
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
|
status: 200;
|
||||||
|
data: number;
|
||||||
|
}>(`/libraries/${encodeURIComponent(id)}/count`, {
|
||||||
|
...opts
|
||||||
|
}));
|
||||||
|
}
|
||||||
export function scanLibrary({ id }: {
|
export function scanLibrary({ id }: {
|
||||||
id: string;
|
id: string;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
@ -2107,16 +2111,6 @@ export function scanLibrary({ id }: {
|
|||||||
method: "POST"
|
method: "POST"
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
export function getLibraryStatistics({ id }: {
|
|
||||||
id: string;
|
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
|
||||||
return oazapfts.ok(oazapfts.fetchJson<{
|
|
||||||
status: 200;
|
|
||||||
data: LibraryStatsResponseDto;
|
|
||||||
}>(`/libraries/${encodeURIComponent(id)}/statistics`, {
|
|
||||||
...opts
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
export function validate({ id, validateLibraryDto }: {
|
export function validate({ id, validateLibraryDto }: {
|
||||||
id: string;
|
id: string;
|
||||||
validateLibraryDto: ValidateLibraryDto;
|
validateLibraryDto: ValidateLibraryDto;
|
||||||
|
@ -57,10 +57,10 @@ export class LibraryController {
|
|||||||
return this.service.validate(id, dto);
|
return this.service.validate(id, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id/statistics')
|
@Get(':id/count')
|
||||||
@Authenticated({ permission: Permission.LIBRARY_STATISTICS, admin: true })
|
@Authenticated({ permission: Permission.LIBRARY_STATISTICS, admin: true })
|
||||||
getLibraryStatistics(@Param() { id }: UUIDParamDto): Promise<LibraryStatsResponseDto> {
|
getAssetCount(@Param() { id }: UUIDParamDto): Promise<number> {
|
||||||
return this.service.getStatistics(id);
|
return this.service.getAssetCount(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post(':id/scan')
|
@Post(':id/scan')
|
||||||
|
@ -201,5 +201,5 @@ export interface IAssetRepository {
|
|||||||
upsertFiles(files: UpsertFileOptions[]): Promise<void>;
|
upsertFiles(files: UpsertFileOptions[]): Promise<void>;
|
||||||
updateOffline(library: LibraryEntity): Promise<UpdateResult>;
|
updateOffline(library: LibraryEntity): Promise<UpdateResult>;
|
||||||
getNewPaths(libraryId: string, paths: string[]): Promise<string[]>;
|
getNewPaths(libraryId: string, paths: string[]): Promise<string[]>;
|
||||||
getAssetCount(id: string, options: AssetSearchOptions): Promise<number | undefined>;
|
getAssetCount(options: AssetSearchOptions): Promise<number | undefined>;
|
||||||
}
|
}
|
||||||
|
@ -786,7 +786,7 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
.then((result) => result.map((row: { path: string }) => row.path));
|
.then((result) => result.map((row: { path: string }) => row.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAssetCount(id: string, options: AssetSearchOptions = {}): Promise<number | undefined> {
|
async getAssetCount(options: AssetSearchOptions = {}): Promise<number | undefined> {
|
||||||
let builder = this.repository.createQueryBuilder('asset').leftJoinAndSelect('asset.files', 'files');
|
let builder = this.repository.createQueryBuilder('asset').leftJoinAndSelect('asset.files', 'files');
|
||||||
builder = searchAssetBuilder(builder, options);
|
builder = searchAssetBuilder(builder, options);
|
||||||
return builder.getCount();
|
return builder.getCount();
|
||||||
|
@ -249,7 +249,12 @@ export class AssetService extends BaseService {
|
|||||||
|
|
||||||
const { thumbnailFile, previewFile } = getAssetFiles(asset.files);
|
const { thumbnailFile, previewFile } = getAssetFiles(asset.files);
|
||||||
const files = [thumbnailFile?.path, previewFile?.path, asset.encodedVideoPath];
|
const files = [thumbnailFile?.path, previewFile?.path, asset.encodedVideoPath];
|
||||||
if (deleteOnDisk) {
|
|
||||||
|
if (deleteOnDisk && !asset.isOffline) {
|
||||||
|
/* We don't want to delete an offline asset because it is either...
|
||||||
|
...missing from disk => don't delete the file since it doesn't exist where we expect
|
||||||
|
...outside of any import path => don't delete the file since we're not responsible for it
|
||||||
|
...matching an exclusion pattern => don't delete the file since it's excluded */
|
||||||
files.push(asset.sidecarPath, asset.originalPath);
|
files.push(asset.sidecarPath, asset.originalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ export class JobService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case JobName.GENERATE_THUMBNAILS: {
|
case JobName.GENERATE_THUMBNAILS: {
|
||||||
if (!item.data.notify && item.data.source !== 'upload') {
|
if (!item.data.notify && item.data.source !== 'upload' && item.data.source !== 'library-import') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
import { BadRequestException, Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||||
import { R_OK } from 'node:constants';
|
import { R_OK } from 'node:constants';
|
||||||
import path, { basename, isAbsolute, parse } from 'node:path';
|
import path, { basename, isAbsolute, parse } from 'node:path';
|
||||||
import picomatch from 'picomatch';
|
import picomatch from 'picomatch';
|
||||||
@ -174,12 +174,12 @@ export class LibraryService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStatistics(id: string): Promise<LibraryStatsResponseDto> {
|
async getAssetCount(id: string): Promise<number> {
|
||||||
const statistics = await this.libraryRepository.getStatistics(id);
|
const count = await this.assetRepository.getAssetCount({ libraryId: id });
|
||||||
if (!statistics) {
|
if (count == undefined) {
|
||||||
throw new BadRequestException(`Library ${id} not found`);
|
throw new InternalServerErrorException(`Failed to get asset count for library ${id}`);
|
||||||
}
|
}
|
||||||
return statistics;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
async get(id: string): Promise<LibraryResponseDto> {
|
async get(id: string): Promise<LibraryResponseDto> {
|
||||||
@ -354,7 +354,8 @@ export class LibraryService extends BaseService {
|
|||||||
private processEntity(filePath: string, ownerId: string, libraryId: string): AssetCreate {
|
private processEntity(filePath: string, ownerId: string, libraryId: string): AssetCreate {
|
||||||
const assetPath = path.normalize(filePath);
|
const assetPath = path.normalize(filePath);
|
||||||
|
|
||||||
const now = new Date();
|
// This date will be set until metadata extraction runs
|
||||||
|
const datePlaceholder = new Date('1900-01-01');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ownerId: ownerId,
|
ownerId: ownerId,
|
||||||
@ -365,9 +366,9 @@ export class LibraryService extends BaseService {
|
|||||||
// TODO: device asset id is deprecated, remove it
|
// TODO: device asset id is deprecated, remove it
|
||||||
deviceAssetId: `${basename(assetPath)}`.replaceAll(/\s+/g, ''),
|
deviceAssetId: `${basename(assetPath)}`.replaceAll(/\s+/g, ''),
|
||||||
deviceId: 'Library Import',
|
deviceId: 'Library Import',
|
||||||
fileCreatedAt: now,
|
fileCreatedAt: datePlaceholder,
|
||||||
fileModifiedAt: now,
|
fileModifiedAt: datePlaceholder,
|
||||||
localDateTime: now,
|
localDateTime: datePlaceholder,
|
||||||
type: mimeTypes.isVideo(assetPath) ? AssetType.VIDEO : AssetType.IMAGE,
|
type: mimeTypes.isVideo(assetPath) ? AssetType.VIDEO : AssetType.IMAGE,
|
||||||
originalFileName: parse(assetPath).base,
|
originalFileName: parse(assetPath).base,
|
||||||
isExternal: true,
|
isExternal: true,
|
||||||
@ -620,7 +621,7 @@ export class LibraryService extends BaseService {
|
|||||||
return JobStatus.SKIPPED;
|
return JobStatus.SKIPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetCount = await this.assetRepository.getAssetCount(library.id, { withDeleted: true });
|
const assetCount = await this.assetRepository.getAssetCount({ libraryId: job.id, withDeleted: true });
|
||||||
|
|
||||||
if (!assetCount) {
|
if (!assetCount) {
|
||||||
this.logger.log(`Library ${library.id} is empty, no need to check assets`);
|
this.logger.log(`Library ${library.id} is empty, no need to check assets`);
|
||||||
|
@ -52,7 +52,7 @@ export class TrashService extends BaseService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
for await (const assetIds of assetPagination) {
|
for await (const assetIds of assetPagination) {
|
||||||
this.logger.debug(`Queueing ${assetIds.length} assets for deletion from the trash`);
|
this.logger.debug(`Queueing ${assetIds.length} asset(s) for deletion from the trash`);
|
||||||
count += assetIds.length;
|
count += assetIds.length;
|
||||||
await this.jobRepository.queueAll(
|
await this.jobRepository.queueAll(
|
||||||
assetIds.map((assetId) => ({
|
assetIds.map((assetId) => ({
|
||||||
|
@ -12,18 +12,16 @@
|
|||||||
notificationController,
|
notificationController,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { ByteUnit, getBytesWithUnit } from '$lib/utils/byte-units';
|
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
import {
|
import {
|
||||||
createLibrary,
|
createLibrary,
|
||||||
deleteLibrary,
|
deleteLibrary,
|
||||||
getAllLibraries,
|
getAllLibraries,
|
||||||
getLibraryStatistics,
|
getAssetCount,
|
||||||
getUserAdmin,
|
getUserAdmin,
|
||||||
scanLibrary,
|
scanLibrary,
|
||||||
updateLibrary,
|
updateLibrary,
|
||||||
type LibraryResponseDto,
|
type LibraryResponseDto,
|
||||||
type LibraryStatsResponseDto,
|
|
||||||
type UserResponseDto,
|
type UserResponseDto,
|
||||||
} from '@immich/sdk';
|
} from '@immich/sdk';
|
||||||
import { mdiDatabase, mdiDotsVertical, mdiPlusBoxOutline, mdiSync } from '@mdi/js';
|
import { mdiDatabase, mdiDotsVertical, mdiPlusBoxOutline, mdiSync } from '@mdi/js';
|
||||||
@ -44,13 +42,8 @@
|
|||||||
|
|
||||||
let libraries: LibraryResponseDto[] = $state([]);
|
let libraries: LibraryResponseDto[] = $state([]);
|
||||||
|
|
||||||
let stats: LibraryStatsResponseDto[] = [];
|
|
||||||
let owner: UserResponseDto[] = $state([]);
|
let owner: UserResponseDto[] = $state([]);
|
||||||
let photos: number[] = [];
|
let assetCount: number[] = $state([]);
|
||||||
let videos: number[] = [];
|
|
||||||
let totalCount: number[] = $state([]);
|
|
||||||
let diskUsage: number[] = $state([]);
|
|
||||||
let diskUsageUnit: ByteUnit[] = $state([]);
|
|
||||||
let editImportPaths: number | undefined = $state();
|
let editImportPaths: number | undefined = $state();
|
||||||
let editScanSettings: number | undefined = $state();
|
let editScanSettings: number | undefined = $state();
|
||||||
let renameLibrary: number | undefined = $state();
|
let renameLibrary: number | undefined = $state();
|
||||||
@ -74,12 +67,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const refreshStats = async (listIndex: number) => {
|
const refreshStats = async (listIndex: number) => {
|
||||||
stats[listIndex] = await getLibraryStatistics({ id: libraries[listIndex].id });
|
assetCount[listIndex] = await getAssetCount({ id: libraries[listIndex].id });
|
||||||
owner[listIndex] = await getUserAdmin({ id: libraries[listIndex].ownerId });
|
owner[listIndex] = await getUserAdmin({ id: libraries[listIndex].ownerId });
|
||||||
photos[listIndex] = stats[listIndex].photos;
|
|
||||||
videos[listIndex] = stats[listIndex].videos;
|
|
||||||
totalCount[listIndex] = stats[listIndex].total;
|
|
||||||
[diskUsage[listIndex], diskUsageUnit[listIndex]] = getBytesWithUnit(stats[listIndex].usage, 0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async function readLibraryList() {
|
async function readLibraryList() {
|
||||||
@ -190,10 +179,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
await refreshStats(index);
|
await refreshStats(index);
|
||||||
const assetCount = totalCount[index];
|
const count = assetCount[index];
|
||||||
if (assetCount > 0) {
|
if (count > 0) {
|
||||||
const isConfirmed = await dialogController.show({
|
const isConfirmed = await dialogController.show({
|
||||||
prompt: $t('admin.confirm_delete_library_assets', { values: { count: assetCount } }),
|
prompt: $t('admin.confirm_delete_library_assets', { values: { count } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isConfirmed) {
|
if (!isConfirmed) {
|
||||||
@ -242,19 +231,18 @@
|
|||||||
<thead
|
<thead
|
||||||
class="mb-4 flex h-12 w-full rounded-md border bg-gray-50 text-immich-primary dark:border-immich-dark-gray dark:bg-immich-dark-gray dark:text-immich-dark-primary"
|
class="mb-4 flex h-12 w-full rounded-md border bg-gray-50 text-immich-primary dark:border-immich-dark-gray dark:bg-immich-dark-gray dark:text-immich-dark-primary"
|
||||||
>
|
>
|
||||||
<tr class="grid grid-cols-6 w-full place-items-center">
|
<tr class="grid grid-cols-5 w-full place-items-center">
|
||||||
<th class="text-center text-sm font-medium">{$t('type')}</th>
|
<th class="text-center text-sm font-medium">{$t('type')}</th>
|
||||||
<th class="text-center text-sm font-medium">{$t('name')}</th>
|
<th class="text-center text-sm font-medium">{$t('name')}</th>
|
||||||
<th class="text-center text-sm font-medium">{$t('owner')}</th>
|
<th class="text-center text-sm font-medium">{$t('owner')}</th>
|
||||||
<th class="text-center text-sm font-medium">{$t('assets')}</th>
|
<th class="text-center text-sm font-medium">{$t('assets')}</th>
|
||||||
<th class="text-center text-sm font-medium">{$t('size')}</th>
|
|
||||||
<th class="text-center text-sm font-medium"></th>
|
<th class="text-center text-sm font-medium"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="block overflow-y-auto rounded-md border dark:border-immich-dark-gray">
|
<tbody class="block overflow-y-auto rounded-md border dark:border-immich-dark-gray">
|
||||||
{#each libraries as library, index (library.id)}
|
{#each libraries as library, index (library.id)}
|
||||||
<tr
|
<tr
|
||||||
class={`grid grid-cols-6 h-[80px] w-full place-items-center text-center dark:text-immich-dark-fg ${
|
class={`grid grid-cols-5 h-[80px] w-full place-items-center text-center dark:text-immich-dark-fg ${
|
||||||
index % 2 == 0
|
index % 2 == 0
|
||||||
? 'bg-immich-gray dark:bg-immich-dark-gray/75'
|
? 'bg-immich-gray dark:bg-immich-dark-gray/75'
|
||||||
: 'bg-immich-bg dark:bg-immich-dark-gray/50'
|
: 'bg-immich-bg dark:bg-immich-dark-gray/50'
|
||||||
@ -275,18 +263,10 @@
|
|||||||
{:else}{owner[index].name}{/if}
|
{:else}{owner[index].name}{/if}
|
||||||
</td>
|
</td>
|
||||||
<td class=" text-ellipsis px-4 text-sm">
|
<td class=" text-ellipsis px-4 text-sm">
|
||||||
{#if totalCount[index] == undefined}
|
{#if assetCount[index] == undefined}
|
||||||
<LoadingSpinner size="40" />
|
<LoadingSpinner size="40" />
|
||||||
{:else}
|
{:else}
|
||||||
{totalCount[index].toLocaleString($locale)}
|
{assetCount[index].toLocaleString($locale)}
|
||||||
{/if}
|
|
||||||
</td>
|
|
||||||
<td class=" text-ellipsis px-4 text-sm">
|
|
||||||
{#if diskUsage[index] == undefined}
|
|
||||||
<LoadingSpinner size="40" />
|
|
||||||
{:else}
|
|
||||||
{diskUsage[index]}
|
|
||||||
{diskUsageUnit[index]}
|
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user