mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
Add option to display mini map
This commit is contained in:
parent
5a8f1d2957
commit
36733deed6
@ -9,17 +9,17 @@ labels:
|
|||||||
- oss
|
- oss
|
||||||
title: CanvasPanelCfg kind
|
title: CanvasPanelCfg kind
|
||||||
---
|
---
|
||||||
|
|
||||||
> Both documentation generation and kinds schemas are in active development and subject to change without prior notice.
|
> Both documentation generation and kinds schemas are in active development and subject to change without prior notice.
|
||||||
|
|
||||||
## CanvasPanelCfg
|
## CanvasPanelCfg
|
||||||
|
|
||||||
#### Maturity: [experimental](../../../maturity/#experimental)
|
#### Maturity: [experimental](../../../maturity/#experimental)
|
||||||
|
|
||||||
#### Version: 0.0
|
#### Version: 0.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|-------------------------|----------------------------------|----------|---------|-----------------------------------------------------------------------|
|
| ----------------------- | -------------------------------- | -------- | ------- | --------------------------------------------------------------------- |
|
||||||
| `BackgroundConfig` | [object](#backgroundconfig) | **Yes** | | |
|
| `BackgroundConfig` | [object](#backgroundconfig) | **Yes** | | |
|
||||||
| `BackgroundImageSize` | string | **Yes** | | Possible values are: `original`, `contain`, `cover`, `fill`, `tile`. |
|
| `BackgroundImageSize` | string | **Yes** | | Possible values are: `original`, `contain`, `cover`, `fill`, `tile`. |
|
||||||
| `CanvasConnection` | [object](#canvasconnection) | **Yes** | | |
|
| `CanvasConnection` | [object](#canvasconnection) | **Yes** | | |
|
||||||
@ -37,7 +37,7 @@ title: CanvasPanelCfg kind
|
|||||||
### BackgroundConfig
|
### BackgroundConfig
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|----------|-----------------------------------------------------|----------|---------|----------------------------------------------------------------------|
|
| -------- | --------------------------------------------------- | -------- | ------- | -------------------------------------------------------------------- |
|
||||||
| `color` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
|
| `color` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
|
||||||
| `image` | [ResourceDimensionConfig](#resourcedimensionconfig) | No | | Links to a resource (image/svg path) |
|
| `image` | [ResourceDimensionConfig](#resourcedimensionconfig) | No | | Links to a resource (image/svg path) |
|
||||||
| `size` | string | No | | Possible values are: `original`, `contain`, `cover`, `fill`, `tile`. |
|
| `size` | string | No | | Possible values are: `original`, `contain`, `cover`, `fill`, `tile`. |
|
||||||
@ -47,14 +47,14 @@ title: CanvasPanelCfg kind
|
|||||||
It extends [BaseDimensionConfig](#basedimensionconfig).
|
It extends [BaseDimensionConfig](#basedimensionconfig).
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
|
| -------- | ------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------ |
|
||||||
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
|
| `field` | string | No | | _(Inherited from [BaseDimensionConfig](#basedimensionconfig))_<br/>fixed: T -- will be added by each element |
|
||||||
| `fixed` | string | No | | |
|
| `fixed` | string | No | | |
|
||||||
|
|
||||||
### BaseDimensionConfig
|
### BaseDimensionConfig
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|----------|--------|----------|---------|-------------------------------------------|
|
| -------- | ------ | -------- | ------- | ----------------------------------------- |
|
||||||
| `field` | string | No | | fixed: T -- will be added by each element |
|
| `field` | string | No | | fixed: T -- will be added by each element |
|
||||||
|
|
||||||
### ResourceDimensionConfig
|
### ResourceDimensionConfig
|
||||||
@ -64,15 +64,15 @@ Links to a resource (image/svg path)
|
|||||||
It extends [BaseDimensionConfig](#basedimensionconfig).
|
It extends [BaseDimensionConfig](#basedimensionconfig).
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
|
| -------- | ------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------ |
|
||||||
| `mode` | string | **Yes** | | Possible values are: `fixed`, `field`, `mapping`. |
|
| `mode` | string | **Yes** | | Possible values are: `fixed`, `field`, `mapping`. |
|
||||||
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
|
| `field` | string | No | | _(Inherited from [BaseDimensionConfig](#basedimensionconfig))_<br/>fixed: T -- will be added by each element |
|
||||||
| `fixed` | string | No | | |
|
| `fixed` | string | No | | |
|
||||||
|
|
||||||
### CanvasConnection
|
### CanvasConnection
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|--------------|-------------------------------------------------|----------|---------|----------------------------------|
|
| ------------ | ----------------------------------------------- | -------- | ------- | -------------------------------- |
|
||||||
| `path` | string | **Yes** | | Possible values are: `straight`. |
|
| `path` | string | **Yes** | | Possible values are: `straight`. |
|
||||||
| `source` | [ConnectionCoordinates](#connectioncoordinates) | **Yes** | | |
|
| `source` | [ConnectionCoordinates](#connectioncoordinates) | **Yes** | | |
|
||||||
| `target` | [ConnectionCoordinates](#connectioncoordinates) | **Yes** | | |
|
| `target` | [ConnectionCoordinates](#connectioncoordinates) | **Yes** | | |
|
||||||
@ -83,7 +83,7 @@ It extends [BaseDimensionConfig](#basedimensionconfig).
|
|||||||
### ConnectionCoordinates
|
### ConnectionCoordinates
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|----------|--------|----------|---------|-------------|
|
| -------- | ------ | -------- | ------- | ----------- |
|
||||||
| `x` | number | **Yes** | | |
|
| `x` | number | **Yes** | | |
|
||||||
| `y` | number | **Yes** | | |
|
| `y` | number | **Yes** | | |
|
||||||
|
|
||||||
@ -92,17 +92,17 @@ It extends [BaseDimensionConfig](#basedimensionconfig).
|
|||||||
It extends [BaseDimensionConfig](#basedimensionconfig).
|
It extends [BaseDimensionConfig](#basedimensionconfig).
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
|
| -------- | ------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------ |
|
||||||
| `max` | number | **Yes** | | |
|
| `max` | number | **Yes** | | |
|
||||||
| `min` | number | **Yes** | | |
|
| `min` | number | **Yes** | | |
|
||||||
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
|
| `field` | string | No | | _(Inherited from [BaseDimensionConfig](#basedimensionconfig))_<br/>fixed: T -- will be added by each element |
|
||||||
| `fixed` | number | No | | |
|
| `fixed` | number | No | | |
|
||||||
| `mode` | string | No | | Possible values are: `linear`, `quad`. |
|
| `mode` | string | No | | Possible values are: `linear`, `quad`. |
|
||||||
|
|
||||||
### CanvasElementOptions
|
### CanvasElementOptions
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|---------------|-----------------------------------------|----------|---------|---------------------------------------------------------|
|
| ------------- | --------------------------------------- | -------- | ------- | ------------------------------------------------------- |
|
||||||
| `name` | string | **Yes** | | |
|
| `name` | string | **Yes** | | |
|
||||||
| `type` | string | **Yes** | | |
|
| `type` | string | **Yes** | | |
|
||||||
| `background` | [BackgroundConfig](#backgroundconfig) | No | | |
|
| `background` | [BackgroundConfig](#backgroundconfig) | No | | |
|
||||||
@ -115,21 +115,21 @@ It extends [BaseDimensionConfig](#basedimensionconfig).
|
|||||||
### Constraint
|
### Constraint
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|--------------|--------|----------|---------|-----------------------------------------------------------------------|
|
| ------------ | ------ | -------- | ------- | --------------------------------------------------------------------- |
|
||||||
| `horizontal` | string | No | | Possible values are: `left`, `right`, `leftright`, `center`, `scale`. |
|
| `horizontal` | string | No | | Possible values are: `left`, `right`, `leftright`, `center`, `scale`. |
|
||||||
| `vertical` | string | No | | Possible values are: `top`, `bottom`, `topbottom`, `center`, `scale`. |
|
| `vertical` | string | No | | Possible values are: `top`, `bottom`, `topbottom`, `center`, `scale`. |
|
||||||
|
|
||||||
### LineConfig
|
### LineConfig
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|----------|-----------------------------------------------|----------|---------|-------------|
|
| -------- | --------------------------------------------- | -------- | ------- | ----------- |
|
||||||
| `color` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
|
| `color` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
|
||||||
| `width` | number | No | | |
|
| `width` | number | No | | |
|
||||||
|
|
||||||
### Placement
|
### Placement
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|----------|--------|----------|---------|-------------|
|
| -------- | ------ | -------- | ------- | ----------- |
|
||||||
| `bottom` | number | No | | |
|
| `bottom` | number | No | | |
|
||||||
| `height` | number | No | | |
|
| `height` | number | No | | |
|
||||||
| `left` | number | No | | |
|
| `left` | number | No | | |
|
||||||
@ -140,7 +140,8 @@ It extends [BaseDimensionConfig](#basedimensionconfig).
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|---------------------|-----------------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------|
|
| ------------------- | --------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
|
| `displayMiniMap` | boolean | **Yes** | `true` | Display mini map during zoom |
|
||||||
| `inlineEditing` | boolean | **Yes** | `true` | Enable inline editing |
|
| `inlineEditing` | boolean | **Yes** | `true` | Enable inline editing |
|
||||||
| `root` | [object](#root) | **Yes** | | The root element of canvas (frame), where all canvas elements are nested<br/>TODO: Figure out how to define a default value for this |
|
| `root` | [object](#root) | **Yes** | | The root element of canvas (frame), where all canvas elements are nested<br/>TODO: Figure out how to define a default value for this |
|
||||||
| `showAdvancedTypes` | boolean | **Yes** | `true` | Show all available element types |
|
| `showAdvancedTypes` | boolean | **Yes** | `true` | Show all available element types |
|
||||||
@ -151,9 +152,7 @@ The root element of canvas (frame), where all canvas elements are nested
|
|||||||
TODO: Figure out how to define a default value for this
|
TODO: Figure out how to define a default value for this
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|------------|-------------------------------------------------|----------|---------|----------------------------------------------------------------|
|
| ---------- | ----------------------------------------------- | -------- | ------- | -------------------------------------------------------------- |
|
||||||
| `elements` | [CanvasElementOptions](#canvaselementoptions)[] | **Yes** | | The list of canvas elements attached to the root element |
|
| `elements` | [CanvasElementOptions](#canvaselementoptions)[] | **Yes** | | The list of canvas elements attached to the root element |
|
||||||
| `name` | string | **Yes** | | Name of the root element |
|
| `name` | string | **Yes** | | Name of the root element |
|
||||||
| `type` | string | **Yes** | | Type of root element (frame)<br/>Possible values are: `frame`. |
|
| `type` | string | **Yes** | | Type of root element (frame)<br/>Possible values are: `frame`. |
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
import * as ui from '@grafana/schema';
|
import * as ui from '@grafana/schema';
|
||||||
|
|
||||||
export const pluginVersion = "10.3.0-pre";
|
export const pluginVersion = '10.3.0-pre';
|
||||||
|
|
||||||
export enum HorizontalConstraint {
|
export enum HorizontalConstraint {
|
||||||
Center = 'center',
|
Center = 'center',
|
||||||
@ -105,6 +105,10 @@ export const defaultCanvasElementOptions: Partial<CanvasElementOptions> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
|
/**
|
||||||
|
* Display mini map during zoom
|
||||||
|
*/
|
||||||
|
displayMiniMap: boolean;
|
||||||
/**
|
/**
|
||||||
* Enable inline editing
|
* Enable inline editing
|
||||||
*/
|
*/
|
||||||
@ -134,6 +138,7 @@ export interface Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const defaultOptions: Partial<Options> = {
|
export const defaultOptions: Partial<Options> = {
|
||||||
|
displayMiniMap: true,
|
||||||
inlineEditing: true,
|
inlineEditing: true,
|
||||||
showAdvancedTypes: true,
|
showAdvancedTypes: true,
|
||||||
};
|
};
|
||||||
|
@ -68,6 +68,7 @@ export class Scene {
|
|||||||
currentLayer?: FrameState;
|
currentLayer?: FrameState;
|
||||||
isEditingEnabled?: boolean;
|
isEditingEnabled?: boolean;
|
||||||
shouldShowAdvancedTypes?: boolean;
|
shouldShowAdvancedTypes?: boolean;
|
||||||
|
shouldDisplayMiniMap?: boolean;
|
||||||
skipNextSelectionBroadcast = false;
|
skipNextSelectionBroadcast = false;
|
||||||
ignoreDataUpdate = false;
|
ignoreDataUpdate = false;
|
||||||
panel: CanvasPanel;
|
panel: CanvasPanel;
|
||||||
@ -104,10 +105,11 @@ export class Scene {
|
|||||||
cfg: CanvasFrameOptions,
|
cfg: CanvasFrameOptions,
|
||||||
enableEditing: boolean,
|
enableEditing: boolean,
|
||||||
showAdvancedTypes: boolean,
|
showAdvancedTypes: boolean,
|
||||||
|
displayMiniMap: boolean,
|
||||||
public onSave: (cfg: CanvasFrameOptions) => void,
|
public onSave: (cfg: CanvasFrameOptions) => void,
|
||||||
panel: CanvasPanel
|
panel: CanvasPanel
|
||||||
) {
|
) {
|
||||||
this.root = this.load(cfg, enableEditing, showAdvancedTypes);
|
this.root = this.load(cfg, enableEditing, showAdvancedTypes, displayMiniMap);
|
||||||
|
|
||||||
this.subscription = this.editModeEnabled.subscribe((open) => {
|
this.subscription = this.editModeEnabled.subscribe((open) => {
|
||||||
if (!this.moveable || !this.isEditingEnabled) {
|
if (!this.moveable || !this.isEditingEnabled) {
|
||||||
@ -140,7 +142,7 @@ export class Scene {
|
|||||||
return !this.byName.has(v);
|
return !this.byName.has(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
load(cfg: CanvasFrameOptions, enableEditing: boolean, showAdvancedTypes: boolean) {
|
load(cfg: CanvasFrameOptions, enableEditing: boolean, showAdvancedTypes: boolean, displayMiniMap: boolean) {
|
||||||
this.root = new RootElement(
|
this.root = new RootElement(
|
||||||
cfg ?? {
|
cfg ?? {
|
||||||
type: 'frame',
|
type: 'frame',
|
||||||
@ -152,6 +154,7 @@ export class Scene {
|
|||||||
|
|
||||||
this.isEditingEnabled = enableEditing;
|
this.isEditingEnabled = enableEditing;
|
||||||
this.shouldShowAdvancedTypes = showAdvancedTypes;
|
this.shouldShowAdvancedTypes = showAdvancedTypes;
|
||||||
|
this.shouldDisplayMiniMap = displayMiniMap;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.div) {
|
if (this.div) {
|
||||||
@ -730,9 +733,11 @@ export class Scene {
|
|||||||
right: '0px',
|
right: '0px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{this.shouldDisplayMiniMap && (
|
||||||
<MiniMap width={200} borderColor={config.theme2.colors.border.weak}>
|
<MiniMap width={200} borderColor={config.theme2.colors.border.weak}>
|
||||||
{element}
|
{element}
|
||||||
</MiniMap>
|
</MiniMap>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<TransformComponent>{element}</TransformComponent>
|
<TransformComponent>{element}</TransformComponent>
|
||||||
</TransformWrapper>
|
</TransformWrapper>
|
||||||
|
@ -67,6 +67,7 @@ export class CanvasPanel extends Component<Props, State> {
|
|||||||
this.props.options.root,
|
this.props.options.root,
|
||||||
this.props.options.inlineEditing,
|
this.props.options.inlineEditing,
|
||||||
this.props.options.showAdvancedTypes,
|
this.props.options.showAdvancedTypes,
|
||||||
|
this.props.options.displayMiniMap,
|
||||||
this.onUpdateScene,
|
this.onUpdateScene,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
@ -227,14 +228,20 @@ export class CanvasPanel extends Component<Props, State> {
|
|||||||
const inlineEditingSwitched = this.props.options.inlineEditing !== nextProps.options.inlineEditing;
|
const inlineEditingSwitched = this.props.options.inlineEditing !== nextProps.options.inlineEditing;
|
||||||
const shouldShowAdvancedTypesSwitched =
|
const shouldShowAdvancedTypesSwitched =
|
||||||
this.props.options.showAdvancedTypes !== nextProps.options.showAdvancedTypes;
|
this.props.options.showAdvancedTypes !== nextProps.options.showAdvancedTypes;
|
||||||
if (this.needsReload || inlineEditingSwitched || shouldShowAdvancedTypesSwitched) {
|
const displayMiniMapSwitched = this.props.options.displayMiniMap !== nextProps.options.displayMiniMap;
|
||||||
|
if (this.needsReload || inlineEditingSwitched || shouldShowAdvancedTypesSwitched || displayMiniMapSwitched) {
|
||||||
if (inlineEditingSwitched) {
|
if (inlineEditingSwitched) {
|
||||||
// Replace scene div to prevent selecto instance leaks
|
// Replace scene div to prevent selecto instance leaks
|
||||||
this.scene.revId++;
|
this.scene.revId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.needsReload = false;
|
this.needsReload = false;
|
||||||
this.scene.load(nextProps.options.root, nextProps.options.inlineEditing, nextProps.options.showAdvancedTypes);
|
this.scene.load(
|
||||||
|
nextProps.options.root,
|
||||||
|
nextProps.options.inlineEditing,
|
||||||
|
nextProps.options.showAdvancedTypes,
|
||||||
|
nextProps.options.displayMiniMap
|
||||||
|
);
|
||||||
this.scene.updateSize(nextProps.width, nextProps.height);
|
this.scene.updateSize(nextProps.width, nextProps.height);
|
||||||
this.scene.updateData(nextProps.data);
|
this.scene.updateData(nextProps.data);
|
||||||
changed = true;
|
changed = true;
|
||||||
|
@ -22,6 +22,13 @@ export const addStandardCanvasEditorOptions = (builder: PanelOptionsEditorBuilde
|
|||||||
description: 'Enable selection of experimental element types',
|
description: 'Enable selection of experimental element types',
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.addBooleanSwitch({
|
||||||
|
path: 'displayMiniMap',
|
||||||
|
name: 'Mini Map',
|
||||||
|
description: 'Display mini map during zoom',
|
||||||
|
defaultValue: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const plugin = new PanelPlugin<Options>(CanvasPanel)
|
export const plugin = new PanelPlugin<Options>(CanvasPanel)
|
||||||
|
@ -88,6 +88,8 @@ composableKinds: PanelCfg: {
|
|||||||
inlineEditing: bool | *true
|
inlineEditing: bool | *true
|
||||||
// Show all available element types
|
// Show all available element types
|
||||||
showAdvancedTypes: bool | *true
|
showAdvancedTypes: bool | *true
|
||||||
|
// Display mini map during zoom
|
||||||
|
displayMiniMap: bool | *true
|
||||||
// The root element of canvas (frame), where all canvas elements are nested
|
// The root element of canvas (frame), where all canvas elements are nested
|
||||||
// TODO: Figure out how to define a default value for this
|
// TODO: Figure out how to define a default value for this
|
||||||
root: {
|
root: {
|
||||||
|
@ -102,6 +102,10 @@ export const defaultCanvasElementOptions: Partial<CanvasElementOptions> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
|
/**
|
||||||
|
* Display mini map during zoom
|
||||||
|
*/
|
||||||
|
displayMiniMap: boolean;
|
||||||
/**
|
/**
|
||||||
* Enable inline editing
|
* Enable inline editing
|
||||||
*/
|
*/
|
||||||
@ -131,6 +135,7 @@ export interface Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const defaultOptions: Partial<Options> = {
|
export const defaultOptions: Partial<Options> = {
|
||||||
|
displayMiniMap: true,
|
||||||
inlineEditing: true,
|
inlineEditing: true,
|
||||||
showAdvancedTypes: true,
|
showAdvancedTypes: true,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user