Internationalisation: Mark up geomap panel edit options (#107140)
mark up geomap panel edit options
This commit is contained in:
@@ -11,16 +11,19 @@ import { NumberInput } from 'app/core/components/OptionsUI/NumberInput';
|
|||||||
import { validateScaleOptions, validateScaleConfig } from '../scale';
|
import { validateScaleOptions, validateScaleConfig } from '../scale';
|
||||||
import { ScaleDimensionOptions } from '../types';
|
import { ScaleDimensionOptions } from '../types';
|
||||||
|
|
||||||
const fixedValueOption: SelectableValue<string> = {
|
|
||||||
label: 'Fixed value',
|
|
||||||
value: '_____fixed_____',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ScaleDimensionEditor = (props: StandardEditorProps<ScaleDimensionConfig, ScaleDimensionOptions>) => {
|
export const ScaleDimensionEditor = (props: StandardEditorProps<ScaleDimensionConfig, ScaleDimensionOptions>) => {
|
||||||
const { value, context, onChange, item } = props;
|
const { value, context, onChange, item } = props;
|
||||||
const { settings } = item;
|
const { settings } = item;
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
|
|
||||||
|
const fixedValueOption: SelectableValue<string> = useMemo(
|
||||||
|
() => ({
|
||||||
|
label: t('dimensions.scale-dimension-editor.fixed-value-option.label.fixed-value', 'Fixed value'),
|
||||||
|
value: '_____fixed_____',
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
const fieldName = value?.field;
|
const fieldName = value?.field;
|
||||||
const isFixed = Boolean(!fieldName);
|
const isFixed = Boolean(!fieldName);
|
||||||
const names = useFieldDisplayNames(context.data);
|
const names = useFieldDisplayNames(context.data);
|
||||||
@@ -53,7 +56,7 @@ export const ScaleDimensionEditor = (props: StandardEditorProps<ScaleDimensionCo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[validateAndDoChange, value]
|
[validateAndDoChange, value, fixedValueOption.value]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onMinChange = useCallback(
|
const onMinChange = useCallback(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Field, FieldType, PanelOptionsEditorBuilder, DataFrame } from '@grafana/data';
|
import { Field, FieldType, PanelOptionsEditorBuilder, DataFrame } from '@grafana/data';
|
||||||
|
import { t } from '@grafana/i18n';
|
||||||
import { FrameGeometrySource, FrameGeometrySourceMode } from '@grafana/schema';
|
import { FrameGeometrySource, FrameGeometrySourceMode } from '@grafana/schema';
|
||||||
import { GazetteerPathEditor } from 'app/features/geo/editor/GazetteerPathEditor';
|
import { GazetteerPathEditor } from 'app/features/geo/editor/GazetteerPathEditor';
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ export function addLocationFields<TOptions>(
|
|||||||
builder.addCustomEditor({
|
builder.addCustomEditor({
|
||||||
id: 'modeEditor',
|
id: 'modeEditor',
|
||||||
path: `${prefix}mode`,
|
path: `${prefix}mode`,
|
||||||
name: 'Location Mode',
|
name: t('geo.location-editor.name-location-mode', 'Location Mode'),
|
||||||
editor: LocationModeEditor,
|
editor: LocationModeEditor,
|
||||||
settings: { data, source },
|
settings: { data, source },
|
||||||
});
|
});
|
||||||
@@ -25,18 +26,18 @@ export function addLocationFields<TOptions>(
|
|||||||
builder
|
builder
|
||||||
.addFieldNamePicker({
|
.addFieldNamePicker({
|
||||||
path: `${prefix}latitude`,
|
path: `${prefix}latitude`,
|
||||||
name: 'Latitude field',
|
name: t('geo.location-editor.name-latitude-field', 'Latitude field'),
|
||||||
settings: {
|
settings: {
|
||||||
filter: (f: Field) => f.type === FieldType.number,
|
filter: (f: Field) => f.type === FieldType.number,
|
||||||
noFieldsMessage: 'No numeric fields found',
|
noFieldsMessage: t('geo.location-editor.latitude-field.no-fields-message', 'No numeric fields found'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.addFieldNamePicker({
|
.addFieldNamePicker({
|
||||||
path: `${prefix}longitude`,
|
path: `${prefix}longitude`,
|
||||||
name: 'Longitude field',
|
name: t('geo.location-editor.name-longitude-field', 'Longitude field'),
|
||||||
settings: {
|
settings: {
|
||||||
filter: (f: Field) => f.type === FieldType.number,
|
filter: (f: Field) => f.type === FieldType.number,
|
||||||
noFieldsMessage: 'No numeric fields found',
|
noFieldsMessage: t('geo.location-editor.longitude-field.no-fields-message', 'No numeric fields found'),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -44,10 +45,10 @@ export function addLocationFields<TOptions>(
|
|||||||
case FrameGeometrySourceMode.Geohash:
|
case FrameGeometrySourceMode.Geohash:
|
||||||
builder.addFieldNamePicker({
|
builder.addFieldNamePicker({
|
||||||
path: `${prefix}geohash`,
|
path: `${prefix}geohash`,
|
||||||
name: 'Geohash field',
|
name: t('geo.location-editor.name-geohash-field', 'Geohash field'),
|
||||||
settings: {
|
settings: {
|
||||||
filter: (f: Field) => f.type === FieldType.string,
|
filter: (f: Field) => f.type === FieldType.string,
|
||||||
noFieldsMessage: 'No strings fields found',
|
noFieldsMessage: t('geo.location-editor.geohash-field.no-fields-message', 'No strings fields found'),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -56,16 +57,16 @@ export function addLocationFields<TOptions>(
|
|||||||
builder
|
builder
|
||||||
.addFieldNamePicker({
|
.addFieldNamePicker({
|
||||||
path: `${prefix}lookup`,
|
path: `${prefix}lookup`,
|
||||||
name: 'Lookup field',
|
name: t('geo.location-editor.name-lookup-field', 'Lookup field'),
|
||||||
settings: {
|
settings: {
|
||||||
filter: (f: Field) => f.type === FieldType.string,
|
filter: (f: Field) => f.type === FieldType.string,
|
||||||
noFieldsMessage: 'No strings fields found',
|
noFieldsMessage: t('geo.location-editor.lookup-field.no-fields-message', 'No strings fields found'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.addCustomEditor({
|
.addCustomEditor({
|
||||||
id: 'gazetteer',
|
id: 'gazetteer',
|
||||||
path: `${prefix}gazetteer`,
|
path: `${prefix}gazetteer`,
|
||||||
name: 'Gazetteer',
|
name: t('geo.location-editor.name-gazetteer', 'Gazetteer'),
|
||||||
editor: GazetteerPathEditor,
|
editor: GazetteerPathEditor,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,38 +3,12 @@ import { useEffect, useState } from 'react';
|
|||||||
|
|
||||||
import { StandardEditorProps, DataFrame, GrafanaTheme2 } from '@grafana/data';
|
import { StandardEditorProps, DataFrame, GrafanaTheme2 } from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
|
import { t } from '@grafana/i18n';
|
||||||
import { FrameGeometrySource, FrameGeometrySourceMode } from '@grafana/schema';
|
import { FrameGeometrySource, FrameGeometrySourceMode } from '@grafana/schema';
|
||||||
import { Alert, HorizontalGroup, Icon, Select, useStyles2 } from '@grafana/ui';
|
import { Alert, HorizontalGroup, Icon, Select, useStyles2 } from '@grafana/ui';
|
||||||
|
|
||||||
import { FrameGeometryField, getGeometryField, getLocationMatchers } from '../utils/location';
|
import { FrameGeometryField, getGeometryField, getLocationMatchers } from '../utils/location';
|
||||||
|
|
||||||
const MODE_OPTIONS = [
|
|
||||||
{
|
|
||||||
value: FrameGeometrySourceMode.Auto,
|
|
||||||
label: 'Auto',
|
|
||||||
ariaLabel: selectors.components.Transforms.SpatialOperations.location.autoOption,
|
|
||||||
description: 'Automatically identify location data based on default field names',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: FrameGeometrySourceMode.Coords,
|
|
||||||
label: 'Coords',
|
|
||||||
ariaLabel: selectors.components.Transforms.SpatialOperations.location.coords.option,
|
|
||||||
description: 'Specify latitude and longitude fields',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: FrameGeometrySourceMode.Geohash,
|
|
||||||
label: 'Geohash',
|
|
||||||
ariaLabel: selectors.components.Transforms.SpatialOperations.location.geohash.option,
|
|
||||||
description: 'Specify geohash field',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: FrameGeometrySourceMode.Lookup,
|
|
||||||
label: 'Lookup',
|
|
||||||
ariaLabel: selectors.components.Transforms.SpatialOperations.location.lookup.option,
|
|
||||||
description: 'Specify Gazetteer and lookup field',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
interface ModeEditorSettings {
|
interface ModeEditorSettings {
|
||||||
data?: DataFrame[];
|
data?: DataFrame[];
|
||||||
source?: FrameGeometrySource;
|
source?: FrameGeometrySource;
|
||||||
@@ -50,6 +24,39 @@ export const LocationModeEditor = ({
|
|||||||
}: StandardEditorProps<string, ModeEditorSettings, unknown, unknown>) => {
|
}: StandardEditorProps<string, ModeEditorSettings, unknown, unknown>) => {
|
||||||
const [info, setInfo] = useState<FrameGeometryField>();
|
const [info, setInfo] = useState<FrameGeometryField>();
|
||||||
|
|
||||||
|
const MODE_OPTIONS = [
|
||||||
|
{
|
||||||
|
value: FrameGeometrySourceMode.Auto,
|
||||||
|
label: t('geo.location-more-editor.mode-options.label-auto', 'Auto'),
|
||||||
|
ariaLabel: selectors.components.Transforms.SpatialOperations.location.autoOption,
|
||||||
|
description: t(
|
||||||
|
'geo.location-more-editor.mode-options.description-auto',
|
||||||
|
'Automatically identify location data based on default field names'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: FrameGeometrySourceMode.Coords,
|
||||||
|
label: t('geo.location-more-editor.mode-options.label-coords', 'Coords'),
|
||||||
|
ariaLabel: selectors.components.Transforms.SpatialOperations.location.coords.option,
|
||||||
|
description: t(
|
||||||
|
'geo.location-more-editor.mode-options.description-coords',
|
||||||
|
'Specify latitude and longitude fields'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: FrameGeometrySourceMode.Geohash,
|
||||||
|
label: t('geo.location-more-editor.mode-options.label-geohash', 'Geohash'),
|
||||||
|
ariaLabel: selectors.components.Transforms.SpatialOperations.location.geohash.option,
|
||||||
|
description: t('geo.location-more-editor.mode-options.description-geohash', 'Specify geohash field'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: FrameGeometrySourceMode.Lookup,
|
||||||
|
label: t('geo.location-more-editor.mode-options.label-lookup', 'Lookup'),
|
||||||
|
ariaLabel: selectors.components.Transforms.SpatialOperations.location.lookup.option,
|
||||||
|
description: t('geo.location-more-editor.mode-options.description-lookup', 'Specify Gazetteer and lookup field'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (item.settings?.source && item.settings?.data?.length && item.settings.data[0]) {
|
if (item.settings?.source && item.settings?.data?.length && item.settings.data[0]) {
|
||||||
getLocationMatchers(item.settings.source).then((location) => {
|
getLocationMatchers(item.settings.source).then((location) => {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
getFieldDisplayName,
|
getFieldDisplayName,
|
||||||
FieldType,
|
FieldType,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
|
import { t } from '@grafana/i18n';
|
||||||
import { FrameGeometrySource, FrameGeometrySourceMode } from '@grafana/schema';
|
import { FrameGeometrySource, FrameGeometrySourceMode } from '@grafana/schema';
|
||||||
|
|
||||||
import { getGeoFieldFromGazetteer, pointFieldFromGeohash, pointFieldFromLonLat } from '../format/utils';
|
import { getGeoFieldFromGazetteer, pointFieldFromGeohash, pointFieldFromLonLat } from '../format/utils';
|
||||||
@@ -178,7 +179,7 @@ export function getGeometryField(frame: DataFrame, location: LocationFieldMatche
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
warning: 'Unable to find location fields',
|
warning: t('geo.get-geometry-field.warning-unable-to-find', 'Unable to find location fields'),
|
||||||
};
|
};
|
||||||
|
|
||||||
case FrameGeometrySourceMode.Coords:
|
case FrameGeometrySourceMode.Coords:
|
||||||
@@ -190,7 +191,7 @@ export function getGeometryField(frame: DataFrame, location: LocationFieldMatche
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
warning: 'Select latitude/longitude fields',
|
warning: t('geo.get-geometry-field.warning-select-lat-long', 'Select latitude/longitude fields'),
|
||||||
};
|
};
|
||||||
|
|
||||||
case FrameGeometrySourceMode.Geohash:
|
case FrameGeometrySourceMode.Geohash:
|
||||||
@@ -202,7 +203,7 @@ export function getGeometryField(frame: DataFrame, location: LocationFieldMatche
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
warning: 'Select geohash field',
|
warning: t('geo.get-geometry-field.warning-select-geohash', 'Select geohash field'),
|
||||||
};
|
};
|
||||||
|
|
||||||
case FrameGeometrySourceMode.Lookup:
|
case FrameGeometrySourceMode.Lookup:
|
||||||
@@ -215,13 +216,13 @@ export function getGeometryField(frame: DataFrame, location: LocationFieldMatche
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
warning: 'Gazetteer not found',
|
warning: t('geo.get-geometry-field.warning-gazetteer-not-found', 'Gazetteer not found'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
warning: 'Select lookup field',
|
warning: t('geo.get-geometry-field.warning-select-lookup', 'Select lookup field'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { warning: 'unable to find geometry' };
|
return { warning: t('geo.get-geometry-field.warning-no-geometry', 'unable to find geometry') };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,9 +242,15 @@ export const StyleEditor = (props: Props) => {
|
|||||||
value={value?.symbolAlign?.vertical ?? defaultStyleConfig.symbolAlign.vertical}
|
value={value?.symbolAlign?.vertical ?? defaultStyleConfig.symbolAlign.vertical}
|
||||||
onChange={onAlignVerticalChange}
|
onChange={onAlignVerticalChange}
|
||||||
options={[
|
options={[
|
||||||
{ value: VerticalAlign.Top, label: capitalize(VerticalAlign.Top) },
|
{ value: VerticalAlign.Top, label: t('geomap.style-editor.vertical-align-options.label-top', 'Top') },
|
||||||
{ value: VerticalAlign.Center, label: capitalize(VerticalAlign.Center) },
|
{
|
||||||
{ value: VerticalAlign.Bottom, label: capitalize(VerticalAlign.Bottom) },
|
value: VerticalAlign.Center,
|
||||||
|
label: t('geomap.style-editor.vertical-align-options.label-center', 'Center'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: VerticalAlign.Bottom,
|
||||||
|
label: t('geomap.style-editor.vertical-align-options.label-bottom', 'Bottom'),
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
@@ -253,9 +259,18 @@ export const StyleEditor = (props: Props) => {
|
|||||||
value={value?.symbolAlign?.horizontal ?? defaultStyleConfig.symbolAlign.horizontal}
|
value={value?.symbolAlign?.horizontal ?? defaultStyleConfig.symbolAlign.horizontal}
|
||||||
onChange={onAlignHorizontalChange}
|
onChange={onAlignHorizontalChange}
|
||||||
options={[
|
options={[
|
||||||
{ value: HorizontalAlign.Left, label: capitalize(HorizontalAlign.Left) },
|
{
|
||||||
{ value: HorizontalAlign.Center, label: capitalize(HorizontalAlign.Center) },
|
value: HorizontalAlign.Left,
|
||||||
{ value: HorizontalAlign.Right, label: capitalize(HorizontalAlign.Right) },
|
label: t('geomap.style-editor.horizontal-align-options.label-left', 'Left'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: HorizontalAlign.Center,
|
||||||
|
label: t('geomap.style-editor.horizontal-align-options.label-center', 'Center'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: HorizontalAlign.Right,
|
||||||
|
label: t('geomap.style-editor.horizontal-align-options.label-right', 'Right'),
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { get as lodashGet, isEqual } from 'lodash';
|
|||||||
|
|
||||||
import { FrameGeometrySourceMode, getFrameMatchers, MapLayerOptions } from '@grafana/data';
|
import { FrameGeometrySourceMode, getFrameMatchers, MapLayerOptions } from '@grafana/data';
|
||||||
import { NestedPanelOptions, NestedValueAccess } from '@grafana/data/internal';
|
import { NestedPanelOptions, NestedValueAccess } from '@grafana/data/internal';
|
||||||
|
import { t } from '@grafana/i18n';
|
||||||
import { setOptionImmutably } from 'app/features/dashboard/components/PanelEditor/utils';
|
import { setOptionImmutably } from 'app/features/dashboard/components/PanelEditor/utils';
|
||||||
import { addLocationFields } from 'app/features/geo/editor/locationEditor';
|
import { addLocationFields } from 'app/features/geo/editor/locationEditor';
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ export function getLayerEditor(opts: LayerEditorOptions): NestedPanelOptions<Map
|
|||||||
|
|
||||||
builder.addSelect({
|
builder.addSelect({
|
||||||
path: 'type',
|
path: 'type',
|
||||||
name: 'Layer type', // required, but hide space
|
name: t('geomap.layer-editor.name-layer-type', 'Layer type'), // required, but hide space
|
||||||
settings: {
|
settings: {
|
||||||
options: layerTypes.options,
|
options: layerTypes.options,
|
||||||
},
|
},
|
||||||
@@ -80,7 +81,7 @@ export function getLayerEditor(opts: LayerEditorOptions): NestedPanelOptions<Map
|
|||||||
builder.addCustomEditor({
|
builder.addCustomEditor({
|
||||||
id: 'filterData',
|
id: 'filterData',
|
||||||
path: 'filterData',
|
path: 'filterData',
|
||||||
name: 'Data',
|
name: t('geomap.layer-editor.name-data', 'Data'),
|
||||||
editor: FrameSelectionEditor,
|
editor: FrameSelectionEditor,
|
||||||
defaultValue: undefined,
|
defaultValue: undefined,
|
||||||
});
|
});
|
||||||
@@ -108,11 +109,11 @@ export function getLayerEditor(opts: LayerEditorOptions): NestedPanelOptions<Map
|
|||||||
if (handler.registerOptionsUI) {
|
if (handler.registerOptionsUI) {
|
||||||
handler.registerOptionsUI(builder, context);
|
handler.registerOptionsUI(builder, context);
|
||||||
}
|
}
|
||||||
if (!isEqual(opts.category, ['Base layer'])) {
|
if (!isEqual(opts.category, [t('geomap.layer-editor.category-base-layer', 'Base layer')])) {
|
||||||
if (!layer.hideOpacity) {
|
if (!layer.hideOpacity) {
|
||||||
builder.addSliderInput({
|
builder.addSliderInput({
|
||||||
path: 'opacity',
|
path: 'opacity',
|
||||||
name: 'Opacity',
|
name: t('geomap.layer-editor.name-opacity', 'Opacity'),
|
||||||
defaultValue: 1,
|
defaultValue: 1,
|
||||||
settings: {
|
settings: {
|
||||||
min: 0,
|
min: 0,
|
||||||
@@ -123,8 +124,8 @@ export function getLayerEditor(opts: LayerEditorOptions): NestedPanelOptions<Map
|
|||||||
}
|
}
|
||||||
builder.addBooleanSwitch({
|
builder.addBooleanSwitch({
|
||||||
path: 'layer-tooltip',
|
path: 'layer-tooltip',
|
||||||
name: 'Display tooltip',
|
name: t('geomap.layer-editor.name-display-tooltip', 'Display tooltip'),
|
||||||
description: 'Show the tooltip for layer',
|
description: t('geomap.layer-editor.description-display-tooltip', 'Show the tooltip for layer'),
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
FrameGeometrySourceMode,
|
FrameGeometrySourceMode,
|
||||||
EventBus,
|
EventBus,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
|
import { t } from '@grafana/i18n';
|
||||||
import { FrameVectorSource } from 'app/features/geo/utils/frameVectorSource';
|
import { FrameVectorSource } from 'app/features/geo/utils/frameVectorSource';
|
||||||
import { getLocationMatchers } from 'app/features/geo/utils/location';
|
import { getLocationMatchers } from 'app/features/geo/utils/location';
|
||||||
|
|
||||||
@@ -230,7 +231,7 @@ export const markersLayer: MapLayerRegistryItem<MarkersConfig> = {
|
|||||||
.addCustomEditor({
|
.addCustomEditor({
|
||||||
id: 'config.style',
|
id: 'config.style',
|
||||||
path: 'config.style',
|
path: 'config.style',
|
||||||
name: 'Styles',
|
name: t('geomap.markers-layer.name-styles', 'Styles'),
|
||||||
editor: StyleEditor,
|
editor: StyleEditor,
|
||||||
settings: {
|
settings: {
|
||||||
displayRotation: true,
|
displayRotation: true,
|
||||||
@@ -239,8 +240,8 @@ export const markersLayer: MapLayerRegistryItem<MarkersConfig> = {
|
|||||||
})
|
})
|
||||||
.addBooleanSwitch({
|
.addBooleanSwitch({
|
||||||
path: 'config.showLegend',
|
path: 'config.showLegend',
|
||||||
name: 'Show legend',
|
name: t('geomap.markers-layer.name-show-legend', 'Show legend'),
|
||||||
description: 'Show map legend',
|
description: t('geomap.markers-layer.description-show-legend', 'Show map legend'),
|
||||||
defaultValue: defaultOptions.showLegend,
|
defaultValue: defaultOptions.showLegend,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { PanelPlugin } from '@grafana/data';
|
import { PanelPlugin } from '@grafana/data';
|
||||||
import { Trans } from '@grafana/i18n';
|
import { t, Trans } from '@grafana/i18n';
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
import { commonOptionsBuilder } from '@grafana/ui';
|
import { commonOptionsBuilder } from '@grafana/ui';
|
||||||
|
|
||||||
@@ -20,13 +20,13 @@ export const plugin = new PanelPlugin<Options>(GeomapPanel)
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.setPanelOptions((builder, context) => {
|
.setPanelOptions((builder, context) => {
|
||||||
let category = ['Map view'];
|
let category = [t('geomap.category-map-view', 'Map view')];
|
||||||
builder.addCustomEditor({
|
builder.addCustomEditor({
|
||||||
category,
|
category,
|
||||||
id: 'view',
|
id: 'view',
|
||||||
path: 'view',
|
path: 'view',
|
||||||
name: 'Initial view', // don't show it
|
name: t('geomap.name-initial-view', 'Initial view'), // don't show it
|
||||||
description: 'This location will show when the panel first loads.',
|
description: t('geomap.description-initial-view', 'This location will show when the panel first loads.'),
|
||||||
editor: MapViewEditor,
|
editor: MapViewEditor,
|
||||||
defaultValue: defaultMapViewConfig,
|
defaultValue: defaultMapViewConfig,
|
||||||
});
|
});
|
||||||
@@ -34,8 +34,11 @@ export const plugin = new PanelPlugin<Options>(GeomapPanel)
|
|||||||
builder.addBooleanSwitch({
|
builder.addBooleanSwitch({
|
||||||
category,
|
category,
|
||||||
path: 'view.shared',
|
path: 'view.shared',
|
||||||
description: 'Use the same view across multiple panels. Note: this may require a dashboard reload.',
|
description: t(
|
||||||
name: 'Share view',
|
'geomap.description-share-view',
|
||||||
|
'Use the same view across multiple panels. Note: this may require a dashboard reload.'
|
||||||
|
),
|
||||||
|
name: t('geomap.name-share-view', 'Share view'),
|
||||||
defaultValue: defaultMapViewConfig.shared,
|
defaultValue: defaultMapViewConfig.shared,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,8 +47,8 @@ export const plugin = new PanelPlugin<Options>(GeomapPanel)
|
|||||||
if (!state?.layers) {
|
if (!state?.layers) {
|
||||||
// TODO? show spinner?
|
// TODO? show spinner?
|
||||||
} else {
|
} else {
|
||||||
const layersCategory = ['Map layers'];
|
const layersCategory = [t('geomap.category-map-layers', 'Map layers')];
|
||||||
const basemapCategory = ['Basemap layer'];
|
const basemapCategory = [t('geomap.category-basemap-layer', 'Basemap layer')];
|
||||||
builder.addCustomEditor({
|
builder.addCustomEditor({
|
||||||
category: layersCategory,
|
category: layersCategory,
|
||||||
id: 'layers',
|
id: 'layers',
|
||||||
@@ -93,59 +96,70 @@ export const plugin = new PanelPlugin<Options>(GeomapPanel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The controls section
|
// The controls section
|
||||||
category = ['Map controls'];
|
category = [t('geomap.category-map-controls', 'Map controls')];
|
||||||
builder
|
builder
|
||||||
.addBooleanSwitch({
|
.addBooleanSwitch({
|
||||||
category,
|
category,
|
||||||
path: 'controls.showZoom',
|
path: 'controls.showZoom',
|
||||||
description: 'Show zoom control buttons in the upper left corner',
|
description: t('geomap.description-show-zoom', 'Show zoom control buttons in the upper left corner'),
|
||||||
name: 'Show zoom control',
|
name: t('geomap.name-show-zoom', 'Show zoom control'),
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
})
|
})
|
||||||
.addBooleanSwitch({
|
.addBooleanSwitch({
|
||||||
category,
|
category,
|
||||||
path: 'controls.mouseWheelZoom',
|
path: 'controls.mouseWheelZoom',
|
||||||
description: 'Enable zoom control via mouse wheel',
|
description: t('geomap.description-mouse-wheel-zoom', 'Enable zoom control via mouse wheel'),
|
||||||
name: 'Mouse wheel zoom',
|
name: t('geomap.name-mouse-wheel-zoom', 'Mouse wheel zoom'),
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
})
|
})
|
||||||
.addBooleanSwitch({
|
.addBooleanSwitch({
|
||||||
category,
|
category,
|
||||||
path: 'controls.showAttribution',
|
path: 'controls.showAttribution',
|
||||||
name: 'Show attribution',
|
name: t('geomap.name-show-attribution', 'Show attribution'),
|
||||||
description: 'Show the map source attribution info in the lower right',
|
description: t(
|
||||||
|
'geomap.description-show-attribution',
|
||||||
|
'Show the map source attribution info in the lower right'
|
||||||
|
),
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
})
|
})
|
||||||
.addBooleanSwitch({
|
.addBooleanSwitch({
|
||||||
category,
|
category,
|
||||||
path: 'controls.showScale',
|
path: 'controls.showScale',
|
||||||
name: 'Show scale',
|
name: t('geomap.name-show-scale', 'Show scale'),
|
||||||
description: 'Indicate map scale',
|
description: t('geomap.description-show-scale', 'Indicate map scale'),
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
})
|
})
|
||||||
.addBooleanSwitch({
|
.addBooleanSwitch({
|
||||||
category,
|
category,
|
||||||
path: 'controls.showMeasure',
|
path: 'controls.showMeasure',
|
||||||
name: 'Show measure tools',
|
name: t('geomap.name-show-measure', 'Show measure tools'),
|
||||||
description: 'Show tools for making measurements on the map',
|
description: t('geomap.description-show-measure', 'Show tools for making measurements on the map'),
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
})
|
})
|
||||||
.addBooleanSwitch({
|
.addBooleanSwitch({
|
||||||
category,
|
category,
|
||||||
path: 'controls.showDebug',
|
path: 'controls.showDebug',
|
||||||
name: 'Show debug',
|
name: t('geomap.name-show-debug', 'Show debug'),
|
||||||
description: 'Show map info',
|
description: t('geomap.description-show-debug', 'Show map info'),
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
})
|
})
|
||||||
.addRadio({
|
.addRadio({
|
||||||
category,
|
category,
|
||||||
path: 'tooltip.mode',
|
path: 'tooltip.mode',
|
||||||
name: 'Tooltip',
|
name: t('geomap.name-tooltip', 'Tooltip'),
|
||||||
defaultValue: TooltipMode.Details,
|
defaultValue: TooltipMode.Details,
|
||||||
settings: {
|
settings: {
|
||||||
options: [
|
options: [
|
||||||
{ label: 'None', value: TooltipMode.None, description: 'Show contents on click, not hover' },
|
{
|
||||||
{ label: 'Details', value: TooltipMode.Details, description: 'Show popup on hover' },
|
label: t('geomap.tooltip-options.label-none', 'None'),
|
||||||
|
value: TooltipMode.None,
|
||||||
|
description: t('geomap.tooltip-options.description-none', 'Show contents on click, not hover'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('geomap.tooltip-options.label-details', 'Details'),
|
||||||
|
value: TooltipMode.Details,
|
||||||
|
description: t('geomap.tooltip-options.description-details', 'Show popup on hover'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import TileSource from 'ol/source/Tile';
|
|||||||
import VectorSource from 'ol/source/Vector';
|
import VectorSource from 'ol/source/Vector';
|
||||||
|
|
||||||
import { DataFrame, GrafanaTheme2, SelectableValue } from '@grafana/data';
|
import { DataFrame, GrafanaTheme2, SelectableValue } from '@grafana/data';
|
||||||
|
import { t } from '@grafana/i18n';
|
||||||
import { getTemplateSrv } from '@grafana/runtime';
|
import { getTemplateSrv } from '@grafana/runtime';
|
||||||
import { getColorDimension } from 'app/features/dimensions/color';
|
import { getColorDimension } from 'app/features/dimensions/color';
|
||||||
import { getScalarDimension } from 'app/features/dimensions/scalar';
|
import { getScalarDimension } from 'app/features/dimensions/scalar';
|
||||||
@@ -132,13 +133,13 @@ export const notifyPanelEditor = (geomapPanel: GeomapPanel, layers: MapLayerStat
|
|||||||
export const getNextLayerName = (panel: GeomapPanel) => {
|
export const getNextLayerName = (panel: GeomapPanel) => {
|
||||||
let idx = panel.layers.length; // since basemap is 0, this looks right
|
let idx = panel.layers.length; // since basemap is 0, this looks right
|
||||||
while (true && idx < 100) {
|
while (true && idx < 100) {
|
||||||
const name = `Layer ${idx++}`;
|
const name = t('geomap.utils.get-next-layer-name', 'Layer {{name}}', { name: idx++ });
|
||||||
if (!panel.byName.has(name)) {
|
if (!panel.byName.has(name)) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return `Layer ${Date.now()}`;
|
return t('geomap.utils.get-next-layer-name', 'Layer {{name}}', { name: Date.now() });
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isSegmentVisible(
|
export function isSegmentVisible(
|
||||||
|
|||||||
@@ -6310,6 +6310,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scale-dimension-editor": {
|
"scale-dimension-editor": {
|
||||||
|
"fixed-value-option": {
|
||||||
|
"label": {
|
||||||
|
"fixed-value": "Fixed value"
|
||||||
|
}
|
||||||
|
},
|
||||||
"label-max": "Max",
|
"label-max": "Max",
|
||||||
"label-min": "Min",
|
"label-min": "Min",
|
||||||
"label-value": "Value"
|
"label-value": "Value"
|
||||||
@@ -7159,7 +7164,53 @@
|
|||||||
"incomplete-request-error": "Sorry, I was unable to complete your request. Please try again.",
|
"incomplete-request-error": "Sorry, I was unable to complete your request. Please try again.",
|
||||||
"send-custom-feedback": "Send"
|
"send-custom-feedback": "Send"
|
||||||
},
|
},
|
||||||
|
"geo": {
|
||||||
|
"get-geometry-field": {
|
||||||
|
"warning-gazetteer-not-found": "Gazetteer not found",
|
||||||
|
"warning-no-geometry": "unable to find geometry",
|
||||||
|
"warning-select-geohash": "Select geohash field",
|
||||||
|
"warning-select-lat-long": "Select latitude/longitude fields",
|
||||||
|
"warning-select-lookup": "Select lookup field",
|
||||||
|
"warning-unable-to-find": "Unable to find location fields"
|
||||||
|
},
|
||||||
|
"location-editor": {
|
||||||
|
"geohash-field": {
|
||||||
|
"no-fields-message": "No strings fields found"
|
||||||
|
},
|
||||||
|
"latitude-field": {
|
||||||
|
"no-fields-message": "No numeric fields found"
|
||||||
|
},
|
||||||
|
"longitude-field": {
|
||||||
|
"no-fields-message": "No numeric fields found"
|
||||||
|
},
|
||||||
|
"lookup-field": {
|
||||||
|
"no-fields-message": "No strings fields found"
|
||||||
|
},
|
||||||
|
"name-gazetteer": "Gazetteer",
|
||||||
|
"name-geohash-field": "Geohash field",
|
||||||
|
"name-latitude-field": "Latitude field",
|
||||||
|
"name-location-mode": "Location Mode",
|
||||||
|
"name-longitude-field": "Longitude field",
|
||||||
|
"name-lookup-field": "Lookup field"
|
||||||
|
},
|
||||||
|
"location-more-editor": {
|
||||||
|
"mode-options": {
|
||||||
|
"description-auto": "Automatically identify location data based on default field names",
|
||||||
|
"description-coords": "Specify latitude and longitude fields",
|
||||||
|
"description-geohash": "Specify geohash field",
|
||||||
|
"description-lookup": "Specify Gazetteer and lookup field",
|
||||||
|
"label-auto": "Auto",
|
||||||
|
"label-coords": "Coords",
|
||||||
|
"label-geohash": "Geohash",
|
||||||
|
"label-lookup": "Lookup"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"geomap": {
|
"geomap": {
|
||||||
|
"category-basemap-layer": "Basemap layer",
|
||||||
|
"category-map-controls": "Map controls",
|
||||||
|
"category-map-layers": "Map layers",
|
||||||
|
"category-map-view": "Map view",
|
||||||
"coordinates-map-view-editor": {
|
"coordinates-map-view-editor": {
|
||||||
"label-latitude": "Latitude",
|
"label-latitude": "Latitude",
|
||||||
"label-longitude": "Longitude"
|
"label-longitude": "Longitude"
|
||||||
@@ -7168,6 +7219,14 @@
|
|||||||
"center": "Center:",
|
"center": "Center:",
|
||||||
"zoom": "Zoom:"
|
"zoom": "Zoom:"
|
||||||
},
|
},
|
||||||
|
"description-initial-view": "This location will show when the panel first loads.",
|
||||||
|
"description-mouse-wheel-zoom": "Enable zoom control via mouse wheel",
|
||||||
|
"description-share-view": "Use the same view across multiple panels. Note: this may require a dashboard reload.",
|
||||||
|
"description-show-attribution": "Show the map source attribution info in the lower right",
|
||||||
|
"description-show-debug": "Show map info",
|
||||||
|
"description-show-measure": "Show tools for making measurements on the map",
|
||||||
|
"description-show-scale": "Indicate map scale",
|
||||||
|
"description-show-zoom": "Show zoom control buttons in the upper left corner",
|
||||||
"fit-map-view-editor": {
|
"fit-map-view-editor": {
|
||||||
"all-layers-editor-fragment": {
|
"all-layers-editor-fragment": {
|
||||||
"label-layer": "Layer"
|
"label-layer": "Layer"
|
||||||
@@ -7190,6 +7249,14 @@
|
|||||||
"geomap-style-rules-editor": {
|
"geomap-style-rules-editor": {
|
||||||
"aria-label-add-geomap-style-rule": "Add geomap style rule"
|
"aria-label-add-geomap-style-rule": "Add geomap style rule"
|
||||||
},
|
},
|
||||||
|
"layer-editor": {
|
||||||
|
"category-base-layer": "Base layer",
|
||||||
|
"description-display-tooltip": "Show the tooltip for layer",
|
||||||
|
"name-data": "Data",
|
||||||
|
"name-display-tooltip": "Display tooltip",
|
||||||
|
"name-layer-type": "Layer type",
|
||||||
|
"name-opacity": "Opacity"
|
||||||
|
},
|
||||||
"layers-editor": {
|
"layers-editor": {
|
||||||
"label-add-layer": "Add layer",
|
"label-add-layer": "Add layer",
|
||||||
"no-layers": "No layers?"
|
"no-layers": "No layers?"
|
||||||
@@ -7200,16 +7267,35 @@
|
|||||||
"label-zoom": "Zoom",
|
"label-zoom": "Zoom",
|
||||||
"use-current-map-settings": "Use current map settings"
|
"use-current-map-settings": "Use current map settings"
|
||||||
},
|
},
|
||||||
|
"markers-layer": {
|
||||||
|
"description-show-legend": "Show map legend",
|
||||||
|
"name-show-legend": "Show legend",
|
||||||
|
"name-styles": "Styles"
|
||||||
|
},
|
||||||
"markers-legend": {
|
"markers-legend": {
|
||||||
"title-symbol": "Symbol"
|
"title-symbol": "Symbol"
|
||||||
},
|
},
|
||||||
"measure-overlay": {
|
"measure-overlay": {
|
||||||
"tooltip-show-measure-tools": "Show measure tools"
|
"tooltip-show-measure-tools": "Show measure tools"
|
||||||
},
|
},
|
||||||
|
"name-initial-view": "Initial view",
|
||||||
|
"name-mouse-wheel-zoom": "Mouse wheel zoom",
|
||||||
|
"name-share-view": "Share view",
|
||||||
|
"name-show-attribution": "Show attribution",
|
||||||
|
"name-show-debug": "Show debug",
|
||||||
|
"name-show-measure": "Show measure tools",
|
||||||
|
"name-show-scale": "Show scale",
|
||||||
|
"name-show-zoom": "Show zoom control",
|
||||||
|
"name-tooltip": "Tooltip",
|
||||||
"plugin": {
|
"plugin": {
|
||||||
"basemap-layer-configured-server-admin": "The basemap layer is configured by the server admin."
|
"basemap-layer-configured-server-admin": "The basemap layer is configured by the server admin."
|
||||||
},
|
},
|
||||||
"style-editor": {
|
"style-editor": {
|
||||||
|
"horizontal-align-options": {
|
||||||
|
"label-center": "Center",
|
||||||
|
"label-left": "Left",
|
||||||
|
"label-right": "Right"
|
||||||
|
},
|
||||||
"label-align": "Align",
|
"label-align": "Align",
|
||||||
"label-baseline": "Baseline",
|
"label-baseline": "Baseline",
|
||||||
"label-color": "Color",
|
"label-color": "Color",
|
||||||
@@ -7223,7 +7309,12 @@
|
|||||||
"label-symbol-vertical-align": "Symbol vertical align",
|
"label-symbol-vertical-align": "Symbol vertical align",
|
||||||
"label-text-label": "Text label",
|
"label-text-label": "Text label",
|
||||||
"label-x-offset": "X offset",
|
"label-x-offset": "X offset",
|
||||||
"label-y-offset": "Y offset"
|
"label-y-offset": "Y offset",
|
||||||
|
"vertical-align-options": {
|
||||||
|
"label-bottom": "Bottom",
|
||||||
|
"label-center": "Center",
|
||||||
|
"label-top": "Top"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"style-rule-editor": {
|
"style-rule-editor": {
|
||||||
"aria-label-comparison-operator": "Comparison operator",
|
"aria-label-comparison-operator": "Comparison operator",
|
||||||
@@ -7234,6 +7325,15 @@
|
|||||||
"placeholder-feature-property": "Feature property",
|
"placeholder-feature-property": "Feature property",
|
||||||
"placeholder-numeric-value": "Numeric value",
|
"placeholder-numeric-value": "Numeric value",
|
||||||
"placeholder-value": "value"
|
"placeholder-value": "value"
|
||||||
|
},
|
||||||
|
"tooltip-options": {
|
||||||
|
"description-details": "Show popup on hover",
|
||||||
|
"description-none": "Show contents on click, not hover",
|
||||||
|
"label-details": "Details",
|
||||||
|
"label-none": "None"
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"get-next-layer-name": "Layer {{name}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"get-enterprise": {
|
"get-enterprise": {
|
||||||
|
|||||||
Reference in New Issue
Block a user