mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 21:16:00 +00:00
axiosInstance replaced with apiCall
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user