You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/03/23 02:53:30 UTC
[incubator-linkis] branch dev-1.1.0 updated: fix:DWSHttpMessageResult cannot distinguish different methods(GET/DELETE) of the same RequestMapping request (#1778)
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.1.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.1.0 by this push:
new 95bc80e fix:DWSHttpMessageResult cannot distinguish different methods(GET/DELETE) of the same RequestMapping request (#1778)
95bc80e is described below
commit 95bc80ee1023b801d5a38f4d54989894841710d6
Author: Casion <ca...@gmail.com>
AuthorDate: Wed Mar 23 10:53:27 2022 +0800
fix:DWSHttpMessageResult cannot distinguish different methods(GET/DELETE) of the same RequestMapping request (#1778)
* datasource getPartitionsByDsId:add traverse parameter
* DWSHttpMessageResult cannot distinguish different methods(GET/DELETE) of the same RequestMapping request
* fix datasource file upload
* code format
---
.../client/request/DeleteDataSourceAction.scala | 2 +-
.../request/MetadataGetPartitionsAction.scala | 8 +
.../client/response/DeleteDataSourceResult.scala | 2 +-
.../core/restful/DataSourceCoreRestfulApi.java | 2 +-
.../core/restful/DataSourceCoreRestfulApiTest.java | 2 +-
.../server/restful/MetadataCoreRestful.java | 3 +
.../server/service/MetadataAppService.java | 7 +-
.../service/impl/MetadataAppServiceImpl.java | 9 +-
.../server/restful/MetadataCoreRestfulTest.java | 4 +-
.../module/datasource/datasourceForm/index.vue | 346 +++++-----
web/src/apps/linkis/module/datasource/index.vue | 730 ++++++++++++---------
11 files changed, 650 insertions(+), 465 deletions(-)
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/request/DeleteDataSourceAction.scala b/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/request/DeleteDataSourceAction.scala
index 102f1af..615b509 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/request/DeleteDataSourceAction.scala
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/request/DeleteDataSourceAction.scala
@@ -31,7 +31,7 @@ class DeleteDataSourceAction extends DeleteAction with DataSourceAction {
override def getUser: String = this.user
- override def suffixURLs: Array[String] = Array(DATA_SOURCE_SERVICE_MODULE.getValue, "info", dataSourceId.toString)
+ override def suffixURLs: Array[String] = Array(DATA_SOURCE_SERVICE_MODULE.getValue, "info/delete", dataSourceId.toString)
}
object DeleteDataSourceAction{
def builder(): Builder = new Builder
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/request/MetadataGetPartitionsAction.scala b/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/request/MetadataGetPartitionsAction.scala
index def90b3..3073084 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/request/MetadataGetPartitionsAction.scala
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/request/MetadataGetPartitionsAction.scala
@@ -26,6 +26,7 @@ class MetadataGetPartitionsAction extends GetAction with DataSourceAction {
private var dataSourceId: Long = _
private var database: String = _
private var table: String = _
+ private var traverse: Boolean = false
override def suffixURLs: Array[String] = Array(METADATA_SERVICE_MODULE.getValue, "partitions", dataSourceId.toString, "db", database, "table", table)
@@ -46,6 +47,7 @@ object MetadataGetPartitionsAction {
private var table: String = _
private var system: String = _
private var user: String = _
+ private var traverse: Boolean = false
def setUser(user: String): Builder = {
this.user = user
@@ -67,6 +69,11 @@ object MetadataGetPartitionsAction {
this
}
+ def setTraverse(traverse: Boolean): Builder = {
+ this.traverse = traverse
+ this
+ }
+
def setSystem(system: String): Builder = {
this.system = system
this
@@ -84,6 +91,7 @@ object MetadataGetPartitionsAction {
metadataGetPartitionsAction.table = this.table
metadataGetPartitionsAction.setParameter("system", system)
metadataGetPartitionsAction.setUser(user)
+ metadataGetPartitionsAction.traverse=this.traverse
metadataGetPartitionsAction
}
}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/response/DeleteDataSourceResult.scala b/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/response/DeleteDataSourceResult.scala
index 0a353db..791f53b 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/response/DeleteDataSourceResult.scala
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-client/src/main/scala/org/apache/linkis/datasource/client/response/DeleteDataSourceResult.scala
@@ -22,7 +22,7 @@ import org.apache.linkis.httpclient.dws.response.DWSResult
import scala.beans.BeanProperty
-@DWSHttpMessageResult("/api/rest_j/v\\d+/data-source-manager/info/(\\S+)")
+@DWSHttpMessageResult("/api/rest_j/v\\d+/data-source-manager/info/delete/(\\S+)")
class DeleteDataSourceResult extends DWSResult{
@BeanProperty var removeId: Long = _
}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApi.java b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApi.java
index e28029d..782b497 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApi.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApi.java
@@ -384,7 +384,7 @@ public class DataSourceCoreRestfulApi {
* @param dataSourceId
* @return
*/
- @RequestMapping(value = "/info/{dataSourceId}", method = RequestMethod.DELETE)
+ @RequestMapping(value = "/info/delete/{dataSourceId}", method = RequestMethod.DELETE)
public Message removeDataSource(
@PathVariable("dataSourceId") Long dataSourceId, HttpServletRequest request) {
return RestfulApiHelper.doAndResponse(
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/test/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApiTest.java b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/test/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApiTest.java
index 80d05c4..0f314d5 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/test/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApiTest.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/test/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApiTest.java
@@ -399,7 +399,7 @@ class DataSourceCoreRestfulApiTest {
void removeDataSource() throws Exception {
MvcUtils mvcUtils = new MvcUtils(mockMvc);
long dataSourceId = 1l;
- String url = String.format("/data-source-manager/info/%s", dataSourceId);
+ String url = String.format("/data-source-manager/info/delete/%s", dataSourceId);
DataSource dataSource = new DataSource();
dataSource.setId(dataSourceId);
dataSource.setCreateUser("hadoop");
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/restful/MetadataCoreRestful.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/restful/MetadataCoreRestful.java
index ebcb9cb..65d27e0 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/restful/MetadataCoreRestful.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/restful/MetadataCoreRestful.java
@@ -190,6 +190,8 @@ public class MetadataCoreRestful {
@PathVariable("database") String database,
@PathVariable("table") String table,
@RequestParam("system") String system,
+ @RequestParam(name = "traverse", required = false, defaultValue = "false")
+ Boolean traverse,
HttpServletRequest request) {
try {
if (StringUtils.isBlank(system)) {
@@ -201,6 +203,7 @@ public class MetadataCoreRestful {
database,
table,
system,
+ traverse,
SecurityFilter.getLoginUsername(request));
return Message.ok().data("props", partitionInfo);
} catch (Exception e) {
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/service/MetadataAppService.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/service/MetadataAppService.java
index d53aa9b..4e5a5df 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/service/MetadataAppService.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/service/MetadataAppService.java
@@ -90,7 +90,12 @@ public interface MetadataAppService {
* @return
*/
MetaPartitionInfo getPartitionsByDsId(
- String dataSourceId, String database, String table, String system, String userName)
+ String dataSourceId,
+ String database,
+ String table,
+ String system,
+ Boolean traverse,
+ String userName)
throws ErrorException;
/**
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/service/impl/MetadataAppServiceImpl.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/service/impl/MetadataAppServiceImpl.java
index 8c78d98..9aa9fb1 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/service/impl/MetadataAppServiceImpl.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/main/java/org/apache/linkis/metadatamanager/server/service/impl/MetadataAppServiceImpl.java
@@ -151,7 +151,12 @@ public class MetadataAppServiceImpl implements MetadataAppService {
@Override
public MetaPartitionInfo getPartitionsByDsId(
- String dataSourceId, String database, String table, String system, String userName)
+ String dataSourceId,
+ String database,
+ String table,
+ String system,
+ Boolean traverse,
+ String userName)
throws ErrorException {
DsInfoResponse dsInfoResponse = reqToGetDataSourceInfo(dataSourceId, system, userName);
if (StringUtils.isNotBlank(dsInfoResponse.dsType())) {
@@ -159,7 +164,7 @@ public class MetadataAppServiceImpl implements MetadataAppService {
dsInfoResponse.dsType(),
"getPartitions",
new Object[] {
- dsInfoResponse.creator(), dsInfoResponse.params(), database, table
+ dsInfoResponse.creator(), dsInfoResponse.params(), database, table, traverse
},
MetaPartitionInfo.class);
}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/test/java/org/apache/linkis/metadatamanager/server/restful/MetadataCoreRestfulTest.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/test/java/org/apache/linkis/metadatamanager/server/restful/MetadataCoreRestfulTest.java
index 1b2c8cb..a685237 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/test/java/org/apache/linkis/metadatamanager/server/restful/MetadataCoreRestfulTest.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-manager/server/src/test/java/org/apache/linkis/metadatamanager/server/restful/MetadataCoreRestfulTest.java
@@ -183,14 +183,14 @@ class MetadataCoreRestfulTest {
params.add("system", "hive");
Mockito.when(
metadataAppService.getPartitionsByDsId(
- dataSourceId, database, table, ",hive", null))
+ dataSourceId, database, table, ",hive", false, null))
.thenReturn(new MetaPartitionInfo());
res = mvcUtils.getMessage(mvcUtils.buildMvcResultGet(url, params));
Assertions.assertTrue(MessageStatus.SUCCESS() == res.getStatus());
Mockito.doThrow(new ErrorException(1, ""))
.when(metadataAppService)
- .getPartitionsByDsId(dataSourceId, database, table, ",hive", null);
+ .getPartitionsByDsId(dataSourceId, database, table, ",hive", false, null);
res = mvcUtils.getMessage(mvcUtils.buildMvcResultGet(url, params));
Assertions.assertTrue(
MessageStatus.ERROR() == res.getStatus()
diff --git a/web/src/apps/linkis/module/datasource/datasourceForm/index.vue b/web/src/apps/linkis/module/datasource/datasourceForm/index.vue
index a0d88d3..f30fa1a 100644
--- a/web/src/apps/linkis/module/datasource/datasourceForm/index.vue
+++ b/web/src/apps/linkis/module/datasource/datasourceForm/index.vue
@@ -17,79 +17,124 @@
<template>
<div class="table-warp">
- <form-create :rule="rule" v-model="fApi" :option="options" :value.sync="formData"/>
+ <form-create
+ :rule="rule"
+ v-model="fApi"
+ :option="options"
+ :value.sync="formData"
+ />
</div>
</template>
<script>
-import _, { merge, mergeWith} from 'lodash';
-import api from '@/common/service/api';
-import {getKeyDefine, getDataSourceByIdAndVersion} from '../dataSourceApi';
+import _, { merge, mergeWith } from 'lodash'
+import api from '@/common/service/api'
+import { getKeyDefine, getDataSourceByIdAndVersion } from '../dataSourceApi'
// import {mysql, hive} from '../datasource';
const type = {
- TEXT: {type: 'input'},
- NUMBER: {type: 'input', props: {type: 'number'}},
- PASSWORD: {type: 'input', props: {type: 'password'}},
- EMAIL: {type: 'input', props: {type: 'email'}},
- DATE: {type: 'input', props: {type: 'date'}},
- TEL: {type: 'input', props: {type: 'tel'}},
- TEXTAREA: {type: 'input', props: {type: 'textarea'}},
- URL: {type: 'input', props: {type: 'url'}},
- FILE: (self, source)=>{
- return {type: 'upload', props: {uploadType: 'file', action: '',allowRemove: true, "maxLength": 1,
- beforeUpload: (file)=>{
- self.file = file;
- source.props.value = file.name;
- return false;
- }}}
+ TEXT: { type: 'input' },
+ NUMBER: { type: 'input', props: { type: 'number' } },
+ PASSWORD: { type: 'input', props: { type: 'password' } },
+ EMAIL: { type: 'input', props: { type: 'email' } },
+ DATE: { type: 'input', props: { type: 'date' } },
+ TEL: { type: 'input', props: { type: 'tel' } },
+ TEXTAREA: { type: 'input', props: { type: 'textarea' } },
+ URL: { type: 'input', props: { type: 'url' } },
+ FILE: (self, source, data) => {
+ return {
+ type: 'upload',
+ props: {
+ uploadType: 'file',
+ action: data.dataSource,
+ allowRemove: true,
+ maxLength: 1,
+ beforeUpload: () => {
+ return true
+ },
+ onSuccess: (res, file) => {
+ self.file = file
+ source.props.value = res.data ? res.data.resourceId : res.data
+ file.url = res.id
+ console.log("resourceId:"+res.data.resourceId);
+ },
+ },
+ }
},
- SELECT: {type: 'select', props: {placement: "bottom"}}
+ SELECT: { type: 'select', props: { placement: 'bottom' } },
}
const typesMap = {
- valueType: (data, source, self)=>{
- if(type[data.valueType]){
- if(typeof type[data.valueType] === 'function'){
- return type[data.valueType](self, source);
+ valueType: (data, source, self) => {
+ if (type[data.valueType]) {
+ if (typeof type[data.valueType] === 'function') {
+ return type[data.valueType](self, source, data)
}
return type[data.valueType]
- }else{
- return {type: data.valueType}
+ } else {
+ return { type: data.valueType }
}
},
name: 'title',
defaultValue: 'value',
// dataSource: 'options',
- dataSource: (data, source, self)=>{
- const fApi = self.fApi;
+ dataSource: (data, source, self) => {
+ const fApi = self.fApi
try {
- return {options: JSON.parse(data.dataSource)}
+ return { options: JSON.parse(data.dataSource) }
} catch (error) {
- api.fetch(data.dataSource, {}, 'get').then(result=>{
- delete source.options;
- source.options = result.envList.map(item=>{
- return {label: item.envName, value: ''+item.id}
- });
- // console.log('self.rule',self.rule)
- fApi.refreshOptions();
- })
- return {options: []}
+ if (!(data.valueType == 'upload' || data.valueType == 'FILE')) {
+ api.fetch(data.dataSource, {}, 'get').then((result) => {
+ delete source.options
+ source.options = result.envList.map((item) => {
+ return { label: item.envName, value: '' + item.id }
+ })
+ // console.log('self.rule',self.rule)
+ fApi.refreshOptions()
+ })
+ return { options: [] }
+ }
}
},
key: 'field',
- description: (data)=>{
- return {props: {placeholder: data.description}}
+ description: (data) => {
+ return { props: { placeholder: data.description } }
},
- require: (data)=>{
- if(data.require) //&& !data.valueRegex
- return {validate: [{ required: true, message: `请输入${data.name}`, trigger: 'blur' }]}
- else return null
+ require: (data) => {
+ if (data.require) {
+ if (data.type == 'upload' || data.type == 'FILE') {
+ return {
+ validate: [
+ {
+ required: true,
+ message: `请输入${data.name}`,
+ trigger: 'blur',
+ validator: function (rule, value, callback) {
+ if (value.length < 1) callback(false)
+ },
+ },
+ ],
+ }
+ }
+
+ return {
+ validate: [
+ { required: true, message: `请输入${data.name}`, trigger: 'blur' },
+ ],
+ }
+ } else return null
},
- valueRegex: (data)=>{
- if(data.valueRegex){
- return {validate: [{pattern: new RegExp(data.valueRegex), message: '不符合规则', trigger: 'blur'}]}
- }
- else return null;
+ valueRegex: (data) => {
+ if (data.valueRegex) {
+ return {
+ validate: [
+ {
+ pattern: new RegExp(data.valueRegex),
+ message: '不符合规则',
+ trigger: 'blur',
+ },
+ ],
+ }
+ } else return null
},
// valueRegex: (data)=>{
// if(data.valueRegex)
@@ -103,165 +148,164 @@ const typesMap = {
}
export default {
props: {
- data: Object
+ data: Object,
},
- data () {
+ data() {
return {
sourceConnectData: {},
fApi: {},
loading: false,
- formData: {file: 'adn'},
+ formData: { file: 'adn' },
options: {
submitBtn: false,
},
rule: [
{
- type: "input",
+ type: 'input',
title: this.$t('message.linkis.datasource.sourceName'),
- field: "dataSourceName",
- value: "",
+ field: 'dataSourceName',
+ value: '',
props: {
- "placeholder": this.$t('message.linkis.datasource.sourceName'),
- },
- validate: [{
- required: true,
- message: `${this.$t('message.linkis.datasource.pleaseInput')}${this.$t('message.linkis.datasource.sourceName')}`,
- trigger: 'blur'
+ placeholder: this.$t('message.linkis.datasource.sourceName'),
},
+ validate: [
+ {
+ required: true,
+ message: `${this.$t(
+ 'message.linkis.datasource.pleaseInput'
+ )}${this.$t('message.linkis.datasource.sourceName')}`,
+ trigger: 'blur',
+ },
],
},
{
- type: "input",
+ type: 'input',
title: this.$t('message.linkis.datasource.sourceDec'),
- field: "dataSourceDesc",
- value: "",
+ field: 'dataSourceDesc',
+ value: '',
props: {
- "placeholder": this.$t('message.linkis.datasource.sourceDec'),
- }
+ placeholder: this.$t('message.linkis.datasource.sourceDec'),
+ },
},
{
- type: "input",
+ type: 'input',
title: this.$t('message.linkis.datasource.label'),
- field: "labels",
- value: "",
+ field: 'labels',
+ value: '',
props: {
- "placeholder": this.$t('message.linkis.datasource.label'),
- }
- }
+ placeholder: this.$t('message.linkis.datasource.label'),
+ },
+ },
],
-
}
},
- created(){
- this.loading = true;
+ created() {
+ this.loading = true
- this.getDataSource(this.data);
+ this.getDataSource(this.data)
- getKeyDefine(this.data.dataSourceTypeId).then((data)=>{
- this.loading = false;
- this.transformData(data.keyDefine);
+ getKeyDefine(this.data.dataSourceTypeId).then((data) => {
+ this.loading = false
+ this.transformData(data.keyDefine)
})
},
watch: {
data: {
- handler (newV) {
-
- this.getDataSource(newV);
+ handler(newV) {
+ this.getDataSource(newV)
},
- deep: true
- }
+ deep: true,
+ },
},
methods: {
- getDataSource(newV){
- if(this.data.id){
- getDataSourceByIdAndVersion(newV.id, newV.versionId||0).then(result=>{
-
- const mConnect = result.info.connectParams;
- this.sourceConnectData = mConnect;
- delete result.info.connectParams;
- this.dataSrc = { ...result.info, ...mConnect};
- this.formData = { ...result.info, ...mConnect};
- })
- }else{
- const connectParams = newV.connectParams;
- delete newV.connectParams;
- this.formData = {...newV, ...connectParams};
- this.dataSrc = {...newV, ...connectParams};
+ getDataSource(newV) {
+ if (this.data.id) {
+ getDataSourceByIdAndVersion(newV.id, newV.versionId || 0).then(
+ (result) => {
+ const mConnect = result.info.connectParams
+ this.sourceConnectData = mConnect
+ delete result.info.connectParams
+ this.dataSrc = { ...result.info, ...mConnect }
+ this.formData = { ...result.info, ...mConnect }
+ }
+ )
+ } else {
+ const connectParams = newV.connectParams
+ delete newV.connectParams
+ this.formData = { ...newV, ...connectParams }
+ this.dataSrc = { ...newV, ...connectParams }
}
},
- transformData(keyDefinitions){
- const tempData = [];
-
- keyDefinitions.forEach((obj)=>{
- let item = {};
- Object.keys(obj).forEach((keyName) =>{
+ transformData(keyDefinitions) {
+ const tempData = []
+ keyDefinitions.forEach((obj) => {
+ let item = {}
+ Object.keys(obj).forEach((keyName) => {
switch (typeof typesMap[keyName]) {
case 'object':
item = merge({}, item, typesMap[keyName])
- break;
+ break
case 'function':
-
- item = mergeWith(item, typesMap[keyName](obj, item, this), function(objValue, srcValue){
- if(_.isArray(objValue)) {
- return objValue.concat(srcValue);
+ item = mergeWith(
+ item,
+ typesMap[keyName](obj, item, this),
+ function (objValue, srcValue) {
+ if (_.isArray(objValue)) {
+ return objValue.concat(srcValue)
+ }
}
- });
- break;
+ )
+ break
case 'string':
- item[typesMap[keyName]] = obj[keyName];
- break;
+ item[typesMap[keyName]] = obj[keyName]
+ break
}
- });
- tempData.push(item);
- });
-
- const insertParent = (id, child)=>{
-
- let parent = tempData.find(item=> id==item.id);
- if(parent && child){
+ })
+ tempData.push(item)
+ })
- if(!parent.control || parent.control.length===0) {
- parent.control = [ //不存在新建
+ const insertParent = (id, child) => {
+ let parent = tempData.find((item) => id == item.id)
+ if (parent && child) {
+ if (!parent.control || parent.control.length === 0) {
+ parent.control = [
+ //不存在新建
{
value: child.refValue,
- rule: [{...child} ]
- }
+ rule: [{ ...child }],
+ },
]
- }else {
- let index = parent.control.findIndex(item=>item.value+'' === child.refValue+'');
- if(index > -1){
- parent.control[index].rule.push({...child})
- }else {
- parent.control.push(
- {
- value: child.refValue,
- rule: [{...child} ]
- }
- )
+ } else {
+ let index = parent.control.findIndex(
+ (item) => item.value + '' === child.refValue + ''
+ )
+ if (index > -1) {
+ parent.control[index].rule.push({ ...child })
+ } else {
+ parent.control.push({
+ value: child.refValue,
+ rule: [{ ...child }],
+ })
}
-
}
-
}
-
}
- for(var i =0; i<tempData.length; i++){
- let item = tempData[i];
- if(item.refId && item.refId > 0){
- let children = tempData.splice(i, 1);
- i--;
- insertParent(item.refId, children[0]);
+ for (var i = 0; i < tempData.length; i++) {
+ let item = tempData[i]
+ if (item.refId && item.refId > 0) {
+ let children = tempData.splice(i, 1)
+ i--
+ insertParent(item.refId, children[0])
}
}
- this.rule = this.rule.concat(tempData);
- return tempData;
-
- }
- }
+ this.rule = this.rule.concat(tempData)
+ return tempData
+ },
+ },
}
</script>
diff --git a/web/src/apps/linkis/module/datasource/index.vue b/web/src/apps/linkis/module/datasource/index.vue
index b602297..b9d35a4 100644
--- a/web/src/apps/linkis/module/datasource/index.vue
+++ b/web/src/apps/linkis/module/datasource/index.vue
@@ -22,7 +22,8 @@
class="modal"
v-model="showVersionList"
:loading="loadingForm"
- :title="`${actionType}${$t('message.linkis.datasource.versionList')}`">
+ :title="`${actionType}${$t('message.linkis.datasource.versionList')}`"
+ >
<Spin size="large" fix v-if="loadingVersionList"></Spin>
<Table
border
@@ -31,25 +32,42 @@
:columns="versionTableColumnNum"
:data="currentVersionList"
max-height="300"
- class="table-content">
- <template
- slot-scope="{row, index}"
- slot="action"
- >
+ class="table-content"
+ >
+ <template slot-scope="{ row, index }" slot="action">
<ButtonGroup size="small" :key="row.versionId">
-
- <Button v-if="row.status==0" size="small" type="text" @click="onPublish(row)"> {{$t('message.linkis.datasource.publish')}} </Button>
-
- <Button size="small" type="text" @click="watch(row, index)">{{$t('message.linkis.datasource.watch')}}</Button>
- <Button v-if="row.status==2" size="small" type="text" @click="onRollback(row)"> {{$t('message.linkis.datasource.rollback')}} </Button>
-
- <Button type="primary" @click="onConnectTestFromVersion(row)">{{$t('message.linkis.datasource.connectTest')}}</Button>
+ <Button
+ v-if="row.status == 0"
+ size="small"
+ type="text"
+ @click="onPublish(row)"
+ >
+ {{ $t('message.linkis.datasource.publish') }}
+ </Button>
+
+ <Button size="small" type="text" @click="watch(row, index)">{{
+ $t('message.linkis.datasource.watch')
+ }}</Button>
+ <Button
+ v-if="row.status == 2"
+ size="small"
+ type="text"
+ @click="onRollback(row)"
+ >
+ {{ $t('message.linkis.datasource.rollback') }}
+ </Button>
+
+ <Button type="primary" @click="onConnectTestFromVersion(row)">{{
+ $t('message.linkis.datasource.connectTest')
+ }}</Button>
</ButtonGroup>
</template>
</Table>
<div slot="footer">
- <div v-if="currentStep===0">
- <Button @click="showVersionList = false">{{$t('message.linkis.cancel')}}</Button>
+ <div v-if="currentStep === 0">
+ <Button @click="showVersionList = false">{{
+ $t('message.linkis.cancel')
+ }}</Button>
</div>
</div>
</Modal>
@@ -57,48 +75,95 @@
width="800"
class="modal"
v-model="showDataSource"
- :title="`${actionType}${$t('message.linkis.datasource.datasourceSrc')}`">
+ :title="`${actionType}${$t('message.linkis.datasource.datasourceSrc')}`"
+ >
<Spin size="large" fix v-if="loadingForm"></Spin>
- <DataSourceType :data="typeList" v-show="currentStep===0" :onSelected="onSelect"/>
- <DatasourceForm :data="currentSourceData" ref="datasourceForm" v-if="showDataSource&¤tStep===1"/>
+ <DataSourceType
+ :data="typeList"
+ v-show="currentStep === 0"
+ :onSelected="onSelect"
+ />
+ <DatasourceForm
+ :data="currentSourceData"
+ ref="datasourceForm"
+ v-if="showDataSource && currentStep === 1"
+ />
<div slot="footer">
- <div v-if="currentStep===0">
- <Button @click="showDataSource = false">{{$t('message.linkis.cancel')}}</Button>
+ <div v-if="currentStep === 0">
+ <Button @click="showDataSource = false">{{
+ $t('message.linkis.cancel')
+ }}</Button>
</div>
- <div v-else class="footer">
- <div><Button type="primary" @click="onConnectFormTest">{{$t('message.linkis.datasource.connectTest')}}</Button></div>
+ <div v-else class="footer">
<div>
- <Button v-if="actionType==$t('message.linkis.create')" @click="stepChange(-1)">{{$t('message.linkis.prev')}}</Button>
- <Button v-if="actionType==$t('message.linkis.datasource.watch')" type="primary" @click="showDataSource = false">{{$t('message.linkis.close')}}</Button>
- <Button v-else type="primary" @click="onSubmit">{{$t('message.linkis.complete')}}</Button>
+ <Button type="primary" @click="onConnectFormTest">{{
+ $t('message.linkis.datasource.connectTest')
+ }}</Button>
+ </div>
+ <div>
+ <Button
+ v-if="actionType == $t('message.linkis.create')"
+ @click="stepChange(-1)"
+ >{{ $t('message.linkis.prev') }}</Button
+ >
+ <Button
+ v-if="actionType == $t('message.linkis.datasource.watch')"
+ type="primary"
+ @click="showDataSource = false"
+ >{{ $t('message.linkis.close') }}</Button
+ >
+ <Button v-else type="primary" @click="onSubmit">{{
+ $t('message.linkis.complete')
+ }}</Button>
</div>
</div>
</div>
</Modal>
<Row class="search-bar" type="flex" justify="space-around">
<Col span="6">
- <Input clearable v-model="searchName" suffix="ios-search" class="input" :placeholder="$t('message.linkis.datasource.sourceName')" @on-enter="searchList(true)"></Input>
+ <Input
+ clearable
+ v-model="searchName"
+ suffix="ios-search"
+ class="input"
+ :placeholder="$t('message.linkis.datasource.sourceName')"
+ @on-enter="searchList(true)"
+ ></Input>
</Col>
<Col span="6" class="search-item">
- <span class="lable">{{$t('message.linkis.datasource.sourceType')}}</span>
+ <span class="lable">{{
+ $t('message.linkis.datasource.sourceType')
+ }}</span>
<Select v-model="dataSourceTypeId" class="input">
- <Option v-for="item in typeList" :value="item.id" :key="item.id">{{item.name}}</Option>
- <Option value="null">{{$t('message.linkis.statusType.all')}}</Option>
+ <Option v-for="item in typeList" :value="item.id" :key="item.id">{{
+ item.name
+ }}</Option>
+ <Option value="null">{{
+ $t('message.linkis.statusType.all')
+ }}</Option>
</Select>
</Col>
<Col span="3">
- <Button type="primary" class="button" @click="searchList(true)">{{$t('message.linkis.search')}}</Button>
+ <Button type="primary" class="button" @click="searchList(true)">{{
+ $t('message.linkis.search')
+ }}</Button>
</Col>
<Col span="3">
- <Button type="primary" @click="createDatasource">{{$t('message.linkis.datasource.create')}}</Button>
+ <Button type="primary" @click="createDatasource">{{
+ $t('message.linkis.datasource.create')
+ }}</Button>
</Col>
<Col span="3">
- <Button type="primary" disabled>{{$t('message.linkis.datasource.exports')}}</Button>
+ <Button type="primary" disabled>{{
+ $t('message.linkis.datasource.exports')
+ }}</Button>
</Col>
<Col span="3">
- <Button type="primary" disabled>{{$t('message.linkis.datasource.imports')}}</Button>
+ <Button type="primary" disabled>{{
+ $t('message.linkis.datasource.imports')
+ }}</Button>
</Col>
</Row>
<Table
@@ -109,46 +174,77 @@
:data="pageDatalist"
max-height="420"
:loading="tableLoading"
- class="table-content">
- <template
- slot-scope="{row, index}"
- slot="version"
- >
- <Button size="small" type="primary" :disabled="row.expire" @click="openVersionList(row, index)">{{`${row.versionId||'-'}`}}</Button>
+ class="table-content"
+ >
+ <template slot-scope="{ row, index }" slot="version">
+ <Button
+ size="small"
+ type="primary"
+ :disabled="row.expire"
+ @click="openVersionList(row, index)"
+ >{{ `${row.versionId || '-'}` }}</Button
+ >
</template>
- <template
- slot-scope="{row, index}"
- slot="action"
- >
+ <template slot-scope="{ row, index }" slot="action">
<ButtonGroup size="small">
- <Button :disabled="row.expire" size="small" type="primary" @click="modify(row, index)">{{$t('message.linkis.edit')}}</Button>
-
- <Button :disabled="row.expire" size="small" type="primary" @click="overdue(row)"> {{$t('message.linkis.datasource.overdue')}} </Button>
-
- <Button type="primary" @click="onConnectTest(row)"> {{$t('message.linkis.datasource.connectTest')}} </Button>
+ <Button
+ :disabled="row.expire"
+ size="small"
+ type="primary"
+ @click="modify(row, index)"
+ >{{ $t('message.linkis.edit') }}</Button
+ >
+
+ <Button
+ :disabled="row.expire"
+ size="small"
+ type="primary"
+ @click="overdue(row)"
+ >
+ {{ $t('message.linkis.datasource.overdue') }}
+ </Button>
+
+ <Button type="primary" @click="onConnectTest(row)">
+ {{ $t('message.linkis.datasource.connectTest') }}
+ </Button>
</ButtonGroup>
</template>
</Table>
- <div style="margin: 10px;overflow: hidden">
- <div style="float: right;">
- <Page :page-size="page.pageSize" :total="page.totalSize" :current="page.pageNow" @on-change="changePage"></Page>
+ <div style="margin: 10px; overflow: hidden">
+ <div style="float: right">
+ <Page
+ :page-size="page.pageSize"
+ :total="page.totalSize"
+ :current="page.pageNow"
+ @on-change="changePage"
+ ></Page>
</div>
</div>
</div>
</template>
<script>
-import DatasourceForm from './datasourceForm/index';
-import DataSourceType from './datasourceType/index';
-import { //createDataSourceForm
- getDataSourceList,getDataSourceTypeList,getEnvList,createDataSource, saveConnectParams, saveConnectParamsForm,
- expire, updateDataSource, publish, connect, getDataSourceByIdAndVersion, getVersionListByDatasourceId
-} from './dataSourceApi';
+import DatasourceForm from './datasourceForm/index'
+import DataSourceType from './datasourceType/index'
+import {
+ //createDataSourceForm
+ getDataSourceList,
+ getDataSourceTypeList,
+ getEnvList,
+ createDataSource,
+ saveConnectParams,
+ expire,
+ updateDataSource,
+ publish,
+ connect,
+ getDataSourceByIdAndVersion,
+ getVersionListByDatasourceId,
+} from './dataSourceApi'
// import _ from 'lodash';
-const FORM_KEYS = ['dataSourceName', 'dataSourceDesc', 'labels']; //'dataSourceEnvId'
+const FORM_KEYS = ['dataSourceName', 'dataSourceDesc', 'labels'] //'dataSourceEnvId'
export default {
components: {
DatasourceForm,
- DataSourceType
+ DataSourceType,
},
data() {
return {
@@ -166,7 +262,7 @@ export default {
page: {
totalSize: 0,
pageSize: 10,
- pageNow: 1
+ pageNow: 1,
},
tableColumnNum: [
{
@@ -174,20 +270,23 @@ export default {
key: 'dataSourceName',
minWidth: 120,
tooltip: true,
- align: 'center'
+ align: 'center',
},
{
title: this.$t('message.linkis.datasource.dataSourceType'),
key: 'dataSourceTypeId',
minWidth: 100,
- render: (h, params)=>{
- let result = {};
- if(this.typeList){
- result = this.typeList.find(item => params.row.dataSourceTypeId == item.id) || {};
+ render: (h, params) => {
+ let result = {}
+ if (this.typeList) {
+ result =
+ this.typeList.find(
+ (item) => params.row.dataSourceTypeId == item.id
+ ) || {}
}
- return h('span', result.name);
+ return h('span', result.name)
},
- align: 'center'
+ align: 'center',
},
// {
// title: this.$t('message.linkis.datasource.dataSourceEnv'),
@@ -209,18 +308,20 @@ export default {
tooltip: true,
minWidth: 60,
align: 'center',
- render: (h, params)=>{
- let result = {};
- if(this.envList){
-
- result = this.tableStatusMap.find(item => params.row.expire == item.status) || {};
+ render: (h, params) => {
+ let result = {}
+ if (this.envList) {
+ result =
+ this.tableStatusMap.find(
+ (item) => params.row.expire == item.status
+ ) || {}
}
- var color = 'green';
- if(result.status){
- color = 'red';
+ var color = 'green'
+ if (result.status) {
+ color = 'red'
}
- return h('p',{style: {color: color,},}, result.name);
- }
+ return h('p', { style: { color: color } }, result.name)
+ },
},
{
title: this.$t('message.linkis.datasource.label'),
@@ -232,7 +333,7 @@ export default {
{
title: this.$t('message.linkis.datasource.version'),
key: 'version',
- slot: "version",
+ slot: 'version',
minWidth: 60,
// render: (h, params)=>{
// return h('span', params.row.versionId || '-');
@@ -245,26 +346,33 @@ export default {
minWidth: 120,
tooltip: true,
- align: 'center'
+ align: 'center',
},
{
title: this.$t('message.linkis.datasource.createUser'),
key: 'createUser',
minWidth: 80,
tooltip: true,
- align: 'center'
+ align: 'center',
},
{
title: this.$t('message.linkis.datasource.action'),
minWidth: 170,
- slot: "action",
- align: 'center'
+ slot: 'action',
+ align: 'center',
},
],
pageDatalist: [],
typeList: [],
- versionStatusMap: [{status: 1, name: this.$t('message.linkis.datasource.published')}, {status: 0, name: this.$t('message.linkis.datasource.unpublish')}, {status: 2, name: this.$t('message.linkis.datasource.cannotPublish')} ],
- tableStatusMap: [{status: false, name: this.$t('message.linkis.datasource.used')}, {status: true, name: this.$t('message.linkis.datasource.overdue')} ],
+ versionStatusMap: [
+ { status: 1, name: this.$t('message.linkis.datasource.published') },
+ { status: 0, name: this.$t('message.linkis.datasource.unpublish') },
+ { status: 2, name: this.$t('message.linkis.datasource.cannotPublish') },
+ ],
+ tableStatusMap: [
+ { status: false, name: this.$t('message.linkis.datasource.used') },
+ { status: true, name: this.$t('message.linkis.datasource.overdue') },
+ ],
currentVersionList: [],
showVersionList: false,
versionTableColumnNum: [
@@ -273,7 +381,7 @@ export default {
key: 'versionId',
tooltip: true,
minWidth: 60,
- align: 'center'
+ align: 'center',
},
{
title: this.$t('message.linkis.datasource.status'),
@@ -281,10 +389,13 @@ export default {
tooltip: true,
minWidth: 60,
align: 'center',
- render: (h, params)=>{
- let result = {};
- result = this.versionStatusMap.find(item => params.row.status == item.status) || {};
- return h('span', result.name);
+ render: (h, params) => {
+ let result = {}
+ result =
+ this.versionStatusMap.find(
+ (item) => params.row.status == item.status
+ ) || {}
+ return h('span', result.name)
},
},
{
@@ -292,7 +403,7 @@ export default {
key: 'comment',
tooltip: true,
minWidth: 60,
- align: 'center'
+ align: 'center',
},
// {
// title: this.$t('message.linkis.datasource.createTime'),
@@ -307,148 +418,134 @@ export default {
tooltip: true,
minWidth: 120,
align: 'center',
- slot: 'action'
- }
- ]
+ slot: 'action',
+ },
+ ],
}
},
- created(){
-
- getDataSourceTypeList().then((data)=>{
- this.typeList = data.typeList;
+ created() {
+ getDataSourceTypeList().then((data) => {
+ this.typeList = data.typeList
- getEnvList().then((data)=>{
- this.envList = data.queryList;
+ getEnvList().then((data) => {
+ this.envList = data.queryList
- this.searchList();
+ this.searchList()
})
})
-
-
-
-
},
methods: {
- overdue(data){
- expire(data.id).then(()=>{
- this.searchList();
+ overdue(data) {
+ expire(data.id).then(() => {
+ this.searchList()
})
},
- searchList(isSearch){
- this.loadingTable = true;
- if(isSearch) {
- this.page.pageNow = 1;
+ searchList(isSearch) {
+ this.loadingTable = true
+ if (isSearch) {
+ this.page.pageNow = 1
}
const data = {
typeId: this.dataSourceTypeId,
pageSize: this.page.pageSize,
currentPage: this.page.pageNow,
- name: this.searchName
- };
+ name: this.searchName,
+ }
- if(data.typeId == 'null'){
- delete data.typeId;
+ if (data.typeId == 'null') {
+ delete data.typeId
}
- getDataSourceList(
- {
- ...data
- }).then(result=>{
- this.tableLoading = false;
- this.pageDatalist = result.queryList;
- this.page.totalSize = result.totalPage;
- });
+ getDataSourceList({
+ ...data,
+ }).then((result) => {
+ this.tableLoading = false
+ this.pageDatalist = result.queryList
+ this.page.totalSize = result.totalPage
+ })
},
- getVersionListBySourceId(){
-
- getVersionListByDatasourceId(this.currentSourceData.id).then(result=>{
- this.currentVersionList = result.versions;
- this.currentVersionList.sort((a, b)=>{
- if(a.versionId > b.versionId){
- return -1;
+ getVersionListBySourceId() {
+ getVersionListByDatasourceId(this.currentSourceData.id).then((result) => {
+ this.currentVersionList = result.versions
+ this.currentVersionList.sort((a, b) => {
+ if (a.versionId > b.versionId) {
+ return -1
}
- if(a.versionId < b.versionId){
- return 1;
+ if (a.versionId < b.versionId) {
+ return 1
}
return 0
})
- let lastPulishIndex = Infinity;
+ let lastPulishIndex = Infinity
for (let index = 0; index < this.currentVersionList.length; index++) {
- const element = this.currentVersionList[index];
- if(lastPulishIndex < index){ //不能发布
- element.status = 2;
- }else{
- element.status = 0;
+ const element = this.currentVersionList[index]
+ if (lastPulishIndex < index) {
+ //不能发布
+ element.status = 2
+ } else {
+ element.status = 0
}
- if(this.currentSourceData.publishedVersionId == element.versionId){
- lastPulishIndex = index;
- element.status = 1;
+ if (this.currentSourceData.publishedVersionId == element.versionId) {
+ lastPulishIndex = index
+ element.status = 1
}
-
}
})
-
-
-
-
},
- openVersionList(row){
- this.currentSourceData = row;
- this.getVersionListBySourceId();
- this.showVersionList = true;
+ openVersionList(row) {
+ this.currentSourceData = row
+ this.getVersionListBySourceId()
+ this.showVersionList = true
},
- changePage(value){
- this.page.pageNow = value;
- this.searchList();
+ changePage(value) {
+ this.page.pageNow = value
+ this.searchList()
},
watch(data) {
- this.actionType = this.$t('message.linkis.datasource.watch');
- this.showDataSource = true;
- this.currentSourceData.versionId = data.versionId;
- this.currentStep = 1;
+ this.actionType = this.$t('message.linkis.datasource.watch')
+ this.showDataSource = true
+ this.currentSourceData.versionId = data.versionId
+ this.currentStep = 1
},
modify(data) {
- this.actionType = this.$t('message.linkis.edit');
- this.showDataSource = true;
- this.currentSourceData = data;
- this.currentStep = 1;
+ this.actionType = this.$t('message.linkis.edit')
+ this.showDataSource = true
+ this.currentSourceData = data
+ this.currentStep = 1
},
- createDatasource(){
- this.currentStep = 0;
- this.currentSourceData = null;
- this.actionType = this.$t('message.linkis.create');
- this.showDataSource = true;
+ createDatasource() {
+ this.currentStep = 0
+ this.currentSourceData = null
+ this.actionType = this.$t('message.linkis.create')
+ this.showDataSource = true
},
- onSelect(item){
- this.currentSourceData = {dataSourceTypeId: item.id};
- this.currentStep = 1;
+ onSelect(item) {
+ this.currentSourceData = { dataSourceTypeId: item.id }
+ this.currentStep = 1
},
- stepChange(step){
-
- this.currentStep += step;
- if(this.currentStep<0){
- this.currentStep = 0;
- }else if(this.currentStep>1){
- this.currentStep = 1;
+ stepChange(step) {
+ this.currentStep += step
+ if (this.currentStep < 0) {
+ this.currentStep = 0
+ } else if (this.currentStep > 1) {
+ this.currentStep = 1
}
-
},
- tranceFormData(data){
- const formData = new FormData();
+ tranceFormData(data) {
+ const formData = new FormData()
Object.keys(data).forEach((key) => {
- if(typeof data[key] === 'object'){
- formData.append(key, JSON.stringify(data[key]));
- }else {
- formData.append(key, data[key]);
+ if (typeof data[key] === 'object') {
+ formData.append(key, JSON.stringify(data[key]))
+ } else {
+ formData.append(key, data[key])
}
-
- });
- return formData;
+ })
+ return formData
},
isEqual(obj1, obj2) {
- const isObject = (obj)=> {
+ const isObject = (obj) => {
return typeof obj === 'object' && obj !== null
}
if (!isObject(obj1) || !isObject(obj2)) {
@@ -471,143 +568,166 @@ export default {
// 否则全相等
return true
},
- onSubmit(){
- this.$refs.datasourceForm.fApi.submit((formData)=>{
-
- const realFormData = {};
- FORM_KEYS.forEach(key=>{
- realFormData[key] = formData[key];
- delete formData[key];
+ onSubmit() {
+ this.$refs.datasourceForm.fApi.submit((formData) => {
+ const realFormData = {}
+ FORM_KEYS.forEach((key) => {
+ realFormData[key] = formData[key]
+ delete formData[key]
})
- realFormData.connectParams = formData;
- realFormData.createSystem = "Linkis";
- realFormData.dataSourceTypeId = this.currentSourceData.dataSourceTypeId;
-
-
-
-
-
- let postDataSource = createDataSource;
- let commentMsg = this.$t('message.linkis.datasource.initVersion');
- if(!this.currentSourceData.id){ //新增数据源
- postDataSource = createDataSource;
- }else{
- postDataSource = updateDataSource;
- commentMsg = this.$t('message.linkis.datasource.updateVersion');
+ realFormData.connectParams = formData
+ realFormData.createSystem = 'Linkis'
+ realFormData.dataSourceTypeId = this.currentSourceData.dataSourceTypeId
+
+ let postDataSource = createDataSource
+ let commentMsg = this.$t('message.linkis.datasource.initVersion')
+ if (!this.currentSourceData.id) {
+ //新增数据源
+ postDataSource = createDataSource
+ } else {
+ postDataSource = updateDataSource
+ commentMsg = this.$t('message.linkis.datasource.updateVersion')
}
- this.loadingForm = true;
- postDataSource(realFormData, this.currentSourceData.id).then(data=>{
- this.loadingForm = false;
- // if(连接信息有变化)
-
- const sourceId = data.id || data.insertId || data.updateId;
-
- console.log()
- if(!this.currentSourceData.id || !this.isEqual(this.preProcessData(this.$refs.datasourceForm.sourceConnectData), formData)){
- if(this.$refs.datasourceForm.file){
- formData.file = this.$refs.datasourceForm.file;
- saveConnectParamsForm(sourceId, formData, commentMsg).then(()=>{
- this.$Message.success('Success');
- this.searchList();
- });
- this.showDataSource = false;
- }else {
- saveConnectParams(sourceId, formData, commentMsg).then(()=>{
- this.$Message.success('Success');
- this.searchList();
- });
- this.showDataSource = false;
+ this.loadingForm = true
+ postDataSource(realFormData, this.currentSourceData.id)
+ .then((data) => {
+ this.loadingForm = false
+ // if(连接信息有变化)
+
+ const sourceId = data.id || data.insertId || data.updateId
+
+ console.log()
+ if (
+ !this.currentSourceData.id ||
+ !this.isEqual(
+ this.preProcessData(
+ this.$refs.datasourceForm.sourceConnectData
+ ),
+ formData
+ )
+ ) {
+ // if(this.$refs.datasourceForm.file){
+ // formData.file = this.$refs.datasourceForm.file;
+ // saveConnectParamsForm(sourceId, formData, commentMsg).then(()=>{
+ // this.$Message.success('Success');
+ // this.searchList();
+ // });
+ // this.showDataSource = false;
+ // }else {
+
+ // }
+ saveConnectParams(sourceId, formData, commentMsg).then(() => {
+ this.$Message.success('Success')
+ this.searchList()
+ })
+ this.showDataSource = false
+ } else {
+ this.$Message.success('Success')
+ this.searchList()
+ this.showDataSource = false
}
- }else {
- this.$Message.success('Success');
- this.searchList();
- this.showDataSource = false;
- }
-
- }).catch(()=>{
- this.loadingForm = false;
- })
+ })
+ .catch(() => {
+ this.loadingForm = false
+ })
})
},
- preProcessData(data){
- Object.keys(data).forEach(item=>{
+ preProcessData(data) {
+ Object.keys(data).forEach((item) => {
let obj = data[item]
- if(typeof obj === 'undefined' || obj === null || obj === '') {
- delete data[item];
+ if (typeof obj === 'undefined' || obj === null || obj === '') {
+ delete data[item]
}
})
- return data;
+ return data
},
- onConnectTestFromVersion(data){
- this.loadingVersionList = true;
- getDataSourceByIdAndVersion(data.datasourceId, data.versionId).then(data=>{
- connect(data.info).then(()=>{
- this.loadingVersionList = false;
- this.$Message.success('Connect Success');
-
- }).catch(()=>{
- this.loadingVersionList = false;
- })
- })
+ onConnectTestFromVersion(data) {
+ this.loadingVersionList = true
+ getDataSourceByIdAndVersion(data.datasourceId, data.versionId).then(
+ (data) => {
+ connect(data.info)
+ .then(() => {
+ this.loadingVersionList = false
+ this.$Message.success('Connect Success')
+ })
+ .catch(() => {
+ this.loadingVersionList = false
+ })
+ }
+ )
},
- onConnectTest(data){
- this.currentSourceData = data;
- this.tableLoading = true;
- getDataSourceByIdAndVersion(this.currentSourceData.id, this.currentSourceData.versionId).then(data=>{
- connect(data.info).then(()=>{
- this.tableLoading = false;
- this.$Message.success('Connect Success');
-
- }).catch(()=>{
- this.tableLoading = false;
+ onConnectTest(data) {
+ this.currentSourceData = data
+ this.tableLoading = true
+ getDataSourceByIdAndVersion(
+ this.currentSourceData.id,
+ this.currentSourceData.versionId
+ )
+ .then((data) => {
+ connect(data.info)
+ .then(() => {
+ this.tableLoading = false
+ this.$Message.success('Connect Success')
+ })
+ .catch(() => {
+ this.tableLoading = false
+ })
+ })
+ .catch(() => {
+ this.tableLoading = false
})
- }).catch(()=>{
- this.tableLoading = false;
- })
-
},
- onConnectFormTest(){
- this.$refs.datasourceForm.fApi.submit(()=>{
- this.loadingForm = true;
- this.$refs.datasourceForm.fApi.submit((formData)=>{
- const realFormData = {};
- FORM_KEYS.forEach(key=>{
- realFormData[key] = formData[key];
- delete formData[key];
+ onConnectFormTest() {
+ this.$refs.datasourceForm.fApi.submit(() => {
+ this.loadingForm = true
+ this.$refs.datasourceForm.fApi.submit((formData) => {
+ const realFormData = {}
+ FORM_KEYS.forEach((key) => {
+ realFormData[key] = formData[key]
+ delete formData[key]
})
- realFormData.connectParams = formData;
- realFormData.createSystem = "Linkis";
- realFormData.dataSourceTypeId = this.currentSourceData.dataSourceTypeId;
- realFormData.dataSourceEnvId = parseInt(realFormData.dataSourceEnvId);
- connect(realFormData).then(()=>{
- this.loadingForm = false;
- this.$Message.success('Connect Success');
- }).catch(()=>{this.loadingForm = false;})
+ realFormData.connectParams = formData
+ realFormData.createSystem = 'Linkis'
+ realFormData.dataSourceTypeId =
+ this.currentSourceData.dataSourceTypeId
+ realFormData.dataSourceEnvId = parseInt(realFormData.dataSourceEnvId)
+ connect(realFormData)
+ .then(() => {
+ this.loadingForm = false
+ this.$Message.success('Connect Success')
+ })
+ .catch(() => {
+ this.loadingForm = false
+ })
})
})
-
},
- onPublish(data){
- this.loadingVersionList = true;
- publish(data.datasourceId, data.versionId).then(()=>{
- this.showVersionList = false;
- this.loadingVersionList = false;
- this.$Message.success('Publish Success');
- this.searchList();
+ onPublish(data) {
+ this.loadingVersionList = true
+ publish(data.datasourceId, data.versionId).then(() => {
+ this.showVersionList = false
+ this.loadingVersionList = false
+ this.$Message.success('Publish Success')
+ this.searchList()
})
},
- onRollback(data){
- this.showVersionList = false;
- const sourceId = data.id || data.datasourceId || data.updateId;
-
- saveConnectParams(sourceId, data.connectParams, this.$t('message.linkis.datasource.commentValue', {text: data.versionId})).then(()=>{
- this.$Message.success('onRollback Success');
- this.searchList();
- });
- }
-
- }
+ onRollback(data) {
+ this.showVersionList = false
+ const sourceId = data.id || data.datasourceId || data.updateId
+
+ saveConnectParams(
+ sourceId,
+ data.connectParams,
+ this.$t('message.linkis.datasource.commentValue', {
+ text: data.versionId,
+ })
+ ).then(() => {
+ this.$Message.success('onRollback Success')
+ this.searchList()
+ })
+ },
+ },
}
</script>
<style lang="scss" src="./index.scss" scoped></style>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org