mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 12:03:58 +00:00
storage permissions
This commit is contained in:
@@ -42,14 +42,16 @@
|
||||
const connections = await apiCall('connections/list');
|
||||
const settings = await getSettings();
|
||||
const apps = await getUsedApps();
|
||||
loadedApi = settings && connections && config && apps;
|
||||
const loadedApiValue = !!(settings && connections && config && apps);
|
||||
|
||||
if (loadedApi) {
|
||||
if (loadedApiValue) {
|
||||
subscribeApiDependendStores();
|
||||
subscribeConnectionPingers();
|
||||
subscribePermissionCompiler();
|
||||
}
|
||||
|
||||
loadedApi = loadedApiValue;
|
||||
|
||||
if (!loadedApi) {
|
||||
console.log('API not initialized correctly, trying again in 1s');
|
||||
setTimeout(loadApi, 1000);
|
||||
|
||||
@@ -4,13 +4,17 @@ import { useConfig } from './metadataLoaders';
|
||||
let compiled = null;
|
||||
|
||||
export default function hasPermission(tested) {
|
||||
// console.log('TESTING PERM', tested, compiled, testPermission(tested, compiled));
|
||||
return testPermission(tested, compiled);
|
||||
}
|
||||
|
||||
export function subscribePermissionCompiler() {
|
||||
// console.log('subscribePermissionCompiler', compiled);
|
||||
|
||||
useConfig().subscribe(value => {
|
||||
if (!value) return;
|
||||
const { permissions } = value;
|
||||
compiled = compilePermissions(permissions);
|
||||
// console.log('COMPILED PERMS', compiled);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,20 +12,17 @@
|
||||
} from '../stores';
|
||||
import mainMenuDefinition from '../../../../app/src/mainMenuDefinition';
|
||||
import hasPermission from '../utility/hasPermission';
|
||||
import { isAdminPage } from '../utility/pageDefs';
|
||||
|
||||
let domSettings;
|
||||
let domMainMenu;
|
||||
|
||||
const isAdmin = isAdminPage();
|
||||
|
||||
const widgets = [
|
||||
getCurrentConfig().storageDatabase && {
|
||||
icon: 'icon admin',
|
||||
name: 'admin',
|
||||
title: 'Administration',
|
||||
},
|
||||
!isAdmin && {
|
||||
{
|
||||
icon: 'icon database',
|
||||
name: 'database',
|
||||
title: 'Database connections',
|
||||
@@ -34,32 +31,32 @@
|
||||
// icon: 'fa-table',
|
||||
// name: 'table',
|
||||
// },
|
||||
!isAdmin && {
|
||||
{
|
||||
icon: 'icon file',
|
||||
name: 'file',
|
||||
title: 'Favorites & Saved files',
|
||||
},
|
||||
!isAdmin && {
|
||||
{
|
||||
icon: 'icon history',
|
||||
name: 'history',
|
||||
title: 'Query history & Closed tabs',
|
||||
},
|
||||
!isAdmin && {
|
||||
{
|
||||
icon: 'icon archive',
|
||||
name: 'archive',
|
||||
title: 'Archive (saved tabular data)',
|
||||
},
|
||||
!isAdmin && {
|
||||
{
|
||||
icon: 'icon plugin',
|
||||
name: 'plugins',
|
||||
title: 'Extensions & Plugins',
|
||||
},
|
||||
!isAdmin && {
|
||||
{
|
||||
icon: 'icon cell-data',
|
||||
name: 'cell-data',
|
||||
title: 'Selected cell data detail view',
|
||||
},
|
||||
!isAdmin && {
|
||||
{
|
||||
icon: 'icon app',
|
||||
name: 'app',
|
||||
title: 'Application layers',
|
||||
@@ -119,17 +116,16 @@
|
||||
|
||||
<div class="flex1"> </div>
|
||||
|
||||
{#if !isAdmin}
|
||||
<div
|
||||
class="wrapper"
|
||||
title={`Toggle whether tabs from all databases are visible. Currently - ${$lockedDatabaseMode ? 'NO' : 'YES'}`}
|
||||
on:click={() => {
|
||||
$lockedDatabaseMode = !$lockedDatabaseMode;
|
||||
}}
|
||||
>
|
||||
<FontIcon icon={$lockedDatabaseMode ? 'icon locked-database-mode' : 'icon unlocked-database-mode'} />
|
||||
</div>
|
||||
{/if}
|
||||
<div
|
||||
class="wrapper"
|
||||
title={`Toggle whether tabs from all databases are visible. Currently - ${$lockedDatabaseMode ? 'NO' : 'YES'}`}
|
||||
on:click={() => {
|
||||
$lockedDatabaseMode = !$lockedDatabaseMode;
|
||||
}}
|
||||
>
|
||||
<FontIcon icon={$lockedDatabaseMode ? 'icon locked-database-mode' : 'icon unlocked-database-mode'} />
|
||||
</div>
|
||||
|
||||
<div class="wrapper" on:click={handleSettingsMenu} bind:this={domSettings}>
|
||||
<FontIcon icon="icon settings" />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user