mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
some progress on groups and options
This commit is contained in:
parent
063a1acf94
commit
61a704a64e
39
public/app/core/components/Picker/Unit/UnitGroup.tsx
Normal file
39
public/app/core/components/Picker/Unit/UnitGroup.tsx
Normal file
@ -0,0 +1,39 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { GroupProps } from 'react-select/lib/components/Group';
|
||||
|
||||
interface ExtendedGroupProps extends GroupProps<any> {
|
||||
data: any;
|
||||
}
|
||||
|
||||
interface State {
|
||||
expanded: boolean;
|
||||
}
|
||||
|
||||
export class UnitGroup extends PureComponent<ExtendedGroupProps, State> {
|
||||
state = {
|
||||
expanded: false,
|
||||
};
|
||||
|
||||
onToggleChildren = () => {
|
||||
this.setState(prevState => ({
|
||||
expanded: !prevState.expanded,
|
||||
}));
|
||||
};
|
||||
|
||||
render() {
|
||||
const { children, label } = this.props;
|
||||
const { expanded } = this.state;
|
||||
|
||||
console.log(children);
|
||||
|
||||
return (
|
||||
<div className="width-18 unit-picker-group" style={{ marginBottom: '5px' }}>
|
||||
<div className="unit-picker-group-item" onClick={this.onToggleChildren}>
|
||||
<span style={{ textTransform: 'capitalize' }}>{label}</span>
|
||||
<i className={`fa ${expanded ? 'fa-minus' : 'fa-plus'}`} />{' '}
|
||||
</div>
|
||||
{expanded && children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
17
public/app/core/components/Picker/Unit/UnitMenu.tsx
Normal file
17
public/app/core/components/Picker/Unit/UnitMenu.tsx
Normal file
@ -0,0 +1,17 @@
|
||||
import React, { SFC } from 'react';
|
||||
import { components } from 'react-select';
|
||||
import { MenuProps } from 'react-select/lib/components/Menu';
|
||||
|
||||
interface ExtendedMenuProps extends MenuProps<any> {
|
||||
data: any;
|
||||
}
|
||||
|
||||
const UnitMenu: SFC<ExtendedMenuProps> = props => {
|
||||
return (
|
||||
<components.Menu {...props}>
|
||||
<div>{props.children}</div>
|
||||
</components.Menu>
|
||||
);
|
||||
};
|
||||
|
||||
export default UnitMenu;
|
22
public/app/core/components/Picker/Unit/UnitOption.tsx
Normal file
22
public/app/core/components/Picker/Unit/UnitOption.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
import React, { SFC } from 'react';
|
||||
import { components } from 'react-select';
|
||||
import { OptionProps } from 'react-select/lib/components/Option';
|
||||
|
||||
interface ExtendedOptionProps extends OptionProps<any> {
|
||||
data: any;
|
||||
}
|
||||
|
||||
const UnitOption: SFC<ExtendedOptionProps> = props => {
|
||||
const { children, isSelected, className } = props;
|
||||
|
||||
return (
|
||||
<components.Option {...props}>
|
||||
<div className={`unit-picker-option__button btn btn-link ${className}`}>
|
||||
{isSelected && <i className="fa fa-check pull-right" aria-hidden="true" />}
|
||||
<div className="gf-form">{children}</div>
|
||||
</div>
|
||||
</components.Option>
|
||||
);
|
||||
};
|
||||
|
||||
export default UnitOption;
|
33
public/app/core/components/Picker/Unit/UnitPicker.tsx
Normal file
33
public/app/core/components/Picker/Unit/UnitPicker.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import Select from 'react-select';
|
||||
import { UnitGroup } from './UnitGroup';
|
||||
import UnitOption from './UnitOption';
|
||||
import UnitMenu from './UnitMenu';
|
||||
import ResetStyles from '../ResetStyles';
|
||||
import kbn from '../../../utils/kbn';
|
||||
|
||||
interface Props {
|
||||
onSelected: (item: any) => {} | void;
|
||||
}
|
||||
|
||||
export default class UnitPicker extends PureComponent<Props> {
|
||||
render() {
|
||||
const options = kbn.getUnitFormats();
|
||||
|
||||
return (
|
||||
<Select
|
||||
classNamePrefix="gf-form-select-box"
|
||||
className="width-20 gf-form-input"
|
||||
isSearchable={true}
|
||||
options={options}
|
||||
placeholder="Choose"
|
||||
components={{
|
||||
Group: UnitGroup,
|
||||
Option: UnitOption,
|
||||
Menu: UnitMenu,
|
||||
}}
|
||||
styles={ResetStyles}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import Select, { components } from 'react-select';
|
||||
import ResetStyles from 'app/core/components/Picker/ResetStyles';
|
||||
import kbn from '../../utils/kbn';
|
||||
|
||||
interface Props {
|
||||
onSelected: (item: any) => {} | void;
|
||||
}
|
||||
|
||||
export class UnitPicker extends PureComponent<Props> {
|
||||
formatGroupLabel = data => {
|
||||
const groupStyles = {
|
||||
margin: '0 15px',
|
||||
fontSize: '16px',
|
||||
fontWeight: 700,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
} as React.CSSProperties;
|
||||
|
||||
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.options.length}</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
renderOption = props => {
|
||||
return (
|
||||
<components.Option {...props}>
|
||||
<div className="description-picker-option__button btn btn-link">
|
||||
<div className="gf-form">{props.children}</div>
|
||||
</div>
|
||||
</components.Option>
|
||||
);
|
||||
};
|
||||
|
||||
renderGroup = props => {
|
||||
return <components.Group {...props} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
const options = kbn.getUnitFormats();
|
||||
|
||||
return (
|
||||
<Select
|
||||
classNamePrefix="gf-form-select-box"
|
||||
className="width-20 gf-form-input"
|
||||
isSearchable={false}
|
||||
options={options}
|
||||
placeholder="Choose"
|
||||
components={{
|
||||
Option: this.renderOption,
|
||||
Group: this.renderGroup,
|
||||
}}
|
||||
styles={ResetStyles}
|
||||
formatGroupLabel={this.formatGroupLabel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
@ -405,7 +405,8 @@ kbn.valueFormats.percentunit = (size, decimals) => {
|
||||
};
|
||||
|
||||
/* Formats the value to hex. Uses float if specified decimals are not 0.
|
||||
* There are two options, one with 0x, and one without */
|
||||
* There are two submenu
|
||||
* , one with 0x, and one without */
|
||||
|
||||
kbn.valueFormats.hex = (value, decimals) => {
|
||||
if (value == null) {
|
||||
@ -905,284 +906,284 @@ kbn.valueFormats.dateTimeFromNow = (epoch, isUtc) => {
|
||||
kbn.getUnitFormats = () => {
|
||||
return [
|
||||
{
|
||||
label: 'none',
|
||||
options: [
|
||||
{ label: 'none', value: 'none' },
|
||||
{ label: 'short', value: 'short' },
|
||||
{ label: 'percent (0-100)', value: 'percent' },
|
||||
{ label: 'percent (0.0-1.0)', value: 'percentunit' },
|
||||
{ label: 'Humidity (%H)', value: 'humidity' },
|
||||
{ label: 'decibel', value: 'dB' },
|
||||
{ label: 'hexadecimal (0x)', value: 'hex0x' },
|
||||
{ label: 'hexadecimal', value: 'hex' },
|
||||
{ label: 'scientific notation', value: 'sci' },
|
||||
{ label: 'locale format', value: 'locale' },
|
||||
text: 'none',
|
||||
submenu: [
|
||||
{ text: 'none', value: 'none' },
|
||||
{ text: 'short', value: 'short' },
|
||||
{ text: 'percent (0-100)', value: 'percent' },
|
||||
{ text: 'percent (0.0-1.0)', value: 'percentunit' },
|
||||
{ text: 'Humidity (%H)', value: 'humidity' },
|
||||
{ text: 'decibel', value: 'dB' },
|
||||
{ text: 'hexadecimal (0x)', value: 'hex0x' },
|
||||
{ text: 'hexadecimal', value: 'hex' },
|
||||
{ text: 'scientific notation', value: 'sci' },
|
||||
{ text: 'locale format', value: 'locale' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'currency',
|
||||
options: [
|
||||
{ label: 'Dollars ($)', value: 'currencyUSD' },
|
||||
{ label: 'Pounds (£)', value: 'currencyGBP' },
|
||||
{ label: 'Euro (€)', value: 'currencyEUR' },
|
||||
{ label: 'Yen (¥)', value: 'currencyJPY' },
|
||||
{ label: 'Rubles (₽)', value: 'currencyRUB' },
|
||||
{ label: 'Hryvnias (₴)', value: 'currencyUAH' },
|
||||
{ label: 'Real (R$)', value: 'currencyBRL' },
|
||||
{ label: 'Danish Krone (kr)', value: 'currencyDKK' },
|
||||
{ label: 'Icelandic Króna (kr)', value: 'currencyISK' },
|
||||
{ label: 'Norwegian Krone (kr)', value: 'currencyNOK' },
|
||||
{ label: 'Swedish Krona (kr)', value: 'currencySEK' },
|
||||
{ label: 'Czech koruna (czk)', value: 'currencyCZK' },
|
||||
{ label: 'Swiss franc (CHF)', value: 'currencyCHF' },
|
||||
{ label: 'Polish Złoty (PLN)', value: 'currencyPLN' },
|
||||
{ label: 'Bitcoin (฿)', value: 'currencyBTC' },
|
||||
text: 'currency',
|
||||
submenu: [
|
||||
{ text: 'Dollars ($)', value: 'currencyUSD' },
|
||||
{ text: 'Pounds (£)', value: 'currencyGBP' },
|
||||
{ text: 'Euro (€)', value: 'currencyEUR' },
|
||||
{ text: 'Yen (¥)', value: 'currencyJPY' },
|
||||
{ text: 'Rubles (₽)', value: 'currencyRUB' },
|
||||
{ text: 'Hryvnias (₴)', value: 'currencyUAH' },
|
||||
{ text: 'Real (R$)', value: 'currencyBRL' },
|
||||
{ text: 'Danish Krone (kr)', value: 'currencyDKK' },
|
||||
{ text: 'Icelandic Króna (kr)', value: 'currencyISK' },
|
||||
{ text: 'Norwegian Krone (kr)', value: 'currencyNOK' },
|
||||
{ text: 'Swedish Krona (kr)', value: 'currencySEK' },
|
||||
{ text: 'Czech koruna (czk)', value: 'currencyCZK' },
|
||||
{ text: 'Swiss franc (CHF)', value: 'currencyCHF' },
|
||||
{ text: 'Polish Złoty (PLN)', value: 'currencyPLN' },
|
||||
{ text: 'Bitcoin (฿)', value: 'currencyBTC' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'time',
|
||||
options: [
|
||||
{ label: 'Hertz (1/s)', value: 'hertz' },
|
||||
{ label: 'nanoseconds (ns)', value: 'ns' },
|
||||
{ label: 'microseconds (µs)', value: 'µs' },
|
||||
{ label: 'milliseconds (ms)', value: 'ms' },
|
||||
{ label: 'seconds (s)', value: 's' },
|
||||
{ label: 'minutes (m)', value: 'm' },
|
||||
{ label: 'hours (h)', value: 'h' },
|
||||
{ label: 'days (d)', value: 'd' },
|
||||
{ label: 'duration (ms)', value: 'dtdurationms' },
|
||||
{ label: 'duration (s)', value: 'dtdurations' },
|
||||
{ label: 'duration (hh:mm:ss)', value: 'dthms' },
|
||||
{ label: 'Timeticks (s/100)', value: 'timeticks' },
|
||||
{ label: 'clock (ms)', value: 'clockms' },
|
||||
{ label: 'clock (s)', value: 'clocks' },
|
||||
text: 'time',
|
||||
submenu: [
|
||||
{ text: 'Hertz (1/s)', value: 'hertz' },
|
||||
{ text: 'nanoseconds (ns)', value: 'ns' },
|
||||
{ text: 'microseconds (µs)', value: 'µs' },
|
||||
{ text: 'milliseconds (ms)', value: 'ms' },
|
||||
{ text: 'seconds (s)', value: 's' },
|
||||
{ text: 'minutes (m)', value: 'm' },
|
||||
{ text: 'hours (h)', value: 'h' },
|
||||
{ text: 'days (d)', value: 'd' },
|
||||
{ text: 'duration (ms)', value: 'dtdurationms' },
|
||||
{ text: 'duration (s)', value: 'dtdurations' },
|
||||
{ text: 'duration (hh:mm:ss)', value: 'dthms' },
|
||||
{ text: 'Timeticks (s/100)', value: 'timeticks' },
|
||||
{ text: 'clock (ms)', value: 'clockms' },
|
||||
{ text: 'clock (s)', value: 'clocks' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'date & time',
|
||||
options: [
|
||||
{ label: 'YYYY-MM-DD HH:mm:ss', value: 'dateTimeAsIso' },
|
||||
{ label: 'DD/MM/YYYY h:mm:ss a', value: 'dateTimeAsUS' },
|
||||
{ label: 'From Now', value: 'dateTimeFromNow' },
|
||||
text: 'date & time',
|
||||
submenu: [
|
||||
{ text: 'YYYY-MM-DD HH:mm:ss', value: 'dateTimeAsIso' },
|
||||
{ text: 'DD/MM/YYYY h:mm:ss a', value: 'dateTimeAsUS' },
|
||||
{ text: 'From Now', value: 'dateTimeFromNow' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'data (IEC)',
|
||||
options: [
|
||||
{ label: 'bits', value: 'bits' },
|
||||
{ label: 'bytes', value: 'bytes' },
|
||||
{ label: 'kibibytes', value: 'kbytes' },
|
||||
{ label: 'mebibytes', value: 'mbytes' },
|
||||
{ label: 'gibibytes', value: 'gbytes' },
|
||||
text: 'data (IEC)',
|
||||
submenu: [
|
||||
{ text: 'bits', value: 'bits' },
|
||||
{ text: 'bytes', value: 'bytes' },
|
||||
{ text: 'kibibytes', value: 'kbytes' },
|
||||
{ text: 'mebibytes', value: 'mbytes' },
|
||||
{ text: 'gibibytes', value: 'gbytes' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'data (Metric)',
|
||||
options: [
|
||||
{ label: 'bits', value: 'decbits' },
|
||||
{ label: 'bytes', value: 'decbytes' },
|
||||
{ label: 'kilobytes', value: 'deckbytes' },
|
||||
{ label: 'megabytes', value: 'decmbytes' },
|
||||
{ label: 'gigabytes', value: 'decgbytes' },
|
||||
text: 'data (Metric)',
|
||||
submenu: [
|
||||
{ text: 'bits', value: 'decbits' },
|
||||
{ text: 'bytes', value: 'decbytes' },
|
||||
{ text: 'kilobytes', value: 'deckbytes' },
|
||||
{ text: 'megabytes', value: 'decmbytes' },
|
||||
{ text: 'gigabytes', value: 'decgbytes' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'data rate',
|
||||
options: [
|
||||
{ label: 'packets/sec', value: 'pps' },
|
||||
{ label: 'bits/sec', value: 'bps' },
|
||||
{ label: 'bytes/sec', value: 'Bps' },
|
||||
{ label: 'kilobits/sec', value: 'Kbits' },
|
||||
{ label: 'kilobytes/sec', value: 'KBs' },
|
||||
{ label: 'megabits/sec', value: 'Mbits' },
|
||||
{ label: 'megabytes/sec', value: 'MBs' },
|
||||
{ label: 'gigabytes/sec', value: 'GBs' },
|
||||
{ label: 'gigabits/sec', value: 'Gbits' },
|
||||
text: 'data rate',
|
||||
submenu: [
|
||||
{ text: 'packets/sec', value: 'pps' },
|
||||
{ text: 'bits/sec', value: 'bps' },
|
||||
{ text: 'bytes/sec', value: 'Bps' },
|
||||
{ text: 'kilobits/sec', value: 'Kbits' },
|
||||
{ text: 'kilobytes/sec', value: 'KBs' },
|
||||
{ text: 'megabits/sec', value: 'Mbits' },
|
||||
{ text: 'megabytes/sec', value: 'MBs' },
|
||||
{ text: 'gigabytes/sec', value: 'GBs' },
|
||||
{ text: 'gigabits/sec', value: 'Gbits' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'hash rate',
|
||||
options: [
|
||||
{ label: 'hashes/sec', value: 'Hs' },
|
||||
{ label: 'kilohashes/sec', value: 'KHs' },
|
||||
{ label: 'megahashes/sec', value: 'MHs' },
|
||||
{ label: 'gigahashes/sec', value: 'GHs' },
|
||||
{ label: 'terahashes/sec', value: 'THs' },
|
||||
{ label: 'petahashes/sec', value: 'PHs' },
|
||||
{ label: 'exahashes/sec', value: 'EHs' },
|
||||
text: 'hash rate',
|
||||
submenu: [
|
||||
{ text: 'hashes/sec', value: 'Hs' },
|
||||
{ text: 'kilohashes/sec', value: 'KHs' },
|
||||
{ text: 'megahashes/sec', value: 'MHs' },
|
||||
{ text: 'gigahashes/sec', value: 'GHs' },
|
||||
{ text: 'terahashes/sec', value: 'THs' },
|
||||
{ text: 'petahashes/sec', value: 'PHs' },
|
||||
{ text: 'exahashes/sec', value: 'EHs' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'throughput',
|
||||
options: [
|
||||
{ label: 'ops/sec (ops)', value: 'ops' },
|
||||
{ label: 'requests/sec (rps)', value: 'reqps' },
|
||||
{ label: 'reads/sec (rps)', value: 'rps' },
|
||||
{ label: 'writes/sec (wps)', value: 'wps' },
|
||||
{ label: 'I/O ops/sec (iops)', value: 'iops' },
|
||||
{ label: 'ops/min (opm)', value: 'opm' },
|
||||
{ label: 'reads/min (rpm)', value: 'rpm' },
|
||||
{ label: 'writes/min (wpm)', value: 'wpm' },
|
||||
text: 'throughput',
|
||||
submenu: [
|
||||
{ text: 'ops/sec (ops)', value: 'ops' },
|
||||
{ text: 'requests/sec (rps)', value: 'reqps' },
|
||||
{ text: 'reads/sec (rps)', value: 'rps' },
|
||||
{ text: 'writes/sec (wps)', value: 'wps' },
|
||||
{ text: 'I/O ops/sec (iops)', value: 'iops' },
|
||||
{ text: 'ops/min (opm)', value: 'opm' },
|
||||
{ text: 'reads/min (rpm)', value: 'rpm' },
|
||||
{ text: 'writes/min (wpm)', value: 'wpm' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'length',
|
||||
options: [
|
||||
{ label: 'millimetre (mm)', value: 'lengthmm' },
|
||||
{ label: 'meter (m)', value: 'lengthm' },
|
||||
{ label: 'feet (ft)', value: 'lengthft' },
|
||||
{ label: 'kilometer (km)', value: 'lengthkm' },
|
||||
{ label: 'mile (mi)', value: 'lengthmi' },
|
||||
text: 'length',
|
||||
submenu: [
|
||||
{ text: 'millimetre (mm)', value: 'lengthmm' },
|
||||
{ text: 'meter (m)', value: 'lengthm' },
|
||||
{ text: 'feet (ft)', value: 'lengthft' },
|
||||
{ text: 'kilometer (km)', value: 'lengthkm' },
|
||||
{ text: 'mile (mi)', value: 'lengthmi' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'area',
|
||||
options: [
|
||||
{ label: 'Square Meters (m²)', value: 'areaM2' },
|
||||
{ label: 'Square Feet (ft²)', value: 'areaF2' },
|
||||
{ label: 'Square Miles (mi²)', value: 'areaMI2' },
|
||||
text: 'area',
|
||||
submenu: [
|
||||
{ text: 'Square Meters (m²)', value: 'areaM2' },
|
||||
{ text: 'Square Feet (ft²)', value: 'areaF2' },
|
||||
{ text: 'Square Miles (mi²)', value: 'areaMI2' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'mass',
|
||||
options: [
|
||||
{ label: 'milligram (mg)', value: 'massmg' },
|
||||
{ label: 'gram (g)', value: 'massg' },
|
||||
{ label: 'kilogram (kg)', value: 'masskg' },
|
||||
{ label: 'metric ton (t)', value: 'masst' },
|
||||
text: 'mass',
|
||||
submenu: [
|
||||
{ text: 'milligram (mg)', value: 'massmg' },
|
||||
{ text: 'gram (g)', value: 'massg' },
|
||||
{ text: 'kilogram (kg)', value: 'masskg' },
|
||||
{ text: 'metric ton (t)', value: 'masst' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'velocity',
|
||||
options: [
|
||||
{ label: 'metres/second (m/s)', value: 'velocityms' },
|
||||
{ label: 'kilometers/hour (km/h)', value: 'velocitykmh' },
|
||||
{ label: 'miles/hour (mph)', value: 'velocitymph' },
|
||||
{ label: 'knot (kn)', value: 'velocityknot' },
|
||||
text: 'velocity',
|
||||
submenu: [
|
||||
{ text: 'metres/second (m/s)', value: 'velocityms' },
|
||||
{ text: 'kilometers/hour (km/h)', value: 'velocitykmh' },
|
||||
{ text: 'miles/hour (mph)', value: 'velocitymph' },
|
||||
{ text: 'knot (kn)', value: 'velocityknot' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'volume',
|
||||
options: [
|
||||
{ label: 'millilitre (mL)', value: 'mlitre' },
|
||||
{ label: 'litre (L)', value: 'litre' },
|
||||
{ label: 'cubic metre', value: 'm3' },
|
||||
{ label: 'Normal cubic metre', value: 'Nm3' },
|
||||
{ label: 'cubic decimetre', value: 'dm3' },
|
||||
{ label: 'gallons', value: 'gallons' },
|
||||
text: 'volume',
|
||||
submenu: [
|
||||
{ text: 'millilitre (mL)', value: 'mlitre' },
|
||||
{ text: 'litre (L)', value: 'litre' },
|
||||
{ text: 'cubic metre', value: 'm3' },
|
||||
{ text: 'Normal cubic metre', value: 'Nm3' },
|
||||
{ text: 'cubic decimetre', value: 'dm3' },
|
||||
{ text: 'gallons', value: 'gallons' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'energy',
|
||||
options: [
|
||||
{ label: 'Watt (W)', value: 'watt' },
|
||||
{ label: 'Kilowatt (kW)', value: 'kwatt' },
|
||||
{ label: 'Milliwatt (mW)', value: 'mwatt' },
|
||||
{ label: 'Watt per square metre (W/m²)', value: 'Wm2' },
|
||||
{ label: 'Volt-ampere (VA)', value: 'voltamp' },
|
||||
{ label: 'Kilovolt-ampere (kVA)', value: 'kvoltamp' },
|
||||
{ label: 'Volt-ampere reactive (var)', value: 'voltampreact' },
|
||||
{ label: 'Kilovolt-ampere reactive (kvar)', value: 'kvoltampreact' },
|
||||
{ label: 'Watt-hour (Wh)', value: 'watth' },
|
||||
{ label: 'Kilowatt-hour (kWh)', value: 'kwatth' },
|
||||
{ label: 'Kilowatt-min (kWm)', value: 'kwattm' },
|
||||
{ label: 'Joule (J)', value: 'joule' },
|
||||
{ label: 'Electron volt (eV)', value: 'ev' },
|
||||
{ label: 'Ampere (A)', value: 'amp' },
|
||||
{ label: 'Kiloampere (kA)', value: 'kamp' },
|
||||
{ label: 'Milliampere (mA)', value: 'mamp' },
|
||||
{ label: 'Volt (V)', value: 'volt' },
|
||||
{ label: 'Kilovolt (kV)', value: 'kvolt' },
|
||||
{ label: 'Millivolt (mV)', value: 'mvolt' },
|
||||
{ label: 'Decibel-milliwatt (dBm)', value: 'dBm' },
|
||||
{ label: 'Ohm (Ω)', value: 'ohm' },
|
||||
{ label: 'Lumens (Lm)', value: 'lumens' },
|
||||
text: 'energy',
|
||||
submenu: [
|
||||
{ text: 'Watt (W)', value: 'watt' },
|
||||
{ text: 'Kilowatt (kW)', value: 'kwatt' },
|
||||
{ text: 'Milliwatt (mW)', value: 'mwatt' },
|
||||
{ text: 'Watt per square metre (W/m²)', value: 'Wm2' },
|
||||
{ text: 'Volt-ampere (VA)', value: 'voltamp' },
|
||||
{ text: 'Kilovolt-ampere (kVA)', value: 'kvoltamp' },
|
||||
{ text: 'Volt-ampere reactive (var)', value: 'voltampreact' },
|
||||
{ text: 'Kilovolt-ampere reactive (kvar)', value: 'kvoltampreact' },
|
||||
{ text: 'Watt-hour (Wh)', value: 'watth' },
|
||||
{ text: 'Kilowatt-hour (kWh)', value: 'kwatth' },
|
||||
{ text: 'Kilowatt-min (kWm)', value: 'kwattm' },
|
||||
{ text: 'Joule (J)', value: 'joule' },
|
||||
{ text: 'Electron volt (eV)', value: 'ev' },
|
||||
{ text: 'Ampere (A)', value: 'amp' },
|
||||
{ text: 'Kiloampere (kA)', value: 'kamp' },
|
||||
{ text: 'Milliampere (mA)', value: 'mamp' },
|
||||
{ text: 'Volt (V)', value: 'volt' },
|
||||
{ text: 'Kilovolt (kV)', value: 'kvolt' },
|
||||
{ text: 'Millivolt (mV)', value: 'mvolt' },
|
||||
{ text: 'Decibel-milliwatt (dBm)', value: 'dBm' },
|
||||
{ text: 'Ohm (Ω)', value: 'ohm' },
|
||||
{ text: 'Lumens (Lm)', value: 'lumens' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'temperature',
|
||||
options: [
|
||||
{ label: 'Celsius (°C)', value: 'celsius' },
|
||||
{ label: 'Farenheit (°F)', value: 'farenheit' },
|
||||
{ label: 'Kelvin (K)', value: 'kelvin' },
|
||||
text: 'temperature',
|
||||
submenu: [
|
||||
{ text: 'Celsius (°C)', value: 'celsius' },
|
||||
{ text: 'Farenheit (°F)', value: 'farenheit' },
|
||||
{ text: 'Kelvin (K)', value: 'kelvin' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'pressure',
|
||||
options: [
|
||||
{ label: 'Millibars', value: 'pressurembar' },
|
||||
{ label: 'Bars', value: 'pressurebar' },
|
||||
{ label: 'Kilobars', value: 'pressurekbar' },
|
||||
{ label: 'Hectopascals', value: 'pressurehpa' },
|
||||
{ label: 'Kilopascals', value: 'pressurekpa' },
|
||||
{ label: 'Inches of mercury', value: 'pressurehg' },
|
||||
{ label: 'PSI', value: 'pressurepsi' },
|
||||
text: 'pressure',
|
||||
submenu: [
|
||||
{ text: 'Millibars', value: 'pressurembar' },
|
||||
{ text: 'Bars', value: 'pressurebar' },
|
||||
{ text: 'Kilobars', value: 'pressurekbar' },
|
||||
{ text: 'Hectopascals', value: 'pressurehpa' },
|
||||
{ text: 'Kilopascals', value: 'pressurekpa' },
|
||||
{ text: 'Inches of mercury', value: 'pressurehg' },
|
||||
{ text: 'PSI', value: 'pressurepsi' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'force',
|
||||
options: [
|
||||
{ label: 'Newton-meters (Nm)', value: 'forceNm' },
|
||||
{ label: 'Kilonewton-meters (kNm)', value: 'forcekNm' },
|
||||
{ label: 'Newtons (N)', value: 'forceN' },
|
||||
{ label: 'Kilonewtons (kN)', value: 'forcekN' },
|
||||
text: 'force',
|
||||
submenu: [
|
||||
{ text: 'Newton-meters (Nm)', value: 'forceNm' },
|
||||
{ text: 'Kilonewton-meters (kNm)', value: 'forcekNm' },
|
||||
{ text: 'Newtons (N)', value: 'forceN' },
|
||||
{ text: 'Kilonewtons (kN)', value: 'forcekN' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'flow',
|
||||
options: [
|
||||
{ label: 'Gallons/min (gpm)', value: 'flowgpm' },
|
||||
{ label: 'Cubic meters/sec (cms)', value: 'flowcms' },
|
||||
{ label: 'Cubic feet/sec (cfs)', value: 'flowcfs' },
|
||||
{ label: 'Cubic feet/min (cfm)', value: 'flowcfm' },
|
||||
{ label: 'Litre/hour', value: 'litreh' },
|
||||
{ label: 'Litre/min (l/min)', value: 'flowlpm' },
|
||||
{ label: 'milliLitre/min (mL/min)', value: 'flowmlpm' },
|
||||
text: 'flow',
|
||||
submenu: [
|
||||
{ text: 'Gallons/min (gpm)', value: 'flowgpm' },
|
||||
{ text: 'Cubic meters/sec (cms)', value: 'flowcms' },
|
||||
{ text: 'Cubic feet/sec (cfs)', value: 'flowcfs' },
|
||||
{ text: 'Cubic feet/min (cfm)', value: 'flowcfm' },
|
||||
{ text: 'Litre/hour', value: 'litreh' },
|
||||
{ text: 'Litre/min (l/min)', value: 'flowlpm' },
|
||||
{ text: 'milliLitre/min (mL/min)', value: 'flowmlpm' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'angle',
|
||||
options: [
|
||||
{ label: 'Degrees (°)', value: 'degree' },
|
||||
{ label: 'Radians', value: 'radian' },
|
||||
{ label: 'Gradian', value: 'grad' },
|
||||
text: 'angle',
|
||||
submenu: [
|
||||
{ text: 'Degrees (°)', value: 'degree' },
|
||||
{ text: 'Radians', value: 'radian' },
|
||||
{ text: 'Gradian', value: 'grad' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'acceleration',
|
||||
options: [
|
||||
{ label: 'Meters/sec²', value: 'accMS2' },
|
||||
{ label: 'Feet/sec²', value: 'accFS2' },
|
||||
{ label: 'G unit', value: 'accG' },
|
||||
text: 'acceleration',
|
||||
submenu: [
|
||||
{ text: 'Meters/sec²', value: 'accMS2' },
|
||||
{ text: 'Feet/sec²', value: 'accFS2' },
|
||||
{ text: 'G unit', value: 'accG' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'radiation',
|
||||
options: [
|
||||
{ label: 'Becquerel (Bq)', value: 'radbq' },
|
||||
{ label: 'curie (Ci)', value: 'radci' },
|
||||
{ label: 'Gray (Gy)', value: 'radgy' },
|
||||
{ label: 'rad', value: 'radrad' },
|
||||
{ label: 'Sievert (Sv)', value: 'radsv' },
|
||||
{ label: 'rem', value: 'radrem' },
|
||||
{ label: 'Exposure (C/kg)', value: 'radexpckg' },
|
||||
{ label: 'roentgen (R)', value: 'radr' },
|
||||
{ label: 'Sievert/hour (Sv/h)', value: 'radsvh' },
|
||||
text: 'radiation',
|
||||
submenu: [
|
||||
{ text: 'Becquerel (Bq)', value: 'radbq' },
|
||||
{ text: 'curie (Ci)', value: 'radci' },
|
||||
{ text: 'Gray (Gy)', value: 'radgy' },
|
||||
{ text: 'rad', value: 'radrad' },
|
||||
{ text: 'Sievert (Sv)', value: 'radsv' },
|
||||
{ text: 'rem', value: 'radrem' },
|
||||
{ text: 'Exposure (C/kg)', value: 'radexpckg' },
|
||||
{ text: 'roentgen (R)', value: 'radr' },
|
||||
{ text: 'Sievert/hour (Sv/h)', value: 'radsvh' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'concentration',
|
||||
options: [
|
||||
{ label: 'parts-per-million (ppm)', value: 'ppm' },
|
||||
{ label: 'parts-per-billion (ppb)', value: 'conppb' },
|
||||
{ label: 'nanogram per cubic metre (ng/m³)', value: 'conngm3' },
|
||||
{ label: 'nanogram per normal cubic metre (ng/Nm³)', value: 'conngNm3' },
|
||||
{ label: 'microgram per cubic metre (μg/m³)', value: 'conμgm3' },
|
||||
{ label: 'microgram per normal cubic metre (μg/Nm³)', value: 'conμgNm3' },
|
||||
{ label: 'milligram per cubic metre (mg/m³)', value: 'conmgm3' },
|
||||
{ label: 'milligram per normal cubic metre (mg/Nm³)', value: 'conmgNm3' },
|
||||
{ label: 'gram per cubic metre (g/m³)', value: 'congm3' },
|
||||
{ label: 'gram per normal cubic metre (g/Nm³)', value: 'congNm3' },
|
||||
text: 'concentration',
|
||||
submenu: [
|
||||
{ text: 'parts-per-million (ppm)', value: 'ppm' },
|
||||
{ text: 'parts-per-billion (ppb)', value: 'conppb' },
|
||||
{ text: 'nanogram per cubic metre (ng/m³)', value: 'conngm3' },
|
||||
{ text: 'nanogram per normal cubic metre (ng/Nm³)', value: 'conngNm3' },
|
||||
{ text: 'microgram per cubic metre (μg/m³)', value: 'conμgm3' },
|
||||
{ text: 'microgram per normal cubic metre (μg/Nm³)', value: 'conμgNm3' },
|
||||
{ text: 'milligram per cubic metre (mg/m³)', value: 'conmgm3' },
|
||||
{ text: 'milligram per normal cubic metre (mg/Nm³)', value: 'conmgNm3' },
|
||||
{ text: 'gram per cubic metre (g/m³)', value: 'congm3' },
|
||||
{ text: 'gram per normal cubic metre (g/Nm³)', value: 'congNm3' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
14
public/app/features/test/TestPage.tsx
Normal file
14
public/app/features/test/TestPage.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import UnitPicker from 'app/core/components/Picker/Unit/UnitPicker';
|
||||
|
||||
export default class TestPage extends PureComponent {
|
||||
render() {
|
||||
return (
|
||||
<div className="page-body page-container">
|
||||
<div style={{ margin: '160px auto 0', width: '500px' }}>
|
||||
<UnitPicker onSelected={() => {}} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
|
||||
import Gauge from 'app/viz/Gauge';
|
||||
import { NullValueMode, PanelOptionsProps, PanelProps } from 'app/types';
|
||||
import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
|
||||
import { UnitPicker } from '../../../core/components/Picker/UnitPicker';
|
||||
import UnitPicker from '../../../core/components/Picker/Unit/UnitPicker';
|
||||
|
||||
export interface Options {}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import NewDataSourcePage from '../features/datasources/NewDataSourcePage';
|
||||
import UsersListPage from 'app/features/users/UsersListPage';
|
||||
import DataSourceDashboards from 'app/features/datasources/DataSourceDashboards';
|
||||
import OrgDetailsPage from '../features/org/OrgDetailsPage';
|
||||
import TestPage from '../features/test/TestPage';
|
||||
|
||||
/** @ngInject */
|
||||
export function setupAngularRoutes($routeProvider, $locationProvider) {
|
||||
@ -308,6 +309,12 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
|
||||
controller: 'AlertNotificationEditCtrl',
|
||||
controllerAs: 'ctrl',
|
||||
})
|
||||
.when('/test', {
|
||||
template: '<react-container />',
|
||||
resolve: {
|
||||
component: () => TestPage,
|
||||
},
|
||||
})
|
||||
.otherwise({
|
||||
templateUrl: 'public/app/partials/error.html',
|
||||
controller: 'ErrorCtrl',
|
||||
|
@ -101,6 +101,7 @@
|
||||
@import 'components/delete_button';
|
||||
@import 'components/add_data_source.scss';
|
||||
@import 'components/page_loader';
|
||||
@import 'components/unit-picker';
|
||||
|
||||
// PAGES
|
||||
@import 'pages/login';
|
||||
|
24
public/sass/components/_unit-picker.scss
Normal file
24
public/sass/components/_unit-picker.scss
Normal file
@ -0,0 +1,24 @@
|
||||
.unit-picker-option {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
display: block;
|
||||
border-radius: 0;
|
||||
white-space: normal;
|
||||
|
||||
i.fa-check {
|
||||
padding-left: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.unit-picker-group {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.unit-picker-group-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
border-bottom: 1px solid #555;
|
||||
}
|
Loading…
Reference in New Issue
Block a user