Skip to content

Commit

Permalink
feat: impl file upload in devops-admin;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Aug 18, 2021
1 parent 9d46658 commit f3b383a
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 186 deletions.
6 changes: 3 additions & 3 deletions packages/app-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: Maslow<wangfugen@126.com>
* @Date: 2021-07-30 10:30:29
* @LastEditTime: 2021-08-17 14:40:21
* @LastEditTime: 2021-08-18 13:19:45
* @Description:
*/

Expand Down Expand Up @@ -43,8 +43,8 @@ server.use(function (req, _res, next) {
req['auth'] = auth

const requestId = req['requestId'] = uuidv4()
logger.info(requestId, `${req.path} start request`)
logger.debug(requestId, `parsed auth: ` + JSON.stringify(auth))
logger.info(requestId, `${req.method} "${req.url}" - referer: ${req.get('referer') || '-'} ${req.get('user-agent')}`)
logger.trace(requestId, `${req.method} ${req.url}`, { body: req.body, headers: req.headers, auth })
next()
})

Expand Down
9 changes: 7 additions & 2 deletions packages/devops-admin/src/api/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ export async function deleteFileBucket(bucketName) {
* @param {string} bucketName
* @returns
*/
export async function getFilesByBucketName(bucketName, { offset, limit }) {
export async function getFilesByBucketName(bucketName, { offset, limit, keyword }) {
assert(bucketName, 'empty `bucketName` got')
const _offset = offset || 0
const _limit = limit || 10
let query = `offset=${_offset}&limit=${_limit}`
if (keyword) {
query = query + `&keyword=${keyword}`
}

const res = await request({
url: `/file/${bucketName}/files?offset=${_offset}&limit=${_limit}`,
url: `/file/${bucketName}/files?${query}`,
method: 'GET'
})
assert(res.code === 0, `get files in ${bucketName} got error`, res)
Expand Down
2 changes: 1 addition & 1 deletion packages/devops-admin/src/router/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const asyncRoutes = [
meta: {
title: '文件列表',
icon: 'documentation',
noCache: true,
noCache: false,
permissions: ['file.read']
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devops-admin/src/views/dashboard/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="dashboard-container">
欢迎使用 less-framework 管理控制台
欢迎使用 LaF 开发运维控制台
</div>
</template>

Expand Down
16 changes: 9 additions & 7 deletions packages/devops-admin/src/views/database/buckets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<div class="app-container">
<!-- 数据检索区 -->
<div class="filter-container">
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="getList">
<el-button plain class="filter-item" type="default" icon="el-icon-search" @click="getList">
刷新
</el-button>
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="showCreateForm">
新建
<el-button plain class="filter-item" type="primary" icon="el-icon-plus" @click="showCreateForm">
新建文件桶
</el-button>
</div>

Expand All @@ -25,7 +25,7 @@
<span>{{ $index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="标识">
<el-table-column label="文件桶">
<template slot-scope="{row}">
<span>{{ row }}</span>
</template>
Expand Down Expand Up @@ -71,8 +71,8 @@

<script>
import * as fs from '@/api/file'
import { assert } from '@/utils/assert'
// @TODO
// 默认化创建表单的值
function getDefaultFormValue() {
return {
Expand Down Expand Up @@ -122,8 +122,9 @@ export default {
// 执行数据查询
const ret = await fs.getFileBuckets().catch(() => { this.listLoading = false })
this.list = ret.data
assert(ret.code === 0, 'get file buckets got error')
this.list = ret.data
this.listLoading = false
},
// 显示创建表单
Expand Down Expand Up @@ -158,7 +159,8 @@ export default {
message: '创建成功!'
})
this.getList()
// Quirks: 因 gridfs 创建 bucket 确有延迟,故等待刷新
setTimeout(() => this.getList(), 1000)
this.dialogFormVisible = false
})
},
Expand Down
Loading

0 comments on commit f3b383a

Please sign in to comment.