mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -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) {
|
||||
if (!this.hasPropsChanged(prevProps)) {
|
||||
return;
|
||||
@ -113,7 +109,7 @@ export class DataPanel extends Component<Props, State> {
|
||||
|
||||
render() {
|
||||
const { response, loading, isFirstLoad } = this.state;
|
||||
console.log('data panel render');
|
||||
|
||||
const timeSeries = response.data;
|
||||
|
||||
if (isFirstLoad && (loading === LoadingState.Loading || loading === LoadingState.NotStarted)) {
|
||||
|
@ -57,7 +57,6 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
onRender = () => {
|
||||
console.log('onRender');
|
||||
this.setState(prevState => ({
|
||||
...prevState,
|
||||
renderCounter: this.state.renderCounter + 1,
|
||||
@ -75,7 +74,6 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
const { datasource, targets } = panel;
|
||||
const PanelComponent = this.props.component;
|
||||
|
||||
console.log('panelChrome render');
|
||||
return (
|
||||
<div className="panel-container">
|
||||
<PanelHeader panel={panel} dashboard={dashboard} />
|
||||
@ -88,7 +86,6 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
refreshCounter={refreshCounter}
|
||||
>
|
||||
{({ loading, timeSeries }) => {
|
||||
console.log('panelcrome inner render');
|
||||
return (
|
||||
<PanelComponent
|
||||
loading={loading}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
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 { UnitPicker } from '../../../core/components/Picker/UnitPicker';
|
||||
|
||||
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