diff --git a/apps/picsa-apps/extension-app-native/android/app/build.gradle b/apps/picsa-apps/extension-app-native/android/app/build.gradle index fa08e2a44..356f24f33 100644 --- a/apps/picsa-apps/extension-app-native/android/app/build.gradle +++ b/apps/picsa-apps/extension-app-native/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "io.picsa.extension" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 3036000 - versionName "3.36.0" + versionCode 3036001 + versionName "3.36.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/apps/picsa-tools/manual-tool/src/app/pages/home/home.component.html b/apps/picsa-tools/manual-tool/src/app/pages/home/home.component.html index 8c2dce76a..181089cd8 100644 --- a/apps/picsa-tools/manual-tool/src/app/pages/home/home.component.html +++ b/apps/picsa-tools/manual-tool/src/app/pages/home/home.component.html @@ -13,7 +13,7 @@ > - + - + - +
diff --git a/apps/picsa-tools/manual-tool/src/app/pages/home/home.component.ts b/apps/picsa-tools/manual-tool/src/app/pages/home/home.component.ts index d2e08324c..98b0ddabb 100644 --- a/apps/picsa-tools/manual-tool/src/app/pages/home/home.component.ts +++ b/apps/picsa-tools/manual-tool/src/app/pages/home/home.component.ts @@ -36,7 +36,11 @@ const LOCALISED_VERSIONS: { [version in IManualVersion]: { [code: string]: IReso animations: [FlyInOut({ axis: 'Y' }), FadeInOut({ inDelay: 200, inSpeed: 300 })], }) export class HomeComponent implements OnDestroy, AfterViewInit { - public resourceDoc: RxDocument | null; + // TODO - ideally all variables should be tracked by version (use additional component) + public resourceDocs: { [version in IManualVersion]: RxDocument | null } = { + farmer: null, + extension: null, + }; public localisation: string; @@ -81,6 +85,7 @@ export class HomeComponent implements OnDestroy, AfterViewInit { /** Prompt manual load if resource file attachment updated */ public async handleResourceAttachmentChange(attachment?: RxAttachment) { if (attachment) { + console.log('resource attachment changed', attachment); await this.loadManual(); this.cdr.markForCheck(); } @@ -99,8 +104,8 @@ export class HomeComponent implements OnDestroy, AfterViewInit { } const manualDoc = await this.resourcesService.dbFiles.findOne(manualResource.id).exec(); if (manualDoc) { - this.resourceDoc = manualDoc; - const uri = await this.resourcesService.getFileAttachmentURI(this.resourceDoc, true); + this.resourceDocs[version] = manualDoc; + const uri = await this.resourcesService.getFileAttachmentURI(manualDoc, true); if (uri) { this.downloadPrompt.show = false; this.pdfSrc = uri; @@ -112,7 +117,6 @@ export class HomeComponent implements OnDestroy, AfterViewInit { public async setSelectedTab(index: number) { this.pdfSrc = undefined; - this.resourceDoc = null; const version = index === 1 ? 'farmer' : 'extension'; this.setManualVersion(version); await this.loadManual(); diff --git a/apps/picsa-tools/resources-tool/src/app/components/resource-item/file/file.html b/apps/picsa-tools/resources-tool/src/app/components/resource-item/file/file.html index 82b5f3686..da2a6cf0c 100644 --- a/apps/picsa-tools/resources-tool/src/app/components/resource-item/file/file.html +++ b/apps/picsa-tools/resources-tool/src/app/components/resource-item/file/file.html @@ -3,7 +3,11 @@
-
+
= { - downscaled_forecast_kasungu_en: { - id: 'downscaled_forecast_kasungu_en', + downscaled_forecast_2023_kasungu_en: { + id: 'downscaled_forecast_2023_kasungu_en', description: '', filename: 'forecast-kasungu-english.pdf', mimetype: 'application/pdf', - title: 'KASUNGU DISTRICT DOWNSCALED SEASONAL FORECAST, 2022-2023', + title: 'KASUNGU DISTRICT DOWNSCALED SEASONAL FORECAST, 2023-2024', type: 'file', subtype: 'pdf', - url: 'https://firebasestorage.googleapis.com/v0/b/picsa-apps.appspot.com/o/weather%2Fforecast-kasungu-english.pdf?alt=media&token=bbb710a6-4854-4f0c-8447-cf919fef1061', - size_kb: 1084.1, - md5Checksum: '95aa01cddb75d06725a7cd3904334043', + url: 'https://firebasestorage.googleapis.com/v0/b/picsa-apps.appspot.com/o/weather%2FSeasonal%20Forecasts%2FKASUNGU_English_Poster_2023_2024_compressed.pdf?alt=media&token=79f46884-e20e-45fd-b2f1-aa096c4e61db', + size_kb: 356, + md5Checksum: '1e9d080d9395f14687100191e75a02f0', filter: { countries: ['mw'] }, language: 'en', meta: { locationId: 'Malawi_Kasungu', }, }, - downscaled_forecast_kasungu_ny: { - id: 'downscaled_forecast_kasungu_ny', + downscaled_forecast_2023_kasungu_ny: { + id: 'downscaled_forecast_2023_kasungu_ny', description: '', filename: 'forecast-kasungu-chichewa.pdf', mimetype: 'application/pdf', - title: 'ULOSI WA KAGWEDWE KA MVULA M’BOMA LA KASUNGU M’DZINJA LA 2022-2023', + title: 'ULOSI WA KAGWEDWE KA MVULA M’BOMA LA KASUNGU M’DZINJA LA 2023-2024', type: 'file', subtype: 'pdf', - url: 'https://firebasestorage.googleapis.com/v0/b/picsa-apps.appspot.com/o/weather%2Fforecast-kasungu-chichewa.pdf?alt=media&token=c8353b9b-0a1a-4a5e-8df0-8ffc136cc38c', - size_kb: 1085.3, - md5Checksum: '9de79ed0fdd77bb202c5716ce3e8d11c', + url: 'https://firebasestorage.googleapis.com/v0/b/picsa-apps.appspot.com/o/weather%2FSeasonal%20Forecasts%2FKASUNGU_Chichewa_Poster_2023_2024_compressed.pdf?alt=media&token=18da5ae1-09dc-4224-b742-0e555cf584fe', + size_kb: 381.4, + md5Checksum: '5e9c7141d11bc6fab0c113487e46d410', filter: { countries: ['mw'] }, language: 'ny', meta: { locationId: 'Malawi_Kasungu', }, }, - downscaled_forecast_nkhotakota_en: { - id: 'downscaled_forecast_nkhotakota_en', + downscaled_forecast_2023_nkhotakota_en: { + id: 'downscaled_forecast_2023_nkhotakota_en', description: '', filename: 'forecast-nkhotakota-english.pdf', mimetype: 'application/pdf', - title: 'NKHOTAKOTA DISTRICT DOWNSCALED SEASONAL FORECAST, 2022-2023', + title: 'NKHOTAKOTA DISTRICT DOWNSCALED SEASONAL FORECAST, 2023-2024', type: 'file', subtype: 'pdf', - url: 'https://firebasestorage.googleapis.com/v0/b/picsa-apps.appspot.com/o/weather%2Fforecast-nkhotakota-english.pdf?alt=media&token=c642c01b-a94d-4953-a16a-d375db9f642a', - size_kb: 702.4, - md5Checksum: '98c2332a4d83d251725fdccc83af1826', + url: 'https://firebasestorage.googleapis.com/v0/b/picsa-apps.appspot.com/o/weather%2FSeasonal%20Forecasts%2FNKHOTAKOTA_English_Poster_2023_2024_compressed.pdf?alt=media&token=0b2b4317-4c0a-44f5-a681-ce10b45af841', + size_kb: 396.2, + md5Checksum: 'b6221f1f62791e9110471b2ed04b9954', filter: { countries: ['mw'] }, language: 'en', meta: { locationId: 'Malawi_Nkhotakota', }, }, - downscaled_forecast_nkhotakota_ny: { - id: 'downscaled_forecast_nkhotakota_ny', + downscaled_forecast_2023_nkhotakota_ny: { + id: 'downscaled_forecast_2023_nkhotakota_ny', description: '', filename: 'forecast-nkhotakota-chichewa.pdf', mimetype: 'application/pdf', - title: 'ULOSI WA KAGWEDWE KA MVULA M’BOMA LA NKHOTAKOTA M’DZINJA LA 2022-2023', + title: 'ULOSI WA KAGWEDWE KA MVULA M’BOMA LA NKHOTAKOTA M’DZINJA LA 2023-2024', type: 'file', subtype: 'pdf', - url: 'https://firebasestorage.googleapis.com/v0/b/picsa-apps.appspot.com/o/weather%2Fforecast-nkhotakota-chichewa.pdf?alt=media&token=04b95abf-a78c-4752-b2b7-a6f42149b492', - size_kb: 742.9, - md5Checksum: '359f9e0df76b4887befcca129b502dc1', + url: 'https://firebasestorage.googleapis.com/v0/b/picsa-apps.appspot.com/o/weather%2FSeasonal%20Forecasts%2FNKHOTAKOTA_Chichewa_Poster_2023_2024_compressed.pdf?alt=media&token=2e4d14cf-2e82-48ac-9222-e8020791c50b', + size_kb: 416.1, + md5Checksum: '70a8fb7adb64982e630d4d3890880c72', filter: { countries: ['mw'] }, language: 'ny', meta: { diff --git a/apps/picsa-tools/resources-tool/src/app/data/weather/locations.ts b/apps/picsa-tools/resources-tool/src/app/data/weather/locations.ts index c356c5904..8a36fa793 100644 --- a/apps/picsa-tools/resources-tool/src/app/data/weather/locations.ts +++ b/apps/picsa-tools/resources-tool/src/app/data/weather/locations.ts @@ -36,12 +36,12 @@ export const WEATHER_LOCATIONS: IWeatherLocation[] = [ id: 'Malawi_Kasungu', label: 'Kasungu', countryCode: 'mw', - meteoBlueId: 'kasungu_malawi_928534', + // meteoBlueId: 'kasungu_malawi_928534', }, { id: 'Malawi_Nkhotakota', label: 'Nkhotakota', countryCode: 'mw', - meteoBlueId: 'nkhotakota_malawi_924705', + // meteoBlueId: 'nkhotakota_malawi_924705', }, ]; 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 db19207aa..fdce52b58 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 @@ -110,6 +110,10 @@ export class ResourcesToolService extends PicsaAsyncService { } private async populateHardcodedResources() { + // Remove resources marked for deletion (TODO - find cleaner method to keep in sync) + // TODO - process after cache check + await this.deleteRemovedResources(); + // Use caching system to only populate once per app version launch const assetsCacheVersion = this.getAssetResourcesVersion(); if (assetsCacheVersion === APP_VERSION.number) { @@ -125,6 +129,32 @@ export class ResourcesToolService extends PicsaAsyncService { this.setAssetResourcesVersion(); } + /** Remove any resources that no longer appear in hardcoded resource list */ + private async deleteRemovedResources() { + // TODO - likely more efficient to track locally docs with a _deleted property (?) + // But keep as-is for now to ensure any legacy data cleaned + const collectionDeletes = await this.diffDBHardcodedResources(this.dbCollections as any, DB_COLLECTION_ENTRIES); + const fileDeletes = await this.diffDBHardcodedResources(this.dbFiles as any, DB_FILE_ENTRIES); + const LinkDeletes = await this.diffDBHardcodedResources(this.dbLinks as any, DB_LINK_ENTRIES); + + await this.dbCollections.bulkRemove(collectionDeletes); + // TODO - ensure attachments removed also + await this.dbFiles.bulkRemove(fileDeletes); + await this.dbLinks.bulkRemove(LinkDeletes); + } + /** + * Compare list of hardcoded resources with db collection, returning IDs of any resources that + * exist in DB but not in hardcoded + * */ + private async diffDBHardcodedResources( + collection: RxCollection, + hardcoded: schemas.IResourceBase[] + ) { + const hardcodedHashmap = arrayToHashmap(hardcoded, 'id'); + const dbEntries = await collection.find().exec(); + return dbEntries.filter((doc) => !(doc.id in hardcodedHashmap)).map((doc) => doc.id); + } + /** Copy hardcoded assets to db (if checksums match) */ private async copyResourcesFromAssets() { // Populate files from cache diff --git a/libs/environments/src/version.ts b/libs/environments/src/version.ts index 92e12f933..0df4cb411 100644 --- a/libs/environments/src/version.ts +++ b/libs/environments/src/version.ts @@ -4,5 +4,5 @@ import packageJson from '../../../package.json'; export const APP_VERSION = { number: packageJson.version, - date: '2023-10-09', + date: '2023-10-21', }; diff --git a/libs/shared/src/features/video-player/video-player.component.scss b/libs/shared/src/features/video-player/video-player.component.scss index 8910e3822..6edc93dff 100644 --- a/libs/shared/src/features/video-player/video-player.component.scss +++ b/libs/shared/src/features/video-player/video-player.component.scss @@ -1,9 +1,19 @@ @use '@angular/material' as mat; -$playerWidth: 480px; +$playerWidth: 854px; :host { - display: contents; + display: block; + width: 100%; + max-width: $playerWidth; + aspect-ratio: 16/9; + // Assuming that video player displayed within 1rem content padding, + // force video to display across all space (full width) + @media screen and (max-width: $playerWidth) { + width: calc(100% + 2rem); + margin-left: -1rem; + margin-right: -1rem; + } } .placeholder, .thumbnail { diff --git a/libs/shared/src/features/video-player/video-player.component.ts b/libs/shared/src/features/video-player/video-player.component.ts index 7fa5c1073..1b5e422bd 100644 --- a/libs/shared/src/features/video-player/video-player.component.ts +++ b/libs/shared/src/features/video-player/video-player.component.ts @@ -73,8 +73,8 @@ export class VideoPlayerComponent implements OnDestroy { playerId: this.playerId, componentTag: 'picsa-video-player', exitOnEnd: false, - width: 480, - height: 270, + width: 854, + height: 480, displayMode: 'landscape', }; if (Capacitor.isNativePlatform()) { diff --git a/package.json b/package.json index 62094ed42..0a9c6b057 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "picsa-apps", - "version": "3.36.0", + "version": "3.36.1", "license": "See LICENSE", "scripts": { "ng": "nx",