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