axiosInstance replaced with apiCall

This commit is contained in:
Jan Prochazka
2021-12-22 10:16:44 +01:00
parent 148af24b2c
commit f9c54cdce2
55 changed files with 257 additions and 328 deletions

View File

@@ -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');
}
}