From 1b8a88e857b001a616725190609ac29f2cd97d26 Mon Sep 17 00:00:00 2001 From: Allen Short Date: Thu, 25 Oct 2018 22:49:29 -0500 Subject: [PATCH] register new visualization components --- client/app/config/index.js | 6 +- client/app/visualizations/chart/index.js | 12 +++ client/app/visualizations/choropleth/index.js | 10 ++ client/app/visualizations/cohort/index.js | 10 ++ client/app/visualizations/counter/index.js | 10 ++ client/app/visualizations/funnel/index.js | 10 ++ client/app/visualizations/map/index.js | 10 ++ client/app/visualizations/pivot/index.js | 10 ++ client/app/visualizations/registry.js | 92 +------------------ client/app/visualizations/sankey/index.js | 10 ++ client/app/visualizations/sunburst/index.js | 10 ++ client/app/visualizations/table/index.js | 12 +++ client/app/visualizations/word-cloud/index.js | 10 ++ 13 files changed, 120 insertions(+), 92 deletions(-) create mode 100644 client/app/visualizations/chart/index.js create mode 100644 client/app/visualizations/choropleth/index.js create mode 100644 client/app/visualizations/cohort/index.js create mode 100644 client/app/visualizations/counter/index.js create mode 100644 client/app/visualizations/funnel/index.js create mode 100644 client/app/visualizations/map/index.js create mode 100644 client/app/visualizations/pivot/index.js create mode 100644 client/app/visualizations/sankey/index.js create mode 100644 client/app/visualizations/sunburst/index.js create mode 100644 client/app/visualizations/table/index.js create mode 100644 client/app/visualizations/word-cloud/index.js diff --git a/client/app/config/index.js b/client/app/config/index.js index 5ec08f9b1f..99055a9af7 100644 --- a/client/app/config/index.js +++ b/client/app/config/index.js @@ -28,7 +28,6 @@ import * as filters from '@/filters'; import registerDirectives from '@/directives'; import markdownFilter from '@/filters/markdown'; import dateTimeFilter from '@/filters/datetime'; -import registerVisualizations from '@/visualizations'; import dashboardGridOptions from './dashboard-grid-options'; const logger = debug('redash:config'); @@ -93,6 +92,11 @@ function registerServices() { registerAll(context); } +function registerVisualizations() { + const context = require.context('@/visualizations', true, /^((?![\\/.]test[\\./]).)*\.js?$/); + registerAll(context); +} + function registerPages() { const context = require.context('@/pages', true, /^((?![\\/.]test[\\./]).)*\.js$/); const routesCollection = registerAll(context); diff --git a/client/app/visualizations/chart/index.js b/client/app/visualizations/chart/index.js new file mode 100644 index 0000000000..86c5e72ead --- /dev/null +++ b/client/app/visualizations/chart/index.js @@ -0,0 +1,12 @@ +import registry from '@/visualizations/registry'; +import ChartRenderer from './ChartRenderer'; +import ChartEditor from './ChartEditor'; + +export default function () { + registry.CHART = Object.freeze({ + name: 'Chart', + renderer: ChartRenderer, + editor: ChartEditor, + defaultOptions: ChartRenderer.DEFAULT_OPTIONS, + }); +} diff --git a/client/app/visualizations/choropleth/index.js b/client/app/visualizations/choropleth/index.js new file mode 100644 index 0000000000..a574dc407e --- /dev/null +++ b/client/app/visualizations/choropleth/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import ChoroplethRenderer from './ChoroplethRenderer'; +import ChoroplethEditor from './ChoroplethEditor'; + +registry.CHOROPLETH = Object.freeze({ + name: 'Map (Choropleth)', + renderer: ChoroplethRenderer, + editor: ChoroplethEditor, + defaultOptions: ChoroplethRenderer.DEFAULT_OPTIONS, +}); diff --git a/client/app/visualizations/cohort/index.js b/client/app/visualizations/cohort/index.js new file mode 100644 index 0000000000..49f119d667 --- /dev/null +++ b/client/app/visualizations/cohort/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import CohortRenderer from './CohortRenderer'; +import CohortEditor from './CohortEditor'; + +registry.COHORT = Object.freeze({ + name: 'Cohort', + renderer: CohortRenderer, + editor: CohortEditor, + defaultOptions: CohortRenderer.DEFAULT_OPTIONS, +}); diff --git a/client/app/visualizations/counter/index.js b/client/app/visualizations/counter/index.js new file mode 100644 index 0000000000..dc284123b3 --- /dev/null +++ b/client/app/visualizations/counter/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import CounterRenderer from './CounterRenderer'; +import CounterEditor from './CounterEditor'; + +registry.COUNTER = Object.freeze({ + name: 'Counter', + renderer: CounterRenderer, + editor: CounterEditor, + defaultOptions: CounterRenderer.DEFAULT_OPTIONS, +}); diff --git a/client/app/visualizations/funnel/index.js b/client/app/visualizations/funnel/index.js new file mode 100644 index 0000000000..f4a8d5073c --- /dev/null +++ b/client/app/visualizations/funnel/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import FunnelRenderer from './FunnelRenderer'; +import FunnelEditor from './FunnelEditor'; + +registry.FUNNEL = Object.freeze({ + name: 'Funnel', + renderer: FunnelRenderer, + editor: FunnelEditor, + defaultOptions: FunnelRenderer.DEFAULT_OPTIONS, +}); diff --git a/client/app/visualizations/map/index.js b/client/app/visualizations/map/index.js new file mode 100644 index 0000000000..b3ccb36519 --- /dev/null +++ b/client/app/visualizations/map/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import MapRenderer from './MapRenderer'; +import MapEditor from './MapEditor'; + +registry.MAP = Object.freeze({ + name: 'Map (Markers)', + renderer: MapRenderer, + editor: MapEditor, + defaultOptions: MapRenderer.DEFAULT_OPTIONS, +}); diff --git a/client/app/visualizations/pivot/index.js b/client/app/visualizations/pivot/index.js new file mode 100644 index 0000000000..89bfd441a2 --- /dev/null +++ b/client/app/visualizations/pivot/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import PivotRenderer from './PivotRenderer'; +import PivotEditor from './PivotEditor'; + +registry.PIVOT = Object.freeze({ + name: 'Pivot Table', + renderer: PivotRenderer, + editor: PivotEditor, + defaultOptions: PivotRenderer.DEFAULT_OPTIONS, +}); diff --git a/client/app/visualizations/registry.js b/client/app/visualizations/registry.js index c313bcc2fc..fa854c0794 100644 --- a/client/app/visualizations/registry.js +++ b/client/app/visualizations/registry.js @@ -1,92 +1,2 @@ -import ChartRenderer from './chart/ChartRenderer'; -import ChartEditor from './chart/ChartEditor'; -import GridRenderer from './table/GridRenderer'; -import GridEditor from './table/GridEditor'; -import ChoroplethRenderer from './choropleth/ChoroplethRenderer'; -import ChoroplethEditor from './choropleth/ChoroplethEditor'; -import CohortRenderer from './cohort/CohortRenderer'; -import CohortEditor from './cohort/CohortEditor'; -import CounterRenderer from './counter/CounterRenderer'; -import CounterEditor from './counter/CounterEditor'; -import FunnelRenderer from './funnel/FunnelRenderer'; -import FunnelEditor from './funnel/FunnelEditor'; -import MapRenderer from './map/MapRenderer'; -import MapEditor from './map/MapEditor'; -import PivotRenderer from './pivot/PivotRenderer'; -import PivotEditor from './pivot/PivotEditor'; -import SankeyRenderer from './sankey/SankeyRenderer'; -import SankeyEditor from './sankey/SankeyEditor'; -import SunburstRenderer from './sunburst/SunburstRenderer'; -import SunburstEditor from './sunburst/SunburstEditor'; -import WordCloudRenderer from './word-cloud/WordCloudRenderer'; -import WordCloudEditor from './word-cloud/WordCloudEditor'; -const visualizationRegistry = { - CHART: Object.freeze({ - name: 'Chart', - renderer: ChartRenderer, - editor: ChartEditor, - defaultOptions: ChartRenderer.DEFAULT_OPTIONS, - }), - TABLE: Object.freeze({ - name: 'Table', - renderer: GridRenderer, - editor: GridEditor, - defaultOptions: GridRenderer.DEFAULT_OPTIONS, - }), - CHOROPLETH: Object.freeze({ - name: 'Map (Choropleth)', - renderer: ChoroplethRenderer, - editor: ChoroplethEditor, - defaultOptions: ChoroplethRenderer.DEFAULT_OPTIONS, - }), - COHORT: Object.freeze({ - name: 'Cohort', - renderer: CohortRenderer, - editor: CohortEditor, - defaultOptions: CohortRenderer.DEFAULT_OPTIONS, - }), - COUNTER: Object.freeze({ - name: 'Counter', - renderer: CounterRenderer, - editor: CounterEditor, - defaultOptions: CounterRenderer.DEFAULT_OPTIONS, - }), - FUNNEL: Object.freeze({ - name: 'Funnel', - renderer: FunnelRenderer, - editor: FunnelEditor, - defaultOptions: FunnelRenderer.DEFAULT_OPTIONS, - }), - MAP: Object.freeze({ - name: 'Map (Markers)', - renderer: MapRenderer, - editor: MapEditor, - defaultOptions: MapRenderer.DEFAULT_OPTIONS, - }), - PIVOT: Object.freeze({ - name: 'Pivot Table', - renderer: PivotRenderer, - editor: PivotEditor, - defaultOptions: PivotRenderer.DEFAULT_OPTIONS, - }), - SANKEY: Object.freeze({ - name: 'Sankey', - renderer: SankeyRenderer, - editor: SankeyEditor, - defaultOptions: SankeyRenderer.DEFAULT_OPTIONS, - }), - SUNBURST_SEQUENCE: Object.freeze({ - name: 'Sunburst Sequence', - renderer: SunburstRenderer, - editor: SunburstEditor, - defaultOptions: SunburstRenderer.DEFAULT_OPTIONS, - }), - WORD_CLOUD: Object.freeze({ - name: 'Word Cloud', - renderer: WordCloudRenderer, - editor: WordCloudEditor, - defaultOptions: WordCloudRenderer.DEFAULT_OPTIONS, - }), -}; -export default Object.freeze(visualizationRegistry); +export default {}; diff --git a/client/app/visualizations/sankey/index.js b/client/app/visualizations/sankey/index.js new file mode 100644 index 0000000000..1eb919a433 --- /dev/null +++ b/client/app/visualizations/sankey/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import SankeyRenderer from './SankeyRenderer'; +import SankeyEditor from './SankeyEditor'; + +registry.SANKEY = Object.freeze({ + name: 'Sankey', + renderer: SankeyRenderer, + editor: SankeyEditor, + defaultOptions: SankeyRenderer.DEFAULT_OPTIONS, +}); diff --git a/client/app/visualizations/sunburst/index.js b/client/app/visualizations/sunburst/index.js new file mode 100644 index 0000000000..42f791db00 --- /dev/null +++ b/client/app/visualizations/sunburst/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import SunburstRenderer from './SunburstRenderer'; +import SunburstEditor from './SunburstEditor'; + +registry.SUNBURST_SEQUENCE = Object.freeze({ + name: 'Sunburst Sequence', + renderer: SunburstRenderer, + editor: SunburstEditor, + defaultOptions: SunburstRenderer.DEFAULT_OPTIONS, +}); diff --git a/client/app/visualizations/table/index.js b/client/app/visualizations/table/index.js new file mode 100644 index 0000000000..d5fa998abb --- /dev/null +++ b/client/app/visualizations/table/index.js @@ -0,0 +1,12 @@ +import registry from '@/visualizations/registry'; +import GridRenderer from './GridRenderer'; +import GridEditor from './GridEditor'; + +export default function () { + registry.TABLE = Object.freeze({ + name: 'Table', + renderer: GridRenderer, + editor: GridEditor, + defaultOptions: GridRenderer.DEFAULT_OPTIONS, + }); +} diff --git a/client/app/visualizations/word-cloud/index.js b/client/app/visualizations/word-cloud/index.js new file mode 100644 index 0000000000..aca491c30e --- /dev/null +++ b/client/app/visualizations/word-cloud/index.js @@ -0,0 +1,10 @@ +import registry from '@/visualizations/registry'; +import WordCloudRenderer from './WordCloudRenderer'; +import WordCloudEditor from './WordCloudEditor'; + +registry.WORD_CLOUD = Object.freeze({ + name: 'Word Cloud', + renderer: WordCloudRenderer, + editor: WordCloudEditor, + defaultOptions: WordCloudRenderer.DEFAULT_OPTIONS, +});