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.
201 lines
5.8 KiB
201 lines
5.8 KiB
4 years ago
|
<template>
|
||
3 years ago
|
<v-container v-if="db" fluid>
|
||
4 years ago
|
<v-card>
|
||
|
<v-card class="pb-2">
|
||
|
<v-toolbar flat height="50" class="toolbar-border-bottom">
|
||
3 years ago
|
<v-text-field
|
||
2 years ago
|
v-if="db"
|
||
3 years ago
|
v-model="filter"
|
||
|
dense
|
||
|
hide-details
|
||
|
class="my-2 mx-auto search-field"
|
||
|
:placeholder="`Search '${db.connection.database}' models`"
|
||
2 years ago
|
style="max-width: 300px"
|
||
3 years ago
|
outlined
|
||
|
>
|
||
|
<template #prepend-inner>
|
||
2 years ago
|
<v-icon small> search </v-icon>
|
||
4 years ago
|
</template>
|
||
|
</v-text-field>
|
||
|
|
||
3 years ago
|
<v-spacer />
|
||
|
<x-btn
|
||
|
outlined
|
||
3 years ago
|
:tooltip="$t('tooltip.reloadList')"
|
||
3 years ago
|
small
|
||
|
color="primary"
|
||
|
icon="refresh"
|
||
|
@click="loadFunctionList()"
|
||
|
>
|
||
3 years ago
|
<!-- Reload -->
|
||
|
{{ $t('general.reload') }}
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
|
outlined
|
||
|
:loading="updating"
|
||
|
:disabled="updating || !edited"
|
||
3 years ago
|
:tooltip="$t('tooltip.saveChanges')"
|
||
3 years ago
|
small
|
||
|
color="primary"
|
||
|
icon="save"
|
||
|
@click="save()"
|
||
|
>
|
||
3 years ago
|
<!-- Save -->
|
||
|
{{ $t('general.save') }}
|
||
4 years ago
|
</x-btn>
|
||
|
</v-toolbar>
|
||
|
|
||
|
<div class="d-flex d-100 justify-center">
|
||
3 years ago
|
<v-simple-table dense style="min-width: 400px">
|
||
4 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
2 years ago
|
<th>Models</th>
|
||
3 years ago
|
<th v-for="role in roles" :key="role">
|
||
|
{{ role }}
|
||
|
</th>
|
||
|
</tr>
|
||
4 years ago
|
</thead>
|
||
|
<tbody>
|
||
2 years ago
|
<template v-for="functionObj in functions">
|
||
3 years ago
|
<tr
|
||
|
v-if="functionObj.function_name.toLowerCase().indexOf(filter.toLowerCase()) > -1"
|
||
|
:key="functionObj.function_name"
|
||
|
>
|
||
|
<td>{{ functionObj.function_name }}</td>
|
||
|
<td v-for="role in roles" :key="`${functionObj.function_name}-${role}`">
|
||
|
<v-tooltip bottom>
|
||
2 years ago
|
<template #activator="{ on }">
|
||
|
<div v-on="on">
|
||
3 years ago
|
<v-checkbox
|
||
|
v-model="functionObj.disabled[role]"
|
||
|
dense
|
||
|
:true-value="false"
|
||
|
:false-value="true"
|
||
2 years ago
|
@change="$set(functionObj, 'edited', true)"
|
||
3 years ago
|
/>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
2 years ago
|
<span v-if="functionObj.disabled[role]"
|
||
|
>Click to hide '{{ functionObj.function_name }}' for Role:{{ role }} in UI dashboard</span
|
||
|
>
|
||
|
<span v-else
|
||
|
>Click to make '{{ functionObj.function_name }}' visible for Role:{{ role }} in UI
|
||
|
dashboard</span
|
||
|
>
|
||
3 years ago
|
</v-tooltip>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</template>
|
||
4 years ago
|
</tbody>
|
||
|
</v-simple-table>
|
||
|
</div>
|
||
|
</v-card>
|
||
|
</v-card>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import { mapGetters } from 'vuex';
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'ToggleFunctionUiAcl',
|
||
4 years ago
|
components: {},
|
||
3 years ago
|
props: ['nodes', 'db'],
|
||
4 years ago
|
data: () => ({
|
||
|
models: null,
|
||
|
updating: false,
|
||
|
dbsTab: 0,
|
||
|
filter: '',
|
||
2 years ago
|
functions: null,
|
||
4 years ago
|
}),
|
||
3 years ago
|
async mounted() {
|
||
2 years ago
|
await this.loadFunctionList();
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
async loadFunctionList() {
|
||
2 years ago
|
this.functions = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
dbAlias: this.db.meta.dbAlias,
|
||
|
env: this.$store.getters['project/GtrEnv'],
|
||
|
},
|
||
|
'xcVisibilityMetaGet',
|
||
|
{
|
||
|
type: 'function',
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
},
|
||
3 years ago
|
async save() {
|
||
4 years ago
|
try {
|
||
2 years ago
|
await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
dbAlias: this.db.meta.dbAlias,
|
||
|
env: this.$store.getters['project/GtrEnv'],
|
||
|
},
|
||
|
'xcVisibilityMetaSet',
|
||
|
{
|
||
|
type: 'function',
|
||
|
disableList: this.functions.filter(t => t.edited),
|
||
|
},
|
||
|
]);
|
||
|
this.$toast.success('Updated UI ACL for tables successfully').goAway(3000);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error('Some error occurred').goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
},
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
|
...mapGetters({
|
||
2 years ago
|
dbAliasList: 'project/GtrDbAliasList',
|
||
4 years ago
|
}),
|
||
3 years ago
|
edited() {
|
||
2 years ago
|
return this.functions && this.functions.length && this.functions.some(t => t.edited);
|
||
4 years ago
|
},
|
||
3 years ago
|
roles() {
|
||
2 years ago
|
return this.functions && this.functions.length ? Object.keys(this.functions[0].disabled) : [];
|
||
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
::v-deep {
|
||
|
.v-tabs-bar {
|
||
|
border-bottom: solid 1px #7f828b33;
|
||
|
}
|
||
|
|
||
|
.v-tab {
|
||
|
border-right: 1px solid #7f828b33;
|
||
|
}
|
||
|
|
||
2 years ago
|
.search-field.v-text-field > .v-input__control,
|
||
|
.search-field.v-text-field > .v-input__control > .v-input__slot {
|
||
4 years ago
|
min-height: auto;
|
||
|
}
|
||
|
}
|
||
|
</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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|