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