grafana/public/app/plugins/panel/nodeGraph/module.tsx

96 lines
3.6 KiB
TypeScript
Raw Normal View History

import { FieldConfigProperty, PanelPlugin } from '@grafana/data';
import { t } from '@grafana/i18n';
NodeGraph: Add node graph visualization (#29706) * Add GraphView component * Add service map panel * Add more metadata visuals * Add context menu on click * Add context menu for services * Fix service map in dashboard * Add field proxy in explore linkSupplier * Refactor the link creation * Remove test file * Fix scale change when view is panned * Fix node centering * Don't show context menu if no links * Fix service map containers * Add collapsible around the service map * Fix stats computation * Remove debug log * Fix time stats * Allow string timestamp * Make panning bounded * Add zooming by mouse wheel * Clean up the colors * Fix stats for single trace graph * Don't show debug config * Add more complex layout * Update layout with better fixing of the root nodes * Code cleanup * Change how we pass in link creation function and some more cleanup * Refactor the panel section into separate render methods * Make the edge hover more readable * Move stats computation to data source * Put edge labels to front * Simplify layout for better multi graph layout * Update for dark theme * Move function to utils * Visual improvements * Improve context menu detail * Allow custom details * Rename to NodeGraph * Remove unused dependencies * Use named color palette and add some fallbacks for missing data * Add test data scenario * Rename plugin * Switch scroll zoom direction to align with google maps * Do some perf optimisations and rise the node limit * Update alert styling * Rename function * Add tests * Add more tests * Change data frame column mapping to use column names * Fix test * Fix type errors * Don't show context menu without links * Add beta status to panel * Fix tests * Changed function to standard methods * Fix typing * Clean up yarn.lock * Add some UI improvements - better styling of the zoom buttons - disable buttons when max reached * Fix panel references after rename * Add panel icon
2021-01-19 23:34:43 +08:00
import { NodeGraphPanel } from './NodeGraphPanel';
import { ArcOptionsEditor } from './editor/ArcOptionsEditor';
import { LayoutAlgorithm, Options as NodeGraphOptions } from './panelcfg.gen';
import { NodeGraphSuggestionsSupplier } from './suggestions';
NodeGraph: Add node graph visualization (#29706) * Add GraphView component * Add service map panel * Add more metadata visuals * Add context menu on click * Add context menu for services * Fix service map in dashboard * Add field proxy in explore linkSupplier * Refactor the link creation * Remove test file * Fix scale change when view is panned * Fix node centering * Don't show context menu if no links * Fix service map containers * Add collapsible around the service map * Fix stats computation * Remove debug log * Fix time stats * Allow string timestamp * Make panning bounded * Add zooming by mouse wheel * Clean up the colors * Fix stats for single trace graph * Don't show debug config * Add more complex layout * Update layout with better fixing of the root nodes * Code cleanup * Change how we pass in link creation function and some more cleanup * Refactor the panel section into separate render methods * Make the edge hover more readable * Move stats computation to data source * Put edge labels to front * Simplify layout for better multi graph layout * Update for dark theme * Move function to utils * Visual improvements * Improve context menu detail * Allow custom details * Rename to NodeGraph * Remove unused dependencies * Use named color palette and add some fallbacks for missing data * Add test data scenario * Rename plugin * Switch scroll zoom direction to align with google maps * Do some perf optimisations and rise the node limit * Update alert styling * Rename function * Add tests * Add more tests * Change data frame column mapping to use column names * Fix test * Fix type errors * Don't show context menu without links * Add beta status to panel * Fix tests * Changed function to standard methods * Fix typing * Clean up yarn.lock * Add some UI improvements - better styling of the zoom buttons - disable buttons when max reached * Fix panel references after rename * Add panel icon
2021-01-19 23:34:43 +08:00
export const plugin = new PanelPlugin<NodeGraphOptions>(NodeGraphPanel)
.useFieldConfig({
disableStandardOptions: Object.values(FieldConfigProperty).filter((v) => v !== FieldConfigProperty.Links),
})
.setPanelOptions((builder, context) => {
const category = [t('node-graph.category-node-graph', 'Node graph')];
builder.addSelect({
name: t('node-graph.name-zoom-mode', 'Zoom mode'),
category,
path: 'zoomMode',
defaultValue: 'cooperative',
settings: {
options: [
{
value: 'cooperative',
label: t('node-graph.zoom-mode-options.label-cooperative', 'Cooperative'),
description: t('node-graph.zoom-mode-options.description-cooperative', 'Lets you scroll the page normally'),
},
{
value: 'greedy',
label: t('node-graph.zoom-mode-options.label-greedy', 'Greedy'),
description: t('node-graph.zoom-mode-options.description-greedy', 'Reacts to all zoom gestures'),
},
],
},
});
builder.addSelect({
name: t('node-graph.name-layout-algorithm', 'Layout algorithm'),
category,
path: 'layoutAlgorithm',
defaultValue: LayoutAlgorithm.Layered,
settings: {
options: [
{
label: t('node-graph.layout-algorithm-options.label-layered', 'Layered'),
value: LayoutAlgorithm.Layered,
description: t('node-graph.layout-algorithm-options.description-layered', 'Use a layered layout'),
},
{
label: t('node-graph.layout-algorithm-options.label-force', 'Force'),
value: LayoutAlgorithm.Force,
description: t('node-graph.layout-algorithm-options.description-force', 'Use a force-directed layout'),
},
{
label: t('node-graph.layout-algorithm-options.label-grid', 'Grid'),
value: LayoutAlgorithm.Grid,
description: t('node-graph.layout-algorithm-options.description-grid', 'Use a grid layout'),
},
],
},
});
builder.addNestedOptions({
category: [t('node-graph.category-nodes', 'Nodes')],
path: 'nodes',
build: (builder) => {
builder.addUnitPicker({
name: t('node-graph.name-main-stat-unit', 'Main stat unit'),
path: 'mainStatUnit',
});
builder.addUnitPicker({
name: t('node-graph.name-secondary-stat-unit', 'Secondary stat unit'),
path: 'secondaryStatUnit',
});
builder.addCustomEditor({
name: t('node-graph.name-arc-sections', 'Arc sections'),
path: 'arcs',
id: 'arcs',
editor: ArcOptionsEditor,
});
},
});
builder.addNestedOptions({
category: [t('node-graph.category-edges', 'Edges')],
path: 'edges',
build: (builder) => {
builder.addUnitPicker({
name: t('node-graph.name-main-stat-unit', 'Main stat unit'),
path: 'mainStatUnit',
});
builder.addUnitPicker({
name: t('node-graph.name-secondary-stat-unit', 'Secondary stat unit'),
path: 'secondaryStatUnit',
});
},
});
})
.setSuggestionsSupplier(new NodeGraphSuggestionsSupplier());