diff --git a/src/main/angular/src/app/api/api.service.ts b/src/main/angular/src/app/api/api.service.ts index 10046b8..2e6ee91 100644 --- a/src/main/angular/src/app/api/api.service.ts +++ b/src/main/angular/src/app/api/api.service.ts @@ -40,7 +40,7 @@ export class ApiService { .subscribe(next); } - getNone(path: any[], next: Next | undefined = undefined): Subscription { + getNone(path: any[], next?: Next): Subscription { return this.http.get(getUrl('http', path)).subscribe(next); } @@ -48,7 +48,7 @@ export class ApiService { return this.http.get(getUrl('http', path), {responseType: "text"}).subscribe(next); } - getSingle(path: any[], fromJson: FromJson, next: Next | undefined = undefined): Subscription { + getSingle(path: any[], fromJson: FromJson, next?: Next): Subscription { return this.http.get(getUrl('http', path)).pipe(map(fromJson)).subscribe(next); } @@ -56,11 +56,11 @@ export class ApiService { return this.http.get(getUrl('http', path)).pipe(map(list => list.map(fromJson))).subscribe(next); } - postNone(path: any[], data: any, next: Next | undefined = undefined): Subscription { + postNone(path: any[], data: any, next?: Next): Subscription { return this.http.post(getUrl('http', path), data).subscribe(next); } - postSingle(path: any[], data: any, fromJson: FromJson, next: Next | undefined = undefined): Subscription { + postSingle(path: any[], data: any, fromJson: FromJson, next?: Next): Subscription { return this.http.post(getUrl('http', path), data).pipe(map(fromJson)).subscribe(next); } diff --git a/src/main/angular/src/app/api/series/Value.ts b/src/main/angular/src/app/api/series/Value.ts index 904c6a1..78118f6 100644 --- a/src/main/angular/src/app/api/series/Value.ts +++ b/src/main/angular/src/app/api/series/Value.ts @@ -30,7 +30,7 @@ export class Value implements IValue { } static map(iValue: IValue | null, mapping: GetValue): Value | null { - if (!iValue || !iValue.value) { + if (iValue === null || iValue.value === null) { return null; } const value = mapping(iValue.value); @@ -54,14 +54,14 @@ export class Value implements IValue { } static bi(a: IValue | null, b: IValue | null, combineValue: CombineValue) { - if (!a) { + if (a === null) { return new Value(null, null, b?.unit || null); } - if (!b) { + if (b === null) { return new Value(null, null, a?.unit || null); } - const oldestDate = !a.date || !b.date ? null : dateMin(a.date, b.date); - const difference = !a.value || !b.value ? null : combineValue(a.value, b.value); + const oldestDate = a.date === null || b.date === null ? null : dateMin(a.date, b.date); + const difference = a.value === null || b.value === null ? null : combineValue(a.value, b.value); return new Value(oldestDate, difference, a.unit); } diff --git a/src/main/angular/src/app/api/validators.ts b/src/main/angular/src/app/api/validators.ts index c76bc5e..79d2238 100644 --- a/src/main/angular/src/app/api/validators.ts +++ b/src/main/angular/src/app/api/validators.ts @@ -1,42 +1,42 @@ import {FromJson} from "./types"; export function validateNumber(json: any): number { - if (!(typeof json == "number")) { + if (!(typeof json === "number")) { throw new Error("Not a number: " + json + " (" + typeof json + "): " + JSON.stringify(json)); } return json; } export function validateNumberOrNull(json: any): number | null { - if (json == null) { + if (json === null || json === undefined) { return null; } return validateNumber(json); } export function validateBoolean(json: any): boolean { - if (!(typeof json == "boolean")) { + if (!(typeof json === "boolean")) { throw new Error("Not a boolean: " + json + " (" + typeof json + "): " + JSON.stringify(json)); } return json; } export function validateBooleanOrNull(json: any): boolean | null { - if (json == null) { + if (json === null || json === undefined) { return null; } return validateBoolean(json); } export function validateString(json: any): string { - if (!(typeof json == "string")) { + if (!(typeof json === "string")) { throw new Error("Not a string: " + json + " (" + typeof json + "): " + JSON.stringify(json)); } return json; } export function validateStringOrNull(json: any): string | null { - if (json == null) { + if (json === null || json === undefined) { return null; } return validateString(json); @@ -47,7 +47,7 @@ export function validateDate(json: any): Date { } export function validateDateOrNull(json: any): Date | null { - if (json == null) { + if (json === null || json === undefined) { return null; } return validateDate(json); @@ -58,7 +58,7 @@ export function validateList(json: any, fromJson: FromJson): T[] { } export function validateLocalDateOrNull(json: any): Date | null { - if (json == null) { + if (json === null || json === undefined) { return null; } return validateLocalDate(json); diff --git a/src/main/angular/src/app/pages/dashboard/dashboard.component.ts b/src/main/angular/src/app/pages/dashboard/dashboard.component.ts index 7e8af9a..8580c87 100644 --- a/src/main/angular/src/app/pages/dashboard/dashboard.component.ts +++ b/src/main/angular/src/app/pages/dashboard/dashboard.component.ts @@ -57,7 +57,7 @@ export class DashboardComponent implements OnInit { if (fresh.name !== name) { return old; } - if (old == null || old.lastDate.getTime() <= fresh.lastDate.getTime()) { + if (old === null || old.lastDate.getTime() <= fresh.lastDate.getTime()) { return fresh; } return old;