Files
brewman/overlord/src/app/entries/entries-resolver.service.ts
T
tanshu 22cac61761 Feature: Adding recipe templates to print recipes.
Feautre: Recipe export to xlsx
Chore: Python 11 style type annotations
Chore: Moved to sqlalchemy 2.0
Chore: Minimum python is 3.11
Fix: Fix nullability of a lot of fields in the database.
2023-07-23 08:12:21 +05:30

39 lines
1.3 KiB
TypeScript

import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { EntriesService } from './entries.service';
import { Report } from './report';
@Injectable({
providedIn: 'root',
})
export class EntriesResolver {
constructor(private ser: EntriesService) {}
resolve(route: ActivatedRouteSnapshot): Observable<Report> {
const start_date = route.queryParamMap.get('s');
const finish_date = route.queryParamMap.get('f');
const posted =
route.queryParamMap.get('p') === null ? null : route.queryParamMap.get('p') === 'true';
const page_size =
route.queryParamMap.get('ps') === null ? 50 : +(route.queryParamMap.get('ps') as string);
const page_index =
route.queryParamMap.get('pi') === null ? 0 : +(route.queryParamMap.get('pi') as string);
const sort = route.queryParamMap.get('a') ?? 'date';
const direction = route.queryParamMap.get('d') ?? 'desc';
const issue_vouchers =
route.queryParamMap.get('i') === null ? false : route.queryParamMap.get('i') === 'true';
return this.ser.list(
start_date,
finish_date,
posted,
page_size,
page_index,
sort,
direction,
issue_vouchers,
);
}
}