This commit is contained in:
rewerma
2019-07-13 18:03:28 +08:00
parent 40d2a8c6cc
commit 4efc0f6078
8 changed files with 215 additions and 31 deletions

View File

@@ -0,0 +1,78 @@
<template>
<div class="app-container">
<el-table
v-loading="listLoading"
:data="list"
element-loading-text="Loading"
border
fit
highlight-current-row
>
<el-table-column label="实例名称" min-width="200" align="center">
<template slot-scope="scope">
{{ scope.row.name }}
</template>
</el-table-column>
<el-table-column label="运行节点" min-width="200" align="center">
<template slot-scope="scope">
<span>{{ scope.row.nodeIp }}</span>
</template>
</el-table-column>
<el-table-column label="修改时间" min-width="200" align="center">
<template slot-scope="scope">
{{ scope.row.modifiedTime }}
</template>
</el-table-column>
<el-table-column align="center" prop="created_at" label="操作" min-width="150">
<template slot-scope="scope">
<el-dropdown trigger="click">
<el-button type="primary" size="mini">
操作<i class="el-icon-arrow-down el-icon--right" />
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="handleUpdate(scope.row)">修改节点</el-dropdown-item>
<el-dropdown-item @click.native="handleDelete(scope.row)">删除节点</el-dropdown-item>
<el-dropdown-item @click.native="handleStart(scope.row)">启动服务</el-dropdown-item>
<el-dropdown-item @click.native="handleStop(scope.row)">停止服务</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import { getCanalInstances } from '@/api/canalInstance'
export default {
filters: {
statusFilter(status) {
const statusMap = {
published: 'success',
draft: 'gray',
deleted: 'danger'
}
return statusMap[status]
}
},
data() {
return {
list: null,
listLoading: true
}
},
created() {
this.fetchData()
},
methods: {
fetchData() {
this.listLoading = true
getCanalInstances().then(res => {
this.list = res.data
this.listLoading = false
})
}
}
}
</script>

View File

@@ -0,0 +1,92 @@
<template>
<div>
<el-form ref="form" :model="form">
<div style="padding-left: 10px;padding-top: 20px;">
<el-form-item>
{{ form.name }}&nbsp;&nbsp;&nbsp;&nbsp;
<el-button type="primary" @click="onSubmit">修改</el-button>
<el-button @click="onCancel">重置</el-button>
</el-form-item>
</div>
<editor v-model="form.content" lang="properties" theme="chrome" width="100%" :height="800" @init="editorInit" />
</el-form>
</div>
</template>
<script>
import { getCanalConfig, updateCanalConfig } from '@/api/canalConfig'
export default {
components: {
editor: require('vue2-ace-editor')
},
data() {
return {
form: {
id: null,
name: '',
content: ''
}
}
},
created() {
this.loadCanalConfig()
},
methods: {
editorInit() {
require('brace/ext/language_tools')
require('brace/mode/html')
require('brace/mode/yaml')
require('brace/mode/properties')
require('brace/mode/javascript')
require('brace/mode/less')
require('brace/theme/chrome')
require('brace/snippets/javascript')
},
loadCanalConfig() {
getCanalConfig().then(response => {
const data = response.data
this.form.id = data.id
this.form.name = data.name
this.form.content = data.content
})
},
onSubmit() {
this.$confirm(
'修改Canal主配置可能会导致Server重启,是否继续?',
'确定修改',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
updateCanalConfig(this.form).then(response => {
if (response.data === 'success') {
this.$message({
message: '修改成功',
type: 'success'
})
this.loadCanalConfig()
} else {
this.$message({
message: '修改失败',
type: 'error'
})
}
})
})
},
onCancel() {
this.loadCanalConfig()
}
}
}
</script>
<style scoped>
.line{
text-align: center;
}
</style>