1 import { Component, EventEmitter, Output } from '@angular/core';
3 import moment from 'moment';
6 selector: 'cd-dashboard-time-selector',
7 templateUrl: './dashboard-time-selector.component.html',
8 styleUrls: ['./dashboard-time-selector.component.scss']
10 export class DashboardTimeSelectorComponent {
12 selectedTime = new EventEmitter<any>();
20 name: $localize`Last 5 minutes`,
21 value: this.timeToDate(5 * 60, 1)
24 name: $localize`Last 15 minutes`,
25 value: this.timeToDate(15 * 60, 3)
28 name: $localize`Last 30 minutes`,
29 value: this.timeToDate(30 * 60, 6)
32 name: $localize`Last 1 hour`,
33 value: this.timeToDate(3600, 12)
36 name: $localize`Last 3 hours`,
37 value: this.timeToDate(3 * 3600, 36)
40 name: $localize`Last 6 hours`,
41 value: this.timeToDate(6 * 3600, 72)
44 name: $localize`Last 12 hours`,
45 value: this.timeToDate(12 * 3600, 144)
48 name: $localize`Last 24 hours`,
49 value: this.timeToDate(24 * 3600, 288)
52 name: $localize`Last 2 days`,
53 value: this.timeToDate(48 * 3600, 576)
56 name: $localize`Last 7 days`,
57 value: this.timeToDate(168 * 3600, 2016)
60 this.time = this.times[3].value;
64 this.selectedTime.emit(this.timeToDate(this.time.end - this.time.start, this.time.step));
67 private timeToDate(secondsAgo: number, step: number): any {
68 const date: number = moment().unix() - secondsAgo;
69 const dateNow: number = moment().unix();
70 const formattedDate: any = {