mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
show app state for current database
This commit is contained in:
parent
83f60f863c
commit
ae861ef1ae
@ -4,7 +4,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import _ from 'lodash';
|
||||
import _, { find } from 'lodash';
|
||||
import { filterName } from 'dbgate-tools';
|
||||
|
||||
import { currentApplication, currentDatabase } from '../stores';
|
||||
@ -14,9 +14,12 @@
|
||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
import { apiCall } from '../utility/api';
|
||||
import { useConnectionList } from '../utility/metadataLoaders';
|
||||
|
||||
export let data;
|
||||
|
||||
$: connections = useConnectionList();
|
||||
|
||||
const handleDelete = () => {
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really delete application ${data.name}?`,
|
||||
@ -61,11 +64,23 @@
|
||||
{ text: 'Rename', onClick: handleRename },
|
||||
|
||||
$currentDatabase && [
|
||||
{ text: 'Enable on current database', onClick: () => setOnCurrentDb(true) },
|
||||
{ text: 'Disable on current database', onClick: () => setOnCurrentDb(false) },
|
||||
!isOnCurrentDb($currentDatabase, $connections) && {
|
||||
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>
|
||||
|
||||
<AppObjectCore
|
||||
@ -73,6 +88,8 @@
|
||||
{data}
|
||||
title={data.name}
|
||||
icon={'img app'}
|
||||
statusIcon={isOnCurrentDb($currentDatabase, $connections) ? 'icon check' : null}
|
||||
statusTitle={`Application ${data.name} is used for database ${$currentDatabase?.name}`}
|
||||
isBold={data.name == $currentApplication}
|
||||
on:click={() => ($currentApplication = data.name)}
|
||||
menu={createMenu}
|
||||
|
Loading…
Reference in New Issue
Block a user