Skip to content

Commit fa88671

Browse files
committed
fix: 针对后端调整,修改控制台 devops db 集合名称;优化部分页面交互体验;
1 parent 0713921 commit fa88671

File tree

12 files changed

+119
-62
lines changed

12 files changed

+119
-62
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const coll_prefix = 'devops_'
2+
3+
const Constants = {
4+
function_collection: '__deployed__functions',
5+
trigger_collection: '__deployed__triggers',
6+
policy_collection: '__deployed__policies',
7+
coll_prefix: coll_prefix,
8+
cn: {
9+
admins: coll_prefix + 'admins',
10+
permissions: coll_prefix + 'permissions',
11+
roles: coll_prefix + 'roles',
12+
policies: coll_prefix + 'policies',
13+
functions: coll_prefix + 'functions',
14+
function_history: coll_prefix + 'function_history',
15+
triggers: coll_prefix + 'triggers',
16+
deploy_targets: coll_prefix + 'deploy_targets',
17+
deploy_requests: coll_prefix + 'deploy_requests'
18+
}
19+
}
20+
21+
Object.freeze(Constants)
22+
Object.freeze(Object.cn)
23+
24+
export { Constants }

packages/devops-admin/src/views/database/collections.vue

+17-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="collec-wrap">
44
<div class="filter-container">
55
集合名称:
6-
<el-select v-model="collectionName" filterable placeholder="请选择集合">
6+
<el-select v-model="collectionName" size="mini" filterable placeholder="请选择集合">
77
<el-option
88
v-for="item in collections"
99
:key="item"
@@ -14,19 +14,19 @@
1414
</div>
1515

1616
<div style="text-align: center;">
17-
<el-radio-group v-model="tabType" style="margin-left: 30px;">
17+
<el-radio-group v-model="tabType" size="mini" style="margin-left: 30px;">
1818
<el-radio-button label="record">记录列表</el-radio-button>
1919
<el-radio-button label="index">索引管理</el-radio-button>
2020
</el-radio-group>
2121
</div>
2222

2323
<!-- 记录 -->
2424
<div v-show="tabType === 'record'" style="margin: 10px 0;">
25-
<el-input v-model.trim="listQuery._id" placeholder="请输入_id查找" style="width:200px" :disabled="!collectionName" @keyup.enter.native="handleFilter" />
26-
<el-button type="primary" style="margin-left: 10px" icon="el-icon-search" :disabled="!collectionName" @click="handleFilter">搜索记录</el-button>
27-
<el-button type="primary" style="margin-left: 10px" icon="el-icon-plus" :disabled="!collectionName" @click="handleCreateRecord">添加记录</el-button>
25+
<el-input v-model.trim="listQuery._id" size="mini" placeholder="请输入_id查找" style="width:200px" :disabled="!collectionName" @keyup.enter.native="handleFilter" />
26+
<el-button size="mini" type="primary" style="margin-left: 10px" icon="el-icon-search" :disabled="!collectionName" @click="handleFilter">搜索记录</el-button>
27+
<el-button size="mini" type="primary" style="margin-left: 10px" icon="el-icon-plus" :disabled="!collectionName" @click="handleCreateRecord">添加记录</el-button>
2828
</div>
29-
<el-container v-show="tabType === 'record'" style="height: 800px; border: 1px solid #eee">
29+
<el-container v-show="tabType === 'record'" style="height: calc(100vh - 240px); border: 1px solid #eee">
3030
<el-aside width="300px" style="background-color: #fff;border: 1px solid #eee;padding: 8px;">
3131
<div v-for="item in list" :key="item._id" class="record-item" :class="getClass(item)" @click="getRecord(item)">
3232
<span class="">_id: {{ item._id }}</span>
@@ -50,7 +50,7 @@
5050
<el-button size="mini" type="primary" :disabled="!collectionName" @click="updateRecord">更新</el-button>
5151
</el-header>
5252
<el-main>
53-
<json-editor v-model="record" :dark="true" :height="660" />
53+
<json-editor v-model="record" class="db-editor" :line-numbers="true" :dark="false" :height="600" />
5454
</el-main>
5555
</el-container>
5656
</el-container>
@@ -356,4 +356,14 @@ export default {
356356
color: blue;
357357
}
358358
}
359+
360+
.el-main {
361+
padding: 0;
362+
width: 100%;
363+
height: 100%;
364+
overflow: hidden;
365+
// .db-editor {
366+
// border: 1px solid lightgray
367+
// }
368+
}
359369
</style>

packages/devops-admin/src/views/database/policies.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
140140
import { db } from '../../api/cloud'
141141
import DeployPanel from '../deploy/components/deploy-panel.vue'
142+
import { Constants } from '../../api/constants'
142143
143144
// 默认化创建表单的值
144145
function getDefaultFormValue() {
@@ -204,7 +205,7 @@ export default {
204205
},
205206
methods: {
206207
async getFunctions() {
207-
const r = await db.collection('__functions')
208+
const r = await db.collection(Constants.cn.functions)
208209
.where({ status: 1 })
209210
.get()
210211
@@ -228,7 +229,7 @@ export default {
228229
}
229230
230231
// 执行数据查询
231-
const res = await db.collection('__policies')
232+
const res = await db.collection(Constants.cn.policies)
232233
.where(query)
233234
.limit(limit)
234235
.skip((page - 1) * limit)
@@ -238,7 +239,7 @@ export default {
238239
this.list = res.data
239240
240241
// 获取数据总数
241-
const { total } = await db.collection('__policies')
242+
const { total } = await db.collection(Constants.cn.policies)
242243
.where(query)
243244
.limit(limit)
244245
.skip((page - 1) * limit)
@@ -268,7 +269,7 @@ export default {
268269
if (!valid) { return }
269270
270271
// 执行创建请求
271-
const r = await db.collection('__policies')
272+
const r = await db.collection(Constants.cn.policies)
272273
.add(this.form)
273274
274275
if (!r.id) {
@@ -315,7 +316,7 @@ export default {
315316
}
316317
317318
// 执行更新请求
318-
const r = await db.collection('__policies')
319+
const r = await db.collection(Constants.cn.policies)
319320
.where({ _id: this.form._id })
320321
.update(data)
321322
@@ -343,7 +344,7 @@ export default {
343344
await this.$confirm('确认要删除此数据?', '删除确认')
344345
345346
// 执行删除请求
346-
const r = await db.collection('__policies')
347+
const r = await db.collection(Constants.cn.policies)
347348
.where({ _id: row._id })
348349
.remove()
349350

packages/devops-admin/src/views/database/policy.vue

+29-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="main-row">
1818
<div class="collection-list">
1919
<div class="label">选择集合</div>
20-
<el-radio-group v-model="collection_name" style="width: 100%;">
20+
<el-radio-group v-model="collection_name" class="radio-group">
2121
<el-radio v-for="item in collections" :key="item" class="collection-radio" border size="medium" :label="item">
2222
{{ item }}
2323
</el-radio>
@@ -29,7 +29,7 @@
2929
<el-button class="btn" size="mini" type="success" :disabled="loading" @click="updateRule">保存</el-button>
3030
<el-button class="btn" type="danger" size="mini" :disabled="loading" @click="removeRule">删除</el-button>
3131
</div>
32-
<json-editor v-model="value" :dark="true" :height="600" />
32+
<json-editor v-model="value" class="editor" :line-numbers="true" :dark="false" :height="600" />
3333
</div>
3434
</div>
3535

@@ -76,6 +76,7 @@ import JsonEditor from '@/components/JsonEditor/rule'
7676
import { db } from '../../api/cloud'
7777
import $ from 'lodash'
7878
import { publishPolicy } from '../../api/publish'
79+
import { Constants } from '../../api/constants'
7980
8081
const defaultValue = '{}'
8182
const defaultForm = {
@@ -125,7 +126,7 @@ export default {
125126
methods: {
126127
async getPolicies() {
127128
this.loading = true
128-
const r = await db.collection('__policies')
129+
const r = await db.collection(Constants.cn.policies)
129130
.get()
130131
131132
if (!r.ok) {
@@ -154,7 +155,7 @@ export default {
154155
this.loading = true
155156
const rule_data = this.value
156157
const key = `rules.${this.collection_name}`
157-
const r = await db.collection('__policies')
158+
const r = await db.collection(Constants.cn.policies)
158159
.where({
159160
_id: this.policy_id
160161
})
@@ -187,7 +188,7 @@ export default {
187188
this.loading = true
188189
189190
const key = `rules.${this.form.collection}`
190-
const { total } = await db.collection('__policies')
191+
const { total } = await db.collection(Constants.cn.policies)
191192
.where({
192193
_id: this.form.policy_id,
193194
[key]: db.command.exists(true)
@@ -198,7 +199,7 @@ export default {
198199
this.$message('该集合规则已存在!')
199200
return
200201
}
201-
const r = await db.collection('__policies')
202+
const r = await db.collection(Constants.cn.policies)
202203
.where({
203204
_id: this.form.policy_id,
204205
[key]: db.command.exists(false)
@@ -244,7 +245,7 @@ export default {
244245
this.loading = true
245246
246247
const key = `rules.${this.collection_name}`
247-
const r = await db.collection('__policies')
248+
const r = await db.collection(Constants.cn.policies)
248249
.where({
249250
_id: this.policy_id,
250251
[key]: db.command.exists(true)
@@ -314,7 +315,9 @@ export default {
314315
display: flex;
315316
316317
.collection-list {
317-
width: 200px;
318+
width: 250px;
319+
320+
padding-bottom: 10px;
318321
border-radius: 5px;
319322
box-sizing: border-box;
320323
@@ -323,8 +326,20 @@ export default {
323326
color: gray;
324327
margin-bottom: 10px;
325328
}
326-
.collection-radio {
329+
330+
.radio-group {
327331
width: 100%;
332+
height: 640px;
333+
overflow-y: scroll;
334+
overflow-x: hidden;
335+
}
336+
337+
.radio-group::-webkit-scrollbar {
338+
display: none;
339+
}
340+
341+
.collection-radio {
342+
width: 80%;
328343
margin-bottom: 10px;
329344
margin-left: 0px;
330345
}
@@ -340,12 +355,16 @@ export default {
340355
display: flex;
341356
width: 400px;
342357
justify-content: flex-start;
343-
margin-bottom: 5px;
358+
margin-bottom: 10px;
344359
345360
.btn {
346361
margin-left: 15px;
347362
}
348363
}
364+
365+
.editor {
366+
border: 1px solid lightgray
367+
}
349368
}
350369
}
351370

packages/devops-admin/src/views/deploy/components/deploy-panel.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<script>
6060
import { db } from '@/api/cloud'
6161
import { deploy2remote } from '@/api/deploy'
62+
import { Constants } from '../../../api/constants'
6263
6364
// 表单验证规则
6465
const formRules = {
@@ -120,7 +121,7 @@ export default {
120121
},
121122
methods: {
122123
async load() {
123-
const r = await db.collection('deploy_targets').get()
124+
const r = await db.collection(Constants.cn.deploy_targets).get()
124125
if (!r.ok) throw new Error('get targets failed')
125126
126127
this.targets = r.data
@@ -131,7 +132,7 @@ export default {
131132
return
132133
}
133134
const func_ids = this.internal_functions.map(func => func._id)
134-
const r = await db.collection('__triggers')
135+
const r = await db.collection(Constants.cn.triggers)
135136
.where({
136137
func_id: db.command.in(func_ids)
137138
})

packages/devops-admin/src/views/deploy/requests.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@
139139
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
140140
import { db } from '@/api/cloud'
141141
import { applyDeployRequest, createDeployToken } from '../../api/deploy'
142+
import { Constants } from '../../api/constants'
143+
142144
// 默认的创建部署令牌表单
143145
function getDefaultFormValue() {
144146
return {
@@ -214,7 +216,7 @@ export default {
214216
}
215217
216218
// 执行数据查询
217-
const res = await db.collection('deploy_requests')
219+
const res = await db.collection(Constants.cn.deploy_requests)
218220
.where(query)
219221
.limit(limit)
220222
.skip((page - 1) * limit)
@@ -224,7 +226,7 @@ export default {
224226
this.list = res.data
225227
226228
// 获取数据总数
227-
const { total } = await db.collection('deploy_requests')
229+
const { total } = await db.collection(Constants.cn.deploy_requests)
228230
.where(query)
229231
.limit(limit)
230232
.skip((page - 1) * limit)
@@ -296,7 +298,7 @@ export default {
296298
await this.$confirm('确认要删除此数据?', '删除确认')
297299
298300
// 执行删除请求
299-
const r = await db.collection('deploy_requests')
301+
const r = await db.collection(Constants.cn.deploy_requests)
300302
.where({ _id: row._id })
301303
.remove()
302304

packages/devops-admin/src/views/deploy/targets.vue

+6-5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
<script>
115115
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
116116
import { db } from '@/api/cloud'
117+
import { Constants } from '../../api/constants'
117118
118119
// 默认化创建表单的值
119120
function getDefaultFormValue() {
@@ -191,7 +192,7 @@ export default {
191192
}
192193
193194
// 执行数据查询
194-
const res = await db.collection('deploy_targets')
195+
const res = await db.collection(Constants.cn.deploy_targets)
195196
.where(query)
196197
.limit(limit)
197198
.skip((page - 1) * limit)
@@ -201,7 +202,7 @@ export default {
201202
this.list = res.data
202203
203204
// 获取数据总数
204-
const { total } = await db.collection('deploy_targets')
205+
const { total } = await db.collection(Constants.cn.deploy_targets)
205206
.where(query)
206207
.limit(limit)
207208
.skip((page - 1) * limit)
@@ -231,7 +232,7 @@ export default {
231232
if (!valid) { return }
232233
233234
// 执行创建请求
234-
const r = await db.collection('deploy_targets')
235+
const r = await db.collection(Constants.cn.deploy_targets)
235236
.add(this.form)
236237
237238
if (!r.id) {
@@ -277,7 +278,7 @@ export default {
277278
}
278279
279280
// 执行更新请求
280-
const r = await db.collection('deploy_targets')
281+
const r = await db.collection(Constants.cn.deploy_targets)
281282
.where({ _id: this.form._id })
282283
.update(data)
283284
@@ -305,7 +306,7 @@ export default {
305306
await this.$confirm('确认要删除此数据?', '删除确认')
306307
307308
// 执行删除请求
308-
const r = await db.collection('deploy_targets')
309+
const r = await db.collection(Constants.cn.deploy_targets)
309310
.where({ _id: row._id })
310311
.remove()
311312

0 commit comments

Comments
 (0)