Skip to content

Commit f966e63

Browse files
authored
Merge branch 'dev' into agora-integrationn
2 parents e985886 + a63026e commit f966e63

File tree

120 files changed

+2806
-495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+2806
-495
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ updates:
66
directory: "/server/api-service"
77
schedule:
88
interval: "monthly"
9+
target-branch: "dev"
910
- package-ecosystem: "npm"
1011
directory: "/server/node-service"
1112
schedule:
1213
interval: "monthly"
14+
target-branch: "dev"
1315
- package-ecosystem: "npm"
1416
directory: "/client"
1517
schedule:
1618
interval: "monthly"
19+
target-branch: "dev"
1720
- package-ecosystem: "docker"
1821
directory: "/deploy/docker"
1922
schedule:
2023
interval: "monthly"
24+
target-branch: "dev"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ stacks/
44
client/.yarn/cache/*.zip
55
server/node-service/.yarn/cache/*.zip
66
.metadata/
7+
.DS_Store

client/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#### Use prebuilt docker image
88

9-
Simply run below command to start a backend server.
9+
Simply run the below command to start a backend server.
1010

1111
```bash
1212
docker run -d --name lowcoder -p 3000:3000 -v "$PWD/stacks:/lowcoder-stacks" lowcoderorg/lowcoder-ce
@@ -16,8 +16,8 @@ For more information, view our [docs](https://docs.lowcoder.cloud/lowcoder-docum
1616

1717
#### Build Docker image from source
1818

19-
1. Check out source code and change to source dir.
20-
2. Use the command below to build Docker image :
19+
1. Check out the source code and change to source dir.
20+
2. Use the command below to build a Docker image :
2121

2222
```bash
2323
docker build -f ./deploy/docker/Dockerfile -t lowcoder-dev .
@@ -31,6 +31,7 @@ docker run -d --name lowcoder-dev -p 3000:3000 -v "$PWD/stacks:/lowcoder-stacks"
3131

3232
### Start develop
3333

34+
3435
1. Check out source code.
3536
2. Change to **/client** dir in the source dir.
3637

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@types/qrcode.react": "^1.0.2",
3434
"@types/react-grid-layout": "^1.3.0",
3535
"@types/react-helmet": "^6.1.5",
36-
"@types/react-resizable": "^1.7.4",
36+
"@types/react-resizable": "^3.0.5",
3737
"@types/react-router-dom": "^5.3.2",
3838
"@types/shelljs": "^0.8.11",
3939
"@types/styled-components": "^5.1.19",

client/packages/lowcoder-cli/client.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ declare var LOWCODER_NODE_SERVICE_URL: string;
3434
declare var LOWCODER_SHOW_BRAND: string;
3535
declare var LOWCODER_CUSTOM_LOGO: string;
3636
declare var LOWCODER_CUSTOM_LOGO_SQUARE: string;
37+
declare var LOWCODER_CUSTOM_AUTH_WELCOME_TEXT: string;
3738
declare var REACT_APP_ENV: string;
3839
declare var REACT_APP_BUILD_ID: string;
3940
declare var REACT_APP_LOG_LEVEL: string;
Lines changed: 18 additions & 0 deletions
Loading

client/packages/lowcoder-comps/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import config from "../../config/test/jest.config.js";
22

33
export default {
44
...config,
5+
setupFiles: [...config.setupFiles, 'jest-canvas-mock'],
56
};

client/packages/lowcoder-comps/package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lowcoder-comps",
3-
"version": "0.0.13",
3+
"version": "0.0.17",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {
@@ -15,6 +15,7 @@
1515
"@types/react-dom": "17",
1616
"big.js": "^6.2.1",
1717
"echarts-extension-gmap": "^1.6.0",
18+
"echarts-wordcloud": "^2.1.0",
1819
"lowcoder-cli": "workspace:^",
1920
"lowcoder-sdk": "workspace:^",
2021
"mermaid": "^10.2.4",
@@ -29,16 +30,16 @@
2930
"name": "Chart",
3031
"icon": "./icons/icon-chart.svg",
3132
"layoutInfo": {
32-
"w": 11,
33-
"h": 35
33+
"w": 15,
34+
"h": 40
3435
}
3536
},
3637
"imageEditor": {
3738
"name": "Image Editor",
3839
"icon": "./icons/icon-chart.svg",
3940
"layoutInfo": {
4041
"w": 15,
41-
"h": 60
42+
"h": 40
4243
}
4344
},
4445
"calendar": {
@@ -48,6 +49,14 @@
4849
"w": 15,
4950
"h": 60
5051
}
52+
},
53+
"mermaid": {
54+
"name": "Mermaid",
55+
"icon": "./icons/mermaidchart.svg",
56+
"layoutInfo": {
57+
"w": 15,
58+
"h": 40
59+
}
5160
}
5261
}
5362
},
@@ -60,6 +69,7 @@
6069
},
6170
"devDependencies": {
6271
"jest": "29.3.0",
72+
"jest-canvas-mock": "^2.5.2",
6373
"vite": "^4.3.9",
6474
"vite-tsconfig-paths": "^3.6.0"
6575
}

client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
UICompBuilder,
2424
withDefault,
2525
withExposingConfigs,
26+
withMethodExposing,
2627
withViewFn,
2728
ThemeContext,
2829
chartColorPalette,
@@ -46,6 +47,10 @@ let ChartTmpComp = (function () {
4647
})();
4748

4849
ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
50+
const apiKey = comp.children.mapApiKey.getView();
51+
const mode = comp.children.mode.getView();
52+
const onEvent = comp.children.onEvent.getView();
53+
4954
const echartsCompRef = useRef<ReactECharts | null>();
5055
const [chartSize, setChartSize] = useState<ChartSize>();
5156
const [mapScriptLoaded, setMapScriptLoaded] = useState(false);
@@ -55,21 +60,24 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
5560
color: chartColorPalette,
5661
backgroundColor: "#fff",
5762
};
63+
5864
let themeConfig = defaultChartTheme;
5965
try {
6066
themeConfig = theme?.theme.chart ? JSON.parse(theme?.theme.chart) : defaultChartTheme;
6167
} catch (error) {
6268
log.error('theme chart error: ', error);
6369
}
64-
const onEvent = comp.children.onEvent.getView();
70+
6571
useEffect(() => {
72+
if(mode !== 'ui') return;
73+
6674
// bind events
6775
const echartsCompInstance = echartsCompRef?.current?.getEchartsInstance();
6876
if (!echartsCompInstance) {
6977
return _.noop;
7078
}
71-
echartsCompInstance.on("selectchanged", (param: any) => {
72-
const option: any = echartsCompInstance.getOption();
79+
echartsCompInstance?.on("selectchanged", (param: any) => {
80+
const option: any = echartsCompInstance?.getOption();
7381
//log.log("chart select change", param);
7482
if (param.fromAction === "select") {
7583
comp.dispatch(changeChildAction("selectedPoints", getSelectedPoints(param, option)));
@@ -80,8 +88,8 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
8088
}
8189
});
8290
// unbind
83-
return () => echartsCompInstance.off("selectchanged");
84-
}, [onEvent]);
91+
return () => echartsCompInstance?.off("selectchanged");
92+
}, [mode, onEvent]);
8593

8694
const echartsConfigChildren = _.omit(comp.children, echartsConfigOmitChildren);
8795
const option = useMemo(() => {
@@ -96,27 +104,33 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
96104
}, [mapScriptLoaded])
97105

98106
const loadGoogleMapsData = () => {
99-
const echartsCompInstance = echartsCompRef?.current?.getEchartsInstance();
100-
if (!echartsCompInstance) {
101-
return _.noop;
102-
}
103-
echartsCompInstance.getModel().getComponent("gmap").getGoogleMap();
104-
}
107+
setTimeout(() => {
108+
const echartsCompInstance = echartsCompRef?.current?.getEchartsInstance();
109+
if (!echartsCompInstance) {
110+
return _.noop;
111+
}
105112

106-
const apiKey = comp.children.mapApiKey.getView();
107-
const mode = comp.children.mode.getView();
113+
let mapInstance = undefined;
114+
mapInstance = echartsCompInstance?.getModel()?.getComponent("gmap")?.getGoogleMap();
115+
comp.dispatch(changeChildAction("mapInstance", mapInstance));
116+
}, 500)
117+
}
118+
108119
useEffect(() => {
109-
if(mode === 'map') {
110-
const gMapScript = loadGoogleMapsScript('');
111-
if(isMapScriptLoaded) {
112-
loadGoogleMapsData();
113-
return;
114-
}
115-
gMapScript.addEventListener('load', function () {
116-
setMapScriptLoaded(true);
117-
loadGoogleMapsData();
118-
});
120+
if( mode !== 'map') {
121+
comp.dispatch(changeChildAction("mapInstance", undefined));
122+
return;
119123
}
124+
125+
const gMapScript = loadGoogleMapsScript(apiKey);
126+
if(isMapScriptLoaded) {
127+
loadGoogleMapsData();
128+
return;
129+
}
130+
gMapScript.addEventListener('load', function () {
131+
setMapScriptLoaded(true);
132+
loadGoogleMapsData();
133+
});
120134
}, [mode, apiKey, option])
121135

122136
return (
@@ -142,6 +156,7 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
142156
opts={{ locale: getEchartsLocale() }}
143157
option={option}
144158
theme={mode !== 'map' ? themeConfig : undefined}
159+
mode={mode}
145160
/>
146161
)}
147162
</ReactResizeDetector>
@@ -241,7 +256,7 @@ ChartTmpComp = class extends ChartTmpComp {
241256
}
242257
};
243258

244-
const ChartComp = withExposingConfigs(ChartTmpComp, [
259+
let ChartComp = withExposingConfigs(ChartTmpComp, [
245260
depsConfig({
246261
name: "selectedPoints",
247262
desc: trans("chart.selectedPointsDesc"),
@@ -266,6 +281,17 @@ const ChartComp = withExposingConfigs(ChartTmpComp, [
266281
new NameConfig("title", trans("chart.titleDesc")),
267282
]);
268283

284+
ChartComp = withMethodExposing(ChartComp, [
285+
{
286+
method: {
287+
name: "getMapInstance",
288+
},
289+
execute: (comp) => {
290+
return comp.children.mapInstance.getView()
291+
},
292+
},
293+
])
294+
269295
export const ChartCompWithDefault = withDefault(ChartComp, {
270296
xAxisKey: "date",
271297
series: [

client/packages/lowcoder-comps/src/comps/chartComp/chartConfigs/chartUrls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ const echartsUrlLocale = language === "zh" ? "zh" : "en";
44
export const optionUrl = `https://echarts.apache.org/${echartsUrlLocale}/option.html`;
55
export const examplesUrl = `https://echarts.apache.org/examples/${echartsUrlLocale}/index.html`;
66
export const xAxisTypeUrl = `${optionUrl}#xAxis.type`;
7-
export const googleMapsApiUrl = `https://maps.googleapis.com/maps/api/js`;
7+
export const googleMapsApiUrl = `https://maps.googleapis.com/maps/api/js?v=3.exp`;
88
export const mapOptionUrl = `https://github.com/plainheart/echarts-extension-gmap`;
99
export const mapExamplesUrl = `https://codepen.io/plainheart/pen/VweLGbR`;

client/packages/lowcoder-comps/src/comps/chartComp/chartConstants.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { jsonControl, JSONObject, stateComp, toJSONObjectArray, toObject } from "lowcoder-sdk";
2-
import { withDefault, BooleanControl, StringControl, NumberControl, JSONObjectControl } from "lowcoder-sdk";
2+
import { withDefault, BooleanControl, StringControl, NumberControl, JSONObjectControl, FunctionControl } from "lowcoder-sdk";
33
import { dropdownControl } from "lowcoder-sdk";
44
import { eventHandlerControl } from "lowcoder-sdk";
55
import { valueComp, withType } from "lowcoder-sdk";
@@ -225,6 +225,8 @@ export const chartUiModeChildren = {
225225
};
226226

227227
const chartMapModeChildren = {
228+
mapInstance: stateComp(),
229+
getMapInstance: FunctionControl,
228230
mapApiKey: withDefault(StringControl, ''),
229231
mapZoomLevel: withDefault(NumberControl, 3),
230232
mapCenterLng: withDefault(NumberControl, 15.932644),

client/packages/lowcoder-comps/src/comps/chartComp/chartUtils.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function transformData(
5252
}
5353

5454
const notAxisChartSet: Set<CharOptionCompType> = new Set(["pie"] as const);
55-
export const echartsConfigOmitChildren = ["hidden", "selectedPoints", "onEvent"] as const;
55+
export const echartsConfigOmitChildren = ["hidden", "selectedPoints", "onEvent", "mapInstance"] as const;
5656
type EchartsConfigProps = Omit<ChartCompPropsType, typeof echartsConfigOmitChildren[number]>;
5757

5858
export function isAxisChart(type: CharOptionCompType) {
@@ -141,7 +141,7 @@ export function getEchartsConfig(props: EchartsConfigProps, chartSize?: ChartSiz
141141
center: [mapCenterLng, mapCenterLat],
142142
zoom: mapZoomLevel,
143143
renderOnMoving: true,
144-
// echartsLayerZIndex: 2019,
144+
echartsLayerZIndex: 2019,
145145
roam: true
146146
},
147147
...echartsOption,
@@ -261,12 +261,18 @@ export function getSelectedPoints(param: any, option: any) {
261261
}
262262

263263
export function loadGoogleMapsScript(apiKey?: string) {
264-
const mapsUrl = `${googleMapsApiUrl}?key=${apiKey}`;
264+
const mapsUrl = `${googleMapsApiUrl}&key=${apiKey}`;
265265
const scripts = document.getElementsByTagName('script');
266-
const scriptIndex = _.findIndex(scripts, (script) => script.src === mapsUrl);
266+
// is script already loaded
267+
let scriptIndex = _.findIndex(scripts, (script) => script.src.endsWith(mapsUrl));
267268
if(scriptIndex > -1) {
268269
return scripts[scriptIndex];
269270
}
271+
// is script loaded with diff api_key, remove the script and load again
272+
scriptIndex = _.findIndex(scripts, (script) => script.src.startsWith(googleMapsApiUrl));
273+
if(scriptIndex > -1) {
274+
scripts[scriptIndex].remove();
275+
}
270276

271277
const script = document.createElement("script");
272278
script.type = "text/javascript";

client/packages/lowcoder-comps/src/comps/chartComp/reactEcharts/core.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,20 @@ export default class EChartsReactCore extends PureComponent<EChartsReactProps> {
5959
!isEqual(prevProps.theme, this.props.theme) ||
6060
!isEqual(prevProps.opts, this.props.opts) ||
6161
!isEqual(prevProps.onEvents, this.props.onEvents) ||
62-
this.props.option.gmap
62+
!isEqual(prevProps.mode, this.props.mode)
63+
// this.props.option.gmap
6364
) {
6465
this.dispose();
6566

6667
this.renderNewEcharts(); // re-render
6768
return;
6869
}
6970

71+
if(this.props.mode === "json") {
72+
this.updateEChartsOption();
73+
return;
74+
}
75+
7076
// when these props are not isEqual, update echarts
7177
const pickKeys = ["option", "notMerge", "lazyUpdate", "showLoading", "loadingOption"];
7278
if (!isEqual(_.pick(this.props, pickKeys), _.pick(prevProps, pickKeys))) {

client/packages/lowcoder-comps/src/comps/chartComp/reactEcharts/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as echarts from "echarts";
2+
import "echarts-wordcloud";
23
import { EChartsReactProps, EChartsInstance, EChartsOptionWithMap } from "./types";
34
import EChartsReactCore from "./core";
45

client/packages/lowcoder-comps/src/comps/chartComp/reactEcharts/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ export type EChartsReactProps = {
6969
* should update echarts options
7070
*/
7171
readonly shouldSetOption?: (prevProps: EChartsReactProps, props: EChartsReactProps) => boolean;
72+
/**
73+
* echarts mode: ui | json | map
74+
*/
75+
readonly mode?: 'ui' | 'json' | 'map'
7276
};

0 commit comments

Comments
 (0)