]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard-time-selector/dashboard-time-selector.component.ts
add stop-gap to fix compat with CPUs not supporting SSE 4.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / dashboard-v3 / dashboard-time-selector / dashboard-time-selector.component.ts
1 import { Component, EventEmitter, Output } from '@angular/core';
2
3 import moment from 'moment';
4
5 @Component({
6 selector: 'cd-dashboard-time-selector',
7 templateUrl: './dashboard-time-selector.component.html',
8 styleUrls: ['./dashboard-time-selector.component.scss']
9 })
10 export class DashboardTimeSelectorComponent {
11 @Output()
12 selectedTime = new EventEmitter<any>();
13
14 times: any;
15 time: any;
16
17 constructor() {
18 this.times = [
19 {
20 name: $localize`Last 5 minutes`,
21 value: this.timeToDate(5 * 60, 1)
22 },
23 {
24 name: $localize`Last 15 minutes`,
25 value: this.timeToDate(15 * 60, 3)
26 },
27 {
28 name: $localize`Last 30 minutes`,
29 value: this.timeToDate(30 * 60, 6)
30 },
31 {
32 name: $localize`Last 1 hour`,
33 value: this.timeToDate(3600, 12)
34 },
35 {
36 name: $localize`Last 3 hours`,
37 value: this.timeToDate(3 * 3600, 36)
38 },
39 {
40 name: $localize`Last 6 hours`,
41 value: this.timeToDate(6 * 3600, 72)
42 },
43 {
44 name: $localize`Last 12 hours`,
45 value: this.timeToDate(12 * 3600, 144)
46 },
47 {
48 name: $localize`Last 24 hours`,
49 value: this.timeToDate(24 * 3600, 288)
50 },
51 {
52 name: $localize`Last 2 days`,
53 value: this.timeToDate(48 * 3600, 576)
54 },
55 {
56 name: $localize`Last 7 days`,
57 value: this.timeToDate(168 * 3600, 2016)
58 }
59 ];
60 this.time = this.times[3].value;
61 }
62
63 emitTime() {
64 this.selectedTime.emit(this.timeToDate(this.time.end - this.time.start, this.time.step));
65 }
66
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 = {
71 start: date,
72 end: dateNow,
73 step: step
74 };
75 return formattedDate;
76 }
77 }