From bdcba4291cf942800f00986f75254b0700235583 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Tue, 6 Aug 2024 13:14:05 -0700 Subject: [PATCH 01/11] feat: wip farmer testimonial videos --- .../step-video/step-video.component.ts | 2 +- .../src/app/data/picsa/farmer-videos.ts | 8 +- libs/data/resources/index.ts | 2 +- libs/data/resources/types.ts | 6 +- libs/data/resources/videos/index.ts | 2 + .../{farmerVideos.ts => videos/picsaSteps.ts} | 48 +++-------- libs/data/resources/videos/testimonials.ts | 84 +++++++++++++++++++ libs/data/resources/videos/utils.ts | 25 ++++++ 8 files changed, 137 insertions(+), 40 deletions(-) create mode 100644 libs/data/resources/videos/index.ts rename libs/data/resources/{farmerVideos.ts => videos/picsaSteps.ts} (76%) create mode 100644 libs/data/resources/videos/testimonials.ts create mode 100644 libs/data/resources/videos/utils.ts diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts index 3958ceaa1..2879bbbc5 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts @@ -37,7 +37,7 @@ export class FarmerStepVideoComponent { private selectDefaultVideo(locale_code: ILocaleCode, videos: IPicsaVideo[]) { // prioritise video in same locale - const localeVideo = videos.find((v) => v.locale_code === locale_code); + const localeVideo = videos.find((v) => v.locale_codes.includes(locale_code)); if (localeVideo) return localeVideo; // TODO - fallback video to same language different locale diff --git a/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts b/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts index 54b440d19..03fc7129a 100644 --- a/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts +++ b/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts @@ -1,4 +1,4 @@ -import { PICSA_FARMER_VIDEO_RESOURCES_HASHMAP } from '@picsa/data/resources'; +import { PICSA_FARMER_VIDEO_RESOURCES_HASHMAP, PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP } from '@picsa/data/resources'; import { IResourceCollection } from '../../schemas'; @@ -15,4 +15,8 @@ const picsa_videos_farmer: IResourceCollection = { parentCollection: 'picsa_videos', }; -export default { ...PICSA_FARMER_VIDEO_RESOURCES_HASHMAP, picsa_videos_farmer }; +export default { + ...PICSA_FARMER_VIDEO_RESOURCES_HASHMAP, + ...PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP, + picsa_videos_farmer, +}; diff --git a/libs/data/resources/index.ts b/libs/data/resources/index.ts index 69c8d315c..d36fa7eed 100644 --- a/libs/data/resources/index.ts +++ b/libs/data/resources/index.ts @@ -1,2 +1,2 @@ export * from './types'; -export * from './farmerVideos'; +export * from './videos'; diff --git a/libs/data/resources/types.ts b/libs/data/resources/types.ts index e28ee367d..3d7eab82f 100644 --- a/libs/data/resources/types.ts +++ b/libs/data/resources/types.ts @@ -2,7 +2,11 @@ import { ILocaleCode } from '../deployments'; export interface IPicsaVideo { id: string; - locale_code: ILocaleCode; + /** + * Country and Language codes supported by video. + * The audio locale should be listed first and subtitle second if different + */ + locale_codes: ILocaleCode[]; size_kb: number; resolution: '360p'; supabase_url: string; diff --git a/libs/data/resources/videos/index.ts b/libs/data/resources/videos/index.ts new file mode 100644 index 000000000..6fdcab8f4 --- /dev/null +++ b/libs/data/resources/videos/index.ts @@ -0,0 +1,2 @@ +export * from './picsaSteps'; +export * from './testimonials'; diff --git a/libs/data/resources/farmerVideos.ts b/libs/data/resources/videos/picsaSteps.ts similarity index 76% rename from libs/data/resources/farmerVideos.ts rename to libs/data/resources/videos/picsaSteps.ts index 6e956c324..d1b0432ab 100644 --- a/libs/data/resources/farmerVideos.ts +++ b/libs/data/resources/videos/picsaSteps.ts @@ -1,6 +1,6 @@ import { arrayToHashmap } from '@picsa/utils'; -import type { IResourceFile } from '@picsa/resources/src/app/schemas'; -import { IPicsaVideoData } from './types'; +import { IPicsaVideoData } from '../types'; +import { hackGenerateLegacyResources } from './utils'; type IPicsaFarmerVideoId = | 'intro' @@ -16,7 +16,7 @@ const PICSA_FARMER_VIDEOS_BASE: Record ({ id: id as IPicsaFarmerVideoId, children: entry.children.map((child) => { - const { locale_code, resolution } = child; + const { locale_codes, resolution } = child; + // use primary locale code for id + const [locale_code] = locale_codes; child.id = `farmer_${id}_${locale_code}_${resolution}`; return child; }), @@ -121,30 +123,6 @@ export const PICSA_FARMER_VIDEOS_HASHMAP: Record> = { + victoria_ngombe: { + title: '', + children: [ + { + id: '', + locale_codes: ['mw_ny', 'global_en'], + resolution: '360p', + size_kb: 0, + supabase_url: '', + }, + ], + }, + dani_chambwe: { + title: '', + children: [ + { + id: '', + locale_codes: ['mw_ny', 'global_en'], + resolution: '360p', + size_kb: 0, + supabase_url: '', + }, + ], + }, + john_tembo: { + title: '', + children: [ + { + id: '', + locale_codes: ['zm_ny', 'global_en'], + resolution: '360p', + size_kb: 0, + supabase_url: '', + }, + ], + }, + jackline_nkhoma: { + title: '', + children: [ + { + id: '', + locale_codes: ['zm_ny', 'global_en'], + resolution: '360p', + size_kb: 0, + supabase_url: '', + }, + ], + }, +}; + +export const PICSA_VIDEO_TESTIMONIAL_DATA: IPicsaVideoData[] = Object.entries(PICSA_VIDEO_TESTIMONIAL_BASE).map( + ([id, entry]) => ({ + id: id as ITestimonialId, + children: entry.children.map((child) => { + const { locale_codes, resolution } = child; + const [locale_code] = locale_codes; + child.id = `farmer_${id}_${locale_code}_${resolution}`; + return child; + }), + }) +); + +export const PICSA_VIDEO_TESTIMONIAL_HASHMAP: Record = arrayToHashmap( + PICSA_VIDEO_TESTIMONIAL_DATA, + 'id' +); + +/************************************************************************** + * Legacy Resource Format + * Support legacy resources system where each resource child has own db entry + * + * TODO - migrate all resources to use modern format so code below can be removed + ***************************************************************************/ + +export const PICSA_VIDEO_TESTIMONIAL_RESOURCES = hackGenerateLegacyResources(PICSA_VIDEO_TESTIMONIAL_DATA); + +export const PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP = arrayToHashmap(PICSA_VIDEO_TESTIMONIAL_RESOURCES, 'id'); diff --git a/libs/data/resources/videos/utils.ts b/libs/data/resources/videos/utils.ts new file mode 100644 index 000000000..2c73ce0c7 --- /dev/null +++ b/libs/data/resources/videos/utils.ts @@ -0,0 +1,25 @@ +import type { IResourceFile } from '@picsa/resources/src/app/schemas'; + +/** + * HACK - generate a list of legacy resources from updated farmer data + */ +export function hackGenerateLegacyResources(videoData) { + const resources: IResourceFile[] = []; + for (const { children } of videoData) { + for (const { id, size_kb, supabase_url } of children) { + const resourceFile: IResourceFile = { + id, + filename: `${id}.mp4`, + md5Checksum: '', + mimetype: 'video/mp4', + size_kb, + subtype: 'video', + title: '', + type: 'file', + url: supabase_url, + }; + resources.push(resourceFile); + } + } + return resources; +} From d4353dde7bf0c086fc373c7610ef60f16ea7f9cb Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Thu, 8 Aug 2024 16:48:05 -0700 Subject: [PATCH 02/11] chore: update videos --- libs/data/resources/videos/picsaSteps.ts | 12 +++++++++--- libs/data/resources/videos/testimonials.ts | 19 +++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/libs/data/resources/videos/picsaSteps.ts b/libs/data/resources/videos/picsaSteps.ts index d1b0432ab..e1baf7142 100644 --- a/libs/data/resources/videos/picsaSteps.ts +++ b/libs/data/resources/videos/picsaSteps.ts @@ -16,11 +16,17 @@ const PICSA_FARMER_VIDEOS_BASE: Record Date: Thu, 8 Aug 2024 16:48:47 -0700 Subject: [PATCH 03/11] chore: bump version --- apps/picsa-apps/extension-app-native/android/app/build.gradle | 4 ++-- libs/environments/src/version.ts | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 cd02d1979..b1d52c9dc 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 3043004 - versionName "3.43.4" + versionCode 3044000 + versionName "3.44.0" 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/libs/environments/src/version.ts b/libs/environments/src/version.ts index d5886b6d7..49e2699a2 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: '2024-08-06', + date: '2024-08-08', }; diff --git a/package.json b/package.json index 51717abfe..0572b4cda 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "picsa-apps", - "version": "3.43.4", + "version": "3.44.0", "license": "See LICENSE", "scripts": { "ng": "nx", From 15ff53c3de7cb06755bfa6056cf2679c90e4dc8e Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Thu, 8 Aug 2024 17:20:47 -0700 Subject: [PATCH 04/11] chore: code tidying --- .../src/app/data/picsa/farmer-videos.ts | 14 +++++++++++++- libs/data/resources/videos/index.ts | 18 ++++++++++++++++++ libs/data/resources/videos/picsaSteps.ts | 11 ----------- libs/data/resources/videos/testimonials.ts | 13 +------------ 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts b/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts index 03fc7129a..31620edcf 100644 --- a/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts +++ b/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts @@ -2,6 +2,18 @@ import { PICSA_FARMER_VIDEO_RESOURCES_HASHMAP, PICSA_VIDEO_TESTIMONIAL_RESOURCES import { IResourceCollection } from '../../schemas'; +/************************************************************************** + * Legacy Resource Format + * Support legacy resources system where each resource child has own db entry + * + * TODO - migrate all resources to use modern format so code below can be removed + ***************************************************************************/ + +const files = [ + ...Object.keys(PICSA_FARMER_VIDEO_RESOURCES_HASHMAP), + ...Object.keys(PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP), +]; + /** * Create a collection to store all farmer videos populated to hardcoded data */ @@ -11,7 +23,7 @@ const picsa_videos_farmer: IResourceCollection = { type: 'collection', title: 'Farmer Videos', description: 'Training videos to support PICSA', - childResources: { collections: [], files: Object.keys(PICSA_FARMER_VIDEO_RESOURCES_HASHMAP), links: [] }, + childResources: { collections: [], files, links: [] }, parentCollection: 'picsa_videos', }; diff --git a/libs/data/resources/videos/index.ts b/libs/data/resources/videos/index.ts index 6fdcab8f4..955998db9 100644 --- a/libs/data/resources/videos/index.ts +++ b/libs/data/resources/videos/index.ts @@ -1,2 +1,20 @@ +import { arrayToHashmap } from '@picsa/utils'; +import { PICSA_FARMER_VIDEOS_DATA } from './picsaSteps'; +import { PICSA_VIDEO_TESTIMONIAL_DATA } from './testimonials'; +import { hackGenerateLegacyResources } from './utils'; + +/************************************************************************** + * Legacy Resource Format + * Support legacy resources system where each resource child has own db entry + * + * TODO - migrate all resources to use modern format so code below can be removed + ***************************************************************************/ + +const PICSA_FARMER_VIDEO_RESOURCES = hackGenerateLegacyResources(PICSA_FARMER_VIDEOS_DATA); +const PICSA_VIDEO_TESTIMONIAL_RESOURCES = hackGenerateLegacyResources(PICSA_VIDEO_TESTIMONIAL_DATA); + +export const PICSA_FARMER_VIDEO_RESOURCES_HASHMAP = arrayToHashmap(PICSA_FARMER_VIDEO_RESOURCES, 'id'); +export const PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP = arrayToHashmap(PICSA_VIDEO_TESTIMONIAL_RESOURCES, 'id'); + export * from './picsaSteps'; export * from './testimonials'; diff --git a/libs/data/resources/videos/picsaSteps.ts b/libs/data/resources/videos/picsaSteps.ts index e1baf7142..a039080b0 100644 --- a/libs/data/resources/videos/picsaSteps.ts +++ b/libs/data/resources/videos/picsaSteps.ts @@ -121,14 +121,3 @@ export const PICSA_FARMER_VIDEOS_HASHMAP: Record { const { locale_codes, resolution } = child; const [locale_code] = locale_codes; - child.id = `farmer_${id}_${locale_code}_${resolution}`; + child.id = `farmer_testimonial_${id}_${locale_code}_${resolution}`; return child; }), }) @@ -74,14 +74,3 @@ export const PICSA_VIDEO_TESTIMONIAL_HASHMAP: Record Date: Fri, 9 Aug 2024 12:55:08 -0700 Subject: [PATCH 05/11] feat: video ranking algorithm --- .../step-video/step-video.component.html | 4 ++ .../step-video/step-video.component.ts | 46 ++++++++++++++----- .../src/app/data/picsa/farmer-videos.ts | 10 ++-- .../app/services/resources-tool.service.ts | 6 +-- .../farmer_content/data/content/0_intro.ts | 8 +++- libs/data/resources/videos/index.ts | 10 ++-- libs/data/resources/videos/picsaSteps.ts | 1 - libs/data/resources/videos/testimonials.ts | 38 ++++++--------- 8 files changed, 70 insertions(+), 53 deletions(-) diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html index ea079b5c6..1e0a86c0a 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html @@ -1 +1,5 @@ +@if(videoResource()){ +} @else { +

Video not found

+} diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts index 2879bbbc5..63499f0a5 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts @@ -2,8 +2,9 @@ import { CommonModule } from '@angular/common'; import { Component, computed, input } from '@angular/core'; import { ConfigurationService } from '@picsa/configuration/src'; import { ILocaleCode } from '@picsa/data'; +import { ICountryCode } from '@picsa/data/deployments'; import { IPicsaVideo, IPicsaVideoData } from '@picsa/data/resources'; -import { PICSA_FARMER_VIDEO_RESOURCES_HASHMAP } from '@picsa/data/resources'; +import { RESOURCE_VIDEO_HASHMAP } from '@picsa/data/resources'; import { ResourcesComponentsModule } from '@picsa/resources/src/app/components/components.module'; /** @@ -25,25 +26,46 @@ export class FarmerStepVideoComponent { videoData = input.required(); videoResource = computed(() => { - const { language_code } = this.configurationService.userSettings(); + // HACK - when identifying video to show user cannot rely solely on language_code as + // that populates 'global_en' when different country used (should be zm_en) + // So instead use country_code specified and language part of localeCode + + const { country_code: userCountry, language_code } = this.configurationService.userSettings(); + const [_, userLanguage] = language_code.split('_'); const availableVideos = this.videoData().children; - const video = this.selectDefaultVideo(language_code, availableVideos); + const video = this.selectDefaultVideo(userCountry, userLanguage, availableVideos); // HACK - lookup resource entry which should be given by same id - const resource = PICSA_FARMER_VIDEO_RESOURCES_HASHMAP[video.id]; + const resource = RESOURCE_VIDEO_HASHMAP[video.id]; return resource; }); constructor(private configurationService: ConfigurationService) {} - private selectDefaultVideo(locale_code: ILocaleCode, videos: IPicsaVideo[]) { - // prioritise video in same locale - const localeVideo = videos.find((v) => v.locale_codes.includes(locale_code)); - if (localeVideo) return localeVideo; - - // TODO - fallback video to same language different locale - // TODO - track preference for video size (when supported in future, currently all 360p) + private selectDefaultVideo(userCountry: string, userLanguage: string, videos: IPicsaVideo[] = []) { + const rankedVideos = videos + .map((v) => ({ ...v, _rank: getVideoRank(userCountry, userLanguage, v) })) + .filter(({ _rank }) => _rank > 0) + .sort((a, b) => a._rank - b._rank); // default fallback to first video entry - return videos[0]; + return rankedVideos[0] || videos[0]; } } + +function getVideoRank(userCountry: string, userLanguage: string, video: IPicsaVideo) { + const [audio, subtitle] = video.locale_codes; + const [audioCountry, audioLanguage] = audio.split('_'); + const subtitleLanguage = subtitle?.split('_')[1]; + + // 1 - same country and audio + if (audioCountry === userCountry && audioLanguage === userLanguage) return 1; + // 2 - same country and user language subtitle + if (audioCountry === userCountry && subtitleLanguage === userLanguage) return 2; + // 3 - global video with user language audio + if (audioCountry === 'global' && audioLanguage === userLanguage) return 3; + // 4 - global video with user language subtitle + if (audioCountry === 'global' && subtitleLanguage === userLanguage) return 4; + // 5 - return all videos for global users + if (userCountry === 'global') return 5; + return -1; +} diff --git a/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts b/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts index 31620edcf..0fcec357b 100644 --- a/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts +++ b/apps/picsa-tools/resources-tool/src/app/data/picsa/farmer-videos.ts @@ -1,4 +1,4 @@ -import { PICSA_FARMER_VIDEO_RESOURCES_HASHMAP, PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP } from '@picsa/data/resources'; +import { RESOURCE_VIDEO_HASHMAP } from '@picsa/data/resources'; import { IResourceCollection } from '../../schemas'; @@ -9,10 +9,7 @@ import { IResourceCollection } from '../../schemas'; * TODO - migrate all resources to use modern format so code below can be removed ***************************************************************************/ -const files = [ - ...Object.keys(PICSA_FARMER_VIDEO_RESOURCES_HASHMAP), - ...Object.keys(PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP), -]; +const files = Object.keys(RESOURCE_VIDEO_HASHMAP); /** * Create a collection to store all farmer videos populated to hardcoded data @@ -28,7 +25,6 @@ const picsa_videos_farmer: IResourceCollection = { }; export default { - ...PICSA_FARMER_VIDEO_RESOURCES_HASHMAP, - ...PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP, + ...RESOURCE_VIDEO_HASHMAP, picsa_videos_farmer, }; 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 6e1e852e1..ec60690c3 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 @@ -4,7 +4,7 @@ import { Browser } from '@capacitor/browser'; import { Capacitor } from '@capacitor/core'; import { Share } from '@capacitor/share'; import { ConfigurationService } from '@picsa/configuration/src'; -import { APP_VERSION } from '@picsa/environments/src'; +import { APP_VERSION, ENVIRONMENT } from '@picsa/environments/src'; import { PicsaAsyncService } from '@picsa/shared/services/asyncService.service'; import { AnalyticsService } from '@picsa/shared/services/core/analytics.service'; import { PicsaDatabase_V2_Service, PicsaDatabaseAttachmentService } from '@picsa/shared/services/core/db_v2'; @@ -162,9 +162,9 @@ export class ResourcesToolService extends PicsaAsyncService { // TODO - process after cache check await this.deleteRemovedResources(); - // Use caching system to only populate once per app version launch + // Use caching system to only populate once per app version launch in production const assetsCacheVersion = this.getAssetResourcesVersion(); - if (assetsCacheVersion === APP_VERSION.number) { + if (ENVIRONMENT.production && assetsCacheVersion === APP_VERSION.number) { return; } // Update DB with hardcoded entries diff --git a/libs/data/farmer_content/data/content/0_intro.ts b/libs/data/farmer_content/data/content/0_intro.ts index f8552ea27..647b9673e 100644 --- a/libs/data/farmer_content/data/content/0_intro.ts +++ b/libs/data/farmer_content/data/content/0_intro.ts @@ -1,9 +1,13 @@ import { marker as translateMarker } from '@biesbjerg/ngx-translate-extract-marker'; import { IFarmerContent, IFarmerContentStep } from '../../types'; -import { PICSA_FARMER_VIDEOS_HASHMAP } from '@picsa/data/resources'; +import { PICSA_FARMER_VIDEOS_HASHMAP, PICSA_VIDEO_TESTIMONIAL_HASHMAP } from '@picsa/data/resources'; -const steps: IFarmerContentStep[] = [{ type: 'video', video: PICSA_FARMER_VIDEOS_HASHMAP.intro }]; +const steps: IFarmerContentStep[] = [ + { type: 'video', video: PICSA_FARMER_VIDEOS_HASHMAP.intro, tabLabel: translateMarker('Intro') }, + { type: 'video', video: PICSA_VIDEO_TESTIMONIAL_HASHMAP.female, tabLabel: translateMarker('Testimonial') }, + { type: 'video', video: PICSA_VIDEO_TESTIMONIAL_HASHMAP.male, tabLabel: translateMarker('Testimonial') }, +]; const content: Omit = { slug: 'intro', diff --git a/libs/data/resources/videos/index.ts b/libs/data/resources/videos/index.ts index 955998db9..aadbfd367 100644 --- a/libs/data/resources/videos/index.ts +++ b/libs/data/resources/videos/index.ts @@ -10,11 +10,13 @@ import { hackGenerateLegacyResources } from './utils'; * TODO - migrate all resources to use modern format so code below can be removed ***************************************************************************/ -const PICSA_FARMER_VIDEO_RESOURCES = hackGenerateLegacyResources(PICSA_FARMER_VIDEOS_DATA); -const PICSA_VIDEO_TESTIMONIAL_RESOURCES = hackGenerateLegacyResources(PICSA_VIDEO_TESTIMONIAL_DATA); +const steps = hackGenerateLegacyResources(PICSA_FARMER_VIDEOS_DATA); +const testimonials = hackGenerateLegacyResources(PICSA_VIDEO_TESTIMONIAL_DATA); -export const PICSA_FARMER_VIDEO_RESOURCES_HASHMAP = arrayToHashmap(PICSA_FARMER_VIDEO_RESOURCES, 'id'); -export const PICSA_VIDEO_TESTIMONIAL_RESOURCES_HASHMAP = arrayToHashmap(PICSA_VIDEO_TESTIMONIAL_RESOURCES, 'id'); +export const RESOURCE_VIDEO_HASHMAP = { + ...arrayToHashmap(steps, 'id'), + ...arrayToHashmap(testimonials, 'id'), +}; export * from './picsaSteps'; export * from './testimonials'; diff --git a/libs/data/resources/videos/picsaSteps.ts b/libs/data/resources/videos/picsaSteps.ts index a039080b0..a9ca478ab 100644 --- a/libs/data/resources/videos/picsaSteps.ts +++ b/libs/data/resources/videos/picsaSteps.ts @@ -1,6 +1,5 @@ import { arrayToHashmap } from '@picsa/utils'; import { IPicsaVideoData } from '../types'; -import { hackGenerateLegacyResources } from './utils'; type IPicsaFarmerVideoId = | 'intro' diff --git a/libs/data/resources/videos/testimonials.ts b/libs/data/resources/videos/testimonials.ts index 57c046185..1bf8c72c5 100644 --- a/libs/data/resources/videos/testimonials.ts +++ b/libs/data/resources/videos/testimonials.ts @@ -1,58 +1,48 @@ import { arrayToHashmap } from '@picsa/utils'; import { IPicsaVideoData } from '../types'; -import { hackGenerateLegacyResources } from './utils'; -type ITestimonialId = 'victoria_ngombe' | 'john_tembo' | 'jackline_nkhoma' | 'dani_chambwe'; +type ITestimonialId = 'male' | 'female'; const PICSA_VIDEO_TESTIMONIAL_BASE: Record> = { - victoria_ngombe: { + female: { title: '', children: [ { - id: 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/mw/videos/testimonials/victoria_ngombe.mp4', + id: '', locale_codes: ['mw_ny', 'global_en'], resolution: '360p', size_kb: 5080, - supabase_url: '', + supabase_url: + 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/mw/videos/testimonials/victoria_ngombe.mp4', }, - ], - }, - dani_chambwe: { - title: '', - children: [ { id: '', - locale_codes: ['mw_ny', 'global_en'], + locale_codes: ['zm_ny', 'global_en'], resolution: '360p', - size_kb: 7630, + size_kb: 6740, supabase_url: - 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/mw/videos/testimonials/dani_chambwe.mp4', + 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/zm/videos/testimonials/jackline_nkhoma.mp4', }, ], }, - john_tembo: { + male: { title: '', children: [ { id: '', - locale_codes: ['zm_ny', 'global_en'], + locale_codes: ['mw_ny', 'global_en'], resolution: '360p', - size_kb: 10150, + size_kb: 7630, supabase_url: - 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/zm/videos/testimonials/john_tembo.mp4', + 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/mw/videos/testimonials/dani_chambwe.mp4', }, - ], - }, - jackline_nkhoma: { - title: '', - children: [ { id: '', locale_codes: ['zm_ny', 'global_en'], resolution: '360p', - size_kb: 6740, + size_kb: 10150, supabase_url: - 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/zm/videos/testimonials/jackline_nkhoma.mp4', + 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/zm/videos/testimonials/john_tembo.mp4', }, ], }, From 39b5e24e04d2fed130a70173f78e32e5a97f2651 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Fri, 9 Aug 2024 13:03:56 -0700 Subject: [PATCH 06/11] feat: add support for multiple videos --- .../components/step-video/step-video.component.html | 9 ++++++--- .../components/step-video/step-video.component.ts | 13 ++++++------- libs/data/farmer_content/data/content/0_intro.ts | 3 +-- libs/data/resources/videos/testimonials.ts | 9 ++------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html index 1e0a86c0a..149b2d3c6 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html @@ -1,5 +1,8 @@ -@if(videoResource()){ - -} @else { +@for(resource of videoResources(); track resource.id){ + + +} + +@if(videoResources().length ===0 ) {

Video not found

} diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts index 63499f0a5..44211c06f 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts @@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common'; import { Component, computed, input } from '@angular/core'; import { ConfigurationService } from '@picsa/configuration/src'; import { ILocaleCode } from '@picsa/data'; -import { ICountryCode } from '@picsa/data/deployments'; import { IPicsaVideo, IPicsaVideoData } from '@picsa/data/resources'; import { RESOURCE_VIDEO_HASHMAP } from '@picsa/data/resources'; import { ResourcesComponentsModule } from '@picsa/resources/src/app/components/components.module'; @@ -25,7 +24,7 @@ import { ResourcesComponentsModule } from '@picsa/resources/src/app/components/c export class FarmerStepVideoComponent { videoData = input.required(); - videoResource = computed(() => { + videoResources = computed(() => { // HACK - when identifying video to show user cannot rely solely on language_code as // that populates 'global_en' when different country used (should be zm_en) // So instead use country_code specified and language part of localeCode @@ -33,22 +32,22 @@ export class FarmerStepVideoComponent { const { country_code: userCountry, language_code } = this.configurationService.userSettings(); const [_, userLanguage] = language_code.split('_'); const availableVideos = this.videoData().children; - const video = this.selectDefaultVideo(userCountry, userLanguage, availableVideos); + const videos = this.filterAvailableVideos(userCountry, userLanguage, availableVideos); // HACK - lookup resource entry which should be given by same id - const resource = RESOURCE_VIDEO_HASHMAP[video.id]; - return resource; + const resources = videos.map((video) => RESOURCE_VIDEO_HASHMAP[video.id]); + return resources; }); constructor(private configurationService: ConfigurationService) {} - private selectDefaultVideo(userCountry: string, userLanguage: string, videos: IPicsaVideo[] = []) { + private filterAvailableVideos(userCountry: string, userLanguage: string, videos: IPicsaVideo[] = []) { const rankedVideos = videos .map((v) => ({ ...v, _rank: getVideoRank(userCountry, userLanguage, v) })) .filter(({ _rank }) => _rank > 0) .sort((a, b) => a._rank - b._rank); // default fallback to first video entry - return rankedVideos[0] || videos[0]; + return rankedVideos; } } diff --git a/libs/data/farmer_content/data/content/0_intro.ts b/libs/data/farmer_content/data/content/0_intro.ts index 647b9673e..b332240e6 100644 --- a/libs/data/farmer_content/data/content/0_intro.ts +++ b/libs/data/farmer_content/data/content/0_intro.ts @@ -5,8 +5,7 @@ import { PICSA_FARMER_VIDEOS_HASHMAP, PICSA_VIDEO_TESTIMONIAL_HASHMAP } from '@p const steps: IFarmerContentStep[] = [ { type: 'video', video: PICSA_FARMER_VIDEOS_HASHMAP.intro, tabLabel: translateMarker('Intro') }, - { type: 'video', video: PICSA_VIDEO_TESTIMONIAL_HASHMAP.female, tabLabel: translateMarker('Testimonial') }, - { type: 'video', video: PICSA_VIDEO_TESTIMONIAL_HASHMAP.male, tabLabel: translateMarker('Testimonial') }, + { type: 'video', video: PICSA_VIDEO_TESTIMONIAL_HASHMAP.combined, tabLabel: translateMarker('Testimonials') }, ]; const content: Omit = { diff --git a/libs/data/resources/videos/testimonials.ts b/libs/data/resources/videos/testimonials.ts index 1bf8c72c5..b90f573e6 100644 --- a/libs/data/resources/videos/testimonials.ts +++ b/libs/data/resources/videos/testimonials.ts @@ -1,10 +1,10 @@ import { arrayToHashmap } from '@picsa/utils'; import { IPicsaVideoData } from '../types'; -type ITestimonialId = 'male' | 'female'; +type ITestimonialId = 'combined'; const PICSA_VIDEO_TESTIMONIAL_BASE: Record> = { - female: { + combined: { title: '', children: [ { @@ -23,11 +23,6 @@ const PICSA_VIDEO_TESTIMONIAL_BASE: Record Date: Fri, 9 Aug 2024 13:15:21 -0700 Subject: [PATCH 07/11] chore: code tidying --- .../app/components/step-video/step-video.component.ts | 11 +++++++---- .../app/pages/module-home/module-home.component.html | 2 +- libs/data/farmer_content/data/content/0_intro.ts | 7 ++++++- libs/data/farmer_content/types.ts | 2 ++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts index 44211c06f..b4c5344c9 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts @@ -1,7 +1,7 @@ import { CommonModule } from '@angular/common'; import { Component, computed, input } from '@angular/core'; import { ConfigurationService } from '@picsa/configuration/src'; -import { ILocaleCode } from '@picsa/data'; +import { IFarmerContentStep, ILocaleCode } from '@picsa/data'; import { IPicsaVideo, IPicsaVideoData } from '@picsa/data/resources'; import { RESOURCE_VIDEO_HASHMAP } from '@picsa/data/resources'; import { ResourcesComponentsModule } from '@picsa/resources/src/app/components/components.module'; @@ -22,7 +22,7 @@ import { ResourcesComponentsModule } from '@picsa/resources/src/app/components/c styleUrl: './step-video.component.scss', }) export class FarmerStepVideoComponent { - videoData = input.required(); + step = input.required(); videoResources = computed(() => { // HACK - when identifying video to show user cannot rely solely on language_code as @@ -31,11 +31,12 @@ export class FarmerStepVideoComponent { const { country_code: userCountry, language_code } = this.configurationService.userSettings(); const [_, userLanguage] = language_code.split('_'); - const availableVideos = this.videoData().children; + const availableVideos = this.step().video.children; const videos = this.filterAvailableVideos(userCountry, userLanguage, availableVideos); // HACK - lookup resource entry which should be given by same id const resources = videos.map((video) => RESOURCE_VIDEO_HASHMAP[video.id]); - return resources; + // HACK - limit max number of videos if not expecting multiple + return this.step().multiple ? resources : [resources[0]]; }); constructor(private configurationService: ConfigurationService) {} @@ -66,5 +67,7 @@ function getVideoRank(userCountry: string, userLanguage: string, video: IPicsaVi if (audioCountry === 'global' && subtitleLanguage === userLanguage) return 4; // 5 - return all videos for global users if (userCountry === 'global') return 5; + // 6 - return global fallback + if (audioCountry === 'global' && audioLanguage === 'en') return 6; return -1; } diff --git a/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html b/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html index 2d9bf4fd1..ca4db09d5 100644 --- a/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html +++ b/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html @@ -33,7 +33,7 @@

{{ content.title | translate }}

@if(step.video){ - + }
diff --git a/libs/data/farmer_content/data/content/0_intro.ts b/libs/data/farmer_content/data/content/0_intro.ts index b332240e6..d13c27398 100644 --- a/libs/data/farmer_content/data/content/0_intro.ts +++ b/libs/data/farmer_content/data/content/0_intro.ts @@ -5,7 +5,12 @@ import { PICSA_FARMER_VIDEOS_HASHMAP, PICSA_VIDEO_TESTIMONIAL_HASHMAP } from '@p const steps: IFarmerContentStep[] = [ { type: 'video', video: PICSA_FARMER_VIDEOS_HASHMAP.intro, tabLabel: translateMarker('Intro') }, - { type: 'video', video: PICSA_VIDEO_TESTIMONIAL_HASHMAP.combined, tabLabel: translateMarker('Testimonials') }, + { + type: 'video', + video: PICSA_VIDEO_TESTIMONIAL_HASHMAP.combined, + tabLabel: translateMarker('Testimonials'), + multiple: true, + }, ]; const content: Omit = { diff --git a/libs/data/farmer_content/types.ts b/libs/data/farmer_content/types.ts index a6773df0e..74c93b22c 100644 --- a/libs/data/farmer_content/types.ts +++ b/libs/data/farmer_content/types.ts @@ -16,6 +16,8 @@ interface IFarmerContentStepVideo { video: IPicsaVideoData; /** Label to show when selecting content from tab */ tabLabel?: string; + /** Show multiple videos (playlist) */ + multiple?: boolean; } export type IFarmerContentStep = IFarmerContentStepVideo; From c9a5124b32d332ae86a5aab8eebd072864d80298 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Fri, 9 Aug 2024 14:00:19 -0700 Subject: [PATCH 08/11] feat: add support for video playlists --- .../step-video/step-video.component.html | 9 +++----- .../step-video/step-video.component.ts | 10 ++++---- .../module-home/module-home.component.html | 21 +++++++++++++---- .../farmer_content/data/content/0_intro.ts | 6 ++--- .../data/content/1_what_you_do.ts | 1 + .../data/content/2_climate_change.ts | 1 + .../data/content/3_opportunities_risks.ts | 1 + .../data/content/4_what_are_the_options.ts | 1 + .../data/content/5_compare_options.ts | 1 + .../data/content/6_decide_and_plan.ts | 1 + libs/data/farmer_content/types.ts | 23 ++++++++++++++----- libs/data/resources/videos/testimonials.ts | 9 ++++++-- 12 files changed, 56 insertions(+), 28 deletions(-) diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html index 149b2d3c6..2e33e5d3c 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html @@ -1,8 +1,5 @@ -@for(resource of videoResources(); track resource.id){ - - -} - -@if(videoResources().length ===0 ) { +@if(videoData()){ + +} @else {

Video not found

} diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts index b4c5344c9..57cc5528d 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts @@ -1,7 +1,6 @@ import { CommonModule } from '@angular/common'; import { Component, computed, input } from '@angular/core'; import { ConfigurationService } from '@picsa/configuration/src'; -import { IFarmerContentStep, ILocaleCode } from '@picsa/data'; import { IPicsaVideo, IPicsaVideoData } from '@picsa/data/resources'; import { RESOURCE_VIDEO_HASHMAP } from '@picsa/data/resources'; import { ResourcesComponentsModule } from '@picsa/resources/src/app/components/components.module'; @@ -22,21 +21,20 @@ import { ResourcesComponentsModule } from '@picsa/resources/src/app/components/c styleUrl: './step-video.component.scss', }) export class FarmerStepVideoComponent { - step = input.required(); + videoData = input.required(); - videoResources = computed(() => { + videoResource = computed(() => { // HACK - when identifying video to show user cannot rely solely on language_code as // that populates 'global_en' when different country used (should be zm_en) // So instead use country_code specified and language part of localeCode const { country_code: userCountry, language_code } = this.configurationService.userSettings(); const [_, userLanguage] = language_code.split('_'); - const availableVideos = this.step().video.children; + const availableVideos = this.videoData().children; const videos = this.filterAvailableVideos(userCountry, userLanguage, availableVideos); // HACK - lookup resource entry which should be given by same id const resources = videos.map((video) => RESOURCE_VIDEO_HASHMAP[video.id]); - // HACK - limit max number of videos if not expecting multiple - return this.step().multiple ? resources : [resources[0]]; + return resources[0]; }); constructor(private configurationService: ConfigurationService) {} diff --git a/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html b/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html index ca4db09d5..507b5ced5 100644 --- a/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html +++ b/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html @@ -28,15 +28,26 @@

{{ content.title | translate }}

@case ("video") { - slideshow + {{ step.tabMatIcon || 'slideshow' }} {{ step.tabLabel || 'video' | translate }}
@if(step.video){ - + + } +
+ } + + @case ("video_playlist") { + + {{ step.tabMatIcon || 'slideshow' }} + {{ step.tabLabel || 'video' | translate }} + +
+ @for(video of step.videos; track video.id){ + }
- } } } @@ -55,7 +66,7 @@

{{ content.title | translate }}

} - @if(photoAlbum(); as album){ + @if(content.showReviewSection){ @if(photoAlbum(); as album){ perm_media @@ -67,7 +78,7 @@

{{ content.title | translate }}

- } + } } +@if(videoResource(); as resource){ + + +} } @else {

Video not found

} diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts index 57cc5528d..1a41af201 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts @@ -27,14 +27,17 @@ export class FarmerStepVideoComponent { // HACK - when identifying video to show user cannot rely solely on language_code as // that populates 'global_en' when different country used (should be zm_en) // So instead use country_code specified and language part of localeCode - const { country_code: userCountry, language_code } = this.configurationService.userSettings(); const [_, userLanguage] = language_code.split('_'); const availableVideos = this.videoData().children; - const videos = this.filterAvailableVideos(userCountry, userLanguage, availableVideos); - // HACK - lookup resource entry which should be given by same id - const resources = videos.map((video) => RESOURCE_VIDEO_HASHMAP[video.id]); - return resources[0]; + // HACK - select best video recommendation. TODO - show toggle options in future + const [video] = this.filterAvailableVideos(userCountry, userLanguage, availableVideos); + if (video) { + // HACK - lookup resource entry which should be given by same id + const resource = RESOURCE_VIDEO_HASHMAP[video.id]; + return resource; + } + return undefined; }); constructor(private configurationService: ConfigurationService) {} diff --git a/libs/data/farmer_content/data/content/0_intro.ts b/libs/data/farmer_content/data/content/0_intro.ts index af1be93d7..0bc468691 100644 --- a/libs/data/farmer_content/data/content/0_intro.ts +++ b/libs/data/farmer_content/data/content/0_intro.ts @@ -7,7 +7,7 @@ const steps: IFarmerContentStep[] = [ { type: 'video', video: PICSA_FARMER_VIDEOS_HASHMAP.intro, tabLabel: translateMarker('Intro') }, { type: 'video_playlist', - videos: [PICSA_VIDEO_TESTIMONIAL_HASHMAP.female, PICSA_VIDEO_TESTIMONIAL_HASHMAP.male], + videos: Object.values(PICSA_VIDEO_TESTIMONIAL_HASHMAP), tabLabel: translateMarker('Testimonials'), tabMatIcon: 'people', }, diff --git a/libs/data/resources/videos/index.ts b/libs/data/resources/videos/index.ts index aadbfd367..b791b320e 100644 --- a/libs/data/resources/videos/index.ts +++ b/libs/data/resources/videos/index.ts @@ -17,6 +17,5 @@ export const RESOURCE_VIDEO_HASHMAP = { ...arrayToHashmap(steps, 'id'), ...arrayToHashmap(testimonials, 'id'), }; - export * from './picsaSteps'; export * from './testimonials'; diff --git a/libs/data/resources/videos/testimonials.ts b/libs/data/resources/videos/testimonials.ts index 1bf8c72c5..e1cc60766 100644 --- a/libs/data/resources/videos/testimonials.ts +++ b/libs/data/resources/videos/testimonials.ts @@ -1,11 +1,9 @@ import { arrayToHashmap } from '@picsa/utils'; import { IPicsaVideoData } from '../types'; -type ITestimonialId = 'male' | 'female'; - -const PICSA_VIDEO_TESTIMONIAL_BASE: Record> = { - female: { - title: '', +const PICSA_VIDEO_TESTIMONIAL_BASE: Record> = { + victoria_ngombe: { + title: "Victoria Ng'ombe", children: [ { id: '', @@ -15,6 +13,11 @@ const PICSA_VIDEO_TESTIMONIAL_BASE: Record ({ - id: id as ITestimonialId, + ...entry, + id, children: entry.children.map((child) => { const { locale_codes, resolution } = child; const [locale_code] = locale_codes; @@ -60,7 +69,7 @@ export const PICSA_VIDEO_TESTIMONIAL_DATA: IPicsaVideoData[] = Object.entries(PI }) ); -export const PICSA_VIDEO_TESTIMONIAL_HASHMAP: Record = arrayToHashmap( +export const PICSA_VIDEO_TESTIMONIAL_HASHMAP: Record = arrayToHashmap( PICSA_VIDEO_TESTIMONIAL_DATA, 'id' ); diff --git a/libs/data/resources/videos/utils.ts b/libs/data/resources/videos/utils.ts index 2c73ce0c7..5d5d9f228 100644 --- a/libs/data/resources/videos/utils.ts +++ b/libs/data/resources/videos/utils.ts @@ -1,12 +1,13 @@ import type { IResourceFile } from '@picsa/resources/src/app/schemas'; +import { IPicsaVideoData } from '../types'; /** * HACK - generate a list of legacy resources from updated farmer data */ -export function hackGenerateLegacyResources(videoData) { +export function hackGenerateLegacyResources(videos: IPicsaVideoData[]) { const resources: IResourceFile[] = []; - for (const { children } of videoData) { - for (const { id, size_kb, supabase_url } of children) { + for (const { children, description, title } of videos) { + for (const { id, size_kb, supabase_url, locale_codes, resolution } of children) { const resourceFile: IResourceFile = { id, filename: `${id}.mp4`, @@ -14,9 +15,10 @@ export function hackGenerateLegacyResources(videoData) { mimetype: 'video/mp4', size_kb, subtype: 'video', - title: '', + title: title || '', type: 'file', url: supabase_url, + description, }; resources.push(resourceFile); } From 08ae189ab376473f9a83240038da11920338f2ce Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Fri, 9 Aug 2024 21:10:05 -0700 Subject: [PATCH 10/11] chore: code tidying --- .../resource-download/resource-download.component.html | 2 +- libs/data/resources/videos/testimonials.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/picsa-tools/resources-tool/src/app/components/resource-download/resource-download.component.html b/apps/picsa-tools/resources-tool/src/app/components/resource-download/resource-download.component.html index d3f1cf23f..f9e1531f5 100644 --- a/apps/picsa-tools/resources-tool/src/app/components/resource-download/resource-download.component.html +++ b/apps/picsa-tools/resources-tool/src/app/components/resource-download/resource-download.component.html @@ -1,5 +1,5 @@ -@if(downloadStatus==='ready'){ +@if(downloadStatus==='ready' || downloadStatus==='error'){