mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
- Logging gets a graph for log distribution (currently per stream, but I think I'll change that to per log-level) - added grid columns for timestamp and unique labels - show common labels of streams - View options to show/hide time columns, label columns - created `--small` modifier for Switch CSS classes - merging of streams is now a datasource responsibility
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import _ from 'lodash';
|
|
|
|
export interface Props {
|
|
label: string;
|
|
checked: boolean;
|
|
labelClass?: string;
|
|
small?: boolean;
|
|
switchClass?: string;
|
|
onChange: (event) => any;
|
|
}
|
|
|
|
export interface State {
|
|
id: any;
|
|
}
|
|
|
|
export class Switch extends PureComponent<Props, State> {
|
|
state = {
|
|
id: _.uniqueId(),
|
|
};
|
|
|
|
internalOnChange = event => {
|
|
event.stopPropagation();
|
|
this.props.onChange(event);
|
|
};
|
|
|
|
render() {
|
|
const { labelClass = '', switchClass = '', label, checked, small } = this.props;
|
|
const labelId = `check-${this.state.id}`;
|
|
let labelClassName = `gf-form-label ${labelClass} pointer`;
|
|
let switchClassName = `gf-form-switch ${switchClass}`;
|
|
if (small) {
|
|
labelClassName += ' gf-form-label--small';
|
|
switchClassName += ' gf-form-switch--small';
|
|
}
|
|
|
|
return (
|
|
<div className="gf-form">
|
|
{label && (
|
|
<label htmlFor={labelId} className={labelClassName}>
|
|
{label}
|
|
</label>
|
|
)}
|
|
<div className={switchClassName}>
|
|
<input id={labelId} type="checkbox" checked={checked} onChange={this.internalOnChange} />
|
|
<label htmlFor={labelId} />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|