PromucFlow_constructor/app/client/src/widgets/ChartWidget.tsx
Abhinav Jha 94b28311c6
Use injected configuration from Nginx at runtime instead of build time (#30)
* Use envsubst and nginx templates to generate nginx configs which can substitute environment variables and inject into the index.html file

* Fix path in dockerfile. Add .gitignore and .env.example files. Fix nginx-linux template.

* Add all environment variables. Add prefix to all environment variables. Update scripts to attempt to substitute all environment variables with the prefix

* Setup dockerfile to execute a bash script. use env.example for fetching environment variables in development

* Toggle features based on injected configs. Fix nginx template substitution script.

* Update env.example file

* Remove debug code from start-nginx.sh

* Fix nginx config templates by adding quotes by default. Fix sed regex to include numerals. Toggle social login buttons on Login page based on the config.

* Update rapid api environment variable name. Toggle oauth buttons based on config in SignUp page. Update .env.example to be a union of server and client environment variables

* Adding a Map disabled message on Map widget

* Adding links to Privacy policy and TNC

* Use REACT_APP_ env variables with higher priority over injected config variables for toggling features

* Update netlify.toml by commenting out the build environment variables

* Remove env variables not required by the client

* Remove start-storybook entry from package.json

* Fix netlify.toml. Fallback algolia configs

* Add contexts to netlify.toml for successful deploys. Swith to using APPSMITH_MARKETPLACE_URL as the toggle for RapidAPI feature on the client. Remove comments in nginx config templates. Fix template used in dockerfile.

Co-authored-by: Satbir Singh <apple@apples-MacBook-Pro.local>
Co-authored-by: Satbir Singh <satbir121@gmail.com>
2020-07-07 15:52:17 +05:30

77 lines
2.0 KiB
TypeScript

import React, { lazy, Suspense } from "react";
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
import { WidgetType } from "constants/WidgetConstants";
import { WidgetPropertyValidationType } from "utils/ValidationFactory";
import { VALIDATION_TYPES } from "constants/WidgetValidation";
import Skeleton from "components/utils/Skeleton";
const ChartComponent = lazy(() =>
import(
/* webpackPrefetch: true, webpackChunkName: "charts" */ "components/designSystems/appsmith/ChartComponent"
),
);
class ChartWidget extends BaseWidget<ChartWidgetProps, WidgetState> {
static getPropertyValidationMap(): WidgetPropertyValidationType {
return {
xAxisName: VALIDATION_TYPES.TEXT,
yAxisName: VALIDATION_TYPES.TEXT,
chartName: VALIDATION_TYPES.TEXT,
isVisible: VALIDATION_TYPES.BOOLEAN,
chartData: VALIDATION_TYPES.CHART_DATA,
};
}
getPageView() {
return (
<Suspense fallback={<Skeleton />}>
<ChartComponent
key={this.props.widgetId}
isVisible={this.props.isVisible}
chartType={this.props.chartType}
xAxisName={this.props.xAxisName}
yAxisName={this.props.yAxisName}
chartName={this.props.chartName}
chartData={this.props.chartData}
widgetId={this.props.widgetId}
allowHorizontalScroll={this.props.allowHorizontalScroll}
/>
</Suspense>
);
}
getWidgetType(): WidgetType {
return "CHART_WIDGET";
}
}
export type ChartType =
| "LINE_CHART"
| "BAR_CHART"
| "PIE_CHART"
| "COLUMN_CHART"
| "AREA_CHART"
| "SCATTER_CHART";
export interface ChartDataPoint {
x: any;
y: any;
}
export interface ChartData {
seriesName?: string;
data: ChartDataPoint[];
}
export interface ChartWidgetProps extends WidgetProps {
chartType: ChartType;
chartData: ChartData[];
xAxisName: string;
yAxisName: string;
chartName: string;
isVisible?: boolean;
allowHorizontalScroll: boolean;
}
export default ChartWidget;