diff --git a/src/components/SelectionManager.vue b/src/components/SelectionManager.vue
index 87f5bb27..fa210f00 100644
--- a/src/components/SelectionManager.vue
+++ b/src/components/SelectionManager.vue
@@ -27,7 +27,7 @@
-
+
diff --git a/src/components/modal/AddToAlbumModal.vue b/src/components/modal/AddToAlbumModal.vue
index bdcf12fa..0fcd7c8b 100644
--- a/src/components/modal/AddToAlbumModal.vue
+++ b/src/components/modal/AddToAlbumModal.vue
@@ -6,19 +6,25 @@
+
+
+ {{ t('memories', 'Processing … {n}/{m}', {
+ n: photosDone,
+ m: photos.length,
+ }) }}
+
@@ -60,4 +76,8 @@ export default class AddToAlbumModal extends Mixins(GlobalMixin) {
.outer {
margin-top: 15px;
}
+
+.info-pad {
+ margin-top: 6px;
+}
\ No newline at end of file
diff --git a/src/services/DavRequests.ts b/src/services/DavRequests.ts
index adc34d92..36ba74d3 100644
--- a/src/services/DavRequests.ts
+++ b/src/services/DavRequests.ts
@@ -115,7 +115,10 @@ async function getFilesInternal(fileIds: number[]): Promise {
let response: any = await client.getDirectoryContents('', options);
return response.data
.map((data: any) => genFileInfo(data))
- .map((data: any) => Object.assign({}, data, { filename: data.filename.replace(prefixPath, '') }));
+ .map((data: any) => Object.assign({}, data, {
+ originalFilename: data.filename,
+ filename: data.filename.replace(prefixPath, '')
+ }));
}
/**
@@ -556,7 +559,7 @@ export async function* removeFaceImages(user: string, name: string, fileIds: num
/**
* Get list of albums and convert to Days response
*/
- export async function getAlbumsData(): Promise {
+export async function getAlbumsData(): Promise {
let data: IAlbum[] = [];
try {
const res = await axios.get(generateUrl('/apps/memories/api/albums'));
@@ -577,4 +580,40 @@ export async function* removeFaceImages(user: string, name: string, fileIds: num
isalbum: true,
} as ITag)),
}]
- }
\ No newline at end of file
+}
+
+/**
+ * Remove images from a face.
+ *
+ * @param user User ID of album
+ * @param name Name of album (or ID)
+ * @param fileIds List of file IDs to add
+ * @returns Generator
+ */
+export async function* addToAlbum(user: string, name: string, fileIds: number[]) {
+ // Get files data
+ let fileInfos = await getFiles(fileIds.filter(f => f));
+
+ // Add each file
+ const calls = fileInfos.map((f) => async () => {
+ try {
+ await client.copyFile(
+ f.originalFilename,
+ `/photos/${user}/albums/${name}/${f.basename}`,
+ )
+ return f.fileid;
+ } catch (e) {
+ if (e.response?.status === 409) {
+ // File already exists, all good
+ return f.fileid;
+ }
+
+ showError(t('memories', 'Failed to add {filename} to album.', {
+ filename: f.filename,
+ }));
+ return 0;
+ }
+ });
+
+ yield* runInParallel(calls, 10);
+}
\ No newline at end of file
diff --git a/src/types.ts b/src/types.ts
index be9ba3b3..3f964d7b 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -5,6 +5,8 @@ export type IFileInfo = {
fileid: number;
/** Full file name, e.g. /pi/test/Qx0dq7dvEXA.jpg */
filename: string;
+ /** Original file name, e.g. /files/admin/pi/test/Qx0dq7dvEXA.jpg */
+ originalFilename: string;
/** Base name of file e.g. Qx0dq7dvEXA.jpg */
basename: string;
/** Etag identifier */