Commit 9ead530c authored by xuezj's avatar xuezj

增加获取base和应用的仓库信息接口

parents 79912660 5bb6b680
......@@ -128,7 +128,7 @@ export function fetchServiceInstance(data) {
export function flushRedis(query) {
return request({
url: '/docker/flush_redis',
url: '/docker/flush_redis_tke',
method: 'get',
params: query
})
......
......@@ -27,7 +27,7 @@ const dockersRouter = {
path: 'createEnv',
component: () => import('@/views/docker/createEnv'),
name: 'CreateEnv',
meta: { title: 'createEnv', noCache: true }
meta: { title: 'createEnv', noCache: true, roles: ['admin'] }
},
{
path: 'envTemplate',
......
......@@ -67,7 +67,8 @@ const user = {
// reject('Verification failed, please login again.')
// }
const data = response.data
data.roles = ['admin']
// data.roles = ['admin']
data.roles = data.role
if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
commit('SET_ROLES', data.roles)
......
......@@ -33,15 +33,16 @@
</el-card>
</el-form-item>
</el-form>
<el-button style="margin-right:40px;margin-bottom:40px;float:right" type="primary" @click="createData()">{{ $t('table.confirm') }}</el-button>
<el-button v-permission="['admin']" style="margin-right:40px;margin-bottom:40px;float:right" type="primary" @click="createData()">{{ $t('table.confirm') }}</el-button>
</div>
</template>
<script>
import { getBaseRepos, getAllEnvTemplate, createEnv } from '@/api/docker'
import permission from '@/directive/permission/index.js' // 权限判断指令
export default {
directives: { permission },
filters: {
upper: function(value) {
if (!value) return ''
......
<template>
<div class="app-container">
<el-form ref="dataForm" 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-select v-model="currentTemplate" value-key="preset_name" style="width:100%" @change="useTemplate">
<el-option v-for="item in templates" :value="item.name" :key="item.name" />
</el-select>
</el-form-item>
<el-form-item v-for="(ns, index) in repoNamespaces" :label="ns.type | upper" :key="index">
<el-card>
<el-button
v-for="item in ns.repos"
:key="item.domain"
:type="dependant[ns.type] && dependant[ns.type].find(sys => sys.appname === item.appname) ? 'success' : ''"
style="margin:3px"
@click="selectSystem(item, ns.type)">
{{ item.appname }}
</el-button>
</el-card>
</el-form-item>
</el-form>
<el-button style="margin-right:40px;margin-bottom:40px;float:right" type="primary" @click="createData()">{{ $t('table.confirm') }}</el-button>
<el-button style="margin-right:40px;margin-bottom:40px;float:right" @click="goBack()">{{ $t('table.cancel') }}</el-button>
</div>
</template>
<script>
import { getAppRepos, getAllEnvTemplate, createEnv } from '@/api/docker'
export default {
filters: {
upper: function(value) {
if (!value) return ''
value = value.toString()
return value[0].toUpperCase() + value.slice(1)
}
},
data() {
return {
namespace: '',
dependant: {},
repoNamespaces: [],
currentTemplate: '',
templates: {}
}
},
created() {
this.namespace = this.$route.params.name
this.getAllRepos()
this.getAllEnvTemplate()
},
methods: {
goBack() {
this.$router.go(-1)
},
getAllRepos() {
getAppRepos().then(res => {
this.repoNamespaces = res.data
})
},
getAllEnvTemplate() {
getAllEnvTemplate().then(res => {
this.templates = res.data
})
},
selectSystem(item, type) {
if (!this.dependant[type]) this.$set(this.dependant, type, [])
const index = this.dependant[type].findIndex(sys => sys.appname === item.appname)
if (index === -1) {
this.dependant[type].push(item)
} else {
this.dependant[type].splice(index, 1)
}
},
useTemplate() {
const vm = this
const t = this.templates.find(item => item.name === this.currentTemplate)
// 清空所有选择
vm.$set(this, 'dependant', {})
// 遍历设置
const keys = Object.keys(t)
keys.forEach(key => {
if (key !== 'name' && key !== '_id') {
t[key].forEach(repo => {
vm.selectSystem(repo, key)
})
}
})
},
createData() {
const param = {
namespace: this.namespace,
dependant: this.dependant
}
createEnv(param).then(res => {
this.$router.push({
path: `/dockers/runingEnv/${this.namespace}`
})
})
this.$message({
message: '正在部署,请稍候',
type: 'success',
duration: 2000
})
}
}
}
</script>
......@@ -480,7 +480,7 @@ export default {
clearRedis() {
flushRedis({ namespace: this.namespace }).then(res => {
this.$message({
message: '清理redis缓存成功',
message: res.data.msg || '清理redis缓存成功',
type: 'success'
})
})
......
......@@ -22,14 +22,16 @@
</el-card>
</el-form-item>
</el-form>
<el-button style="margin-right:40px;margin-bottom:40px;float:right" type="primary" @click="createData()">{{ $t('table.confirm') }}</el-button>
<el-button v-permission="['admin']" style="margin-right:40px;margin-bottom:40px;float:right" type="primary" @click="createData()">{{ $t('table.confirm') }}</el-button>
</div>
</template>
<script>
import { getAllRepos, getAllEnvTemplate, createEnvTemplate } from '@/api/docker'
import permission from '@/directive/permission/index.js' // 权限判断指令
export default {
directives: { permission },
filters: {
upper: function(value) {
......
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