diff --git a/apps/picsa-tools/resources-tool/src/app/components/resource-item/templates/video.ts b/apps/picsa-tools/resources-tool/src/app/components/resource-item/templates/video.ts
index b5198f1e3..c1c1c43d0 100644
--- a/apps/picsa-tools/resources-tool/src/app/components/resource-item/templates/video.ts
+++ b/apps/picsa-tools/resources-tool/src/app/components/resource-item/templates/video.ts
@@ -11,7 +11,7 @@ import { ResourcesToolService } from '../../../services/resources-tool.service';
{{ resource.title | translate }}
-
+
;
- public isDownloaded: boolean;
public videoData: Blob;
+ public showDownloadOverlay = false;
+
constructor(private service: ResourcesToolService) {}
async ngOnInit() {
@@ -66,14 +67,20 @@ export class ResourceItemVideoComponent implements OnInit {
const dbDoc = await this.service.dbFileCollection.findOne(this.resource._key).exec();
if (dbDoc) {
this.dbDoc = dbDoc;
+ this.loadVideo();
}
}
public async loadVideo() {
- const dbAttachment = await this.service.getFileAttachment(this.dbDoc);
- if (dbAttachment) {
- this.isDownloaded = true;
- this.videoData = dbAttachment;
+ // avoid duplicate calls on initial init as downloadComplete emits
+ if (!this.videoData) {
+ const dbAttachment = await this.service.getFileAttachment(this.dbDoc);
+ if (dbAttachment) {
+ this.videoData = dbAttachment;
+ this.showDownloadOverlay = false;
+ } else {
+ this.showDownloadOverlay = true;
+ }
}
}
}
diff --git a/apps/picsa-tools/resources-tool/src/app/data/index.ts b/apps/picsa-tools/resources-tool/src/app/data/index.ts
index 956fda755..0a78dd33a 100644
--- a/apps/picsa-tools/resources-tool/src/app/data/index.ts
+++ b/apps/picsa-tools/resources-tool/src/app/data/index.ts
@@ -59,7 +59,7 @@ for (const [key, resources] of Object.entries(typeExports)) {
* Format of hardcoded resources to be used in database
* TODO - alternate formats can be removed once DB used throughout app
*/
-const dbEntries: schemas.IResourceFile[] = [];
+const dbFileEntries: schemas.IResourceFile[] = [];
for (const entry of [...typeExports.file, ...typeExports.video]) {
/* eslint-disable @typescript-eslint/no-unused-vars */
const { _created, _key, _modified, meta, appCountries, image, imageFit, subtitle, ...keptFields } = entry;
@@ -71,8 +71,8 @@ for (const entry of [...typeExports.file, ...typeExports.video]) {
countries: appCountries || [],
},
};
- dbEntries.push(file);
+ dbFileEntries.push(file);
}
-export const DB_ENTRIES = dbEntries;
+export const DB_FILE_ENTRIES = dbFileEntries;
export default { ...typeExports, byId };
diff --git a/apps/picsa-tools/resources-tool/src/app/pages/collection/collection.component.html b/apps/picsa-tools/resources-tool/src/app/pages/collection/collection.component.html
index 1f2d275bd..2dc71b051 100644
--- a/apps/picsa-tools/resources-tool/src/app/pages/collection/collection.component.html
+++ b/apps/picsa-tools/resources-tool/src/app/pages/collection/collection.component.html
@@ -1,7 +1,7 @@
-
+
- {{ 'Collection not found' | translate }}
+ {{
+ 'Collection not found' | translate
+ }}
-
-
diff --git a/apps/picsa-tools/resources-tool/src/app/services/resources-tool.service.ts b/apps/picsa-tools/resources-tool/src/app/services/resources-tool.service.ts
index 05488bbfa..a5b0aef74 100644
--- a/apps/picsa-tools/resources-tool/src/app/services/resources-tool.service.ts
+++ b/apps/picsa-tools/resources-tool/src/app/services/resources-tool.service.ts
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';
import { PicsaAsyncService } from '@picsa/shared/services/asyncService.service';
import { PicsaDatabase_V2_Service } from '@picsa/shared/services/core/db_v2';
-import { RxCollection } from 'rxdb';
+import { RxCollection, RxDocument } from 'rxdb';
-import HARDCODED_RESOURCES from '../data';
+import { DB_FILE_ENTRIES } from '../data';
import * as schemas from '../schemas';
@Injectable({ providedIn: 'root' })
@@ -29,27 +29,12 @@ export class ResourcesToolService extends PicsaAsyncService {
return this.dbService.db.collections['resources_tool_files'] as RxCollection;
}
+ public getFileAttachment(doc: RxDocument) {
+ return this.dbService.getAttachment('resources_tool_files', doc as any);
+ }
+
private async populateFileList() {
- // TODO - ideally refactor hardcoded to keep all file resources together and remove store methods
- const { file, video } = HARDCODED_RESOURCES;
- /* eslint-disable @typescript-eslint/no-unused-vars */
- const combined = [...file, ...video];
- const fileResources: schemas.IResourceFile[] = combined.map((entry) => {
- const { _created, _key, _modified, _downloaded, meta, appCountries, image, imageFit, subtitle, ...keptFields } =
- entry;
- const file: schemas.IResourceFile = {
- ...keptFields,
- id: _key,
- md5Hash: 'TODO',
- size_kb: -1,
- priority: entry.priority || 1,
- };
- return file;
- });
- console.log('populating file resources', fileResources);
- // TODO - handle resource removal or file updated
- await this.dbFileCollection.bulkUpsert(fileResources);
- // dbFormCollection.bulkUpsert(HARDCODED_FORMS);
+ await this.dbFileCollection.bulkUpsert(DB_FILE_ENTRIES);
}
private async populateAssetResources() {