added last downtime log (closes #55)

added uptime statistics (closes #56)
added german translations (closes #57)
This commit is contained in:
Samuel Philipp 2021-01-10 16:06:18 +01:00
parent acb39f6b2a
commit e9599373ec
27 changed files with 819 additions and 265 deletions

View file

@ -0,0 +1,8 @@
import { DayjsPipe } from './dayjs.pipe';
describe('DayjsPipe', () => {
it('create an instance', () => {
const pipe = new DayjsPipe();
expect(pipe).toBeTruthy();
});
});

View file

@ -0,0 +1,36 @@
import { Pipe, PipeTransform } from '@angular/core';
import * as dayjs from 'dayjs';
import * as utc from 'dayjs/plugin/utc';
import * as relativeTime from 'dayjs/plugin/relativeTime';
import * as localizedFormat from 'dayjs/plugin/localizedFormat';
import {TranslateService} from '@ngx-translate/core';
import 'dayjs/locale/de';
dayjs.extend(utc);
dayjs.extend(relativeTime);
dayjs.extend(localizedFormat);
@Pipe({
name: 'dayjs',
pure: false
})
export class DayjsPipe implements PipeTransform {
constructor(private translate: TranslateService) {
}
transform(value: string | Date, method: string, ...args: any[]): string {
const date = dayjs.utc(value);
switch (method) {
case 'to':
const to = args[0] ? dayjs.utc(args[0]) : dayjs.utc();
const suffix = args.length > 1 && args[1] === true;
return date.locale(this.translate.currentLang).to(to, !suffix);
case 'from':
const from = args[0] ? dayjs.utc(args[0]) : dayjs.utc();
return date.locale(this.translate.currentLang).from(from);
case 'format':
return date.local().locale(this.translate.currentLang).format(args[0]);
}
throw new Error('please pass a method to use!');
}
}