Commit 56204ae1 authored by 智勇's avatar 智勇

创建服务增加镜像默认值

parent dbb774e5
...@@ -4,7 +4,8 @@ export function getNotify(data) { ...@@ -4,7 +4,8 @@ export function getNotify(data) {
return request({ return request({
url: '/notify/getNotify', url: '/notify/getNotify',
method: 'post', method: 'post',
data }) data
})
} }
export function saveNotify(data) { export function saveNotify(data) {
......
import request from '@/utils/request' import request from '@/utils/request'
export function getMaster(data) { export function getBranch(query) {
return request({ return request({
url: '/pipeline/master', url: '/pipeline/getGitBranch',
method: 'post', method: 'get',
data params: query
}) })
} }
export function saveApplication(data) { export function saveApplication(data) {
......
...@@ -328,7 +328,7 @@ ...@@ -328,7 +328,7 @@
v-for="(item,index) in tagOptions" v-for="(item,index) in tagOptions"
:key="index" :key="index"
:label="item.tagName" :label="item.tagName"
:value="item.repo_name + ':' +item.tagName"/> :value="item.tagName"/>
</el-select> </el-select>
</el-col> </el-col>
</el-row> </el-row>
...@@ -367,7 +367,7 @@ ...@@ -367,7 +367,7 @@
:closable="false" :closable="false"
title="温馨提醒" title="温馨提醒"
type="warning" type="warning"
description="警告:该操作将会更新这个服务为指定版本,在这个pod上做的所有操作将会丢失。" description="警告:该操作将会更新这个服务为指定版本,在这个pod上做的所有操作将会丢失。"
/> />
<p class="title-sub">选择服务</p> <p class="title-sub">选择服务</p>
<el-row :gutter="20"> <el-row :gutter="20">
...@@ -387,7 +387,7 @@ ...@@ -387,7 +387,7 @@
v-for="(item,index) in tagOptions" v-for="(item,index) in tagOptions"
:key="index" :key="index"
:label="item.tagName" :label="item.tagName"
:value="item.repo_name + ':' +item.tagName"/> :value="item.tagName"/>
</el-select> </el-select>
</el-col> </el-col>
</el-row> </el-row>
...@@ -587,6 +587,7 @@ export default { ...@@ -587,6 +587,7 @@ export default {
}).then(res => { }).then(res => {
if (res.data.tagCount) { if (res.data.tagCount) {
this.tagOptions = res.data.tagInfo this.tagOptions = res.data.tagInfo
this.tagName = `latest`
} }
}) })
}, },
...@@ -602,7 +603,7 @@ export default { ...@@ -602,7 +603,7 @@ export default {
CreateCluService({ CreateCluService({
serviceName: serviceName, serviceName: serviceName,
namespace: this.namespace, namespace: this.namespace,
image: this.tagName, image: `${this.reponame}:${this.tagName}`,
label: this.label, label: this.label,
type: this.type, type: this.type,
domain: this.domain.split('.')[0], domain: this.domain.split('.')[0],
...@@ -695,7 +696,6 @@ export default { ...@@ -695,7 +696,6 @@ export default {
}, },
updateService(value) { updateService(value) {
this.tagName = ''
this.updateDialog = true this.updateDialog = true
this.serviceName = value.serviceName this.serviceName = value.serviceName
this.type = value.labels.type this.type = value.labels.type
...@@ -703,6 +703,8 @@ export default { ...@@ -703,6 +703,8 @@ export default {
fetchTaglist({ reponame: 'qa-' + value.labels.type + '/' + this.serviceName }).then(res => { fetchTaglist({ reponame: 'qa-' + value.labels.type + '/' + this.serviceName }).then(res => {
if (res.data.tagCount) { if (res.data.tagCount) {
this.tagOptions = res.data.tagInfo this.tagOptions = res.data.tagInfo
this.reponame = res.data.reponame
this.tagName = 'latest'
this.server = res.data.server this.server = res.data.server
} }
}) })
...@@ -726,7 +728,7 @@ export default { ...@@ -726,7 +728,7 @@ export default {
updateClusterService() { updateClusterService() {
const self = this const self = this
modifyCluService({ serviceName: this.serviceName, image: this.tagName, namespace: this.namespace, type: this.type }).then(res => { modifyCluService({ serviceName: this.serviceName, image: `${this.reponame}:${this.tagName}`, namespace: this.namespace, type: this.type }).then(res => {
this.$message({ this.$message({
message: `更新${this.serviceName}成功`, message: `更新${this.serviceName}成功`,
type: 'success', type: 'success',
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="namespace" label="命名空间" align="center"/> <el-table-column prop="namespace" label="命名空间" align="center"/>
<el-table-column prop="create_time" label="创建时间" align="center"/> <el-table-column :formatter="formatDate" label="时间" align="center"/>
<el-table-column :label="$t('table.actions')" align="center" width="180" class-name="small-padding fixed-width"> <el-table-column :label="$t('table.actions')" align="center" width="180" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{ $t('table.edit') }}</el-button> <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{ $t('table.edit') }}</el-button>
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
</template> </template>
<script> <script>
import { getApplications, saveApplication, updateApplication, deleteApplication, getMaster } from '@/api/pipelineNode' import { getApplications, saveApplication, updateApplication, deleteApplication, getBranch } from '@/api/pipelineNode'
import { getProjects } from '@/api/proconfig' import { getProjects } from '@/api/proconfig'
import waves from '@/directive/waves' // Waves directive import waves from '@/directive/waves' // Waves directive
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
...@@ -132,18 +132,14 @@ import { getCluster } from '@/api/cluster' ...@@ -132,18 +132,14 @@ import { getCluster } from '@/api/cluster'
import { fetchKubernetesList } from '@/api/docker' import { fetchKubernetesList } from '@/api/docker'
export default { export default {
name: 'ComplexTable',
components: { Pagination }, components: { Pagination },
directives: { waves }, directives: { waves },
filters: { filters: {
replaceeRef(ref) { replaceeRef(ref) {
return ref ? ref.replace('refs/heads/', '') : '' return ref ? ref.replace('refs/heads/', '') : ''
}, },
formatDeploy(ref) { formatDeploy(data) {
return ref ? '' : '' return data ? '' : ''
},
formatDate(date, pattern = 'YYYY-MM-DD HH:mm:ss') {
return moment(date).format(pattern)
} }
}, },
data() { data() {
...@@ -151,17 +147,13 @@ export default { ...@@ -151,17 +147,13 @@ export default {
value1: true, value1: true,
repository: '', repository: '',
total: 0, total: 0,
cacheData: {}, listQuery: {},
listQuery: { temp: {},
},
temp: {
},
dialogFormVisible: false, dialogFormVisible: false,
dialogDeleteVisible: false, dialogDeleteVisible: false,
dialogStatus: '', dialogStatus: '',
rules: { rules: {
application_name: [{ required: true, message: '请输入', trigger: 'change' }], application_name: [{ required: true, message: '请输入', trigger: 'change' }],
// timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
namespace: [{ required: true, message: '请输入', trigger: 'blur' }], namespace: [{ required: true, message: '请输入', trigger: 'blur' }],
cluster: [{ required: true, message: '请输入', trigger: 'blur' }] cluster: [{ required: true, message: '请输入', trigger: 'blur' }]
}, },
...@@ -239,6 +231,11 @@ export default { ...@@ -239,6 +231,11 @@ export default {
this.getApplications() this.getApplications()
}, },
formatDate(row, val) {
const pattern = 'YYYY-MM-DD HH:mm:ss'
return moment(row.updatedAt || row.createdAt).format(pattern)
},
resetTemp() { resetTemp() {
this.temp = { this.temp = {
id: 0, id: 0,
...@@ -248,24 +245,28 @@ export default { ...@@ -248,24 +245,28 @@ export default {
isDeploy: false, isDeploy: false,
repos: [{ repository: '', ref: { id: '请选择' }}], repos: [{ repository: '', ref: { id: '请选择' }}],
application_name: '', application_name: '',
create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
new_user: '', new_user: '',
update_user: '', update_user: '',
cluster: this.$store.getters.cluster cluster: this.$store.getters.cluster
} }
}, },
handleCreate() { getProjects() {
this.resetTemp()
this.dialogStatus = '新建'
getProjects({ is_active: true, deploy_to_testenv: true }).then(res => { getProjects({ is_active: true, deploy_to_testenv: true }).then(res => {
this.repos = res.data this.repos = res.data
this.repos.sort((s1, s2) => { this.repos.sort((s1, s2) => {
return s1.project_name.localeCompare(s2.project_name) return s1.project_name.localeCompare(s2.project_name)
}) })
}) })
},
handleCreate() {
this.resetTemp()
this.dialogStatus = '新建'
this.getProjects()
this.dialogFormVisible = true this.dialogFormVisible = true
}, },
getRefs(repo, flag) { getRefs(repo, flag) {
if (flag) { if (flag) {
this.temp.repos.forEach(item => { this.temp.repos.forEach(item => {
...@@ -274,9 +275,7 @@ export default { ...@@ -274,9 +275,7 @@ export default {
} }
}) })
} }
// 拿出gitlab地址信息 getBranch({ name: repo }).then(res => {
const gitlabAddress = this.screen(repo, this.repos)
getMaster({ name: repo, gitlabAddress }).then(res => {
if (res.data.code === '0001') { if (res.data.code === '0001') {
this.$notify({ this.$notify({
title: 'error', title: 'error',
...@@ -296,14 +295,7 @@ export default { ...@@ -296,14 +295,7 @@ export default {
} }
}) })
}, },
screen(name, list) {
const data = list.filter(item => {
if (name === item.project_name) {
return item
}
})
return data[0].git_lab
},
createData() { createData() {
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
...@@ -374,16 +366,12 @@ export default { ...@@ -374,16 +366,12 @@ 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
getProjects({ is_active: true }).then(res => { this.getProjects()
this.repos = res.data
this.repos.sort((s1, s2) => {
return s1.project_name.localeCompare(s2.project_name)
})
row.repos.forEach(item => { row.repos.forEach(item => {
this.getRefs(item.repository) this.getRefs(item.repository)
}) })
})
}, },
handleDelete(row) { handleDelete(row) {
this.temp = row this.temp = row
this.dialogDeleteVisible = true this.dialogDeleteVisible = true
......
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