Merge pull request #882 from dataease/dev

Dev
This commit is contained in:
fit2cloudrd 2021-09-26 14:09:39 +08:00 committed by GitHub
commit a159dce308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 1185 additions and 563 deletions

View File

@ -94,11 +94,6 @@
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
@ -141,16 +136,6 @@
<artifactId>java-jwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.4.1.jre8</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.14</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
@ -179,49 +164,6 @@
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<!-- 执行 js 代码依赖 -->
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.tools</groupId>
<artifactId>profiler</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.tools</groupId>
<artifactId>chromeinspector</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.2</version>
</dependency>
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>0.15.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@ -229,63 +171,43 @@
<version>1.21</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
</dependency>
<!--xpath不加这个依赖会报错-->
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlcleaner</groupId>
<artifactId>htmlcleaner</artifactId>
<version>2.24</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20171018</version>
</dependency>
<!--<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>-->
<!-- 反射工具包 -->
<dependency>
<groupId>net.oneandone.reflections8</groupId>
<artifactId>reflections8</artifactId>
<version>0.11.7</version>
</dependency>
<!--开启 cache 缓存 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!-- ehcache 缓存 -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<!-- ehcache 缓存 -->
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>3.0.8</version>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.9.1</version>
</dependency>
<!--由于暂时插件接口未注册到公司仓库请先down下代码安装到本地仓库
https://github.com/dataease/dataease-plugins-->
<dependency>
<groupId>io.dataease</groupId>
<artifactId>dataease-plugin-interface</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.4</version>
</dependency>
<!-- kettle及数据源依赖 -->
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
@ -311,42 +233,26 @@
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<!--由于暂时插件接口未注册到公司仓库请先down下代码安装到本地仓库
https://github.com/dataease/dataease-plugins-->
<dependency>
<groupId>io.dataease</groupId>
<artifactId>dataease-plugin-interface</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>ST4</artifactId>
<version>4.0.8</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.4</version>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-ldap</artifactId>
</dependency>-->
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.4.1.jre8</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.14</version>
</dependency>
</dependencies>
<build>

View File

@ -14,20 +14,26 @@ import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.CodingUtil;
import io.dataease.commons.utils.LogUtil;
import io.dataease.commons.utils.ServletUtils;
import io.dataease.controller.sys.request.LdapAddRequest;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator;
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.plugins.util.PluginUtils;
import io.dataease.plugins.xpack.ldap.dto.request.LdapValidateRequest;
import io.dataease.plugins.xpack.ldap.dto.response.ValidateResult;
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
import io.dataease.service.sys.SysUserService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -41,6 +47,10 @@ public class AuthServer implements AuthApi {
private AuthUserService authUserService;
@Autowired
private SysUserService sysUserService;
@Override
@ -48,7 +58,6 @@ public class AuthServer implements AuthApi {
String username = loginDto.getUsername();
String password = loginDto.getPassword();
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
// 增加ldap登录方式
Integer loginType = loginDto.getLoginType();
@ -56,11 +65,23 @@ public class AuthServer implements AuthApi {
if (loginType == 1 && isSupportLdap) {
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
LdapValidateRequest request = LdapValidateRequest.builder().userName(username).password(pwd).build();
ValidateResult validateResult = ldapXpackService.login(request);
ValidateResult<XpackLdapUserEntity> validateResult = ldapXpackService.login(request);
if (!validateResult.isSuccess()) {
DataEaseException.throwException(validateResult.getMsg());
}
username = validateResult.getUserName();
XpackLdapUserEntity ldapUserEntity = validateResult.getData();
SysUserEntity user = authUserService.getUserByName(username);
if(ObjectUtils.isEmpty(user) || ObjectUtils.isEmpty(user.getUserId())) {
LdapAddRequest ldapAddRequest = new LdapAddRequest();
ldapAddRequest.setUsers(new ArrayList<XpackLdapUserEntity>(){{add(ldapUserEntity);}});
ldapAddRequest.setEnabled(1L);
ldapAddRequest.setDeptId(1L);
ldapAddRequest.setRoleIds(new ArrayList<Long>(){{add(2L);}});
sysUserService.validateExistUser(ldapUserEntity.getUserName(), ldapUserEntity.getEmail());
sysUserService.saveLdapUsers(ldapAddRequest);
}
username = validateResult.getData().getUserName();
}
// 增加ldap登录方式

View File

@ -21,8 +21,6 @@ public class Datasource implements Serializable {
private String status;
private String computeType;
private String configuration;
private static final long serialVersionUID = 1L;

View File

@ -643,76 +643,6 @@ public class DatasourceExample {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andComputeTypeIsNull() {
addCriterion("compute_type is null");
return (Criteria) this;
}
public Criteria andComputeTypeIsNotNull() {
addCriterion("compute_type is not null");
return (Criteria) this;
}
public Criteria andComputeTypeEqualTo(String value) {
addCriterion("compute_type =", value, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeNotEqualTo(String value) {
addCriterion("compute_type <>", value, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeGreaterThan(String value) {
addCriterion("compute_type >", value, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeGreaterThanOrEqualTo(String value) {
addCriterion("compute_type >=", value, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeLessThan(String value) {
addCriterion("compute_type <", value, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeLessThanOrEqualTo(String value) {
addCriterion("compute_type <=", value, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeLike(String value) {
addCriterion("compute_type like", value, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeNotLike(String value) {
addCriterion("compute_type not like", value, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeIn(List<String> values) {
addCriterion("compute_type in", values, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeNotIn(List<String> values) {
addCriterion("compute_type not in", values, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeBetween(String value1, String value2) {
addCriterion("compute_type between", value1, value2, "computeType");
return (Criteria) this;
}
public Criteria andComputeTypeNotBetween(String value1, String value2) {
addCriterion("compute_type not between", value1, value2, "computeType");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -10,7 +10,6 @@
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="compute_type" jdbcType="VARCHAR" property="computeType" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.Datasource">
<result column="configuration" jdbcType="LONGVARCHAR" property="configuration" />
@ -74,7 +73,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, `desc`, `type`, create_time, update_time, create_by, `status`, compute_type
id, `name`, `desc`, `type`, create_time, update_time, create_by, `status`
</sql>
<sql id="Blob_Column_List">
configuration
@ -130,12 +129,12 @@
<insert id="insert" parameterType="io.dataease.base.domain.Datasource">
insert into datasource (id, `name`, `desc`,
`type`, create_time, update_time,
create_by, `status`, compute_type,
configuration)
create_by, `status`, configuration
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{createBy,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{computeType,jdbcType=VARCHAR},
#{configuration,jdbcType=LONGVARCHAR})
#{createBy,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{configuration,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.Datasource">
insert into datasource
@ -164,9 +163,6 @@
<if test="status != null">
`status`,
</if>
<if test="computeType != null">
compute_type,
</if>
<if test="configuration != null">
configuration,
</if>
@ -196,9 +192,6 @@
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="computeType != null">
#{computeType,jdbcType=VARCHAR},
</if>
<if test="configuration != null">
#{configuration,jdbcType=LONGVARCHAR},
</if>
@ -237,9 +230,6 @@
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.computeType != null">
compute_type = #{record.computeType,jdbcType=VARCHAR},
</if>
<if test="record.configuration != null">
configuration = #{record.configuration,jdbcType=LONGVARCHAR},
</if>
@ -258,7 +248,6 @@
update_time = #{record.updateTime,jdbcType=BIGINT},
create_by = #{record.createBy,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
compute_type = #{record.computeType,jdbcType=VARCHAR},
configuration = #{record.configuration,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -273,8 +262,7 @@
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_by = #{record.createBy,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
compute_type = #{record.computeType,jdbcType=VARCHAR}
`status` = #{record.status,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -303,9 +291,6 @@
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="computeType != null">
compute_type = #{computeType,jdbcType=VARCHAR},
</if>
<if test="configuration != null">
configuration = #{configuration,jdbcType=LONGVARCHAR},
</if>
@ -321,7 +306,6 @@
update_time = #{updateTime,jdbcType=BIGINT},
create_by = #{createBy,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
compute_type = #{computeType,jdbcType=VARCHAR},
configuration = #{configuration,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
@ -333,8 +317,7 @@
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_by = #{createBy,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
compute_type = #{computeType,jdbcType=VARCHAR}
`status` = #{status,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -337,7 +337,7 @@ public class ExcelXlsxReader extends DefaultHandler {
formatString = style.getDataFormatString();
short format = this.formatIndex;
if (format == 14 || format == 31 || format == 57 ||format == 59||
format == 58 || (176 <= format && format < 178)
format == 58 || (176 < format && format < 178)
|| (182 <= format && format <= 196) ||
(210 <= format && format <= 213) || (208 == format))
{ // 日期
@ -440,10 +440,6 @@ public class ExcelXlsxReader extends DefaultHandler {
}
}
}
if(curCol==1){
System.out.println(type);
System.out.println(nextDataType);
}
return thisStr;
}

View File

@ -7,7 +7,7 @@ public enum DatasourceTypes {
sqlServer("sqlServer", "sqlServer", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
doris("doris", "doris", "com.mysql.jdbc.Driver", "`", "`", "", ""),
oracle("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
ch("ch", "ch", "ru.yandex.clickhouse.ClickHouseDriver", "`", "`", "'", "'"),
ck("ch", "ch", "ru.yandex.clickhouse.ClickHouseDriver", "`", "`", "'", "'"),
es("es", "es", "", "\"", "\"", "\"", "\"");
private String feature;

View File

@ -10,5 +10,7 @@ public class EsConfigDTO {
private String url;
private String username;
private String password;
private String version;
private String uri;
private String dataSourceType = "es";
}

View File

@ -12,6 +12,7 @@ public class EsReponse {
private String cursor;
private Integer status;
private Error error;
private String version;
@Data
public class Error{

View File

@ -1,5 +1,7 @@
package io.dataease.datasource.provider;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import io.dataease.commons.utils.HttpClientConfig;
@ -10,6 +12,7 @@ import io.dataease.datasource.dto.es.Requst;
import io.dataease.datasource.dto.es.RequstWithCursor;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator;
import io.dataease.provider.es.EsQueryProvider;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
@ -46,15 +49,16 @@ public class EsProvider extends DatasourceProvider {
List<String[]> list = new LinkedList<>();
try {
EsConfigDTO esConfigDTO = new Gson().fromJson(dsr.getDatasource().getConfiguration(), EsConfigDTO.class);
HttpClientConfig httpClientConfig = new HttpClientConfig();
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
if(StringUtils.isNotEmpty(esConfigDTO.getUsername())){
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
}
Requst requst = new Requst();
requst.setQuery(dsr.getQuery());
requst.setFetch_size(dsr.getFetchSize());
String url = esConfigDTO.getUrl().endsWith("/") ? esConfigDTO.getUrl() + "_sql?format=json" : esConfigDTO.getUrl() + "/" + "_sql?format=json";
String url = esConfigDTO.getUrl().endsWith("/") ? esConfigDTO.getUrl() + esConfigDTO.getUri() + "?format=json" : esConfigDTO.getUrl() + "/" + esConfigDTO.getUri() + "?format=json";
String response = HttpClientUtil.post(url, new Gson().toJson(requst), httpClientConfig);
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
@ -84,7 +88,7 @@ public class EsProvider extends DatasourceProvider {
public List<String[]> fetchResult(DatasourceRequest datasourceRequest) throws Exception {
List<String[]> list = new LinkedList<>();
try {
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "_sql?format=json");
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
list = fetchResult(response);
} catch (Exception e) {
DataEaseException.throwException(e);
@ -110,7 +114,7 @@ public class EsProvider extends DatasourceProvider {
public List<TableFiled> fetchResultField(DatasourceRequest datasourceRequest) throws Exception {
List<TableFiled> tableFileds = new ArrayList<>();
try {
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "_sql?format=json");
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
tableFileds = fetchResultField(response);
} catch (Exception e) {
DataEaseException.throwException(e);
@ -140,7 +144,7 @@ public class EsProvider extends DatasourceProvider {
public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception {
Map<String, List> result = new HashMap<>();
try {
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "_sql?format=json");
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
result.put("dataList", fetchResult(response));
result.put("fieldList", fetchResultField(response));
} catch (Exception e) {
@ -157,7 +161,7 @@ public class EsProvider extends DatasourceProvider {
public List<String> getTables(DatasourceRequest datasourceRequest) throws Exception {
List<String> tables = new ArrayList<>();
try {
String response = exexQuery(datasourceRequest, "show tables", "_sql?format=json");
String response = exexQuery(datasourceRequest, "show tables", "?format=json");
tables = fetchTables(response);
} catch (Exception e) {
DataEaseException.throwException(e);
@ -176,6 +180,9 @@ public class EsProvider extends DatasourceProvider {
if(row.length == 3 && row[1].equalsIgnoreCase("TABLE") && row[2].equalsIgnoreCase("INDEX")){
tables.add(row[0]);
}
if(row.length == 2 && row[1].equalsIgnoreCase("BASE TABLE")){
tables.add(row[0]);
}
}
return tables;
}
@ -189,7 +196,7 @@ public class EsProvider extends DatasourceProvider {
public List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
List<TableFiled> tableFileds = new ArrayList<>();
try {
String response = exexQuery(datasourceRequest, "desc " + datasourceRequest.getTable(), "_sql?format=json");
String response = exexQuery(datasourceRequest, "desc " + datasourceRequest.getTable(), "?format=json");
tableFileds = fetchResultField(response);
} catch (Exception e) {
DataEaseException.throwException(e);
@ -199,16 +206,34 @@ public class EsProvider extends DatasourceProvider {
@Override
public void checkStatus(DatasourceRequest datasourceRequest) throws Exception {
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
String response = exexGetQuery(datasourceRequest);
String version = JSONObject.parseObject(response).getJSONObject("version").getString("number");
if(Integer.valueOf(version.substring(0,1)) < 6 ){
throw new Exception(Translator.get("i18n_es_limit"));
}
if(Integer.valueOf(version.substring(2,3)) < 3 ){
throw new Exception(Translator.get("i18n_es_limit"));
}
if(Integer.valueOf(version.substring(0,1)) == 6 ) {
esConfigDTO.setUri("_xpack/sql");
}
if(Integer.valueOf(version.substring(0,1)) == 7 ) {
esConfigDTO.setUri("_sql");
}
datasourceRequest.getDatasource().setConfiguration(new Gson().toJson(esConfigDTO));
getTables(datasourceRequest);
}
private String exexQuery(DatasourceRequest datasourceRequest, String sql, String uri){
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
uri = esConfigDTO.getUri()+uri;
HttpClientConfig httpClientConfig = new HttpClientConfig();
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
if(StringUtils.isNotEmpty(esConfigDTO.getUsername()) && StringUtils.isNotEmpty(esConfigDTO.getPassword())){
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
}
Requst requst = new Requst();
requst.setQuery(sql);
@ -218,4 +243,17 @@ public class EsProvider extends DatasourceProvider {
return response;
}
private String exexGetQuery(DatasourceRequest datasourceRequest){
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
HttpClientConfig httpClientConfig = new HttpClientConfig();
if(StringUtils.isNotEmpty(esConfigDTO.getUsername()) && StringUtils.isNotEmpty(esConfigDTO.getPassword())){
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
}
String response = HttpClientUtil.get(esConfigDTO.getUrl(), httpClientConfig);
return response;
}
}

View File

@ -7,6 +7,7 @@ import io.dataease.datasource.dto.*;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator;
import io.dataease.provider.QueryProvider;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.beans.PropertyVetoException;
@ -127,7 +128,7 @@ public class JdbcProvider extends DatasourceProvider {
connection = getConnectionFromPool(datasourceRequest);
Statement stat = connection.createStatement();
rs = stat.executeQuery(datasourceRequest.getQuery());
return fetchResultField(rs);
return fetchResultField(rs, datasourceRequest);
} catch (SQLException e) {
DataEaseException.throwException(e);
} catch (Exception e) {
@ -152,7 +153,7 @@ public class JdbcProvider extends DatasourceProvider {
Statement stat = connection.createStatement();
rs = stat.executeQuery(datasourceRequest.getQuery());
dataList = fetchResult(rs);
fieldList = fetchResultField(rs);
fieldList = fetchResultField(rs, datasourceRequest);
result.put("dataList", dataList);
result.put("fieldList", fieldList);
return result;
@ -168,7 +169,7 @@ public class JdbcProvider extends DatasourceProvider {
return new HashMap<>();
}
private List<TableFiled> fetchResultField(ResultSet rs) throws Exception {
private List<TableFiled> fetchResultField(ResultSet rs, DatasourceRequest datasourceRequest) throws Exception {
List<TableFiled> fieldList = new ArrayList<>();
ResultSetMetaData metaData = rs.getMetaData();
int columnCount = metaData.getColumnCount();
@ -180,7 +181,13 @@ public class JdbcProvider extends DatasourceProvider {
field.setFieldName(l);
field.setRemarks(l);
field.setFieldType(t);
field.setFieldSize(metaData.getColumnDisplaySize(j + 1));
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())){
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType());
field.setFieldSize(qp.transFieldSize(t));
}else {
field.setFieldSize(metaData.getColumnDisplaySize(j + 1));
}
if(t.equalsIgnoreCase("LONG")){field.setFieldSize(65533);} //oracle LONG
if(StringUtils.isNotEmpty(t) && t.toLowerCase().contains("date") && field.getFieldSize() < 50 ){
field.setFieldSize(50);
@ -193,9 +200,9 @@ public class JdbcProvider extends DatasourceProvider {
@Override
public List<String> getTables(DatasourceRequest datasourceRequest) throws Exception {
List<String> tables = new ArrayList<>();
String queryStr = getTablesSql(datasourceRequest);
Connection con = null;
try {
String queryStr = getTablesSql(datasourceRequest);
con = getConnection(datasourceRequest);
Statement statement = con.createStatement();
ResultSet resultSet = statement.executeQuery(queryStr);
@ -204,6 +211,20 @@ public class JdbcProvider extends DatasourceProvider {
}
resultSet.close();
statement.close();
String queryView = getViewSql(datasourceRequest);
if(StringUtils.isNotEmpty(queryView)){
con = getConnection(datasourceRequest);
statement = con.createStatement();
resultSet = statement.executeQuery(queryView);
while (resultSet.next()) {
tables.add(resultSet.getString(1));
}
resultSet.close();
statement.close();
}
return tables;
} catch (Exception e) {
DataEaseException.throwException(e);
@ -251,19 +272,19 @@ public class JdbcProvider extends DatasourceProvider {
while (resultSet.next()) {
String tableName = resultSet.getString("TABLE_NAME");
String database = null;
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase("ch")){
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())){
database = resultSet.getString("TABLE_SCHEM");
}else {
database = resultSet.getString("TABLE_CAT");
}
if(database != null){
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) {
TableFiled tableFiled = getTableFiled(resultSet);
TableFiled tableFiled = getTableFiled(resultSet, datasourceRequest);
list.add(tableFiled);
}
}else {
if (tableName.equals(datasourceRequest.getTable())) {
TableFiled tableFiled = getTableFiled(resultSet);
TableFiled tableFiled = getTableFiled(resultSet, datasourceRequest);
list.add(tableFiled);
}
}
@ -281,7 +302,7 @@ public class JdbcProvider extends DatasourceProvider {
return list;
}
private TableFiled getTableFiled(ResultSet resultSet) throws SQLException {
private TableFiled getTableFiled(ResultSet resultSet, DatasourceRequest datasourceRequest) throws SQLException {
TableFiled tableFiled = new TableFiled();
String colName = resultSet.getString("COLUMN_NAME");
tableFiled.setFieldName(colName);
@ -290,13 +311,19 @@ public class JdbcProvider extends DatasourceProvider {
remarks = colName;
}
tableFiled.setRemarks(remarks);
tableFiled.setFieldSize(Integer.valueOf(resultSet.getString("COLUMN_SIZE")));
String dbType = resultSet.getString("TYPE_NAME").toUpperCase();
tableFiled.setFieldType(dbType);
if(dbType.equalsIgnoreCase("LONG")){tableFiled.setFieldSize(65533);}
if(StringUtils.isNotEmpty(dbType) && dbType.toLowerCase().contains("date") && tableFiled.getFieldSize() < 50 ){
tableFiled.setFieldSize(50);
}
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())){
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType());
tableFiled.setFieldSize(qp.transFieldSize(dbType));
}else {
tableFiled.setFieldSize(Integer.valueOf(resultSet.getString("COLUMN_SIZE")));
}
return tableFiled;
}
@ -442,7 +469,7 @@ public class JdbcProvider extends DatasourceProvider {
driver = pgConfigration.getDriver();
jdbcurl = pgConfigration.getJdbc();
break;
case ch:
case ck:
CHConfigration chConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), CHConfigration.class);
username = chConfigration.getUsername();
password = chConfigration.getPassword();
@ -506,7 +533,7 @@ public class JdbcProvider extends DatasourceProvider {
dataSource.setJdbcUrl(pgConfigration.getJdbc());
jdbcDTO = pgConfigration;
break;
case ch:
case ck:
CHConfigration chConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), CHConfigration.class);
dataSource.setUser(chConfigration.getUsername());
dataSource.setDriverClass(chConfigration.getDriver());
@ -567,8 +594,8 @@ public class JdbcProvider extends DatasourceProvider {
if(StringUtils.isEmpty(pgConfigration.getSchema())){
throw new Exception(Translator.get("i18n_schema_is_empty"));
}
return "SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg%' AND tablename NOT LIKE 'sql_%' AND schemaname='SCHEMA' ;".replace("SCHEMA", pgConfigration.getSchema());
case ch:
return "SELECT tablename FROM pg_tables WHERE schemaname='SCHEMA' ;".replace("SCHEMA", pgConfigration.getSchema());
case ck:
CHConfigration chConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), CHConfigration.class);
return "SELECT name FROM system.tables where database='DATABASE';".replace("DATABASE", chConfigration.getDataBase());
default:
@ -576,6 +603,40 @@ public class JdbcProvider extends DatasourceProvider {
}
}
private String getViewSql(DatasourceRequest datasourceRequest) throws Exception {
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
switch (datasourceType) {
case mysql:
return null;
case doris:
return null;
case sqlServer:
SqlServerConfigration sqlServerConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfigration.class);
if(StringUtils.isEmpty(sqlServerConfigration.getSchema())){
throw new Exception(Translator.get("i18n_schema_is_empty"));
}
return "SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'DS_SCHEMA' ;"
.replace("DATABASE", sqlServerConfigration.getDataBase())
.replace("DS_SCHEMA", sqlServerConfigration.getSchema());
case oracle:
OracleConfigration oracleConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), OracleConfigration.class);
if(StringUtils.isEmpty(oracleConfigration.getSchema())){
throw new Exception(Translator.get("i18n_schema_is_empty"));
}
return "select VIEW_NAME from all_views where owner='" + oracleConfigration.getSchema() + "'";
case pg:
PgConfigration pgConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), PgConfigration.class);
if(StringUtils.isEmpty(pgConfigration.getSchema())){
throw new Exception(Translator.get("i18n_schema_is_empty"));
}
return "SELECT viewname FROM pg_views WHERE schemaname='SCHEMA' ;".replace("SCHEMA", pgConfigration.getSchema());
case ck:
return null;
default:
return null;
}
}
private String getSchemaSql(DatasourceRequest datasourceRequest) {
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
switch (datasourceType) {

View File

@ -52,8 +52,8 @@ public class ProviderFactory implements ApplicationContextAware {
return context.getBean("oracleQuery", QueryProvider.class);
case es:
return context.getBean("esQuery", QueryProvider.class);
case ch:
return context.getBean("chQuery", QueryProvider.class);
case ck:
return context.getBean("ckQuery", QueryProvider.class);
default:
return context.getBean("mysqlQuery", QueryProvider.class);
}
@ -62,16 +62,10 @@ public class ProviderFactory implements ApplicationContextAware {
public static DDLProvider getDDLProvider(String type) {
DatasourceTypes datasourceType = DatasourceTypes.valueOf(type);
switch (datasourceType) {
case mysql:
return context.getBean("mysqlDDL", DDLProvider.class);
case doris:
return context.getBean("dorisDDL", DDLProvider.class);
case oracle:
return context.getBean("oracleDDL", DDLProvider.class);
case sqlServer:
return context.getBean("mysqlDDL", DDLProvider.class);
default:
return context.getBean("mysqlDDL", DDLProvider.class);
return context.getBean("dorisDDL", DDLProvider.class);
}
}

View File

@ -65,9 +65,10 @@ public class DatasourceService {
datasource.setUpdateTime(currentTimeMillis);
datasource.setCreateTime(currentTimeMillis);
datasource.setCreateBy(String.valueOf(AuthUtils.getUser().getUsername()));
checkAndUpdateDatasourceStatus(datasource);
datasourceMapper.insertSelective(datasource);
handleConnectionPool(datasource, "add");
checkAndUpdateDatasourceStatus(datasource);
return datasource;
}
@ -129,9 +130,9 @@ public class DatasourceService {
checkName(datasource);
datasource.setCreateTime(null);
datasource.setUpdateTime(System.currentTimeMillis());
checkAndUpdateDatasourceStatus(datasource);
datasourceMapper.updateByPrimaryKeySelective(datasource);
handleConnectionPool(datasource, "edit");
checkAndUpdateDatasourceStatus(datasource);
}
public ResultHolder validate(Datasource datasource) throws Exception {
@ -256,10 +257,8 @@ public class DatasourceService {
datasourceRequest.setDatasource(datasource);
datasourceProvider.checkStatus(datasourceRequest);
datasource.setStatus("Success");
datasourceMapper.updateByPrimaryKeySelective(datasource);
} catch (Exception e) {
datasource.setStatus("Error");
datasourceMapper.updateByPrimaryKeySelective(datasource);
}
}

View File

@ -1,5 +1,7 @@
package io.dataease.plugins.server;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -39,38 +41,57 @@ public class SSOServer {
@GetMapping("/callBack")
public ModelAndView callBack(@RequestParam("code") String code, @RequestParam("state") String state) {
Map<String, OidcXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((OidcXpackService.class));
if(beansOfType.keySet().size() == 0) {
DEException.throwException("缺少oidc插件");
}
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
Boolean suuportOIDC = oidcXpackService.isSuuportOIDC();
if (!suuportOIDC) {
DEException.throwException("未开启oidc");
}
Map<String, String> config = config(oidcXpackService);
SSOToken ssoToken = oidcXpackService.requestSsoToken(config, code, state);
SSOUserInfo ssoUserInfo = oidcXpackService.requestUserInfo(config, ssoToken.getAccessToken());
SysUserEntity sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
if(null == sysUserEntity){
sysUserService.saveOIDCUser(ssoUserInfo);
sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
}
TokenInfo tokenInfo = TokenInfo.builder().userId(sysUserEntity.getUserId()).username(sysUserEntity.getUsername()).build();
String realPwd = CodingUtil.md5(sysUserService.defaultPWD());
String token = JWTUtils.sign(tokenInfo, realPwd);
ServletUtils.setToken(token);
HttpServletResponse response = ServletUtils.response();
Cookie cookie_token = new Cookie("Authorization", token);cookie_token.setPath("/");
Cookie cookie_id_token = new Cookie("IdToken", ssoToken.getIdToken());cookie_id_token.setPath("/");
Cookie cookie_ac_token = new Cookie("AccessToken", ssoToken.getAccessToken());cookie_ac_token.setPath("/");
ModelAndView modelAndView = new ModelAndView("redirect:/");
HttpServletResponse response = ServletUtils.response();
response.addCookie(cookie_token);
response.addCookie(cookie_id_token);
response.addCookie(cookie_ac_token);
ModelAndView modelAndView = new ModelAndView("redirect:/");
try {
Map<String, OidcXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((OidcXpackService.class));
if(beansOfType.keySet().size() == 0) {
DEException.throwException("缺少oidc插件");
}
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
Boolean suuportOIDC = oidcXpackService.isSuuportOIDC();
if (!suuportOIDC) {
DEException.throwException("未开启oidc");
}
Map<String, String> config = config(oidcXpackService);
SSOToken ssoToken = oidcXpackService.requestSsoToken(config, code, state);
SSOUserInfo ssoUserInfo = oidcXpackService.requestUserInfo(config, ssoToken.getAccessToken());
SysUserEntity sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
if(null == sysUserEntity){
sysUserService.validateExistUser(ssoUserInfo.getUsername(), ssoUserInfo.getEmail());
sysUserService.saveOIDCUser(ssoUserInfo);
sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
}
TokenInfo tokenInfo = TokenInfo.builder().userId(sysUserEntity.getUserId()).username(sysUserEntity.getUsername()).build();
String realPwd = CodingUtil.md5(sysUserService.defaultPWD());
String token = JWTUtils.sign(tokenInfo, realPwd);
ServletUtils.setToken(token);
Cookie cookie_token = new Cookie("Authorization", token);cookie_token.setPath("/");
Cookie cookie_id_token = new Cookie("IdToken", ssoToken.getIdToken());cookie_id_token.setPath("/");
Cookie cookie_ac_token = new Cookie("AccessToken", ssoToken.getAccessToken());cookie_ac_token.setPath("/");
response.addCookie(cookie_token);
response.addCookie(cookie_id_token);
response.addCookie(cookie_ac_token);
}catch(Exception e) {
String msg;
try {
msg = URLEncoder.encode(e.getMessage(), "UTF-8");
Cookie cookie_error = new Cookie("OidcError", msg);
cookie_error.setPath("/");
response.addCookie(cookie_error);
return modelAndView;
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return modelAndView;
}
private Map<String, String> config(OidcXpackService oidcXpackService) {

View File

@ -30,7 +30,11 @@ public class XLdapServer {
@PostMapping("/testConn")
public void testConn() {
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
ldapXpackService.testConn();
try {
ldapXpackService.testConn();
}catch(Exception e) {
throw new RuntimeException(e);
}
}
@PostMapping("/users")

View File

@ -54,6 +54,9 @@ public abstract class QueryProvider {
public abstract String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList);
public Integer transFieldSize(String type){
return 50;
};
/**
* 单指标汇总
*

View File

@ -1,17 +1,17 @@
package io.dataease.provider.ch;
package io.dataease.provider.ck;
import io.dataease.provider.SQLConstants;
import static io.dataease.datasource.constants.DatasourceTypes.ch;
import static io.dataease.datasource.constants.DatasourceTypes.ck;
/**
* @Author gin
* @Date 2021/7/8 7:22 下午
*/
public class CHConstants extends SQLConstants {
public static final String KEYWORD_TABLE = ch.getKeywordPrefix() + "%s" + ch.getKeywordSuffix();
public class CKConstants extends SQLConstants {
public static final String KEYWORD_TABLE = ck.getKeywordPrefix() + "%s" + ck.getKeywordSuffix();
public static final String KEYWORD_FIX = "%s." + ch.getKeywordPrefix() + "%s" + ch.getKeywordSuffix();
public static final String KEYWORD_FIX = "%s." + ck.getKeywordPrefix() + "%s" + ck.getKeywordSuffix();
public static final String toInt32 = "toInt32(%s)";

View File

@ -1,4 +1,4 @@
package io.dataease.provider.ch;
package io.dataease.provider.ck;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.base.domain.DatasetTableFieldExample;
@ -32,8 +32,8 @@ import static io.dataease.provider.SQLConstants.TABLE_ALIAS_PREFIX;
* @Author gin
* @Date 2021/5/17 2:43 下午
*/
@Service("chQuery")
public class CHQueryProvider extends QueryProvider {
@Service("ckQuery")
public class CKQueryProvider extends QueryProvider {
@Resource
private DatasetTableFieldMapper datasetTableFieldMapper;
@ -80,6 +80,25 @@ public class CHQueryProvider extends QueryProvider {
}
}
@Override
public Integer transFieldSize(String field){
Integer type = transFieldType(field);
switch (type) {
case 0:
return 65533;
case 1:
return 60;
case 2:
return 0;
case 3:
return 0;
case 4:
return 0;
default:
return 65533;
}
}
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp ORDER BY null " + " LIMIT 0,1000";
@ -88,7 +107,7 @@ public class CHQueryProvider extends QueryProvider {
@Override
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CHConstants.KEYWORD_TABLE, table))
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
.build();
List<SQLObj> xFields = new ArrayList<>();
@ -100,9 +119,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(f.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
String fieldName = "";
@ -110,29 +129,29 @@ public class CHQueryProvider extends QueryProvider {
if (f.getDeExtractType() == DeTypeConstants.DE_TIME) {
if (f.getDeType() == DeTypeConstants.DE_INT || f.getDeType() == DeTypeConstants.DE_FLOAT) {
if(f.getType().equalsIgnoreCase("DATE")){
fieldName = String.format(CHConstants.toInt32, String.format(CHConstants.toDateTime, originField)) + "*1000";
fieldName = String.format(CKConstants.toInt32, String.format(CKConstants.toDateTime, originField)) + "*1000";
}else {
fieldName = String.format(CHConstants.toInt32, originField) + "*1000";
fieldName = String.format(CKConstants.toInt32, originField) + "*1000";
}
} else {
fieldName = originField;
}
} else if (f.getDeExtractType() == DeTypeConstants.DE_STRING) {
if (f.getDeType() == DeTypeConstants.DE_INT) {
fieldName = String.format(CHConstants.toInt64, originField);
fieldName = String.format(CKConstants.toInt64, originField);
} else if (f.getDeType() == DeTypeConstants.DE_FLOAT) {
fieldName = String.format(CHConstants.toFloat64, originField);
fieldName = String.format(CKConstants.toFloat64, originField);
} else if (f.getDeType() == DeTypeConstants.DE_TIME) {
fieldName = String.format(CHConstants.toDateTime, originField);
fieldName = String.format(CKConstants.toDateTime, originField);
} else {
fieldName = originField;
}
} else {
if (f.getDeType() == DeTypeConstants.DE_TIME) {
String cast = String.format(CHConstants.toFloat64, originField);
fieldName = String.format(CHConstants.toDateTime, cast);
String cast = String.format(CKConstants.toFloat64, originField);
fieldName = String.format(CKConstants.toDateTime, cast);
} else if (f.getDeType() == DeTypeConstants.DE_INT) {
fieldName = String.format(CHConstants.toInt64, originField);
fieldName = String.format(CKConstants.toInt64, originField);
} else {
fieldName = originField;
}
@ -180,7 +199,7 @@ public class CHQueryProvider extends QueryProvider {
@Override
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CHConstants.KEYWORD_TABLE, table))
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
.build();
List<SQLObj> xFields = new ArrayList<>();
@ -194,9 +213,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
// 处理横轴字段
@ -224,9 +243,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(y.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
@ -274,7 +293,7 @@ public class CHQueryProvider extends QueryProvider {
ST st = stg.getInstanceOf("querySql");
SQLObj tableSQL = SQLObj.builder()
.tableName(String.format(CHConstants.BRACKETS, sql))
.tableName(String.format(CKConstants.BRACKETS, sql))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
.build();
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
@ -286,7 +305,7 @@ public class CHQueryProvider extends QueryProvider {
@Override
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CHConstants.KEYWORD_TABLE, table))
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
.build();
List<SQLObj> xFields = new ArrayList<>();
@ -300,9 +319,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
// 处理横轴字段
@ -347,7 +366,7 @@ public class CHQueryProvider extends QueryProvider {
ST st = stg.getInstanceOf("previewSql");
st.add("isGroup", false);
SQLObj tableSQL = SQLObj.builder()
.tableName(String.format(CHConstants.BRACKETS, sql))
.tableName(String.format(CKConstants.BRACKETS, sql))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
.build();
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
@ -369,7 +388,7 @@ public class CHQueryProvider extends QueryProvider {
@Override
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CHConstants.KEYWORD_TABLE, table))
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
.build();
List<SQLObj> xFields = new ArrayList<>();
@ -386,9 +405,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
// 处理横轴字段
@ -416,9 +435,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(y.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
@ -466,7 +485,7 @@ public class CHQueryProvider extends QueryProvider {
ST st = stg.getInstanceOf("querySql");
SQLObj tableSQL = SQLObj.builder()
.tableName(String.format(CHConstants.BRACKETS, sql))
.tableName(String.format(CKConstants.BRACKETS, sql))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
.build();
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
@ -483,7 +502,7 @@ public class CHQueryProvider extends QueryProvider {
@Override
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, Datasource ds) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CHConstants.KEYWORD_TABLE, table))
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
.build();
List<SQLObj> xFields = new ArrayList<>();
@ -497,9 +516,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
// 处理横轴字段
@ -530,9 +549,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(y.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
@ -580,7 +599,7 @@ public class CHQueryProvider extends QueryProvider {
ST st = stg.getInstanceOf("querySql");
SQLObj tableSQL = SQLObj.builder()
.tableName(String.format(CHConstants.BRACKETS, sql))
.tableName(String.format(CKConstants.BRACKETS, sql))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
.build();
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
@ -603,7 +622,7 @@ public class CHQueryProvider extends QueryProvider {
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
// 字段汇总 排序等
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CHConstants.KEYWORD_TABLE, table))
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
.build();
List<SQLObj> yFields = new ArrayList<>();
@ -617,9 +636,9 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(y.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
} else {
originField = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
@ -662,7 +681,7 @@ public class CHQueryProvider extends QueryProvider {
ST st = stg.getInstanceOf("querySql");
SQLObj tableSQL = SQLObj.builder()
.tableName(String.format(CHConstants.BRACKETS, sql))
.tableName(String.format(CKConstants.BRACKETS, sql))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
.build();
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
@ -757,17 +776,17 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(CHConstants.toDateTime, originName);
whereName = String.format(CKConstants.toDateTime, originName);
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == 4) {
String cast = String.format(CHConstants.toFloat64, originName);
whereName = String.format(CHConstants.toDateTime, cast);
String cast = String.format(CKConstants.toFloat64, originName);
whereName = String.format(CKConstants.toDateTime, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
@ -776,7 +795,7 @@ public class CHQueryProvider extends QueryProvider {
whereName = originName;
}
if (StringUtils.equalsIgnoreCase(request.getTerm(), "null")) {
whereValue = CHConstants.WHERE_VALUE_NULL;
whereValue = CKConstants.WHERE_VALUE_NULL;
} else if (StringUtils.equalsIgnoreCase(request.getTerm(), "not_null")) {
whereTerm = String.format(whereTerm, originName);
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "in")) {
@ -784,7 +803,7 @@ public class CHQueryProvider extends QueryProvider {
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "like")) {
whereValue = "'%" + value + "%'";
} else {
whereValue = String.format(CHConstants.WHERE_VALUE_VALUE, value);
whereValue = String.format(CKConstants.WHERE_VALUE_VALUE, value);
}
list.add(SQLObj.builder()
.whereField(whereName)
@ -814,18 +833,18 @@ public class CHQueryProvider extends QueryProvider {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(CHConstants.toDateTime, originName);
whereName = String.format(CKConstants.toDateTime, originName);
}
if (field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == 4) {
String cast = String.format(CHConstants.toFloat64, originName);
whereName = String.format(CHConstants.toDateTime, cast);
String cast = String.format(CKConstants.toFloat64, originName);
whereName = String.format(CKConstants.toDateTime, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
@ -844,12 +863,12 @@ public class CHQueryProvider extends QueryProvider {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
whereValue = String.format(CHConstants.WHERE_BETWEEN, startTime, endTime);
whereValue = String.format(CKConstants.WHERE_BETWEEN, startTime, endTime);
} else {
whereValue = String.format(CHConstants.WHERE_BETWEEN, value.get(0), value.get(1));
whereValue = String.format(CKConstants.WHERE_BETWEEN, value.get(0), value.get(1));
}
} else {
whereValue = String.format(CHConstants.WHERE_VALUE_VALUE, value.get(0));
whereValue = String.format(CKConstants.WHERE_VALUE_VALUE, value.get(0));
}
list.add(SQLObj.builder()
.whereField(whereName)
@ -903,13 +922,13 @@ public class CHQueryProvider extends QueryProvider {
if (x.getDeExtractType() == DeTypeConstants.DE_TIME) {
if (x.getDeType() == DeTypeConstants.DE_INT || x.getDeType() == DeTypeConstants.DE_FLOAT) {
if(x.getType().equalsIgnoreCase("DATE")){
fieldName = String.format(CHConstants.toInt32, String.format(CHConstants.toDateTime, originField)) + "*1000";
fieldName = String.format(CKConstants.toInt32, String.format(CKConstants.toDateTime, originField)) + "*1000";
}else {
fieldName = String.format(CHConstants.toInt32, originField) + "*1000";
fieldName = String.format(CKConstants.toInt32, originField) + "*1000";
}
} else if (x.getDeType() == DeTypeConstants.DE_TIME) {
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
fieldName = String.format(CHConstants.formatDateTime, originField, format);
fieldName = String.format(CKConstants.formatDateTime, originField, format);
} else {
fieldName = originField;
}
@ -917,9 +936,9 @@ public class CHQueryProvider extends QueryProvider {
if (x.getDeType() == DeTypeConstants.DE_TIME) {
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
if (x.getDeExtractType() == DeTypeConstants.DE_STRING) {
fieldName = String.format(CHConstants.formatDateTime, String.format(CHConstants.toDateTime, originField), format);
fieldName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, originField), format);
} else {
fieldName = String.format(CHConstants.formatDateTime, String.format(CHConstants.toDateTime, String.format(CHConstants.toFloat64, originField)), format);
fieldName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, String.format(CKConstants.toFloat64, originField)), format);
}
} else {
fieldName = originField;
@ -935,17 +954,17 @@ public class CHQueryProvider extends QueryProvider {
private SQLObj getYFields(ChartViewFieldDTO y, String originField, String fieldAlias) {
String fieldName = "";
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
fieldName = CHConstants.AGG_COUNT;
fieldName = CKConstants.AGG_COUNT;
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
fieldName = String.format(CHConstants.AGG_FIELD, y.getSummary(), originField);
fieldName = String.format(CKConstants.AGG_FIELD, y.getSummary(), originField);
} else {
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
String cast = y.getDeType() == 2? String.format(CHConstants.toInt64, originField) : String.format(CHConstants.toFloat64, originField);
String agg = String.format(CHConstants.AGG_FIELD, y.getSummary(), cast);
fieldName = String.format(CHConstants.toDecimal, agg);
String cast = y.getDeType() == 2? String.format(CKConstants.toInt64, originField) : String.format(CKConstants.toFloat64, originField);
String agg = String.format(CKConstants.AGG_FIELD, y.getSummary(), cast);
fieldName = String.format(CKConstants.toDecimal, agg);
} else {
String cast = y.getDeType() == 2 ? String.format(CHConstants.toInt64, originField) : String.format(CHConstants.toFloat64, originField);
fieldName = String.format(CHConstants.AGG_FIELD, y.getSummary(), cast);
String cast = y.getDeType() == 2 ? String.format(CKConstants.toInt64, originField) : String.format(CKConstants.toFloat64, originField);
fieldName = String.format(CKConstants.AGG_FIELD, y.getSummary(), cast);
}
}
return SQLObj.builder()
@ -962,7 +981,7 @@ public class CHQueryProvider extends QueryProvider {
String whereValue = "";
// 原始类型不是时间在de中被转成时间的字段做处理
if (StringUtils.equalsIgnoreCase(f.getTerm(), "null")) {
whereValue = CHConstants.WHERE_VALUE_NULL;
whereValue = CKConstants.WHERE_VALUE_NULL;
} else if (StringUtils.equalsIgnoreCase(f.getTerm(), "not_null")) {
whereTerm = String.format(whereTerm, originField);
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) {
@ -970,7 +989,7 @@ public class CHQueryProvider extends QueryProvider {
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) {
whereValue = "'%" + f.getValue() + "%'";
} else {
whereValue = String.format(CHConstants.WHERE_VALUE_VALUE, f.getValue());
whereValue = String.format(CKConstants.WHERE_VALUE_VALUE, f.getValue());
}
list.add(SQLObj.builder()
.whereField(fieldAlias)
@ -1001,7 +1020,7 @@ public class CHQueryProvider extends QueryProvider {
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
for (DatasetTableField ele : calcFields) {
originField = originField.replaceAll("\\[" + ele.getId() + "]",
String.format(CHConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
}
return originField;
}

View File

@ -33,6 +33,8 @@ public class DorisConstants extends SQLConstants {
public static final String WHERE_VALUE_VALUE = "'%s'";
public static final String WHERE_NUMBER_VALUE = "%s";
public static final String AGG_COUNT = "COUNT(*)";
public static final String AGG_FIELD = "%s(%s)";

View File

@ -785,7 +785,11 @@ public class DorisQueryProvider extends QueryProvider {
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "like")) {
whereValue = "'%" + value + "%'";
} else {
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value);
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereValue = String.format(DorisConstants.WHERE_NUMBER_VALUE, value);
} else {
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value);
}
}
list.add(SQLObj.builder()
.whereField(whereName)
@ -849,7 +853,11 @@ public class DorisQueryProvider extends QueryProvider {
whereValue = String.format(DorisConstants.WHERE_BETWEEN, value.get(0), value.get(1));
}
} else {
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value.get(0));
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereValue = String.format(DorisConstants.WHERE_NUMBER_VALUE, value.get(0));
} else {
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value.get(0));
}
}
list.add(SQLObj.builder()
.whereField(whereName)

View File

@ -35,6 +35,8 @@ public class EsQueryProvider extends QueryProvider {
@Override
public Integer transFieldType(String field) {
field = field.toLowerCase();
field = field.contains("date") ? "datetime" : field;
switch (field) {
case "keyword":
case "text":
@ -64,6 +66,8 @@ public class EsQueryProvider extends QueryProvider {
}
public static Integer transFieldTypeSize(String field) {
field = field.toLowerCase();
field = field.contains("date") ? "datetime" : field;
switch (field) {
case "null":
return 1;
@ -147,7 +151,7 @@ public class EsQueryProvider extends QueryProvider {
String cast = String.format(EsSqlLConstants.CAST, originField, "timestamp");
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
} else if (f.getDeType() == DeTypeConstants.DE_INT) {
fieldName = String.format(EsSqlLConstants.CAST, originField, "timestamp");
fieldName = String.format(EsSqlLConstants.CAST, originField, "bigint");
} else {
fieldName = originField;
}

View File

@ -1,26 +0,0 @@
package io.dataease.provider.mysql;
import io.dataease.provider.DDLProvider;
import org.springframework.stereotype.Service;
/**
* @Author gin
* @Date 2021/5/17 4:27 下午
*/
@Service("mysqlDDL")
public class MysqlDDLProvider extends DDLProvider {
@Override
public String createView(String name, String viewSQL) {
return "CREATE VIEW IF NOT EXISTS " + name + " AS (" + viewSQL + ")";
}
@Override
public String dropTable(String name) {
return "DROP TABLE IF EXISTS " + name;
}
@Override
public String dropView(String name) {
return "DROP VIEW IF EXISTS " + name;
}
}

View File

@ -1,26 +0,0 @@
package io.dataease.provider.oracle;
import io.dataease.provider.DDLProvider;
import org.springframework.stereotype.Service;
/**
* @Author gin
* @Date 2021/5/17 4:27 下午
*/
@Service("oracleDDL")
public class OracleDDLProvider extends DDLProvider {
@Override
public String createView(String name, String viewSQL) {
return "CREATE VIEW IF NOT EXISTS " + name + " AS (" + viewSQL + ")";
}
@Override
public String dropTable(String name) {
return "DROP TABLE IF EXISTS " + name;
}
@Override
public String dropView(String name) {
return "DROP VIEW IF EXISTS " + name;
}
}

View File

@ -469,6 +469,7 @@ public class DataSetTableService {
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
map.put("sql", datasourceRequest.getQuery());
System.out.println(datasourceRequest.getQuery());
datasourceRequest.setPage(page);
datasourceRequest.setFetchSize(Integer.parseInt(dataSetTableRequest.getRow()));
datasourceRequest.setPageSize(pageSize);
@ -558,8 +559,12 @@ public class DataSetTableService {
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
map.put("sql", datasourceRequest.getQuery());
System.out.println(datasourceRequest.getQuery());
try {
data.addAll(jdbcProvider.getData(datasourceRequest));
for(int i=0;i< data.size(); i++){
System.out.println(data.get(i)[2]);
}
} catch (Exception e) {
e.printStackTrace();
DEException.throwException(e.getMessage());

View File

@ -312,6 +312,7 @@ public class ExtractDataService {
msg = true;
lastExecStatus = JobStatus.Completed;
} catch (Exception e) {
e.printStackTrace();
saveErrorLog(datasetTableId, taskId, e);
msg = false;
lastExecStatus = JobStatus.Error;
@ -456,7 +457,7 @@ public class ExtractDataService {
for (DatasetTableField datasetTableField : datasetTableFields) {
Column_Fields = Column_Fields + datasetTableField.getDataeaseName() + "` ";
Integer size = datasetTableField.getSize() * 3;
if (datasetTableField.getSize() > 65533 || datasetTableField.getSize() * 3 > 65533) {
if (datasetTableField.getSize() == 0 || datasetTableField.getSize() > 65533 || datasetTableField.getSize() * 3 > 65533) {
size = 65533;
}
switch (datasetTableField.getDeExtractType()) {
@ -468,7 +469,7 @@ public class ExtractDataService {
Column_Fields = Column_Fields + "varchar(lenth)".replace("lenth", String.valueOf(size)) + ",`";
break;
case 2:
Column_Fields = Column_Fields + "bigint(lenth)".replace("lenth", String.valueOf(size)) + ",`";
Column_Fields = Column_Fields + "bigint" + ",`";
break;
case 3:
Column_Fields = Column_Fields + "DOUBLE" + ",`";
@ -616,7 +617,8 @@ public class ExtractDataService {
Thread.sleep(1000);
}
if (!transStatus.getStatusDescription().equals("Finished")) {
DataEaseException.throwException((transStatus.getLoggingString()));
DataEaseException.throwException(transStatus.getLoggingString());
return;
}
executing = true;
@ -637,11 +639,6 @@ public class ExtractDataService {
}
}
private boolean isExitFile(String fileName) {
File file = new File(root_path + fileName);
return file.exists();
}
private SlaveServer getSlaveServer() {
SlaveServer remoteSlaveServer = new SlaveServer();
remoteSlaveServer.setHostname(carte);// 设置远程IP
@ -805,6 +802,16 @@ public class ExtractDataService {
inputStep = inputStep(transMeta, selectSQL);
udjcStep = udjc(datasetTableFields, DatasourceTypes.oracle);
break;
case ck:
CHConfigration chConfigration = new Gson().fromJson(datasource.getConfiguration(), CHConfigration.class);
dataMeta = new DatabaseMeta("db", "ORACLE", "Native", chConfigration.getHost().trim(), chConfigration.getDataBase().trim(), chConfigration.getPort().toString(), chConfigration.getUsername(), chConfigration.getPassword());
// dataMeta.addExtraOption("MYSQL", "characterEncoding", "UTF-8");
dataMeta.setDatabaseType("Clickhouse");
transMeta.addDatabase(dataMeta);
selectSQL = getSelectSQL(extractType, datasetTable, datasource, datasetTableFields, selectSQL);
inputStep = inputStep(transMeta, selectSQL);
udjcStep = udjc(datasetTableFields, DatasourceTypes.ck);
break;
case excel:
inputStep = excelInputStep(datasetTable.getInfo(), datasetTableFields);
udjcStep = udjc(datasetTableFields, DatasourceTypes.excel);

View File

@ -299,6 +299,33 @@ public class SysUserService {
return null;
}
public void validateExistUser(String userName, String email) {
SysUserExample example = new SysUserExample();
if (StringUtils.isNotBlank(userName)) {
example.createCriteria().andUsernameEqualTo(userName);
List<SysUser> users = sysUserMapper.selectByExample(example);
if(CollectionUtils.isNotEmpty(users)) {
throw new RuntimeException("用户ID【"+userName+"】已存在,请联系管理员");
}
}
/* if (StringUtils.isNotBlank(nickName)) {
example.createCriteria().andNickNameEqualTo(nickName);
List<SysUser> users = sysUserMapper.selectByExample(example);
if(CollectionUtils.isNotEmpty(users)) {
throw new RuntimeException("用户姓名【"+nickName+"】已存在,请联系管理员");
}
} */
if (StringUtils.isNotBlank(email)) {
example.createCriteria().andEmailEqualTo(email);
List<SysUser> users = sysUserMapper.selectByExample(example);
if(CollectionUtils.isNotEmpty(users)) {
throw new RuntimeException("用户邮箱【"+email+"】已存在,请联系管理员");
}
}
}
public List<SysUser> users(List<Long> userIds) {
return userIds.stream().map(sysUserMapper::selectByPrimaryKey).collect(Collectors.toList());

View File

@ -26,12 +26,9 @@ UPDATE `chart_view` SET `y_axis_ext` = '[]';
ALTER TABLE `sys_user` ADD COLUMN `from` int(4) NOT NULL COMMENT '来源' AFTER `language`;
INSERT INTO `sys_menu` VALUES (60, 1, 0, 1, '导入LDAP用户', 'system-user-import', 'system/user/imp-ldap', 11, NULL, 'user-ldap', b'0', b'0', b'1', 'user:import', NULL, NULL, NULL, NULL);
ALTER TABLE `datasource` ADD COLUMN `compute_type` VARCHAR(45) NULL DEFAULT 'ALL' COMMENT '数据计算模式' AFTER `status`;
update datasource set compute_type='ALL';
-- ----------------------------
-- INSERT INTO `sys_menu` VALUES (60, 1, 0, 1, '导入LDAP用户', 'system-user-import', 'system/user/imp-ldap', 11, NULL, 'user-ldap', b'0', b'0', b'1', 'user:import', NULL, NULL, NULL, NULL);
-- ----------------------------
BEGIN;
INSERT INTO `system_parameter` VALUES ('ldap.url', NULL, 'text', 1);
INSERT INTO `system_parameter` VALUES ('ldap.dn', NULL, 'text', 2);

View File

@ -286,3 +286,4 @@ i18n_Stopped=END
i18n_Exec=Running
i18n_no_trigger=The current setting does not trigger task generation.
i18n_dataset_field_delete=Union field deleted,please set again and redo.
i18n_es_limit=Elasticsearch version cannot be less than 6.3

View File

@ -285,4 +285,4 @@ i18n_Stopped=执行结束
i18n_Exec=运行中
i18n_no_trigger=当前设置没有触发任务生成
i18n_dataset_field_delete=该自定义数据集有关联字段被删除,请重新确认关联关系并重做该数据集
i18n_es_limit=Elasticsearch 版本不能小于6.3

View File

@ -288,3 +288,4 @@ i18n_Stopped=執行結束
i18n_Exec=運行中
i18n_no_trigger=当前设置没有触发任务生成 當前設置沒有觸發任務生成.
i18n_dataset_field_delete=該自定義數據集有關聯字段被刪除,請重新確認關聯關系並重做該數據集
i18n_es_limit=Elasticsearch 版本不能小於6.3

View File

@ -45,6 +45,7 @@
"vue-codemirror": "^4.0.6",
"vue-fullscreen": "^2.5.2",
"vue-i18n": "7.3.2",
"vue-power-drag": "^0.2.0",
"vue-router": "3.0.6",
"vue-to-pdf": "^1.0.0",
"vue-uuid": "2.0.2",

View File

@ -1,5 +1,5 @@
<template>
<div style="z-index:1" :style="style" />
<div style="z-index:-1" :style="styleInfo" />
</template>
<script>
@ -8,18 +8,42 @@ export default {
replace: true,
name: 'Shadow',
computed: {
style() {
styleInfo() {
// console.log('styleInfo==>')
// debugger
// console.log('dragComponentInfo==>' + this.dragComponentInfo.shadowStyle.x)
let left = 0
let top = 0
let width = 0
let height = 0
if (this.dragComponentInfo) {
//
left = this.dragComponentInfo.shadowStyle.x
top = this.dragComponentInfo.shadowStyle.y
width = this.dragComponentInfo.style.width
height = this.dragComponentInfo.style.height
// console.log('left:' + left + 'top:' + top + 'width:' + width + 'height:' + height)
} else {
left = this.curComponent.style.left * this.curCanvasScale.scaleWidth / 100
top = this.curComponent.style.top * this.curCanvasScale.scaleHeight / 100
width = this.curComponent.style.width * this.curCanvasScale.scaleWidth / 100
height = this.curComponent.style.height * this.curCanvasScale.scaleHeight / 100
// console.log('curComponent left:' + left + 'top:' + top + 'width:' + width + 'height:' + height)
}
//
let left = this.curComponent.style.left * this.curCanvasScale.scaleWidth / 100
let top = this.curComponent.style.top * this.curCanvasScale.scaleHeight / 100
let width = this.curComponent.style.width * this.curCanvasScale.scaleWidth / 100
let height = this.curComponent.style.height * this.curCanvasScale.scaleHeight / 100
if (this.canvasStyleData.auxiliaryMatrix) {
left = Math.round(left / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
width = Math.round(width / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
top = Math.round(top / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
height = Math.round(height / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
}
//
const xGap = left + width - this.canvasWidth
// console.log('canvasWidth:' + this.canvasWidth + ';xGap:' + xGap)
if (xGap > 0) {
left = left - xGap
}
const style = {
transform: `translate(${left}px, ${top}px) rotate(0deg)`,
width: width + 'px',
@ -29,8 +53,19 @@ export default {
position: 'absolute'
}
// console.log('style=>' + JSON.stringify(style))
//
if (this.dragComponentInfo) {
this.recordShadowStyle(left, top, width, height)
}
return style
},
dragComponentInfo() {
return this.$store.state.dragComponentInfo
},
canvasWidth() {
const scaleWidth = this.curCanvasScale.scaleWidth / 100
return this.canvasStyleData.width * scaleWidth
},
...mapState([
'curComponent',
'editor',
@ -38,6 +73,20 @@ export default {
'canvasStyleData',
'linkageSettingStatus'
])
},
methods: {
recordShadowStyle(x, y, width, height) {
this.dragComponentInfo.shadowStyle.width = this.scaleW(width)
this.dragComponentInfo.shadowStyle.x = this.scaleW(x)
this.dragComponentInfo.shadowStyle.height = this.scaleH(height)
this.dragComponentInfo.shadowStyle.y = this.scaleH(y)
},
scaleH(h) {
return h * 100 / this.curCanvasScale.scaleHeight
},
scaleW(w) {
return w * 100 / this.curCanvasScale.scaleWidth
}
}
}

View File

@ -24,6 +24,7 @@
:out-style="config.style"
:style="getComponentStyleDefault(config.style)"
:prop-value="config.propValue"
:is-edit="false"
:element="config"
:search-count="searchCount"
/>

View File

@ -139,32 +139,46 @@ export default {
this.restore()
},
deep: true
},
canvasStyleData: {
handler(newVal, oldVla) {
this.canvasStyleDataInit()
},
deep: true
}
},
mounted() {
const _this = this
const erd = elementResizeDetectorMaker()
// div
erd.listenTo(document.getElementById('canvasInfoTemp'), element => {
const tempDom = document.getElementById('canvasInfoTemp')
erd.listenTo(tempDom, element => {
_this.$nextTick(() => {
_this.restore()
//mainHeight px html2canvas
_this.mainHeight = tempDom.scrollHeight + 'px!important'
})
})
//
let refreshTime = 300000
if (this.canvasStyleData.refreshTime && this.canvasStyleData.refreshTime > 0) {
refreshTime = this.canvasStyleData.refreshTime * 1000
}
this.timer = setInterval(() => {
this.searchCount++
}, refreshTime)
eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog)
this.$store.commit('clearLinkageSettingInfo', false)
this.canvasStyleDataInit()
},
beforeDestroy() {
clearInterval(this.timer)
},
methods: {
canvasStyleDataInit() {
//
this.searchCount = 0
this.timer && clearInterval(this.timer)
let refreshTime = 300000
if (this.canvasStyleData.refreshTime && this.canvasStyleData.refreshTime > 0) {
refreshTime = this.canvasStyleData.refreshTime * 60000
}
this.timer = setInterval(() => {
this.searchCount++
}, refreshTime)
},
changeStyleWithScale,
getStyle,
restore() {

View File

@ -12,6 +12,7 @@
<el-dropdown-item icon="el-icon-arrow-up" @click.native="upComponent">{{ $t('panel.upComponent') }}</el-dropdown-item>
<el-dropdown-item icon="el-icon-arrow-down" @click.native="downComponent">{{ $t('panel.downComponent') }}</el-dropdown-item>
<el-dropdown-item v-if="'view'===curComponent.type" icon="el-icon-link" @click.native="linkageSetting">{{ $t('panel.linkage_setting') }}</el-dropdown-item>
<el-dropdown-item v-if="'de-tabs'===curComponent.type" icon="el-icon-link" @click.native="addTab">新增Tab</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
@ -137,6 +138,9 @@ export default {
getViewLinkageGather(requestInfo).then(rsp => {
this.$store.commit('setLinkageInfo', rsp.data)
})
},
addTab() {
bus.$emit('add-new-tab')
}
}
}

View File

@ -9,10 +9,12 @@
}
]"
:style="customStyle"
@dragover="handleDragOver"
@mousedown="handleMouseDown"
@scroll="canvasScroll"
>
<!-- 网格线 -->
<!-- <Grid v-if="canvasStyleData.auxiliaryMatrix&&!linkageSettingStatus" :matrix-style="matrixStyle" />-->
<!-- <Grid v-if="canvasStyleData.auxiliaryMatrix&&!linkageSettingStatus" :matrix-style="matrixStyle" />-->
<!-- 仪表板联动清除按钮-->
<canvas-opt-bar />
@ -104,7 +106,7 @@
/>
</de-drag>
<!--拖拽阴影部分-->
<drag-shadow v-if="curComponent&&this.curComponent.optStatus.dragging" />
<drag-shadow v-if="(curComponent&&this.curComponent.optStatus.dragging)||dragComponentInfo" />
<!-- 右击菜单 -->
<ContextMenu />
<!-- 标线 (临时去掉标线 吸附等功能)-->
@ -262,6 +264,9 @@ export default {
panelInfo() {
return this.$store.state.panel.panelInfo
},
dragComponentInfo() {
return this.$store.state.dragComponentInfo
},
...mapState([
'componentData',
'curComponent',
@ -633,11 +638,38 @@ export default {
showViewDetails(index) {
this.$refs.wrapperChild[index].openChartDetailsDialog()
},
resizeView(index, item) {
if (item.type === 'view') {
// console.log('view:resizeView')
this.$refs.wrapperChild[index].chartResize()
}
},
handleDragOver(e) {
// console.log('handleDragOver=>layer:' + e.layerX + ':' + e.layerY + ';offSet=>' + e.offsetX + ':' + e.offsetY + ';page=' + e.pageX + ':' + e.pageY)
// console.log('e=>x=>' + JSON.stringify(e))
// 使e.pageX
this.dragComponentInfo.shadowStyle.x = e.pageX - 220
this.dragComponentInfo.shadowStyle.y = e.pageY - 90
// console.log('handleDragOver=>x=>' + this.dragComponentInfo.shadowStyle.x)
e.preventDefault()
e.dataTransfer.dropEffect = 'copy'
},
getPositionX(x) {
if (this.canvasStyleData.selfAdaption) {
return x * 100 / this.curCanvasScale.scaleWidth
} else {
return x
}
},
getPositionY(y) {
if (this.canvasStyleData.selfAdaption) {
return y * 100 / this.curCanvasScale.scaleHeight
} else {
return y
}
},
canvasScroll(event) {
this.$emit('canvasScroll', event)
}
}
}
@ -648,7 +680,8 @@ export default {
position: relative;
/*background: #fff;*/
margin: auto;
overflow-x: hidden;
/*会影响设置组件不能出现在最高层*/
/*overflow-x: hidden;*/
background-size:100% 100% !important;
/*transform-style:preserve-3d;*/
.lock {

View File

@ -27,6 +27,14 @@ export const assistList = [
label: '矩形',
icon: 'iconfont icon-juxing',
defaultClass: 'text-filter'
},
{
id: '10006',
component: 'de-tabs',
type: 'de-tabs',
label: '选项卡',
icon: 'iconfont icon-tabs',
defaultClass: 'text-filter'
}
]
@ -137,18 +145,47 @@ const list = [
icon: 'juxing',
type: 'view',
style: {
width: 200,
width: 400,
height: 300,
borderRadius: ''
}
},
{
id: '10006',
component: 'de-tabs',
label: '选项卡',
propValue: '',
icon: 'tabs',
type: 'de-tabs',
style: {
width: 200,
height: 200,
borderStyle: 'solid',
borderWidth: 1,
borderColor: '#000000',
backgroundColor: '#ffffff',
borderRadius: 0
},
options: {
tabList: [{
title: 'Tab1',
name: '1',
content: null
}]
}
},
{
id: '20001',
component: 'picture-add',
type: 'picture-add',
label: '拖拽上传',
icon: 'iconfont icon-picture',
defaultClass: 'text-filter'
defaultClass: 'text-filter',
style: {
width: 400,
height: 200,
borderRadius: ''
}
}
]

View File

@ -0,0 +1,269 @@
<template>
<div class="de-tabs-div">
<el-tabs v-model="activeTabName" type="card" class="de-tabs">
<el-tab-pane
v-for="(item, index) in tabList"
:key="item.name+index"
:lazy="true"
:name="item.name"
>
<span slot="label">
<span>{{ item.title }}</span>
<el-dropdown v-if="isEdit" slot="label" class="de-tab-drop" trigger="click" @command="handleCommand">
<span class="el-dropdown-link">
<!-- <span>{{ item.title }}</span> -->
<i v-if="isEdit" class="de-tab-i el-icon-arrow-down el-icon--right" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeHandleCommond('editTitle', item)">
{{ $t('detabs.eidttitle') }}
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommond('selectView', item)">
{{ $t('detabs.selectview') }}
</el-dropdown-item>
<el-dropdown-item v-if="tabList.length > 1" :command="beforeHandleCommond('deleteCur', item)">
{{ $t('table.delete') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
<div class="de-tab-content">
<user-view v-if="item.content" :ref="item.name" :element="item.content" :out-style="outStyle" />
</div>
</el-tab-pane>
</el-tabs>
<el-dialog
:title="$t('detabs.eidttitle')"
:append-to-body="true"
:visible.sync="dialogVisible"
width="30%"
center
>
<el-input
v-model="textarea"
type="textarea"
:rows="2"
:placeholder="$t('dataset.input_content')"
/>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{ $t('table.cancel') }}</el-button>
<el-button type="primary" @click="sureCurTitle">{{ $t('table.confirm') }}</el-button>
</span>
</el-dialog>
<el-dialog
:title="$t('detabs.selectview')"
:append-to-body="true"
:visible.sync="viewDialogVisible"
width="20%"
height="400px"
center
>
<div style="width: 100%;min-height: 250px; max-height: 300px; overflow-y: auto;">
<view-select ref="viewSelect" :select-model="true" />
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="viewDialogVisible = false">{{ $t('table.cancel') }}</el-button>
<el-button type="primary" @click="sureViewSelector">{{ $t('table.confirm') }}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import ViewSelect from '@/views/panel/ViewSelect'
import { uuid } from 'vue-uuid'
import bus from '@/utils/bus'
import componentList from '@/components/canvas/custom-component/component-list'
export default {
name: 'DeTabls',
components: { ViewSelect },
props: {
element: {
type: Object,
default: null
},
isEdit: {
type: Boolean,
default: true
},
outStyle: {
type: Object,
required: false,
default: function() {
return {}
}
}
},
data() {
return {
activeTabName: null,
tabIndex: 1,
// isEdit: true,
dialogVisible: false,
textarea: '',
curItem: null,
viewDialogVisible: false,
tabList: []
}
},
created() {
bus.$on('add-new-tab', this.addNewTab)
this.tabList = this.element.options && this.element.options.tabList
this.activeTabName = this.tabList[0].name
},
methods: {
beforeHandleCommond(item, param) {
return {
'command': item,
'param': param
}
},
handleCommand(command) {
switch (command.command) {
case 'editTitle':
this.editCurTitle(command.param)
break
case 'deleteCur':
this.deleteCur(command.param)
break
case 'selectView':
this.selectView(command.param)
break
}
},
selectView(param) {
this.activeTabName = param.name
this.curItem = param
this.viewDialogVisible = true
},
sureViewSelector() {
const nodes = this.$refs.viewSelect.getCurrentSelected()
const node = nodes[0]
let component
const newComponentId = uuid.v1()
const componentInfo = {
type: 'view',
id: node.id
}
componentList.forEach(componentTemp => {
if (componentTemp.type === 'view') {
component = JSON.parse(JSON.stringify(componentTemp))
const propValue = {
id: newComponentId,
viewId: componentInfo.id
}
component.propValue = propValue
component.filters = []
component.linkageFilters = []
}
})
component.id = newComponentId
component.style.width = '100%'
component.style.height = '100%'
this.curItem.content = component
this.curItem.name = newComponentId
this.viewDialogVisible = false
this.activeTabName = newComponentId
this.styleChange()
// this.setComponentInfo()
},
setComponentInfo() {
console.log('aaa')
},
editCurTitle(param) {
this.activeTabName = param.name
this.curItem = param
this.textarea = param.title
this.dialogVisible = true
},
sureCurTitle() {
this.curItem.title = this.textarea
this.dialogVisible = false
this.styleChange()
},
deleteCur(param) {
this.curItem = param
let len = this.element.options.tabList.length
while (len--) {
if (this.element.options.tabList[len].name === param.name) {
this.element.options.tabList.splice(len, 1)
this.tabList = this.element.options.tabList
const activIndex = (len - 1 + this.element.options.tabList.length) % this.element.options.tabList.length
this.activeTabName = this.element.options.tabList[activIndex].name
}
}
this.styleChange()
},
addNewTab() {
const curName = uuid.v1()
const tab = {
title: 'NewTab',
name: curName,
content: null
}
this.element.options.tabList.push(tab)
this.tabList = this.element.options.tabList
this.styleChange()
},
styleChange() {
this.$store.state.styleChangeTimes++
},
chartResize() {
// this.$refs[this.activeTabName]
}
}
}
</script>
<style lang="scss" scoped>
.de-tabs-div {
height: 100%;
}
.de-tabs {
height: 100%;
>>>div.el-tabs__content {
height: calc(100% - 55px);
.el-tab-pane {
height: 100%;
}
}
}
.de-tab-i {
transition: 0.3s;
opacity: 0;
transform: translateY(100%);
}
.de-tab-drop:hover .de-tab-i {
opacity: 1;
transform: translateY(0);
}
.de-tab-content {
width: 100%;
height: 100%;
}
</style>

View File

@ -395,6 +395,10 @@ export default {
cancel: 'Cancel',
confirm: 'Confirm'
},
detabs: {
eidttitle: 'Edit Title',
selectview: 'Select View'
},
example: {
warning: 'Creating and editing pages cannot be cached by keep-alive because keep-alive include does not currently support caching based on routes, so it is currently cached based on component name. If you want to achieve a similar caching effect, you can use a browser caching scheme such as localStorage. Or do not use keep-alive include to cache all pages directly. See details'
},
@ -523,7 +527,7 @@ export default {
input_url_placeholder: 'Please key url (like ldap://localhost:389)',
input_ou_placeholder: 'Please key OU ',
input_filter_placeholder: 'Please key filter',
input_mapping_placeholder: 'like{"username":"uid","name":"sn","email":"mail"}',
input_mapping_placeholder: 'like{"userName":"uid","nickName":"cn","email":"mail"}',
test_connect: 'Test connect',
edit: 'Edit',
login_success: 'Login success',
@ -923,7 +927,8 @@ export default {
liquid_shape_diamond: 'Diamond',
liquid_shape_triangle: 'Triangle',
liquid_shape_pin: 'Pin',
liquid_shape_rect: 'Rect'
liquid_shape_rect: 'Rect',
dimension_or_quota: 'Dimension Or Quota'
},
dataset: {
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',
@ -1199,6 +1204,8 @@ export default {
gap: 'Gap',
no_gap: 'No Gap',
component_gap: 'Component Gap',
refresh_time: 'Refresh Time',
minute: 'minute',
photo: 'Photo',
default_panel: 'Default Dashboard',
create_public_links: 'Create public links',

View File

@ -395,6 +395,10 @@ export default {
cancel: '取 消',
confirm: '確 定'
},
detabs: {
eidttitle: '編輯標題',
selectview: '選擇視圖'
},
example: {
warning: '創建和編輯頁面是不能被 keep-alive 緩存的因爲keep-alive 的 include 目前不支持根據路由來緩存,所以目前都是基于 component name 來進行緩存的。如果你想類似的實現緩存效果,可以使用 localStorage 等浏覽器緩存方案。或者不要使用 keep-alive 的 include直接緩存所有頁面。詳情見'
},
@ -525,7 +529,7 @@ export default {
input_url_placeholder: '請輸入LDAP地址 (如 ldap://localhost:389)',
input_ou_placeholder: '輸入用戶OU (使用|分隔各OU)',
input_filter_placeholder: '輸入過濾器 [可能的選項是cn或uid或sAMAccountName={0}, 如:(uid={0})]',
input_mapping_placeholder: '如:{"username":"uid","name":"sn","email":"mail"}, username映射的選項可能是cn或uid或sAMAccountName',
input_mapping_placeholder: '如:{"userName":"uid","nickName":"cn","email":"mail"}, username映射的選項可能是cn或uid或sAMAccountName',
test_connect: '測試連接',
test_login: '測試登錄',
edit: '編輯',
@ -924,7 +928,8 @@ export default {
liquid_shape_diamond: '菱形',
liquid_shape_triangle: '三角形',
liquid_shape_pin: '氣球',
liquid_shape_rect: '矩形'
liquid_shape_rect: '矩形',
dimension_or_quota: '維度或指標'
},
dataset: {
sheet_warn: '有多個 Sheet 頁,默認抽取第一個',
@ -1202,6 +1207,8 @@ export default {
gap: '有間隙',
no_gap: '無間隙',
component_gap: '組件間隙',
refresh_time: '刷新时间',
minute: '分钟',
photo: '圖片',
default_panel: '默認儀表板',
create_public_links: '創建公共鏈接',

View File

@ -395,6 +395,10 @@ export default {
cancel: '取 消',
confirm: '确 定'
},
detabs: {
eidttitle: '编辑标题',
selectview: '选择视图'
},
example: {
warning: '创建和编辑页面是不能被 keep-alive 缓存的因为keep-alive 的 include 目前不支持根据路由来缓存,所以目前都是基于 component name 来进行缓存的。如果你想类似的实现缓存效果,可以使用 localStorage 等浏览器缓存方案。或者不要使用 keep-alive 的 include直接缓存所有页面。详情见'
},
@ -525,7 +529,7 @@ export default {
input_url_placeholder: '请输入LDAP地址 (如 ldap://localhost:389)',
input_ou_placeholder: '输入用户OU (使用|分隔各OU)',
input_filter_placeholder: '输入过滤器 [可能的选项是cn或uid或sAMAccountName={0}, 如:(uid={0})]',
input_mapping_placeholder: '如:{"username":"uid","name":"sn","email":"mail"}, username映射的选项可能是cn或uid或sAMAccountName',
input_mapping_placeholder: '如:{"userName":"uid","nickName":"cn","email":"mail"}, username映射的选项可能是cn或uid或sAMAccountName',
test_connect: '测试连接',
test_login: '测试登录',
edit: '编辑',
@ -924,7 +928,8 @@ export default {
liquid_shape_diamond: '菱形',
liquid_shape_triangle: '三角形',
liquid_shape_pin: '气球',
liquid_shape_rect: '矩形'
liquid_shape_rect: '矩形',
dimension_or_quota: '维度或指标'
},
dataset: {
sheet_warn: '有多个 Sheet 页,默认抽取第一个',
@ -1207,6 +1212,8 @@ export default {
gap: '有间隙',
no_gap: '无间隙',
component_gap: '组件间隙',
refresh_time: '刷新时间',
minute: '分钟',
photo: '图片',
default_panel: '默认仪表板',
create_public_links: '创建公共链接',

View File

@ -258,6 +258,12 @@ const data = {
// state.styleChangeTimes++
},
setDragComponentInfo(state, dragComponentInfo) {
dragComponentInfo['shadowStyle'] = {
x: 0,
y: 0,
height: 0,
width: 0
}
state.dragComponentInfo = dragComponentInfo
},
clearDragComponentInfo(state) {

View File

@ -215,35 +215,35 @@
margin: 1em 0;
}
.markdown >p,
.markdown >blockquote,
.markdown >.highlight,
.markdown >ol,
.markdown >ul {
.markdown>p,
.markdown>blockquote,
.markdown>.highlight,
.markdown>ol,
.markdown>ul {
width: 80%;
}
.markdown ul >li {
.markdown ul>li {
list-style: circle;
}
.markdown >ul li,
.markdown blockquote ul >li {
.markdown>ul li,
.markdown blockquote ul>li {
margin-left: 20px;
padding-left: 4px;
}
.markdown >ul li p,
.markdown >ol li p {
.markdown>ul li p,
.markdown>ol li p {
margin: 0.6em 0;
}
.markdown ol >li {
.markdown ol>li {
list-style: decimal;
}
.markdown >ol li,
.markdown blockquote ol >li {
.markdown>ol li,
.markdown blockquote ol>li {
margin-left: 20px;
padding-left: 4px;
}
@ -260,7 +260,7 @@
font-weight: 600;
}
.markdown >table {
.markdown>table {
border-collapse: collapse;
border-spacing: 0px;
empty-cells: show;
@ -269,14 +269,14 @@
margin-bottom: 24px;
}
.markdown >table th {
.markdown>table th {
white-space: nowrap;
color: #333;
font-weight: 600;
}
.markdown >table th,
.markdown >table td {
.markdown>table th,
.markdown>table td {
border: 1px solid #e9e9e9;
padding: 8px 16px;
text-align: left;

View File

@ -54,6 +54,18 @@
<div class="content unicode" style="display: block;">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont">&#xe62a;</span>
<div class="name">44.tabs</div>
<div class="code-name">&amp;#xe62a;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe619;</span>
<div class="name">洗浴</div>
<div class="code-name">&amp;#xe619;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe973;</span>
<div class="name">线性图标-取消下钻</div>
@ -360,9 +372,9 @@
<pre><code class="language-css"
>@font-face {
font-family: 'iconfont';
src: url('iconfont.woff2?t=1628652979833') format('woff2'),
url('iconfont.woff?t=1628652979833') format('woff'),
url('iconfont.ttf?t=1628652979833') format('truetype');
src: url('iconfont.woff2?t=1632382166116') format('woff2'),
url('iconfont.woff?t=1632382166116') format('woff'),
url('iconfont.ttf?t=1632382166116') format('truetype');
}
</code></pre>
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
@ -388,6 +400,24 @@
<div class="content font-class">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont icon-tabs"></span>
<div class="name">
44.tabs
</div>
<div class="code-name">.icon-tabs
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-xiyu"></span>
<div class="name">
洗浴
</div>
<div class="code-name">.icon-xiyu
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-quxiaoshangzuan"></span>
<div class="name">
@ -847,6 +877,22 @@
<div class="content symbol">
<ul class="icon_lists dib-box">
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-tabs"></use>
</svg>
<div class="name">44.tabs</div>
<div class="code-name">#icon-tabs</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-xiyu"></use>
</svg>
<div class="name">洗浴</div>
<div class="code-name">#icon-xiyu</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-quxiaoshangzuan"></use>

View File

@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 2459092 */
src: url('iconfont.woff2?t=1628652979833') format('woff2'),
url('iconfont.woff?t=1628652979833') format('woff'),
url('iconfont.ttf?t=1628652979833') format('truetype');
src: url('iconfont.woff2?t=1632382166116') format('woff2'),
url('iconfont.woff?t=1632382166116') format('woff'),
url('iconfont.ttf?t=1632382166116') format('truetype');
}
.iconfont {
@ -13,6 +13,14 @@
-moz-osx-font-smoothing: grayscale;
}
.icon-tabs:before {
content: "\e62a";
}
.icon-xiyu:before {
content: "\e619";
}
.icon-quxiaoshangzuan:before {
content: "\e973";
}

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,20 @@
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "15196968",
"name": "44.tabs",
"font_class": "tabs",
"unicode": "e62a",
"unicode_decimal": 58922
},
{
"icon_id": "23570269",
"name": "洗浴",
"font_class": "xiyu",
"unicode": "e619",
"unicode_decimal": 58905
},
{
"icon_id": "23496077",
"name": "线性图标-取消下钻",

View File

@ -275,7 +275,8 @@
<span v-else-if="view.type && view.type === 'map'">{{ $t('chart.area') }}</span>
<span v-else-if="view.type && view.type.includes('treemap')">{{ $t('chart.drag_block_treemap_label') }}</span>
/
<span>{{ $t('chart.dimension') }}</span>
<span v-if="view.type && view.type !== 'table-info'">{{ $t('chart.dimension') }}</span>
<span v-else-if="view.type && view.type === 'table-info'">{{ $t('chart.dimension_or_quota') }}</span>
</span>
<draggable
v-model="view.xaxis"

View File

@ -28,8 +28,8 @@
</el-form-item>
<el-form-item class="form-item">
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.direct_connect')" value="0" :disabled="selectedDatasource.computeType==='EXTRACT'"/>
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!kettleRunning || selectedDatasource.computeType==='DIRECT'" />
<el-option :label="$t('dataset.direct_connect')" value="0" />
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!kettleRunning || selectedDatasource.type==='es' || selectedDatasource.type==='ck'" />
</el-select>
</el-form-item>

View File

@ -32,8 +32,8 @@
</el-form-item>
<el-form-item v-if="!param.tableId" class="form-item">
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.direct_connect')" value="0" :disabled="selectedDatasource.computeType==='EXTRACT'"/>
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!kettleRunning || selectedDatasource.computeType==='DIRECT'" />
<el-option :label="$t('dataset.direct_connect')" value="0" />
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!kettleRunning || selectedDatasource.type==='es' || selectedDatasource.type==='ck'" />
</el-select>
</el-form-item>

View File

@ -66,6 +66,7 @@ import { encrypt } from '@/utils/rsaEncrypt'
import { ldapStatus, oidcStatus } from '@/api/user'
import { getSysUI } from '@/utils/auth'
import PluginCom from '@/views/system/plugin/PluginCom'
import Cookies from 'js-cookie'
export default {
name: 'Login',
components: { PluginCom },
@ -92,7 +93,7 @@ export default {
},
computed: {
msg() {
return this.$store.state.user.loginMsg
return this.$store.state.user.loginMsg || Cookies.get('OidcError')
}
},
watch: {
@ -137,6 +138,7 @@ export default {
}
},
handleLogin() {
Cookies.remove('OidcError')
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
@ -159,6 +161,7 @@ export default {
},
changeLoginType(val) {
if (val !== 2) return
Cookies.remove('OidcError')
this.$nextTick(() => {
})

View File

@ -169,6 +169,7 @@ export default {
allMarkReaded() {
allRead().then(res => {
this.$success(this.$t('webmsg.mark_success'))
bus.$emit('refresh-top-notification')
this.search()
})
},
@ -180,6 +181,7 @@ export default {
const param = this.multipleSelection.map(item => item.msgId)
batchRead(param).then(res => {
this.$success(this.$t('webmsg.mark_success'))
bus.$emit('refresh-top-notification')
this.search()
})
},

View File

@ -1,6 +1,6 @@
<template>
<div class="filter-container" @dragstart="handleDragStart">
<div class="filter-container" @dragstart="handleDragStart" @dragend="handleDragEnd()">
<div class="widget-subject">
<div class="filter-header">
@ -55,13 +55,14 @@
</template>
<script>
import { assistList, pictureList } from '@/components/canvas/custom-component/component-list'
import componentList, { assistList, pictureList } from '@/components/canvas/custom-component/component-list'
import toast from '@/components/canvas/utils/toast'
import { commonStyle, commonAttr } from '@/components/canvas/custom-component/component-list'
import generateID from '@/components/canvas/utils/generateID'
import { deepCopy } from '@/components/canvas/utils/utils'
export default {
name: 'FilterGroup',
name: 'AssisComponent',
data() {
return {
assistList,
@ -71,6 +72,7 @@ export default {
methods: {
handleDragStart(ev) {
this.$store.commit('setDragComponentInfo', this.componentInfo(ev.target.dataset.id))
ev.dataTransfer.effectAllowed = 'copy'
const dataTrans = {
type: 'assist',
@ -115,13 +117,26 @@ export default {
}
})
this.$store.commit('recordSnapshot','handleFileChange')
this.$store.commit('recordSnapshot', 'handleFileChange')
}
img.src = fileResult
}
reader.readAsDataURL(file)
},
componentInfo(id) {
//
let component
componentList.forEach(componentTemp => {
if (id === componentTemp.id) {
component = deepCopy(componentTemp)
}
})
return component
},
handleDragEnd(ev) {
this.$store.commit('clearDragComponentInfo')
}
}
}

View File

@ -23,7 +23,7 @@ import { mapState } from 'vuex'
import { deepCopy } from '@/components/canvas/utils/utils'
export default {
name: 'BackgroundSelector',
name: 'ComponentGap',
props: {
},
data() {

View File

@ -0,0 +1,89 @@
<template>
<div>
<div style="width: 100%;">
<el-popover
placement="right"
width="400"
trigger="click"
>
<el-col>
<el-form ref="colorForm" label-width="80px" size="mini">
<el-form-item :label="$t('panel.minute')" class="form-item form-item-slider">
<el-slider v-model="canvasStyleData.refreshTime" show-input :show-input-controls="false" input-size="mini" :min="1" :max="60" @change="onChangePanelStyle" />
</el-form-item>
</el-form>
</el-col>
<el-button slot="reference" size="mini" class="shape-item">{{ $t('panel.refresh_time') }} <i class="el-icon-setting el-icon--right" /></el-button>
</el-popover>
</div>
</div>
</template>
<script>
// eslint-disable-next-line no-unused-vars
import { deepCopy } from '@/components/canvas/utils/utils'
import {
CANVAS_STYLE
} from '@/views/panel/panel'
export default {
name: 'PanelRefreshTime',
props: {
},
computed: {
canvasStyleData() {
return this.$store.state.canvasStyleData
}
},
created() {
//
if (!this.canvasStyleData.refreshTime) {
this.canvasStyleData['refreshTime'] = CANVAS_STYLE.refreshTime
}
},
methods: {
onChangePanelStyle() {
this.$store.state.styleChangeTimes++
}
}
}
</script>
<style scoped>
.avatar-uploader>>>.el-upload {
width: 100px;
height: 60px;
line-height: 70px;
}
.avatar-uploader>>>.el-upload-list li{
width: 100px !important;
height: 60px !important;
}
.disabled>>>.el-upload--picture-card {
display: none;
}
.shape-item{
padding: 6px;
border: none;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.form-item-slider>>>.el-form-item__label{
font-size: 12px;
line-height: 38px;
}
.form-item>>>.el-form-item__label{
font-size: 12px;
}
.el-select-dropdown__item{
padding: 0 20px;
}
span{
font-size: 12px
}
.el-form-item{
margin-bottom: 6px;
}
</style>

View File

@ -12,6 +12,7 @@
<el-row style="background-color: #f7f8fa; margin: 5px">
<background-selector class="attr-selector" />
<component-gap class="attr-selector" />
<Panel-Refresh-Time class="attr-selector" />
</el-row>
</el-collapse-item>
<el-collapse-item :title="$t('chart.module_style')" name="component">
@ -41,6 +42,7 @@ import BackgroundSelector from './PanelStyle/BackgroundSelector'
import PanelBackgroundColorSelector from './PanelStyle/PanelBackgroundColorSelector'
import PanelColorSelector from './PanelStyle/PanelColorSelector'
import ComponentGap from './PanelStyle/ComponentGap'
import PanelRefreshTime from './PanelStyle/PanelRefreshTime'
import { mapState } from 'vuex'
import { deepCopy } from '@/components/canvas/utils/utils'
@ -52,7 +54,8 @@ export default {
BackgroundSelector,
ComponentGap,
PanelColorSelector,
PanelBackgroundColorSelector
PanelBackgroundColorSelector,
PanelRefreshTime
},
data() {
return {
@ -135,7 +138,7 @@ export default {
chart.customFilter = JSON.stringify(this.chart.customFilter)
canvasStyleData.chart = chart
this.$store.commit('setCanvasStyle', canvasStyleData)
this.$store.commit('recordSnapshot','save')
this.$store.commit('recordSnapshot', 'save')
}
}
}

View File

@ -2,7 +2,7 @@
<el-col v-loading="loading">
<el-row style="margin-top: 5px">
<el-row style="margin-left: 5px;margin-right: 5px">
<el-col :span="16">
<el-col :span="selectModel ? 23 : 16">
<el-input
v-model="templateFilterText"
:placeholder="$t('panel.filter_keywords')"
@ -11,7 +11,7 @@
prefix-icon="el-icon-search"
/>
</el-col>
<el-col :span="7">
<el-col v-if="!selectModel" :span="7">
<el-button type="primary" size="mini" style="float: right" @click="newChart">新建 </el-button>
</el-col>
@ -20,6 +20,7 @@
<el-tree
ref="templateTree"
:default-expanded-keys="defaultExpandedKeys"
:show-checkbox="selectModel"
:data="data"
node-key="id"
:props="defaultProps"
@ -31,6 +32,11 @@
:highlight-current="true"
@node-drag-start="handleDragStart"
@node-click="nodeClick"
@check="checkChanged"
@node-drag-end="dragEnd"
>
<span slot-scope="{ node, data }" class="custom-tree-node">
<span>
@ -62,8 +68,16 @@
<script>
import { tree, findOne } from '@/api/panel/view'
import componentList from '@/components/canvas/custom-component/component-list'
import { deepCopy } from '@/components/canvas/utils/utils'
export default {
name: 'ViewSelect',
props: {
selectModel: {
type: Boolean,
default: false
}
},
data() {
return {
templateFilterText: '',
@ -105,19 +119,21 @@ export default {
})
},
handleDragStart(node, ev) {
this.$store.commit('setDragComponentInfo', node)
this.$store.commit('setDragComponentInfo', this.viewComponentInfo())
ev.dataTransfer.effectAllowed = 'copy'
const dataTrans = {
type: 'view',
id: node.data.id
}
ev.dataTransfer.setData('componentInfo', JSON.stringify(dataTrans))
},
dragEnd() {
console.log('dragEnd')
this.$store.commit('clearDragComponentInfo')
},
//
allowDrag(draggingNode) {
if (draggingNode.data.type === 'scene') {
if (draggingNode.data.type === 'scene' || draggingNode.data.type === 'group') {
return false
} else {
return true
@ -128,6 +144,27 @@ export default {
},
newChart() {
this.$emit('newChart')
},
checkChanged(node, status) {
this.$refs.templateTree.setCheckedNodes([])
if (status.checkedKeys && status.checkedKeys.length > 0) {
this.$refs.templateTree.setCheckedNodes([node])
}
},
getCurrentSelected() {
const nodes = this.$refs.templateTree.getCheckedNodes(true, false)
return nodes
},
viewComponentInfo() {
let component
//
componentList.forEach(componentTemp => {
if (componentTemp.type === 'view') {
component = deepCopy(componentTemp)
}
})
return component
}
}

View File

@ -98,12 +98,10 @@
id="canvasInfo"
class="content this_canvas"
@drop="handleDrop"
@dragover="handleDragOver"
@mousedown="handleMouseDown"
@mouseup="deselectCurComponent"
@scroll="canvasScroll"
>
<Editor v-if="!previewVisible" :out-style="outStyle" />
<Editor v-if="!previewVisible" :out-style="outStyle" @canvasScroll="canvasScroll" />
</div>
</de-main-container>
<!-- <de-aside-container v-if="aidedButtonActive" :class="aidedButtonActive ? 'show' : 'hidden'" class="style-aside">-->
@ -276,7 +274,8 @@ export default {
adviceGroupId: null,
scrollLeft: 0,
scrollTop: 0,
timeMachine: null
timeMachine: null,
dropComponentInfo: null
}
},
@ -291,7 +290,8 @@ export default {
'canvasStyleData',
'curComponentIndex',
'componentData',
'linkageSettingStatus'
'linkageSettingStatus',
'dragComponentInfo'
])
},
@ -440,7 +440,8 @@ export default {
return data
},
handleDrop(e) {
this.$store.commit('clearDragComponentInfo')
//
this.dropComponentInfo = deepCopy(this.dragComponentInfo)
this.currentDropElement = e
e.preventDefault()
e.stopPropagation()
@ -490,12 +491,18 @@ export default {
}
// position = absolution
component.style.top = this.getPositionY(e.layerY)
component.style.left = this.getPositionX(e.layerX)
// component.style.top = this.getPositionY(e.layerY)
// component.style.left = this.getPositionX(e.layerX)
component.style.top = this.dropComponentInfo.shadowStyle.y
component.style.left = this.dropComponentInfo.shadowStyle.x
component.style.width = this.dropComponentInfo.shadowStyle.width
component.style.height = this.dropComponentInfo.shadowStyle.height
component.id = newComponentId
this.$store.commit('addComponent', { component })
this.$store.commit('recordSnapshot', 'handleDrop')
this.clearCurrentInfo()
// this.$store.commit('clearDragComponentInfo')
// //
// if (component.type === 'v-text') {
@ -509,12 +516,6 @@ export default {
this.currentFilterCom = null
},
handleDragOver(e) {
console.log('handleDragOver=>x:' + this.getPositionX(e.layerX) + ';y=' + this.getPositionY(e.layerY) + e.dataTransfer.getData('componentInfo'))
e.preventDefault()
e.dataTransfer.dropEffect = 'copy'
},
handleMouseDown() {
// console.log('handleMouseDown123')
@ -595,6 +596,7 @@ export default {
this.$refs.files.click()
},
handleFileChange(e) {
const _this = this
const file = e.target.files[0]
if (!file.type.includes('image')) {
toast('只能插入图片')
@ -619,10 +621,10 @@ export default {
propValue: fileResult,
style: {
...commonStyle,
top: this.getPositionY(this.currentDropElement.layerY),
left: this.getPositionX(this.currentDropElement.layerX),
width: img.width / scale,
height: img.height / scale
top: _this.dropComponentInfo.shadowStyle.y,
left: _this.dropComponentInfo.shadowStyle.x,
width: _this.dropComponentInfo.shadowStyle.width,
height: _this.dropComponentInfo.shadowStyle.height
}
}
})
@ -693,6 +695,7 @@ export default {
}
},
canvasScroll(event) {
console.log('testTop' + event.target.scrollTop)
this.scrollLeft = event.target.scrollLeft
this.scrollTop = event.target.scrollTop
},

View File

@ -1,6 +1,6 @@
<template>
<div class="filter-container" @dragstart="handleDragStart">
<div class="filter-container" @dragstart="handleDragStart" @dragend="handleDragEnd()">
<div v-for="(item, key) in widgetSubjects" :key="key" class="widget-subject">
<div class="filter-header">
@ -30,6 +30,7 @@
<script>
import { ApplicationContext } from '@/utils/ApplicationContext'
import { deepCopy } from '@/components/canvas/utils/utils'
export default {
name: 'FilterGroup',
data() {
@ -80,12 +81,17 @@ export default {
methods: {
handleDragStart(ev) {
//
this.$store.commit('setDragComponentInfo', deepCopy(ApplicationContext.getService(ev.target.dataset.id).getDrawPanel()))
ev.dataTransfer.effectAllowed = 'copy'
const dataTrans = {
type: 'other',
id: ev.target.dataset.id
}
ev.dataTransfer.setData('componentInfo', JSON.stringify(dataTrans))
},
handleDragEnd(ev) {
this.$store.commit('clearDragComponentInfo')
}
}
}

View File

@ -19,7 +19,8 @@ export const CANVAS_STYLE = {
selfAdaption: true,
auxiliaryMatrix: true,
openCommonStyle: true,
panel: DEFAULT_PANEL_STYLE
panel: DEFAULT_PANEL_STYLE,
refreshTime: 5 // 仪表板刷新时间 默认五分钟
}
export const DEFAULT_COMMON_CANVAS_STYLE_STRING = {

View File

@ -24,17 +24,6 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('datasource.data_mode')" prop="type">
<el-select v-model="form.computeType" :placeholder="$t('datasource.please_choose_data_type')" class="select-width" :disabled="formType=='modify' || (formType==='add' && params && !!params.computeMode)">
<el-option
v-for="item in compute_mode"
:key="item.type"
:label="item.label"
:value="item.type"
/>
</el-select>
</el-form-item>
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.host')" prop="configuration.host">
<el-input v-model="form.configuration.host" autocomplete="off" />
</el-form-item>
@ -50,10 +39,10 @@
<el-radio v-model="form.configuration.connectionType" label="serviceName">{{ $t('datasource.oracle_service_name') }}</el-radio>
</el-form-item>
<el-form-item :label="$t('datasource.user_name')" prop="configuration.username">
<el-form-item :label="$t('datasource.user_name')" >
<el-input v-model="form.configuration.username" autocomplete="off" />
</el-form-item>
<el-form-item :label="$t('datasource.password')" prop="configuration.password">
<el-form-item :label="$t('datasource.password')" >
<el-input v-model="form.configuration.password" autocomplete="off" show-password />
</el-form-item>
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.port')" prop="configuration.port">
@ -164,14 +153,9 @@ export default {
{ name: 'sqlServer', label: 'SQL Server', type: 'jdbc' },
{ name: 'pg', label: 'PostgreSQL', type: 'jdbc' },
{ name: 'es', label: 'Elasticsearch', type: 'es' },
{ name: 'ch', label: 'ClickHouse', type: 'jdbc' }
{ name: 'ck', label: 'ClickHouse', type: 'jdbc' }
],
schemas: [],
compute_mode: [
{type: "DIRECT", label: this.$t('datasource.direct')},
{type: "EXTRACT", label: this.$t('datasource.extract')},
{type: "ALL", label: this.$t('datasource.all_compute_mode')}
],
canEdit: false,
originConfiguration: {}
}
@ -222,6 +206,14 @@ export default {
this.$refs.dsForm.resetFields()
},
save() {
if(this.form.type !== 'es' && !this.form.configuration.username){
this.$message.error(this.$t('datasource.please_input_user_name'))
return
}
if(this.form.type !== 'es' && !this.form.configuration.username){
this.$message.error(this.$t('datasource.please_input_password'))
return
}
if (!this.form.configuration.schema && (this.form.type === 'oracle' || this.form.type === 'sqlServer')) {
this.$message.error(this.$t('datasource.please_choose_schema'))
return
@ -312,15 +304,6 @@ export default {
this.form.configuration.dataSourceType = this.allTypes[i].type
}
}
if(this.form.type === 'es'){
this.compute_mode = [{type: "DIRECT", label: this.$t('datasource.direct')}];
}else {
this.compute_mode = [
{type: "DIRECT", label: this.$t('datasource.direct')},
{type: "EXTRACT", label: this.$t('datasource.extract')},
{type: "ALL", label: this.$t('datasource.all_compute_mode')}
];
}
},
backToList() {
this.$emit('switch-component', { })

View File

@ -14,7 +14,7 @@
<el-button v-permission="['user:add']" icon="el-icon-circle-plus-outline" @click="create">{{ $t('user.create') }}</el-button>
<!-- <el-button v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button> -->
<el-button v-if="openLdap" v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button>
<!-- <el-button v-if="openLdap" v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button> -->
</template>
<el-table-column prop="username" label="ID" />