arbor-dashboard 1.0.1 → 1.1.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.
package/README.md CHANGED
@@ -1,2 +1,15 @@
1
- # data.responsive_charting_dashboards
2
- An npm package of responsive charting components for data visualisation
1
+ # 🚀 Welcome to your new awesome project!
2
+
3
+ This project has been created using **webpack-cli**, you can now run
4
+
5
+ ```
6
+ npm run build
7
+ ```
8
+
9
+ or
10
+
11
+ ```
12
+ yarn build
13
+ ```
14
+
15
+ to bundle your application
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "arbor-dashboard",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "A tool to create responsive dashboards with charts",
5
- "main": "index.ts",
5
+ "main": "src/index.ts",
6
+ "types": "src/index.d.ts",
6
7
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "webpack --mode=production --node-env=production",
10
+ "build:dev": "webpack --mode=development",
11
+ "build:prod": "webpack --mode=production --node-env=production",
12
+ "watch": "webpack --watch"
8
13
  },
9
14
  "repository": {
10
15
  "type": "git",
@@ -33,10 +38,22 @@
33
38
  },
34
39
  "devDependencies": {
35
40
  "@eslint/js": "^9.13.0",
41
+ "@types/react": "^18.3.12",
42
+ "@types/react-grid-layout": "^1.3.5",
43
+ "@webpack-cli/generators": "^3.0.7",
44
+ "css-loader": "^7.1.2",
36
45
  "eslint": "^9.13.0",
37
46
  "eslint-plugin-react": "^7.37.1",
38
47
  "globals": "^15.11.0",
48
+ "html-webpack-plugin": "^5.6.3",
49
+ "mini-css-extract-plugin": "^2.9.2",
39
50
  "prettier": "^3.3.3",
40
- "typescript-eslint": "^8.11.0"
51
+ "sass": "^1.81.0",
52
+ "sass-loader": "^16.0.3",
53
+ "style-loader": "^4.0.0",
54
+ "ts-loader": "^9.5.1",
55
+ "typescript-eslint": "^8.11.0",
56
+ "webpack": "^5.96.1",
57
+ "webpack-cli": "^5.1.4"
41
58
  }
42
59
  }
@@ -1,20 +1,17 @@
1
- import {ResponsiveBar} from '@nivo/bar';
1
+ import {BarDatum, ResponsiveBar} from '@nivo/bar';
2
2
  import React from 'react';
3
3
  import {transformChartData} from './transformChartData';
4
4
  import {useQuery} from '@tanstack/react-query';
5
5
  import {httpGet} from '../../HttpRequest/HttpRequest';
6
- type BarChartProps = {
7
- dataUrl: string;
8
- authToken: string;
9
- testEnv: boolean;
10
- };
6
+ import {BarChartProps} from '../../index.d';
7
+
11
8
  export const BarChart = ({dataUrl, authToken, testEnv}: BarChartProps) => {
12
9
  const {data} = useQuery({
13
10
  queryKey: ['bar'],
14
11
  queryFn: () => httpGet(dataUrl, authToken),
15
12
  });
16
13
 
17
- const {transformedData, query, annotation} = transformChartData(
14
+ const {transformedData, query, annotation} = transformChartData<BarDatum>(
18
15
  data,
19
16
  'bar',
20
17
  testEnv,
@@ -8,12 +8,7 @@ import React from 'react';
8
8
  import {transformChartData} from './transformChartData';
9
9
  import {useQuery} from '@tanstack/react-query';
10
10
  import {httpGet} from '../../HttpRequest/HttpRequest';
11
-
12
- type HeatMapProps = {
13
- dataUrl: string;
14
- authToken: string;
15
- testEnv: boolean;
16
- };
11
+ import {HeatMapProps} from '../../index.d';
17
12
 
18
13
  export const HeatMap = ({dataUrl, authToken, testEnv}: HeatMapProps) => {
19
14
  const {data} = useQuery({
@@ -3,12 +3,8 @@ import React from 'react';
3
3
  import {transformChartData} from './transformChartData';
4
4
  import {useQuery} from '@tanstack/react-query';
5
5
  import {httpGet} from '../../HttpRequest/HttpRequest';
6
+ import {LineChartProps} from '../../index.d';
6
7
 
7
- type LineChartProps = {
8
- dataUrl: string;
9
- authToken: string;
10
- testEnv: boolean;
11
- };
12
8
  export const LineChart = ({dataUrl, authToken, testEnv}: LineChartProps) => {
13
9
  const {data} = useQuery({
14
10
  queryKey: ['line'],
@@ -1,89 +1,10 @@
1
1
  import {BarDatum} from '@nivo/bar';
2
2
  import {HeatMapDatum, HeatMapSerie} from '@nivo/heatmap';
3
-
4
- type Query = {
5
- limit: number;
6
- measures: string[];
7
- dimensions: string[];
8
- filters: {
9
- member: string;
10
- operator: string;
11
- values: string[];
12
- }[];
13
- timeDimensions: {
14
- dimension: string;
15
- granularity: string;
16
- }[];
17
- timezone: string;
18
- rowLimit: number;
19
- };
20
-
21
- type Data = {
22
- [key: string]: string | number;
23
- };
24
-
25
- type ApiResponse<T> = {
26
- query: Query;
27
- data: T[];
28
- lastRefreshTime: string;
29
- annotation: {
30
- measures: {
31
- [key: string]: {
32
- title: string;
33
- shortTitle: string;
34
- description: string;
35
- type: string;
36
- meta: {
37
- user_roles: string[];
38
- };
39
- drillMembers: string[];
40
- drillMembersGrouped: {
41
- measures: string[];
42
- dimensions: string[];
43
- };
44
- };
45
- };
46
- dimensions: {
47
- [key: string]: {
48
- title: string;
49
- shortTitle: string;
50
- type: string;
51
- };
52
- };
53
- segments: {};
54
- timeDimensions: {
55
- [key: string]: {
56
- title: string;
57
- shortTitle: string;
58
- description: string;
59
- type: string;
60
- meta: {
61
- user_roles: string[];
62
- };
63
- };
64
- };
65
- };
66
- dataSource: string;
67
- dbType: string;
68
- extDbType: string;
69
- external: boolean;
70
- slowQuery: boolean;
71
- total: number | null;
72
- };
73
-
74
- type ChartType = 'bar' | 'line' | 'heatMap';
75
-
76
- type LineData = {
77
- id: string | number;
78
- data: Array<{
79
- x: number | string | Date;
80
- y: number | string | Date;
81
- }>;
82
- };
3
+ import {ApiResponse, Data, LineData} from '../../index.d';
83
4
 
84
5
  export const transformChartData = <T extends Data>(
85
6
  data: ApiResponse<T>,
86
- chartType: ChartType,
7
+ chartType: 'bar' | 'line' | 'heatMap',
87
8
  testEnv: boolean,
88
9
  ) => {
89
10
  // dimensions are stored in an array in query.dimensions - loop through this for measure strings
@@ -6,14 +6,10 @@ import {MoveIcon} from '../../Icons';
6
6
  import {LineChart} from '../Charts/LineChart';
7
7
  import {HeatMap} from '../Charts/HeatMap';
8
8
  import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
9
+ import {DashboardProps} from '../../index.d';
9
10
 
10
11
  const ResponsiveGridLayout = WidthProvider(Responsive);
11
12
 
12
- type DashboardProps = {
13
- layoutConfig: string;
14
- authToken: string;
15
- };
16
-
17
13
  const queryClient = new QueryClient();
18
14
 
19
15
  export const Dashboard = ({layoutConfig, authToken}: DashboardProps) => {
package/src/index.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ export interface BarChartProps {
2
+ dataUrl: string;
3
+ authToken: string;
4
+ testEnv: boolean;
5
+ }
6
+ export interface LineChartProps {
7
+ dataUrl: string;
8
+ authToken: string;
9
+ testEnv: boolean;
10
+ }
11
+ export interface HeatMapProps {
12
+ dataUrl: string;
13
+ authToken: string;
14
+ testEnv: boolean;
15
+ }
16
+ export interface DashboardProps {
17
+ layoutConfig: string;
18
+ authToken: string;
19
+ }
20
+ type Query = {
21
+ limit: number;
22
+ measures: string[];
23
+ dimensions: string[];
24
+ filters: {
25
+ member: string;
26
+ operator: string;
27
+ values: string[];
28
+ }[];
29
+ timeDimensions: {
30
+ dimension: string;
31
+ granularity: string;
32
+ }[];
33
+ timezone: string;
34
+ rowLimit: number;
35
+ };
36
+
37
+ export interface Data {
38
+ [key: string]: string | number;
39
+ }
40
+
41
+ export interface ApiResponse<T> {
42
+ query: Query;
43
+ data: T[];
44
+ lastRefreshTime: string;
45
+ annotation: {
46
+ measures: {
47
+ [key: string]: {
48
+ title: string;
49
+ shortTitle: string;
50
+ description: string;
51
+ type: string;
52
+ meta: {
53
+ user_roles: string[];
54
+ };
55
+ drillMembers: string[];
56
+ drillMembersGrouped: {
57
+ measures: string[];
58
+ dimensions: string[];
59
+ };
60
+ };
61
+ };
62
+ dimensions: {
63
+ [key: string]: {
64
+ title: string;
65
+ shortTitle: string;
66
+ type: string;
67
+ };
68
+ };
69
+ segments: {};
70
+ timeDimensions: {
71
+ [key: string]: {
72
+ title: string;
73
+ shortTitle: string;
74
+ description: string;
75
+ type: string;
76
+ meta: {
77
+ user_roles: string[];
78
+ };
79
+ };
80
+ };
81
+ };
82
+ dataSource: string;
83
+ dbType: string;
84
+ extDbType: string;
85
+ external: boolean;
86
+ slowQuery: boolean;
87
+ total: number | null;
88
+ }
89
+
90
+ export interface LineData {
91
+ id: string | number;
92
+ data: Array<{
93
+ x: number | string | Date;
94
+ y: number | string | Date;
95
+ }>;
96
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export {Dashboard} from './Components/Dashboard/Dashboard';
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "noImplicitAny": true,
5
+ "module": "NodeNext",
6
+ "target": "es5",
7
+ "allowJs": true,
8
+ "jsx": "react",
9
+ "moduleResolution": "nodenext"
10
+ },
11
+ "files": ["src/index.ts"]
12
+ }
@@ -0,0 +1,60 @@
1
+ // Generated using webpack-cli https://github.com/webpack/webpack-cli
2
+
3
+ const path = require('path');
4
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
5
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
+
7
+ const isProduction = process.env.NODE_ENV == 'production';
8
+
9
+ const stylesHandler = MiniCssExtractPlugin.loader;
10
+
11
+ const config = {
12
+ target: 'web',
13
+ entry: './src/index.ts',
14
+ output: {
15
+ path: path.resolve(__dirname, 'dist'),
16
+ filename: 'arbor-dashboard.js',
17
+ library: 'arbor-dashboard',
18
+ libraryTarget: 'umd',
19
+ globalObject: 'this',
20
+ umdNamedDefine: true,
21
+ },
22
+ plugins: [
23
+ new MiniCssExtractPlugin(),
24
+
25
+ // Add your plugins here
26
+ // Learn more about plugins from https://webpack.js.org/configuration/plugins/
27
+ ],
28
+ module: {
29
+ rules: [
30
+ {
31
+ test: /\.(ts|tsx)$/i,
32
+ loader: 'ts-loader',
33
+ exclude: ['/node_modules/'],
34
+ },
35
+ {
36
+ test: /\.s[ac]ss$/i,
37
+ use: [stylesHandler, 'css-loader', 'sass-loader'],
38
+ },
39
+ {
40
+ test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
41
+ type: 'asset',
42
+ },
43
+
44
+ // Add your rules for custom modules here
45
+ // Learn more about loaders from https://webpack.js.org/loaders/
46
+ ],
47
+ },
48
+ resolve: {
49
+ extensions: ['.tsx', '.ts', '.jsx', '.js', '...'],
50
+ },
51
+ };
52
+
53
+ module.exports = () => {
54
+ if (isProduction) {
55
+ config.mode = 'production';
56
+ } else {
57
+ config.mode = 'development';
58
+ }
59
+ return config;
60
+ };
package/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export {BarChart} from './src/Components/Charts/BarChart';
2
- export {Dashboard} from './src/Components/Dashboard/Dashboard';