Skip to content

Commit

Permalink
fix(system-client): fix dbm pages;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Sep 3, 2021
1 parent cf9186d commit e0f44da
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
10 changes: 0 additions & 10 deletions packages/system-client/src/api/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,3 @@ export const cloud = new Cloud({
})

export const db = cloud.database()

/**
* 用于数据库管理
*/
export const dbm_cloud = new Cloud({
baseUrl: process.env.VUE_APP_BASE_API,
entryUrl: '/dbm/entry',
getAccessToken: getToken,
requestClass: CloudRequest
})
39 changes: 32 additions & 7 deletions packages/system-client/src/api/collec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import request from '@/utils/request'
import store from '@/store'
import { getToken } from '@/utils/auth'
import { Cloud } from 'less-api-client'

/**
* 获取集合列表
* Get collection list
* @param {*} query
* @param {*} page
* @param {*} pageSize
*/
export function getCollections() {
const appid = store.state.app.appid
return request({
url: `/dbm/collections`,
url: `/apps/${appid}/dbm/collections`,
method: 'get'
})
}

/**
* 获取集合的索引信息
*/
export function getCollectionIndexes(collection = 'functions') {
export function getCollectionIndexes(collection) {
const appid = store.state.app.appid
return request({
url: `/dbm/collection/indexes?collection=${collection}`,
url: `/apps/${appid}/dbm/collection/indexes?collection=${collection}`,
method: 'get'
})
}
Expand All @@ -26,8 +34,9 @@ export function getCollectionIndexes(collection = 'functions') {
* @return
*/
export function setCollectionIndexes(collection, data) {
const appid = store.state.app.appid
return request({
url: `/dbm/collection/indexes?collection=${collection}`,
url: `/apps/${appid}/dbm/collection/indexes?collection=${collection}`,
method: 'post',
data
})
Expand All @@ -39,9 +48,25 @@ export function setCollectionIndexes(collection, data) {
* @param {String} index 索引名
* @returns
*/
export function deleCollectionIndexe(collection, index) {
export function deleCollectionIndex(collection, index) {
const appid = store.state.app.appid
return request({
url: `/dbm/collection/indexes?collection=${collection}&index=${index}`,
url: `/apps/${appid}/dbm/collection/indexes?collection=${collection}&index=${index}`,
method: 'delete'
})
}

/**
* Get a Db instance for dbm
* @returns
*/
export function getDb() {
const appid = store.state.app.appid
const dbm_cloud = new Cloud({
baseUrl: process.env.VUE_APP_BASE_API,
entryUrl: `/apps/${appid}/dbm/entry`,
getAccessToken: getToken
})

return dbm_cloud.database()
}
2 changes: 1 addition & 1 deletion packages/system-client/src/views/application/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{ scope.row.status }}
</template>
</el-table-column>
<el-table-column fixed="right" label="服务启停" align="center" width="380" class-name="small-padding">
<el-table-column label="服务启停" align="center" width="200" class-name="small-padding">
<template slot-scope="{row}">
<el-button v-if="row.status !== 'running'" plain type="warning" size="mini" @click="startApp(row)">
启动
Expand Down
8 changes: 3 additions & 5 deletions packages/system-client/src/views/database/collections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,12 @@
</template>

<script>
import { dbm_cloud } from '@/api/cloud'
import { getCollections, getCollectionIndexes, deleCollectionIndexe, setCollectionIndexes } from '@/api/collec'
// import { TYPES } from '@/utils/types'
import { getCollections, getCollectionIndexes, deleCollectionIndex, setCollectionIndexes, getDb } from '@/api/collec'
import MiniPagination from '@/components/Pagination/mini'
import JsonEditor from '@/components/JsonEditor/param'
const db = dbm_cloud.database()
const db = getDb()
export default {
name: 'CollectionManagement',
Expand Down Expand Up @@ -294,7 +292,7 @@ export default {
async deleIndex(index) {
await this.$confirm('确认要删除此数据?', '删除确认')
await deleCollectionIndexe(this.collectionName, index.name)
await deleCollectionIndex(this.collectionName, index.name)
this.$message('删除成功')
this.getIndexes()
Expand Down

0 comments on commit e0f44da

Please sign in to comment.