@devtable/dashboard 2.4.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +25 -1
  2. package/dist/api-caller/index.d.ts +13 -7
  3. package/dist/api-caller/types.d.ts +1 -1
  4. package/dist/contexts/index.d.ts +1 -3
  5. package/dist/contexts/model-context.d.ts +24165 -0
  6. package/dist/contexts/panel-context.d.ts +0 -1
  7. package/dist/dashboard.es.js +9680 -15352
  8. package/dist/dashboard.umd.js +38 -19
  9. package/dist/definition-editor/data-editor-modal.d.ts +2 -2
  10. package/dist/definition-editor/global-variables-guide.d.ts +2 -2
  11. package/dist/definition-editor/query-editor/data-preview.d.ts +3 -3
  12. package/dist/definition-editor/query-editor/editor.d.ts +1 -1
  13. package/dist/definition-editor/query-editor/form.d.ts +4 -5
  14. package/dist/definition-editor/query-editor/index.d.ts +2 -2
  15. package/dist/definition-editor/query-editor/select-or-add-query.d.ts +1 -1
  16. package/dist/definition-editor/sql-snippet-editor/editor.d.ts +2 -2
  17. package/dist/filter/filter-checkbox/editor.d.ts +1 -1
  18. package/dist/filter/filter-checkbox/render.d.ts +1 -1
  19. package/dist/filter/filter-date-range/editor.d.ts +1 -1
  20. package/dist/filter/filter-date-range/render.d.ts +1 -1
  21. package/dist/filter/filter-multi-select/editor.d.ts +1 -1
  22. package/dist/filter/filter-multi-select/render.d.ts +1 -1
  23. package/dist/filter/filter-query-field/index.d.ts +1 -1
  24. package/dist/filter/filter-query-field/select-data-source.d.ts +1 -1
  25. package/dist/filter/filter-query-field/test-query.d.ts +1 -1
  26. package/dist/filter/filter-select/editor.d.ts +1 -1
  27. package/dist/filter/filter-select/render.d.ts +1 -1
  28. package/dist/filter/filter-settings/filter-settings.d.ts +0 -2
  29. package/dist/filter/filter-settings/index.d.ts +2 -4
  30. package/dist/filter/filter-text-input/editor.d.ts +1 -1
  31. package/dist/filter/filter-text-input/render.d.ts +1 -1
  32. package/dist/filter/index.d.ts +2 -6
  33. package/dist/index.d.ts +1 -0
  34. package/dist/layout/index.d.ts +1 -1
  35. package/dist/layout/read-only.d.ts +2 -2
  36. package/dist/main/actions.d.ts +1 -3
  37. package/dist/main/full-screen-panel.d.ts +2 -2
  38. package/dist/main/main.d.ts +2 -2
  39. package/dist/main/read-only.d.ts +2 -2
  40. package/dist/main/use-sticky-area-style.d.ts +1 -0
  41. package/dist/model/context.d.ts +11 -0
  42. package/dist/model/dashboard.d.ts +8579 -684
  43. package/dist/model/{filter → filters/filter}/checkbox.d.ts +0 -0
  44. package/dist/model/{filter → filters/filter}/common.d.ts +0 -0
  45. package/dist/model/{filter → filters/filter}/date-range.d.ts +0 -0
  46. package/dist/model/{filter → filters/filter}/index.d.ts +0 -0
  47. package/dist/model/{filter → filters/filter}/multi-select.d.ts +0 -0
  48. package/dist/model/{filter → filters/filter}/select.d.ts +0 -0
  49. package/dist/model/{filter → filters/filter}/text-input.d.ts +0 -0
  50. package/dist/{main/use-filters.d.ts → model/filters/index.d.ts} +1430 -16
  51. package/dist/model/index.d.ts +4 -1
  52. package/dist/model/queries/index.d.ts +116 -0
  53. package/dist/model/queries/mute-query.d.ts +17 -0
  54. package/dist/model/queries/query.d.ts +31 -0
  55. package/dist/model/queries/types.d.ts +5 -0
  56. package/dist/model/sql-snippets/index.d.ts +26 -0
  57. package/dist/model/sql-snippets/sql-snippet.d.ts +9 -0
  58. package/dist/panel/index.d.ts +2 -2
  59. package/dist/panel/plugin-adaptor.d.ts +7 -0
  60. package/dist/panel/settings/index.d.ts +2 -2
  61. package/dist/panel/settings/pick-query/index.d.ts +2 -2
  62. package/dist/panel/title-bar.d.ts +2 -2
  63. package/dist/panel/viz/index.d.ts +3 -3
  64. package/dist/plugins/hooks/index.d.ts +2 -0
  65. package/dist/plugins/hooks/use-channel-event.d.ts +2 -0
  66. package/dist/plugins/hooks/use-storage-data.d.ts +6 -0
  67. package/dist/plugins/index.d.ts +4 -0
  68. package/dist/plugins/json-plugin-storage.d.ts +12 -0
  69. package/dist/plugins/message-channels.d.ts +7 -0
  70. package/dist/plugins/plugin-context.d.ts +12 -0
  71. package/dist/plugins/plugin-data-migrator/index.d.ts +1 -0
  72. package/dist/plugins/plugin-data-migrator/plugin-data-migrator.d.ts +13 -0
  73. package/dist/plugins/plugin-manager.d.ts +18 -0
  74. package/dist/plugins/viz-components/table/index.d.ts +2 -0
  75. package/dist/{panel/viz → plugins/viz-components}/table/type.d.ts +1 -0
  76. package/dist/{panel/viz → plugins/viz-components}/table/value-type-selector.d.ts +0 -0
  77. package/dist/{panel/viz → plugins/viz-components}/table/value.d.ts +0 -0
  78. package/dist/plugins/viz-components/table/viz-table-panel.d.ts +3 -0
  79. package/dist/plugins/viz-components/table/viz-table.d.ts +3 -0
  80. package/dist/plugins/viz-manager/components.d.ts +22 -0
  81. package/dist/plugins/viz-manager/impl.d.ts +10 -0
  82. package/dist/plugins/viz-manager/index.d.ts +4 -0
  83. package/dist/plugins/viz-manager/types.d.ts +12 -0
  84. package/dist/style.css +1 -1
  85. package/dist/types/dashboard.d.ts +4 -12
  86. package/dist/types/plugin/index.d.ts +101 -0
  87. package/dist/utils/download.d.ts +6 -0
  88. package/dist/utils/sql.d.ts +7 -6
  89. package/package.json +25 -6
  90. package/dist/contexts/context-info-context.d.ts +0 -5
  91. package/dist/contexts/definition-context.d.ts +0 -7
  92. package/dist/contexts/filter-values-context.d.ts +0 -4
  93. package/dist/panel/viz/table/index.d.ts +0 -10
  94. package/dist/panel/viz/table/panel.d.ts +0 -3
@@ -1,2 +1,5 @@
1
+ export * from './filters';
2
+ export * from './queries';
3
+ export * from './sql-snippets';
4
+ export * from './context';
1
5
  export * from './dashboard';
2
- export * from './filter';
@@ -0,0 +1,116 @@
1
+ import { QueryModelInstance } from './query';
2
+ export declare const QueriesModel: import("mobx-state-tree").IModelType<{
3
+ original: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
4
+ id: import("mobx-state-tree").ISimpleType<string>;
5
+ type: import("mobx-state-tree").ISimpleType<import("./types").DataSourceType>;
6
+ key: import("mobx-state-tree").ISimpleType<string>;
7
+ sql: import("mobx-state-tree").ISimpleType<string>;
8
+ }, {
9
+ readonly valid: string;
10
+ readonly configurations: {
11
+ id: string;
12
+ type: import("./types").DataSourceType;
13
+ key: string;
14
+ sql: string;
15
+ };
16
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>, [undefined]>;
17
+ current: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
18
+ id: import("mobx-state-tree").ISimpleType<string>;
19
+ type: import("mobx-state-tree").ISimpleType<import("./types").DataSourceType>;
20
+ key: import("mobx-state-tree").ISimpleType<string>;
21
+ sql: import("mobx-state-tree").ISimpleType<string>;
22
+ } & {
23
+ state: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"idle" | "loading" | "error">, [undefined]>;
24
+ data: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<Object, Object, Object>>, [undefined]>;
25
+ error: import("mobx-state-tree").IType<any, any, any>;
26
+ }, {
27
+ readonly valid: string;
28
+ readonly configurations: {
29
+ id: string;
30
+ type: import("./types").DataSourceType;
31
+ key: string;
32
+ sql: string;
33
+ };
34
+ } & {
35
+ readonly formattedSQL: any;
36
+ } & {
37
+ setID(id: string): void;
38
+ setKey(key: string): void;
39
+ setType(type: import("./types").DataSourceType): void;
40
+ setSQL(sql: string): void;
41
+ fetchData: () => Promise<void>;
42
+ } & {
43
+ afterCreate(): void;
44
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>, [undefined]>;
45
+ }, {
46
+ readonly changed: boolean;
47
+ readonly firstID: string | undefined;
48
+ findByID(id: string): ({
49
+ id: string;
50
+ type: import("./types").DataSourceType;
51
+ key: string;
52
+ sql: string;
53
+ state: "idle" | "loading" | "error";
54
+ data: import("mobx-state-tree").IMSTArray<import("mobx-state-tree").IType<Object, Object, Object>> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<Object, Object, Object>>, [undefined]>>;
55
+ error: any;
56
+ } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
57
+ readonly valid: string;
58
+ readonly configurations: {
59
+ id: string;
60
+ type: import("./types").DataSourceType;
61
+ key: string;
62
+ sql: string;
63
+ };
64
+ } & {
65
+ readonly formattedSQL: any;
66
+ } & {
67
+ setID(id: string): void;
68
+ setKey(key: string): void;
69
+ setType(type: import("./types").DataSourceType): void;
70
+ setSQL(sql: string): void;
71
+ fetchData: () => Promise<void>;
72
+ } & {
73
+ afterCreate(): void;
74
+ } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
75
+ id: import("mobx-state-tree").ISimpleType<string>;
76
+ type: import("mobx-state-tree").ISimpleType<import("./types").DataSourceType>;
77
+ key: import("mobx-state-tree").ISimpleType<string>;
78
+ sql: import("mobx-state-tree").ISimpleType<string>;
79
+ } & {
80
+ state: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"idle" | "loading" | "error">, [undefined]>;
81
+ data: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<Object, Object, Object>>, [undefined]>;
82
+ error: import("mobx-state-tree").IType<any, any, any>;
83
+ }, {
84
+ readonly valid: string;
85
+ readonly configurations: {
86
+ id: string;
87
+ type: import("./types").DataSourceType;
88
+ key: string;
89
+ sql: string;
90
+ };
91
+ } & {
92
+ readonly formattedSQL: any;
93
+ } & {
94
+ setID(id: string): void;
95
+ setKey(key: string): void;
96
+ setType(type: import("./types").DataSourceType): void;
97
+ setSQL(sql: string): void;
98
+ fetchData: () => Promise<void>;
99
+ } & {
100
+ afterCreate(): void;
101
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>) | undefined;
102
+ readonly options: {
103
+ value: string;
104
+ label: string;
105
+ }[];
106
+ } & {
107
+ reset(): void;
108
+ replace(current: Array<QueryModelInstance>): void;
109
+ append(item: QueryModelInstance): void;
110
+ remove(index: number): void;
111
+ replaceByIndex(index: number, replacement: QueryModelInstance): void;
112
+ downloadAllData(): void;
113
+ downloadDataByQueryID(queryID: string): void;
114
+ refetchDataByQueryID(queryID: string): Promise<void> | undefined;
115
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
116
+ export * from './query';
@@ -0,0 +1,17 @@
1
+ import { Instance } from 'mobx-state-tree';
2
+ import { DataSourceType } from './types';
3
+ export declare const MuteQueryModel: import("mobx-state-tree").IModelType<{
4
+ id: import("mobx-state-tree").ISimpleType<string>;
5
+ type: import("mobx-state-tree").ISimpleType<DataSourceType>;
6
+ key: import("mobx-state-tree").ISimpleType<string>;
7
+ sql: import("mobx-state-tree").ISimpleType<string>;
8
+ }, {
9
+ readonly valid: string;
10
+ readonly configurations: {
11
+ id: string;
12
+ type: DataSourceType;
13
+ key: string;
14
+ sql: string;
15
+ };
16
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
17
+ export declare type MuteQueryModelInstance = Instance<typeof MuteQueryModel>;
@@ -0,0 +1,31 @@
1
+ import { Instance } from 'mobx-state-tree';
2
+ import { DataSourceType } from './types';
3
+ export declare const QueryModel: import("mobx-state-tree").IModelType<{
4
+ id: import("mobx-state-tree").ISimpleType<string>;
5
+ type: import("mobx-state-tree").ISimpleType<DataSourceType>;
6
+ key: import("mobx-state-tree").ISimpleType<string>;
7
+ sql: import("mobx-state-tree").ISimpleType<string>;
8
+ } & {
9
+ state: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"idle" | "loading" | "error">, [undefined]>;
10
+ data: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<Object, Object, Object>>, [undefined]>;
11
+ error: import("mobx-state-tree").IType<any, any, any>;
12
+ }, {
13
+ readonly valid: string;
14
+ readonly configurations: {
15
+ id: string;
16
+ type: DataSourceType;
17
+ key: string;
18
+ sql: string;
19
+ };
20
+ } & {
21
+ readonly formattedSQL: any;
22
+ } & {
23
+ setID(id: string): void;
24
+ setKey(key: string): void;
25
+ setType(type: DataSourceType): void;
26
+ setSQL(sql: string): void;
27
+ fetchData: () => Promise<void>;
28
+ } & {
29
+ afterCreate(): void;
30
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
31
+ export declare type QueryModelInstance = Instance<typeof QueryModel>;
@@ -0,0 +1,5 @@
1
+ export declare enum DataSourceType {
2
+ Postgresql = "postgresql",
3
+ MySQL = "mysql",
4
+ HTTP = "http"
5
+ }
@@ -0,0 +1,26 @@
1
+ import { SQLSnippetModelInstance } from './sql-snippet';
2
+ export declare const SQLSnippetsModel: import("mobx-state-tree").IModelType<{
3
+ original: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
4
+ key: import("mobx-state-tree").ISimpleType<string>;
5
+ value: import("mobx-state-tree").ISimpleType<string>;
6
+ }, {
7
+ setKey(key: string): void;
8
+ setValue(value: string): void;
9
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>, [undefined]>;
10
+ current: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
11
+ key: import("mobx-state-tree").ISimpleType<string>;
12
+ value: import("mobx-state-tree").ISimpleType<string>;
13
+ }, {
14
+ setKey(key: string): void;
15
+ setValue(value: string): void;
16
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>, [undefined]>;
17
+ }, {
18
+ readonly changed: boolean;
19
+ } & {
20
+ reset(): void;
21
+ replace(current: Array<SQLSnippetModelInstance>): void;
22
+ append(item: SQLSnippetModelInstance): void;
23
+ remove(index: number): void;
24
+ replaceByIndex(index: number, replacement: SQLSnippetModelInstance): void;
25
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
26
+ export * from './sql-snippet';
@@ -0,0 +1,9 @@
1
+ import { Instance } from 'mobx-state-tree';
2
+ export declare const SQLSnippetModel: import("mobx-state-tree").IModelType<{
3
+ key: import("mobx-state-tree").ISimpleType<string>;
4
+ value: import("mobx-state-tree").ISimpleType<string>;
5
+ }, {
6
+ setKey(key: string): void;
7
+ setValue(value: string): void;
8
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
9
+ export declare type SQLSnippetModelInstance = Instance<typeof SQLSnippetModel>;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { IDashboardPanel } from '../types/dashboard';
3
3
  interface IPanel extends IDashboardPanel {
4
4
  update?: (panel: IDashboardPanel) => void;
5
5
  }
6
- export declare function Panel({ viz: initialViz, queryID: initialQueryID, title: initialTitle, description: initialDesc, update, layout, id, }: IPanel): JSX.Element;
6
+ export declare const Panel: React.FunctionComponent<IPanel>;
7
7
  export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { IConfigComponentProps, IViewComponentProps } from '../plugins/viz-manager/components';
3
+ import { IVizConfig } from '../types';
4
+ export declare function PluginVizConfigComponent({ setVizConf, ...props }: IConfigComponentProps & {
5
+ setVizConf: (val: React.SetStateAction<IVizConfig>) => void;
6
+ }): JSX.Element;
7
+ export declare function PluginVizViewComponent(props: IViewComponentProps): JSX.Element;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  interface IPanelSettingsModal {
3
3
  opened: boolean;
4
4
  close: () => void;
5
5
  }
6
- export declare function PanelSettingsModal({ opened, close }: IPanelSettingsModal): JSX.Element;
6
+ export declare const PanelSettingsModal: React.FunctionComponent<IPanelSettingsModal>;
7
7
  export {};
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  interface IPickQuery {
3
3
  }
4
- export declare function PickQuery({}: IPickQuery): JSX.Element;
4
+ export declare const PickQuery: React.FunctionComponent<IPickQuery>;
5
5
  export {};
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  interface IPanelTitleBar {
3
3
  }
4
- export declare function PanelTitleBar({}: IPanelTitleBar): JSX.Element;
4
+ export declare const PanelTitleBar: React.FunctionComponent<IPanelTitleBar>;
5
5
  export {};
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
2
- import { IVizConfig } from '../../types/dashboard';
1
+ import React from 'react';
2
+ import { IVizConfig } from '../../types';
3
3
  interface IViz {
4
4
  viz: IVizConfig;
5
5
  data: any;
6
6
  loading: boolean;
7
7
  }
8
- export declare function Viz({ viz, data, loading }: IViz): JSX.Element;
8
+ export declare const Viz: React.FunctionComponent<IViz>;
9
9
  export {};
@@ -0,0 +1,2 @@
1
+ export * from './use-channel-event';
2
+ export * from './use-storage-data';
@@ -0,0 +1,2 @@
1
+ import { ListenerFn, EventEmitter2 } from 'eventemitter2';
2
+ export declare function useChannelEvent(channel: EventEmitter2, event: string, listener: ListenerFn): void;
@@ -0,0 +1,6 @@
1
+ import { PluginStorage } from '../../types/plugin';
2
+ export declare const useStorageData: <T>(storage: PluginStorage, dataKey: string) => {
3
+ loading: boolean;
4
+ value: T | undefined;
5
+ set: (val: T) => Promise<void>;
6
+ };
@@ -0,0 +1,4 @@
1
+ export * from './viz-manager';
2
+ export * from './plugin-context';
3
+ export * from './plugin-data-migrator';
4
+ export * from './hooks';
@@ -0,0 +1,12 @@
1
+ import { PluginStorage } from '../types/plugin';
2
+ export declare class JsonPluginStorage implements PluginStorage {
3
+ protected rootRef: {
4
+ current: Record<string, any>;
5
+ };
6
+ constructor(initValue: Record<string, any>);
7
+ deleteItem(key: string): Promise<void>;
8
+ getItem<T>(key: string | null): Promise<T>;
9
+ private getValueFromRoot;
10
+ setItem<T>(key: string | null, item: T): Promise<T>;
11
+ watchItem<T>(key: string | null, callback: (value: T, previous?: T) => void): () => void;
12
+ }
@@ -0,0 +1,7 @@
1
+ import EventEmitter2 from 'eventemitter2';
2
+ import { IMessageChannels } from '../types/plugin';
3
+ export declare class MessageChannels implements IMessageChannels {
4
+ private channels;
5
+ globalChannel: EventEmitter2;
6
+ getChannel(name: string): EventEmitter2;
7
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { IPluginManager } from '../types/plugin';
3
+ import { PluginManager } from './plugin-manager';
4
+ import { VizManager } from './viz-manager';
5
+ interface IPluginContextProps {
6
+ pluginManager: IPluginManager;
7
+ vizManager: VizManager;
8
+ }
9
+ export declare const pluginManager: PluginManager;
10
+ export declare const createPluginContext: () => IPluginContextProps;
11
+ export declare const PluginContext: import("react").Context<IPluginContextProps>;
12
+ export {};
@@ -0,0 +1 @@
1
+ export * from './plugin-data-migrator';
@@ -0,0 +1,13 @@
1
+ interface IMigration {
2
+ version: number;
3
+ handler: (data: any) => any;
4
+ }
5
+ export declare class PluginDataMigrator {
6
+ protected migrations: IMigration[];
7
+ version(version: number, handler: (data: any) => any): PluginDataMigrator;
8
+ run(migrationTarget: {
9
+ from: number;
10
+ to: number;
11
+ }, val: any): any;
12
+ }
13
+ export {};
@@ -0,0 +1,18 @@
1
+ import { IDashboardPlugin, IPluginManager, VizComponent } from '../types/plugin';
2
+ export declare class PluginManager implements IPluginManager {
3
+ /**
4
+ * Id to plugin map
5
+ * @private
6
+ */
7
+ private plugins;
8
+ /**
9
+ * Name to component map
10
+ */
11
+ private vizComponents;
12
+ constructor();
13
+ factory: {
14
+ viz: (name: string) => VizComponent;
15
+ };
16
+ install(plugin: IDashboardPlugin): void;
17
+ get installedPlugins(): IDashboardPlugin[];
18
+ }
@@ -0,0 +1,2 @@
1
+ import { VizComponent } from '../../../types/plugin';
2
+ export declare const TableVizComponent: VizComponent;
@@ -19,3 +19,4 @@ export interface ITableConf {
19
19
  striped: boolean;
20
20
  highlightOnHover: boolean;
21
21
  }
22
+ export declare const DEFAULT_CONFIG: ITableConf;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { VizConfigProps } from '../../../types/plugin';
3
+ export declare function VizTablePanel({ context }: VizConfigProps): JSX.Element;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { VizViewProps } from '../../../types/plugin';
3
+ export declare function VizTable({ context }: VizViewProps): JSX.Element;
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { IPanelInfoEditor } from '../../types/plugin';
3
+ import { IPanelInfo, IVizManager } from './types';
4
+ export declare type IViewPanelInfo = IPanelInfo & {
5
+ layout: {
6
+ w: number;
7
+ h: number;
8
+ };
9
+ };
10
+ export declare type IViewComponentProps<TDebug = {}> = {
11
+ panel: IViewPanelInfo;
12
+ data: any;
13
+ vizManager: IVizManager;
14
+ } & TDebug;
15
+ export declare const VizViewComponent: <T>(props: IViewComponentProps<T>) => JSX.Element;
16
+ export declare type IConfigComponentProps<TDebug = {}> = {
17
+ panel: IPanelInfo;
18
+ panelInfoEditor: IPanelInfoEditor;
19
+ vizManager: IVizManager;
20
+ data: any;
21
+ } & TDebug;
22
+ export declare const VizConfigComponent: <T>(props: IConfigComponentProps<T>) => JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { IPluginManager, VizComponent } from '../../types/plugin';
2
+ import { IPanelInfo, IVizManager, VizInstanceInfo } from './types';
3
+ export declare class VizManager implements IVizManager {
4
+ private pluginManager;
5
+ private instances;
6
+ constructor(pluginManager: IPluginManager);
7
+ get availableVizList(): VizComponent[];
8
+ resolveComponent(name: string): VizComponent;
9
+ getOrCreateInstance(panel: IPanelInfo): VizInstanceInfo;
10
+ }
@@ -0,0 +1,4 @@
1
+ export { VizManager } from './impl';
2
+ export type { IVizManager, IPanelInfo } from './types';
3
+ export { VizConfigComponent, VizViewComponent } from './components';
4
+ export type { IViewPanelInfo, IViewComponentProps } from './components';
@@ -0,0 +1,12 @@
1
+ import { IDashboardPanel } from '../../types';
2
+ import { IMessageChannels, PluginStorage, VizComponent, VizInstance } from '../../types/plugin';
3
+ export declare type IPanelInfo = Omit<IDashboardPanel, 'layout'>;
4
+ export interface IVizManager {
5
+ readonly availableVizList: VizComponent[];
6
+ resolveComponent(type: string): VizComponent;
7
+ getOrCreateInstance(panel: IPanelInfo): VizInstanceInfo;
8
+ }
9
+ export interface VizInstanceInfo extends VizInstance {
10
+ messageChannels: IMessageChannels;
11
+ instanceData: PluginStorage;
12
+ }
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .viz-root{width:100%;overflow:scroll;padding-top:5px;height:calc(100% - 25px);background-color:#fff}.panel-title-wrapper{text-align:center;transition:background-color .3s ease}.panel-title-wrapper:hover{cursor:pointer;background-color:#6464640d}.panel-root{padding:5px;height:100%;width:100%;max-width:100%;background:transparent;border-radius:5px;box-shadow:0 0 10px #0003}.mantine-Tabs-root{width:100%;height:calc(100% - 25px);overflow:hidden;display:flex;justify-content:flex-start;flex-direction:column;flex-wrap:nowrap}.mantine-Tabs-tabsListWrapper{flex:0}.mantine-Tabs-body{flex:1;overflow:scroll}.dashboard-layout{margin-left:-10px;margin-right:-10px}.react-grid-item{padding:0}.remove-panel{position:absolute;right:2px;top:0;cursor:pointer}.code-textarea textarea{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}
1
+ .viz-root{width:100%;overflow:scroll;padding-top:5px;height:calc(100% - 25px);background-color:#fff}.panel-title-wrapper{text-align:center;transition:background-color .3s ease}.panel-title-wrapper:hover{cursor:pointer;background-color:#6464640d}.panel-root{padding:5px;height:100%;width:100%;max-width:100%;background:transparent;border-radius:5px;box-shadow:0 0 10px #0003}.panel-settings-tabs{width:100%;height:100%}.panel-settings-tabs .mantine-Tabs-panel{height:calc(100% - 25px)}.panel-settings-tabs .mantine-Tabs-tabsListWrapper{flex:0}.panel-settings-tabs .mantine-Tabs-body{flex:1;overflow:scroll}.dashboard-layout{margin-left:-10px;margin-right:-10px}.react-grid-item{padding:0}.remove-panel{position:absolute;right:2px;top:0;cursor:pointer}.code-textarea textarea{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.filter-settings-tabs{width:100%;height:100%}.filter-settings-tabs .mantine-Tabs-panel{height:calc(100% - 25px)}.filter-settings-tabs .mantine-Tabs-tabsListWrapper{flex:0}.filter-settings-tabs .mantine-Tabs-body{flex:1;overflow:scroll}.dashboard-root{overflow:scroll;padding:0 10px 10px}.dashboard-sticky-area{z-index:100;background:white;margin:0 -10px;padding:0 10px 10px}
@@ -1,14 +1,10 @@
1
1
  import { FilterModelInstance } from '../model';
2
+ import { QueryModelInstance } from '../model/queries';
3
+ import { SQLSnippetModelInstance } from '../model/sql-snippets';
2
4
  export interface IVizConfig {
3
5
  type: string;
4
6
  conf: Record<string, any>;
5
7
  }
6
- export interface IQuery {
7
- type: 'postgresql';
8
- key: string;
9
- sql: string;
10
- id: string;
11
- }
12
8
  export interface IDashboardPanel {
13
9
  id: string;
14
10
  title: string;
@@ -29,13 +25,9 @@ export declare enum DashboardMode {
29
25
  Layout = "layout",
30
26
  Edit = "edit"
31
27
  }
32
- export interface ISQLSnippet {
33
- key: string;
34
- value: string;
35
- }
36
28
  export interface IDashboardDefinition {
37
- sqlSnippets: ISQLSnippet[];
38
- queries: IQuery[];
29
+ sqlSnippets: SQLSnippetModelInstance[];
30
+ queries: QueryModelInstance[];
39
31
  }
40
32
  export interface IDashboard {
41
33
  id: string;
@@ -0,0 +1,101 @@
1
+ import EventEmitter2 from 'eventemitter2';
2
+ import React from 'react';
3
+ /**
4
+ * Basic information of a viz component instance
5
+ */
6
+ export interface VizInstance {
7
+ id: string;
8
+ name: string;
9
+ type: string;
10
+ }
11
+ /**
12
+ * Props to render the view of viz component
13
+ */
14
+ export interface VizViewProps {
15
+ instance: VizInstance;
16
+ context: VizViewContext;
17
+ }
18
+ export interface PluginStorage {
19
+ getItem<T>(key: string | null): Promise<T>;
20
+ setItem<T>(key: string | null, item: T): Promise<T>;
21
+ deleteItem(key: string): Promise<void>;
22
+ watchItem<T>(key: string | null, callback: (value: T, previous?: T) => void): () => void;
23
+ }
24
+ export interface ColorPaletteItem {
25
+ name: string;
26
+ type: string;
27
+ category: string;
28
+ }
29
+ export interface SingleColor extends ColorPaletteItem {
30
+ type: 'single';
31
+ value: string;
32
+ }
33
+ export interface ColorInterpolation extends ColorPaletteItem {
34
+ type: 'interpolation';
35
+ interpolation: (value: number) => string;
36
+ }
37
+ export interface ColorPalette {
38
+ getColor(colorInfo: ColorPaletteItem): (value: unknown) => string;
39
+ }
40
+ export interface IMessageChannels {
41
+ globalChannel: EventEmitter2;
42
+ getChannel(name: string): EventEmitter2;
43
+ }
44
+ export interface VizContext {
45
+ pluginData: PluginStorage;
46
+ instanceData: PluginStorage;
47
+ colorPalette: ColorPalette;
48
+ locale: string;
49
+ msgChannels: IMessageChannels;
50
+ data: unknown;
51
+ }
52
+ declare type Setter<T> = (val: string) => void;
53
+ export interface IPanelInfoEditor {
54
+ setTitle: Setter<string>;
55
+ setDescription: Setter<string>;
56
+ setQueryID: Setter<string>;
57
+ }
58
+ export interface VizConfigContext extends VizContext {
59
+ panelInfoEditor: IPanelInfoEditor;
60
+ }
61
+ export interface VizViewContext extends VizContext {
62
+ viewport: {
63
+ width: number;
64
+ height: number;
65
+ };
66
+ }
67
+ export interface VizConfigProps {
68
+ instance: VizInstance;
69
+ context: VizConfigContext;
70
+ }
71
+ export interface VizComponentMigrationContext {
72
+ instanceData: PluginStorage;
73
+ }
74
+ export interface VizComponent {
75
+ name: string;
76
+ displayName?: string;
77
+ viewRender: React.ComponentType<VizViewProps>;
78
+ configRender: React.ComponentType<VizConfigProps>;
79
+ migrator: IVizComponentMigrator;
80
+ }
81
+ export interface IVizComponentMigrator {
82
+ needMigration(ctx: VizComponentMigrationContext): Promise<boolean>;
83
+ migrate(ctx: VizComponentMigrationContext): Promise<void>;
84
+ }
85
+ export interface IPluginManifest {
86
+ viz: VizComponent[];
87
+ color: ColorPaletteItem[];
88
+ }
89
+ export interface IDashboardPlugin {
90
+ id: string;
91
+ version: string;
92
+ manifest: IPluginManifest;
93
+ }
94
+ export interface IPluginManager {
95
+ install(plugin: IDashboardPlugin): void;
96
+ installedPlugins: IDashboardPlugin[];
97
+ factory: {
98
+ viz: (name: string) => VizComponent;
99
+ };
100
+ }
101
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare function downloadCSV(id: string, csv: string): void;
2
+ export declare function downloadDataListAsZip(idDataList: Array<{
3
+ id: string;
4
+ data: any[];
5
+ }>): void;
6
+ export declare function makeCSV(data: any | any[]): string;
@@ -1,8 +1,9 @@
1
- import { ContextInfoContextType, FilterValuesContextType } from '../contexts';
2
- import { IDashboardDefinition } from '../types';
3
- export declare function explainSQLSnippet(snippet: string, context: ContextInfoContextType): any;
1
+ import { FilterValuesType } from '../model';
2
+ import { ContextInfoType } from '../model/context';
3
+ import { SQLSnippetModelInstance } from '../model/sql-snippets';
4
+ export declare function explainSQLSnippet(snippet: string, context: ContextInfoType): any;
4
5
  export declare function formatSQL(sql: string, params: Record<string, any>): any;
5
- export declare function getSQLParams(context: ContextInfoContextType, definitions: IDashboardDefinition, filterValues: FilterValuesContextType): Record<string, any> & ContextInfoContextType & {
6
- filters: FilterValuesContextType;
6
+ export declare function getSQLParams(context: ContextInfoType, sqlSnippets: SQLSnippetModelInstance[], filterValues: FilterValuesType): Record<string, any> & ContextInfoType & {
7
+ filters: FilterValuesType;
7
8
  };
8
- export declare function explainSQL(sql: string, context: ContextInfoContextType, definitions: IDashboardDefinition, filterValues: FilterValuesContextType): any;
9
+ export declare function explainSQL(sql: string, context: ContextInfoType, sqlSnippets: SQLSnippetModelInstance[], filterValues: FilterValuesType): any;