Skip to content

Commit

Permalink
feat(admin): enhance perm table, add buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Dec 30, 2023
1 parent 785f0a4 commit d34abc0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
50 changes: 34 additions & 16 deletions plugins/admin/client/group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@

<h2 class="k-schema-header">权限列表</h2>
<template v-if="permissions.length">
<ul>
<li v-for="(permission, index) in permissions">
<permission-name :id="permission" />
<el-button @click="removePermission(index)">删除</el-button>
</li>
</ul>
<table class="perm-table">
<tr v-for="(permission, index) in permissions" :key="index">
<td class="text-left"><permission-name :id="permission" /></td>
<td class="text-right">
<el-button v-if="getLink(permission)" @click="router.push(getLink(permission))">前往</el-button>
<el-button @click="removePermission(index)">删除</el-button>
</td>
</tr>
</table>
</template>
<p v-else>该用户组没有权限。</p>

<el-select v-model="permission">
<el-option
v-for="id in store.permissions.filter(item => (active.type === 'track' ? item.startsWith('group.') : true) && !permissions.includes(item))"
Expand Down Expand Up @@ -87,12 +91,12 @@
</template>
</el-dialog>

<el-dialog v-model="showUserDialog" destroy-on-close title="用户管理">
<el-input v-model="platform" placeholder="平台名"/>
<el-input v-model="account" placeholder="账号"/>
<el-dialog class="user-dialog" v-model="showUserDialog" destroy-on-close title="用户管理">
<div class="my-4"><el-input v-model="platform" placeholder="平台名"/></div>
<div class="my-4"><el-input v-model="account" placeholder="账号"/></div>
<template #footer>
<el-button @click="removeUser">从用户组移除</el-button>
<el-button @click="addUser">添加到用户组</el-button>
<el-button type="primary" @click="removeUser">从用户组移除</el-button>
<el-button type="primary" @click="addUser">添加到用户组</el-button>
</template>
</el-dialog>
</template>
Expand Down Expand Up @@ -227,6 +231,16 @@ async function removeUser() {
showUserDialog.value = false
}
function getLink(name: string) {
if (name.startsWith('group.')) {
return `/admin/group/${name.slice(6)}`
} else if (name.startsWith('track.')) {
return `/admin/track/${name.slice(6)}`
} else if (name.startsWith('command.')) {
return `/commands/${name.slice(8).replace(/\./g, '/')}`
}
}
</script>

<style lang="scss">
Expand All @@ -245,6 +259,15 @@ async function removeUser() {
}
}
.perm-table {
margin: 1rem 0;
tr:hover {
transition: var(--color-transition);
background-color: var(--k-side-bg);
}
}
.rename-input {
border: none;
outline: none;
Expand All @@ -254,11 +277,6 @@ async function removeUser() {
background: transparent;
}
.el-button-group.text-center {
display: flex;
justify-content: center;
}
.create-dialog {
.el-input.invalid .el-input__wrapper {
box-shadow: 0 0 0 1px var(--el-color-danger) inset;
Expand Down
4 changes: 2 additions & 2 deletions plugins/admin/client/icons/activity.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<svg class="k-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512">
<path fill="currentColor" d="M319.9 320c57.41 0 103.1-46.56 103.1-104c0-57.44-46.54-104-103.1-104c-57.41 0-103.1 46.56-103.1 104C215.9 273.4 262.5 320 319.9 320zM319.9 144c39.68 0 71.96 32.3 71.96 72S359.5 288 319.9 288S247.9 255.7 247.9 216S280.2 144 319.9 144zM369.9 352H270.1C191.6 352 128 411.7 128 485.3C128 500.1 140.7 512 156.4 512h327.2C499.3 512 512 500.1 512 485.3C512 411.7 448.4 352 369.9 352zM160.2 480c3.021-53.41 51.19-96 109.1-96H369.9c58.78 0 106.9 42.59 109.1 96H160.2zM512 160c44.18 0 80-35.82 80-80S556.2 0 512 0c-44.18 0-80 35.82-80 80S467.8 160 512 160zM512 32c26.47 0 48 21.53 48 48S538.5 128 512 128s-48-21.53-48-48S485.5 32 512 32zM128 160c44.18 0 80-35.82 80-80S172.2 0 128 0C83.82 0 48 35.82 48 80S83.82 160 128 160zM128 32c26.47 0 48 21.53 48 48S154.5 128 128 128S80 106.5 80 80S101.5 32 128 32zM561.1 192H496c-11.16 0-22.08 2.5-32.47 7.438c-7.984 3.797-11.39 13.34-7.594 21.31s13.38 11.39 21.31 7.594C483.3 225.5 489.6 224 496 224h65.08C586.1 224 608 246.7 608 274.7V288c0 8.844 7.156 16 16 16S640 296.8 640 288V274.7C640 229.1 604.6 192 561.1 192zM162.8 228.3c7.938 3.797 17.53 .375 21.31-7.594c3.797-7.969 .3906-17.52-7.594-21.31C166.1 194.5 155.2 192 144 192H78.92C35.41 192 0 229.1 0 274.7V288c0 8.844 7.156 16 16 16S32 296.8 32 288V274.7C32 246.7 53.05 224 78.92 224H144C150.4 224 156.7 225.5 162.8 228.3z"/>
<path fill="currentColor" d="M274.7 304H173.3c-95.73 0-173.3 77.6-173.3 173.3C0 496.5 15.52 512 34.66 512H413.3C432.5 512 448 496.5 448 477.3C448 381.6 370.4 304 274.7 304zM413.3 480H34.66C33.2 480 32 478.8 32 477.3C32 399.4 95.4 336 173.3 336H274.7C352.6 336 416 399.4 416 477.3C416 478.8 414.8 480 413.3 480zM224 256c70.7 0 128-57.31 128-128S294.7 0 224 0C153.3 0 96 57.31 96 128S153.3 256 224 256zM224 32c52.94 0 96 43.06 96 96c0 52.93-43.06 96-96 96S128 180.9 128 128C128 75.06 171.1 32 224 32zM375.1 241C392.9 250.8 412.3 256 432 256C493.8 256 544 205.8 544 144S493.8 32 432 32c-12.83 0-25.39 2.156-37.34 6.391c-8.328 2.953-12.69 12.09-9.734 20.42c2.953 8.344 12.12 12.66 20.42 9.734C413.9 65.53 422.8 64 432 64C476.1 64 512 99.89 512 144S476.1 224 432 224c-14.08 0-27.91-3.703-39.98-10.69c-7.656-4.453-17.44-1.828-21.86 5.828C365.7 226.8 368.3 236.6 375.1 241zM490.7 320H448c-8.844 0-16 7.156-16 16S439.2 352 448 352h42.67C555.4 352 608 404.6 608 469.3C608 475.2 603.2 480 597.3 480H496c-8.844 0-16 7.156-16 16s7.156 16 16 16h101.3C620.9 512 640 492.9 640 469.3C640 386.1 573 320 490.7 320z"/>
</svg>
</template>
</template>

0 comments on commit d34abc0

Please sign in to comment.