|
@@ -1,5 +1,12 @@
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
+ <div class="filter-container">
|
|
|
+ <el-input v-model="listQuery.name" placeholder="实例名称" style="width: 200px;" class="filter-item" />
|
|
|
+ <el-button class="filter-item" type="primary" icon="el-icon-search" plain @click="fetchData()">查询</el-button>
|
|
|
+
|
|
|
+ <el-button class="filter-item" type="primary" @click="handleCreate()">新建实例</el-button>
|
|
|
+ <el-button class="filter-item" type="info" @click="fetchData()">刷新列表</el-button>
|
|
|
+ </div>
|
|
|
<el-table
|
|
|
v-loading="listLoading"
|
|
|
:data="list"
|
|
@@ -30,8 +37,8 @@
|
|
|
操作<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="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>
|
|
@@ -43,7 +50,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getCanalInstances } from '@/api/canalInstance'
|
|
|
+import { getCanalInstances, deleteCanalInstance, startInstance, stopNodeServer } from '@/api/canalInstance'
|
|
|
|
|
|
export default {
|
|
|
filters: {
|
|
@@ -59,7 +66,10 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
list: null,
|
|
|
- listLoading: true
|
|
|
+ listLoading: true,
|
|
|
+ listQuery: {
|
|
|
+ name: ''
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -68,10 +78,90 @@ export default {
|
|
|
methods: {
|
|
|
fetchData() {
|
|
|
this.listLoading = true
|
|
|
- getCanalInstances().then(res => {
|
|
|
+ getCanalInstances(this.listQuery).then(res => {
|
|
|
this.list = res.data
|
|
|
this.listLoading = false
|
|
|
})
|
|
|
+ },
|
|
|
+ handleCreate() {
|
|
|
+ this.$router.push('/canalServer/canalInstance/add')
|
|
|
+ },
|
|
|
+ handleUpdate(row) {
|
|
|
+ this.$router.push('/canalServer/canalInstance/modify?id=' + row.id)
|
|
|
+ },
|
|
|
+ handleDelete(row) {
|
|
|
+ this.$confirm('删除实例配置会导致Canal实例停止', '确定删除实例信息', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ deleteCanalInstance(row.id).then((res) => {
|
|
|
+ if (res.data === 'success') {
|
|
|
+ this.fetchData()
|
|
|
+ this.$message({
|
|
|
+ message: '删除实例信息成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: '删除实例点信息失败',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleStart(row) {
|
|
|
+ if (row.nodeId !== null) {
|
|
|
+ this.$message({ message: '当前实例不是停止状态,无法启动', type: 'error' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$confirm('启动Canal Instance: ' + row.name, '确定启动实例服务', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ startInstance(row.id).then((res) => {
|
|
|
+ if (res.data) {
|
|
|
+ this.fetchData()
|
|
|
+ this.$message({
|
|
|
+ message: '启动成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: '启动实例服务出现异常',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleStop(row) {
|
|
|
+ if (row.nodeId === null) {
|
|
|
+ this.$message({ message: '当前实例不是启动状态,无法停止', type: 'error' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$confirm('停止Canal Instance: ' + row.name, '确定停止实例服务', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ stopNodeServer(row.id, row.nodeId).then((res) => {
|
|
|
+ if (res.data) {
|
|
|
+ this.fetchData()
|
|
|
+ this.$message({
|
|
|
+ message: '停止成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: '停止实例服务出现异常',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|