mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
Merge branch 'master' into develop
This commit is contained in:
commit
4672540f82
@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"version": "5.0.6-beta.4",
|
||||
"version": "5.0.6-beta.6",
|
||||
"name": "dbgate-all",
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
|
@ -83,12 +83,7 @@
|
||||
label: 'New collection name',
|
||||
header: 'Create collection',
|
||||
onConfirm: async newCollection => {
|
||||
const dbid = { conid: connection._id, database: name };
|
||||
await apiCall('database-connections/run-script', {
|
||||
...dbid,
|
||||
sql: `db.createCollection('${newCollection}')`,
|
||||
});
|
||||
await apiCall('database-connections/sync-model', dbid);
|
||||
saveScriptToDatabase({ conid: connection._id, database: name }, `db.createCollection('${newCollection}')`);
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -224,13 +219,7 @@
|
||||
};
|
||||
|
||||
async function handleConfirmSql(sql) {
|
||||
const resp = await apiCall('database-connections/run-script', { conid: connection._id, database: name, sql });
|
||||
const { errorMessage } = resp || {};
|
||||
if (errorMessage) {
|
||||
showModal(ErrorMessageModal, { title: 'Error when executing script', message: errorMessage });
|
||||
} else {
|
||||
showSnackbarSuccess('Saved to database');
|
||||
}
|
||||
saveScriptToDatabase({ conid: connection._id, database: name }, sql, false);
|
||||
}
|
||||
|
||||
const driver = findEngineDriver(connection, getExtensions());
|
||||
@ -317,7 +306,7 @@
|
||||
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
||||
import { apiCall } from '../utility/api';
|
||||
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
||||
import ConfirmSqlModal, { saveScriptToDatabase } from '../modals/ConfirmSqlModal.svelte';
|
||||
import { filterAppsForDatabase } from '../utility/appTools';
|
||||
import newQuery from '../query/newQuery';
|
||||
import { exportSqlDump } from '../utility/exportFileTools';
|
||||
|
@ -47,18 +47,22 @@
|
||||
{
|
||||
label: 'Drop table',
|
||||
isDrop: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
{
|
||||
label: 'Rename table',
|
||||
isRename: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
{
|
||||
label: 'Create table backup',
|
||||
isDuplicateTable: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
{
|
||||
label: 'Query designer',
|
||||
isQueryDesigner: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
{
|
||||
label: 'Show diagram',
|
||||
@ -75,6 +79,7 @@
|
||||
{
|
||||
label: 'Import',
|
||||
isImport: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
{
|
||||
label: 'Open as data sheet',
|
||||
@ -475,12 +480,8 @@
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really drop collection ${data.pureName}?`,
|
||||
onConfirm: async () => {
|
||||
saveScriptToDatabase(_.pick(data, ['conid', 'database']), `db.dropCollection('${data.pureName}')`);
|
||||
const dbid = _.pick(data, ['conid', 'database']);
|
||||
await apiCall('database-connections/run-script', {
|
||||
...dbid,
|
||||
sql: `db.dropCollection('${data.pureName}')`,
|
||||
});
|
||||
apiCall('database-connections/sync-model', dbid);
|
||||
},
|
||||
});
|
||||
} else if (menu.isRenameCollection) {
|
||||
@ -527,8 +528,7 @@
|
||||
showModal(ConfirmSqlModal, {
|
||||
sql: dmp.s,
|
||||
onConfirm: async () => {
|
||||
const resp = await apiCall('database-connections/run-script', { conid, database, sql: dmp.s });
|
||||
await apiCall('database-connections/sync-model', { conid, database });
|
||||
saveScriptToDatabase({ conid, database }, dmp.s);
|
||||
},
|
||||
engine: driver.engine,
|
||||
});
|
||||
@ -630,7 +630,7 @@
|
||||
);
|
||||
}
|
||||
|
||||
export function createDatabaseObjectMenu(data) {
|
||||
export function createDatabaseObjectMenu(data, connection = null) {
|
||||
const { objectTypeField } = data;
|
||||
return menus[objectTypeField]
|
||||
.filter(x => x)
|
||||
@ -669,6 +669,9 @@
|
||||
);
|
||||
}
|
||||
|
||||
if (connection?.isReadOnly && menu.requiresWriteAccess) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
text: menu.label,
|
||||
onClick: () => {
|
||||
@ -712,7 +715,7 @@
|
||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||
import { exportQuickExportFile } from '../utility/exportFileTools';
|
||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
||||
import ConfirmSqlModal, { saveScriptToDatabase } from '../modals/ConfirmSqlModal.svelte';
|
||||
import { alterDatabaseDialog, renameDatabaseObjectDialog } from '../utility/alterDatabaseTools';
|
||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||
import { apiCall } from '../utility/api';
|
||||
@ -729,7 +732,7 @@
|
||||
}
|
||||
|
||||
function createMenu() {
|
||||
return createDatabaseObjectMenu(data);
|
||||
return createDatabaseObjectMenu(data, passProps?.connection);
|
||||
}
|
||||
|
||||
$: isPinned = !!$pinnedTables.find(x => testEqual(data, x));
|
||||
|
@ -1,3 +1,21 @@
|
||||
<script context="module">
|
||||
export async function saveScriptToDatabase({ conid, database }, sql, syncModel = true) {
|
||||
const resp = await apiCall('database-connections/run-script', {
|
||||
conid,
|
||||
database,
|
||||
sql,
|
||||
});
|
||||
|
||||
const { errorMessage } = resp || {};
|
||||
if (errorMessage) {
|
||||
showModal(ErrorMessageModal, { title: 'Error when executing script', message: errorMessage });
|
||||
} else {
|
||||
showSnackbarSuccess('Saved to database');
|
||||
if (syncModel) apiCall('database-connections/sync-model', { conid, database });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import _, { startsWith } from 'lodash';
|
||||
import { writable } from 'svelte/store';
|
||||
@ -8,9 +26,12 @@
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
import newQuery from '../query/newQuery';
|
||||
import SqlEditor from '../query/SqlEditor.svelte';
|
||||
import { apiCall } from '../utility/api';
|
||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
||||
import ErrorMessageModal from './ErrorMessageModal.svelte';
|
||||
|
||||
import ModalBase from './ModalBase.svelte';
|
||||
import { closeCurrentModal } from './modalTools';
|
||||
import { closeCurrentModal, showModal } from './modalTools';
|
||||
|
||||
export let sql;
|
||||
export let onConfirm;
|
||||
|
@ -4,7 +4,7 @@ import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import { getExtensions } from '../stores';
|
||||
import { getConnectionInfo, getDatabaseInfo } from './metadataLoaders';
|
||||
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
||||
import ConfirmSqlModal, { saveScriptToDatabase } from '../modals/ConfirmSqlModal.svelte';
|
||||
import { apiCall } from './api';
|
||||
|
||||
export async function alterDatabaseDialog(conid, database, updateFunc) {
|
||||
@ -21,8 +21,7 @@ export async function alterDatabaseDialog(conid, database, updateFunc) {
|
||||
sql,
|
||||
recreates,
|
||||
onConfirm: async () => {
|
||||
const resp = await apiCall('database-connections/run-script', { conid, database, sql });
|
||||
await apiCall('database-connections/sync-model', { conid, database });
|
||||
saveScriptToDatabase({ conid, database }, sql);
|
||||
},
|
||||
engine: driver.engine,
|
||||
});
|
||||
|
@ -145,7 +145,7 @@
|
||||
data.objectTypeField == 'tables' || data.objectTypeField == 'views' || data.objectTypeField == 'matviews'}
|
||||
expandIconFunc={chevronExpandIcon}
|
||||
{filter}
|
||||
passProps={{ showPinnedInsteadOfUnpin: true }}
|
||||
passProps={{ showPinnedInsteadOfUnpin: true, connection: $connection }}
|
||||
/>
|
||||
{/if}
|
||||
</WidgetsInnerContainer>
|
||||
|
Loading…
Reference in New Issue
Block a user