mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 18:03:58 +00:00
show app state for current database
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import _ from 'lodash';
|
import _, { find } from 'lodash';
|
||||||
import { filterName } from 'dbgate-tools';
|
import { filterName } from 'dbgate-tools';
|
||||||
|
|
||||||
import { currentApplication, currentDatabase } from '../stores';
|
import { currentApplication, currentDatabase } from '../stores';
|
||||||
@@ -14,9 +14,12 @@
|
|||||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
|
import { useConnectionList } from '../utility/metadataLoaders';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
|
$: connections = useConnectionList();
|
||||||
|
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
showModal(ConfirmModal, {
|
showModal(ConfirmModal, {
|
||||||
message: `Really delete application ${data.name}?`,
|
message: `Really delete application ${data.name}?`,
|
||||||
@@ -61,11 +64,23 @@
|
|||||||
{ text: 'Rename', onClick: handleRename },
|
{ text: 'Rename', onClick: handleRename },
|
||||||
|
|
||||||
$currentDatabase && [
|
$currentDatabase && [
|
||||||
{ text: 'Enable on current database', onClick: () => setOnCurrentDb(true) },
|
!isOnCurrentDb($currentDatabase, $connections) && {
|
||||||
{ text: 'Disable on current database', onClick: () => setOnCurrentDb(false) },
|
text: 'Enable on current database',
|
||||||
|
onClick: () => setOnCurrentDb(true),
|
||||||
|
},
|
||||||
|
isOnCurrentDb($currentDatabase, $connections) && {
|
||||||
|
text: 'Disable on current database',
|
||||||
|
onClick: () => setOnCurrentDb(false),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isOnCurrentDb(currentDb, connections) {
|
||||||
|
const conn = connections.find(x => x._id == currentDb?.connection?._id);
|
||||||
|
const db = conn?.databases?.find(x => x.name == currentDb?.name);
|
||||||
|
return db && db[`useApp:${data.name}`];
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<AppObjectCore
|
<AppObjectCore
|
||||||
@@ -73,6 +88,8 @@
|
|||||||
{data}
|
{data}
|
||||||
title={data.name}
|
title={data.name}
|
||||||
icon={'img app'}
|
icon={'img app'}
|
||||||
|
statusIcon={isOnCurrentDb($currentDatabase, $connections) ? 'icon check' : null}
|
||||||
|
statusTitle={`Application ${data.name} is used for database ${$currentDatabase?.name}`}
|
||||||
isBold={data.name == $currentApplication}
|
isBold={data.name == $currentApplication}
|
||||||
on:click={() => ($currentApplication = data.name)}
|
on:click={() => ($currentApplication = data.name)}
|
||||||
menu={createMenu}
|
menu={createMenu}
|
||||||
|
|||||||
Reference in New Issue
Block a user