Skip to content

Commit 004fa1c

Browse files
ymh6315431minghao.yang
and
minghao.yang
authored
feat(serverless): add routes and comment out search input in admin list (#1084)
* Draft MR * feat(serverless): add routes and comment out search input in admin list --------- Co-authored-by: minghao.yang <[email protected]>
1 parent 0721029 commit 004fa1c

File tree

5 files changed

+154
-2
lines changed

5 files changed

+154
-2
lines changed
Loading

frontend/src/components/admin_next/router/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import AdminTagCategoriesForm from "../tag_categories/AdminTagCategoriesForm.vue
1414
import AdminModelDetail from "../models/AdminModelDetail.vue";
1515
import AdminModelList from "../models/AdminModelList.vue";
1616
import AdminModelEdit from "../models/AdminModelEdit.vue";
17+
18+
import AdminServerlessList from '../serverless/AdminServerlessList.vue'
1719
import AdminServerlessForm from '../serverless/AdminServerlessForm.vue'
1820
import AdminServerlessDetail from '../serverless/AdminServerlessDetail.vue'
1921
import { Setting, User, Connection } from "@element-plus/icons-vue";
@@ -107,6 +109,14 @@ export const MENU_SETTING = [
107109
name: adminLocale.models.modelEdit,
108110
parentName: PARENT_NAME.hub
109111
},
112+
{
113+
path: `${BASE_URL}/serverless`,
114+
component: AdminServerlessList,
115+
name: adminLocale.serverless.title,
116+
parentName: PARENT_NAME.hub,
117+
icon: 'admin-menu-serverless',
118+
type: 'menu'
119+
},
110120
{
111121
path: `${BASE_URL}/serverless/:namespace/:name/new`,
112122
component: AdminServerlessForm,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<template>
2+
<Container
3+
type="serverless"
4+
:title="$t('admin.serverless.title')"
5+
subtitle=""
6+
:breadcrumbs="[{ text: $t('admin.serverless.title') }]"
7+
>
8+
<!-- search & filter -->
9+
<!-- <div class="flex items-center gap-3 w-full pt-1">
10+
<el-input
11+
v-model="keyword"
12+
:placeholder="$t('admin.name') + ',' + $t('admin.owner')"
13+
size="large"
14+
:prefix-icon="Search"
15+
@input="searchServerless"
16+
/>
17+
</div> -->
18+
<Table
19+
:title="$t('admin.serverless.listTitle')"
20+
:data="serverless"
21+
size="small"
22+
:border="false"
23+
class="custom-table"
24+
>
25+
<el-table-column :label="$t('admin.serverless.deployName')" min-width="200" show-overflow-tooltip>
26+
<template #default="scope">
27+
<a
28+
:href="`/admin_panel/serverless/${scope.row.model_id}/${scope.row.deploy_id}`"
29+
target="_blank"
30+
class="underline"
31+
>
32+
{{ scope.row.deploy_name }}
33+
</a>
34+
</template>
35+
</el-table-column>
36+
<el-table-column
37+
prop="hardware"
38+
:label="$t('admin.serverless.resource')"
39+
min-width="240"
40+
show-overflow-tooltip
41+
/>
42+
<el-table-column
43+
prop="runtime_framework"
44+
:label="$t('admin.serverless.runtimeFramework')"
45+
width="130"
46+
/>
47+
<el-table-column
48+
prop="status"
49+
:label="$t('admin.serverless.status')"
50+
min-width="100"
51+
/>
52+
<el-table-column
53+
:label="$t('admin.operations')"
54+
width="260px"
55+
fixed="right"
56+
>
57+
<template #default="scope">
58+
<div class="flex gap-2">
59+
<CsgButton
60+
class="btn btn-secondary-gray btn-sm"
61+
:name="$t('admin.serverless.detail')"
62+
@click="showDetail(scope.row)"
63+
/>
64+
<CsgButton
65+
class="btn btn-primary btn-sm"
66+
:name="$t('admin.serverless.edit')"
67+
@click="shoeEdit(scope.row)"
68+
/>
69+
</div>
70+
</template>
71+
</el-table-column>
72+
<template #footer>
73+
<Pagination
74+
v-model:current-page="page"
75+
:page-size="per"
76+
layout="prev, pager, next"
77+
:total="total"
78+
@current-change="fetchServerless"
79+
/>
80+
</template>
81+
</Table>
82+
</Container>
83+
</template>
84+
85+
<script setup>
86+
import { Container, Pagination, Table } from '../admin_component'
87+
import { ref, onMounted, inject } from 'vue'
88+
import { Search } from '@element-plus/icons-vue'
89+
import { ElMessage } from 'element-plus'
90+
import useFetchApi from '../../../packs/useFetchApi'
91+
import useUserStore from '@/stores/UserStore'
92+
93+
const userStore = useUserStore()
94+
95+
const serverless = ref([])
96+
const page = ref(1)
97+
const per = ref(10)
98+
const total = ref(0)
99+
const keyword = ref('')
100+
101+
const fetchServerless = async (current) => {
102+
const { data, error } = await useFetchApi(
103+
`/user/${userStore.username}/run/serverless?page=${
104+
current || page.value
105+
}&per=${per.value}&search=${keyword.value}`
106+
).json()
107+
if (data.value) {
108+
const res_json = data.value
109+
serverless.value = res_json.data
110+
total.value = res_json.total
111+
} else {
112+
ElMessage.error(error.value.msg || 'Failed to fetch serverless')
113+
}
114+
}
115+
116+
const searchServerless = () => {
117+
page.value = 1
118+
fetchServerless()
119+
}
120+
121+
const showDetail = (detail) => {
122+
window.location.href = `/admin_panel/serverless/${detail.model_id}/${detail.deploy_id}`
123+
}
124+
125+
const shoeEdit = (detail) => {
126+
window.location.href = `/admin_panel/serverless/${detail.model_id}/${detail.deploy_id}/edit`
127+
}
128+
129+
onMounted(() => {
130+
fetchServerless()
131+
})
132+
</script>

frontend/src/locales/en_js/admin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const admin = {
6363
sync: 'Sync'
6464
},
6565
serverless: {
66-
title: 'Serverless Management',
66+
title: 'Serverless APIs',
6767
listTitle: 'Serverless List',
6868
detailTitle: 'Serverless Detail',
6969
newTitle: 'New Serverless',

frontend/src/locales/zh_js/admin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const admin = {
6363
sync:'同步'
6464
},
6565
serverless: {
66-
title: 'Serverless 管理',
66+
title: '公共推理服务',
6767
listTitle: 'Serverless 列表',
6868
detailTitle: 'Serverless 详情',
6969
newTitle: '新建 Serverless',

0 commit comments

Comments
 (0)