提交 e81138ec authored 作者: taojinlong's avatar taojinlong

feat: 支持精简模式

上级 0609d245
package io.dataease.controller.engine;
import io.dataease.base.domain.DeEngine;
import io.dataease.controller.ResultHolder;
import io.dataease.dto.DatasourceDTO;
import io.dataease.service.engine.EngineService;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
@ApiIgnore
@RequestMapping("engine")
@RestController
public class EngineController {
@Resource
private EngineService engineService;
@ApiIgnore
@GetMapping("/mode")
public String runMode() throws Exception{
return engineService.mode();
}
@ApiIgnore
@GetMapping("/info")
public DeEngine info() throws Exception{
return engineService.info();
}
@ApiIgnore
@PostMapping("/validate")
public ResultHolder validate(@RequestBody DatasourceDTO datasource) throws Exception {
return engineService.validate(datasource);
}
@ApiIgnore
@PostMapping("/save")
public ResultHolder save(@RequestBody DeEngine engine) throws Exception {
return engineService.save(engine);
}
}
...@@ -18,4 +18,6 @@ public abstract class DDLProvider { ...@@ -18,4 +18,6 @@ public abstract class DDLProvider {
public abstract String replaceTable(String name); public abstract String replaceTable(String name);
public abstract String createTableSql(String name, List<DatasetTableField> datasetTableFields); public abstract String createTableSql(String name, List<DatasetTableField> datasetTableFields);
public abstract String insertSql(String name, List<String[]> dataList, int page, int pageNumber);
} }
package io.dataease.provider; package io.dataease.provider;
import io.dataease.base.domain.DatasetTableField; import io.dataease.base.domain.DatasetTableField;
import io.dataease.commons.utils.Md5Utils;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class DDLProviderImpl extends DDLProvider { public class DDLProviderImpl extends DDLProvider {
...@@ -30,5 +32,19 @@ public class DDLProviderImpl extends DDLProvider { ...@@ -30,5 +32,19 @@ public class DDLProviderImpl extends DDLProvider {
return null; return null;
} }
@Override
public String insertSql(String name, List<String[]> dataList, int page, int pageNumber) {
String insertSql = "INSERT INTO TABLE_NAME VALUES ".replace("TABLE_NAME", name);
StringBuffer values = new StringBuffer();
Integer realSize = page * pageNumber < dataList.size() ? page * pageNumber : dataList.size();
for (String[] strings : dataList.subList((page - 1) * pageNumber, realSize)) {
values.append("(").append(Md5Utils.md5(String.join(",", Arrays.asList(strings))))
.append("," ).append(String.join(",", Arrays.asList(strings)))
.append("),");
}
return insertSql + values.substring(0, values.length() - 1);
}
} }
...@@ -71,7 +71,7 @@ public class DatasourceService { ...@@ -71,7 +71,7 @@ public class DatasourceService {
return datasource; return datasource;
} }
private void handleConnectionPool(Datasource datasource, String type) { public void handleConnectionPool(Datasource datasource, String type) {
commonThreadPool.addTask(() -> { commonThreadPool.addTask(() -> {
try { try {
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType()); DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
...@@ -221,7 +221,6 @@ public class DatasourceService { ...@@ -221,7 +221,6 @@ public class DatasourceService {
}catch (Exception e){ }catch (Exception e){
return ResultHolder.error("Datasource is invalid: " + e.getMessage()); return ResultHolder.error("Datasource is invalid: " + e.getMessage());
} }
} }
public ResultHolder validate(String datasourceId) { public ResultHolder validate(String datasourceId) {
......
...@@ -6,20 +6,32 @@ import io.dataease.base.domain.DeEngine; ...@@ -6,20 +6,32 @@ import io.dataease.base.domain.DeEngine;
import io.dataease.base.domain.DeEngineExample; import io.dataease.base.domain.DeEngineExample;
import io.dataease.base.mapper.DeEngineMapper; import io.dataease.base.mapper.DeEngineMapper;
import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.BeanUtils;
import io.dataease.controller.ResultHolder;
import io.dataease.controller.request.datasource.DatasourceRequest;
import io.dataease.dto.DatasourceDTO;
import io.dataease.provider.ProviderFactory;
import io.dataease.provider.datasource.DatasourceProvider;
import io.dataease.service.datasource.DatasourceService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.UUID;
@Service @Service
@Transactional(rollbackFor = Exception.class)
public class EngineService { public class EngineService {
@Resource @Resource
private Environment env; private Environment env;
@Resource @Resource
private DeEngineMapper deEngineMapper; private DeEngineMapper deEngineMapper;
static private Datasource ds = null; @Resource
private DatasourceService datasource;
static private Datasource ds = new Datasource();
public Boolean isLocalMode(){ public Boolean isLocalMode(){
...@@ -29,8 +41,50 @@ public class EngineService { ...@@ -29,8 +41,50 @@ public class EngineService {
public Boolean isSimpleMode(){ public Boolean isSimpleMode(){
return env.getProperty("engine_mode", "local").equalsIgnoreCase("simple"); return env.getProperty("engine_mode", "local").equalsIgnoreCase("simple");
} }
public Boolean isClusterMode(){
return env.getProperty("engine_mode", "local").equalsIgnoreCase("cluster");
}
public String mode(){
return env.getProperty("engine_mode", "local");
}
public DeEngine info(){
List<DeEngine> deEngines = deEngineMapper.selectByExampleWithBLOBs(new DeEngineExample());
if(CollectionUtils.isEmpty(deEngines)){
return new DeEngine();
}
return deEngines.get(0);
}
public ResultHolder validate(DatasourceDTO datasource) throws Exception {
try {
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(datasource);
datasourceProvider.checkStatus(datasourceRequest);
return ResultHolder.success(datasource);
}catch (Exception e){
return ResultHolder.error("Datasource is invalid: " + e.getMessage());
}
}
public ResultHolder save(DeEngine engine) throws Exception {
if(StringUtils.isEmpty(engine.getId())){
engine.setId(UUID.randomUUID().toString());
deEngineMapper.insert(engine);
}else {
deEngineMapper.updateByPrimaryKeyWithBLOBs(engine);
}
datasource.handleConnectionPool(this.ds, "delete");
BeanUtils.copyBean(this.ds, engine);
datasource.handleConnectionPool(this.ds, "add");
return ResultHolder.success(engine);
}
public Datasource getDeEngine() throws Exception{ public Datasource getDeEngine() throws Exception{
if (this.ds != null) { if (this.ds != null || StringUtils.isNotEmpty(ds.getType())) {
return this.ds; return this.ds;
} }
if(isLocalMode()){ if(isLocalMode()){
...@@ -52,7 +106,7 @@ public class EngineService { ...@@ -52,7 +106,7 @@ public class EngineService {
this.ds = datasource; this.ds = datasource;
} }
if(isSimpleMode()){ if(isSimpleMode()){
List<DeEngine> deEngines = deEngineMapper.selectByExample(new DeEngineExample()); List<DeEngine> deEngines = deEngineMapper.selectByExampleWithBLOBs(new DeEngineExample());
if(CollectionUtils.isEmpty(deEngines)){ if(CollectionUtils.isEmpty(deEngines)){
throw new Exception("未设置数据引擎"); throw new Exception("未设置数据引擎");
} }
......
import request from '@/utils/request'
import {validateDs} from "@/api/system/datasource";
export function engineMode() {
return request({
url: '/engine/mode',
method: 'get',
loading: true
})
}
export function engineInfo() {
return request({
url: '/engine/info',
method: 'get',
loading: true
})
}
export function validate(data) {
return request({
url: '/engine/validate',
method: 'post',
loading: true,
data
})
}
export function save(data) {
return request({
url: '/engine/save',
method: 'post',
loading: true,
data
})
}
...@@ -647,7 +647,8 @@ export default { ...@@ -647,7 +647,8 @@ export default {
port: 'Port number cannot be empty', port: 'Port number cannot be empty',
account: 'Account cannot be empty', account: 'Account cannot be empty',
test_recipients: 'Test recipients', test_recipients: 'Test recipients',
tip: 'Tip: use as test mail recipient only' tip: 'Tip: use as test mail recipient only',
engine_mode_setting: 'Engine Setting'
}, },
chart: { chart: {
save_snapshot: 'Save Snapshot', save_snapshot: 'Save Snapshot',
......
...@@ -649,7 +649,8 @@ export default { ...@@ -649,7 +649,8 @@ export default {
port: '端口號不能爲空', port: '端口號不能爲空',
account: '賬戶不能爲空', account: '賬戶不能爲空',
test_recipients: '測試收件人', test_recipients: '測試收件人',
tip: '提示:僅用來作爲測試郵件收件人' tip: '提示:僅用來作爲測試郵件收件人',
engine_mode_setting: '引擎設置'
}, },
chart: { chart: {
save_snapshot: '保存縮略圖', save_snapshot: '保存縮略圖',
......
...@@ -651,7 +651,7 @@ export default { ...@@ -651,7 +651,7 @@ export default {
account: '账户不能为空', account: '账户不能为空',
test_recipients: '测试收件人', test_recipients: '测试收件人',
tip: '提示:仅用来作为测试邮件收件人', tip: '提示:仅用来作为测试邮件收件人',
simple_mode_datasource: '数据设置' engine_mode_setting: '引擎设置'
}, },
chart: { chart: {
save_snapshot: '保存缩略图', save_snapshot: '保存缩略图',
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
</el-form-item> </el-form-item>
<el-form-item class="form-item"> <el-form-item class="form-item">
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini"> <el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!kettleRunning || selectedDatasource.type==='es' || selectedDatasource.type==='ck' || selectedDatasource.type==='mongo' || selectedDatasource.type==='redshift' || selectedDatasource.type==='hive'" /> <el-option :label="$t('dataset.sync_data')" value="1" :disabled="!kettleRunning && engineMode!=='simple'" />
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
<script> <script>
import { listApiDatasource, post, isKettleRunning } from '@/api/dataset/dataset' import { listApiDatasource, post, isKettleRunning } from '@/api/dataset/dataset'
import {engineMode} from "@/api/system/engine";
export default { export default {
name: 'AddApi', name: 'AddApi',
...@@ -86,6 +87,7 @@ export default { ...@@ -86,6 +87,7 @@ export default {
syncType: 'sync_now', syncType: 'sync_now',
tableData: [], tableData: [],
kettleRunning: false, kettleRunning: false,
engineMode: 'local',
selectedDatasource: {} selectedDatasource: {}
} }
}, },
...@@ -119,6 +121,9 @@ export default { ...@@ -119,6 +121,9 @@ export default {
}, },
created() { created() {
this.kettleState() this.kettleState()
engineMode().then(res => {
this.engineMode = res.data
})
}, },
methods: { methods: {
initDataSource() { initDataSource() {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</el-button> </el-button>
</el-row> </el-row>
</el-row> </el-row>
<el-divider /> <el-divider/>
<el-row> <el-row>
<el-form :inline="true"> <el-form :inline="true">
<el-form-item class="form-item"> <el-form-item class="form-item">
...@@ -28,15 +28,16 @@ ...@@ -28,15 +28,16 @@
</el-form-item> </el-form-item>
<el-form-item class="form-item"> <el-form-item class="form-item">
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini"> <el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.direct_connect')" value="0" /> <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' || selectedDatasource.type==='mongo' || selectedDatasource.type==='redshift' || selectedDatasource.type==='hive'" /> <el-option :label="$t('dataset.sync_data')" value="1"
:disabled="disabledSync"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-if="mode === '1'" class="form-item"> <el-form-item v-if="mode === '1'" class="form-item">
<el-select v-model="syncType" filterable :placeholder="$t('dataset.connect_mode')" size="mini"> <el-select v-model="syncType" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.sync_now')" value="sync_now" /> <el-option :label="$t('dataset.sync_now')" value="sync_now"/>
<el-option :label="$t('dataset.sync_latter')" value="sync_latter" /> <el-option :label="$t('dataset.sync_latter')" value="sync_latter"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -53,12 +54,14 @@ ...@@ -53,12 +54,14 @@
</el-row> </el-row>
<el-col style="overflow-y: auto;"> <el-col style="overflow-y: auto;">
<el-checkbox-group v-model="checkTableList" size="small"> <el-checkbox-group v-model="checkTableList" size="small">
<el-tooltip v-for="t in tableData" :key="t.name" :disabled="t.enableCheck" effect="dark" :content="$t('dataset.table_already_add_to')+': '+t.datasetPath" placement="bottom"> <el-tooltip v-for="t in tableData" :key="t.name" :disabled="t.enableCheck" effect="dark"
:content="$t('dataset.table_already_add_to')+': '+t.datasetPath" placement="bottom">
<el-checkbox <el-checkbox
border border
:label="t.name" :label="t.name"
:disabled="!t.enableCheck" :disabled="!t.enableCheck"
>{{ showTableNameWithComment(t) }}</el-checkbox> >{{ showTableNameWithComment(t) }}
</el-checkbox>
</el-tooltip> </el-tooltip>
</el-checkbox-group> </el-checkbox-group>
</el-col> </el-col>
...@@ -66,7 +69,8 @@ ...@@ -66,7 +69,8 @@
</template> </template>
<script> <script>
import { listDatasource, post, isKettleRunning } from '@/api/dataset/dataset' import {listDatasource, post, isKettleRunning} from '@/api/dataset/dataset'
import {engineMode} from "@/api/system/engine";
export default { export default {
name: 'AddDB', name: 'AddDB',
...@@ -87,13 +91,16 @@ export default { ...@@ -87,13 +91,16 @@ export default {
syncType: 'sync_now', syncType: 'sync_now',
tableData: [], tableData: [],
kettleRunning: false, kettleRunning: false,
selectedDatasource: {} selectedDatasource: {},
engineMode: 'local',
disabledSync: true,
disabledSyncDs: ['es', 'ck', 'mongo', 'redshift', 'hive']
} }
}, },
watch: { watch: {
dataSource(val) { dataSource(val) {
if (val) { if (val) {
post('/datasource/getTables', { id: val }).then(response => { post('/datasource/getTables', {id: val}).then(response => {
this.tables = response.data this.tables = response.data
this.tableData = JSON.parse(JSON.stringify(this.tables)) this.tableData = JSON.parse(JSON.stringify(this.tables))
}) })
...@@ -101,13 +108,20 @@ export default { ...@@ -101,13 +108,20 @@ export default {
if (this.options[i].id === val) { if (this.options[i].id === val) {
this.selectedDatasource = this.options[i] this.selectedDatasource = this.options[i]
this.mode = '0' this.mode = '0'
if (this.engineMode === 'simple' || (!this.kettleRunning || this.disabledSyncDs.indexOf(this.selectedDatasource.type) !== -1 )) {
this.disabledSync = true
} else {
this.disabledSync = false
}
} }
} }
} }
}, },
searchTable(val) { searchTable(val) {
if (val && val !== '') { if (val && val !== '') {
this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.toLocaleLowerCase().includes(val.toLocaleLowerCase()) }))) this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => {
return ele.name.toLocaleLowerCase().includes(val.toLocaleLowerCase())
})))
} else { } else {
this.tableData = JSON.parse(JSON.stringify(this.tables)) this.tableData = JSON.parse(JSON.stringify(this.tables))
} }
...@@ -121,6 +135,9 @@ export default { ...@@ -121,6 +135,9 @@ export default {
}, },
created() { created() {
this.kettleState() this.kettleState()
engineMode().then(res => {
this.engineMode = res.data
})
}, },
methods: { methods: {
initDataSource() { initDataSource() {
...@@ -152,7 +169,7 @@ export default { ...@@ -152,7 +169,7 @@ export default {
const tables = [] const tables = []
const mode = this.mode const mode = this.mode
const syncType = this.syncType const syncType = this.syncType
this.checkTableList.forEach(function(name) { this.checkTableList.forEach(function (name) {
tables.push({ tables.push({
name: ds.name + '_' + name, name: ds.name + '_' + name,
sceneId: sceneId, sceneId: sceneId,
...@@ -160,7 +177,7 @@ export default { ...@@ -160,7 +177,7 @@ export default {
type: 'db', type: 'db',
syncType: syncType, syncType: syncType,
mode: parseInt(mode), mode: parseInt(mode),
info: JSON.stringify({ table: name }) info: JSON.stringify({table: name})
}) })
}) })
post('/dataset/table/batchAdd', tables).then(response => { post('/dataset/table/batchAdd', tables).then(response => {
...@@ -171,7 +188,7 @@ export default { ...@@ -171,7 +188,7 @@ export default {
cancel() { cancel() {
this.dataReset() this.dataReset()
this.$emit('switchComponent', { name: '' }) this.$emit('switchComponent', {name: ''})
}, },
dataReset() { dataReset() {
...@@ -187,25 +204,25 @@ export default { ...@@ -187,25 +204,25 @@ export default {
</script> </script>
<style scoped> <style scoped>
.el-divider--horizontal { .el-divider--horizontal {
margin: 12px 0; margin: 12px 0;
} }
.form-item { .form-item {
margin-bottom: 6px; margin-bottom: 6px;
} }
.el-checkbox { .el-checkbox {
margin-bottom: 14px; margin-bottom: 14px;
margin-left: 0; margin-left: 0;
margin-right: 14px; margin-right: 14px;
} }
.el-checkbox.is-bordered + .el-checkbox.is-bordered { .el-checkbox.is-bordered + .el-checkbox.is-bordered {
margin-left: 0; margin-left: 0;
} }
span{ span {
font-size: 14px; font-size: 14px;
} }
</style> </style>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini"> <el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.direct_connect')" value="0"/> <el-option :label="$t('dataset.direct_connect')" value="0"/>
<el-option :label="$t('dataset.sync_data')" value="1" <el-option :label="$t('dataset.sync_data')" value="1"
:disabled="!kettleRunning || selectedDatasource.type==='es' || selectedDatasource.type==='ck'|| selectedDatasource.type==='mongo'|| selectedDatasource.type==='redshift' || selectedDatasource.type==='hive'"/> :disabled="disabledSync"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -124,6 +124,7 @@ import 'codemirror/keymap/emacs.js' ...@@ -124,6 +124,7 @@ import 'codemirror/keymap/emacs.js'
import 'codemirror/addon/hint/show-hint.css' import 'codemirror/addon/hint/show-hint.css'
import 'codemirror/addon/hint/sql-hint' import 'codemirror/addon/hint/sql-hint'
import 'codemirror/addon/hint/show-hint' import 'codemirror/addon/hint/show-hint'
import {engineMode} from "@/api/system/engine";
export default { export default {
name: 'AddSQL', name: 'AddSQL',
...@@ -157,7 +158,9 @@ export default { ...@@ -157,7 +158,9 @@ export default {
syncType: 'sync_now', syncType: 'sync_now',
height: 500, height: 500,
kettleRunning: false, kettleRunning: false,
selectedDatasource: {} selectedDatasource: {},
engineMode: 'local',
disabledSync: true
} }
}, },
computed: { computed: {
...@@ -187,6 +190,9 @@ export default { ...@@ -187,6 +190,9 @@ export default {
}, },
created() { created() {
this.kettleState() this.kettleState()
engineMode().then(res => {
this.engineMode = res.data
})
}, },
methods: { methods: {
kettleState() { kettleState() {
...@@ -198,6 +204,11 @@ export default { ...@@ -198,6 +204,11 @@ export default {
for (let i = 0; i < this.options.length; i++) { for (let i = 0; i < this.options.length; i++) {
if (this.options[i].id === this.dataSource) { if (this.options[i].id === this.dataSource) {
this.selectedDatasource = this.options[i] this.selectedDatasource = this.options[i]
if (this.engineMode === 'simple' || (!this.kettleRunning || this.disabledSyncDs.indexOf(this.selectedDatasource.type) !== -1 )) {
this.disabledSync = true
} else {
this.disabledSync = false
}
} }
} }
}, },
......
...@@ -79,7 +79,6 @@ ...@@ -79,7 +79,6 @@
</template> </template>
<script> <script>
import { isKettleRunning, post } from '@/api/dataset/dataset'
import { queryAuthModel } from '@/api/authModel/authModel' import { queryAuthModel } from '@/api/authModel/authModel'
export default { export default {
name: 'DatasetGroupSelectorTree', name: 'DatasetGroupSelectorTree',
...@@ -144,7 +143,6 @@ export default { ...@@ -144,7 +143,6 @@ export default {
all: this.$t('commons.all'), all: this.$t('commons.all'),
folder: this.$t('commons.folder') folder: this.$t('commons.folder')
}, },
kettleRunning: false,
sceneMode: false, sceneMode: false,
search: '', search: '',
data: [], data: [],
...@@ -200,14 +198,8 @@ export default { ...@@ -200,14 +198,8 @@ export default {
this.treeNode() this.treeNode()
}, },
created() { created() {
this.kettleState()
}, },
methods: { methods: {
kettleState() {
isKettleRunning(false).then(res => {
this.kettleRunning = res.data
})
},
close() { close() {
this.editGroup = false this.editGroup = false
this.groupForm = { this.groupForm = {
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
<svg-icon icon-class="ds-sql" class="ds-icon-sql" /> <svg-icon icon-class="ds-sql" class="ds-icon-sql" />
{{ $t('dataset.sql_data') }} {{ $t('dataset.sql_data') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item :command="beforeClickAddData('excel',data)" :disabled="!kettleRunning"> <el-dropdown-item :command="beforeClickAddData('excel',data)" :disabled="!kettleRunning && engineMode!=='simple'">
<svg-icon icon-class="ds-excel" class="ds-icon-excel" /> <svg-icon icon-class="ds-excel" class="ds-icon-excel" />
{{ $t('dataset.excel_data') }} {{ $t('dataset.excel_data') }}
</el-dropdown-item> </el-dropdown-item>
...@@ -232,6 +232,7 @@ import { loadTable, getScene, addGroup, delGroup, delTable, post, isKettleRunnin ...@@ -232,6 +232,7 @@ import { loadTable, getScene, addGroup, delGroup, delTable, post, isKettleRunnin
import GroupMoveSelector from './GroupMoveSelector' import GroupMoveSelector from './GroupMoveSelector'
import DsMoveSelector from './DsMoveSelector' import DsMoveSelector from './DsMoveSelector'
import { queryAuthModel } from '@/api/authModel/authModel' import { queryAuthModel } from '@/api/authModel/authModel'
import {engineMode} from "@/api/system/engine";
export default { export default {
name: 'Group', name: 'Group',
...@@ -304,6 +305,7 @@ export default { ...@@ -304,6 +305,7 @@ export default {
}, },
isTreeSearch: false, isTreeSearch: false,
kettleRunning: false, kettleRunning: false,
engineMode: 'local',
searchPids: [], // 查询命中的pid searchPids: [], // 查询命中的pid
filterText: '', filterText: '',
searchType: 'all', searchType: 'all',
...@@ -333,6 +335,9 @@ export default { ...@@ -333,6 +335,9 @@ export default {
}, },
created() { created() {
this.kettleState() this.kettleState()
engineMode().then(res => {
this.engineMode = res.data
})
}, },
mounted() { mounted() {
this.treeNode(true) this.treeNode(true)
......
<template>
<div>
<!--邮件表单-->
<el-form ref="form" v-loading="loading"
:model="form"
:rules="rules"
class="demo-form-inline"
:disabled="show"
label-width="180px"
label-position="top"
size="small"
>
<el-row>
<el-col>
<el-form-item :label="$t('datasource.type')" prop="type">
<el-select
v-model="form.type"
:placeholder="$t('datasource.please_choose_type')"
@change="changeType()"
filterable
>
<el-option
v-for="item in allTypes"
:key="item.name"
:label="item.label"
:value="item.name"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('datasource.host')" prop="configuration.host">
<el-input v-model="form.configuration.host"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('datasource.data_base')" prop="configuration.dataBase">
<el-input v-model="form.configuration.dataBase"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('datasource.user_name')">
<el-input v-model="form.configuration.username"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('datasource.password')">
<el-input v-model="form.configuration.password" show-password/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('datasource.port')" prop="configuration.port">
<el-input v-model="form.configuration.port" autocomplete="off" type="number" min="0"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('datasource.extra_params')">
<el-input v-model="form.configuration.extraParams"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div>
<el-button type="primary" size="small" @click="validaDatasource">
{{ $t('commons.validate') }}
</el-button>
<el-button v-if="showEdit" size="small" @click="edit">
{{ $t('commons.edit') }}
</el-button>
<el-button v-if="showSave" type="success" size="small" @click="save">
{{ $t('commons.save') }}
</el-button>
<el-button v-if="showCancel" type="info" size="small" @click="cancel">
{{ $t('commons.cancel') }}
</el-button>
</div>
</div>
</template>
<script>
import {engineInfo, validate, save} from '@/api/system/engine'
import i18n from "@/lang";
export default {
name: 'SimpleMode',
data() {
return {
form:
{
type: 'mysql',
configuration: {
host: '',
dataBase: '',
username: '',
password: '',
port: '',
extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
}
},
originConfiguration: {
host: '',
dataBase: '',
username: '',
password: '',
port: '',
extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
},
input: '',
visible: true,
showEdit: true,
showSave: false,
showCancel: false,
show: true,
disabledConnection: false,
disabledSave: false,
loading: false,
rules: {
host: [
{
required: true,
message: this.$t('system_parameter_setting.host'),
trigger: ['change', 'blur']
}
],
port: [
{
required: true,
message: this.$t('system_parameter_setting.port'),
trigger: ['change', 'blur']
}
],
account: [
{
required: true,
message: this.$t('system_parameter_setting.account'),
trigger: ['change', 'blur']
}]
},
allTypes: [
{
name: 'mysql',
label: 'MySQL',
type: 'jdbc',
extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
}
]
}
},
created() {
this.query()
},
methods: {
query() {
engineInfo().then(response => {
if (response.data.id) {
this.form = JSON.parse(JSON.stringify(response.data))
this.form.configuration = JSON.parse(this.form.configuration)
this.originConfiguration = JSON.parse(JSON.stringify(this.form.configuration))
}
this.$nextTick(() => {
this.$refs.form.clearValidate()
})
})
},
edit() {
this.showEdit = false
this.showSave = true
this.showCancel = true
this.show = false
},
save() {
if (this.form.configuration.dataSourceType === 'jdbc' && this.form.configuration.port <= 0) {
this.$message.error(i18n.t('datasource.port_no_less_then_0'))
return
}
if (this.form.configuration.initialPoolSize < 0 || this.form.configuration.minPoolSize < 0 || this.form.configuration.maxPoolSize < 0) {
this.$message.error(i18n.t('datasource.no_less_then_0'))
return
}
this.$refs.form.validate(valid => {
if (!valid) {
return false
}
const form = JSON.parse(JSON.stringify(this.form))
form.configuration = JSON.stringify(form.configuration)
save(form).then(res => {
this.showEdit = true
this.showCancel = false
this.showSave = false
this.show = true
this.originConfiguration = JSON.parse(JSON.stringify(this.form.configuration))
this.$success(i18n.t('commons.save_success'))
})
})
},
cancel() {
this.showEdit = true
this.showCancel = false
this.showSave = false
this.show = true
this.form.configuration = JSON.parse(JSON.stringify(this.originConfiguration))
},
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
}
}
},
validaDatasource() {
if (!this.form.configuration.schema && this.form.type === 'oracle') {
this.$message.error(i18n.t('datasource.please_choose_schema'))
return
}
if (this.form.configuration.dataSourceType === 'jdbc' && this.form.configuration.port <= 0) {
this.$message.error(i18n.t('datasource.port_no_less_then_0'))
return
}
this.$refs.form.validate(valid => {
if (valid) {
const data = JSON.parse(JSON.stringify(this.form))
data.configuration = JSON.stringify(data.configuration)
validate(data).then(res => {
if (res.success) {
this.$success(i18n.t('datasource.validate_success'))
} else {
if (res.message.length < 2500) {
this.$error(res.message)
} else {
this.$error(res.message.substring(0, 2500) + '......')
}
}
}).catch(res => {
this.$error(res.message)
})
} else {
return false
}
})
},
}
}
</script>
<style scoped>
</style>
<template>
<div>
<!--邮件表单-->
<el-form
ref="formInline"
v-loading="loading"
:model="formInline"
:rules="rules"
class="demo-form-inline"
:disabled="show"
size="small"
>
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.SMTP_host')" prop="host">
<el-input
v-model="formInline.host"
:placeholder="$t('system_parameter_setting.SMTP_host')"
@input="change()"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.SMTP_port')" prop="port">
<el-input
v-model="formInline.port"
:placeholder="$t('system_parameter_setting.SMTP_port')"
@input="change()"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.SMTP_account')" prop="account">
<el-input
v-model="formInline.account"
:placeholder="$t('system_parameter_setting.SMTP_account')"
@input="change()"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.SMTP_password')" prop="password">
<el-input
ref="input"
v-model="formInline.password"
:placeholder="$t('system_parameter_setting.SMTP_password')"
autocomplete="new-password"
show-password
type="text"
@focus="changeType"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item :label="$t('system_parameter_setting.test_recipients')">
<el-input
ref="input"
v-model="formInline.recipient"
:placeholder="$t('system_parameter_setting.test_recipients')"
autocomplete="new-password"
show-password
type="text"
/>
<p style="color: #8a8b8d">({{ $t('system_parameter_setting.tip') }})</p>
</el-form-item>
</el-col>
</el-row>
<!---->
<div style="border: 0px;margin-bottom: 20px">
<el-checkbox v-model="formInline.ssl" :label="$t('system_parameter_setting.SSL')" />
</div>
<div style="border: 0px;margin-bottom: 20px">
<el-checkbox v-model="formInline.tls" :label="$t('system_parameter_setting.TLS')" />
</div>
<template v-slot:footer />
</el-form>
<div>
<el-button type="primary" :disabled="disabledConnection" size="small" @click="testConnection('formInline')">
{{ $t('system_parameter_setting.test_connection') }}
</el-button>
<el-button v-if="showEdit" size="small" @click="edit">{{ $t('commons.edit') }}</el-button>
<el-button v-if="showSave" type="success" :disabled="disabledSave" size="small" @click="save('formInline')">
{{ $t('commons.save') }}
</el-button>
<el-button v-if="showCancel" type="info" size="small" @click="cancel">{{ $t('commons.cancel') }}</el-button>
</div>
</div>
</template>
<script>
import { emailInfo, updateInfo, validate } from '@/api/system/email'
export default {
name: 'EmailSetting',
data() {
return {
formInline: {},
input: '',
visible: true,
showEdit: true,
showSave: false,
showCancel: false,
show: true,
disabledConnection: false,
disabledSave: false,
loading: false,
rules: {
host: [
{
required: true,
message: this.$t('system_parameter_setting.host'),
trigger: ['change', 'blur']
}
],
port: [
{
required: true,
message: this.$t('system_parameter_setting.port'),
trigger: ['change', 'blur']
}
],
account: [
{
required: true,
message: this.$t('system_parameter_setting.account'),
trigger: ['change', 'blur']
}]
}
}
},
created() {
this.query()
},
methods: {
changeType() {
this.$refs.input = 'password'
},
query() {
emailInfo().then(response => {
this.formInline = response.data
this.formInline.ssl = this.formInline.ssl === 'true'
this.formInline.tls = this.formInline.tls === 'true'
this.$nextTick(() => {
this.$refs.formInline.clearValidate()
})
})
},
change() {
if (!this.formInline.host || !this.formInline.port || !this.formInline.account) {
this.disabledConnection = true
this.disabledSave = true
} else {
this.disabledConnection = false
this.disabledSave = false
}
},
testConnection(formInline) {
const param = {
'smtp.host': this.formInline.host,
'smtp.port': this.formInline.port,
'smtp.account': this.formInline.account,
'smtp.password': this.formInline.password,
'smtp.ssl': this.formInline.ssl,
'smtp.tls': this.formInline.tls,
'smtp.recipient': this.formInline.recipient
}
this.$refs[formInline].validate((valid) => {
if (valid) {
validate(param).then(response => {
this.$success(this.$t('commons.connection_successful'))
})
} else {
return false
}
})
},
edit() {
this.showEdit = false
this.showSave = true
this.showCancel = true
this.show = false
},
save(formInline) {
this.showEdit = true
this.showCancel = false
this.showSave = false
this.show = true
const param = [
{ paramKey: 'smtp.host', paramValue: this.formInline.host, type: 'text', sort: 1 },
{ paramKey: 'smtp.port', paramValue: this.formInline.port, type: 'text', sort: 2 },
{ paramKey: 'smtp.account', paramValue: this.formInline.account, type: 'text', sort: 3 },
{ paramKey: 'smtp.password', paramValue: this.formInline.password, type: 'password', sort: 4 },
{ paramKey: 'smtp.ssl', paramValue: this.formInline.ssl, type: 'text', sort: 5 },
{ paramKey: 'smtp.tls', paramValue: this.formInline.tls, type: 'text', sort: 6 },
{ paramKey: 'smtp.recipient', paramValue: this.formInline.recipient, type: 'text', sort: 8 }
]
this.$refs[formInline].validate(valid => {
if (valid) {
updateInfo(param).then(response => {
const flag = response.success
if (flag) {
this.$success(this.$t('commons.save_success'))
} else {
this.$message.error(this.$t('commons.save_failed'))
}
})
} else {
// this.result = false
}
})
},
cancel() {
this.showEdit = true
this.showCancel = false
this.showSave = false
this.show = true
this.query()
}
}
}
</script>
<style scoped>
</style>
...@@ -6,10 +6,6 @@ ...@@ -6,10 +6,6 @@
<basic-setting /> <basic-setting />
</el-tab-pane> </el-tab-pane>
<el-tab-pane :lazy="true" :label="$t('system_parameter_setting.simple_mode_datasource')" name="first">
<email-setting />
</el-tab-pane>
<el-tab-pane :lazy="true" :label="$t('system_parameter_setting.mailbox_service_settings')" name="first"> <el-tab-pane :lazy="true" :label="$t('system_parameter_setting.mailbox_service_settings')" name="first">
<email-setting /> <email-setting />
</el-tab-pane> </el-tab-pane>
...@@ -30,32 +26,42 @@ ...@@ -30,32 +26,42 @@
<plugin-com v-if="isPluginLoaded" ref="DisplaySetting" component-name="SsoSetting" /> <plugin-com v-if="isPluginLoaded" ref="DisplaySetting" component-name="SsoSetting" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane v-if="engineMode==='simple'" :lazy="true" :label="$t('system_parameter_setting.engine_mode_setting')" name="six">
<simple-mode />
</el-tab-pane>
</el-tabs> </el-tabs>
</layout-content> </layout-content>
</template> </template>
<script> <script>
import BasicSetting from './BasicSetting' import BasicSetting from './BasicSetting'
import EmailSetting from './EmailSetting' import EmailSetting from './EmailSetting'
import SimpleMode from './SimpleModeSetting'
import LayoutContent from '@/components/business/LayoutContent' import LayoutContent from '@/components/business/LayoutContent'
import PluginCom from '@/views/system/plugin/PluginCom' import PluginCom from '@/views/system/plugin/PluginCom'
import { pluginLoaded } from '@/api/user' import { pluginLoaded } from '@/api/user'
import { engineMode } from '@/api/system/engine'
export default { export default {
components: { BasicSetting, EmailSetting, LayoutContent, PluginCom }, components: { BasicSetting, EmailSetting, LayoutContent, PluginCom, SimpleMode},
data() { data() {
return { return {
activeName: 'zero', activeName: 'zero',
isPluginLoaded: false isPluginLoaded: false,
engineMode: 'local'
} }
}, },
beforeCreate() { beforeCreate() {
pluginLoaded().then(res => { pluginLoaded().then(res => {
this.isPluginLoaded = res.success && res.data this.isPluginLoaded = res.success && res.data
}) })
engineMode().then(res => {
this.engineMode = res.data
})
}, },
methods: { methods: {
handleClick(tab, event) { handleClick(tab, event) {
console.log(tab, event) // console.log(tab, event)
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论