Skip to content

Commit

Permalink
Merge branch 'development' into allow-excel-generation-567
Browse files Browse the repository at this point in the history
  • Loading branch information
olzraiti committed Nov 14, 2024
2 parents a655d6d + 330fbd3 commit bc20b38
Show file tree
Hide file tree
Showing 65 changed files with 589 additions and 987 deletions.
459 changes: 7 additions & 452 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"@angular/router": "^16.2.5",
"@apollo/client": "^3.6.9",
"@luomus/label-designer": "^4.0.16",
"@luomus/laji-form": "^15.1.23",
"@luomus/laji-form": "^15.1.24",
"@luomus/laji-form-builder": "^1.1.3",
"@luomus/laji-map": "^5.1.1",
"@ng-select/ng-select": "^11.1.1",
Expand Down
6 changes: 3 additions & 3 deletions projects/iucn/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export const environment = {
sourceKotka: 'KE.3',
systemID: 'KE.389',
apiBase: 'https://dev.laji.fi/api',
loginCheck: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/loginInfo',
loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login',
selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self',
loginCheck: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/loginInfo',
loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login',
selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self',
kerttuApi: 'https://staging-kerttu-backend.laji.fi',
protaxApi: 'https://protax-api-dev.laji.fi',
geoserver: 'https://geoserver-dev.laji.fi/geoserver',
Expand Down
4 changes: 2 additions & 2 deletions projects/kerttu-global/src/environments/environment.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const environment = {
systemID: 'KE.1181',
apiBase: '/api',
loginCheck: '',
loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login',
selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self',
loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login',
selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self',
kerttuApi: 'https://staging-kerttu-backend.laji.fi',
protaxApi: 'https://protax-api-dev.laji.fi',
geoserver: 'https://geoserver-dev.laji.fi/geoserver',
Expand Down
4 changes: 2 additions & 2 deletions projects/kerttu-global/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const environment = {
systemID: 'KE.542',
apiBase: 'https://dev.laji.fi/api',
loginCheck: '',
loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login',
selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self',
loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login',
selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self',
// kerttuApi: 'http://localhost:5000',
kerttuApi: 'https://staging-kerttu-backend.laji.fi',
protaxApi: 'https://protax-api-dev.laji.fi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export class WbcCensusesComponent implements OnInit {
activeIndex = 0;
loadedTabs = new LoadedElementsStore(['list', 'map']);

activeYear: number;
activeSeason: SEASON;
activeYear?: number;
activeSeason?: SEASON;

rows: any[];
rows!: any[];
selected = [
'document.namedPlace.name',
'document.namedPlace.municipalityDisplayName',
Expand All @@ -31,8 +31,8 @@ export class WbcCensusesComponent implements OnInit {
];

loading = false;
queryKey: string;
resultSub: Subscription;
queryKey!: string;
resultSub!: Subscription;
filterBy = '';

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export class WbcResultFiltersComponent implements OnInit, OnChanges {
seasons: SEASON[] = ['fall', 'winter', 'spring'];
areaTypes = Area.AreaType;

activeYear: number;
activeSeason: SEASON;
activeArea: string;
activeYear?: number;
activeSeason?: SEASON;
activeArea?: string;
toHtmlSelectElement = toHtmlSelectElement;

@Output() yearChange = new EventEmitter<number>();
Expand Down Expand Up @@ -58,7 +58,7 @@ export class WbcResultFiltersComponent implements OnInit, OnChanges {
}
}

onYearChange(newYear: string) {
onYearChange(newYear: string | undefined) {
this.activeYear = newYear ? parseInt(newYear, 10) : undefined;
this.yearChange.emit(this.activeYear);
if (!this.activeYear) {
Expand All @@ -68,13 +68,13 @@ export class WbcResultFiltersComponent implements OnInit, OnChanges {
}
}

onSeasonChange(newSeason: string) {
onSeasonChange(newSeason: string | undefined) {
this.activeSeason = newSeason as SEASON;
this.seasonChange.emit(newSeason as SEASON);
this.onFiltersChange();
}

onAreaChange(newArea: string) {
onAreaChange(newArea: string | undefined) {
if (newArea === 'all') {
newArea = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ enum Tabs {
})
export class WbcResultComponent implements OnInit, OnDestroy {

@Input() form: Form.SchemaForm;
@Input() form!: Form.SchemaForm;

tab$: Observable<keyof typeof Tabs>;
tab$!: Observable<keyof typeof Tabs>;

Tabs = Tabs; // eslint-disable-line @typescript-eslint/naming-convention

defaultTabSubscription: Subscription;
defaultTabSubscription!: Subscription;

constructor(
private route: ActivatedRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export class WbcResultService {
spring: [2, 3]
};

private yearCache: number[];
private yearObs: Observable<number[]>;
private speciesListCache: any[];
private yearCache?: number[];
private yearObs?: Observable<number[]>;
private speciesListCache?: any[];

constructor(
private warehouseApi: WarehouseApi
Expand All @@ -41,7 +41,7 @@ export class WbcResultService {
const yearMonth = year ? (Array.isArray(year) ? year : [year]).map(y => this.getYearMonthParam(y, season)) : [];
return {
collectionId: [this.collectionId],
birdAssociationAreaId: [birdAssociationArea],
birdAssociationAreaId: birdAssociationArea ? [birdAssociationArea] : undefined,
yearMonth,
taxonId: taxonId ? (Array.isArray(taxonId) ? taxonId : [taxonId]) : []
};
Expand Down Expand Up @@ -249,14 +249,14 @@ export class WbcResultService {
getCountsByYearForSpecies(taxonId: string, birdAssociationArea?: string, taxonCensus?: string): Observable<CountsPerYearForTaxon> {
return forkJoin([
this.warehouseApi.warehouseQueryGatheringStatisticsGet(
{...this.getFilterParams(undefined, undefined, birdAssociationArea), taxonCensus: [taxonCensus]},
{...this.getFilterParams(undefined, undefined, birdAssociationArea), taxonCensus: taxonCensus ? [taxonCensus] : undefined},
['gathering.conversions.year', 'gathering.conversions.month'],
undefined,
10000,
1
),
this.warehouseApi.warehouseQueryStatisticsGet(
{...this.getFilterParams(undefined, undefined, birdAssociationArea), taxonId: [taxonId], taxonCensus: [taxonCensus]},
{...this.getFilterParams(undefined, undefined, birdAssociationArea), taxonId: [taxonId], taxonCensus: taxonCensus ? [taxonCensus] : undefined},
['gathering.conversions.year', 'gathering.conversions.month'],
undefined,
10000,
Expand All @@ -265,7 +265,7 @@ export class WbcResultService {
false
)
]).pipe(map(data => {
const result = {fall: {}, winter: {}, spring: {}};
const result: CountsPerYearForTaxon = {fall: {}, winter: {}, spring: {}};
this.addCounts(data[1].results, 'count', result, false, 'individualCountSum');
this.addCounts(data[0].results, 'censusCount', result, true);
return result;
Expand All @@ -285,7 +285,7 @@ export class WbcResultService {
)
).pipe(
map(list => {
const statsByDocumentId = {};
const statsByDocumentId: any = {};
list.map(l => {
statsByDocumentId[l['document.documentId']] = l;
});
Expand Down Expand Up @@ -383,7 +383,7 @@ export class WbcResultService {
}

private parseObservationStatsList(resultList: any[], result: ObservationStats, isMammal = false, isLoxia = false) {
const currentState = {};
const currentState: Record<string, { taxonId: string; foundYears: any[]; row: any }> = {};
for (const season of ['fall', 'winter', 'spring']) {
currentState[season] = {taxonId: '', foundYears: [], row: undefined};
}
Expand Down Expand Up @@ -424,7 +424,7 @@ export class WbcResultService {
}

private addStatisticsToObservationStats(result: ObservationStats) {
const addStatisticsToObj = (obj, years) => {
const addStatisticsToObj = (obj: any, years: number[]) => {
let min = Number.MAX_VALUE;
let max = 0;

Expand Down Expand Up @@ -465,7 +465,7 @@ export class WbcResultService {
}
}

private addCounts(counts, key, result, addToExistingOnly = false, countKey = 'count') {
private addCounts(counts: any[], key: string, result: CountsPerYearForTaxon, addToExistingOnly = false, countKey = 'count') {
counts.map(count => {
const month = parseInt(count.aggregateBy['gathering.conversions.month'], 10);
const year = parseInt(count.aggregateBy['gathering.conversions.year'], 10);
Expand All @@ -477,7 +477,7 @@ export class WbcResultService {
if (addToExistingOnly) {
return;
}
result[season][startYear] = {};
result[season][startYear] = {} as any;
}

this.addCount(result[season][startYear], key, count[countKey]);
Expand Down Expand Up @@ -530,7 +530,7 @@ export class WbcResultService {
return month < 10 ? '0' + month : '' + month;
}

private getSeason(month: number): SEASON {
private getSeason(month: number): SEASON | undefined {
if (this.monthIsInSeasonRange(month, 'fall')) {
return 'fall';
} else if (this.monthIsInSeasonRange(month, 'winter')) {
Expand All @@ -549,7 +549,7 @@ export class WbcResultService {
return month >= this.seasonRanges[season][0] && month <= this.seasonRanges[season][1];
}

private median(array) {
private median(array: any[]) {
array.sort((a, b) => (a - b));
const mid = array.length / 2;
return mid % 1 ? array[mid - 0.5] : (array[mid - 1] + array[mid]) / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[showFooter]="false"
[height]="'calc(80vh - 40px)'"
[virtualScrolling]="true"
[rows]="rows"
[rows]="rows ? rows : []"
[loading]="!rows"
[columnMode]="'standard'"
[totalMessage]="'haseka.submissions.total' | translate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import { BookType } from 'xlsx';
styleUrls: ['./wbc-route-table.component.scss']
})
export class WbcRouteTableComponent implements OnInit {
@Input() routeId: string;
@Input() season: SEASON;
@Input() routeId!: string;
@Input() season!: SEASON;

rows: any[];
rows: any[] | undefined;
columns: DatatableColumn[] = [];

_getRowClass: (data: any) => string = this.getRowClass.bind(this);
_getCellClass: (data: any) => string = this.getCellClass.bind(this);

downloadLoading = false;

@LocalStorage() showWbcRouteTableInfo;
@LocalStorage() showWbcRouteTableInfo!: boolean | null;

@ViewChild('textOrTranslationKey', { static: true }) textOrTranslationKeyTpl: TemplateRef<any>;
@ViewChild('numberOrDocumentIds', { static: true }) numberOrDocumentIdsTpl: TemplateRef<any>;
@ViewChild('textOrTranslationKey', { static: true }) textOrTranslationKeyTpl!: TemplateRef<any>;
@ViewChild('numberOrDocumentIds', { static: true }) numberOrDocumentIdsTpl!: TemplateRef<any>;

@Output() documentClick = new EventEmitter<string>();

Expand Down Expand Up @@ -58,18 +58,18 @@ export class WbcRouteTableComponent implements OnInit {
this.showWbcRouteTableInfo = !this.showWbcRouteTableInfo;
}

onSort(event) {
const speciesStats = this.rows.slice(0, -3);
const otherStats = this.rows.slice(-3);
event.sorts.forEach((sort) => {
onSort(event: any) {
const speciesStats = this.rows?.slice(0, -3);
const otherStats = this.rows?.slice(-3);
event.sorts.forEach((sort: any) => {
const comparator = this.getSortingComparator(sort.prop);
const dir = sort.dir === 'asc' ? 1 : -1;
speciesStats.sort((a, b) => dir * comparator(a[sort.prop], b[sort.prop]));
speciesStats?.sort((a, b) => dir * comparator(a[sort.prop], b[sort.prop]));
});
this.rows = speciesStats.concat(otherStats);
this.rows = speciesStats?.concat(otherStats);
}

setColumns(data) {
setColumns(data: any) {
this.columns = [{
name: 'name',
label: 'result.unit.taxonVerbatim',
Expand Down Expand Up @@ -116,15 +116,16 @@ export class WbcRouteTableComponent implements OnInit {
}

private getAoa(): string[][] {
const aoa = [[]];
const aoa: any[] = [[]];

for (const col of this.columns) {
aoa[0].push(this.translate.instant(col.label));
/* eslint-disable @typescript-eslint/no-non-null-assertion */
aoa[0].push(this.translate.instant(col.label!));
}
for (let i = 0; i < this.rows.length; i++) {
for (let i = 0; i < (this.rows ? this.rows.length : 0); i++) {
aoa.push([]);
for (let j = 0; j < this.columns.length; j++) {
let value = this.rows[i][this.columns[j].name];
let value = this.rows![i][this.columns[j].name!];
if (j === 0 && this.isLastRowName(value)) {
value = this.translate.instant('wbc.stats.route.' + value);
}
Expand Down Expand Up @@ -172,7 +173,7 @@ export class WbcRouteTableComponent implements OnInit {
return name.indexOf('SpeciesCount') > -1 || name.indexOf('IndividualCount') > -1 || name === 'documentIds';
}

private getSortingComparator(prop: string): (a, b) => number {
private getSortingComparator(prop: string): (a: any, b: any) => number {
if (prop === 'name') {
return (a, b) => (a).localeCompare(b);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { DocumentViewerFacade } from '../../../../shared-modules/document-viewer
styleUrls: ['./wbc-route.component.css']
})
export class WbcRouteComponent implements OnInit, OnDestroy {
routeId: string;
routeId!: string;

rows: any[];
rows?: any[];
selected = ['gathering.eventDate.begin', 'count', 'individualCountSum'];
sorts: {prop: string; dir: 'asc'|'desc'}[] = [
{prop: 'gathering.eventDate.begin', dir: 'desc'},
Expand All @@ -21,10 +21,10 @@ export class WbcRouteComponent implements OnInit, OnDestroy {
loadingCensusList = false;
loadingObservationStats = false;

season: SEASON;
season!: SEASON;
observationStats: any;

private routeSub: Subscription;
private routeSub!: Subscription;

constructor(
private resultService: WbcResultService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
[filterBy]="filterBy"
[height]="height"
[virtualScrolling]="true"
[rows]="rows"
[rows]="rows ? rows : []"
[loading]="loading"
[columnMode]="columnMode"
[totalMessage]="'haseka.submissions.total' | translate"
[columns]="columns"
[count]="rows?.length">
[count]=" rows ? rows.length : 0">
</laji-datatable>

<ng-template let-value="value" let-row="row" #routeLink>
Expand Down
Loading

0 comments on commit bc20b38

Please sign in to comment.