added month history to location-detail
This commit is contained in:
parent
bec1ee0c28
commit
810dc77b24
@ -2,21 +2,32 @@
|
|||||||
|
|
||||||
<app-location-power [location]="location"></app-location-power>
|
<app-location-power [location]="location"></app-location-power>
|
||||||
|
|
||||||
<app-location-energy [location]="location" [interval]="Interval.DAY" heading="Heute"></app-location-energy>
|
<app-location-energy [location]="location" [interval]="Interval.DAY" [offset]="offsetDay">
|
||||||
|
|
||||||
<app-location-energy [location]="location" [interval]="Interval.DAY" [offset]="offset">
|
|
||||||
<ng-content #SeriesHistoryHeading>
|
<ng-content #SeriesHistoryHeading>
|
||||||
<div style="display: flex; width: 100%">
|
<div style="display: flex; width: 100%">
|
||||||
|
|
||||||
<div (click)="offset += 1">←</div>
|
<div (click)="offsetDay += 1">←</div>
|
||||||
|
|
||||||
<div (click)="offset = Math.max(1, offset -1)">→</div>
|
<div (click)="offsetDay = Math.max(0, offsetDay -1)">→</div>
|
||||||
|
|
||||||
<div style="flex: 1">{{ offsetDayTitle() }}</div>
|
<div style="flex: 1">{{ offsetDayTitle() }}</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-content>
|
</ng-content>
|
||||||
</app-location-energy>
|
</app-location-energy>
|
||||||
|
|
||||||
|
<app-location-energy [location]="location" [interval]="Interval.MONTH" [offset]="offsetMonth">
|
||||||
|
<ng-content #SeriesHistoryHeading>
|
||||||
|
<div style="display: flex; width: 100%">
|
||||||
|
|
||||||
|
<div (click)="offsetMonth += 1">←</div>
|
||||||
|
|
||||||
|
<div (click)="offsetMonth = Math.max(0, offsetMonth -1)">→</div>
|
||||||
|
|
||||||
|
<div style="flex: 1">{{ offsetMonthTitle() }}</div>
|
||||||
|
</div>
|
||||||
|
</ng-content>
|
||||||
|
</app-location-energy>
|
||||||
|
|
||||||
<div class="Section">
|
<div class="Section">
|
||||||
<div class="SectionHeading">
|
<div class="SectionHeading">
|
||||||
<div class="SectionHeadingText">
|
<div class="SectionHeadingText">
|
||||||
|
|||||||
@ -41,7 +41,9 @@ export class LocationDetail implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private readonly subs: Subscription [] = [];
|
private readonly subs: Subscription [] = [];
|
||||||
|
|
||||||
protected offset: number = 1;
|
protected offsetDay: number = 0;
|
||||||
|
|
||||||
|
protected offsetMonth: number = 0;
|
||||||
|
|
||||||
private readonly datePipe: DatePipe;
|
private readonly datePipe: DatePipe;
|
||||||
|
|
||||||
@ -76,16 +78,21 @@ export class LocationDetail implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected offsetDayTitle(): string {
|
protected offsetDayTitle(): string {
|
||||||
if (this.offset === 1) {
|
if (this.offsetDay === 0) {
|
||||||
|
return 'Heute';
|
||||||
|
} else if (this.offsetDay === 1) {
|
||||||
return 'Gestern';
|
return 'Gestern';
|
||||||
} else {
|
} else {
|
||||||
if (this.offset < 7) {
|
|
||||||
const d = new Date(this.dateService.now);
|
const d = new Date(this.dateService.now);
|
||||||
d.setDate(d.getDate() - this.offset);
|
d.setDate(d.getDate() - this.offsetDay);
|
||||||
return this.datePipe.transform(d, 'EEEE') || '';
|
return this.datePipe.transform(d, 'dd.MM.yyyy EEEE') || '';
|
||||||
}
|
|
||||||
return `Vor ${this.offset} Tagen`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected offsetMonthTitle(): string {
|
||||||
|
const d = new Date(this.dateService.now);
|
||||||
|
d.setMonth(d.getMonth() - this.offsetMonth);
|
||||||
|
return this.datePipe.transform(d, 'yyyy MMMM') || '';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export class Interval {
|
|||||||
|
|
||||||
static readonly WEEK = new Interval('WEEK', this.HOUR);
|
static readonly WEEK = new Interval('WEEK', this.HOUR);
|
||||||
|
|
||||||
static readonly MONTH = new Interval('MONTH', this.HOUR);
|
static readonly MONTH = new Interval('MONTH', this.DAY);
|
||||||
|
|
||||||
static readonly YEAR = new Interval('YEAR', this.DAY);
|
static readonly YEAR = new Interval('YEAR', this.DAY);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user