feat: Improve notifications, add donation button, improved asn form field

This commit is contained in:
Anton Stubenbord
2023-03-06 22:21:14 +01:00
parent bd891a8658
commit 1172e54199
37 changed files with 985 additions and 305 deletions

View File

@@ -76,7 +76,7 @@ class DocumentModel extends Equatable {
DateTime? created,
DateTime? modified,
DateTime? added,
int? archiveSerialNumber,
int? Function()? archiveSerialNumber,
String? originalFileName,
String? archivedFileName,
}) {
@@ -84,17 +84,18 @@ class DocumentModel extends Equatable {
id: id,
title: title ?? this.title,
content: content ?? this.content,
documentType:
documentType != null ? documentType.call() : this.documentType,
documentType: documentType != null ? documentType() : this.documentType,
correspondent:
correspondent != null ? correspondent.call() : this.correspondent,
storagePath: storagePath != null ? storagePath.call() : this.storagePath,
correspondent != null ? correspondent() : this.correspondent,
storagePath: storagePath != null ? storagePath() : this.storagePath,
tags: tags ?? this.tags,
created: created ?? this.created,
modified: modified ?? this.modified,
added: added ?? this.added,
originalFileName: originalFileName ?? this.originalFileName,
archiveSerialNumber: archiveSerialNumber ?? this.archiveSerialNumber,
archiveSerialNumber: archiveSerialNumber != null
? archiveSerialNumber()
: this.archiveSerialNumber,
archivedFileName: archivedFileName ?? this.archivedFileName,
);
}

View File

@@ -24,6 +24,12 @@ abstract class PaperlessDocumentsApi {
Future<Uint8List> getPreview(int docId);
String getThumbnailUrl(int docId);
Future<Uint8List> download(DocumentModel document, {bool original});
Future<void> downloadToFile(
DocumentModel document,
String localFilePath, {
bool original = false,
void Function(double)? onProgressChanged,
});
Future<FieldSuggestions> findSuggestions(DocumentModel document);
Future<List<String>> autocomplete(String query, [int limit = 10]);

View File

@@ -199,7 +199,7 @@ class PaperlessDocumentsApiImpl implements PaperlessDocumentsApi {
try {
final response = await client.get(
"/api/documents/${document.id}/download/",
queryParameters: original ? {'original': true} : {},
queryParameters: {'original': original},
options: Options(responseType: ResponseType.bytes),
);
return response.data;
@@ -208,6 +208,27 @@ class PaperlessDocumentsApiImpl implements PaperlessDocumentsApi {
}
}
@override
Future<void> downloadToFile(
DocumentModel document,
String localFilePath, {
bool original = false,
void Function(double)? onProgressChanged,
}) async {
try {
final response = await client.download(
"/api/documents/${document.id}/download/",
localFilePath,
onReceiveProgress: (count, total) =>
onProgressChanged?.call(count / total),
queryParameters: {'original': original},
);
return response.data;
} on DioError catch (err) {
throw err.error!;
}
}
@override
Future<DocumentMetaData> getMetaData(DocumentModel document) async {
try {