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

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

@ -18,7 +18,6 @@
<graalvm.version>20.1.0</graalvm.version> <graalvm.version>20.1.0</graalvm.version>
<jwt.version>3.12.1</jwt.version> <jwt.version>3.12.1</jwt.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -398,7 +397,6 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<repositories> <repositories>
<repository> <repository>
<id>pentaho-public</id> <id>pentaho-public</id>

@ -94,7 +94,7 @@ public class DatasourceController {
@ApiOperation("查询表字段") @ApiOperation("查询表字段")
@PostMapping("/getData/{tableName}/{fetchSize}") @PostMapping("/getData/{tableName}/{fetchSize}")
public Map<String, List> getData(@RequestBody Datasource datasource, @PathVariable String tableName, @PathVariable Integer fetchSize) throws Exception { 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 @ApiIgnore

@ -263,15 +263,12 @@ public class DatasourceService {
return datasourceProvider.fetchResultField(datasourceRequest); 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()); DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest(); DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(datasource); datasourceRequest.setDatasource(datasource);
QueryProvider qp = ProviderFactory.getQueryProvider(datasource.getType()); QueryProvider qp = ProviderFactory.getQueryProvider(datasource.getType());
datasourceRequest.setQuery(qp.convertTableToSql(tableName, datasource)); datasourceRequest.setQuery(qp.createSQLPreview(qp.convertTableToSql(tableName, datasource), null, offset, fetchSize));
datasourceRequest.setFetchSize(fetchSize);
datasourceRequest.setPageable(true);
datasourceRequest.setPreviewData(true);
return datasourceProvider.fetchResultAndField(datasourceRequest); 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.ChartCustomFilterDTO;
import com.ipsos.dto.chart.ChartViewFieldDTO; import com.ipsos.dto.chart.ChartViewFieldDTO;
import com.ipsos.dto.sqlObj.SQLObj; import com.ipsos.dto.sqlObj.SQLObj;
import com.ipsos.provider.mysql.MySQLConstants;
import com.ipsos.provider.pg.PgConstants; import com.ipsos.provider.pg.PgConstants;
import com.ipsos.base.domain.DatasetTableField; 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);
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 createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds);
public abstract String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup); public abstract String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup);

@ -101,7 +101,12 @@ public class CKQueryProvider extends QueryProvider {
@Override @Override
public String createSQLPreview(String sql, String orderBy) { 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 @Override

@ -73,7 +73,12 @@ public class DorisQueryProvider extends QueryProvider {
@Override @Override
public String createSQLPreview(String sql, String orderBy) { 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 @Override

@ -105,7 +105,12 @@ public class EsQueryProvider extends QueryProvider {
@Override @Override
public String createSQLPreview(String sql, String orderBy) { 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 @Override

@ -73,7 +73,12 @@ public class MysqlQueryProvider extends QueryProvider {
@Override @Override
public String createSQLPreview(String sql, String orderBy) { 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 @Override

@ -88,7 +88,12 @@ public class OracleQueryProvider extends QueryProvider {
@Override @Override
public String createSQLPreview(String sql, String orderBy) { 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 @Override

@ -93,7 +93,12 @@ public class PgQueryProvider extends QueryProvider {
@Override @Override
public String createSQLPreview(String sql, String orderBy) { 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 @Override

@ -81,7 +81,12 @@ public class SqlserverQueryProvider extends QueryProvider {
@Override @Override
public String createSQLPreview(String sql, String orderBy) { 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 @Override

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

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

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

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

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

Loading…
Cancel
Save