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.
257 lines
7.8 KiB
257 lines
7.8 KiB
3 years ago
|
<template>
|
||
3 years ago
|
<v-container v-if="db" fluid>
|
||
3 years ago
|
<v-card>
|
||
|
<v-card class="pb-2">
|
||
|
<v-toolbar flat height="50" class="toolbar-border-bottom">
|
||
3 years ago
|
<v-text-field
|
||
|
v-if="db"
|
||
|
v-model="filter"
|
||
|
dense
|
||
|
hide-details
|
||
|
class="my-2 mx-auto search-field"
|
||
3 years ago
|
placeholder="Search models"
|
||
3 years ago
|
style="max-width: 300px"
|
||
3 years ago
|
outlined
|
||
|
>
|
||
|
<template #prepend-inner>
|
||
3 years ago
|
<v-icon small>
|
||
|
search
|
||
|
</v-icon>
|
||
3 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"
|
||
3 years ago
|
class="nc-acl-reload"
|
||
3 years ago
|
@click="loadTableList()"
|
||
|
>
|
||
3 years ago
|
Reload
|
||
3 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"
|
||
3 years ago
|
class="nc-acl-save"
|
||
3 years ago
|
@click="save()"
|
||
|
>
|
||
3 years ago
|
<!-- Save -->
|
||
3 years ago
|
{{ $t("general.save") }}
|
||
3 years ago
|
</x-btn>
|
||
|
</v-toolbar>
|
||
|
|
||
|
<div class="d-flex d-100 justify-center">
|
||
3 years ago
|
<v-simple-table v-if="tables" dense style="min-width: 400px">
|
||
3 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
3 years ago
|
<th class="caption" width="100px">
|
||
3 years ago
|
<!--TableName-->
|
||
3 years ago
|
{{ $t("labels.tableName") }}
|
||
3 years ago
|
</th>
|
||
3 years ago
|
<th class="caption" width="150px">
|
||
3 years ago
|
<!--ViewName-->
|
||
3 years ago
|
{{ $t("labels.viewName") }}
|
||
3 years ago
|
</th>
|
||
3 years ago
|
<th
|
||
|
v-for="role in roles"
|
||
|
:key="role"
|
||
|
class="caption"
|
||
|
width="100px"
|
||
|
>
|
||
3 years ago
|
{{ role.charAt(0).toUpperCase() + role.slice(1) }}
|
||
3 years ago
|
</th>
|
||
|
</tr>
|
||
3 years ago
|
</thead>
|
||
|
<tbody>
|
||
3 years ago
|
<template v-for="table in tables">
|
||
3 years ago
|
<tr
|
||
3 years ago
|
v-if="
|
||
|
table.title.toLowerCase().indexOf(filter.toLowerCase()) > -1
|
||
|
"
|
||
3 years ago
|
:key="table.table_name"
|
||
|
:class="`nc-acl-table-row nc-acl-table-row-${table.title}`"
|
||
3 years ago
|
>
|
||
|
<td>
|
||
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<span class="caption ml-2" v-on="on">{{
|
||
|
table.ptype === "table"
|
||
|
? table._ptn
|
||
|
: table.ptype === "view"
|
||
3 years ago
|
? table._ptn
|
||
|
: table._ptn
|
||
3 years ago
|
}}</span>
|
||
3 years ago
|
</template>
|
||
3 years ago
|
<span class="caption">{{ table.ptn || table._ptn }}</span>
|
||
3 years ago
|
</v-tooltip>
|
||
|
</td>
|
||
3 years ago
|
<td>
|
||
3 years ago
|
<v-icon
|
||
|
small
|
||
|
:color="viewIcons[table.type].color"
|
||
|
v-on="on"
|
||
|
>
|
||
3 years ago
|
{{ viewIcons[table.type].icon }}
|
||
3 years ago
|
</v-icon>
|
||
3 years ago
|
<span v-if="table.ptn" class="caption">{{
|
||
|
table.title
|
||
|
}}</span>
|
||
|
<span v-else class="caption">{{
|
||
|
$t("general.default")
|
||
|
}}</span>
|
||
3 years ago
|
<!-- {{ table.show_as || table.type }}-->
|
||
|
</td>
|
||
3 years ago
|
<td
|
||
|
v-for="role in roles"
|
||
|
:key="`${table.table_name}-${role}`"
|
||
|
>
|
||
3 years ago
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<div v-on="on">
|
||
3 years ago
|
<v-checkbox
|
||
|
v-model="table.disabled[role]"
|
||
3 years ago
|
:class="`pt-0 mt-0 nc-acl-${table.title
|
||
|
.toLowerCase()
|
||
|
.replace('_', '')}-${role}-chkbox`"
|
||
3 years ago
|
dense
|
||
3 years ago
|
hide-details
|
||
3 years ago
|
:true-value="false"
|
||
|
:false-value="true"
|
||
3 years ago
|
@change="$set(table, 'edited', true)"
|
||
3 years ago
|
/>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
3 years ago
|
<span v-if="table.disabled[role]">Click to make '{{ table.table_name }}' visible for
|
||
|
Role:{{ role }} in UI dashboard</span>
|
||
|
<span v-else>Click to hide '{{ table.table_name }}' for Role:{{
|
||
|
role
|
||
|
}}
|
||
|
in UI dashboard</span>
|
||
3 years ago
|
</v-tooltip>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</template>
|
||
3 years ago
|
</tbody>
|
||
|
</v-simple-table>
|
||
3 years ago
|
<v-skeleton-loader v-else type="table" />
|
||
3 years ago
|
</div>
|
||
|
</v-card>
|
||
|
</v-card>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { mapGetters } from 'vuex'
|
||
|
import viewIcons from '~/helpers/viewIcons'
|
||
3 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'ToggleTableUiAcl',
|
||
3 years ago
|
components: {},
|
||
3 years ago
|
props: ['nodes', 'db'],
|
||
3 years ago
|
data: () => ({
|
||
3 years ago
|
viewIcons,
|
||
3 years ago
|
models: null,
|
||
|
updating: false,
|
||
|
dbsTab: 0,
|
||
3 years ago
|
filter: '',
|
||
|
tables: null
|
||
3 years ago
|
}),
|
||
3 years ago
|
async mounted() {
|
||
3 years ago
|
await this.loadTableList()
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
async loadTableList() {
|
||
3 years ago
|
this.tables = await this.$api.project.modelVisibilityList(
|
||
|
this.db.project_id,
|
||
|
{
|
||
3 years ago
|
includeM2M: this.$store.state.settings.includeM2M || ''
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
3 years ago
|
// this.tables = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
|
||
|
// dbAlias: this.db.meta.dbAlias,
|
||
|
// env: this.$store.getters['project/GtrEnv']
|
||
|
// }, 'xcVisibilityMetaGet', {
|
||
|
// type: 'all'
|
||
|
// }]))
|
||
3 years ago
|
},
|
||
3 years ago
|
async save() {
|
||
3 years ago
|
try {
|
||
3 years ago
|
await this.$api.project.modelVisibilitySet(
|
||
|
this.db.project_id,
|
||
3 years ago
|
this.tables.filter(t => t.edited)
|
||
|
)
|
||
3 years ago
|
this.$toast
|
||
3 years ago
|
.success('Updated UI ACL for tables successfully')
|
||
|
.goAway(3000)
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.message).goAway(3000)
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('a:proj-meta:ui-acl')
|
||
|
}
|
||
3 years ago
|
},
|
||
|
computed: {
|
||
|
...mapGetters({
|
||
3 years ago
|
dbAliasList: 'project/GtrDbAliasList'
|
||
3 years ago
|
}),
|
||
3 years ago
|
edited() {
|
||
3 years ago
|
return (
|
||
3 years ago
|
this.tables && this.tables.length && this.tables.some(t => t.edited)
|
||
|
)
|
||
3 years ago
|
},
|
||
3 years ago
|
roles() {
|
||
3 years ago
|
return ['editor', 'commenter', 'viewer'] // this.tables && this.tables.length ? Object.keys(this.tables[0].disabled) : []
|
||
|
}
|
||
|
}
|
||
|
}
|
||
3 years ago
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
::v-deep {
|
||
|
.v-tabs-bar {
|
||
|
border-bottom: solid 1px #7f828b33;
|
||
|
}
|
||
|
|
||
|
.v-tab {
|
||
|
border-right: 1px solid #7f828b33;
|
||
|
}
|
||
|
|
||
3 years ago
|
.search-field.v-text-field > .v-input__control,
|
||
|
.search-field.v-text-field > .v-input__control > .v-input__slot {
|
||
3 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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|