修改数据源预览数据为10条

package
郑皇 4 years ago
parent 623f7314bd
commit 59724d1c6f

@ -18,7 +18,6 @@
<graalvm.version>20.1.0</graalvm.version>
<jwt.version>3.12.1</jwt.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -398,21 +397,20 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>pentaho-public</id>
<name>Pentaho Public</name>
<url>http://nexus.pentaho.org/content/groups/omni</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>pentaho-public</id>
<name>Pentaho Public</name>
<url>http://nexus.pentaho.org/content/groups/omni</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>

@ -94,7 +94,7 @@ public class DatasourceController {
@ApiOperation("查询表字段")
@PostMapping("/getData/{tableName}/{fetchSize}")
public Map<String, List> getData(@RequestBody Datasource datasource, @PathVariable String tableName, @PathVariable Integer fetchSize) throws Exception {
return datasourceService.getDataByDatasource(datasource, tableName, fetchSize);
return datasourceService.getDataByDatasource(datasource, tableName, 0, fetchSize);
}
@ApiIgnore

@ -263,15 +263,12 @@ public class DatasourceService {
return datasourceProvider.fetchResultField(datasourceRequest);
}
public Map<String, List> getDataByDatasource(Datasource datasource, String tableName, Integer fetchSize) throws Exception {
public Map<String, List> getDataByDatasource(Datasource datasource, String tableName, Integer offset, Integer fetchSize) throws Exception {
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(datasource);
QueryProvider qp = ProviderFactory.getQueryProvider(datasource.getType());
datasourceRequest.setQuery(qp.convertTableToSql(tableName, datasource));
datasourceRequest.setFetchSize(fetchSize);
datasourceRequest.setPageable(true);
datasourceRequest.setPreviewData(true);
datasourceRequest.setQuery(qp.createSQLPreview(qp.convertTableToSql(tableName, datasource), null, offset, fetchSize));
return datasourceProvider.fetchResultAndField(datasourceRequest);
}

@ -7,6 +7,7 @@ import com.ipsos.datasource.dto.JdbcConfiguration;
import com.ipsos.dto.chart.ChartCustomFilterDTO;
import com.ipsos.dto.chart.ChartViewFieldDTO;
import com.ipsos.dto.sqlObj.SQLObj;
import com.ipsos.provider.mysql.MySQLConstants;
import com.ipsos.provider.pg.PgConstants;
import com.ipsos.base.domain.DatasetTableField;
@ -22,6 +23,8 @@ public abstract class QueryProvider {
public abstract String createSQLPreview(String sql, String orderBy);
public abstract String createSQLPreview(String sql, String orderBy, Integer offset, Integer limit);
public abstract String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds);
public abstract String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup);

@ -101,7 +101,12 @@ public class CKQueryProvider extends QueryProvider {
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp " + " LIMIT 0,1000";
return createSQLPreview(sql, orderBy, 0, 1000);
}
@Override
public String createSQLPreview(String sql, String orderBy, Integer offset, Integer limit) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp " + " LIMIT " + offset + "," + limit;
}
@Override

@ -73,7 +73,12 @@ public class DorisQueryProvider extends QueryProvider {
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sql + ") AS tmp ORDER BY " + orderBy + " LIMIT 0,1000";
return createSQLPreview(sql, orderBy, 0, 1000);
}
@Override
public String createSQLPreview(String sql, String orderBy, Integer offset, Integer limit) {
return "SELECT * FROM (" + sql + ") AS tmp ORDER BY " + orderBy + " LIMIT " + offset + "," + limit;
}
@Override

@ -105,7 +105,12 @@ public class EsQueryProvider extends QueryProvider {
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp " + " LIMIT 1000";
return createSQLPreview(sql, orderBy, 0, 1000);
}
@Override
public String createSQLPreview(String sql, String orderBy, Integer offset, Integer limit) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp " + " LIMIT " + limit;
}
@Override

@ -73,7 +73,12 @@ public class MysqlQueryProvider extends QueryProvider {
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp " + " LIMIT 0,1000";
return createSQLPreview(sql, orderBy, 0, 1000);
}
@Override
public String createSQLPreview(String sql, String orderBy, Integer offset, Integer limit) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp " + " LIMIT " + offset + "," + limit;
}
@Override

@ -88,7 +88,12 @@ public class OracleQueryProvider extends QueryProvider {
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sqlFix(sql) + ") DE_TMP " + " WHERE rownum <= 1000";
return createSQLPreview(sql, orderBy, 0, 1000);
}
@Override
public String createSQLPreview(String sql, String orderBy, Integer offset, Integer limit) {
return "SELECT * FROM (" + sqlFix(sql) + ") DE_TMP " + " WHERE rownum <= " + limit;
}
@Override

@ -93,7 +93,12 @@ public class PgQueryProvider extends QueryProvider {
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp " + " LIMIT 1000 offset 0";
return createSQLPreview(sql, orderBy, 0, 1000);
}
@Override
public String createSQLPreview(String sql, String orderBy, Integer offset, Integer limit) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp " + " LIMIT " + limit + " offset " + offset;
}
@Override

@ -81,7 +81,12 @@ public class SqlserverQueryProvider extends QueryProvider {
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT top 1000 * FROM (" + sqlFix(sql) + ") AS tmp";
return createSQLPreview(sql, orderBy, 0, 1000);
}
@Override
public String createSQLPreview(String sql, String orderBy, Integer offset, Integer limit) {
return "SELECT top " + limit + " * FROM (" + sqlFix(sql) + ") AS tmp";
}
@Override

@ -31,6 +31,7 @@
<goal>install-node-and-yarn</goal>
</goals>
<configuration>
<nodeDownloadRoot>http://nodejs.org/dist/</nodeDownloadRoot>
<!-- See https://nodejs.org/en/download/ for latest node and npm (lts) versions -->
<nodeVersion>v15.12.0</nodeVersion>
<yarnVersion>v1.22.17</yarnVersion>

@ -1,192 +1,232 @@
<template>
<de-container>
<span>敬请期待</span>
<!-- <de-aside-container>-->
<!-- <el-button v-show="!showSourceSearchInput" class="de-icon" icon="el-icon-search" circle size="mini" @click="showSourceSearchWidget" />-->
<!-- <div v-show="showSourceSearchInput" class="de-input">-->
<!-- <el-input v-model="sourceFilterText">-->
<!-- <el-button slot="append" icon="el-icon-close" @click="closeSourceSearchWidget" />-->
<!-- </el-input>-->
<!-- </div>-->
<!-- <el-tabs v-model="sourceActiveName" :class="{'de-search-header': showSourceSearchInput}" @tab-click="handleClick">-->
<!-- <el-tab-pane v-for="(sourceInfo, index) in sourceInfoArray" :key="index" :lazy="true" :label="sourceInfo.tabName" :name="sourceInfo.authType">-->
<!-- <lazy-tree-->
<!-- v-if="authCondition"-->
<!-- :active-name="sourceActiveName"-->
<!-- :filter-text="sourceFilterText"-->
<!-- :data-info="sourceInfo"-->
<!-- highlight-current-->
<!-- @nodeClick="authNodeClick"-->
<!-- />-->
<!-- </el-tab-pane>-->
<!-- </el-tabs>-->
<!-- </de-aside-container>-->
<!-- <de-main-container class="de-main-container-auth">-->
<!-- <el-button v-show="!showTargetSearchInput" class="de-icon" icon="el-icon-search" circle size="mini" @click="showTargetSearchWidget" />-->
<!-- <div v-show="showTargetSearchInput" class="de-input">-->
<!-- <el-input v-model="targetFilterText">-->
<!-- <el-button slot="append" icon="el-icon-close" @click="closeTargetSearchWidget" />-->
<!-- </el-input>-->
<!-- </div>-->
<!-- <el-tabs v-model="targetActiveName" :class="{'de-search-header': showTargetSearchInput}" @tab-click="handleClick">-->
<!-- <el-tab-pane v-for="(targetInfo, index) in targetInfoArray" :key="index" :lazy="true" :label="targetInfo.tabName" :name="targetInfo.authType">-->
<!-- <lazy-tree-->
<!-- :active-name="targetActiveName"-->
<!-- :filter-text="targetFilterText"-->
<!-- :data-info="targetInfo"-->
<!-- show-extent-->
<!-- :auth-condition="authCondition"-->
<!-- />-->
<!-- </el-tab-pane>-->
<!-- </el-tabs>-->
<!-- </de-main-container>-->
<!-- <span>敬请期待</span> -->
<de-aside-container>
<el-button
v-show="!showSourceSearchInput"
class="de-icon"
icon="el-icon-search"
circle
size="mini"
@click="showSourceSearchWidget"
/>
<div v-show="showSourceSearchInput" class="de-input">
<el-input v-model="sourceFilterText">
<el-button
slot="append"
icon="el-icon-close"
@click="closeSourceSearchWidget"
/>
</el-input>
</div>
<el-tabs
v-model="sourceActiveName"
:class="{ 'de-search-header': showSourceSearchInput }"
@tab-click="handleClick"
>
<el-tab-pane
v-for="(sourceInfo, index) in sourceInfoArray"
:key="index"
:lazy="true"
:label="sourceInfo.tabName"
:name="sourceInfo.authType"
>
<lazy-tree
v-if="authCondition"
:active-name="sourceActiveName"
:filter-text="sourceFilterText"
:data-info="sourceInfo"
highlight-current
@nodeClick="authNodeClick"
/>
</el-tab-pane>
</el-tabs>
</de-aside-container>
<de-main-container class="de-main-container-auth">
<el-button
v-show="!showTargetSearchInput"
class="de-icon"
icon="el-icon-search"
circle
size="mini"
@click="showTargetSearchWidget"
/>
<div v-show="showTargetSearchInput" class="de-input">
<el-input v-model="targetFilterText">
<el-button
slot="append"
icon="el-icon-close"
@click="closeTargetSearchWidget"
/>
</el-input>
</div>
<el-tabs
v-model="targetActiveName"
:class="{ 'de-search-header': showTargetSearchInput }"
@tab-click="handleClick"
>
<el-tab-pane
v-for="(targetInfo, index) in targetInfoArray"
:key="index"
:lazy="true"
:label="targetInfo.tabName"
:name="targetInfo.authType"
>
<lazy-tree
:active-name="targetActiveName"
:filter-text="targetFilterText"
:data-info="targetInfo"
show-extent
:auth-condition="authCondition"
/>
</el-tab-pane>
</el-tabs>
</de-main-container>
</de-container>
</template>
<script>
import DeContainer from '../../../components/dataease/DeContainer'
import DeAsideContainer from '../../../components/dataease/DeAsideContainer'
import DeMainContainer from '../../../components/dataease/DeMainContainer'
import LazyTree from './components/LazyTree'
import DeContainer from "../../../components/dataease/DeContainer";
import DeAsideContainer from "../../../components/dataease/DeAsideContainer";
import DeMainContainer from "../../../components/dataease/DeMainContainer";
import LazyTree from "./components/LazyTree";
export default {
name: 'Authority',
name: "Authority",
// eslint-disable-next-line vue/no-unused-components
components: { LazyTree, DeMainContainer, DeAsideContainer, DeContainer },
props: {
resourceId: {
type: String,
default: null
}
default: null,
},
},
data() {
return {
targetInfoArray:
[
{
tabName: '部门权限',
head: '所有部门',
direction: 'target',
authType: 'dept'
},
{
tabName: '角色权限',
head: '所有角色',
direction: 'target',
authType: 'role'
},
{
tabName: '用户权限',
head: '所有用户',
direction: 'target',
authType: 'user'
}],
sourceInfoArray:
[
{
tabName: '数据源',
head: '所有数据源',
direction: 'source',
authType: 'link'
},
{
tabName: '数据集',
head: '所有数据集',
direction: 'source',
authType: 'dataset'
},
{
tabName: '视图',
head: '所有视图',
direction: 'source',
authType: 'chart'
},
{
tabName: '仪表板',
head: '所有仪表板',
direction: 'source',
authType: 'panel'
}],
targetInfoArray: [
{
tabName: "部门权限",
head: "所有部门",
direction: "target",
authType: "dept",
},
{
tabName: "角色权限",
head: "所有角色",
direction: "target",
authType: "role",
},
{
tabName: "用户权限",
head: "所有用户",
direction: "target",
authType: "user",
},
],
sourceInfoArray: [
{
tabName: "数据源",
head: "所有数据源",
direction: "source",
authType: "link",
},
{
tabName: "数据集",
head: "所有数据集",
direction: "source",
authType: "dataset",
},
{
tabName: "视图",
head: "所有视图",
direction: "source",
authType: "chart",
},
{
tabName: "仪表板",
head: "所有仪表板",
direction: "source",
authType: "panel",
},
],
targetActiveName: null,
sourceActiveName: null,
showSourceSearchInput: false,
showTargetSearchInput: false,
sourceFilterText: '',
targetFilterText: '',
sourceFilterText: "",
targetFilterText: "",
timeMachine: null,
authCondition: null
}
authCondition: null,
};
},
created() {
this.targetActiveName = this.targetInfoArray[0].authType
this.targetActiveName = this.targetInfoArray[0].authType;
},
methods: {
handleClick(tab, event) {
},
handleClick(tab, event) {},
showSourceSearchWidget() {
this.showSourceSearchInput = true
this.showSourceSearchInput = true;
},
closeSourceSearchWidget() {
this.sourceFilterText = ''
this.showSourceSearchInput = false
this.sourceFilterText = "";
this.showSourceSearchInput = false;
},
showTargetSearchWidget() {
this.showTargetSearchInput = true
this.showTargetSearchInput = true;
},
closeTargetSearchWidget() {
this.targetFilterText = ''
this.showTargetSearchInput = false
this.targetFilterText = "";
this.showTargetSearchInput = false;
},
save() {
this.$refs[this.activeName].save()
this.$emit('close-grant', 0)
this.$refs[this.activeName].save();
this.$emit("close-grant", 0);
},
cancel() {
this.$refs[this.activeName].cancel()
this.$emit('close-grant', 0)
this.$refs[this.activeName].cancel();
this.$emit("close-grant", 0);
},
authNodeClick(val) {
// console.log('authNodeClick')
this.authCondition = val
this.authCondition = val;
},
clickAuth(auth) {
// console.log('clickAuth')
}
}
}
},
},
};
</script>
<style lang="scss" scoped>
.de-tab {
border:1px solid #E6E6E6;
min-height:200px !important;
max-height:300px !important;
overflow:auto;
}
.de-icon {
position: absolute;
right: 10px;
top: 15px;
z-index: 99;
}
.el-input-group__append{
background-color: #ffffff;
}
.el-input__inner{
border-right: none;
}
.de-tab {
border: 1px solid #e6e6e6;
min-height: 200px !important;
max-height: 300px !important;
overflow: auto;
}
.de-icon {
position: absolute;
right: 10px;
top: 15px;
z-index: 99;
}
.el-input-group__append {
background-color: #ffffff;
}
.el-input__inner {
border-right: none;
}
.auth-root-class {
margin: 15px 0px 5px;
text-align: right;
}
.de-main-container-auth{
border: 1px solid #E6E6E6;
}
.auth-root-class {
margin: 15px 0px 5px;
text-align: right;
}
.de-main-container-auth {
border: 1px solid #e6e6e6;
}
// ::-webkit-scrollbar {
// ::-webkit-scrollbar {
// }
// }
</style>

@ -2,43 +2,39 @@
<de-main-container style="height: calc(100vh - 56px)">
<el-tabs v-model="authorityType" @tab-click="handleClick">
<el-tab-pane name="authConfig">
<span slot="label">{{ $t('auth.authConfig') }}</span>
<span slot="label">{{ $t("auth.authConfig") }}</span>
<auth-config />
</el-tab-pane>
<!-- <el-tab-pane name="authQuickConfig">-->
<!-- <span slot="label">{{$t('auth.authQuickConfig')}}</span>-->
<!-- <auth-quick-config />-->
<!-- </el-tab-pane>-->
<el-tab-pane name="authQuickConfig">
<span slot="label">{{ $t("auth.authQuickConfig") }}</span>
<auth-quick-config />
</el-tab-pane>
</el-tabs>
</de-main-container>
</template>
<script>
import DeMainContainer from '@/components/dataease/DeMainContainer'
import DeContainer from '@/components/dataease/DeContainer'
import AuthConfig from './authConfig'
import AuthQuickConfig from './authQuickConfig'
import DeMainContainer from "@/components/dataease/DeMainContainer";
import DeContainer from "@/components/dataease/DeContainer";
import AuthConfig from "./authConfig";
import AuthQuickConfig from "./authQuickConfig";
export default {
name: 'Authority',
name: "Authority",
// eslint-disable-next-line vue/no-unused-components
components: { DeContainer, DeMainContainer, AuthConfig, AuthQuickConfig },
data() {
return {
authorityType: 'authConfig'
}
},
watch: {
},
mounted() {
authorityType: "authConfig",
};
},
watch: {},
mounted() {},
methods: {
handleClick() {
// console.log('===>handleClick')
}
}
}
},
},
};
</script>
<style scoped>
</style>
<style scoped></style>

@ -8,14 +8,14 @@
<el-icon name="back" class="back-button" @click.native="backToList" />
{{
params &&
params.id &&
params.showModel &&
params.showModel === 'show' &&
!canEdit
? $t('datasource.show_info')
: formType == 'add'
? $t('datasource.create')
: $t('datasource.modify')
params.id &&
params.showModel &&
params.showModel === "show" &&
!canEdit
? $t("datasource.show_info")
: formType == "add"
? $t("datasource.create")
: $t("datasource.modify")
}}
</template>
<div>
@ -28,10 +28,10 @@
size="small"
:disabled="
params &&
params.id &&
params.showModel &&
params.showModel === 'show' &&
!canEdit
params.id &&
params.showModel &&
params.showModel === 'show' &&
!canEdit
"
label-width="auto"
label-position="right"
@ -49,7 +49,7 @@
class="select-width"
:disabled="
formType == 'modify' ||
(formType === 'add' && params && !!params.type)
(formType === 'add' && params && !!params.type)
"
@change="changeType()"
>
@ -99,11 +99,13 @@
<el-radio
v-model="form.configuration.connectionType"
label="sid"
>{{ $t('datasource.oracle_sid') }}</el-radio>
>{{ $t("datasource.oracle_sid") }}</el-radio
>
<el-radio
v-model="form.configuration.connectionType"
label="serviceName"
>{{ $t('datasource.oracle_service_name') }}</el-radio>
>{{ $t("datasource.oracle_service_name") }}</el-radio
>
</el-form-item>
<el-form-item
@ -150,7 +152,7 @@
<el-form-item
v-if="
form.configuration.dataSourceType == 'jdbc' &&
form.type !== 'oracle'
form.type !== 'oracle'
"
:label="$t('datasource.extra_params')"
>
@ -175,20 +177,20 @@
<el-form-item
v-if="
form.type == 'oracle' ||
form.type == 'sqlServer' ||
form.type == 'pg'
form.type == 'sqlServer' ||
form.type == 'pg'
"
>
<el-button icon="el-icon-plus" size="mini" @click="getSchema()">
{{ $t('datasource.get_schema') }}
{{ $t("datasource.get_schema") }}
</el-button>
</el-form-item>
<el-form-item
v-if="
form.type == 'oracle' ||
form.type == 'sqlServer' ||
form.type == 'pg'
form.type == 'sqlServer' ||
form.type == 'pg'
"
:label="$t('datasource.schema')"
>
@ -296,9 +298,11 @@
:label="$t('datasource.table_name')"
>
<template slot-scope="scope">
<span><i class="el-icon-coin" />&nbsp;&nbsp;{{
scope.row
}}</span>
<span
><i class="el-icon-coin" />&nbsp;&nbsp;{{
scope.row
}}</span
>
</template>
</el-table-column>
</el-table>
@ -330,8 +334,8 @@
<span
v-if="
scope.row.fieldType.indexOf('CHAR') >= 0 ||
scope.row.fieldType.indexOf('TEXT') >= 0 ||
scope.row.fieldType.indexOf('BLOB') >= 0
scope.row.fieldType.indexOf('TEXT') >= 0 ||
scope.row.fieldType.indexOf('BLOB') >= 0
"
>
<svg-icon
@ -339,13 +343,13 @@
class="field-icon-text"
/>
<span class="field-class">{{
$t('dataset.text')
$t("dataset.text")
}}</span>
</span>
<span
v-if="
scope.row.fieldType.indexOf('DATE') >= 0 ||
scope.row.fieldType.indexOf('TIME') >= 0
scope.row.fieldType.indexOf('TIME') >= 0
"
>
<svg-icon
@ -353,15 +357,15 @@
class="field-icon-time"
/>
<span class="field-class">{{
$t('dataset.time')
$t("dataset.time")
}}</span>
</span>
<span
v-if="
scope.row.fieldType.indexOf('INT') >= 0 ||
scope.row.fieldType.indexOf('FLOAT') >= 0 ||
scope.row.fieldType.indexOf('DOUBLE') >= 0 ||
scope.row.fieldType.indexOf('DECIMAL') >= 0
scope.row.fieldType.indexOf('FLOAT') >= 0 ||
scope.row.fieldType.indexOf('DOUBLE') >= 0 ||
scope.row.fieldType.indexOf('DECIMAL') >= 0
"
>
<svg-icon
@ -369,16 +373,17 @@
class="field-icon-value"
/>
<span class="field-class">{{
$t('dataset.value')
$t("dataset.value")
}}</span>
<span
v-if="
scope.row.fieldType.indexOf('FLOAT') >= 0 ||
scope.row.fieldType.indexOf('DOUBLE') >= 0 ||
scope.row.fieldType.indexOf('DECIMAL') >= 0
scope.row.fieldType.indexOf('DOUBLE') >= 0 ||
scope.row.fieldType.indexOf('DECIMAL') >= 0
"
class="field-class"
>{{ '(' + $t('dataset.float') + ')' }}</span>
>{{ "(" + $t("dataset.float") + ")" }}</span
>
</span>
<span>({{ scope.row.fieldType }})</span>
</span>
@ -418,7 +423,8 @@
: hasDataPermission('manage', params.privileges)
"
@click="validaDatasource"
>{{ $t('commons.validate') }}</el-button>
>{{ $t("commons.validate") }}</el-button
>
<el-button
v-if="
formType === 'add'
@ -427,7 +433,8 @@
"
type="primary"
@click="save"
>{{ $t('commons.save') }}</el-button>
>{{ $t("commons.save") }}</el-button
>
</div>
<div v-else slot="footer" class="dialog-footer">
<el-button
@ -437,7 +444,8 @@
: hasDataPermission('manage', params.privileges)
"
@click="validaDatasource"
>{{ $t('commons.validate') }}</el-button>
>{{ $t("commons.validate") }}</el-button
>
<el-button
v-if="
formType === 'add'
@ -446,7 +454,8 @@
"
type="primary"
@click="changeEdit"
>{{ $t('commons.edit') }}</el-button>
>{{ $t("commons.edit") }}</el-button
>
</div>
</div>
</div>
@ -454,168 +463,168 @@
</template>
<script>
import LayoutContent from '@/components/business/LayoutContent'
import { post } from '@/api/dataset/dataset'
import LayoutContent from "@/components/business/LayoutContent";
import { post } from "@/api/dataset/dataset";
import {
addDs,
editDs,
getSchema,
validateDs,
validateDsById
} from '@/api/system/datasource'
import { $confirm } from '@/utils/message'
validateDsById,
} from "@/api/system/datasource";
import { $confirm } from "@/utils/message";
export default {
name: 'DsForm',
name: "DsForm",
components: { LayoutContent },
props: {
params: {
type: Object,
default: null
}
default: null,
},
},
data() {
return {
form: {
configuration: {
initialPoolSize: 5,
extraParams: '',
extraParams: "",
minPoolSize: 5,
maxPoolSize: 50,
maxIdleTime: 30,
acquireIncrement: 5,
idleConnectionTestPeriod: 5,
connectTimeout: 5
}
connectTimeout: 5,
},
},
rule: {
name: [
{
required: true,
message: this.$t('datasource.input_name'),
trigger: 'blur'
message: this.$t("datasource.input_name"),
trigger: "blur",
},
{
min: 2,
max: 25,
message: this.$t('datasource.input_limit_2_25', [2, 25]),
trigger: 'blur'
}
message: this.$t("datasource.input_limit_2_25", [2, 25]),
trigger: "blur",
},
],
desc: [
{
min: 0,
max: 50,
message: this.$t('datasource.input_limit_0_50'),
trigger: 'blur'
}
message: this.$t("datasource.input_limit_0_50"),
trigger: "blur",
},
],
type: [
{
required: true,
message: this.$t('datasource.please_choose_type'),
trigger: 'change'
}
message: this.$t("datasource.please_choose_type"),
trigger: "change",
},
],
'configuration.dataBase': [
"configuration.dataBase": [
{
required: true,
message: this.$t('datasource.please_input_data_base'),
trigger: 'blur'
}
message: this.$t("datasource.please_input_data_base"),
trigger: "blur",
},
],
'configuration.connectionType': [
"configuration.connectionType": [
{
required: true,
message: this.$t('datasource.please_select_oracle_type'),
trigger: 'blur'
}
message: this.$t("datasource.please_select_oracle_type"),
trigger: "blur",
},
],
'configuration.username': [
"configuration.username": [
{
required: true,
message: this.$t('datasource.please_input_user_name'),
trigger: 'blur'
}
message: this.$t("datasource.please_input_user_name"),
trigger: "blur",
},
],
'configuration.password': [
"configuration.password": [
{
required: true,
message: this.$t('datasource.please_input_password'),
trigger: 'change'
}
message: this.$t("datasource.please_input_password"),
trigger: "change",
},
],
'configuration.host': [
"configuration.host": [
{
required: true,
message: this.$t('datasource.please_input_host'),
trigger: 'change'
}
message: this.$t("datasource.please_input_host"),
trigger: "change",
},
],
'configuration.url': [
"configuration.url": [
{
required: true,
message: this.$t('datasource.please_input_url'),
trigger: 'change'
}
message: this.$t("datasource.please_input_url"),
trigger: "change",
},
],
'configuration.port': [
"configuration.port": [
{
required: true,
message: this.$t('datasource.please_input_port'),
trigger: 'change'
}
message: this.$t("datasource.please_input_port"),
trigger: "change",
},
],
'configuration.initialPoolSize': [
"configuration.initialPoolSize": [
{
required: true,
message: this.$t('datasource.please_input_initial_pool_size'),
trigger: 'change'
}
message: this.$t("datasource.please_input_initial_pool_size"),
trigger: "change",
},
],
'configuration.minPoolSize': [
"configuration.minPoolSize": [
{
required: true,
message: this.$t('datasource.please_input_min_pool_size'),
trigger: 'change'
}
message: this.$t("datasource.please_input_min_pool_size"),
trigger: "change",
},
],
'configuration.maxPoolSize': [
"configuration.maxPoolSize": [
{
required: true,
message: this.$t('datasource.please_input_max_pool_size'),
trigger: 'change'
}
message: this.$t("datasource.please_input_max_pool_size"),
trigger: "change",
},
],
'configuration.maxIdleTime': [
"configuration.maxIdleTime": [
{
required: true,
message: this.$t('datasource.please_input_max_idle_time'),
trigger: 'change'
}
message: this.$t("datasource.please_input_max_idle_time"),
trigger: "change",
},
],
'configuration.acquireIncrement': [
"configuration.acquireIncrement": [
{
required: true,
message: this.$t('datasource.please_input_acquire_increment'),
trigger: 'change'
}
message: this.$t("datasource.please_input_acquire_increment"),
trigger: "change",
},
],
'configuration.connectTimeout': [
"configuration.connectTimeout": [
{
required: true,
message: this.$t('datasource.please_input_connect_timeout'),
trigger: 'change'
}
]
message: this.$t("datasource.please_input_connect_timeout"),
trigger: "change",
},
],
},
allTypes: [
{
name: 'mysql',
label: 'MySQL',
type: 'jdbc',
name: "mysql",
label: "MySQL",
type: "jdbc",
extraParams:
'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
"characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true",
},
// { name: 'oracle', label: 'Oracle', type: 'jdbc'},
// { name: 'pg', label: 'PostgreSQL', type: 'jdbc', extraParams: '' },
@ -623,18 +632,18 @@ export default {
// { name: 'ds_doris', label: 'Doris', type: 'jdbc', extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true' },
// { name: 'ck', label: 'ClickHouse', type: 'jdbc', extraParams: '' }
{
name: 'mariadb',
label: 'MariaDB',
type: 'jdbc',
name: "mariadb",
label: "MariaDB",
type: "jdbc",
extraParams:
'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
"characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true",
},
{
name: 'sqlServer',
label: 'SQL Server',
type: 'jdbc',
extraParams: ''
}
name: "sqlServer",
label: "SQL Server",
type: "jdbc",
extraParams: "",
},
],
schemas: [],
canEdit: false,
@ -645,100 +654,100 @@ export default {
tableLoading: false,
tableFields: [],
showTableFields: false,
dataList: []
}
dataList: [],
};
},
watch: {
form: {
handler(val, old) {
if (val.id) {
const _this = this
post('/datasource/getTables', { id: val.id }).then((response) => {
_this.tables = response.data
_this.tableData = []
const _this = this;
post("/datasource/getTables", { id: val.id }).then((response) => {
_this.tables = response.data;
_this.tableData = [];
_this.tables.forEach((item) => {
_this.tableData.push(item.name)
})
_this.showTableList = _this.tableData.length > 0
})
_this.tableData.push(item.name);
});
_this.showTableList = _this.tableData.length > 0;
});
}
},
deep: true
}
deep: true,
},
},
created() {
if (this.params && this.params.id) {
const row = this.params
this.edit(row)
const row = this.params;
this.edit(row);
} else {
this.create()
this.create();
if (this.params && this.params.type) {
this.setType()
this.setType();
}
}
},
mounted() {},
methods: {
handleCurrentChange(row) {
const _this = this
const ds = JSON.parse(JSON.stringify(this.form))
ds.configuration = JSON.stringify(ds.configuration)
this.tableLoading = true
post('/datasource/getData/' + row + '/10', ds)
const _this = this;
const ds = JSON.parse(JSON.stringify(this.form));
ds.configuration = JSON.stringify(ds.configuration);
this.tableLoading = true;
post("/datasource/getData/" + row + "/10", ds)
.then((response) => {
_this.tableFields = response.data.fieldList
_this.showTableFields = _this.tableFields.length > 0
_this.dataList = response.data.dataList
_this.tableFields = response.data.fieldList;
_this.showTableFields = _this.tableFields.length > 0;
_this.dataList = response.data.dataList;
})
.finally((_) => {
this.tableLoading = false
})
this.tableLoading = false;
});
},
setType() {
this.form.type = this.params.type
this.form.type = this.params.type;
this.form.configuration = {
initialPoolSize: 5,
extraParams: '',
extraParams: "",
minPoolSize: 5,
maxPoolSize: 50,
maxIdleTime: 30,
acquireIncrement: 5,
idleConnectionTestPeriod: 5,
connectTimeout: 5
}
this.changeType()
connectTimeout: 5,
};
this.changeType();
},
changeEdit() {
this.canEdit = true
this.formType = 'modify'
this.canEdit = true;
this.formType = "modify";
},
create() {
this.formType = 'add'
this.canEdit = true
this.formType = "add";
this.canEdit = true;
},
edit(row) {
this.formType = 'modify'
this.form = Object.assign({}, row)
this.originConfiguration = this.form.configuration
this.form.configuration = JSON.parse(this.form.configuration)
this.formType = "modify";
this.form = Object.assign({}, row);
this.originConfiguration = this.form.configuration;
this.form.configuration = JSON.parse(this.form.configuration);
},
reset() {
this.$refs.dsForm.resetFields()
this.$refs.dsForm.resetFields();
},
save() {
if (
!this.form.configuration.schema &&
(this.form.type === 'oracle' || this.form.type === 'sqlServer')
(this.form.type === "oracle" || this.form.type === "sqlServer")
) {
this.$message.error(this.$t('datasource.please_choose_schema'))
return
this.$message.error(this.$t("datasource.please_choose_schema"));
return;
}
if (
this.form.configuration.dataSourceType === 'jdbc' &&
this.form.configuration.dataSourceType === "jdbc" &&
this.form.configuration.port <= 0
) {
this.$message.error(this.$t('datasource.port_no_less_then_0'))
return
this.$message.error(this.$t("datasource.port_no_less_then_0"));
return;
}
if (
this.form.configuration.initialPoolSize < 0 ||
@ -749,118 +758,118 @@ export default {
this.form.configuration.idleConnectionTestPeriod < 0 ||
this.form.configuration.connectTimeout < 0
) {
this.$message.error(this.$t('datasource.no_less_then_0'))
return
this.$message.error(this.$t("datasource.no_less_then_0"));
return;
}
this.$refs.dsForm.validate((valid) => {
if (valid) {
const method = this.formType === 'add' ? addDs : editDs
const form = JSON.parse(JSON.stringify(this.form))
form.configuration = JSON.stringify(form.configuration)
const method = this.formType === "add" ? addDs : editDs;
const form = JSON.parse(JSON.stringify(this.form));
form.configuration = JSON.stringify(form.configuration);
if (
this.formType !== 'add' &&
this.formType !== "add" &&
this.originConfiguration !== form.configuration
) {
$confirm(this.$t('datasource.edit_datasource_msg'), () => {
$confirm(this.$t("datasource.edit_datasource_msg"), () => {
method(form).then((res) => {
this.$success(this.$t('commons.save_success'))
this.refreshTree()
this.backToList()
})
})
this.$success(this.$t("commons.save_success"));
this.refreshTree();
this.backToList();
});
});
} else {
method(form).then((res) => {
this.$success(this.$t('commons.save_success'))
this.refreshTree()
this.backToList()
})
this.$success(this.$t("commons.save_success"));
this.refreshTree();
this.backToList();
});
}
} else {
return false
return false;
}
})
});
},
getSchema() {
this.$refs.dsForm.validate((valid) => {
if (valid) {
const data = JSON.parse(JSON.stringify(this.form))
data.configuration = JSON.stringify(data.configuration)
const data = JSON.parse(JSON.stringify(this.form));
data.configuration = JSON.stringify(data.configuration);
getSchema(data).then((res) => {
this.schemas = res.data
this.$success(this.$t('commons.success'))
})
this.schemas = res.data;
this.$success(this.$t("commons.success"));
});
} else {
return false
return false;
}
})
});
},
validaDatasource() {
if (!this.form.configuration.schema && this.form.type === 'oracle') {
this.$message.error(this.$t('datasource.please_choose_schema'))
return
if (!this.form.configuration.schema && this.form.type === "oracle") {
this.$message.error(this.$t("datasource.please_choose_schema"));
return;
}
if (
this.form.configuration.dataSourceType === 'jdbc' &&
this.form.configuration.dataSourceType === "jdbc" &&
this.form.configuration.port <= 0
) {
this.$message.error(this.$t('datasource.port_no_less_then_0'))
return
this.$message.error(this.$t("datasource.port_no_less_then_0"));
return;
}
this.$refs.dsForm.validate((valid) => {
if (valid) {
const data = JSON.parse(JSON.stringify(this.form))
data.configuration = JSON.stringify(data.configuration)
if (data.showModel === 'show' && !this.canEdit) {
const data = JSON.parse(JSON.stringify(this.form));
data.configuration = JSON.stringify(data.configuration);
if (data.showModel === "show" && !this.canEdit) {
validateDsById(data.id)
.then((res) => {
if (res.success) {
this.$success(this.$t('datasource.validate_success'))
this.$success(this.$t("datasource.validate_success"));
} else {
this.$error(this.$t(res.message))
this.$error(this.$t(res.message));
}
this.refreshTree()
this.refreshTree();
})
.catch((res) => {
this.$error(res.message)
})
this.$error(res.message);
});
} else {
validateDs(data)
.then((res) => {
if (res.success) {
this.tableData = res.data
console.log(this.tableData)
this.showTableList = true
this.$success(this.$t('datasource.validate_success'))
this.tableData = res.data;
console.log(this.tableData);
this.showTableList = true;
this.$success(this.$t("datasource.validate_success"));
} else {
this.$error(this.$t(res.message))
this.$error(this.$t(res.message));
}
})
.catch((res) => {
this.$error(res.message)
})
this.$error(res.message);
});
}
} else {
return false
return false;
}
})
});
},
changeType() {
for (let i = 0; i < this.allTypes.length; i++) {
if (this.allTypes[i].name === this.form.type) {
this.form.configuration.dataSourceType = this.allTypes[i].type
this.form.configuration.extraParams = this.allTypes[i].extraParams
this.form.configuration.dataSourceType = this.allTypes[i].type;
this.form.configuration.extraParams = this.allTypes[i].extraParams;
}
}
},
backToList() {
this.$emit('switch-component', {})
this.$emit("switch-component", {});
// this.$router.push({ name: 'datasource' })
},
refreshTree() {
this.$emit('refresh-left-tree')
}
}
}
this.$emit("refresh-left-tree");
},
},
};
</script>
<style lang="scss" scoped>
.back-button {

@ -6,6 +6,7 @@
<artifactId>ipsos-bi-server</artifactId>
<version>1.3.0</version>
<packaging>pom</packaging>
<name>ipsos-bi</name>
<parent>
<groupId>org.springframework.boot</groupId>
@ -13,8 +14,6 @@
<version>2.4.3</version>
<relativePath/>
</parent>
<name>ipsos-bi</name>
<modules>
<module>quartz-spring-boot-starter</module>
<module>plugins</module>

Loading…
Cancel
Save