Skip to content

Commit

Permalink
fix(sys-client): fix func tags list; add owner role;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Sep 9, 2021
1 parent 5afecf9 commit 152d195
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 43 deletions.
11 changes: 11 additions & 0 deletions packages/system-client/src/api/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ export function getFunctions(query, page, pageSize) {
})
}

/**
* Get all tags of cloud functions
*/
export function getAllFunctionTags() {
const appid = store.state.app.appid
return request({
url: `/apps/${appid}/function/tags/all`,
method: 'get'
})
}

/**
* Get a cloud function
* @param {*} query
Expand Down
12 changes: 0 additions & 12 deletions packages/system-client/src/api/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,3 @@ export function removeTrigger(func_id, trigger_id) {
method: 'delete'
})
}

/**
* Publish triggers
* @returns
*/
export function publishTriggers() {
const appid = store.state.app.appid
return request({
url: `/apps/${appid}/function/publish/triggers`,
method: 'post'
})
}
3 changes: 1 addition & 2 deletions packages/system-client/src/router/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export const asyncRoutes = [
name: 'FunctionListPage',
meta: {
title: '云函数',
icon: 'bug',
noCache: true
icon: 'bug'
}
},
{
Expand Down
24 changes: 15 additions & 9 deletions packages/system-client/src/views/application/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
<el-button v-if="row.status === 'running'" :loading="serviceLoading" plain type="danger" size="mini" @click="stopApp(row)">
停止
</el-button>
<el-button v-if="row.status === 'stopped'" :loading="serviceLoading" plain type="default" size="mini" @click="removeAppService(row)">
清除
</el-button>
<el-tooltip content="仅清除应用服务实例,并[不会]删除应用或数据,请放心清除" effect="light" placement="bottom">
<el-button v-if="row.status === 'stopped'" :loading="serviceLoading" plain type="default" size="mini" @click="removeAppService(row)">
清除
</el-button>
</el-tooltip>

</template>
</el-table-column>
<el-table-column label="创建时间" align="center">
Expand Down Expand Up @@ -100,9 +103,11 @@
<el-button v-if="row.status === 'running'" :loading="serviceLoading" plain type="danger" size="mini" @click="stopApp(row)">
停止
</el-button>
<el-button v-if="row.status === 'stopped'" :loading="serviceLoading" plain type="default" size="mini" @click="removeAppService(row)">
清除
</el-button>
<el-tooltip content="仅清除应用服务实例,并[不会]删除应用或数据,请放心清除" effect="light" placement="bottom">
<el-button v-if="row.status === 'stopped'" :loading="serviceLoading" plain type="default" size="mini" @click="removeAppService(row)">
清除
</el-button>
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center">
Expand Down Expand Up @@ -155,7 +160,7 @@
</el-dialog>

<!-- 导入应用对话框 -->
<el-dialog v-if="importForm.app" v-loading="loading" title="导入应用" :visible.sync="dialogImportVisible">
<el-dialog v-if="importForm.app" title="导入应用" :visible.sync="dialogImportVisible">
<el-form
ref="importForm"
:rules="importFormRules"
Expand All @@ -169,7 +174,7 @@
</el-form-item>
<el-form-item label="选择应用文件" prop="file">
<el-upload
ref="upload"
ref="uploader"
action=""
:auto-upload="false"
:multiple="false"
Expand All @@ -186,7 +191,7 @@
<el-button @click="dialogImportVisible = false">
取消
</el-button>
<el-button type="primary" @click="handleImportApp">
<el-button :loading="loading" type="primary" @click="handleImportApp">
确定
</el-button>
</div>
Expand Down Expand Up @@ -399,6 +404,7 @@ export default {
this.dialogImportVisible = true
this.$nextTick(() => {
this.$refs['importForm'].clearValidate()
this.$refs['uploader'].clearFiles()
})
},
onImportFileChanged(data) {
Expand Down
8 changes: 3 additions & 5 deletions packages/system-client/src/views/cloudfunction/debug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,15 @@ export default {
*/
async launch() {
const debug_token = this.$store.state.app.debug_token
// await this.updateFunc(false)
await this.updateFunc(false)
if (this.loading) return
this.loading = true
await publishFunctions(this.appid)
const param = this.parseInvokeParam(this.invokeParams)
const res = await launchFunction(this.func.name, param, debug_token)
.catch(err => {
console.error(err)
this.$message.warning('运行失败: ' + err)
})
this.loading = false
this.$message.success('运行成功')
this.invokeResult = res
this.getLatestLogs()
Expand Down
8 changes: 4 additions & 4 deletions packages/system-client/src/views/cloudfunction/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<script>
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import DeployPanel from '../deploy/components/deploy-panel.vue'
import { createFunction, getFunctions, publishFunctions, removeFunction, updateFunction } from '@/api/func'
import { createFunction, getAllFunctionTags, getFunctions, publishFunctions, removeFunction, updateFunction } from '@/api/func'
const defaultCode = `
import cloud from '@/cloud-sdk'
Expand Down Expand Up @@ -274,9 +274,9 @@ export default {
methods: {
/** 获取所有标签 */
async getAllTags() {
// TODO
const tags = []
this.all_tags = Array.from(new Set(tags))
const res = await getAllFunctionTags()
this.all_tags = res.data
// this.all_tags = Array.from(new Set(tags))
},
/**
* 获取数据列表
Expand Down
10 changes: 1 addition & 9 deletions packages/system-client/src/views/cloudfunction/triggers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
<script>
import { getFunctionById } from '@/api/func'
import { createTrigger, removeTrigger, updateTrigger } from '@/api/trigger'
import { publishTriggers } from '@/api/trigger'
// 默认化创建表单的值
function getDefaultFormValue() {
Expand Down Expand Up @@ -220,10 +219,6 @@ export default {
this.list = r.data?.triggers || []
this.loading = false
},
// 发布触发器配置
async publishTrigger(triggerId) {
await publishTriggers()
},
// 显示创建表单
showCreateForm() {
this.form = getDefaultFormValue()
Expand Down Expand Up @@ -266,7 +261,6 @@ export default {
})
this.getFunction()
this.publishTrigger()
this.dialogFormVisible = false
})
},
Expand Down Expand Up @@ -308,7 +302,6 @@ export default {
})
this.getFunction()
this.publishTrigger()
this.dialogFormVisible = false
})
},
Expand Down Expand Up @@ -340,12 +333,11 @@ export default {
message: '删除成功!'
})
this.publishTrigger()
this.list.splice(index, 1)
},
// 查看触发器日志(跳转日志页)
showTriggerLogs(row) {
this.$router.push(`/development/logs?trigger_id=${row._id}`)
this.$router.push({ path: `../logs?trigger_id=${row._id}` })
},
// 设置标签标题
setTagViewTitle() {
Expand Down
6 changes: 4 additions & 2 deletions packages/system-client/src/views/collaborate/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,14 @@ export default {
},
getRoleLabel(role_name) {
switch (role_name) {
case 'owner':
return '应用管理员'
case 'dba':
return '数据库管理员'
return '数据管理员'
case 'developer':
return '开发者'
case 'operator':
return '运维'
return '运维工程师'
}
return 'Unknown'
}
Expand Down

0 comments on commit 152d195

Please sign in to comment.