mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
335 lines
8.6 KiB
335 lines
8.6 KiB
3 years ago
|
<!-- eslint-disable -->
|
||
4 years ago
|
<template>
|
||
|
<div>
|
||
|
<v-toolbar flat height="42" class="toolbar-border-bottom">
|
||
|
<v-toolbar-title>
|
||
3 years ago
|
<v-breadcrumbs
|
||
|
:items="[{
|
||
|
text: nodes.env,
|
||
|
disabled: true,
|
||
|
href: '#'
|
||
|
},
|
||
|
{
|
||
|
text: 'Global ACL',
|
||
|
disabled: true,
|
||
|
href: '#'
|
||
|
}]"
|
||
|
divider=">"
|
||
|
small
|
||
|
>
|
||
|
<template #divider>
|
||
|
<v-icon small color="grey lighten-2">
|
||
|
forward
|
||
|
</v-icon>
|
||
4 years ago
|
</template>
|
||
|
</v-breadcrumbs>
|
||
|
</v-toolbar-title>
|
||
3 years ago
|
<v-spacer />
|
||
|
<x-btn
|
||
|
v-ge="['acl','reload']"
|
||
|
outlined
|
||
|
tooltip="Reload ACL"
|
||
|
color="primary"
|
||
|
small
|
||
|
@click="loadAcls"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-icon small left>
|
||
|
refresh
|
||
|
</v-icon>
|
||
3 years ago
|
<!-- Reload -->
|
||
|
{{ $t('general.reload') }}
|
||
4 years ago
|
</x-btn>
|
||
|
|
||
3 years ago
|
<x-btn
|
||
|
v-ge="['acl','save']"
|
||
|
outlined
|
||
3 years ago
|
:tooltip="$t('tooltip.saveChanges')"
|
||
3 years ago
|
color="primary"
|
||
|
class="primary"
|
||
|
small
|
||
|
:disabled="disableSaveButton"
|
||
|
>
|
||
|
<v-icon small left>
|
||
|
save
|
||
|
</v-icon>
|
||
3 years ago
|
<!-- Save -->
|
||
|
{{ $t('general.save') }}
|
||
4 years ago
|
</x-btn>
|
||
|
</v-toolbar>
|
||
|
|
||
3 years ago
|
<v-text-field
|
||
|
v-model="search"
|
||
|
dense
|
||
|
hide-details
|
||
|
class="ma-2"
|
||
|
:placeholder="`Search routes`"
|
||
|
prepend-inner-icon="search"
|
||
|
outlined
|
||
|
/>
|
||
|
|
||
|
<v-simple-table v-if="true" v-slot dense>
|
||
4 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
|
<th>Table</th>
|
||
|
<th v-for="role in roles" :colspan="methods.length">
|
||
|
{{ role }}
|
||
|
</th>
|
||
|
<th width="25" />
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th />
|
||
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
|
<th :key="`${role}-${method}`" width="25">
|
||
|
{{ method }}
|
||
|
</th>
|
||
|
</template>
|
||
4 years ago
|
</template>
|
||
|
|
||
3 years ago
|
<th />
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th />
|
||
4 years ago
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
3 years ago
|
<th :key="`${role}-${method}`" width="25">
|
||
4 years ago
|
<v-checkbox
|
||
|
dense
|
||
|
hide-details
|
||
3 years ago
|
/>
|
||
|
</th>
|
||
4 years ago
|
</template>
|
||
|
</template>
|
||
3 years ago
|
|
||
|
<th width="25" />
|
||
4 years ago
|
</tr>
|
||
3 years ago
|
</thead>
|
||
|
<tbody>
|
||
|
<template v-for="(acl,table) in groupedData">
|
||
|
<tr :key="table + 'row'">
|
||
|
<td class="font-weight-bold">
|
||
|
{{ table }}
|
||
|
</td>
|
||
4 years ago
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
3 years ago
|
<td :key="`${role}-${method}`" width="25">
|
||
4 years ago
|
<v-checkbox
|
||
|
dense
|
||
|
hide-details
|
||
3 years ago
|
/>
|
||
4 years ago
|
</td>
|
||
|
</template>
|
||
|
</template>
|
||
3 years ago
|
<td width="25">
|
||
|
<v-icon v-if="expandedRow !== table" small @click="expandedRow=table">
|
||
|
mdi-chevron-down
|
||
|
</v-icon>
|
||
|
<v-icon v-else small @click="expandedRow=null">
|
||
|
mdi-chevron-up
|
||
|
</v-icon>
|
||
|
</td>
|
||
4 years ago
|
</tr>
|
||
3 years ago
|
<template v-for="(item,i) in groupedData[table]" v-if="expandedRow === table">
|
||
|
<tr v-if="item.path" :key="`${table}-row-${i}`">
|
||
|
<td class="caption">
|
||
|
{{ item.path }}
|
||
|
</td>
|
||
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
|
<td :key="`${role}-${method}`" width="25">
|
||
|
<v-checkbox
|
||
|
dense
|
||
|
hide-details
|
||
|
/>
|
||
|
</td>
|
||
|
</template>
|
||
|
</template>
|
||
|
<td width="25" />
|
||
|
</tr>
|
||
|
</template>
|
||
4 years ago
|
</template>
|
||
|
</tbody>
|
||
|
</v-simple-table>
|
||
|
|
||
3 years ago
|
<v-simple-table v-slot dense>
|
||
4 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
|
<th>Table</th>
|
||
|
<th v-for="role in roles" :colspan="methods.length">
|
||
|
{{ role }}
|
||
|
</th>
|
||
|
<th width="25" />
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th />
|
||
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
|
<th :key="`${role}-${method}`" width="25">
|
||
|
{{ method }}
|
||
|
</th>
|
||
|
</template>
|
||
4 years ago
|
</template>
|
||
|
|
||
3 years ago
|
<th />
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th />
|
||
4 years ago
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
3 years ago
|
<th :key="`${role}-${method}`" width="25">
|
||
4 years ago
|
<v-checkbox
|
||
|
dense
|
||
|
hide-details
|
||
3 years ago
|
/>
|
||
|
</th>
|
||
4 years ago
|
</template>
|
||
|
</template>
|
||
|
|
||
3 years ago
|
<th width="25" />
|
||
4 years ago
|
</tr>
|
||
3 years ago
|
</thead>
|
||
|
<tbody>
|
||
|
<template v-for="(acl,table) in groupedData">
|
||
|
<tr :key="table + 'row'">
|
||
|
<td>{{ table }}</td>
|
||
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
|
<td :key="`${role}-${method}`" width="25">
|
||
|
<v-checkbox
|
||
|
dense
|
||
|
hide-details
|
||
|
/>
|
||
|
</td>
|
||
|
</template>
|
||
|
</template>
|
||
|
<td width="25">
|
||
|
<v-icon v-if="expandedRow !== table" small @click="expandedRow=table">
|
||
|
mdi-chevron-down
|
||
|
</v-icon>
|
||
|
<v-icon v-else small @click="expandedRow=null">
|
||
|
mdi-chevron-up
|
||
|
</v-icon>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr v-if="expandedRow === table" :key="table + 'exp'" class="expansion-row">
|
||
|
<td :colspan="methods.length * roles.length + 2" class="pa-1">
|
||
|
<acl-ts-file-db-child
|
||
|
v-if="groupedData"
|
||
|
key="acl"
|
||
|
:search="search"
|
||
|
:nodes="nodes"
|
||
|
:policies="groupedData[table]"
|
||
|
/>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</template>
|
||
4 years ago
|
</tbody>
|
||
|
</v-simple-table>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
/* eslint-disable */
|
||
4 years ago
|
|
||
3 years ago
|
import AclTsFileDbChild from '~/components/project/tableTabs/AclTsFileDbChild'
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'GlobalAcl',
|
||
|
components: { AclTsFileDbChild },
|
||
4 years ago
|
props: ['nodes'],
|
||
|
data: () => ({
|
||
|
loading: false,
|
||
|
edited: false,
|
||
|
data: null,
|
||
|
groupedData: null,
|
||
|
aclTabs: null,
|
||
|
expandedRow: null,
|
||
|
search: '',
|
||
|
roles: [
|
||
|
'creator',
|
||
|
'editor',
|
||
|
'guest'
|
||
|
],
|
||
|
methods: [
|
||
|
'get', 'post', 'put', 'delete'
|
||
3 years ago
|
]
|
||
4 years ago
|
}),
|
||
3 years ago
|
computed: {
|
||
|
tables () {
|
||
|
return this.groupedData ? Object.keys(this.groupedData) : []
|
||
|
},
|
||
|
acls () {
|
||
|
return this.groupedData ? Object.values(this.groupedData) : []
|
||
|
}
|
||
|
},
|
||
|
async created () {
|
||
|
await this.loadAcls()
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
async loadAcls () {
|
||
4 years ago
|
try {
|
||
|
const data = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.$store.state.project.authDbAlias
|
||
3 years ago
|
}, 'xcRoutesPolicyGet'])).data.list
|
||
4 years ago
|
|
||
3 years ago
|
const groupedData = {}
|
||
4 years ago
|
|
||
|
for (const item of data) {
|
||
3 years ago
|
groupedData[item.table_name] = groupedData[item.table_name] || []
|
||
|
groupedData[item.table_name].push(item)
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
this.groupedData = groupedData
|
||
4 years ago
|
|
||
|
// for()
|
||
|
|
||
3 years ago
|
this.data = data
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error('Failed loading role list').goAway(3000)
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
this.edited = false
|
||
|
}
|
||
4 years ago
|
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
::v-deep {
|
||
|
table {
|
||
|
.expansion-row {
|
||
|
&, td {
|
||
|
height: auto !important;
|
||
|
background: transparent !important;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|