mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
value formats: another rename and updates code to use new valueFormats func
This commit is contained in:
parent
8aae6e8c09
commit
9e6411bf4b
@ -1,2 +1,2 @@
|
|||||||
export * from './processTimeSeries';
|
export * from './processTimeSeries';
|
||||||
export * from './value_formats/valueFormats';
|
export * from './valueFormats/valueFormats';
|
||||||
|
@ -158,7 +158,7 @@ export function getValueFormats() {
|
|||||||
submenu: cat.formats.map(format => {
|
submenu: cat.formats.map(format => {
|
||||||
return {
|
return {
|
||||||
text: format.name,
|
text: format.name,
|
||||||
id: format.id,
|
value: format.id,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
};
|
};
|
@ -1,6 +1,6 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import Select from './Select';
|
import Select from './Select';
|
||||||
import kbn from 'app/core/utils/kbn';
|
import { getValueFormats } from '@grafana/ui';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onChange: (item: any) => void;
|
onChange: (item: any) => void;
|
||||||
@ -16,14 +16,14 @@ export default class UnitPicker extends PureComponent<Props> {
|
|||||||
render() {
|
render() {
|
||||||
const { defaultValue, onChange, width } = this.props;
|
const { defaultValue, onChange, width } = this.props;
|
||||||
|
|
||||||
const unitGroups = kbn.getUnitFormats();
|
const unitGroups = getValueFormats();
|
||||||
|
|
||||||
// Need to transform the data structure to work well with Select
|
// Need to transform the data structure to work well with Select
|
||||||
const groupOptions = unitGroups.map(group => {
|
const groupOptions = unitGroups.map(group => {
|
||||||
const options = group.submenu.map(unit => {
|
const options = group.submenu.map(unit => {
|
||||||
return {
|
return {
|
||||||
label: unit.text,
|
label: unit.text,
|
||||||
value: unit.id,
|
value: unit.value,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { getValueFormat, getValueFormatterIndex } from '@grafana/ui';
|
import { getValueFormat, getValueFormatterIndex, getValueFormats } from '@grafana/ui';
|
||||||
import { getUnitFormats } from '@grafana/ui/src';
|
|
||||||
|
|
||||||
const kbn: any = {};
|
const kbn: any = {};
|
||||||
|
|
||||||
@ -284,9 +283,12 @@ kbn.roundValue = (num, decimals) => {
|
|||||||
///// FORMAT MENU /////
|
///// FORMAT MENU /////
|
||||||
|
|
||||||
kbn.getUnitFormats = () => {
|
kbn.getUnitFormats = () => {
|
||||||
return getUnitFormats();
|
return getValueFormats();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Backward compatible layer for value formats to support old plugins
|
||||||
|
//
|
||||||
if (typeof Proxy !== "undefined") {
|
if (typeof Proxy !== "undefined") {
|
||||||
kbn.valueFormats = new Proxy(kbn.valueFormats, {
|
kbn.valueFormats = new Proxy(kbn.valueFormats, {
|
||||||
get(target, name, receiver) {
|
get(target, name, receiver) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import kbn from 'app/core/utils/kbn';
|
import { getValueFormats } from '@grafana/ui';
|
||||||
|
|
||||||
export class AxesEditorCtrl {
|
export class AxesEditorCtrl {
|
||||||
panel: any;
|
panel: any;
|
||||||
@ -15,7 +15,7 @@ export class AxesEditorCtrl {
|
|||||||
this.panel = this.panelCtrl.panel;
|
this.panel = this.panelCtrl.panel;
|
||||||
this.$scope.ctrl = this;
|
this.$scope.ctrl = this;
|
||||||
|
|
||||||
this.unitFormats = kbn.getUnitFormats();
|
this.unitFormats = getValueFormats();
|
||||||
|
|
||||||
this.logScales = {
|
this.logScales = {
|
||||||
linear: 1,
|
linear: 1,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import kbn from 'app/core/utils/kbn';
|
import { getValueFormats } from '@grafana/ui';
|
||||||
|
|
||||||
export class ColumnOptionsCtrl {
|
export class ColumnOptionsCtrl {
|
||||||
panel: any;
|
panel: any;
|
||||||
@ -22,7 +22,7 @@ export class ColumnOptionsCtrl {
|
|||||||
this.activeStyleIndex = 0;
|
this.activeStyleIndex = 0;
|
||||||
this.panelCtrl = $scope.ctrl;
|
this.panelCtrl = $scope.ctrl;
|
||||||
this.panel = this.panelCtrl.panel;
|
this.panel = this.panelCtrl.panel;
|
||||||
this.unitFormats = kbn.getUnitFormats();
|
this.unitFormats = getValueFormats();
|
||||||
this.colorModes = [
|
this.colorModes = [
|
||||||
{ text: 'Disabled', value: null },
|
{ text: 'Disabled', value: null },
|
||||||
{ text: 'Cell', value: 'cell' },
|
{ text: 'Cell', value: 'cell' },
|
||||||
|
Loading…
Reference in New Issue
Block a user