sharding-scaling-ui fix details (#4399)
* feature[sharding-ui-frontend]:Data migration list and form form function addition #3848
* refactor:[shardingsphere-ui-frontend]Update directory structure #3848
* [shardingsphere-ui-frontend]Basic development of progress bar page #3848
* feature[shardingsphere-ui-frontend]Local interface test #3848
* feature[shardingsphere-ui-frontend]Add interface automatic request logic judgment #3848
* fix[shardingsphere-ui-frontend]Logical error calculating percentage #3848
* refactor[shardingsphere-ui-frontend]Remove host configuration #3848
* feature[shardingsphere-ui-frontend]Add server configuration interaction #4234
* refactor[shardingsphere-ui-frontend]Remove host configuration #4234
* feature[shardingsphere-ui-frontend]User sets interactive add for the first time #4234
* docs[shardingsphere-ui-frontend]Update API documentation #4234
* fix[shardingsphere-ui-frontend]Fix the first login assignment problem #4234
* fix[shardingsphere-ui-frontend]Initialization assignment error #4234
* fix[shardingsphere-ui-frontend]Fix dynamic update of progress value #4234
* fix[shardingsphere-ui-frontend] Serviceurl replacement #4234
* fix[shardingsphere-ui-frontend]Progress dynamic update #4234
* fix[shardingsphere-ui-frontend]Host delete configuration #4234
diff --git a/shardingsphere-ui-frontend/src/lang/en-US.js b/shardingsphere-ui-frontend/src/lang/en-US.js
index dad08e5..b6364e8 100644
--- a/shardingsphere-ui-frontend/src/lang/en-US.js
+++ b/shardingsphere-ui-frontend/src/lang/en-US.js
@@ -172,7 +172,8 @@
},
rules: {
source: 'Please select the source of the registration center',
- target: 'Please select a target'
+ target: 'Please select a target',
+ serviceUrl: 'ServiceUrl must fill'
},
notify: {
title: 'Prompt',
diff --git a/shardingsphere-ui-frontend/src/utils/api.js b/shardingsphere-ui-frontend/src/utils/api.js
index 41a242b..d7a5a1b 100644
--- a/shardingsphere-ui-frontend/src/utils/api.js
+++ b/shardingsphere-ui-frontend/src/utils/api.js
@@ -50,6 +50,10 @@
location.href = '#/login'
return
}
+ if (data.errorCode === 400) {
+ resolve(data)
+ return
+ }
Message({
message: data.errorMsg,
type: 'error',
diff --git a/shardingsphere-ui-frontend/src/views/data-scaling/module/index.vue b/shardingsphere-ui-frontend/src/views/data-scaling/module/index.vue
index d7c7cac..618007a 100644
--- a/shardingsphere-ui-frontend/src/views/data-scaling/module/index.vue
+++ b/shardingsphere-ui-frontend/src/views/data-scaling/module/index.vue
@@ -279,7 +279,7 @@
</el-col>
<el-col :span="2"><div>History</div></el-col>
<el-col :span="6" class="collapse-progress">
- <el-progress :stroke-width="10" :percentage="getPercentage(syncTaskProgress.historySyncTaskProgress)"></el-progress>
+ <el-progress :stroke-width="10" :percentage="percentageComputed"></el-progress>
</el-col>
</el-row>
</template>
@@ -336,9 +336,6 @@
<el-form-item label="Service Name:">
<el-input v-model="serviceForm.serviceName" :placeholder="$t('dataScaling.serviceDialog.serviceName')"/>
</el-form-item>
- <el-form-item label="Service Type:">
- <el-input v-model="serviceForm.serviceType" :placeholder="$t('dataScaling.serviceDialog.serviceType')"/>
- </el-form-item>
<el-form-item label="Service Url:">
<el-input v-model="serviceForm.serviceUrl" :placeholder="$t('dataScaling.serviceDialog.serviceUrl')"/>
</el-form-item>
@@ -360,6 +357,7 @@
import ECharts from 'vue-echarts'
import moment from 'moment'
import clone from 'lodash/clone'
+import isEmpty from 'lodash/isEmpty'
import 'echarts-liquidfill'
import API from '../api'
@@ -408,7 +406,7 @@
RuleVisible: false,
serviceForm: {
serviceName: '',
- serviceType: '',
+ serviceType: 'ShardingScaling',
serviceUrl: ''
},
schemaData: [],
@@ -524,6 +522,21 @@
null,
'\t'
)
+ },
+ percentageComputed() {
+ const arr = this.syncTaskProgress.historySyncTaskProgress
+ if (!arr) return
+ let sumEstimatedRows = 0
+ let sumSyncedRows = 0
+ for (const v of arr) {
+ sumEstimatedRows += v.estimatedRows
+ sumSyncedRows += v.syncedRows
+ }
+ let res = 0
+ if (sumEstimatedRows) {
+ res = sumSyncedRows / sumEstimatedRows
+ }
+ return nDecimal(res * 100, 0)
}
},
created() {
@@ -534,25 +547,39 @@
this.serverDialogVisible = true
},
setServer() {
- API.postJobServer(this.serviceForm).then(res => {
- this.$notify({
- title: this.$t('dataScaling').notify.title,
- message: 'Set up successfully!',
- type: 'success'
+ if (this.serviceForm.serviceUrl) {
+ API.postJobServer(this.serviceForm).then(res => {
+ this.$notify({
+ title: this.$t('dataScaling').notify.title,
+ message: 'Set up successfully!',
+ type: 'success'
+ })
+ this.serverDialogVisible = false
+ }, () => {
+ this.$notify({
+ title: this.$t('dataScaling').notify.title,
+ message: 'Setup failed!',
+ type: 'error'
+ })
})
- this.serverDialogVisible = false
- }, () => {
+ } else {
this.$notify({
title: this.$t('dataScaling').notify.title,
- message: 'Setup failed!',
+ message: this.$t('dataScaling').rules.serviceUrl,
type: 'error'
})
- })
+ }
},
getJobServer() {
API.getJobServer().then(res => {
- if (res) {
- this.serviceForm = res
+ const { model } = res
+ if (model) {
+ const { serviceName, serviceType, serviceUrl } = model
+ this.serviceForm = {
+ serviceName,
+ serviceType,
+ serviceUrl
+ }
this.getJobList()
} else {
this.serverDialogVisible = true
@@ -652,7 +679,16 @@
getJobProgress(row) {
const { jobId, status } = row
API.getJobProgress(jobId).then(res => {
- this.progressRow = res.model
+ const { model } = res
+ this.progressRow = model
+ if (!isEmpty(this.syncTaskProgress)) {
+ for (const v of model.syncTaskProgress) {
+ if (v.id === this.syncTaskProgress.id) {
+ this.syncTaskProgress = v
+ }
+ }
+ }
+ clearTimeout(timer)
if (status !== 'STOPPED') {
timer = setTimeout(() => {
this.getJobProgress(row)