Skip to content

Commit e36a9dc

Browse files
committed
merge dev code
2 parents e14e7c6 + 5796484 commit e36a9dc

File tree

335 files changed

+8507
-3932
lines changed

Some content is hidden

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

335 files changed

+8507
-3932
lines changed

README_zh.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ datart 是新一代数据可视化开放平台,支持各类企业数据可视
6464

6565
## License
6666
datart is under the Apache 2.0 license. See the [LICENSE](https://gitee.com/running-elephant/datart/blob/master/LICENSE) file for details.
67+
68+
**(在使用上遇到的任何问题,以及对 datart 的建议,欢迎创建 issue 提问和讨论)**

bin/datart-server.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ START_CLASS="datart.DatartServerApplication"
2929
#java -server -Xms2G -Xmx2G -Dspring.profiles.active=config -Dfile.encoding=UTF-8 -cp "${CLASS_PATH}" datart.DatartServerApplication
3030

3131
datart_status(){
32-
result=`ps -ef | awk '/DatartServerApplication/ && !/awk/{print $2}' | wc -l`
32+
#result=`ps -ef | awk '/DatartServerApplication/ && !/awk/{print $2}' | wc -l`
33+
result=`ps -ef | grep -v grep | grep "${BASE_DIR}/lib" | grep 'DatartServerApplication' | awk {'print $2'} | wc -l`
3334

3435
if [[ $result -eq 0 ]]; then
3536
return 0
@@ -47,7 +48,8 @@ datart_start(){
4748

4849
else
4950
echo ""
50-
PID=`ps -ef | awk '/DatartServerApplication/ && !/awk/{print $2}'`
51+
#PID=`ps -ef | awk '/DatartServerApplication/ && !/awk/{print $2}'`
52+
PID=`ps -ef | grep -v grep | grep "${BASE_DIR}/lib" | grep 'DatartServerApplication' | awk {'print $2'}`
5153
echo "Datart is Running Now..... PID is ${PID} "
5254
fi
5355
}
@@ -60,7 +62,8 @@ datart_stop(){
6062
echo "Datart is not Running....."
6163
echo ""
6264
else
63-
ps -ef | awk '/DatartServerApplication/ && !/awk/{print $2}'| xargs kill -9
65+
#ps -ef | awk '/DatartServerApplication/ && !/awk/{print $2}'| xargs kill -9
66+
ps -ef | grep -v grep | grep "$BASE_DIR/lib" | grep 'DatartServerApplication' | awk {'print $2'} | xargs kill -9
6467

6568
fi
6669
}
@@ -77,7 +80,7 @@ case $1 in
7780
stop )
7881
echo ""
7982

80-
echo "Datart Stoping.......... "
83+
echo "Datart Stopping.......... "
8184

8285
echo ""
8386
datart_stop
@@ -100,7 +103,8 @@ case $1 in
100103
echo ""
101104
else
102105
echo ""
103-
PID=`ps -ef | awk '/DatartServerApplication/ && !/awk/{print $2}'`
106+
#PID=`ps -ef | awk '/DatartServerApplication/ && !/awk/{print $2}'`
107+
PID=`ps -ef | grep -v grep | grep "${BASE_DIR}/lib" | grep 'DatartServerApplication' | awk {'print $2'}`
104108
echo "Datart is Running..... PID is ${PID}"
105109
echo ""
106110
fi

config/datart.conf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ datart.address=http://127.0.0.1
1616
datart.send-mail=false
1717
datart.webdriver-path=http://127.0.0.1:4444/wd/hub
1818
datart.user.register=true
19-
datart.invite.duration=
20-
# 系统运行模式: normal-正常(默认),single-单组织
21-
datart.mode=normal
22-
# 用户名/密码: 仅单组织模式且两者都不为空时重置
19+
# 注册邮件有效期/小时, 默认48小时
20+
datart.register.expire-hours=
21+
# 邀请邮件有效期/小时, 默认48小时
22+
datart.invite.expire-hours=
23+
# 租户管理模式:platform-平台(默认),team-团队
24+
datart.tenant-management-mode=platform
25+
# 团队管理员用户名/密码: 仅team模式且两者都不为空时重置
2326
datart.admin.username=
2427
datart.admin.password=

config/profiles/application-config.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,20 @@ spring:
6262
server:
6363
port: ${server.port:8080}
6464
address: ${server.ip:0.0.0.0}
65+
ssl:
66+
enabled: false
67+
key-store: keystore.p12 # Absolute path
68+
key-store-password: password
69+
keyStoreType: PKCS12
70+
keyAlias: tomcat
6571

6672
datart:
6773
server:
6874
address: ${datart.address:http://127.0.0.1:8080}
6975

70-
# 系统运行模式:normal-正常(默认),single-单组织
71-
mode: normal
72-
# 用户名/密码: 仅单组织模式且两者都不为空时重置
76+
# 租户管理模式:plateform-平台(默认),team-团队
77+
tenant-management-mode: platform
78+
# 团队管理员用户名/密码: 仅team模式且两者都不为空时重置
7379
admin:
7480
username:
7581
password:
@@ -78,9 +84,9 @@ datart:
7884
register: true # 是否允许注册
7985
active:
8086
send-mail: ${datart.send-mail:false} # 注册用户时是否需要邮件验证激活
81-
82-
invite:
83-
duration: ${datart.invite.duration:3} #邀请有效期/天
87+
expire-hours: ${datart.register.expire-hours:48} # 注册邮件有效期/小时
88+
invite:
89+
expire-hours: ${datart.invite.expire-hours:48} # 邀请邮件有效期/小时
8490

8591
security:
8692
token:

core/src/main/java/datart/core/base/consts/SystemMode.java

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package datart.core.base.consts;
2+
3+
public enum TenantManagementMode {
4+
/** 团队模式 */
5+
TEAM,
6+
/** 平台模式 */
7+
PLATFORM;
8+
9+
}

core/src/main/java/datart/core/common/Application.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package datart.core.common;
2020

21-
import datart.core.base.consts.SystemMode;
21+
import datart.core.base.consts.TenantManagementMode;
2222
import lombok.extern.slf4j.Slf4j;
2323
import org.apache.commons.lang3.BooleanUtils;
2424
import org.apache.commons.lang3.StringUtils;
@@ -28,15 +28,15 @@
2828
import org.springframework.lang.NonNull;
2929
import org.springframework.stereotype.Component;
3030

31-
import static datart.core.base.consts.SystemMode.NORMAL;
31+
import static datart.core.base.consts.TenantManagementMode.PLATFORM;
3232

3333
@Component
3434
@Slf4j
3535
public class Application implements ApplicationContextAware {
3636

3737
private static ApplicationContext context;
3838

39-
private static SystemMode currMode;
39+
private static TenantManagementMode currMode;
4040

4141
@Override
4242
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
@@ -86,6 +86,10 @@ public static String getApiPrefix() {
8686
return getProperty("datart.server.path-prefix");
8787
}
8888

89+
public static String getServerPrefix() {
90+
return getProperty("server.servlet.context-path","/");
91+
}
92+
8993
public static String getTokenSecret() {
9094
return getProperty("datart.security.token.secret", "d@a$t%a^r&a*t");
9195
}
@@ -95,21 +99,21 @@ public static boolean canRegister() {
9599
}
96100

97101
public static String getAdminId() {
98-
if (getCurrMode().equals(SystemMode.SINGLE)){
102+
if (getCurrMode().equals(TenantManagementMode.TEAM)){
99103
return getProperty("datart.admin-id", "datart-admin");
100104
}
101105
return "";
102106
}
103107

104-
public static SystemMode getCurrMode() {
108+
public static TenantManagementMode getCurrMode() {
105109
if (currMode == null) {
106-
String mode = Application.getProperty("datart.mode");
110+
String mode = Application.getProperty("datart.tenant-management-mode");
107111
try {
108-
return SystemMode.valueOf(mode.toUpperCase());
112+
return TenantManagementMode.valueOf(mode.toUpperCase());
109113
} catch (Exception e) {
110-
log.warn("Unrecognized mode: '{}', and this will run in normal mode", mode);
114+
log.warn("Unrecognized tenant-management-mode: '{}', and this will run in platform tenant-management-mode", mode);
111115
}
112-
currMode = NORMAL;
116+
currMode = PLATFORM;
113117
}
114118
return currMode;
115119
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Datart
3+
* <p>
4+
* Copyright 2021
5+
* <p>
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package datart.core.common;
20+
21+
import org.apache.ibatis.javassist.ClassPool;
22+
import org.apache.ibatis.javassist.CtClass;
23+
import org.apache.ibatis.javassist.CtMethod;
24+
25+
public class ClassTransformer {
26+
27+
public static void transform() {
28+
transformSqlWriter();
29+
transformFlyway();
30+
}
31+
32+
private static void transformSqlWriter() {
33+
try {
34+
ClassPool classPool = ClassPool.getDefault();
35+
CtClass ctClass = classPool.get("org.apache.calcite.sql.pretty.SqlPrettyWriter");
36+
CtMethod keyword = ctClass.getDeclaredMethod("keyword");
37+
keyword.setBody("{ maybeWhitespace($1);" +
38+
" buf.append($1);" +
39+
" if (!$1.equals(\"\")) {" +
40+
" setNeedWhitespace(needWhitespaceAfter($1));" +
41+
" } " +
42+
"return;} ");
43+
ctClass.toClass();
44+
} catch (Exception e) {
45+
e.printStackTrace();
46+
}
47+
}
48+
49+
private static void transformFlyway() {
50+
try {
51+
ClassPool classPool = ClassPool.getDefault();
52+
CtClass ctClass = classPool.get("org.flywaydb.core.internal.database.mysql.MySQLConnection");
53+
CtMethod getIntVariableValue = ctClass.getDeclaredMethod("getIntVariableValue");
54+
getIntVariableValue.setBody("return 0;");
55+
56+
CtMethod doRestoreOriginalState = ctClass.getDeclaredMethod("doRestoreOriginalState");
57+
doRestoreOriginalState.setBody("return;");
58+
59+
CtMethod hasUserVariableResetCapability = ctClass.getDeclaredMethod("hasUserVariableResetCapability");
60+
hasUserVariableResetCapability.setBody("{return false;}");
61+
ctClass.toClass();
62+
} catch (Exception e) {
63+
e.printStackTrace();
64+
}
65+
}
66+
}

core/src/main/java/datart/core/common/WebUtils.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package datart.core.common;
1919

20-
import datart.core.base.exception.BaseException;
2120
import datart.core.base.exception.Exceptions;
2221
import lombok.extern.slf4j.Slf4j;
2322
import org.apache.commons.lang3.StringUtils;
@@ -74,19 +73,23 @@ public static <T> T screenShot(String url, OutputType<T> outputType, int imageWi
7473

7574
Double contentHeight = Double.parseDouble(webDriver.findElement(By.id("height")).getAttribute("value"));
7675

77-
if (imageWidth != contentWidth) {
76+
if (imageWidth>0 && imageWidth != contentWidth) {
7877
// scale the window
7978
webDriver.manage().window().setSize(new Dimension(imageWidth, contentHeight.intValue()));
80-
Thread.sleep(1000);
8179
}
80+
Thread.sleep(1500);
8281
// scale the window again
8382
contentWidth = Double.parseDouble(webDriver.findElement(By.id("width")).getAttribute("value"));
83+
contentWidth = contentWidth>0 ? contentWidth : 1920;
8484
contentHeight = Double.parseDouble(webDriver.findElement(By.id("height")).getAttribute("value"));
85+
contentHeight = contentHeight>0 ? contentHeight : 600;
8586
webDriver.manage().window().setSize(new Dimension(contentWidth.intValue(), contentHeight.intValue()));
8687
Thread.sleep(1000);
8788

8889
TakesScreenshot screenshot = (TakesScreenshot) webDriver;
89-
return screenshot.getScreenshotAs(outputType);
90+
T output = screenshot.getScreenshotAs(outputType);
91+
webDriver.quit();
92+
return output;
9093
}
9194

9295
public static File screenShot2File(String url, String path, int imageWidth) throws Exception {
@@ -123,6 +126,7 @@ private static WebDriver createChromeWebDriver(String driverPath) throws Excepti
123126
options.addArguments("disable-web-security");
124127
options.addArguments("no-proxy-server");
125128
options.addArguments("disable-dev-shm-usage");
129+
options.addArguments("window-size=2048,1536");
126130

127131
if (isRemoteDriver(driverPath)) {
128132
return new RemoteWebDriver(new URL(driverPath), options);

core/src/main/java/datart/core/data/provider/DataProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public DataProviderConfigTemplate getConfigTemplate() throws IOException {
7979

8080
public abstract String getConfigDescription(String name);
8181

82+
public abstract String getQueryKey(DataProviderSource config, QueryScript script, ExecuteParam executeParam) throws Exception;
83+
8284
public abstract Dataframe execute(DataProviderSource config, QueryScript script, ExecuteParam executeParam) throws Exception;
8385

8486
/**
@@ -121,5 +123,4 @@ public Set<StdSqlOperator> supportedStdFunctions(DataProviderSource source) {
121123
public void resetSource(DataProviderSource source) {
122124
}
123125

124-
125126
}

0 commit comments

Comments
 (0)