Commit 26f15233 by Torkel Ödegaard Committed by GitHub

Graph: Improves graph edit options in side pane (#24352)

* Graph: Improves graph edit options in side pane

* Fixed spell issue and order

* Fixed ts issue
parent 58000099
...@@ -7,5 +7,5 @@ export const UnitValueEditor: React.FC<FieldConfigEditorProps<string, UnitFieldC ...@@ -7,5 +7,5 @@ export const UnitValueEditor: React.FC<FieldConfigEditorProps<string, UnitFieldC
value, value,
onChange, onChange,
}) => { }) => {
return <UnitPicker value={value} onChange={onChange} useNewForms />; return <UnitPicker value={value} onChange={onChange} />;
}; };
...@@ -13,5 +13,4 @@ export default { ...@@ -13,5 +13,4 @@ export default {
}, },
}; };
export const simple = () => <UnitPicker useNewForms onChange={val => console.log(val)} />; export const simple = () => <UnitPicker onChange={val => console.log(val)} />;
export const old = () => <UnitPicker onChange={val => console.log(val)} />;
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { Select } from '../Forms/Legacy/Select/Select';
import { Cascader, CascaderOption } from '../Cascader/Cascader'; import { Cascader, CascaderOption } from '../Cascader/Cascader';
import { getValueFormats, SelectableValue } from '@grafana/data'; import { getValueFormats, SelectableValue } from '@grafana/data';
...@@ -8,8 +6,6 @@ interface Props { ...@@ -8,8 +6,6 @@ interface Props {
onChange: (item?: string) => void; onChange: (item?: string) => void;
value?: string; value?: string;
width?: number; width?: number;
/** Temporary flag that uses the new form styles. */
useNewForms?: boolean;
} }
function formatCreateLabel(input: string) { function formatCreateLabel(input: string) {
...@@ -17,16 +13,12 @@ function formatCreateLabel(input: string) { ...@@ -17,16 +13,12 @@ function formatCreateLabel(input: string) {
} }
export class UnitPicker extends PureComponent<Props> { export class UnitPicker extends PureComponent<Props> {
static defaultProps = {
width: 12,
};
onChange = (value: SelectableValue<string>) => { onChange = (value: SelectableValue<string>) => {
this.props.onChange(value.value); this.props.onChange(value.value);
}; };
render() { render() {
const { value, width, useNewForms } = this.props; const { value, width } = this.props;
// Set the current selection // Set the current selection
let current: SelectableValue<string> | undefined = undefined; let current: SelectableValue<string> | undefined = undefined;
...@@ -46,17 +38,12 @@ export class UnitPicker extends PureComponent<Props> { ...@@ -46,17 +38,12 @@ export class UnitPicker extends PureComponent<Props> {
} }
return sel; return sel;
}); });
if (useNewForms) {
return { return {
label: group.text, label: group.text,
value: group.text, value: group.text,
items: options, items: options,
}; };
}
return {
label: group.text,
options,
};
}); });
// Show the custom unit // Show the custom unit
...@@ -64,8 +51,9 @@ export class UnitPicker extends PureComponent<Props> { ...@@ -64,8 +51,9 @@ export class UnitPicker extends PureComponent<Props> {
current = { value, label: value }; current = { value, label: value };
} }
return useNewForms ? ( return (
<Cascader <Cascader
width={width}
initialValue={current && current.label} initialValue={current && current.label}
allowCustomValue allowCustomValue
formatCreateLabel={formatCreateLabel} formatCreateLabel={formatCreateLabel}
...@@ -73,17 +61,6 @@ export class UnitPicker extends PureComponent<Props> { ...@@ -73,17 +61,6 @@ export class UnitPicker extends PureComponent<Props> {
placeholder="Choose" placeholder="Choose"
onSelect={this.props.onChange} onSelect={this.props.onChange}
/> />
) : (
<Select
width={width}
defaultValue={current}
isSearchable={true}
allowCustomValue={true}
formatCreateLabel={formatCreateLabel}
options={groupOptions}
placeholder="Choose"
onChange={this.onChange}
/>
); );
} }
} }
...@@ -159,7 +159,7 @@ $scrollbarBorder: black; ...@@ -159,7 +159,7 @@ $scrollbarBorder: black;
// Tables // Tables
// ------------------------- // -------------------------
$table-bg-accent: $dark-6; // for striping $table-bg-accent: ${styleMixins.hoverColor(theme.colors.bg1, theme)}; // for striping
$table-border: $dark-6; // table and cell border $table-border: $dark-6; // table and cell border
$table-bg-odd: $dark-3; $table-bg-odd: $dark-3;
......
...@@ -152,7 +152,7 @@ $scrollbarBorder: $gray-7; ...@@ -152,7 +152,7 @@ $scrollbarBorder: $gray-7;
// Tables // Tables
// ------------------------- // -------------------------
$table-bg-accent: $gray-5; // for striping $table-bg-accent: ${styleMixins.hoverColor(theme.colors.bg1, theme)};
$table-border: $gray-3; // table and cell border $table-border: $gray-3; // table and cell border
$table-bg-odd: $gray-6; $table-bg-odd: $gray-6;
......
<div class="editor-row"> <div class="editor-row">
<div class="section gf-form-group" ng-repeat="yaxis in ctrl.panel.yaxes"> <div class="gf-form-group" ng-repeat="yaxis in ctrl.panel.yaxes">
<h5 class="section-heading" ng-show="$index === 0">Left Y</h5> <h5 class="section-heading" ng-show="$index === 0">Left Y</h5>
<h5 class="section-heading" ng-show="$index === 1">Right Y</h5> <h5 class="section-heading" ng-show="$index === 1">Right Y</h5>
<gf-form-switch class="gf-form" label="Show" label-class="width-6" checked="yaxis.show" on-change="ctrl.render()"></gf-form-switch> <gf-form-switch
class="gf-form"
label="Show"
label-class="width-6"
checked="yaxis.show"
on-change="ctrl.render()"
></gf-form-switch>
<div ng-if="yaxis.show"> <div ng-if="yaxis.show">
<div class="gf-form"> <div class="gf-form gf-form--grow">
<label class="gf-form-label width-6">Unit</label> <label class="gf-form-label width-6">Unit</label>
<unit-picker onChange="ctrl.setUnitFormat(yaxis)" value="yaxis.format" width="20" /> <unit-picker onChange="ctrl.setUnitFormat(yaxis)" value="yaxis.format" class="flex-grow-1" />
</div> </div>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">Scale</label> <label class="gf-form-label width-6">Scale</label>
<div class="gf-form-select-wrapper max-width-20"> <div class="gf-form-select-wrapper max-width-20">
<select class="gf-form-input" ng-model="yaxis.logBase" ng-options="v as k for (k, v) in ctrl.logScales" ng-change="ctrl.render()"></select> <select
class="gf-form-input"
ng-model="yaxis.logBase"
ng-options="v as k for (k, v) in ctrl.logScales"
ng-change="ctrl.render()"
></select>
</div> </div>
</div> </div>
<div class="gf-form-inline">
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">Y-Min</label> <label class="gf-form-label width-6">Y-Min</label>
<input type="text" class="gf-form-input width-5" placeholder="auto" empty-to-null ng-model="yaxis.min" ng-change="ctrl.render()" ng-model-onblur> <input
type="text"
class="gf-form-input"
placeholder="auto"
empty-to-null
ng-model="yaxis.min"
ng-change="ctrl.render()"
ng-model-onblur
/>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">Y-Max</label> <label class="gf-form-label width-6">Y-Max</label>
<input type="text" class="gf-form-input width-5" placeholder="auto" empty-to-null ng-model="yaxis.max" ng-change="ctrl.render()" ng-model-onblur> <input
</div> type="text"
class="gf-form-input"
placeholder="auto"
empty-to-null
ng-model="yaxis.max"
ng-change="ctrl.render()"
ng-model-onblur
/>
</div> </div>
<div ng-if="yaxis.show"> <div ng-if="yaxis.show">
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">Decimals</label> <label class="gf-form-label width-6">Decimals</label>
<input type="number" class="gf-form-input max-width-20" placeholder="auto" empty-to-null bs-tooltip="'Override automatic decimal precision for y-axis'" data-placement="right" ng-model="yaxis.decimals" ng-change="ctrl.render()" ng-model-onblur> <input
type="number"
class="gf-form-input width-5"
placeholder="auto"
empty-to-null
bs-tooltip="'Override automatic decimal precision for y-axis'"
data-placement="right"
ng-model="yaxis.decimals"
ng-change="ctrl.render()"
ng-model-onblur
/>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">Label</label> <label class="gf-form-label width-6">Label</label>
<input type="text" class="gf-form-input max-width-20" ng-model="yaxis.label" ng-change="ctrl.render()" ng-model-onblur> <input
type="text"
class="gf-form-input max-width-20"
ng-model="yaxis.label"
ng-change="ctrl.render()"
ng-model-onblur
/>
</div> </div>
</div> </div>
</div> </div>
<div class="section gf-form-group" aria-label={{ctrl.selectors.xAxisSection}}> <div class="gf-form-group">
<h5 class="section-heading">Y-Axes</h5>
<gf-form-switch
class="gf-form"
label="Align Y-Axes"
label-class="width-6"
switch-class="width-5"
checked="ctrl.panel.yaxis.align"
on-change="ctrl.render()"
></gf-form-switch>
<div class="gf-form" ng-show="ctrl.panel.yaxis.align">
<label class="gf-form-label width-6">
Level
</label>
<input
type="number"
class="gf-form-input width-6"
placeholder="0"
ng-model="ctrl.panel.yaxis.alignLevel"
ng-change="ctrl.render()"
ng-model-onblur
bs-tooltip="'Alignment of Y-axes are based on this value, starting from Y=0'"
data-placement="right"
/>
</div>
</div>
<div class="gf-form-group" aria-label="{{ctrl.selectors.xAxisSection}}">
<h5 class="section-heading">X-Axis</h5> <h5 class="section-heading">X-Axis</h5>
<gf-form-switch class="gf-form" label="Show" label-class="width-6" checked="ctrl.panel.xaxis.show" on-change="ctrl.render()"></gf-form-switch> <gf-form-switch
class="gf-form"
label="Show"
label-class="width-6"
checked="ctrl.panel.xaxis.show"
on-change="ctrl.render()"
></gf-form-switch>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">Mode</label> <label class="gf-form-label width-6">Mode</label>
<div class="gf-form-select-wrapper max-width-15"> <div class="gf-form-select-wrapper max-width-15">
<select class="gf-form-input" ng-model="ctrl.panel.xaxis.mode" ng-options="v as k for (k, v) in ctrl.xAxisModes" ng-change="ctrl.xAxisModeChanged()"> </select> <select
class="gf-form-input"
ng-model="ctrl.panel.xaxis.mode"
ng-options="v as k for (k, v) in ctrl.xAxisModes"
ng-change="ctrl.xAxisModeChanged()"
>
</select>
</div> </div>
</div> </div>
<!-- Series mode --> <!-- Series mode -->
<div class="gf-form" ng-if="ctrl.panel.xaxis.mode === 'series'"> <div class="gf-form" ng-if="ctrl.panel.xaxis.mode === 'series'">
<label class="gf-form-label width-6">Value</label> <label class="gf-form-label width-6">Value</label>
<metric-segment-model property="ctrl.panel.xaxis.values[0]" options="ctrl.xAxisStatOptions" on-change="ctrl.xAxisValueChanged()" custom="false" css-class="width-10" select-mode="true"></metric-segment-model> <metric-segment-model
property="ctrl.panel.xaxis.values[0]"
options="ctrl.xAxisStatOptions"
on-change="ctrl.xAxisValueChanged()"
custom="false"
css-class="width-10"
select-mode="true"
></metric-segment-model>
</div> </div>
<!-- Histogram mode --> <!-- Histogram mode -->
<div class="gf-form" ng-if="ctrl.panel.xaxis.mode === 'histogram'"> <div class="gf-form" ng-if="ctrl.panel.xaxis.mode === 'histogram'">
<label class="gf-form-label width-6">Buckets</label> <label class="gf-form-label width-6">Buckets</label>
<input type="number" class="gf-form-input max-width-8" ng-model="ctrl.panel.xaxis.buckets" placeholder="auto" ng-change="ctrl.render()" ng-model-onblur bs-tooltip="'Number of buckets'" data-placement="right"> <input
type="number"
class="gf-form-input max-width-8"
ng-model="ctrl.panel.xaxis.buckets"
placeholder="auto"
ng-change="ctrl.render()"
ng-model-onblur
bs-tooltip="'Number of buckets'"
data-placement="right"
/>
</div> </div>
<div class="gf-form-inline" ng-if="ctrl.panel.xaxis.mode === 'histogram'"> <div class="gf-form-inline" ng-if="ctrl.panel.xaxis.mode === 'histogram'">
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">X-Min</label> <label class="gf-form-label width-6">X-Min</label>
<input type="number" class="gf-form-input width-5" placeholder="auto" empty-to-null ng-model="ctrl.panel.xaxis.min" ng-change="ctrl.render()" ng-model-onblur> <input
type="number"
class="gf-form-input width-5"
placeholder="auto"
empty-to-null
ng-model="ctrl.panel.xaxis.min"
ng-change="ctrl.render()"
ng-model-onblur
/>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">X-Max</label> <label class="gf-form-label width-6">X-Max</label>
<input type="number" class="gf-form-input width-5" placeholder="auto" empty-to-null ng-model="ctrl.panel.xaxis.max" ng-change="ctrl.render()" ng-model-onblur> <input
type="number"
class="gf-form-input width-5"
placeholder="auto"
empty-to-null
ng-model="ctrl.panel.xaxis.max"
ng-change="ctrl.render()"
ng-model-onblur
/>
</div> </div>
</div> </div>
<div>
<br/>
<h5 class="section-heading">Y-Axes</h5>
<gf-form-switch class="gf-form" label="Align" tooltip="Align left and right Y-axes" label-class="width-6" switch-class="width-5" checked="ctrl.panel.yaxis.align" on-change="ctrl.render()"></gf-form-switch>
<div class="gf-form" ng-show="ctrl.panel.yaxis.align">
<label class="gf-form-label width-6">
Level
</label>
<input type="number" class="gf-form-input width-5" placeholder="0" ng-model="ctrl.panel.yaxis.alignLevel" ng-change="ctrl.render()" ng-model-onblur bs-tooltip="'Alignment of Y-axes are based on this value, starting from Y=0'" data-placement="right">
</div>
</div> </div>
</div>
</div> </div>
...@@ -167,7 +167,7 @@ class GraphCtrl extends MetricsPanelCtrl { ...@@ -167,7 +167,7 @@ class GraphCtrl extends MetricsPanelCtrl {
onInitEditMode() { onInitEditMode() {
this.addEditorTab('Display', 'public/app/plugins/panel/graph/tab_display.html'); this.addEditorTab('Display', 'public/app/plugins/panel/graph/tab_display.html');
this.addEditorTab('Series overides', 'public/app/plugins/panel/graph/tab_series_overrides.html'); this.addEditorTab('Series overrides', 'public/app/plugins/panel/graph/tab_series_overrides.html');
this.addEditorTab('Axes', axesEditorComponent); this.addEditorTab('Axes', axesEditorComponent);
this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html'); this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html');
this.addEditorTab('Thresholds', 'public/app/plugins/panel/graph/tab_thresholds.html'); this.addEditorTab('Thresholds', 'public/app/plugins/panel/graph/tab_thresholds.html');
......
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
<gf-form-switch <gf-form-switch
class="gf-form" class="gf-form"
label="With only nulls" label="With only nulls"
label-class="width-10" label-class="width-7"
checked="ctrl.panel.legend.hideEmpty" checked="ctrl.panel.legend.hideEmpty"
on-change="ctrl.render()" on-change="ctrl.render()"
> >
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
<gf-form-switch <gf-form-switch
class="gf-form" class="gf-form"
label="With only zeros" label="With only zeros"
label-class="width-10" label-class="width-7"
checked="ctrl.panel.legend.hideZero" checked="ctrl.panel.legend.hideZero"
on-change="ctrl.render()" on-change="ctrl.render()"
> >
......
...@@ -161,7 +161,7 @@ $scrollbarBorder: black; ...@@ -161,7 +161,7 @@ $scrollbarBorder: black;
// Tables // Tables
// ------------------------- // -------------------------
$table-bg-accent: $dark-6; // for striping $table-bg-accent: #191b1e; // for striping
$table-border: $dark-6; // table and cell border $table-border: $dark-6; // table and cell border
$table-bg-odd: $dark-3; $table-bg-odd: $dark-3;
......
...@@ -154,7 +154,7 @@ $scrollbarBorder: $gray-7; ...@@ -154,7 +154,7 @@ $scrollbarBorder: $gray-7;
// Tables // Tables
// ------------------------- // -------------------------
$table-bg-accent: $gray-5; // for striping $table-bg-accent: #fafafa;
$table-border: $gray-3; // table and cell border $table-border: $gray-3; // table and cell border
$table-bg-odd: $gray-6; $table-bg-odd: $gray-6;
......
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
overflow: hidden; overflow: hidden;
} }
.graph-legend-series:nth-child(odd) { .graph-legend-series:nth-child(even) {
background: $table-bg-accent; background: $table-bg-accent;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment