mirror of https://github.com/openspug/spug
U 优化服务删除逻辑
parent
6a9f9629f7
commit
eb68491043
|
@ -4,7 +4,7 @@
|
||||||
from django.views.generic import View
|
from django.views.generic import View
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
from libs import json_response, JsonParser, Argument, auth
|
from libs import json_response, JsonParser, Argument, auth
|
||||||
from apps.app.models import Deploy
|
from apps.app.models import Deploy, App
|
||||||
from apps.config.models import *
|
from apps.config.models import *
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
@ -111,8 +111,16 @@ class ServiceView(View):
|
||||||
Argument('id', type=int, help='请指定操作对象')
|
Argument('id', type=int, help='请指定操作对象')
|
||||||
).parse(request.GET)
|
).parse(request.GET)
|
||||||
if error is None:
|
if error is None:
|
||||||
if Config.objects.filter(type='src', o_id=form.id).exists():
|
rel_apps = []
|
||||||
return json_response(error='该服务已存在关联的配置信息,请删除相关配置后再尝试删除')
|
for app in App.objects.filter(rel_services__isnull=False):
|
||||||
|
rel_services = json.loads(app.rel_services)
|
||||||
|
if form.id in rel_services:
|
||||||
|
rel_apps.append(app.name)
|
||||||
|
if rel_apps:
|
||||||
|
return json_response(error=f'该服务在配置中心已被 "{", ".join(rel_apps)}" 依赖,请解除依赖关系后再尝试删除。')
|
||||||
|
# auto delete configs
|
||||||
|
Config.objects.filter(type='src', o_id=form.id).delete()
|
||||||
|
ConfigHistory.objects.filter(type='src', o_id=form.id).delete()
|
||||||
Service.objects.filter(pk=form.id).delete()
|
Service.objects.filter(pk=form.id).delete()
|
||||||
return json_response(error=error)
|
return json_response(error=error)
|
||||||
|
|
||||||
|
|
|
@ -70,9 +70,9 @@ class ComTable extends React.Component {
|
||||||
<Table.Column width={210} title="操作" render={info => (
|
<Table.Column width={210} title="操作" render={info => (
|
||||||
<Action>
|
<Action>
|
||||||
<Action.Button auth="config.app.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
|
<Action.Button auth="config.app.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
|
||||||
<Action.Button auth="config.app.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
|
|
||||||
<Action.Button auth="config.app.view_config" onClick={() => store.showRel(info)}>依赖</Action.Button>
|
<Action.Button auth="config.app.view_config" onClick={() => store.showRel(info)}>依赖</Action.Button>
|
||||||
<Action.Button auth="config.app.view_config" onClick={() => this.toConfig(info)}>配置</Action.Button>
|
<Action.Button auth="config.app.view_config" onClick={() => this.toConfig(info)}>配置</Action.Button>
|
||||||
|
<Action.Button danger auth="config.app.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
|
||||||
</Action>
|
</Action>
|
||||||
)}/>
|
)}/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -76,7 +76,7 @@ function ComTable() {
|
||||||
<Table.Column title="操作" render={info => (
|
<Table.Column title="操作" render={info => (
|
||||||
<Action>
|
<Action>
|
||||||
<Action.Button auth="config.env.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
|
<Action.Button auth="config.env.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
|
||||||
<Action.Button auth="config.env.del" onClick={() => handleDelete(info)}>删除</Action.Button>
|
<Action.Button danger auth="config.env.del" onClick={() => handleDelete(info)}>删除</Action.Button>
|
||||||
</Action>
|
</Action>
|
||||||
)}/>
|
)}/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ComTable extends React.Component {
|
||||||
handleDelete = (text) => {
|
handleDelete = (text) => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '删除确认',
|
title: '删除确认',
|
||||||
content: `确定要删除【${text['name']}】?`,
|
content: `将会同步删除服务的配置信息,确定要删除服务【${text['name']}】? `,
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
return http.delete('/api/config/service/', {params: {id: text.id}})
|
return http.delete('/api/config/service/', {params: {id: text.id}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -66,8 +66,8 @@ class ComTable extends React.Component {
|
||||||
<Table.Column title="操作" render={info => (
|
<Table.Column title="操作" render={info => (
|
||||||
<Action>
|
<Action>
|
||||||
<Action.Button auth="config.src.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
|
<Action.Button auth="config.src.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
|
||||||
<Action.Button auth="config.src.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
|
|
||||||
<Action.Button auth="config.src.view_config" onClick={() => this.toConfig(info)}>配置</Action.Button>
|
<Action.Button auth="config.src.view_config" onClick={() => this.toConfig(info)}>配置</Action.Button>
|
||||||
|
<Action.Button danger auth="config.src.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
|
||||||
</Action>
|
</Action>
|
||||||
)}/>
|
)}/>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue