mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 21:56:00 +00:00
axiosInstance replaced with apiCall
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
const connProps: any = {};
|
const connProps: any = {};
|
||||||
let tooltip = undefined;
|
let tooltip = undefined;
|
||||||
|
|
||||||
const resp = await axiosInstance().post('files/load', {
|
const resp = await apiCall('files/load', {
|
||||||
folder: 'archive:' + folderName,
|
folder: 'archive:' + folderName,
|
||||||
file: fileName + '.' + fileType,
|
file: fileName + '.' + fileType,
|
||||||
format: 'text',
|
format: 'text',
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
...connProps,
|
...connProps,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ editor: resp.data }
|
{ editor: resp }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +82,7 @@
|
|||||||
markArchiveFileAsDataSheet,
|
markArchiveFileAsDataSheet,
|
||||||
markArchiveFileAsReadonly,
|
markArchiveFileAsReadonly,
|
||||||
} from '../utility/archiveTools';
|
} from '../utility/archiveTools';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@
|
|||||||
label: 'New file name',
|
label: 'New file name',
|
||||||
header: 'Rename file',
|
header: 'Rename file',
|
||||||
onConfirm: newFile => {
|
onConfirm: newFile => {
|
||||||
axiosInstance().post('archive/rename-file', {
|
apiCall('archive/rename-file', {
|
||||||
file: data.fileName,
|
file: data.fileName,
|
||||||
folder: data.folderName,
|
folder: data.folderName,
|
||||||
fileType: data.fileType,
|
fileType: data.fileType,
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
showModal(ConfirmModal, {
|
showModal(ConfirmModal, {
|
||||||
message: `Really delete file ${data.fileName}?`,
|
message: `Really delete file ${data.fileName}?`,
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
axiosInstance().post('archive/delete-file', {
|
apiCall('archive/delete-file', {
|
||||||
file: data.fileName,
|
file: data.fileName,
|
||||||
folder: data.folderName,
|
folder: data.folderName,
|
||||||
fileType: data.fileType,
|
fileType: data.fileType,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
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 ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
? `Really delete link to folder ${data.name}? Folder content remains untouched.`
|
? `Really delete link to folder ${data.name}? Folder content remains untouched.`
|
||||||
: `Really delete folder ${data.name}?`,
|
: `Really delete folder ${data.name}?`,
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
axiosInstance().post('archive/delete-folder', { folder: data.name });
|
apiCall('archive/delete-folder', { folder: data.name });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -41,7 +42,7 @@
|
|||||||
label: 'New folder name',
|
label: 'New folder name',
|
||||||
header: 'Rename folder',
|
header: 'Rename folder',
|
||||||
onConfirm: async newFolder => {
|
onConfirm: async newFolder => {
|
||||||
await axiosInstance().post('archive/rename-folder', {
|
await apiCall('archive/rename-folder', {
|
||||||
folder: data.name,
|
folder: data.name,
|
||||||
newFolder: newFolder + suffix,
|
newFolder: newFolder + suffix,
|
||||||
});
|
});
|
||||||
@@ -78,16 +79,16 @@ await dbgateApi.deployDb(${JSON.stringify(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleGenerateDeploySql = async () => {
|
const handleGenerateDeploySql = async () => {
|
||||||
const resp = await axiosInstance().post('database-connections/generate-deploy-sql', {
|
const resp = await apiCall('database-connections/generate-deploy-sql', {
|
||||||
conid: $currentDatabase.connection._id,
|
conid: $currentDatabase.connection._id,
|
||||||
database: $currentDatabase.name,
|
database: $currentDatabase.name,
|
||||||
archiveFolder: data.name,
|
archiveFolder: data.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (resp.data.errorMessage) {
|
if (resp.errorMessage) {
|
||||||
showModal(ErrorMessageModal, { message: resp.data.errorMessage });
|
showModal(ErrorMessageModal, { message: resp.errorMessage });
|
||||||
} else {
|
} else {
|
||||||
newQuery({ initialData: resp.data.sql });
|
newQuery({ initialData: resp.sql });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||||
import { getDatabaseList } from '../utility/metadataLoaders';
|
import { getDatabaseList } from '../utility/metadataLoaders';
|
||||||
import { getLocalStorage } from '../utility/storageCache';
|
import { getLocalStorage } from '../utility/storageCache';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
@@ -44,14 +45,14 @@
|
|||||||
const handleConnect = () => {
|
const handleConnect = () => {
|
||||||
if (data.singleDatabase) {
|
if (data.singleDatabase) {
|
||||||
$currentDatabase = { connection: data, name: data.defaultDatabase };
|
$currentDatabase = { connection: data, name: data.defaultDatabase };
|
||||||
axiosInstance().post('database-connections/refresh', {
|
apiCall('database-connections/refresh', {
|
||||||
conid: data._id,
|
conid: data._id,
|
||||||
database: data.defaultDatabase,
|
database: data.defaultDatabase,
|
||||||
keepOpen: true,
|
keepOpen: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$openedConnections = _.uniq([...$openedConnections, data._id]);
|
$openedConnections = _.uniq([...$openedConnections, data._id]);
|
||||||
axiosInstance().post('server-connections/refresh', {
|
apiCall('server-connections/refresh', {
|
||||||
conid: data._id,
|
conid: data._id,
|
||||||
keepOpen: true,
|
keepOpen: true,
|
||||||
});
|
});
|
||||||
@@ -61,16 +62,16 @@
|
|||||||
const getContextMenu = () => {
|
const getContextMenu = () => {
|
||||||
const config = getCurrentConfig();
|
const config = getCurrentConfig();
|
||||||
const handleRefresh = () => {
|
const handleRefresh = () => {
|
||||||
axiosInstance().post('server-connections/refresh', { conid: data._id });
|
apiCall('server-connections/refresh', { conid: data._id });
|
||||||
};
|
};
|
||||||
const handleDisconnect = () => {
|
const handleDisconnect = () => {
|
||||||
openedConnections.update(list => list.filter(x => x != data._id));
|
openedConnections.update(list => list.filter(x => x != data._id));
|
||||||
if (electron) {
|
if (electron) {
|
||||||
axiosInstance().post('server-connections/disconnect', { conid: data._id });
|
apiCall('server-connections/disconnect', { conid: data._id });
|
||||||
}
|
}
|
||||||
if (_.get($currentDatabase, 'connection._id') == data._id) {
|
if (_.get($currentDatabase, 'connection._id') == data._id) {
|
||||||
if (electron) {
|
if (electron) {
|
||||||
axiosInstance().post('database-connections/disconnect', { conid: data._id, database: $currentDatabase.name });
|
apiCall('database-connections/disconnect', { conid: data._id, database: $currentDatabase.name });
|
||||||
}
|
}
|
||||||
currentDatabase.set(null);
|
currentDatabase.set(null);
|
||||||
}
|
}
|
||||||
@@ -81,11 +82,11 @@
|
|||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
showModal(ConfirmModal, {
|
showModal(ConfirmModal, {
|
||||||
message: `Really delete connection ${getConnectionLabel(data)}?`,
|
message: `Really delete connection ${getConnectionLabel(data)}?`,
|
||||||
onConfirm: () => axiosInstance().post('connections/delete', data),
|
onConfirm: () => apiCall('connections/delete', data),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const handleDuplicate = () => {
|
const handleDuplicate = () => {
|
||||||
axiosInstance().post('connections/save', {
|
apiCall('connections/save', {
|
||||||
...data,
|
...data,
|
||||||
_id: undefined,
|
_id: undefined,
|
||||||
displayName: `${getConnectionLabel(data)} - copy`,
|
displayName: `${getConnectionLabel(data)} - copy`,
|
||||||
@@ -97,7 +98,7 @@
|
|||||||
value: 'newdb',
|
value: 'newdb',
|
||||||
label: 'Database name',
|
label: 'Database name',
|
||||||
onConfirm: name =>
|
onConfirm: name =>
|
||||||
axiosInstance().post('server-connections/create-database', {
|
apiCall('server-connections/create-database', {
|
||||||
conid: data._id,
|
conid: data._id,
|
||||||
name,
|
name,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -47,13 +47,11 @@
|
|||||||
header: 'Create collection',
|
header: 'Create collection',
|
||||||
onConfirm: async newCollection => {
|
onConfirm: async newCollection => {
|
||||||
const dbid = { conid: connection._id, database: name };
|
const dbid = { conid: connection._id, database: name };
|
||||||
await axiosInstance().request({
|
await apiCall('database-connections/run-script', {
|
||||||
url: 'database-connections/run-script',
|
...dbid,
|
||||||
method: 'post',
|
sql: `db.createCollection('${newCollection}')`,
|
||||||
params: dbid,
|
|
||||||
data: { sql: `db.createCollection('${newCollection}')` },
|
|
||||||
});
|
});
|
||||||
axiosInstance().post('database-connections/sync-model', dbid);
|
await apiCall('database-connections/sync-model', dbid);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -90,19 +88,19 @@
|
|||||||
const handleDisconnect = () => {
|
const handleDisconnect = () => {
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
if (electron) {
|
if (electron) {
|
||||||
axiosInstance().post('database-connections/disconnect', { conid: connection._id, database: name });
|
apiCall('database-connections/disconnect', { conid: connection._id, database: name });
|
||||||
}
|
}
|
||||||
currentDatabase.set(null);
|
currentDatabase.set(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExportModel = async () => {
|
const handleExportModel = async () => {
|
||||||
const resp = await axiosInstance().post('database-connections/export-model', {
|
const resp = await apiCall('database-connections/export-model', {
|
||||||
conid: connection._id,
|
conid: connection._id,
|
||||||
database: name,
|
database: name,
|
||||||
});
|
});
|
||||||
currentArchive.set(resp.data.archiveFolder);
|
currentArchive.set(resp.archiveFolder);
|
||||||
selectedWidget.set('archive');
|
selectedWidget.set('archive');
|
||||||
showSnackbarSuccess(`Saved to archive ${resp.data.archiveFolder}`);
|
showSnackbarSuccess(`Saved to archive ${resp.archiveFolder}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCompareWithCurrentDb = () => {
|
const handleCompareWithCurrentDb = () => {
|
||||||
@@ -182,6 +180,7 @@
|
|||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
import { getDatabaseInfo } from '../utility/metadataLoaders';
|
import { getDatabaseInfo } from '../utility/metadataLoaders';
|
||||||
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
|
|||||||
@@ -411,6 +411,7 @@
|
|||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
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';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
@@ -559,13 +560,11 @@
|
|||||||
message: `Really drop collection ${data.pureName}?`,
|
message: `Really drop collection ${data.pureName}?`,
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
const dbid = _.pick(data, ['conid', 'database']);
|
const dbid = _.pick(data, ['conid', 'database']);
|
||||||
await axiosInstance().request({
|
await apiCall('database-connections/run-script', {
|
||||||
url: 'database-connections/run-script',
|
...dbid,
|
||||||
method: 'post',
|
sql: `db.dropCollection('${data.pureName}')`,
|
||||||
params: dbid,
|
|
||||||
data: { sql: `db.dropCollection('${data.pureName}')` },
|
|
||||||
});
|
});
|
||||||
axiosInstance().post('database-connections/sync-model', dbid);
|
apiCall('database-connections/sync-model', dbid);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -7,14 +7,14 @@
|
|||||||
const { icon, tabComponent, title, props, tabdata } = favorite;
|
const { icon, tabComponent, title, props, tabdata } = favorite;
|
||||||
let tabdataNew = tabdata;
|
let tabdataNew = tabdata;
|
||||||
if (props.savedFile) {
|
if (props.savedFile) {
|
||||||
const resp = await axiosInstance().post('files/load', {
|
const resp = await apiCall('files/load', {
|
||||||
folder: props.savedFolder,
|
folder: props.savedFolder,
|
||||||
file: props.savedFile,
|
file: props.savedFile,
|
||||||
format: props.savedFormat,
|
format: props.savedFormat,
|
||||||
});
|
});
|
||||||
tabdataNew = {
|
tabdataNew = {
|
||||||
...tabdata,
|
...tabdata,
|
||||||
editor: resp.data,
|
editor: resp,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
openNewTab(
|
openNewTab(
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
import FavoriteModal from '../modals/FavoriteModal.svelte';
|
import FavoriteModal from '../modals/FavoriteModal.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const editFavoriteJson = async () => {
|
const editFavoriteJson = async () => {
|
||||||
const resp = await axiosInstance().post('files/load', {
|
const resp = await apiCall('files/load', {
|
||||||
folder: 'favorites',
|
folder: 'favorites',
|
||||||
file: data.file,
|
file: data.file,
|
||||||
format: 'text',
|
format: 'text',
|
||||||
@@ -64,7 +65,7 @@
|
|||||||
savedFolder: 'favorites',
|
savedFolder: 'favorites',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ editor: JSON.stringify(JSON.parse(resp.data), null, 2) }
|
{ editor: JSON.stringify(JSON.parse(resp), null, 2) }
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@
|
|||||||
showModal(ConfirmModal, {
|
showModal(ConfirmModal, {
|
||||||
message: `Really delete favorite ${data.title}?`,
|
message: `Really delete favorite ${data.title}?`,
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
axiosInstance().post('files/delete', { file: data.file, folder: 'favorites' });
|
apiCall('files/delete', { file: data.file, folder: 'favorites' });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
|
|
||||||
import { currentDatabase } from '../stores';
|
import { currentDatabase } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||||
@@ -114,7 +115,7 @@
|
|||||||
showModal(ConfirmModal, {
|
showModal(ConfirmModal, {
|
||||||
message: `Really delete file ${data.file}?`,
|
message: `Really delete file ${data.file}?`,
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
axiosInstance().post('files/delete', data);
|
apiCall('files/delete', data);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -125,7 +126,7 @@
|
|||||||
label: 'New file name',
|
label: 'New file name',
|
||||||
header: 'Rename file',
|
header: 'Rename file',
|
||||||
onConfirm: newFile => {
|
onConfirm: newFile => {
|
||||||
axiosInstance().post('files/rename', { ...data, newFile });
|
apiCall('files/rename', { ...data, newFile });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -136,13 +137,13 @@
|
|||||||
label: 'New file name',
|
label: 'New file name',
|
||||||
header: 'Rename file',
|
header: 'Rename file',
|
||||||
onConfirm: newFile => {
|
onConfirm: newFile => {
|
||||||
axiosInstance().post('files/copy', { ...data, newFile });
|
apiCall('files/copy', { ...data, newFile });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
async function openTab() {
|
async function openTab() {
|
||||||
const resp = await axiosInstance().post('files/load', { folder, file: data.file, format: handler.format });
|
const resp = await apiCall('files/load', { folder, file: data.file, format: handler.format });
|
||||||
|
|
||||||
const connProps: any = {};
|
const connProps: any = {};
|
||||||
let tooltip = undefined;
|
let tooltip = undefined;
|
||||||
@@ -168,7 +169,7 @@
|
|||||||
...connProps,
|
...connProps,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ editor: resp.data }
|
{ editor: resp }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount, afterUpdate, onDestroy } from 'svelte';
|
import { onMount, afterUpdate, onDestroy } from 'svelte';
|
||||||
import registerCommand from '../commands/registerCommand';
|
import registerCommand from '../commands/registerCommand';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
|
|
||||||
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
|
|
||||||
export async function exportChart() {
|
export async function exportChart() {
|
||||||
saveFileToDisk(async filePath => {
|
saveFileToDisk(async filePath => {
|
||||||
await axiosInstance().post('files/export-chart', {
|
await apiCall('files/export-chart', {
|
||||||
title,
|
title,
|
||||||
filePath,
|
filePath,
|
||||||
config: {
|
config: {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { dumpSqlSelect, Select } from 'dbgate-sqltree';
|
|||||||
import { EngineDriver } from 'dbgate-types';
|
import { EngineDriver } from 'dbgate-types';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export async function loadChartStructure(driver: EngineDriver, conid, database, sql) {
|
export async function loadChartStructure(driver: EngineDriver, conid, database, sql) {
|
||||||
const select: Select = {
|
const select: Select = {
|
||||||
@@ -16,9 +17,9 @@ export async function loadChartStructure(driver: EngineDriver, conid, database,
|
|||||||
|
|
||||||
const dmp = driver.createDumper();
|
const dmp = driver.createDumper();
|
||||||
dumpSqlSelect(dmp, select);
|
dumpSqlSelect(dmp, select);
|
||||||
const resp = await axiosInstance().post('database-connections/query-data', { conid, database, sql: dmp.s });
|
const resp = await apiCall('database-connections/query-data', { conid, database, sql: dmp.s });
|
||||||
if (resp.data.errorMessage) throw new Error(resp.data.errorMessage);
|
if (resp.errorMessage) throw new Error(resp.errorMessage);
|
||||||
return resp.data.columns.map(x => x.columnName);
|
return resp.columns.map(x => x.columnName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadChartData(driver: EngineDriver, conid, database, sql, config) {
|
export async function loadChartData(driver: EngineDriver, conid, database, sql, config) {
|
||||||
@@ -74,8 +75,8 @@ export async function loadChartData(driver: EngineDriver, conid, database, sql,
|
|||||||
|
|
||||||
const dmp = driver.createDumper();
|
const dmp = driver.createDumper();
|
||||||
dumpSqlSelect(dmp, select);
|
dumpSqlSelect(dmp, select);
|
||||||
const resp = await axiosInstance().post('database-connections/query-data', { conid, database, sql: dmp.s });
|
const resp = await apiCall('database-connections/query-data', { conid, database, sql: dmp.s });
|
||||||
let { rows, columns, errorMessage } = resp.data;
|
let { rows, columns, errorMessage } = resp;
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
throw new Error(errorMessage);
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { currentDatabase, getCurrentDatabase } from '../stores';
|
|||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
import registerCommand from './registerCommand';
|
import registerCommand from './registerCommand';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
id: 'database.changeState',
|
id: 'database.changeState',
|
||||||
@@ -20,20 +21,20 @@ registerCommand({
|
|||||||
{
|
{
|
||||||
text: 'Sync model',
|
text: 'Sync model',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
axiosInstance().post('database-connections/sync-model', dbid);
|
apiCall('database-connections/sync-model', dbid);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Reopen',
|
text: 'Reopen',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
axiosInstance().post('database-connections/refresh', dbid);
|
apiCall('database-connections/refresh', dbid);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Disconnect',
|
text: 'Disconnect',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
if (electron) axiosInstance().post('database-connections/disconnect', dbid);
|
if (electron) apiCall('database-connections/disconnect', dbid);
|
||||||
currentDatabase.set(null);
|
currentDatabase.set(null);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { openArchiveFolder } from '../utility/openArchiveFolder';
|
|||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
import { removeLocalStorage } from '../utility/storageCache';
|
import { removeLocalStorage } from '../utility/storageCache';
|
||||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
import { showSnackbarSuccess } from '../utility/snackbar';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
function themeCommand(theme: ThemeDefinition) {
|
function themeCommand(theme: ThemeDefinition) {
|
||||||
return {
|
return {
|
||||||
@@ -121,7 +122,7 @@ registerCommand({
|
|||||||
label: 'New archive folder name',
|
label: 'New archive folder name',
|
||||||
header: 'Create archive folder',
|
header: 'Create archive folder',
|
||||||
onConfirm: async folder => {
|
onConfirm: async folder => {
|
||||||
axiosInstance().post('archive/create-folder', { folder });
|
apiCall('archive/create-folder', { folder });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -188,13 +189,8 @@ registerCommand({
|
|||||||
label: 'New collection name',
|
label: 'New collection name',
|
||||||
header: 'Create collection',
|
header: 'Create collection',
|
||||||
onConfirm: async newCollection => {
|
onConfirm: async newCollection => {
|
||||||
await axiosInstance().request({
|
await apiCall('database-connections/run-script', { ...dbid, sql: `db.createCollection('${newCollection}')` });
|
||||||
url: 'database-connections/run-script',
|
apiCall('database-connections/sync-model', dbid);
|
||||||
method: 'post',
|
|
||||||
params: dbid,
|
|
||||||
data: { sql: `db.createCollection('${newCollection}')` },
|
|
||||||
});
|
|
||||||
axiosInstance().post('database-connections/sync-model', dbid);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -256,8 +252,8 @@ registerCommand({
|
|||||||
label: 'New database name',
|
label: 'New database name',
|
||||||
header: 'Create SQLite database',
|
header: 'Create SQLite database',
|
||||||
onConfirm: async file => {
|
onConfirm: async file => {
|
||||||
const resp = await axiosInstance().post('connections/new-sqlite-database', { file });
|
const resp = await apiCall('connections/new-sqlite-database', { file });
|
||||||
const connection = resp.data;
|
const connection = resp;
|
||||||
currentDatabase.set({ connection, name: `${file}.sqlite` });
|
currentDatabase.set({ connection, name: `${file}.sqlite` });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -63,26 +63,20 @@
|
|||||||
export async function loadCollectionDataPage(props, offset, limit) {
|
export async function loadCollectionDataPage(props, offset, limit) {
|
||||||
const { conid, database } = props;
|
const { conid, database } = props;
|
||||||
|
|
||||||
const response = await axiosInstance().request({
|
const response = await apiCall('database-connections/collection-data', {
|
||||||
url: 'database-connections/collection-data',
|
conid,
|
||||||
method: 'post',
|
database,
|
||||||
params: {
|
options: {
|
||||||
conid,
|
pureName: props.pureName,
|
||||||
database,
|
limit,
|
||||||
},
|
skip: offset,
|
||||||
data: {
|
condition: buildGridMongoCondition(props),
|
||||||
options: {
|
sort: buildMongoSort(props),
|
||||||
pureName: props.pureName,
|
|
||||||
limit,
|
|
||||||
skip: offset,
|
|
||||||
condition: buildGridMongoCondition(props),
|
|
||||||
sort: buildMongoSort(props),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.errorMessage) return response.data;
|
if (response.errorMessage) return response;
|
||||||
return response.data.rows;
|
return response.rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dataPageAvailable(props) {
|
function dataPageAvailable(props) {
|
||||||
@@ -95,23 +89,17 @@
|
|||||||
async function loadRowCount(props) {
|
async function loadRowCount(props) {
|
||||||
const { conid, database } = props;
|
const { conid, database } = props;
|
||||||
|
|
||||||
const response = await axiosInstance().request({
|
const response = await apiCall('database-connections/collection-data', {
|
||||||
url: 'database-connections/collection-data',
|
conid,
|
||||||
method: 'post',
|
database,
|
||||||
params: {
|
options: {
|
||||||
conid,
|
pureName: props.pureName,
|
||||||
database,
|
countDocuments: true,
|
||||||
},
|
condition: buildGridMongoCondition(props),
|
||||||
data: {
|
|
||||||
options: {
|
|
||||||
pureName: props.pureName,
|
|
||||||
countDocuments: true,
|
|
||||||
condition: buildGridMongoCondition(props),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return response.data.count;
|
return response.count;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -127,6 +115,7 @@
|
|||||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import { extensions } from '../stores';
|
import { extensions } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { registerMenu } from '../utility/contextMenu';
|
import { registerMenu } from '../utility/contextMenu';
|
||||||
|
|||||||
@@ -285,6 +285,7 @@
|
|||||||
import { findCommand } from '../commands/runCommand';
|
import { findCommand } from '../commands/runCommand';
|
||||||
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
||||||
import EditJsonModal from '../modals/EditJsonModal.svelte';
|
import EditJsonModal from '../modals/EditJsonModal.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let onLoadNextData = undefined;
|
export let onLoadNextData = undefined;
|
||||||
export let grider = undefined;
|
export let grider = undefined;
|
||||||
@@ -404,7 +405,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function reconnect() {
|
export async function reconnect() {
|
||||||
await axiosInstance().post('database-connections/refresh', { conid, database });
|
await apiCall('database-connections/refresh', { conid, database });
|
||||||
display.reload();
|
display.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
async function loadDataPage(props, offset, limit) {
|
async function loadDataPage(props, offset, limit) {
|
||||||
const { jslid, display } = props;
|
const { jslid, display } = props;
|
||||||
|
|
||||||
const response = await axiosInstance().post('jsldata/get-rows', {
|
const response = await apiCall('jsldata/get-rows', {
|
||||||
jslid,
|
jslid,
|
||||||
offset,
|
offset,
|
||||||
limit,
|
limit,
|
||||||
@@ -30,16 +30,9 @@
|
|||||||
async function loadRowCount(props) {
|
async function loadRowCount(props) {
|
||||||
const { jslid } = props;
|
const { jslid } = props;
|
||||||
|
|
||||||
const response = await axiosInstance().request({
|
const response = await apiCall('jsldata/get-stats', { jslid });
|
||||||
url: 'jsldata/get-stats',
|
return response.rowCount;
|
||||||
method: 'get',
|
|
||||||
params: {
|
|
||||||
jslid,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return response.data.rowCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -48,6 +41,7 @@
|
|||||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import { extensions } from '../stores';
|
import { extensions } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { registerMenu } from '../utility/contextMenu';
|
import { registerMenu } from '../utility/contextMenu';
|
||||||
@@ -140,7 +134,6 @@
|
|||||||
},
|
},
|
||||||
{ command: 'jslTableGrid.export', tag: 'export' }
|
{ command: 'jslTableGrid.export', tag: 'export' }
|
||||||
);
|
);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<LoadingDataGridCore
|
<LoadingDataGridCore
|
||||||
|
|||||||
@@ -31,18 +31,14 @@
|
|||||||
|
|
||||||
const sql = display.getPageQuery(offset, limit);
|
const sql = display.getPageQuery(offset, limit);
|
||||||
|
|
||||||
const response = await axiosInstance().request({
|
const response = await apiCall('database-connections/query-data', {
|
||||||
url: 'database-connections/query-data',
|
conid,
|
||||||
method: 'post',
|
database,
|
||||||
params: {
|
sql,
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.errorMessage) return response.data;
|
if (response.errorMessage) return response;
|
||||||
return response.data.rows;
|
return response.rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dataPageAvailable(props) {
|
function dataPageAvailable(props) {
|
||||||
@@ -56,17 +52,13 @@
|
|||||||
|
|
||||||
const sql = display.getCountQuery();
|
const sql = display.getCountQuery();
|
||||||
|
|
||||||
const response = await axiosInstance().request({
|
const response = await apiCall('database-connections/query-data', {
|
||||||
url: 'database-connections/query-data',
|
conid,
|
||||||
method: 'post',
|
database,
|
||||||
params: {
|
sql,
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return parseInt(response.data.rows[0].count);
|
return parseInt(response.rows[0].count);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -77,6 +69,7 @@
|
|||||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import { extensions } from '../stores';
|
import { extensions } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { registerMenu } from '../utility/contextMenu';
|
import { registerMenu } from '../utility/contextMenu';
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
|
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
|
|
||||||
import { useArchiveFolders } from '../utility/metadataLoaders';
|
import { useArchiveFolders } from '../utility/metadataLoaders';
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
const createOption = folder => {
|
const createOption = folder => {
|
||||||
axiosInstance().post('archive/create-folder', { folder });
|
apiCall('archive/create-folder', { folder });
|
||||||
setFieldValue(name, folder);
|
setFieldValue(name, folder);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,7 @@
|
|||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import DictionaryLookupModal from '../modals/DictionaryLookupModal.svelte';
|
import DictionaryLookupModal from '../modals/DictionaryLookupModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { copyTextToClipboard, extractRowCopiedValue } from '../utility/clipboard';
|
import { copyTextToClipboard, extractRowCopiedValue } from '../utility/clipboard';
|
||||||
@@ -260,7 +261,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function reconnect() {
|
export async function reconnect() {
|
||||||
await axiosInstance().post('database-connections/refresh', { conid, database });
|
await apiCall('database-connections/refresh', { conid, database });
|
||||||
formDisplay.reload();
|
formDisplay.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" context="module">
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
async function loadRow(props, sql) {
|
async function loadRow(props, sql) {
|
||||||
const { conid, database } = props;
|
const { conid, database } = props;
|
||||||
|
|
||||||
if (!sql) return null;
|
if (!sql) return null;
|
||||||
|
|
||||||
const response = await axiosInstance().request({
|
const response = await apiCall('database-connections/query-data', {
|
||||||
url: 'database-connections/query-data',
|
conid,
|
||||||
method: 'post',
|
database,
|
||||||
params: {
|
sql,
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.errorMessage) return response.data;
|
if (response.errorMessage) return response;
|
||||||
return response.data.rows[0];
|
return response.rows[0];
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -122,42 +120,6 @@
|
|||||||
$: former = new ChangeSetFormer(rowData, changeSetState, dispatchChangeSet, formDisplay);
|
$: former = new ChangeSetFormer(rowData, changeSetState, dispatchChangeSet, formDisplay);
|
||||||
|
|
||||||
$: if (onReferenceSourceChanged && rowData) onReferenceSourceChanged([rowData], loadedTime);
|
$: if (onReferenceSourceChanged && rowData) onReferenceSourceChanged([rowData], loadedTime);
|
||||||
|
|
||||||
// async function handleConfirmSql(sql) {
|
|
||||||
// const resp = await axiosInstance().request({
|
|
||||||
// url: 'database-connections/query-data',
|
|
||||||
// method: 'post',
|
|
||||||
// params: {
|
|
||||||
// conid,
|
|
||||||
// database,
|
|
||||||
// },
|
|
||||||
// data: { sql },
|
|
||||||
// });
|
|
||||||
// const { errorMessage } = resp.data || {};
|
|
||||||
// if (errorMessage) {
|
|
||||||
// showModal(ErrorMessageModal, { title: 'Error when saving', message: errorMessage });
|
|
||||||
// } else {
|
|
||||||
// dispatchChangeSet({ type: 'reset', value: createChangeSet() });
|
|
||||||
// formDisplay.reload();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function handleSave() {
|
|
||||||
// const script = changeSetToSql(changeSetState && changeSetState.value, formDisplay.dbinfo);
|
|
||||||
// const sql = scriptToSql(formDisplay.driver, script);
|
|
||||||
// showModal(ConfirmSqlModal, {
|
|
||||||
// sql,
|
|
||||||
// onConfirm: () => handleConfirmSql(sql),
|
|
||||||
// engine: formDisplay.engine,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FormView
|
<FormView {...$$props} {former} isLoading={isLoadingData} {allRowCount} {rowCountBefore} onNavigate={handleNavigate} />
|
||||||
{...$$props}
|
|
||||||
{former}
|
|
||||||
isLoading={isLoadingData}
|
|
||||||
{allRowCount}
|
|
||||||
{rowCountBefore}
|
|
||||||
onNavigate={handleNavigate}
|
|
||||||
/>
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
import DataGridCore from '../datagrid/DataGridCore.svelte';
|
import DataGridCore from '../datagrid/DataGridCore.svelte';
|
||||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { registerMenu } from '../utility/contextMenu';
|
import { registerMenu } from '../utility/contextMenu';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
@@ -45,7 +46,7 @@
|
|||||||
|
|
||||||
export async function exportGrid() {
|
export async function exportGrid() {
|
||||||
const jslid = uuidv1();
|
const jslid = uuidv1();
|
||||||
await axiosInstance().post('jsldata/save-free-table', { jslid, data: modelState.value });
|
await apiCall('jsldata/save-free-table', { jslid, data: modelState.value });
|
||||||
const initialValues: any = {};
|
const initialValues: any = {};
|
||||||
initialValues.sourceStorageType = 'jsldata';
|
initialValues.sourceStorageType = 'jsldata';
|
||||||
initialValues.sourceJslId = jslid;
|
initialValues.sourceJslId = jslid;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import RowsArrayGrider from '../datagrid/RowsArrayGrider';
|
import RowsArrayGrider from '../datagrid/RowsArrayGrider';
|
||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
|
|
||||||
export let reader;
|
export let reader;
|
||||||
@@ -27,14 +28,16 @@
|
|||||||
}
|
}
|
||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const resp = await axiosInstance().post('runners/load-reader', sourceReader);
|
const resp = await apiCall('runners/load-reader', sourceReader);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
model = resp.data;
|
model = resp;
|
||||||
grider = new RowsArrayGrider(resp.data.rows);
|
grider = new RowsArrayGrider(resp.rows);
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
errorMessage = (err && err.response && err.response.data && err.response.data.error) || 'Loading failed';
|
// errorMessage = (err && err.response && err.response.data && err.response.data.error) || 'Loading failed';
|
||||||
|
// TODO API
|
||||||
|
errorMessage = 'Loading failed';
|
||||||
console.error(err.response);
|
console.error(err.response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import ColorSelector from '../forms/ColorSelector.svelte';
|
import ColorSelector from '../forms/ColorSelector.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { useConnectionColor } from '../utility/useConnectionColor';
|
import { useConnectionColor } from '../utility/useConnectionColor';
|
||||||
import ModalBase from './ModalBase.svelte';
|
import ModalBase from './ModalBase.svelte';
|
||||||
@@ -27,13 +28,13 @@
|
|||||||
value = e.detail;
|
value = e.detail;
|
||||||
|
|
||||||
if (database) {
|
if (database) {
|
||||||
axiosInstance().post('connections/update-database', {
|
apiCall('connections/update-database', {
|
||||||
conid,
|
conid,
|
||||||
database,
|
database,
|
||||||
values: { connectionColor: e.detail },
|
values: { connectionColor: e.detail },
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
axiosInstance().post('connections/update', {
|
apiCall('connections/update', {
|
||||||
_id: conid,
|
_id: conid,
|
||||||
values: { connectionColor: e.detail },
|
values: { connectionColor: e.detail },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
import FormTextField from '../forms/FormTextField.svelte';
|
import FormTextField from '../forms/FormTextField.svelte';
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import { commandsSettings } from '../stores';
|
import { commandsSettings } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import KeyboardModal from './KeyboardModal.svelte';
|
import KeyboardModal from './KeyboardModal.svelte';
|
||||||
import ModalBase from './ModalBase.svelte';
|
import ModalBase from './ModalBase.svelte';
|
||||||
@@ -42,7 +43,7 @@
|
|||||||
value="OK"
|
value="OK"
|
||||||
on:click={e => {
|
on:click={e => {
|
||||||
closeCurrentModal();
|
closeCurrentModal();
|
||||||
axiosInstance().post('config/update-settings', {
|
apiCall('config/update-settings', {
|
||||||
commands: {
|
commands: {
|
||||||
...$commandsSettings,
|
...$commandsSettings,
|
||||||
[command.id]: {
|
[command.id]: {
|
||||||
@@ -58,7 +59,7 @@
|
|||||||
value="Reset"
|
value="Reset"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
closeCurrentModal();
|
closeCurrentModal();
|
||||||
axiosInstance().post('config/update-settings', {
|
apiCall('config/update-settings', {
|
||||||
commands: _.omit($commandsSettings, [command.id]),
|
commands: _.omit($commandsSettings, [command.id]),
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
import { extensions } from '../stores';
|
import { extensions } from '../stores';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { getDatabaseFileLabel } from '../utility/getConnectionLabel';
|
import { getDatabaseFileLabel } from '../utility/getConnectionLabel';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let connection;
|
export let connection;
|
||||||
|
|
||||||
@@ -38,11 +39,11 @@
|
|||||||
isTesting = true;
|
isTesting = true;
|
||||||
testIdRef.update(x => x + 1);
|
testIdRef.update(x => x + 1);
|
||||||
const testid = testIdRef.get();
|
const testid = testIdRef.get();
|
||||||
const resp = await axiosInstance().post('connections/test', e.detail);
|
const resp = await apiCall('connections/test', e.detail);
|
||||||
if (testIdRef.get() != testid) return;
|
if (testIdRef.get() != testid) return;
|
||||||
|
|
||||||
isTesting = false;
|
isTesting = false;
|
||||||
sqlConnectResult = resp.data;
|
sqlConnectResult = resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCancelTest() {
|
function handleCancelTest() {
|
||||||
@@ -70,7 +71,7 @@
|
|||||||
let connection = _.omit(e.detail, omitProps);
|
let connection = _.omit(e.detail, omitProps);
|
||||||
if (driver?.beforeConnectionSave) connection = driver?.beforeConnectionSave(connection);
|
if (driver?.beforeConnectionSave) connection = driver?.beforeConnectionSave(connection);
|
||||||
|
|
||||||
axiosInstance().post('connections/save', connection);
|
apiCall('connections/save', connection);
|
||||||
closeCurrentModal();
|
closeCurrentModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
import SearchInput from '../elements/SearchInput.svelte';
|
import SearchInput from '../elements/SearchInput.svelte';
|
||||||
import FormTextField from '../forms/FormTextField.svelte';
|
import FormTextField from '../forms/FormTextField.svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let onConfirm;
|
export let onConfirm;
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -100,17 +101,13 @@
|
|||||||
dumpSqlSelect(dmp, select);
|
dumpSqlSelect(dmp, select);
|
||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const response = await axiosInstance().request({
|
const response = await apiCall('database-connections/query-data', {
|
||||||
url: 'database-connections/query-data',
|
conid,
|
||||||
method: 'post',
|
database,
|
||||||
params: {
|
sql: dmp.s,
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql: dmp.s },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
rows = response.data.rows;
|
rows = response.rows;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
import FormSelectField from '../forms/FormSelectField.svelte';
|
import FormSelectField from '../forms/FormSelectField.svelte';
|
||||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||||
import FormButton from '../forms/FormButton.svelte';
|
import FormButton from '../forms/FormButton.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let editingData;
|
export let editingData;
|
||||||
export let savingTab;
|
export let savingTab;
|
||||||
@@ -69,7 +70,7 @@
|
|||||||
const saveTab = async values => {
|
const saveTab = async values => {
|
||||||
const data = await getTabSaveData(values);
|
const data = await getTabSaveData(values);
|
||||||
|
|
||||||
axiosInstance().post('files/save', {
|
apiCall('files/save', {
|
||||||
folder: 'favorites',
|
folder: 'favorites',
|
||||||
file: uuidv1(),
|
file: uuidv1(),
|
||||||
format: 'json',
|
format: 'json',
|
||||||
@@ -78,18 +79,18 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveFile = async values => {
|
const saveFile = async values => {
|
||||||
const oldDataResp = await axiosInstance().post('files/load', {
|
const oldDataResp = await apiCall('files/load', {
|
||||||
folder: 'favorites',
|
folder: 'favorites',
|
||||||
file: editingData.file,
|
file: editingData.file,
|
||||||
format: 'json',
|
format: 'json',
|
||||||
});
|
});
|
||||||
|
|
||||||
axiosInstance().post('files/save', {
|
apiCall('files/save', {
|
||||||
folder: 'favorites',
|
folder: 'favorites',
|
||||||
file: editingData.file,
|
file: editingData.file,
|
||||||
format: 'json',
|
format: 'json',
|
||||||
data: {
|
data: {
|
||||||
...oldDataResp.data,
|
...oldDataResp,
|
||||||
...values,
|
...values,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
import RunnerOutputFiles from '../query/RunnerOutputFiles.svelte';
|
import RunnerOutputFiles from '../query/RunnerOutputFiles.svelte';
|
||||||
import SocketMessageView from '../query/SocketMessageView.svelte';
|
import SocketMessageView from '../query/SocketMessageView.svelte';
|
||||||
import { currentArchive, currentDatabase, extensions, selectedWidget } from '../stores';
|
import { currentArchive, currentDatabase, extensions, selectedWidget } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import createRef from '../utility/createRef';
|
import createRef from '../utility/createRef';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
@@ -81,8 +82,8 @@
|
|||||||
const handleRunnerDone = () => {
|
const handleRunnerDone = () => {
|
||||||
busy = false;
|
busy = false;
|
||||||
if (refreshArchiveFolderRef.get()) {
|
if (refreshArchiveFolderRef.get()) {
|
||||||
axiosInstance().post('archive/refresh-folders', {});
|
apiCall('archive/refresh-folders', {});
|
||||||
axiosInstance().post('archive/refresh-files', { folder: refreshArchiveFolderRef.get() });
|
apiCall('archive/refresh-files', { folder: refreshArchiveFolderRef.get() });
|
||||||
$currentArchive = refreshArchiveFolderRef.get();
|
$currentArchive = refreshArchiveFolderRef.get();
|
||||||
$selectedWidget = 'archive';
|
$selectedWidget = 'archive';
|
||||||
}
|
}
|
||||||
@@ -108,8 +109,8 @@
|
|||||||
const script = await createImpExpScript($extensions, values);
|
const script = await createImpExpScript($extensions, values);
|
||||||
executeNumber += 1;
|
executeNumber += 1;
|
||||||
let runid = runnerId;
|
let runid = runnerId;
|
||||||
const resp = await axiosInstance().post('runners/start', { script });
|
const resp = await apiCall('runners/start', { script });
|
||||||
runid = resp.data.runid;
|
runid = resp.runid;
|
||||||
runnerId = runid;
|
runnerId = runid;
|
||||||
|
|
||||||
if (values.targetStorageType == 'archive') {
|
if (values.targetStorageType == 'archive') {
|
||||||
@@ -120,7 +121,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
axiosInstance().post('runners/cancel', {
|
apiCall('runners/cancel', {
|
||||||
runid: runnerId,
|
runid: runnerId,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import FormProvider from '../forms/FormProvider.svelte';
|
import FormProvider from '../forms/FormProvider.svelte';
|
||||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||||
import FormTextField from '../forms/FormTextField.svelte';
|
import FormTextField from '../forms/FormTextField.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
|
|
||||||
const handleSubmit = async e => {
|
const handleSubmit = async e => {
|
||||||
const { name } = e.detail;
|
const { name } = e.detail;
|
||||||
await axiosInstance().post('files/save', { folder, file: name, data, format });
|
await apiCall('files/save', { folder, file: name, data, format });
|
||||||
closeCurrentModal();
|
closeCurrentModal();
|
||||||
if (onSave) {
|
if (onSave) {
|
||||||
onSave(name, {
|
onSave(name, {
|
||||||
@@ -38,7 +39,7 @@
|
|||||||
const parsed = path.parse(filePath);
|
const parsed = path.parse(filePath);
|
||||||
// if (!parsed.ext) filePath += `.${fileExtension}`;
|
// if (!parsed.ext) filePath += `.${fileExtension}`;
|
||||||
|
|
||||||
await axiosInstance().post('files/save-as', { filePath, data, format });
|
await apiCall('files/save-as', { filePath, data, format });
|
||||||
closeCurrentModal();
|
closeCurrentModal();
|
||||||
|
|
||||||
if (onSave) {
|
if (onSave) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
||||||
import { getObjectTypeFieldLabel } from '../utility/common';
|
import { getObjectTypeFieldLabel } from '../utility/common';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
@@ -86,7 +87,7 @@
|
|||||||
const loadid = uuidv1();
|
const loadid = uuidv1();
|
||||||
loadRef.set(loadid);
|
loadRef.set(loadid);
|
||||||
busy = true;
|
busy = true;
|
||||||
const response = await axiosInstance().post('database-connections/sql-preview', {
|
const response = await apiCall('database-connections/sql-preview', {
|
||||||
conid,
|
conid,
|
||||||
database,
|
database,
|
||||||
objects,
|
objects,
|
||||||
@@ -96,7 +97,7 @@
|
|||||||
// newer load exists
|
// newer load exists
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { sql, isTruncated, isError, errorMessage } = response.data || {};
|
const { sql, isTruncated, isError, errorMessage } = response || {};
|
||||||
|
|
||||||
truncated = isTruncated;
|
truncated = isTruncated;
|
||||||
if (isError) {
|
if (isError) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
import SearchInput from '../elements/SearchInput.svelte';
|
import SearchInput from '../elements/SearchInput.svelte';
|
||||||
import FormTextField from '../forms/FormTextField.svelte';
|
import FormTextField from '../forms/FormTextField.svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let onConfirm;
|
export let onConfirm;
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
let checkedKeys = [];
|
let checkedKeys = [];
|
||||||
|
|
||||||
async function reload() {
|
async function reload() {
|
||||||
const dmp = driver.createDumper();
|
const dmp = driver.createDumper();
|
||||||
const select = {
|
const select = {
|
||||||
commandType: 'select',
|
commandType: 'select',
|
||||||
distinct: true,
|
distinct: true,
|
||||||
@@ -85,17 +86,13 @@
|
|||||||
dumpSqlSelect(dmp, select);
|
dumpSqlSelect(dmp, select);
|
||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const response = await axiosInstance().request({
|
const response = await apiCall('database-connections/query-data', {
|
||||||
url: 'database-connections/query-data',
|
conid,
|
||||||
method: 'post',
|
database,
|
||||||
params: {
|
sql: dmp.s,
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql: dmp.s },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
rows = response.data.rows;
|
rows = response.rows;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@
|
|||||||
$: $effect;
|
$: $effect;
|
||||||
|
|
||||||
const handleRunnerDone = async () => {
|
const handleRunnerDone = async () => {
|
||||||
const resp = await axiosInstance().get(`runners/files?runid=${runnerId}`);
|
const resp = await apiCall(`runners/files?runid=${runnerId}`);
|
||||||
files = resp.data;
|
files = resp;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
import ModalBase from '../modals/ModalBase.svelte';
|
import ModalBase from '../modals/ModalBase.svelte';
|
||||||
import { closeCurrentModal } from '../modals/modalTools';
|
import { closeCurrentModal } from '../modals/modalTools';
|
||||||
import { getCurrentSettings, getVisibleToolbar, getZoomKoef, visibleToolbar, zoomKoef } from '../stores';
|
import { getCurrentSettings, getVisibleToolbar, getZoomKoef, visibleToolbar, zoomKoef } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
|
|
||||||
function handleOk(e) {
|
function handleOk(e) {
|
||||||
axiosInstance().post(
|
apiCall(
|
||||||
'config/update-settings',
|
'config/update-settings',
|
||||||
_.omitBy(e.detail, (v, k) => k.startsWith(':'))
|
_.omitBy(e.detail, (v, k) => k.startsWith(':'))
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
||||||
import Markdown from '../elements/Markdown.svelte';
|
import Markdown from '../elements/Markdown.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
|
|
||||||
@@ -14,8 +15,8 @@
|
|||||||
|
|
||||||
const handleLoad = async () => {
|
const handleLoad = async () => {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const resp = await axiosInstance().get('config/changelog');
|
const resp = await apiCall('config/changelog');
|
||||||
text = resp.data;
|
text = resp;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
import ChangeSetGrider from '../datagrid/ChangeSetGrider';
|
import ChangeSetGrider from '../datagrid/ChangeSetGrider';
|
||||||
import { setContext } from 'svelte';
|
import { setContext } from 'svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -91,14 +92,10 @@
|
|||||||
// $: console.log('LOADED ROWS MONGO', loadedRows);
|
// $: console.log('LOADED ROWS MONGO', loadedRows);
|
||||||
|
|
||||||
async function handleConfirmChange(changeSet) {
|
async function handleConfirmChange(changeSet) {
|
||||||
const resp = await axiosInstance().request({
|
const resp = await apiCall('database-connections/update-collection', {
|
||||||
url: 'database-connections/update-collection',
|
conid,
|
||||||
method: 'post',
|
database,
|
||||||
params: {
|
changeSet,
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { changeSet },
|
|
||||||
});
|
});
|
||||||
const { errorMessage } = resp.data || {};
|
const { errorMessage } = resp.data || {};
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
import SqlEditor from '../query/SqlEditor.svelte';
|
import SqlEditor from '../query/SqlEditor.svelte';
|
||||||
import useEditorData from '../query/useEditorData';
|
import useEditorData from '../query/useEditorData';
|
||||||
import { extensions } from '../stores';
|
import { extensions } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { changeTab } from '../utility/common';
|
import { changeTab } from '../utility/common';
|
||||||
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
||||||
@@ -228,7 +229,7 @@
|
|||||||
|
|
||||||
export async function showReport() {
|
export async function showReport() {
|
||||||
saveFileToDisk(async filePath => {
|
saveFileToDisk(async filePath => {
|
||||||
await axiosInstance().post('database-connections/generate-db-diff-report', {
|
await apiCall('database-connections/generate-db-diff-report', {
|
||||||
filePath,
|
filePath,
|
||||||
sourceConid: $values?.sourceConid,
|
sourceConid: $values?.sourceConid,
|
||||||
sourceDatabase: $values?.sourceDatabase,
|
sourceDatabase: $values?.sourceDatabase,
|
||||||
@@ -261,11 +262,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function refreshModels() {
|
export function refreshModels() {
|
||||||
axiosInstance().post('database-connections/sync-model', {
|
apiCall('database-connections/sync-model', {
|
||||||
conid: $values?.targetConid,
|
conid: $values?.targetConid,
|
||||||
database: $values?.targetDatabase,
|
database: $values?.targetDatabase,
|
||||||
});
|
});
|
||||||
axiosInstance().post('database-connections/sync-model', {
|
apiCall('database-connections/sync-model', {
|
||||||
conid: $values?.sourceConid,
|
conid: $values?.sourceConid,
|
||||||
database: $values?.sourceDatabase,
|
database: $values?.sourceDatabase,
|
||||||
});
|
});
|
||||||
@@ -275,18 +276,13 @@
|
|||||||
const conid = $values?.targetConid;
|
const conid = $values?.targetConid;
|
||||||
const database = $values?.targetDatabase;
|
const database = $values?.targetDatabase;
|
||||||
|
|
||||||
const resp = await axiosInstance().request({
|
const resp = await apiCall('database-connections/run-script', { conid, database, sql });
|
||||||
url: 'database-connections/run-script',
|
|
||||||
method: 'post',
|
|
||||||
params: { conid, database },
|
|
||||||
data: { sql },
|
|
||||||
});
|
|
||||||
const { errorMessage } = resp.data || {};
|
const { errorMessage } = resp.data || {};
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
showModal(ErrorMessageModal, { title: 'Error when saving', message: errorMessage });
|
showModal(ErrorMessageModal, { title: 'Error when saving', message: errorMessage });
|
||||||
} else {
|
} else {
|
||||||
$values = _.omitBy($values, (v, k) => k.startsWith('isChecked_'));
|
$values = _.omitBy($values, (v, k) => k.startsWith('isChecked_'));
|
||||||
await axiosInstance().post('database-connections/sync-model', { conid, database });
|
await apiCall('database-connections/sync-model', { conid, database });
|
||||||
showSnackbarSuccess('Saved to database');
|
showSnackbarSuccess('Saved to database');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||||
import { openFavorite } from '../appobj/FavoriteFileAppObject.svelte';
|
import { openFavorite } from '../appobj/FavoriteFileAppObject.svelte';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
export let savedFile;
|
export let savedFile;
|
||||||
@@ -97,7 +98,7 @@
|
|||||||
export function save() {
|
export function save() {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(getData());
|
const data = JSON.parse(getData());
|
||||||
axiosInstance().post('files/save', {
|
apiCall('files/save', {
|
||||||
file: savedFile,
|
file: savedFile,
|
||||||
folder: 'favorites',
|
folder: 'favorites',
|
||||||
format: 'json',
|
format: 'json',
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import SaveArchiveModal from '../modals/SaveArchiveModal.svelte';
|
import SaveArchiveModal from '../modals/SaveArchiveModal.svelte';
|
||||||
import useEditorData from '../query/useEditorData';
|
import useEditorData from '../query/useEditorData';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import { markArchiveFileAsDataSheet } from '../utility/archiveTools';
|
import { markArchiveFileAsDataSheet } from '../utility/archiveTools';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { changeTab } from '../utility/common';
|
import { changeTab } from '../utility/common';
|
||||||
@@ -61,10 +62,7 @@
|
|||||||
|
|
||||||
const { setEditorData, editorState } = useEditorData({
|
const { setEditorData, editorState } = useEditorData({
|
||||||
tabid,
|
tabid,
|
||||||
loadFromArgs:
|
loadFromArgs: initialArgs && initialArgs.functionName ? () => apiCall('runners/load-reader', initialArgs) : null,
|
||||||
initialArgs && initialArgs.functionName
|
|
||||||
? () => axiosInstance().post('runners/load-reader', initialArgs).then(x => x.data)
|
|
||||||
: null,
|
|
||||||
onInitialData: value => {
|
onInitialData: value => {
|
||||||
dispatchModel({ type: 'reset', value });
|
dispatchModel({ type: 'reset', value });
|
||||||
},
|
},
|
||||||
@@ -84,7 +82,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const doSave = async (folder, file) => {
|
const doSave = async (folder, file) => {
|
||||||
await axiosInstance().post('archive/save-free-table', { folder, file, data: $modelState.value });
|
await apiCall('archive/save-free-table', { folder, file, data: $modelState.value });
|
||||||
changeTab(tabid, tab => ({
|
changeTab(tabid, tab => ({
|
||||||
...tab,
|
...tab,
|
||||||
title: file,
|
title: file,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
||||||
import Markdown from '../elements/Markdown.svelte';
|
import Markdown from '../elements/Markdown.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
|
|
||||||
@@ -16,12 +17,12 @@
|
|||||||
|
|
||||||
const handleLoad = async () => {
|
const handleLoad = async () => {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const resp = await axiosInstance().post('files/load', {
|
const resp = await apiCall('files/load', {
|
||||||
folder: 'markdown',
|
folder: 'markdown',
|
||||||
file: savedFile,
|
file: savedFile,
|
||||||
format: 'text',
|
format: 'text',
|
||||||
});
|
});
|
||||||
text = resp.data;
|
text = resp;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import FormStyledButton from '../elements/FormStyledButton.svelte';
|
import FormStyledButton from '../elements/FormStyledButton.svelte';
|
||||||
import Markdown from '../elements/Markdown.svelte';
|
import Markdown from '../elements/Markdown.svelte';
|
||||||
import { extractPluginAuthor, extractPluginIcon } from '../plugins/manifestExtractors';
|
import { extractPluginAuthor, extractPluginIcon } from '../plugins/manifestExtractors';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import hasPermission from '../utility/hasPermission';
|
import hasPermission from '../utility/hasPermission';
|
||||||
@@ -27,13 +28,13 @@
|
|||||||
$: isPackaged = $info?.isPackaged;
|
$: isPackaged = $info?.isPackaged;
|
||||||
|
|
||||||
const handleInstall = async () => {
|
const handleInstall = async () => {
|
||||||
axiosInstance().post('plugins/install', { packageName });
|
apiCall('plugins/install', { packageName });
|
||||||
};
|
};
|
||||||
const handleUninstall = async () => {
|
const handleUninstall = async () => {
|
||||||
axiosInstance().post('plugins/uninstall', { packageName });
|
apiCall('plugins/uninstall', { packageName });
|
||||||
};
|
};
|
||||||
const handleUpgrade = async () => {
|
const handleUpgrade = async () => {
|
||||||
axiosInstance().post('plugins/upgrade', { packageName });
|
apiCall('plugins/upgrade', { packageName });
|
||||||
};
|
};
|
||||||
|
|
||||||
$: installedFound = $installed?.find(x => x.name == packageName);
|
$: installedFound = $installed?.find(x => x.name == packageName);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
import QueryDesignColumns from '../elements/QueryDesignColumns.svelte';
|
import QueryDesignColumns from '../elements/QueryDesignColumns.svelte';
|
||||||
import useTimerLabel from '../utility/useTimerLabel';
|
import useTimerLabel from '../utility/useTimerLabel';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -105,23 +106,23 @@
|
|||||||
|
|
||||||
let sesid = sessionId;
|
let sesid = sessionId;
|
||||||
if (!sesid) {
|
if (!sesid) {
|
||||||
const resp = await axiosInstance().post('sessions/create', {
|
const resp = await apiCall('sessions/create', {
|
||||||
conid,
|
conid,
|
||||||
database,
|
database,
|
||||||
});
|
});
|
||||||
sesid = resp.data.sesid;
|
sesid = resp.sesid;
|
||||||
sessionId = sesid;
|
sessionId = sesid;
|
||||||
}
|
}
|
||||||
busy = true;
|
busy = true;
|
||||||
timerLabel.start();
|
timerLabel.start();
|
||||||
await axiosInstance().post('sessions/execute-query', {
|
await apiCall('sessions/execute-query', {
|
||||||
sesid,
|
sesid,
|
||||||
sql: sqlPreview,
|
sql: sqlPreview,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function kill() {
|
export async function kill() {
|
||||||
await axiosInstance().post('sessions/kill', {
|
await apiCall('sessions/kill', {
|
||||||
sesid: sessionId,
|
sesid: sessionId,
|
||||||
});
|
});
|
||||||
sessionId = null;
|
sessionId = null;
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
import AceEditor from '../query/AceEditor.svelte';
|
import AceEditor from '../query/AceEditor.svelte';
|
||||||
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
|
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
|
||||||
import { showSnackbarError } from '../utility/snackbar';
|
import { showSnackbarError } from '../utility/snackbar';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -150,20 +151,20 @@
|
|||||||
|
|
||||||
let sesid = sessionId;
|
let sesid = sessionId;
|
||||||
if (!sesid) {
|
if (!sesid) {
|
||||||
const resp = await axiosInstance().post('sessions/create', {
|
const resp = await apiCall('sessions/create', {
|
||||||
conid,
|
conid,
|
||||||
database,
|
database,
|
||||||
});
|
});
|
||||||
sesid = resp.data.sesid;
|
sesid = resp.sesid;
|
||||||
sessionId = sesid;
|
sessionId = sesid;
|
||||||
}
|
}
|
||||||
busy = true;
|
busy = true;
|
||||||
timerLabel.start();
|
timerLabel.start();
|
||||||
await axiosInstance().post('sessions/execute-query', {
|
await apiCall('sessions/execute-query', {
|
||||||
sesid,
|
sesid,
|
||||||
sql,
|
sql,
|
||||||
});
|
});
|
||||||
await axiosInstance().post('query-history/write', {
|
await apiCall('query-history/write', {
|
||||||
data: {
|
data: {
|
||||||
sql,
|
sql,
|
||||||
conid,
|
conid,
|
||||||
@@ -184,7 +185,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function kill() {
|
export async function kill() {
|
||||||
await axiosInstance().post('sessions/kill', {
|
await apiCall('sessions/kill', {
|
||||||
sesid: sessionId,
|
sesid: sessionId,
|
||||||
});
|
});
|
||||||
sessionId = null;
|
sessionId = null;
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
import AceEditor from '../query/AceEditor.svelte';
|
import AceEditor from '../query/AceEditor.svelte';
|
||||||
import RunnerOutputPane from '../query/RunnerOutputPane.svelte';
|
import RunnerOutputPane from '../query/RunnerOutputPane.svelte';
|
||||||
import useEditorData from '../query/useEditorData';
|
import useEditorData from '../query/useEditorData';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { copyTextToClipboard } from '../utility/clipboard';
|
import { copyTextToClipboard } from '../utility/clipboard';
|
||||||
import { changeTab } from '../utility/common';
|
import { changeTab } from '../utility/common';
|
||||||
@@ -140,8 +141,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function copyNodeScript() {
|
export async function copyNodeScript() {
|
||||||
const resp = await axiosInstance().post('runners/get-node-script', { script: getActiveScript() });
|
const resp = await apiCall('runners/get-node-script', { script: getActiveScript() });
|
||||||
copyTextToClipboard(resp.data);
|
copyTextToClipboard(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// export function openWizardEnabled() {
|
// export function openWizardEnabled() {
|
||||||
@@ -172,10 +173,10 @@
|
|||||||
executeNumber += 1;
|
executeNumber += 1;
|
||||||
|
|
||||||
let runid = runnerId;
|
let runid = runnerId;
|
||||||
const resp = await axiosInstance().post('runners/start', {
|
const resp = await apiCall('runners/start', {
|
||||||
script: getActiveScript(),
|
script: getActiveScript(),
|
||||||
});
|
});
|
||||||
runid = resp.data.runid;
|
runid = resp.runid;
|
||||||
runnerId = runid;
|
runnerId = runid;
|
||||||
busy = true;
|
busy = true;
|
||||||
timerLabel.start();
|
timerLabel.start();
|
||||||
@@ -186,7 +187,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function kill() {
|
export function kill() {
|
||||||
axiosInstance().post('runners/cancel', {
|
apiCall('runners/cancel', {
|
||||||
runid: runnerId,
|
runid: runnerId,
|
||||||
});
|
});
|
||||||
timerLabel.stop();
|
timerLabel.stop();
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import { getBoolSettingsValue } from '../settings/settingsTools';
|
import { getBoolSettingsValue } from '../settings/settingsTools';
|
||||||
import { setContext } from 'svelte';
|
import { setContext } from 'svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -70,16 +71,8 @@
|
|||||||
const [changeSetStore, dispatchChangeSet] = createUndoReducer(createChangeSet());
|
const [changeSetStore, dispatchChangeSet] = createUndoReducer(createChangeSet());
|
||||||
|
|
||||||
async function handleConfirmSql(sql) {
|
async function handleConfirmSql(sql) {
|
||||||
const resp = await axiosInstance().request({
|
const resp = await apiCall('database-connections/run-script', { conid, database, sql });
|
||||||
url: 'database-connections/run-script',
|
const { errorMessage } = resp || {};
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql },
|
|
||||||
});
|
|
||||||
const { errorMessage } = resp.data || {};
|
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
showModal(ErrorMessageModal, { title: 'Error when saving', message: errorMessage });
|
showModal(ErrorMessageModal, { title: 'Error when saving', message: errorMessage });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
import { changeTab } from '../utility/common';
|
import { changeTab } from '../utility/common';
|
||||||
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
|
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -130,16 +131,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleConfirmSql(sql, createTableName) {
|
async function handleConfirmSql(sql, createTableName) {
|
||||||
const resp = await axiosInstance().request({
|
const resp = await apiCall('database-connections/run-script', { conid, database, sql });
|
||||||
url: 'database-connections/run-script',
|
const { errorMessage } = resp || {};
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql },
|
|
||||||
});
|
|
||||||
const { errorMessage } = resp.data || {};
|
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
showModal(ErrorMessageModal, { title: 'Error when saving', message: errorMessage });
|
showModal(ErrorMessageModal, { title: 'Error when saving', message: errorMessage });
|
||||||
} else {
|
} else {
|
||||||
@@ -154,14 +147,14 @@
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
await axiosInstance().post('database-connections/sync-model', { conid, database });
|
await apiCall('database-connections/sync-model', { conid, database });
|
||||||
showSnackbarSuccess('Saved to database');
|
showSnackbarSuccess('Saved to database');
|
||||||
clearEditorData();
|
clearEditorData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function reset() {
|
export async function reset() {
|
||||||
await axiosInstance().post('database-connections/sync-model', { conid, database });
|
await apiCall('database-connections/sync-model', { conid, database });
|
||||||
clearEditorData();
|
clearEditorData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { getExtensions } from '../stores';
|
|||||||
import { getConnectionInfo, getDatabaseInfo } from './metadataLoaders';
|
import { getConnectionInfo, getDatabaseInfo } from './metadataLoaders';
|
||||||
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
||||||
import axiosInstance from './axiosInstance';
|
import axiosInstance from './axiosInstance';
|
||||||
|
import { apiCall } from './api';
|
||||||
|
|
||||||
export async function alterDatabaseDialog(conid, database, updateFunc) {
|
export async function alterDatabaseDialog(conid, database, updateFunc) {
|
||||||
const conn = await getConnectionInfo({ conid });
|
const conn = await getConnectionInfo({ conid });
|
||||||
@@ -21,16 +22,8 @@ export async function alterDatabaseDialog(conid, database, updateFunc) {
|
|||||||
sql,
|
sql,
|
||||||
recreates,
|
recreates,
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
const resp = await axiosInstance().request({
|
const resp = await apiCall('database-connections/run-script', { conid, database, sql });
|
||||||
url: 'database-connections/run-script',
|
await apiCall('database-connections/sync-model', { conid, database });
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql },
|
|
||||||
});
|
|
||||||
await axiosInstance().post('database-connections/sync-model', { conid, database });
|
|
||||||
},
|
},
|
||||||
engine: driver.engine,
|
engine: driver.engine,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { openedConnections, currentDatabase } from '../stores';
|
import { openedConnections, currentDatabase } from '../stores';
|
||||||
|
import { apiCall } from './api';
|
||||||
import axiosInstance from './axiosInstance';
|
import axiosInstance from './axiosInstance';
|
||||||
|
|
||||||
const doServerPing = value => {
|
const doServerPing = value => {
|
||||||
axiosInstance().post('server-connections/ping', { connections: value });
|
apiCall('server-connections/ping', { connections: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const doDatabasePing = value => {
|
const doDatabasePing = value => {
|
||||||
const database = _.get(value, 'name');
|
const database = _.get(value, 'name');
|
||||||
const conid = _.get(value, 'connection._id');
|
const conid = _.get(value, 'connection._id');
|
||||||
if (conid && database) {
|
if (conid && database) {
|
||||||
axiosInstance().post('database-connections/ping', { conid, database });
|
apiCall('database-connections/ping', { conid, database });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import axiosInstance from '../utility/axiosInstance';
|
|||||||
import socket from '../utility/socket';
|
import socket from '../utility/socket';
|
||||||
import { showSnackbar, showSnackbarInfo, showSnackbarError, closeSnackbar } from '../utility/snackbar';
|
import { showSnackbar, showSnackbarInfo, showSnackbarError, closeSnackbar } from '../utility/snackbar';
|
||||||
import resolveApi from './resolveApi';
|
import resolveApi from './resolveApi';
|
||||||
|
import { apiCall } from './api';
|
||||||
|
|
||||||
export async function exportElectronFile(dataName, reader, format) {
|
export async function exportElectronFile(dataName, reader, format) {
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
@@ -28,8 +29,8 @@ export async function exportElectronFile(dataName, reader, format) {
|
|||||||
script.copyStream(sourceVar, targetVar);
|
script.copyStream(sourceVar, targetVar);
|
||||||
script.put();
|
script.put();
|
||||||
|
|
||||||
const resp = await axiosInstance().post('runners/start', { script: script.getScript() });
|
const resp = await apiCall('runners/start', { script: script.getScript() });
|
||||||
const runid = resp.data.runid;
|
const runid = resp.runid;
|
||||||
let isCanceled = false;
|
let isCanceled = false;
|
||||||
|
|
||||||
const snackId = showSnackbar({
|
const snackId = showSnackbar({
|
||||||
@@ -40,7 +41,7 @@ export async function exportElectronFile(dataName, reader, format) {
|
|||||||
label: 'Cancel',
|
label: 'Cancel',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
isCanceled = true;
|
isCanceled = true;
|
||||||
axiosInstance().post('runners/cancel', { runid });
|
apiCall('runners/cancel', { runid });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -74,8 +75,8 @@ export async function saveFileToDisk(
|
|||||||
await filePathFunc(filePath);
|
await filePathFunc(filePath);
|
||||||
electron.openExternal('file:///' + filePath);
|
electron.openExternal('file:///' + filePath);
|
||||||
} else {
|
} else {
|
||||||
const resp = await axiosInstance().get('files/generate-uploads-file');
|
const resp = await apiCall('files/generate-uploads-file');
|
||||||
await filePathFunc(resp.data.filePath);
|
await filePathFunc(resp.filePath);
|
||||||
window.open(`${resolveApi()}/uploads/get?file=${resp.data.fileName}`, '_blank');
|
window.open(`${resolveApi()}/uploads/get?file=${resp.fileName}`, '_blank');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import getElectron from './getElectron';
|
|||||||
import { currentArchive, extensions, selectedWidget } from '../stores';
|
import { currentArchive, extensions, selectedWidget } from '../stores';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { showSnackbarSuccess } from './snackbar';
|
import { showSnackbarSuccess } from './snackbar';
|
||||||
|
import { apiCall } from './api';
|
||||||
|
|
||||||
export async function openArchiveFolder() {
|
export async function openArchiveFolder() {
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
@@ -12,9 +13,9 @@ export async function openArchiveFolder() {
|
|||||||
});
|
});
|
||||||
const linkedFolder = filePaths && filePaths[0];
|
const linkedFolder = filePaths && filePaths[0];
|
||||||
if (!linkedFolder) return;
|
if (!linkedFolder) return;
|
||||||
const resp = await axiosInstance().post('archive/create-link', { linkedFolder });
|
const resp = await apiCall('archive/create-link', { linkedFolder });
|
||||||
|
|
||||||
currentArchive.set(resp.data);
|
currentArchive.set(resp);
|
||||||
selectedWidget.set('archive');
|
selectedWidget.set('archive');
|
||||||
showSnackbarSuccess(`Created link ${resp.data}`);
|
showSnackbarSuccess(`Created link ${resp}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { currentDatabase, extensions } from '../stores';
|
|||||||
import { getUploadListener } from './uploadFiles';
|
import { getUploadListener } from './uploadFiles';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { getDatabaseFileLabel } from './getConnectionLabel';
|
import { getDatabaseFileLabel } from './getConnectionLabel';
|
||||||
|
import { apiCall } from './api';
|
||||||
|
|
||||||
export function canOpenByElectron(file, extensions) {
|
export function canOpenByElectron(file, extensions) {
|
||||||
if (!file) return false;
|
if (!file) return false;
|
||||||
@@ -21,7 +22,7 @@ export function canOpenByElectron(file, extensions) {
|
|||||||
|
|
||||||
export async function openSqliteFile(filePath) {
|
export async function openSqliteFile(filePath) {
|
||||||
const defaultDatabase = getDatabaseFileLabel(filePath);
|
const defaultDatabase = getDatabaseFileLabel(filePath);
|
||||||
const resp = await axiosInstance().post('connections/save', {
|
const resp = await apiCall('connections/save', {
|
||||||
_id: undefined,
|
_id: undefined,
|
||||||
databaseFile: filePath,
|
databaseFile: filePath,
|
||||||
engine: 'sqlite@dbgate-plugin-sqlite',
|
engine: 'sqlite@dbgate-plugin-sqlite',
|
||||||
@@ -29,7 +30,7 @@ export async function openSqliteFile(filePath) {
|
|||||||
defaultDatabase,
|
defaultDatabase,
|
||||||
});
|
});
|
||||||
currentDatabase.set({
|
currentDatabase.set({
|
||||||
connection: resp.data,
|
connection: resp,
|
||||||
name: getDatabaseFileLabel(filePath),
|
name: getDatabaseFileLabel(filePath),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import axiosInstance from '../utility/axiosInstance';
|
|||||||
import { changeTab } from './common';
|
import { changeTab } from './common';
|
||||||
import SaveFileModal from '../modals/SaveFileModal.svelte';
|
import SaveFileModal from '../modals/SaveFileModal.svelte';
|
||||||
import registerCommand from '../commands/registerCommand';
|
import registerCommand from '../commands/registerCommand';
|
||||||
|
import { apiCall } from './api';
|
||||||
|
|
||||||
// export function saveTabEnabledStore(editorStore) {
|
// export function saveTabEnabledStore(editorStore) {
|
||||||
// return derived(editorStore, editor => editor != null);
|
// return derived(editorStore, editor => editor != null);
|
||||||
@@ -18,10 +19,10 @@ export default function saveTabFile(editor, saveAs, folder, format, fileExtensio
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (savedFile) {
|
if (savedFile) {
|
||||||
await axiosInstance().post('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
|
await apiCall('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
|
||||||
}
|
}
|
||||||
if (savedFilePath) {
|
if (savedFilePath) {
|
||||||
await axiosInstance().post('files/save-as', { filePath: savedFilePath, data, format });
|
await apiCall('files/save-as', { filePath: savedFilePath, data, format });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import { currentArchive } from '../stores';
|
import { currentArchive } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import { markArchiveFileAsDataSheet } from '../utility/archiveTools';
|
import { markArchiveFileAsDataSheet } from '../utility/archiveTools';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { useArchiveFiles, useArchiveFolders } from '../utility/metadataLoaders';
|
import { useArchiveFiles, useArchiveFolders } from '../utility/metadataLoaders';
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
$: files = useArchiveFiles({ folder });
|
$: files = useArchiveFiles({ folder });
|
||||||
|
|
||||||
const handleRefreshFiles = () => {
|
const handleRefreshFiles = () => {
|
||||||
axiosInstance().post('archive/refresh-files', { folder });
|
apiCall('archive/refresh-files', { folder });
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleNewDataSheet() {
|
function handleNewDataSheet() {
|
||||||
@@ -49,7 +50,7 @@
|
|||||||
label: 'New file name',
|
label: 'New file name',
|
||||||
header: 'Create new data sheet',
|
header: 'Create new data sheet',
|
||||||
onConfirm: async file => {
|
onConfirm: async file => {
|
||||||
await axiosInstance().post('archive/save-free-table', {
|
await apiCall('archive/save-free-table', {
|
||||||
folder: $currentArchive,
|
folder: $currentArchive,
|
||||||
file,
|
file,
|
||||||
data: createFreeTableModel(),
|
data: createFreeTableModel(),
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
import SearchBoxWrapper from '../elements/SearchBoxWrapper.svelte';
|
import SearchBoxWrapper from '../elements/SearchBoxWrapper.svelte';
|
||||||
import SearchInput from '../elements/SearchInput.svelte';
|
import SearchInput from '../elements/SearchInput.svelte';
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { useArchiveFolders } from '../utility/metadataLoaders';
|
import { useArchiveFolders } from '../utility/metadataLoaders';
|
||||||
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
$: folders = useArchiveFolders();
|
$: folders = useArchiveFolders();
|
||||||
|
|
||||||
const handleRefreshFolders = () => {
|
const handleRefreshFolders = () => {
|
||||||
axiosInstance().post('archive/refresh-folders', {});
|
apiCall('archive/refresh-folders');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
import { useConnectionColorFactory } from '../utility/useConnectionColor';
|
import { useConnectionColorFactory } from '../utility/useConnectionColor';
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import CloseSearchButton from '../elements/CloseSearchButton.svelte';
|
import CloseSearchButton from '../elements/CloseSearchButton.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
const connections = useConnectionList();
|
const connections = useConnectionList();
|
||||||
const serverStatus = useServerStatus();
|
const serverStatus = useServerStatus();
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
|
|
||||||
const handleRefreshConnections = () => {
|
const handleRefreshConnections = () => {
|
||||||
for (const conid of $openedConnections) {
|
for (const conid of $openedConnections) {
|
||||||
axiosInstance().post('server-connections/refresh', { conid });
|
apiCall('server-connections/refresh', { conid });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import CloseSearchButton from '../elements/CloseSearchButton.svelte';
|
import CloseSearchButton from '../elements/CloseSearchButton.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
let filter = '';
|
let filter = '';
|
||||||
let search = '';
|
let search = '';
|
||||||
@@ -18,15 +19,8 @@
|
|||||||
let historyItems = [];
|
let historyItems = [];
|
||||||
|
|
||||||
async function reloadItems() {
|
async function reloadItems() {
|
||||||
const resp = await axiosInstance().request({
|
const resp = await apiCall('query-history/read', { filter: search, limit: 100 });
|
||||||
method: 'get',
|
historyItems = resp;
|
||||||
url: 'query-history/read',
|
|
||||||
params: {
|
|
||||||
filter: search,
|
|
||||||
limit: 100,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
historyItems = resp.data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
import { extensions } from '../stores';
|
import { extensions } from '../stores';
|
||||||
import newQuery from '../query/newQuery';
|
import newQuery from '../query/newQuery';
|
||||||
import runCommand from '../commands/runCommand';
|
import runCommand from '../commands/runCommand';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
@@ -62,7 +63,7 @@
|
|||||||
// $: objectList = generateObjectList(generateIndex);
|
// $: objectList = generateObjectList(generateIndex);
|
||||||
|
|
||||||
const handleRefreshDatabase = () => {
|
const handleRefreshDatabase = () => {
|
||||||
axiosInstance().post('database-connections/refresh', { conid, database });
|
apiCall('database-connections/refresh', { conid, database });
|
||||||
};
|
};
|
||||||
|
|
||||||
function createAddMenu() {
|
function createAddMenu() {
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import { findCommand } from '../commands/runCommand';
|
import { findCommand } from '../commands/runCommand';
|
||||||
import { useConnectionColor } from '../utility/useConnectionColor';
|
import { useConnectionColor } from '../utility/useConnectionColor';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
$: databaseName = $currentDatabase && $currentDatabase.name;
|
$: databaseName = $currentDatabase && $currentDatabase.name;
|
||||||
$: connection = $currentDatabase && $currentDatabase.connection;
|
$: connection = $currentDatabase && $currentDatabase.connection;
|
||||||
@@ -64,7 +65,7 @@
|
|||||||
|
|
||||||
async function handleSyncModel() {
|
async function handleSyncModel() {
|
||||||
if (connection && databaseName) {
|
if (connection && databaseName) {
|
||||||
await axiosInstance().post('database-connections/sync-model', { conid: connection._id, database: databaseName });
|
await apiCall('database-connections/sync-model', { conid: connection._id, database: databaseName });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user