|
@@ -1,6 +1,7 @@
|
|
|
import { Component, ElementRef, HostListener, Input, OnInit, ViewChild } from '@angular/core';
|
|
import { Component, ElementRef, HostListener, Input, OnInit, ViewChild } from '@angular/core';
|
|
|
-import { faLocationDot, faEllipsis } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
|
|
|
+import { faLocationDot, faEllipsis, faMagnifyingGlassPlus } from '@fortawesome/free-solid-svg-icons';
|
|
|
import { ChartData, ChartOptions, TooltipItem } from 'chart.js';
|
|
import { ChartData, ChartOptions, TooltipItem } from 'chart.js';
|
|
|
|
|
+import * as dateFns from 'date-fns';
|
|
|
import { debounceTime, throttleTime, Subject } from 'rxjs';
|
|
import { debounceTime, throttleTime, Subject } from 'rxjs';
|
|
|
|
|
|
|
|
import { BytePipe } from 'src/app/pipes/byte.pipe';
|
|
import { BytePipe } from 'src/app/pipes/byte.pipe';
|
|
@@ -39,7 +40,10 @@ export class ServerDataChartComponent implements OnInit {
|
|
|
public end!: Date;
|
|
public end!: Date;
|
|
|
public data?: ChartData<'line', ServerData[], Date>;
|
|
public data?: ChartData<'line', ServerData[], Date>;
|
|
|
public options!: ChartOptions<'line'> & any;
|
|
public options!: ChartOptions<'line'> & any;
|
|
|
- public fa = { locationDot: faLocationDot, ellipsis: faEllipsis };
|
|
|
|
|
|
|
+ public fa = { locationDot: faLocationDot, ellipsis: faEllipsis, zoomPlus: faMagnifyingGlassPlus };
|
|
|
|
|
+
|
|
|
|
|
+ public zoomRanges = ['3M', '1M', '2W', '4D', '1D', '12H', '4H', '1H'];
|
|
|
|
|
+ public selectedZoomRange = '4H';
|
|
|
|
|
|
|
|
constructor(private apiService: ServerApiService, private bytePipe: BytePipe) {
|
|
constructor(private apiService: ServerApiService, private bytePipe: BytePipe) {
|
|
|
this.defaults();
|
|
this.defaults();
|
|
@@ -177,6 +181,7 @@ export class ServerDataChartComponent implements OnInit {
|
|
|
this.start = new Date(newStartMs);
|
|
this.start = new Date(newStartMs);
|
|
|
this.end = new Date(newEndMs);
|
|
this.end = new Date(newEndMs);
|
|
|
|
|
|
|
|
|
|
+ this.selectedZoomRange = '';
|
|
|
this.updateOptions();
|
|
this.updateOptions();
|
|
|
this.zoomEvent$.next();
|
|
this.zoomEvent$.next();
|
|
|
}
|
|
}
|
|
@@ -250,4 +255,27 @@ export class ServerDataChartComponent implements OnInit {
|
|
|
this.updateOptions();
|
|
this.updateOptions();
|
|
|
this.zoomEvent$.next();
|
|
this.zoomEvent$.next();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ zoomButton(zoomRange: string) {
|
|
|
|
|
+ this.selectedZoomRange = zoomRange;
|
|
|
|
|
+
|
|
|
|
|
+ const m = /^(\d+)(\w)$/.exec(zoomRange);
|
|
|
|
|
+ if (!m) return;
|
|
|
|
|
+ switch (m[2]) {
|
|
|
|
|
+ case 'H':
|
|
|
|
|
+ this.start = dateFns.addHours(this.end, -1 * Number(m[1]));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'D':
|
|
|
|
|
+ this.start = dateFns.addDays(this.end, -1 * Number(m[1]));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'W':
|
|
|
|
|
+ this.start = dateFns.addWeeks(this.end, -1 * Number(m[1]));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'M':
|
|
|
|
|
+ this.start = dateFns.addMonths(this.end, -1 * Number(m[1]));
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.zoomEvent$.next();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|