Commit 668eec26 authored by 黎博's avatar 黎博

update

parent 2cb6d6a4
......@@ -134,3 +134,12 @@ export function syncMq(data) {
data
})
}
// 清空redis缓存
export function flushRedis(data) {
return request({
url: '/k8s/redis/flush',
method: 'post',
data
})
}
......@@ -68,6 +68,7 @@ Vue.prototype.$echarts = echarts
Vue.prototype.$message = Message
Vue.prototype.$loading = Loading
Vue.prototype.$messageBox = MessageBox
Vue.prototype.$confirm = MessageBox.confirm
Vue.prototype.$bus = bus
// axios.defaults.baseURL = 'https://qa-platform-pre.liangkebang.net'
// axios.defaults.baseURL = 'http://localhost:8082'
......
......@@ -75,6 +75,8 @@ export default {
this.$router.push({
path: `/docker/env`
})
// 强制刷新整个页面
this.$router.go(0)
},
handleSyncMysql() {
this.$router.push('/effect/database')
......
......@@ -14,7 +14,7 @@
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="syncDb">同步线上MySQL</el-dropdown-item>
<el-dropdown-item @click.native="syncMq">同步线上MQ</el-dropdown-item>
<el-dropdown-item @click.native="handleMqSync">同步线上MQ</el-dropdown-item>
<el-dropdown-item @click.native="clearRedis">清理Redis缓存</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
......@@ -295,6 +295,8 @@
<el-button type="primary" @click="updateService()">确 定</el-button>
</span>
</el-dialog>
<!-- 详细信息对话框 -->
<el-dialog :visible.sync="centerDialogVisible" title="详细信息" height="500px" center>
<div class="editor-container">
<json-viewer :expand-depth=3 :value='detailValue' style="margin-top:-25px"></json-viewer>
......@@ -304,6 +306,22 @@
<el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
</span>
</el-dialog>
<!-- 同步MQ对话框 -->
<el-dialog title="同步MQ" :visible.sync="mqSyncDialogVisible" width="50%" :before-close="handleClose">
<el-form ref="mqDataForm" label-position="left" label-width="130px" style="width: 95%; margin-left:20px;">
<el-form-item label="Namespace名称">
<el-input v-model="namespace" :disabled="true" />
</el-form-item>
<el-form-item label="服务地址">
<el-input v-model="mqUrl" :disabled="true" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="mqSyncDialogVisible = false">取消</el-button>
<el-button type="primary" @click="syncMQ()">开始同步</el-button>
</span>
</el-dialog>
</div>
</template>
......@@ -318,7 +336,9 @@ import {
serviceRedeploy,
serviceUpdate,
serviceDelete,
getDockerProjectType
getDockerProjectType,
syncMq,
flushRedis
} from '@/api/k8s'
export default {
data() {
......@@ -352,7 +372,16 @@ export default {
mysqlName: '',
// 当前选中的项目名
serviceName: '',
updateServiceParams: {}
updateServiceParams: {},
mqSyncDialogVisible: false,
mqUrl: '',
mqDataForm: {},
loadingOptions: {
text: '加载中...',
lock: true,
spinner: 'el-icon-loading',
background: 'rgba(0,0,0,0.7)'
}
}
},
created() {
......@@ -379,9 +408,11 @@ export default {
},
// 获取服务列表
getServiceList() {
const tLoading = this.$loading.service(this.loadingOptions)
getServiceList({ namespace: this.namespace }).then((resp) => {
const serviceList = resp.data.data
this.array2Object(serviceList)
tLoading.close()
})
},
// 刷新,重新获取服务列表
......@@ -418,11 +449,56 @@ export default {
)
},
// 同步数据库
syncDb() {},
// 通过Mq
syncMq() {},
syncDb() {
this.$router.push('/effect/database')
},
// 打开MQ同步对话框
handleMqSync() {
getServiceDetail({
namespace: this.namespace,
serviceType: 'base',
serviceName: 'rabbitmq'
}).then((resp) => {
if (resp.data.data != null) {
this.mqUrl =
resp.data.data.lanIp + ':' + resp.data.data.portMappings[1].nodePort
} else {
return this.$message.error('当前环境没有MQ!')
}
})
this.mqSyncDialogVisible = true
},
// 同步MQ
syncMQ() {
var formdata = new FormData()
formdata.set('host', this.mqUrl)
syncMq(formdata).then((resp) => {
if (resp.data.data === true) {
this.mqSyncDialogVisible = false
return this.$message.success('同步成功!')
} else {
return this.$message.error('同步失败!')
}
})
},
// 清空redis
clearRedis() {},
clearRedis() {
this.$confirm(`此操作将清空${this.namespace}环境所有Redis缓存, 是否继续?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var formdata = new FormData()
formdata.set('namespace', this.namespace)
flushRedis(formdata).then((resp) => {
if (resp.data.data) {
return this.$message.success(resp.data.msg)
} else {
return this.$message.error(resp.data.msg)
}
})
})
},
// 获取服务详情
getServiceDetails(service) {
getServiceDetail({
......@@ -442,10 +518,10 @@ export default {
serviceRedeploy(formdata).then((resp) => {
if (resp.data.data === true) {
this.getServiceList()
return this.$message.success('重置成功!')
return this.$message.success(`服务${service.serviceName}重置成功!`)
} else {
this.getServiceList()
return this.$message.error('重置失败!')
return this.$message.error(`服务${service.serviceName}重置失败!`)
}
})
},
......@@ -484,10 +560,11 @@ export default {
},
// 调用接口更新服务
updateService() {
this.updateServiceParams['image'] = 'qa-test/' + this.serviceName + ':' + this.tagName
this.updateServiceParams['image'] =
'qa-test/' + this.serviceName + ':' + this.tagName
serviceUpdate(this.updateServiceParams).then((resp) => {
if (resp.data.data === true) {
this.getServiceList()
// this.getServiceList()
this.updateDialogVisible = false
return this.$message.success('更新成功!')
} else {
......@@ -497,7 +574,7 @@ export default {
},
// 删除服务
deleteService(service) {
this.$messageBox(
this.$confirm(
`此操作将删除 ${service.serviceName} 服务, 是否继续?`,
'提示',
{
......
......@@ -10,7 +10,7 @@
<el-option v-for="item in avtiveOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="getProjectList">搜索</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">添加</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" v-permission="('docker:proconfig:add')" @click="handleCreate">添加</el-button>
</div>
<!-- 表格 -->
......@@ -82,7 +82,7 @@
<el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="primary" size="mini" v-permission="('docker:proconfig:edit')" @click="handleUpdate(scope.row)">编辑</el-button>
</template>
</el-table-column>
</el-table>
......
......@@ -10,8 +10,8 @@
<el-input type="password" @keyup.enter.native="login" v-model="loginForm.password" placeholder="请输入用户名" prefix-icon="el-icon-unlock" show-password></el-input>
</el-form-item>
<el-form-item class="input-style" prop="namespace">
<el-select v-model="loginForm.namespace" placeholder="请选择环境" @change="handleSelectChange" style="width: 100%;">
<el-option v-for="item in nsOptions" :key="item.key" :label="item.desc" :value="item.key"></el-option>
<el-select v-model="loginForm.namespace" filterable placeholder="请选择环境" @change="handleSelectChange" style="width: 100%;">
<el-option v-for="item in nsOptions" :key="item.name" :label="item.name" :value="item.name"></el-option>
</el-select>
</el-form-item>
<el-form-item class="input-style">
......@@ -23,7 +23,7 @@
</template>
<script>
import { getNamespaceList } from '@/api/getXyqbData/'
import { getNamespaceList } from '@/api/k8s'
import { login } from '@/api/Login/'
export default {
data() {
......@@ -73,7 +73,7 @@ export default {
})
},
getNamespaceList() {
getNamespaceList().then((resp) => {
getNamespaceList({env: 'all'}).then((resp) => {
this.nsOptions = resp.data.data
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment