Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
fix(pulse-plugin): fixed permitted intervals format (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
dron8552 committed Mar 4, 2019
1 parent 7cc40d9 commit 498e59e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/pulse/charts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { PulseChart } from './pulse-chart';
export { PulseChart, PulseChartComponent } from './pulse-chart';

export { PulseDiskChartComponent } from './pulse-disk-chart/pulse-disk-chart.component';
export { PulseNetworkChartComponent } from './pulse-network-chart/pulse-network-chart.component';
Expand Down
15 changes: 13 additions & 2 deletions src/app/pulse/pulse.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ interface TimeParams {
shift: string;
}

export interface Interval {
scales: Object;
export interface Scale {
range: string;
aggregations: string[];
}

export interface Intervals {
scales: Scale[];
shifts: string[];
}

export interface IntervalsResp {
scales: { [name: string]: Scale }[];
shifts: string[];
}

@Injectable()
Expand Down
25 changes: 15 additions & 10 deletions src/app/pulse/vm-pulse/vm-pulse.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import {
import { MAT_DIALOG_DATA, MatTabChangeEvent } from '@angular/material';
import { TranslateService } from '@ngx-translate/core';
import { Dictionary } from '@ngrx/entity';
const debounce = require('lodash/debounce');
import * as moment from 'moment';

import { LocalStorageService } from '../../shared/services/local-storage.service';
import { PulseChartComponent } from '../charts/pulse-chart';
import { PulseCpuRamChartComponent } from '../charts/pulse-cpu-ram-chart/pulse-cpu-ram-chart.component';
import { PulseDiskChartComponent } from '../charts/pulse-disk-chart/pulse-disk-chart.component';
import { PulseNetworkChartComponent } from '../charts/pulse-network-chart/pulse-network-chart.component';
import { Interval, PulseService } from '../pulse.service';
import {
PulseChartComponent,
PulseCpuRamChartComponent,
PulseDiskChartComponent,
PulseNetworkChartComponent,
} from '../charts';
import { Intervals, IntervalsResp, PulseService } from '../pulse.service';

const debounce = require('lodash/debounce');

const enum TabIndex {
CpuRam,
Expand Down Expand Up @@ -47,7 +50,7 @@ export class VmPulseComponent implements OnInit, OnDestroy {
diskChart: PulseDiskChartComponent;

public tabIndex = 0;
public permittedIntervals;
public permittedIntervals: Intervals;

public pulseTranslations: {
LABELS: Dictionary<string>;
Expand Down Expand Up @@ -79,9 +82,11 @@ export class VmPulseComponent implements OnInit, OnDestroy {

public ngOnInit() {
moment.locale(this.translateService.currentLang);
this.pulse.getPermittedIntervals().subscribe((intervals: Interval) => {
intervals.scales = Object.values(intervals.scales);
this.permittedIntervals = intervals;
this.pulse.getPermittedIntervals().subscribe((intervals: IntervalsResp) => {
this.permittedIntervals = {
shifts: intervals.shifts,
scales: intervals.scales.map(scale => Object.values(scale)[0]),
};
this.scheduleAutoRefresh();
this.initParameters();
});
Expand Down

0 comments on commit 498e59e

Please sign in to comment.