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.
300 lines
8.1 KiB
300 lines
8.1 KiB
3 years ago
|
<!-- eslint-disable -->
|
||
3 years ago
|
<template>
|
||
|
<div>
|
||
|
<v-toolbar flat height="42" class="toolbar-border-bottom">
|
||
|
<v-toolbar-title>
|
||
3 years ago
|
<v-breadcrumbs
|
||
2 years ago
|
:items="[
|
||
|
{
|
||
|
text: nodes.env,
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
{
|
||
|
text: 'Global ACL',
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
]"
|
||
3 years ago
|
divider=">"
|
||
|
small
|
||
|
>
|
||
|
<template #divider>
|
||
2 years ago
|
<v-icon small color="grey lighten-2"> forward </v-icon>
|
||
3 years ago
|
</template>
|
||
|
</v-breadcrumbs>
|
||
|
</v-toolbar-title>
|
||
3 years ago
|
<v-spacer />
|
||
2 years ago
|
<x-btn v-ge="['acl', 'reload']" outlined tooltip="Reload ACL" color="primary" small @click="loadAcls">
|
||
|
<v-icon small left> refresh </v-icon>
|
||
3 years ago
|
<!-- Reload -->
|
||
|
{{ $t('general.reload') }}
|
||
3 years ago
|
</x-btn>
|
||
|
|
||
3 years ago
|
<x-btn
|
||
2 years ago
|
v-ge="['acl', 'save']"
|
||
3 years ago
|
outlined
|
||
3 years ago
|
:tooltip="$t('tooltip.saveChanges')"
|
||
3 years ago
|
color="primary"
|
||
|
class="primary"
|
||
|
small
|
||
|
:disabled="disableSaveButton"
|
||
|
>
|
||
2 years ago
|
<v-icon small left> save </v-icon>
|
||
3 years ago
|
<!-- Save -->
|
||
|
{{ $t('general.save') }}
|
||
3 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>
|
||
3 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>
|
||
3 years ago
|
</template>
|
||
|
|
||
3 years ago
|
<th />
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th />
|
||
3 years ago
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
3 years ago
|
<th :key="`${role}-${method}`" width="25">
|
||
2 years ago
|
<v-checkbox dense hide-details />
|
||
3 years ago
|
</th>
|
||
3 years ago
|
</template>
|
||
|
</template>
|
||
3 years ago
|
|
||
|
<th width="25" />
|
||
3 years ago
|
</tr>
|
||
3 years ago
|
</thead>
|
||
|
<tbody>
|
||
2 years ago
|
<template v-for="(acl, table) in groupedData">
|
||
3 years ago
|
<tr :key="table + 'row'">
|
||
|
<td class="font-weight-bold">
|
||
|
{{ table }}
|
||
|
</td>
|
||
3 years ago
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
3 years ago
|
<td :key="`${role}-${method}`" width="25">
|
||
2 years ago
|
<v-checkbox dense hide-details />
|
||
3 years ago
|
</td>
|
||
|
</template>
|
||
|
</template>
|
||
3 years ago
|
<td width="25">
|
||
2 years ago
|
<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>
|
||
3 years ago
|
</td>
|
||
3 years ago
|
</tr>
|
||
2 years ago
|
<template v-for="(item, i) in groupedData[table]" v-if="expandedRow === table">
|
||
3 years ago
|
<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">
|
||
2 years ago
|
<v-checkbox dense hide-details />
|
||
3 years ago
|
</td>
|
||
|
</template>
|
||
|
</template>
|
||
|
<td width="25" />
|
||
|
</tr>
|
||
|
</template>
|
||
3 years ago
|
</template>
|
||
|
</tbody>
|
||
|
</v-simple-table>
|
||
|
|
||
3 years ago
|
<v-simple-table v-slot dense>
|
||
3 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>
|
||
3 years ago
|
</template>
|
||
|
|
||
3 years ago
|
<th />
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th />
|
||
3 years ago
|
<template v-for="role in roles">
|
||
|
<template v-for="method in methods">
|
||
3 years ago
|
<th :key="`${role}-${method}`" width="25">
|
||
2 years ago
|
<v-checkbox dense hide-details />
|
||
3 years ago
|
</th>
|
||
3 years ago
|
</template>
|
||
|
</template>
|
||
|
|
||
3 years ago
|
<th width="25" />
|
||
3 years ago
|
</tr>
|
||
3 years ago
|
</thead>
|
||
|
<tbody>
|
||
2 years ago
|
<template v-for="(acl, table) in groupedData">
|
||
3 years ago
|
<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">
|
||
2 years ago
|
<v-checkbox dense hide-details />
|
||
3 years ago
|
</td>
|
||
|
</template>
|
||
|
</template>
|
||
|
<td width="25">
|
||
2 years ago
|
<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>
|
||
3 years ago
|
</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>
|
||
3 years ago
|
</tbody>
|
||
|
</v-simple-table>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
/* eslint-disable */
|
||
3 years ago
|
|
||
2 years ago
|
import AclTsFileDbChild from '~/components/project/tableTabs/AclTsFileDbChild';
|
||
3 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'GlobalAcl',
|
||
|
components: { AclTsFileDbChild },
|
||
3 years ago
|
props: ['nodes'],
|
||
|
data: () => ({
|
||
|
loading: false,
|
||
|
edited: false,
|
||
|
data: null,
|
||
|
groupedData: null,
|
||
|
aclTabs: null,
|
||
|
expandedRow: null,
|
||
|
search: '',
|
||
2 years ago
|
roles: ['creator', 'editor', 'guest'],
|
||
|
methods: ['get', 'post', 'put', 'delete'],
|
||
3 years ago
|
}),
|
||
3 years ago
|
computed: {
|
||
2 years ago
|
tables() {
|
||
|
return this.groupedData ? Object.keys(this.groupedData) : [];
|
||
|
},
|
||
|
acls() {
|
||
|
return this.groupedData ? Object.values(this.groupedData) : [];
|
||
3 years ago
|
},
|
||
|
},
|
||
2 years ago
|
async created() {
|
||
|
await this.loadAcls();
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
2 years ago
|
async loadAcls() {
|
||
3 years ago
|
try {
|
||
2 years ago
|
const data = (
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.$store.state.project.authDbAlias,
|
||
|
},
|
||
|
'xcRoutesPolicyGet',
|
||
|
])
|
||
|
).data.list;
|
||
3 years ago
|
|
||
2 years ago
|
const groupedData = {};
|
||
3 years ago
|
|
||
|
for (const item of data) {
|
||
2 years ago
|
groupedData[item.table_name] = groupedData[item.table_name] || [];
|
||
|
groupedData[item.table_name].push(item);
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
this.groupedData = groupedData;
|
||
3 years ago
|
|
||
|
// for()
|
||
|
|
||
2 years ago
|
this.data = data;
|
||
3 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error('Failed loading role list').goAway(3000);
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
this.edited = false;
|
||
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
::v-deep {
|
||
|
table {
|
||
|
.expansion-row {
|
||
2 years ago
|
&,
|
||
|
td {
|
||
3 years ago
|
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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|