Commit 12bbb7ea authored by 智勇's avatar 智勇

增加k8s conf

parent e88bd005
...@@ -32,17 +32,22 @@ ...@@ -32,17 +32,22 @@
<!-- <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" /> --> <!-- <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" /> -->
<el-dialog :title="dialogStatus" :visible.sync="dialogFormVisible"> <el-dialog :title="dialogStatus" :visible.sync="dialogFormVisible">
<el-alert
v-show="dialogStatus==='新建'"
style="margin-bottom:20px"
title="新建需要管理员权限"
type="warning"/>
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="90px" style="width: 90%; margin-left:40px;"> <el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="90px" style="width: 90%; margin-left:40px;">
<el-form-item label="Database" prop="dbname" > <el-form-item label="Database" prop="dbname" >
<el-input v-model="temp.dbname" style="width:100%"/> <el-input v-model="temp.dbname" :disabled="disabled" style="width:100%"/>
</el-form-item> </el-form-item>
<el-form :inline="true" :rules="rules" :model="temp" class="demo-form-inline" label-width="90px"> <el-form :inline="true" :rules="rules" :model="temp" class="demo-form-inline" label-width="90px">
<el-form-item label="Host" prop="ip"> <el-form-item label="Host" prop="ip">
<el-input v-model="temp.ip" placeholder="数据库同步环境IP" class="input-width"/> <el-input v-model="temp.ip" :disabled="disabled" placeholder="数据库同步环境IP" class="input-width"/>
</el-form-item> </el-form-item>
<el-form-item label="Port" prop="port"> <el-form-item label="Port" prop="port">
<el-input v-model="temp.port" placeholder="数据库同步环境端口" class="input-width"/> <el-input v-model="temp.port" :disabled="disabled" placeholder="数据库同步环境端口" class="input-width"/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-form :inline="true" :model="temp" class="demo-form-inline" label-width="90px"> <el-form :inline="true" :model="temp" class="demo-form-inline" label-width="90px">
...@@ -60,7 +65,7 @@ ...@@ -60,7 +65,7 @@
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">{{ $t('table.cancel') }}</el-button> <el-button @click="dialogFormVisible = false">{{ $t('table.cancel') }}</el-button>
<el-button v-permission="['admin']" type="primary" @click="createData()">{{ $t('table.confirm') }}</el-button> <el-button :disabled="disabled && dialogStatus==='新建'" type="primary" @click="createData()">{{ $t('table.confirm') }}</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -92,6 +97,7 @@ export default { ...@@ -92,6 +97,7 @@ export default {
return { return {
temp: { temp: {
}, },
disabled: undefined,
dialogFormVisible: false, dialogFormVisible: false,
dialogDeleteVisible: false, dialogDeleteVisible: false,
dialogStatus: '', dialogStatus: '',
...@@ -110,6 +116,7 @@ export default { ...@@ -110,6 +116,7 @@ export default {
}, },
created() { created() {
this.getConfig() this.getConfig()
this.disabled = !this.$store.getters.roles.includes('admin')
}, },
methods: { methods: {
getConfig() { getConfig() {
...@@ -133,6 +140,9 @@ export default { ...@@ -133,6 +140,9 @@ export default {
this.resetTemp() this.resetTemp()
this.dialogStatus = '新建' this.dialogStatus = '新建'
this.dialogFormVisible = true this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
}, },
createData() { createData() {
...@@ -156,6 +166,9 @@ export default { ...@@ -156,6 +166,9 @@ export default {
this.temp = Object.assign({}, row) // copy obj this.temp = Object.assign({}, row) // copy obj
this.dialogStatus = '编辑' this.dialogStatus = '编辑'
this.dialogFormVisible = true this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
}, },
handleDelete(row) { handleDelete(row) {
......
...@@ -21,11 +21,7 @@ ...@@ -21,11 +21,7 @@
size="medium" size="medium"
style="width: 100%;"> style="width: 100%;">
<el-table-column :label="$t('table.id')" prop="id" align="center" width="55"> <el-table-column label="ID" type="index" align="center" width="55"/>
<template slot-scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="服务名称" align="center" > <el-table-column label="服务名称" align="center" >
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -33,33 +29,21 @@ ...@@ -33,33 +29,21 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="服务描述" align="center"> <el-table-column label="服务描述" prop="des" align="center"/>
<template slot-scope="scope">
<span >{{ scope.row.des }}</span>
</template>
</el-table-column>
<el-table-column label="线上域名" align="center"> <el-table-column label="线上域名" prop="host_name" align="center"/>
<template slot-scope="scope">
<span>{{ scope.row.host_name }}</span>
</template>
</el-table-column>
<el-table-column label="负责人" width="80px" align="center"> <el-table-column label="负责人" width="80px" prop="auth" align="center"/>
<template slot-scope="scope">
<span>{{ scope.row.auth }}</span>
</template>
</el-table-column>
<el-table-column label="状态" width="90px" align="center"> <el-table-column label="状态" width="90px" align="center">
<template slot-scope="scope"> <template slot-scope="{row}">
<el-tag :type="scope.row.is_active | statusFilter">{{ scope.row.is_active | activeFileter }}</el-tag> <el-tag :type="row.is_active | statusFilter">{{ row.is_active | activeFileter }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="部署容器" width="90px" align="center"> <el-table-column label="部署容器" width="90px" align="center">
<template slot-scope="scope"> <template slot-scope="{row}">
<el-tag :type="scope.row.deploy_to_testenv | statusFilter">{{ scope.row.deploy_to_testenv | deployFileter }}</el-tag> <el-tag :type="row.deploy_to_testenv | statusFilter">{{ row.deploy_to_testenv | deployFileter }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
...@@ -67,9 +51,9 @@ ...@@ -67,9 +51,9 @@
label="API地址" label="API地址"
align="center" align="center"
width="80px"> width="80px">
<template slot-scope="scope"> <template slot-scope="{row}">
<el-tooltip :content="scope.row.api" class="item" effect="dark" placement="top"> <el-tooltip :content="row.api" class="item" effect="dark" placement="top">
<el-button v-if="scope.row.api" type="primary" icon="el-icon-time" circle @click="openUrl(scope.row.api)"/> <el-button v-show="row.api" type="primary" icon="el-icon-time" circle @click="openUrl(row.api)"/>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
...@@ -78,9 +62,9 @@ ...@@ -78,9 +62,9 @@
label="DDL地址" label="DDL地址"
width="80px" width="80px"
align="center"> align="center">
<template slot-scope="scope"> <template slot-scope="{row}">
<el-tooltip :content="scope.row.ddl" class="item" effect="dark" placement="top"> <el-tooltip :content="row.ddl" class="item" effect="dark" placement="top">
<el-button v-if="scope.row.ddl" type="success" icon="el-icon-time" circle @click="openUrl(scope.row.ddl)"/> <el-button v-show="row.ddl" type="success" icon="el-icon-time" circle @click="openUrl(row.ddl)"/>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
...@@ -89,9 +73,9 @@ ...@@ -89,9 +73,9 @@
label="Wiki" label="Wiki"
width="80px" width="80px"
align="center"> align="center">
<template slot-scope="scope"> <template slot-scope="{row}">
<el-tooltip :content="scope.row.wiki" class="item" effect="dark" placement="top"> <el-tooltip :content="row.wiki" class="item" effect="dark" placement="top">
<el-button v-if="scope.row.wiki" type="warning" icon="el-icon-time" circle @click="openUrl(scope.row.wiki)"/> <el-button v-show="row.wiki" type="warning" icon="el-icon-time" circle @click="openUrl(row.wiki)"/>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
...@@ -100,24 +84,24 @@ ...@@ -100,24 +84,24 @@
label="Git地址" label="Git地址"
width="80px" width="80px"
align="center"> align="center">
<template slot-scope="scope"> <template slot-scope="{row}">
<el-tooltip :content="scope.row.git_path" class="item" effect="dark" placement="top"> <el-tooltip :content="row.git_path" class="item" effect="dark" placement="top">
<el-button v-if="scope.row.git_path" type="info" icon="el-icon-tickets" circle /> <el-button v-show="row.git_path" type="info" icon="el-icon-tickets" circle />
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('table.actions')" align="center" width="70" class-name="small-padding fixed-width"> <el-table-column :label="$t('table.actions')" align="center" width="70" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="{row}">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{ $t('table.edit') }}</el-button> <el-button type="primary" size="mini" @click="handleUpdate(row)">{{ $t('table.edit') }}</el-button>
<!-- <el-button size="mini" type="danger" @click="handleDelete(scope.row)">{{ $t('table.delete') }} <!-- <el-button size="mini" type="danger" @click="handleDelete(row)">{{ $t('table.delete') }}
</el-button> --> </el-button> -->
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible"> <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
<el-form ref="dataForm" :model="temp" label-position="left" label-width="105px" style="width: 90%; margin-left:40px;"> <el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="115px" style="width: 90%; margin-left:40px;">
<el-form-item label="类型" prop="type"> <el-form-item label="类型" prop="type">
<el-select v-model="temp.type" class="filter-item" placeholder="Please select"> <el-select v-model="temp.type" class="filter-item" placeholder="Please select">
<el-option v-for="item in typeOptions" :key="item.key" :label="item.display_name" :value="item.key"/> <el-option v-for="item in typeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
...@@ -126,47 +110,80 @@ ...@@ -126,47 +110,80 @@
<el-form-item label="Git地址" prop="git_path" style="width: 100%;"> <el-form-item label="Git地址" prop="git_path" style="width: 100%;">
<el-input v-model="temp.git_path"/> <el-input v-model="temp.git_path"/>
</el-form-item> </el-form-item>
<el-form-item label="是否服役" >
<el-form-item label="负责人" style="width: 100%;" prop="auth">
<el-input v-model="temp.auth"/>
</el-form-item>
<el-form-item label="项目描述" style="width: 100%;">
<el-input :autosize="{ minRows: 1, maxRows: 4}" v-model="temp.des" type="textarea" placeholder="Please input"/>
</el-form-item>
<el-form-item label="API" style="width: 100%;">
<el-input v-model="temp.api"/>
</el-form-item>
<el-form-item label="数据库DDL" style="width: 100%;">
<el-input v-model="temp.ddl"/>
</el-form-item>
<el-form-item label="Wiki" style="width: 100%;">
<el-input v-model="temp.wiki"/>
</el-form-item>
<el-form-item label="是否服役" prop="is_active">
<el-select v-model="temp.is_active" class="filter-item" placeholder="Please select"> <el-select v-model="temp.is_active" class="filter-item" placeholder="Please select">
<el-option v-for="item in avtiveOptions" :key="item.key" :label="item.display_name" :value="item.key"/> <el-option v-for="item in avtiveOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="是否部署容器" > <el-form-item label="是否部署容器" prop="deploy_to_testenv">
<el-select v-model="temp.deploy_to_testenv" class="filter-item" placeholder="Please select"> <el-select v-model="temp.deploy_to_testenv" class="filter-item" placeholder="Please select">
<el-option v-for="item in deployOptions" :key="item.key" :label="item.display_name" :value="item.key"/> <el-option v-for="item in deployOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="项目描述" style="width: 100%;"> <el-form-item v-if="temp.deploy_to_testenv" label="线上域名" prop="host_name" style="width: 100%;">
<el-input :autosize="{ minRows: 2, maxRows: 4}" v-model="temp.des" type="textarea" placeholder="Please input"/>
</el-form-item>
<el-form-item label="线上域名" style="width: 100%;">
<el-input v-model="temp.host_name"/> <el-input v-model="temp.host_name"/>
</el-form-item> </el-form-item>
<el-form-item label="负责人" style="width: 100%;">
<el-input v-model="temp.auth"/> <el-form-item v-if="temp.deploy_to_testenv" label="配置文件路径" style="width: 100%;">
</el-form-item>
<el-form-item label="配置文件路径" style="width: 100%;">
<el-input v-model="temp.config_path"/> <el-input v-model="temp.config_path"/>
</el-form-item> </el-form-item>
<el-form-item label="Build文件路径" style="width: 100%;"> <el-form-item v-if="temp.deploy_to_testenv" label="Build文件路径" style="width: 100%;">
<el-input v-model="temp.jar_path"/> <el-input v-model="temp.jar_path"/>
</el-form-item> </el-form-item>
<el-form-item label="日志路径" style="width: 100%;"> <el-form-item v-if="temp.deploy_to_testenv" label="日志路径" style="width: 100%;">
<el-input v-model="temp.log_path"/> <el-input v-model="temp.log_path"/>
</el-form-item> </el-form-item>
<el-form-item label="部署命令" style="width: 100%;"> <el-form-item v-if="temp.deploy_to_testenv" label="部署命令" style="width: 100%;">
<el-input v-model="temp.build_command"/> <el-input v-model="temp.build_command"/>
</el-form-item> </el-form-item>
<el-form-item label="API" style="width: 100%;">
<el-input v-model="temp.api"/> <el-alert
</el-form-item> v-show="temp.type==='java' && temp.deploy_to_testenv"
<el-form-item label="数据库DDL" style="width: 100%;"> style="margin-bottom:20px"
<el-input v-model="temp.ddl"/> title="编辑启动命令需要管理员权限"
</el-form-item> type="warning"/>
<el-form-item label="Wiki" style="width: 100%;">
<el-input v-model="temp.wiki"/> <el-form-item v-show="temp.type==='java' && temp.deploy_to_testenv" label="启动命令" style="width: 100%;">
<el-input :autosize="{ minRows: 2, maxRows: 10}" v-model="temp.start_command" :disabled="disabled" type="textarea" placeholder="Please input"/>
</el-form-item> </el-form-item>
<el-card v-permission="['admin']" v-if="temp.deploy_to_testenv" class="box-card">
<div slot="header" >
<span>Kubernetes设置</span>
</div>
<el-form :inline="true" size="medium" >
<el-form-item label="CPU request" style="width:40%" prop="cpuRequest">
<el-input v-model="temp.cpuRequest" />
</el-form-item>
<el-form-item label="CPU limit" style="width:40%" prop="cpuLimit">
<el-input v-model="temp.cpuLimit" />
</el-form-item>
<el-form-item label="内存 request" style="width:40%" prop="memRequest">
<el-input v-model="temp.memRequest" />
</el-form-item>
<el-form-item label="内存 limit" style="width:40%" prop="memLimit">
<el-input v-model="temp.memLimit" />
</el-form-item>
</el-form>
</el-card>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">{{ $t('table.cancel') }}</el-button> <el-button @click="dialogFormVisible = false">{{ $t('table.cancel') }}</el-button>
...@@ -190,6 +207,7 @@ ...@@ -190,6 +207,7 @@
<script> <script>
import { getProjects, saveProject, deleteProject } from '@/api/proconfig' import { getProjects, saveProject, deleteProject } from '@/api/proconfig'
import waves from '@/directive/waves' // Waves directive import waves from '@/directive/waves' // Waves directive
import permission from '@/directive/permission/index.js' // 权限判断指令
const typeOptions = [ const typeOptions = [
{ key: 'java', display_name: 'Java' }, { key: 'java', display_name: 'Java' },
...@@ -219,7 +237,7 @@ const deployKeyValue = deployOptions.reduce((acc, cur) => { ...@@ -219,7 +237,7 @@ const deployKeyValue = deployOptions.reduce((acc, cur) => {
}, {}) }, {})
export default { export default {
directives: { waves }, directives: { waves, permission },
filters: { filters: {
statusFilter(status) { statusFilter(status) {
const statusMap = { const statusMap = {
...@@ -256,7 +274,16 @@ export default { ...@@ -256,7 +274,16 @@ export default {
}, },
proconfigs: [], proconfigs: [],
avtiveOptions, avtiveOptions,
deployOptions deployOptions,
disabled: undefined,
rules: {
type: [{ required: true, message: '请选择', trigger: 'change' }],
git_path: [{ required: true, message: '请输入', trigger: 'change' }],
is_active: [{ required: true, message: '请选择', trigger: 'change' }],
deploy_to_testenv: [{ required: true, message: '请选择', trigger: 'change' }],
host_name: [{ required: true, message: '请输入', trigger: 'change' }],
auth: [{ required: true, message: '请输入', trigger: 'change' }]
}
} }
}, },
watch: { watch: {
...@@ -266,9 +293,9 @@ export default { ...@@ -266,9 +293,9 @@ export default {
deep: true deep: true
} }
}, },
// created() { created() {
// this.getProjects() this.disabled = !this.$store.getters.roles.includes('admin')
// }, },
methods: { methods: {
getProjects() { getProjects() {
for (const prop in this.listQuery) { for (const prop in this.listQuery) {
...@@ -299,28 +326,9 @@ export default { ...@@ -299,28 +326,9 @@ export default {
} }
this.getProjects() this.getProjects()
}, },
resetTemp() {
this.temp = {
is_active: undefined,
deploy_to_testenv: undefined,
type: '',
project_name: '',
git_path: '',
host_name: '',
log_path: '',
config_path: '',
des: '',
auth: '',
jar_path: '',
command1: '',
build_command: '',
api: '',
ddl: '',
wiki: ''
}
},
handleCreate() { handleCreate() {
this.resetTemp() this.temp = {}
this.dialogStatus = 'create' this.dialogStatus = 'create'
this.dialogFormVisible = true this.dialogFormVisible = true
this.$nextTick(() => { this.$nextTick(() => {
...@@ -331,7 +339,6 @@ export default { ...@@ -331,7 +339,6 @@ export default {
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
saveProject(this.temp).then(() => { saveProject(this.temp).then(() => {
// this.proconfigs.unshift(this.temp)
this.dialogFormVisible = false this.dialogFormVisible = false
this.$notify({ this.$notify({
title: '成功', title: '成功',
...@@ -348,9 +355,9 @@ export default { ...@@ -348,9 +355,9 @@ export default {
this.temp = Object.assign({}, row) // copy obj this.temp = Object.assign({}, row) // copy obj
this.dialogStatus = 'update' this.dialogStatus = 'update'
this.dialogFormVisible = true this.dialogFormVisible = true
// this.$nextTick(() => { this.$nextTick(() => {
// this.$refs['dataForm'].clearValidate() this.$refs['dataForm'].clearValidate()
// }) })
}, },
handleDelete(row) { handleDelete(row) {
...@@ -373,9 +380,3 @@ export default { ...@@ -373,9 +380,3 @@ export default {
} }
} }
</script> </script>
<style scoped>
.el-form-item {
width: 600px;
}
</style>
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