mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
first stuff
This commit is contained in:
parent
f50dc4e99d
commit
e4e41474b1
68
public/app/core/components/Picker/UnitPicker.tsx
Normal file
68
public/app/core/components/Picker/UnitPicker.tsx
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import React, { PureComponent } from 'react';
|
||||||
|
import Select from 'react-select';
|
||||||
|
import ResetStyles from 'app/core/components/Picker/ResetStyles';
|
||||||
|
import DescriptionOption from './DescriptionOption';
|
||||||
|
import kbn from '../../utils/kbn';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
width: number;
|
||||||
|
className?: string;
|
||||||
|
onSelected: (item: any) => {} | void;
|
||||||
|
placeholder?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class UnitPicker extends PureComponent<Props> {
|
||||||
|
formatGroupLabel = data => {
|
||||||
|
console.log('format', data);
|
||||||
|
|
||||||
|
const groupStyles = {
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
};
|
||||||
|
|
||||||
|
const groupBadgeStyles = {
|
||||||
|
backgroundColor: '#EBECF0',
|
||||||
|
borderRadius: '2em',
|
||||||
|
color: '#172B4D',
|
||||||
|
display: 'inline-block',
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: 400,
|
||||||
|
lineHeight: '1',
|
||||||
|
minWidth: 1,
|
||||||
|
padding: '0.16666666666667em 0.5em',
|
||||||
|
textAlign: 'center',
|
||||||
|
} as React.CSSProperties;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={groupStyles}>
|
||||||
|
<span>{data.label}</span>
|
||||||
|
<span style={groupBadgeStyles}>{data.submenu.length}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { className, onSelected, placeholder, width } = this.props;
|
||||||
|
|
||||||
|
const options = kbn.getUnitFormats();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
classNamePrefix="gf-form-select-box"
|
||||||
|
className={`width-${width} gf-form-input gf-form-input--form-dropdown ${className || ''}`}
|
||||||
|
components={{
|
||||||
|
Option: DescriptionOption,
|
||||||
|
}}
|
||||||
|
getOptionLabel={i => i.text}
|
||||||
|
getOptionValue={i => i.value}
|
||||||
|
isSearchable={false}
|
||||||
|
onChange={onSelected}
|
||||||
|
options={options}
|
||||||
|
placeholder={placeholder || 'Choose'}
|
||||||
|
styles={ResetStyles}
|
||||||
|
formatGroupLabel={this.formatGroupLabel}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -48,10 +48,6 @@ export class DataPanel extends Component<Props, State> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
console.log('DataPanel mount');
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidUpdate(prevProps: Props) {
|
async componentDidUpdate(prevProps: Props) {
|
||||||
if (!this.hasPropsChanged(prevProps)) {
|
if (!this.hasPropsChanged(prevProps)) {
|
||||||
return;
|
return;
|
||||||
@ -113,7 +109,7 @@ export class DataPanel extends Component<Props, State> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { response, loading, isFirstLoad } = this.state;
|
const { response, loading, isFirstLoad } = this.state;
|
||||||
console.log('data panel render');
|
|
||||||
const timeSeries = response.data;
|
const timeSeries = response.data;
|
||||||
|
|
||||||
if (isFirstLoad && (loading === LoadingState.Loading || loading === LoadingState.NotStarted)) {
|
if (isFirstLoad && (loading === LoadingState.Loading || loading === LoadingState.NotStarted)) {
|
||||||
|
@ -57,7 +57,6 @@ export class PanelChrome extends PureComponent<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onRender = () => {
|
onRender = () => {
|
||||||
console.log('onRender');
|
|
||||||
this.setState(prevState => ({
|
this.setState(prevState => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
renderCounter: this.state.renderCounter + 1,
|
renderCounter: this.state.renderCounter + 1,
|
||||||
@ -75,7 +74,6 @@ export class PanelChrome extends PureComponent<Props, State> {
|
|||||||
const { datasource, targets } = panel;
|
const { datasource, targets } = panel;
|
||||||
const PanelComponent = this.props.component;
|
const PanelComponent = this.props.component;
|
||||||
|
|
||||||
console.log('panelChrome render');
|
|
||||||
return (
|
return (
|
||||||
<div className="panel-container">
|
<div className="panel-container">
|
||||||
<PanelHeader panel={panel} dashboard={dashboard} />
|
<PanelHeader panel={panel} dashboard={dashboard} />
|
||||||
@ -88,7 +86,6 @@ export class PanelChrome extends PureComponent<Props, State> {
|
|||||||
refreshCounter={refreshCounter}
|
refreshCounter={refreshCounter}
|
||||||
>
|
>
|
||||||
{({ loading, timeSeries }) => {
|
{({ loading, timeSeries }) => {
|
||||||
console.log('panelcrome inner render');
|
|
||||||
return (
|
return (
|
||||||
<PanelComponent
|
<PanelComponent
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import Gauge from 'app/viz/Gauge';
|
import Gauge from 'app/viz/Gauge';
|
||||||
import { NullValueMode, PanelProps } from 'app/types';
|
import { NullValueMode, PanelOptionsProps, PanelProps } from 'app/types';
|
||||||
import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
|
import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
|
||||||
|
import { UnitPicker } from '../../../core/components/Picker/UnitPicker';
|
||||||
|
|
||||||
export interface Options {}
|
export interface Options {}
|
||||||
|
|
||||||
@ -20,4 +21,17 @@ export class GaugePanel extends PureComponent<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { GaugePanel as PanelComponent };
|
export class GaugeOptions extends PureComponent<PanelOptionsProps<Options>> {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="section gf-form-group">
|
||||||
|
<h5 className="page-heading">Units</h5>
|
||||||
|
<UnitPicker width={20} onSelected={() => {}} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { GaugePanel as PanelComponent, GaugeOptions as PanelOptionsComponent };
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
import React, { PureComponent } from 'react';
|
|
||||||
import { PanelOptionsProps } from '../types';
|
|
||||||
|
|
||||||
interface Props {}
|
|
||||||
|
|
||||||
export class GaugeOptions extends PureComponent<PanelOptionsProps<Props>> {
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<div className="section gf-form-group">
|
|
||||||
<h5 className="page-heading">Draw Modes</h5>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user