Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,781 changes: 1,665 additions & 1,116 deletions projects/laji-api-client/generated/api.d.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions projects/laji/src/app/home/home-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface IHomeData {
news: {
prevPage: number;
nextPage: number;
results: Pick<News, 'id'|'title'|'external'|'externalURL'|'tags'|'posted'>[];
results: Pick<News, 'id'|'title'|'external'|'externalURL'|'tag'|'posted'>[];
};
}

Expand Down Expand Up @@ -124,7 +124,7 @@ const HOME_QUERY = gql`
results {
id
title
tags
tag
posted
external
externalURL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class HorizontalChartDataService {
) { }


getChartDataLabels(ids: string[]): Observable<Record<string, {vernacularName: string; scientificName: string}>> {
getChartDataLabels(ids: string[]): Observable<Record<string, {vernacularName?: string; scientificName: string}>> {
if (ids.length === 0) { return of({}); }
return this.api.get('/taxa',
{ query: { id: ids.join(','), pageSize: ids.length, selectedFields: 'id,vernacularName,scientificName' } },
Expand All @@ -21,7 +21,7 @@ export class HorizontalChartDataService {
map(({ results }) => results.reduce((idToNames, {id, vernacularName, scientificName }) => {
idToNames[id] = { vernacularName, scientificName };
return idToNames;
}, {} as Record<string, {vernacularName: string; scientificName: string}>))
}, {} as Record<string, {vernacularName?: string; scientificName: string}>))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,7 @@ export class DocumentExportService {
}

if (key.match(new RegExp('^' + this.valuePrefixes.collection + '\.[0-9]+$'))) {
return this.collectionService
.getName$(key, this.translate.getCurrentLang());
return this.collectionService.getName$(key);
}

return ObservableOf(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class MetadataSelectComponent implements OnChanges, OnDestroy, ControlVal
case 'KE.informationSystem':
return this.sourceService.getAllAsLookUp().pipe(
map(system => Object.keys(system).reduce<SelectOption[]>((total, current) => {
total.push({id: current, value: system[current].name});
total.push({id: current, value: system[current].name || current});
return total;
}, [])));
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TechnicalNewsDumbComponent {
isNew = Date.now() - parseInt(newsItem.posted, 10) < (days * 86400000); // number of milliseconds in a day
}

const isTechnical = newsItem.tags?.includes('technical');
const isTechnical = newsItem.tag === 'technical';
return isTechnical && isNew;
}));
}
Expand Down
31 changes: 2 additions & 29 deletions projects/laji/src/app/shared/iucn-footer/footer.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FooterService } from '../service/footer.service';
import { NavigationEnd, Router } from '@angular/router';
import { of, Subscription } from 'rxjs';
import { Subscription } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
import { Logger } from '../logger/logger.service';
import { LajiApiClientService } from 'projects/laji-api-client/src/laji-api-client.service';
import { filter, map } from 'rxjs';
import { filter } from 'rxjs';

@Component({
selector: 'laji-iucn-footer',
Expand All @@ -15,13 +13,10 @@ import { filter, map } from 'rxjs';
})
export class IucnFooterComponent implements OnInit, OnDestroy {

private static treeData: any;

public onFrontPage = false;
public onMapPage = false;
public subRouteEvent!: Subscription;
public subLangChange!: Subscription;
public tree$: any;
public columns = [
'col-sm-offset-1 col-sm-6 col-md-3',
'col-sm-5 col-md-2',
Expand All @@ -32,24 +27,17 @@ export class IucnFooterComponent implements OnInit, OnDestroy {
constructor(
public footerService: FooterService,
private router: Router,
private api: LajiApiClientService,
private translate: TranslateService,
private logger: Logger
) {
}

ngOnInit() {
this.tree$ = of(IucnFooterComponent.treeData);
this.fetchTreeData(false);
this.subRouteEvent = this.router.events.pipe(filter(event => event instanceof NavigationEnd))
.subscribe(() => {
this.onFrontPage = this.router.isActive('/', true)
|| this.router.isActive('/en', true)
|| this.router.isActive('/sv', true);
});
this.subLangChange = this.translate.onLangChange.subscribe(() => {
this.fetchTreeData();
});
}

ngOnDestroy() {
Expand All @@ -64,19 +52,4 @@ export class IucnFooterComponent implements OnInit, OnDestroy {
currentLangIsFinnish() {
return this.translate.getCurrentLang() === 'fi';
}

fetchTreeData(force = true) {
if (!force && IucnFooterComponent.treeData) {
return;
}
this.api.get('/information/index').pipe(
map(tree => tree.children || [])
).subscribe(
tree => {
IucnFooterComponent.treeData = tree;
this.tree$ = of(IucnFooterComponent.treeData);
},
err => this.logger.error('Failed to fetchList information tree', err)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ <h3>{{ 'home.news-list.current' | translate }}</h3>
</div>
}
<div>
@for (tag of item.tags!; track tag) {
<span class="label label-default">{{ tag | translate }}</span>
}
<span class="label label-default">{{ item.tag | translate }}</span>
<span class="pull-right">{{ item.posted! | amFromUnix | amDateFormat:'DD.MM.YYYY' }}</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion projects/laji/src/app/shared/pipe/collection-name.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class CollectionNamePipe extends AbstractLabelPipe implements PipeTransfo

protected _updateValue(key: string): Observable<string> {
this.key = key;
return this.collectionService.getName$(key, '');
return this.collectionService.getName$(key);
}

protected _parseValue(res: string): string {
Expand Down
6 changes: 3 additions & 3 deletions projects/laji/src/app/shared/service/collection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class CollectionService {

getAllAsKeyValue$(mustHaveWarehouseData = false) {
const all$ = this.api.get('/collections', { query: { selectedFields: 'id,collectionName', pageSize: 100000 } })
.pipe(map(({results}) => results.map(({id, collectionName}) => ({ id, value: collectionName }))));
.pipe(map(({results}) => results.map(({id, collectionName}) => ({ id, value: collectionName || id }))));
if (mustHaveWarehouseData) {
return this.getAllWarehouseCollections$().pipe(
switchMap(warehouseCollection => all$.pipe(
Expand All @@ -123,10 +123,10 @@ export class CollectionService {
return this.api.get('/collections/{id}', { path: { id } });
}

getName$(id: string, empty: null|string = null): Observable<string> {
getName$(id: string): Observable<string> {
return this.getAllAsKeyValue$().pipe(
map(data => data.find(col => col.id === id)),
map(col => col ? col.value : (empty === null ? id : empty))
map(col => col?.value ? col.value : id)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Taxon = components['schemas']['LajiBackendTaxon'];
type SimpleTaxon = components['schemas']['LajiBackendSimpleTaxon'];

type SimpleTaxonArrayKeys = {
[K in keyof Taxon]: Taxon[K] extends SimpleTaxon[] ? K : never
[K in keyof Taxon]-?: Taxon[K] extends SimpleTaxon[] ? K : never
}[keyof Taxon];

export const SYNONYM_KEYS: SimpleTaxonArrayKeys[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Taxon = components['schemas']['LajiBackendTaxon'];
type SimpleTaxon = components['schemas']['LajiBackendSimpleTaxon'];

type SimpleTaxonArrayKeys = {
[K in keyof Taxon]: Taxon[K] extends SimpleTaxon[] ? K : never
[K in keyof Taxon]-?: Taxon[K] extends SimpleTaxon[] ? K : never
}[keyof Taxon];

interface AvailableLangs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Taxon = components['schemas']['LajiBackendTaxon'];
type SimpleTaxon = components['schemas']['LajiBackendSimpleTaxon'];

type SimpleTaxonArrayKeys = {
[K in keyof Taxon]: Taxon[K] extends SimpleTaxon[] ? K : never
[K in keyof Taxon]-?: Taxon[K] extends SimpleTaxon[] ? K : never
}[keyof Taxon];

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class SoundIdentificationTableComponent implements OnInit {
@Input() loading = false;

columns!: DatatableColumn[];
vernacularCache: Record<string, Observable<string>> = {};
vernacularCache: Record<string, Observable<string | undefined>> = {};
lang!: string;

constructor(
Expand Down
Loading