mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 21:26:00 +00:00
feat: add new duck db command
This commit is contained in:
@@ -4,6 +4,7 @@ module.exports = ({ editMenu, isMac }) => [
|
||||
submenu: [
|
||||
{ command: 'new.connection', hideDisabled: true },
|
||||
{ command: 'new.sqliteDatabase', hideDisabled: true },
|
||||
{ command: 'new.duckdbDatabase', hideDisabled: true },
|
||||
{ divider: true },
|
||||
{ command: 'new.query', hideDisabled: true },
|
||||
{ command: 'new.queryDesign', hideDisabled: true },
|
||||
|
||||
@@ -435,6 +435,22 @@ module.exports = {
|
||||
return res;
|
||||
},
|
||||
|
||||
newDuckdbDatabase_meta: true,
|
||||
async newDuckdbDatabase({ file }) {
|
||||
const duckdbDir = path.join(filesdir(), 'duckdb');
|
||||
if (!(await fs.exists(duckdbDir))) {
|
||||
await fs.mkdir(duckdbDir);
|
||||
}
|
||||
const databaseFile = path.join(duckdbDir, `${file}.duckdb`);
|
||||
const res = await this.save({
|
||||
engine: 'duckdb@dbgate-plugin-duckdb',
|
||||
databaseFile,
|
||||
singleDatabase: true,
|
||||
defaultDatabase: `${file}.duckdb`,
|
||||
});
|
||||
return res;
|
||||
},
|
||||
|
||||
dbloginWeb_meta: {
|
||||
raw: true,
|
||||
method: 'get',
|
||||
|
||||
Binary file not shown.
@@ -46,6 +46,7 @@ import { openImportExportTab } from '../utility/importExportTools';
|
||||
import newTable from '../tableeditor/newTable';
|
||||
import { isProApp } from '../utility/proTools';
|
||||
import { openWebLink } from '../utility/simpleTools';
|
||||
import { _t } from '../translations';
|
||||
|
||||
// function themeCommand(theme: ThemeDefinition) {
|
||||
// return {
|
||||
@@ -389,12 +390,12 @@ registerCommand({
|
||||
category: 'New',
|
||||
icon: 'img sqlite-database',
|
||||
name: 'SQLite database',
|
||||
menuName: 'New SQLite database',
|
||||
menuName: _t('command.new.sqliteDatabase', { defaultMessage: 'New SQLite database' }),
|
||||
onClick: () => {
|
||||
showModal(InputTextModal, {
|
||||
value: 'newdb',
|
||||
label: 'New database name',
|
||||
header: 'Create SQLite database',
|
||||
label: _t('command.new.sqliteDatabase', { defaultMessage: 'New SQLite database' }),
|
||||
header: _t('command.new.sqliteDatabase.header', { defaultMessage: 'Create SQLite database' }),
|
||||
onConfirm: async file => {
|
||||
const resp = await apiCall('connections/new-sqlite-database', { file });
|
||||
const connection = resp;
|
||||
@@ -404,6 +405,26 @@ registerCommand({
|
||||
},
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'new.duckdbDatabase',
|
||||
category: 'New',
|
||||
icon: 'img sqlite-database',
|
||||
name: 'DuckDB database',
|
||||
menuName: _t('command.new.duckdbDatabase', { defaultMessage: 'New DuckDB database' }),
|
||||
onClick: () => {
|
||||
showModal(InputTextModal, {
|
||||
value: 'newdb',
|
||||
label: _t('command.new.duckdbDatabase', { defaultMessage: 'New DuckDB database' }),
|
||||
header: _t('command.new.duckdbDatabase.header', { defaultMessage: 'Create DuckDB database' }),
|
||||
onConfirm: async file => {
|
||||
const resp = await apiCall('connections/new-duckdb-database', { file });
|
||||
const connection = resp;
|
||||
switchCurrentDatabase({ connection, name: `${file}.duckdb` });
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'tabs.changelog',
|
||||
category: 'Tabs',
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
"command.datagrid.undo": "Undo",
|
||||
"command.datagrid.viewJsonDocument": "View row as JSON document",
|
||||
"command.datagrid.viewJsonValue": "View cell as JSON document",
|
||||
"command.new.duckdbDatabase": "New DuckDB database",
|
||||
"command.new.duckdbDatabase.header": "Create DuckDB database",
|
||||
"command.new.sqliteDatabase": "New SQLite database",
|
||||
"command.new.sqliteDatabase.header": "Create SQLite database",
|
||||
"command.tabs.addToFavorites": "Add current tab to favorites",
|
||||
"command.tabs.closeAll": "Close all tabs",
|
||||
"command.tabs.closeTab": "Close tab",
|
||||
@@ -51,7 +55,6 @@
|
||||
"connection.newQuery": "New Query (server)",
|
||||
"connection.refresh": "Refresh",
|
||||
"connection.serverSummary": "Server summary",
|
||||
"connection.sqlRestore": "Restore/import SQL dump",
|
||||
"connection.viewDetails": "View details",
|
||||
"error.driverNotFound": "Invalid database connection, driver not found",
|
||||
"importExport.sourceFiles": "Source files",
|
||||
@@ -61,6 +64,7 @@
|
||||
"schema.delete": "Delete schema",
|
||||
"schema.resetToDefault": "Reset to default",
|
||||
"schema.schemaName": "Schema name",
|
||||
"settings.behaviour.jsonPreviewWrap": "Wrap json in preview",
|
||||
"settings.localization": "Localization",
|
||||
"tab.administration": "Administration",
|
||||
"widget.databaseContent": "Database content",
|
||||
|
||||
Reference in New Issue
Block a user