|
@@ -183,7 +183,8 @@
|
|
testLoading: false,
|
|
testLoading: false,
|
|
showPrincipal: true,
|
|
showPrincipal: true,
|
|
showdDatabase: false,
|
|
showdDatabase: false,
|
|
- isShowPrincipal:true
|
|
|
|
|
|
+ isShowPrincipal:true,
|
|
|
|
+ prePortMapper:{}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
props: {
|
|
props: {
|
|
@@ -221,7 +222,7 @@
|
|
host: this.host,
|
|
host: this.host,
|
|
port: this.port,
|
|
port: this.port,
|
|
database: this.database,
|
|
database: this.database,
|
|
- principal:this.principal,
|
|
|
|
|
|
+ principal: this.principal,
|
|
userName: this.userName,
|
|
userName: this.userName,
|
|
password: this.password,
|
|
password: this.password,
|
|
other: this.other
|
|
other: this.other
|
|
@@ -317,13 +318,19 @@
|
|
/**
|
|
/**
|
|
* Get modified data
|
|
* Get modified data
|
|
*/
|
|
*/
|
|
- _getEditDatasource () {
|
|
|
|
- this.store.dispatch('datasource/getEditDatasource', { id: this.item.id }).then(res => {
|
|
|
|
|
|
+ _getEditDatasource() {
|
|
|
|
+ this.store.dispatch('datasource/getEditDatasource', {id: this.item.id}).then(res => {
|
|
this.type = res.type
|
|
this.type = res.type
|
|
this.name = res.name
|
|
this.name = res.name
|
|
this.note = res.note
|
|
this.note = res.note
|
|
this.host = res.host
|
|
this.host = res.host
|
|
- this.port = res.port
|
|
|
|
|
|
+
|
|
|
|
+ //When in Editpage, Prevent default value overwrite backfill value
|
|
|
|
+ let that = this;
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.port = res.port
|
|
|
|
+ },0)
|
|
|
|
+
|
|
this.principal = res.principal
|
|
this.principal = res.principal
|
|
this.database = res.database
|
|
this.database = res.database
|
|
this.userName = res.userName
|
|
this.userName = res.userName
|
|
@@ -332,7 +339,60 @@
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
this.$message.error(e.msg || '')
|
|
this.$message.error(e.msg || '')
|
|
})
|
|
})
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * Set default port for each type.
|
|
|
|
+ */
|
|
|
|
+ _setDefaultValues(value) {
|
|
|
|
+
|
|
|
|
+ //Default type is MYSQL
|
|
|
|
+ let type = this.type || 'MYSQL'
|
|
|
|
+
|
|
|
|
+ let defaultPort = this._getDefaultPort(type)
|
|
|
|
+
|
|
|
|
+ //Backfill the previous input from memcache
|
|
|
|
+ let mapperPort = this.prePortMapper[type]
|
|
|
|
+
|
|
|
|
+ this.port = mapperPort || defaultPort
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Get default port by type
|
|
|
|
+ */
|
|
|
|
+ _getDefaultPort(type) {
|
|
|
|
+ var defaultPort = ''
|
|
|
|
+ switch (type) {
|
|
|
|
+ case 'MYSQL':
|
|
|
|
+ defaultPort = '3306'
|
|
|
|
+ break
|
|
|
|
+ case 'POSTGRESQL':
|
|
|
|
+ defaultPort = '5432'
|
|
|
|
+ break
|
|
|
|
+ case 'HIVE':
|
|
|
|
+ defaultPort = '10000'
|
|
|
|
+ break
|
|
|
|
+ case 'SPARK':
|
|
|
|
+ defaultPort = '10015'
|
|
|
|
+ break
|
|
|
|
+ case 'CLICKHOUSE':
|
|
|
|
+ defaultPort = '8123'
|
|
|
|
+ break
|
|
|
|
+ case 'ORACLE':
|
|
|
|
+ defaultPort = '1521'
|
|
|
|
+ break
|
|
|
|
+ case 'SQLSERVER':
|
|
|
|
+ defaultPort = '1433'
|
|
|
|
+ break
|
|
|
|
+ case 'DB2':
|
|
|
|
+ defaultPort = '50000'
|
|
|
|
+ break
|
|
|
|
+ default:
|
|
|
|
+ break
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return defaultPort
|
|
|
|
+ },
|
|
},
|
|
},
|
|
created () {
|
|
created () {
|
|
// Backfill
|
|
// Backfill
|
|
@@ -340,6 +400,8 @@
|
|
this._getEditDatasource()
|
|
this._getEditDatasource()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this._setDefaultValues()
|
|
|
|
+
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
type(value){
|
|
type(value){
|
|
@@ -348,6 +410,10 @@
|
|
} else {
|
|
} else {
|
|
this.showdDatabase = false;
|
|
this.showdDatabase = false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //Set default port for each type datasource
|
|
|
|
+ this._setDefaultValues(value)
|
|
|
|
+
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
this.store.dispatch('datasource/getKerberosStartupState').then(res => {
|
|
this.store.dispatch('datasource/getKerberosStartupState').then(res => {
|
|
this.isShowPrincipal=res
|
|
this.isShowPrincipal=res
|
|
@@ -361,6 +427,13 @@
|
|
reject(e)
|
|
reject(e)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * Cache the previous input port for each type datasource
|
|
|
|
+ * @param value
|
|
|
|
+ */
|
|
|
|
+ port(value){
|
|
|
|
+ this.prePortMapper[this.type] = value
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|