@@ -49,25 +49,132 @@
>
+
+
+ @if (countryLink && mapChart && mapChart.selectedCountry) {
+
+ {{ mapChart.selectedCountry | renameCountry | uppercase }}
+
+
+ } @else {
{{ dimension | renameApiFacet | uppercase }}
ITEMS PROVIDED
+ }
+
+
+
+ @if (countryLink){ @if(mapChart && mapChart.selectedCountry){
+
+
+
+
+ @if(countryData && countryData[mapChart.selectedCountry]){
+
+ 3D
+
+ {{
+ countryData[mapChart.selectedCountry][0]["three_d"] || 0 | number
+ }}
+
+
+
+ HQ
+
+ {{
+ countryData[mapChart.selectedCountry][0]["high_quality"] || 0
+ | number
+ }}
+
+
+ }
+
+
+ @if(targetMetaData){
+
+
+ } } @else {
+
+ } } @else {
+
- }
{{ row.value | number }}
{{ row.percent }}%
+ }
@@ -166,8 +273,13 @@
+
{
const configureTestBed = (): void => {
TestBed.configureTestingModule({
- imports: [FormsModule, ReactiveFormsModule, LandingComponent],
- schemas: [CUSTOM_ELEMENTS_SCHEMA]
+ imports: [
+ FormsModule,
+ HttpClientTestingModule,
+ ReactiveFormsModule,
+ LandingComponent
+ ],
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ providers: [
+ {
+ provide: APIService,
+ useClass: MockAPIService
+ }
+ ]
}).compileComponents();
};
@@ -36,9 +50,9 @@ describe('LandingComponent', () => {
});
it('should have data', () => {
- expect(component.hasData()).toBeFalsy();
+ expect(component.hasLandingData()).toBeFalsy();
component.landingData = { contentTier: [] };
- expect(component.hasData()).toBeTruthy();
+ expect(component.hasLandingData()).toBeTruthy();
});
it('should refresh the charts when the data changes', () => {
diff --git a/src/app/landing/landing.component.ts b/src/app/landing/landing.component.ts
index abc9129..4b97841 100644
--- a/src/app/landing/landing.component.ts
+++ b/src/app/landing/landing.component.ts
@@ -1,5 +1,6 @@
import {
DecimalPipe,
+ JsonPipe,
LowerCasePipe,
NgClass,
NgFor,
@@ -7,19 +8,34 @@ import {
NgTemplateOutlet,
UpperCasePipe
} from '@angular/common';
-import { Component, Input, QueryList, ViewChildren } from '@angular/core';
+import {
+ Component,
+ inject,
+ Input,
+ QueryList,
+ ViewChild,
+ ViewChildren
+} from '@angular/core';
import { RouterLink } from '@angular/router';
-
import { externalLinks, isoCountryCodes } from '../_data';
-import { DimensionName, GeneralResultsFormatted } from '../_models';
+import {
+ DimensionName,
+ GeneralResultsFormatted,
+ IHash,
+ IHashArray,
+ TargetData,
+ TargetMetaData
+} from '../_models';
+import { APIService } from '../_services';
import {
RenameApiFacetPipe,
RenameApiFacetShortPipe,
RenameCountryPipe
} from '../_translate';
-import { BarComponent } from '../chart';
-import { MapComponent } from '../chart/map/map.component';
+
+import { BarComponent, MapComponent } from '../chart';
import { ResizeComponent } from '../resize';
+import { SubscriptionManager } from '../subscription-manager';
import { TruncateComponent } from '../truncate';
@Component({
@@ -41,10 +57,11 @@ import { TruncateComponent } from '../truncate';
DecimalPipe,
RenameApiFacetPipe,
RenameApiFacetShortPipe,
- RenameCountryPipe
+ RenameCountryPipe,
+ JsonPipe
]
})
-export class LandingComponent {
+export class LandingComponent extends SubscriptionManager {
public externalLinks = externalLinks;
public DimensionName = DimensionName;
public isoCountryCodes = isoCountryCodes;
@@ -54,10 +71,14 @@ export class LandingComponent {
// Used to re-draw bar-charts
@ViewChildren(BarComponent) barCharts: QueryList;
+ @ViewChild(MapComponent) mapChart: MapComponent;
barColour = '#0771ce';
isLoading: boolean;
_landingData: GeneralResultsFormatted = {};
+ targetMetaData: IHash>;
+ targetData: IHash>;
+ countryData: IHash>;
@Input() set landingData(results: GeneralResultsFormatted) {
this._landingData = results;
@@ -67,7 +88,36 @@ export class LandingComponent {
return this._landingData;
}
- hasData(): boolean {
+ private readonly api = inject(APIService);
+
+ constructor() {
+ super();
+ }
+
+ onMapCountrySet(): void {
+ if (!this.targetMetaData) {
+ this.subs.push(
+ this.api
+ .getTargetMetaData()
+ .subscribe((targetMetaData: IHash>) => {
+ this.targetMetaData = targetMetaData;
+ })
+ );
+ }
+
+ if (!this.countryData) {
+ this.subs.push(
+ this.api
+ .getCountryData()
+ .subscribe((countryData: IHash>) => {
+ this.countryData = countryData;
+ console.log('loaded countryData', countryData);
+ })
+ );
+ }
+ }
+
+ hasLandingData(): boolean {
return Object.keys(this.landingData).length > 0;
}