mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 13:06:01 +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>
|
||||
|
||||
Reference in New Issue
Block a user