mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 20:35:59 +00:00
electron app starting
This commit is contained in:
@@ -23,9 +23,11 @@
|
||||
}
|
||||
|
||||
try {
|
||||
const settings = await axiosInstance.get('config/get-settings');
|
||||
const connections = await axiosInstance.get('connections/list');
|
||||
const config = await axiosInstance.get('config/get');
|
||||
// console.log('************** LOADING API');
|
||||
|
||||
const settings = await axiosInstance().get('config/get-settings');
|
||||
const connections = await axiosInstance().get('connections/list');
|
||||
const config = await axiosInstance().get('config/get');
|
||||
loadedApi = settings?.data && connections?.data && config?.data;
|
||||
if (!loadedApi) {
|
||||
console.log('API not initialized correctly, trying again in 1s');
|
||||
@@ -51,11 +53,11 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<DataGridRowHeightMeter />
|
||||
<ErrorHandler />
|
||||
<CommandListener />
|
||||
|
||||
{#if loadedApi}
|
||||
<DataGridRowHeightMeter />
|
||||
<CommandListener />
|
||||
<PluginsProvider />
|
||||
{#if $loadingPluginStore?.loaded}
|
||||
<OpenTabsOnStartup />
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
const connProps: any = {};
|
||||
let tooltip = undefined;
|
||||
|
||||
const resp = await axiosInstance.post('files/load', {
|
||||
const resp = await axiosInstance().post('files/load', {
|
||||
folder: 'archive:' + folderName,
|
||||
file: fileName + '.' + fileType,
|
||||
format: 'text',
|
||||
@@ -91,7 +91,7 @@
|
||||
label: 'New file name',
|
||||
header: 'Rename file',
|
||||
onConfirm: newFile => {
|
||||
axiosInstance.post('archive/rename-file', {
|
||||
axiosInstance().post('archive/rename-file', {
|
||||
file: data.fileName,
|
||||
folder: data.folderName,
|
||||
fileType: data.fileType,
|
||||
@@ -105,7 +105,7 @@
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really delete file ${data.fileName}?`,
|
||||
onConfirm: () => {
|
||||
axiosInstance.post('archive/delete-file', {
|
||||
axiosInstance().post('archive/delete-file', {
|
||||
file: data.fileName,
|
||||
folder: data.folderName,
|
||||
fileType: data.fileType,
|
||||
|
||||
@@ -26,7 +26,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 });
|
||||
axiosInstance().post('archive/delete-folder', { folder: data.name });
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -41,7 +41,7 @@
|
||||
label: 'New folder name',
|
||||
header: 'Rename folder',
|
||||
onConfirm: async newFolder => {
|
||||
await axiosInstance.post('archive/rename-folder', {
|
||||
await axiosInstance().post('archive/rename-folder', {
|
||||
folder: data.name,
|
||||
newFolder: newFolder + suffix,
|
||||
});
|
||||
@@ -78,7 +78,7 @@ await dbgateApi.deployDb(${JSON.stringify(
|
||||
};
|
||||
|
||||
const handleGenerateDeploySql = async () => {
|
||||
const resp = await axiosInstance.post('database-connections/generate-deploy-sql', {
|
||||
const resp = await axiosInstance().post('database-connections/generate-deploy-sql', {
|
||||
conid: $currentDatabase.connection._id,
|
||||
database: $currentDatabase.name,
|
||||
archiveFolder: data.name,
|
||||
|
||||
@@ -44,14 +44,14 @@
|
||||
const handleConnect = () => {
|
||||
if (data.singleDatabase) {
|
||||
$currentDatabase = { connection: data, name: data.defaultDatabase };
|
||||
axiosInstance.post('database-connections/refresh', {
|
||||
axiosInstance().post('database-connections/refresh', {
|
||||
conid: data._id,
|
||||
database: data.defaultDatabase,
|
||||
keepOpen: true,
|
||||
});
|
||||
} else {
|
||||
$openedConnections = _.uniq([...$openedConnections, data._id]);
|
||||
axiosInstance.post('server-connections/refresh', {
|
||||
axiosInstance().post('server-connections/refresh', {
|
||||
conid: data._id,
|
||||
keepOpen: true,
|
||||
});
|
||||
@@ -61,16 +61,16 @@
|
||||
const getContextMenu = () => {
|
||||
const config = getCurrentConfig();
|
||||
const handleRefresh = () => {
|
||||
axiosInstance.post('server-connections/refresh', { conid: data._id });
|
||||
axiosInstance().post('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 });
|
||||
axiosInstance().post('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 });
|
||||
axiosInstance().post('database-connections/disconnect', { conid: data._id, database: $currentDatabase.name });
|
||||
}
|
||||
currentDatabase.set(null);
|
||||
}
|
||||
@@ -81,11 +81,11 @@
|
||||
const handleDelete = () => {
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really delete connection ${getConnectionLabel(data)}?`,
|
||||
onConfirm: () => axiosInstance.post('connections/delete', data),
|
||||
onConfirm: () => axiosInstance().post('connections/delete', data),
|
||||
});
|
||||
};
|
||||
const handleDuplicate = () => {
|
||||
axiosInstance.post('connections/save', {
|
||||
axiosInstance().post('connections/save', {
|
||||
...data,
|
||||
_id: undefined,
|
||||
displayName: `${getConnectionLabel(data)} - copy`,
|
||||
@@ -97,7 +97,7 @@
|
||||
value: 'newdb',
|
||||
label: 'Database name',
|
||||
onConfirm: name =>
|
||||
axiosInstance.post('server-connections/create-database', {
|
||||
axiosInstance().post('server-connections/create-database', {
|
||||
conid: data._id,
|
||||
name,
|
||||
}),
|
||||
|
||||
@@ -48,13 +48,13 @@
|
||||
header: 'Create collection',
|
||||
onConfirm: async newCollection => {
|
||||
const dbid = { conid: connection._id, database: name };
|
||||
await axiosInstance.request({
|
||||
await axiosInstance().request({
|
||||
url: 'database-connections/run-script',
|
||||
method: 'post',
|
||||
params: dbid,
|
||||
data: { sql: `db.createCollection('${newCollection}')` },
|
||||
});
|
||||
axiosInstance.post('database-connections/sync-model', dbid);
|
||||
axiosInstance().post('database-connections/sync-model', dbid);
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -90,13 +90,13 @@
|
||||
|
||||
const handleDisconnect = () => {
|
||||
if (electron) {
|
||||
axiosInstance.post('database-connections/disconnect', { conid: connection._id, database: name });
|
||||
axiosInstance().post('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 axiosInstance().post('database-connections/export-model', {
|
||||
conid: connection._id,
|
||||
database: name,
|
||||
});
|
||||
|
||||
@@ -559,13 +559,13 @@
|
||||
message: `Really drop collection ${data.pureName}?`,
|
||||
onConfirm: async () => {
|
||||
const dbid = _.pick(data, ['conid', 'database']);
|
||||
await axiosInstance.request({
|
||||
await axiosInstance().request({
|
||||
url: 'database-connections/run-script',
|
||||
method: 'post',
|
||||
params: dbid,
|
||||
data: { sql: `db.dropCollection('${data.pureName}')` },
|
||||
});
|
||||
axiosInstance.post('database-connections/sync-model', dbid);
|
||||
axiosInstance().post('database-connections/sync-model', dbid);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
const { icon, tabComponent, title, props, tabdata } = favorite;
|
||||
let tabdataNew = tabdata;
|
||||
if (props.savedFile) {
|
||||
const resp = await axiosInstance.post('files/load', {
|
||||
const resp = await axiosInstance().post('files/load', {
|
||||
folder: props.savedFolder,
|
||||
file: props.savedFile,
|
||||
format: props.savedFormat,
|
||||
@@ -47,7 +47,7 @@
|
||||
};
|
||||
|
||||
const editFavoriteJson = async () => {
|
||||
const resp = await axiosInstance.post('files/load', {
|
||||
const resp = await axiosInstance().post('files/load', {
|
||||
folder: 'favorites',
|
||||
file: data.file,
|
||||
format: 'text',
|
||||
@@ -76,7 +76,7 @@
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really delete favorite ${data.title}?`,
|
||||
onConfirm: () => {
|
||||
axiosInstance.post('files/delete', { file: data.file, folder: 'favorites' });
|
||||
axiosInstance().post('files/delete', { file: data.file, folder: 'favorites' });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really delete file ${data.file}?`,
|
||||
onConfirm: () => {
|
||||
axiosInstance.post('files/delete', data);
|
||||
axiosInstance().post('files/delete', data);
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -125,7 +125,7 @@
|
||||
label: 'New file name',
|
||||
header: 'Rename file',
|
||||
onConfirm: newFile => {
|
||||
axiosInstance.post('files/rename', { ...data, newFile });
|
||||
axiosInstance().post('files/rename', { ...data, newFile });
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -136,13 +136,13 @@
|
||||
label: 'New file name',
|
||||
header: 'Rename file',
|
||||
onConfirm: newFile => {
|
||||
axiosInstance.post('files/copy', { ...data, newFile });
|
||||
axiosInstance().post('files/copy', { ...data, newFile });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
async function openTab() {
|
||||
const resp = await axiosInstance.post('files/load', { folder, file: data.file, format: handler.format });
|
||||
const resp = await axiosInstance().post('files/load', { folder, file: data.file, format: handler.format });
|
||||
|
||||
const connProps: any = {};
|
||||
let tooltip = undefined;
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
export async function exportChart() {
|
||||
saveFileToDisk(async filePath => {
|
||||
await axiosInstance.post('files/export-chart', {
|
||||
await axiosInstance().post('files/export-chart', {
|
||||
title,
|
||||
filePath,
|
||||
config: {
|
||||
|
||||
@@ -16,7 +16,7 @@ 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 });
|
||||
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);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ 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 });
|
||||
const resp = await axiosInstance().post('database-connections/query-data', { conid, database, sql: dmp.s });
|
||||
let { rows, columns, errorMessage } = resp.data;
|
||||
if (errorMessage) {
|
||||
throw new Error(errorMessage);
|
||||
|
||||
@@ -22,19 +22,19 @@ registerCommand({
|
||||
{
|
||||
text: 'Sync model',
|
||||
onClick: () => {
|
||||
axiosInstance.post('database-connections/sync-model', dbid);
|
||||
axiosInstance().post('database-connections/sync-model', dbid);
|
||||
},
|
||||
},
|
||||
{
|
||||
text: 'Reopen',
|
||||
onClick: () => {
|
||||
axiosInstance.post('database-connections/refresh', dbid);
|
||||
axiosInstance().post('database-connections/refresh', dbid);
|
||||
},
|
||||
},
|
||||
{
|
||||
text: 'Disconnect',
|
||||
onClick: () => {
|
||||
if (electron) axiosInstance.post('database-connections/disconnect', dbid);
|
||||
if (electron) axiosInstance().post('database-connections/disconnect', dbid);
|
||||
currentDatabase.set(null);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -123,7 +123,7 @@ registerCommand({
|
||||
label: 'New archive folder name',
|
||||
header: 'Create archive folder',
|
||||
onConfirm: async folder => {
|
||||
axiosInstance.post('archive/create-folder', { folder });
|
||||
axiosInstance().post('archive/create-folder', { folder });
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -190,13 +190,13 @@ registerCommand({
|
||||
label: 'New collection name',
|
||||
header: 'Create collection',
|
||||
onConfirm: async newCollection => {
|
||||
await axiosInstance.request({
|
||||
await axiosInstance().request({
|
||||
url: 'database-connections/run-script',
|
||||
method: 'post',
|
||||
params: dbid,
|
||||
data: { sql: `db.createCollection('${newCollection}')` },
|
||||
});
|
||||
axiosInstance.post('database-connections/sync-model', dbid);
|
||||
axiosInstance().post('database-connections/sync-model', dbid);
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -258,7 +258,7 @@ registerCommand({
|
||||
label: 'New database name',
|
||||
header: 'Create SQLite database',
|
||||
onConfirm: async file => {
|
||||
const resp = await axiosInstance.post('connections/new-sqlite-database', { file });
|
||||
const resp = await axiosInstance().post('connections/new-sqlite-database', { file });
|
||||
const connection = resp.data;
|
||||
currentDatabase.set({ connection, name: `${file}.sqlite` });
|
||||
},
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
export async function loadCollectionDataPage(props, offset, limit) {
|
||||
const { conid, database } = props;
|
||||
|
||||
const response = await axiosInstance.request({
|
||||
const response = await axiosInstance().request({
|
||||
url: 'database-connections/collection-data',
|
||||
method: 'post',
|
||||
params: {
|
||||
@@ -95,7 +95,7 @@
|
||||
async function loadRowCount(props) {
|
||||
const { conid, database } = props;
|
||||
|
||||
const response = await axiosInstance.request({
|
||||
const response = await axiosInstance().request({
|
||||
url: 'database-connections/collection-data',
|
||||
method: 'post',
|
||||
params: {
|
||||
|
||||
@@ -404,7 +404,7 @@
|
||||
}
|
||||
|
||||
export async function reconnect() {
|
||||
await axiosInstance.post('database-connections/refresh', { conid, database });
|
||||
await axiosInstance().post('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 axiosInstance().post('jsldata/get-rows', {
|
||||
jslid,
|
||||
offset,
|
||||
limit,
|
||||
@@ -30,7 +30,7 @@
|
||||
async function loadRowCount(props) {
|
||||
const { jslid } = props;
|
||||
|
||||
const response = await axiosInstance.request({
|
||||
const response = await axiosInstance().request({
|
||||
url: 'jsldata/get-stats',
|
||||
method: 'get',
|
||||
params: {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
const sql = display.getPageQuery(offset, limit);
|
||||
|
||||
const response = await axiosInstance.request({
|
||||
const response = await axiosInstance().request({
|
||||
url: 'database-connections/query-data',
|
||||
method: 'post',
|
||||
params: {
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
const sql = display.getCountQuery();
|
||||
|
||||
const response = await axiosInstance.request({
|
||||
const response = await axiosInstance().request({
|
||||
url: 'database-connections/query-data',
|
||||
method: 'post',
|
||||
params: {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
];
|
||||
|
||||
const createOption = folder => {
|
||||
axiosInstance.post('archive/create-folder', { folder });
|
||||
axiosInstance().post('archive/create-folder', { folder });
|
||||
setFieldValue(name, folder);
|
||||
};
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
}
|
||||
|
||||
export async function reconnect() {
|
||||
await axiosInstance.post('database-connections/refresh', { conid, database });
|
||||
await axiosInstance().post('database-connections/refresh', { conid, database });
|
||||
formDisplay.reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
if (!sql) return null;
|
||||
|
||||
const response = await axiosInstance.request({
|
||||
const response = await axiosInstance().request({
|
||||
url: 'database-connections/query-data',
|
||||
method: 'post',
|
||||
params: {
|
||||
@@ -124,7 +124,7 @@
|
||||
$: if (onReferenceSourceChanged && rowData) onReferenceSourceChanged([rowData], loadedTime);
|
||||
|
||||
// async function handleConfirmSql(sql) {
|
||||
// const resp = await axiosInstance.request({
|
||||
// const resp = await axiosInstance().request({
|
||||
// url: 'database-connections/query-data',
|
||||
// method: 'post',
|
||||
// params: {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
export async function exportGrid() {
|
||||
const jslid = uuidv1();
|
||||
await axiosInstance.post('jsldata/save-free-table', { jslid, data: modelState.value });
|
||||
await axiosInstance().post('jsldata/save-free-table', { jslid, data: modelState.value });
|
||||
const initialValues: any = {};
|
||||
initialValues.sourceStorageType = 'jsldata';
|
||||
initialValues.sourceJslId = jslid;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
}
|
||||
errorMessage = null;
|
||||
isLoading = true;
|
||||
const resp = await axiosInstance.post('runners/load-reader', sourceReader);
|
||||
const resp = await axiosInstance().post('runners/load-reader', sourceReader);
|
||||
// @ts-ignore
|
||||
model = resp.data;
|
||||
grider = new RowsArrayGrider(resp.data.rows);
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
value = e.detail;
|
||||
|
||||
if (database) {
|
||||
axiosInstance.post('connections/update-database', {
|
||||
axiosInstance().post('connections/update-database', {
|
||||
conid,
|
||||
database,
|
||||
values: { connectionColor: e.detail },
|
||||
});
|
||||
} else {
|
||||
axiosInstance.post('connections/update', {
|
||||
axiosInstance().post('connections/update', {
|
||||
_id: conid,
|
||||
values: { connectionColor: e.detail },
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
value="OK"
|
||||
on:click={e => {
|
||||
closeCurrentModal();
|
||||
axiosInstance.post('config/update-settings', {
|
||||
axiosInstance().post('config/update-settings', {
|
||||
commands: {
|
||||
...$commandsSettings,
|
||||
[command.id]: {
|
||||
@@ -58,7 +58,7 @@
|
||||
value="Reset"
|
||||
on:click={() => {
|
||||
closeCurrentModal();
|
||||
axiosInstance.post('config/update-settings', {
|
||||
axiosInstance().post('config/update-settings', {
|
||||
commands: _.omit($commandsSettings, [command.id]),
|
||||
});
|
||||
}}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
isTesting = true;
|
||||
testIdRef.update(x => x + 1);
|
||||
const testid = testIdRef.get();
|
||||
const resp = await axiosInstance.post('connections/test', e.detail);
|
||||
const resp = await axiosInstance().post('connections/test', e.detail);
|
||||
if (testIdRef.get() != testid) return;
|
||||
|
||||
isTesting = false;
|
||||
@@ -70,7 +70,7 @@
|
||||
let connection = _.omit(e.detail, omitProps);
|
||||
if (driver?.beforeConnectionSave) connection = driver?.beforeConnectionSave(connection);
|
||||
|
||||
axiosInstance.post('connections/save', connection);
|
||||
axiosInstance().post('connections/save', connection);
|
||||
closeCurrentModal();
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
dumpSqlSelect(dmp, select);
|
||||
|
||||
isLoading = true;
|
||||
const response = await axiosInstance.request({
|
||||
const response = await axiosInstance().request({
|
||||
url: 'database-connections/query-data',
|
||||
method: 'post',
|
||||
params: {
|
||||
|
||||
@@ -69,7 +69,7 @@ import FormButton from '../forms/FormButton.svelte';
|
||||
const saveTab = async values => {
|
||||
const data = await getTabSaveData(values);
|
||||
|
||||
axiosInstance.post('files/save', {
|
||||
axiosInstance().post('files/save', {
|
||||
folder: 'favorites',
|
||||
file: uuidv1(),
|
||||
format: 'json',
|
||||
@@ -78,13 +78,13 @@ import FormButton from '../forms/FormButton.svelte';
|
||||
};
|
||||
|
||||
const saveFile = async values => {
|
||||
const oldDataResp = await axiosInstance.post('files/load', {
|
||||
const oldDataResp = await axiosInstance().post('files/load', {
|
||||
folder: 'favorites',
|
||||
file: editingData.file,
|
||||
format: 'json',
|
||||
});
|
||||
|
||||
axiosInstance.post('files/save', {
|
||||
axiosInstance().post('files/save', {
|
||||
folder: 'favorites',
|
||||
file: editingData.file,
|
||||
format: 'json',
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
const handleRunnerDone = () => {
|
||||
busy = false;
|
||||
if (refreshArchiveFolderRef.get()) {
|
||||
axiosInstance.post('archive/refresh-folders', {});
|
||||
axiosInstance.post('archive/refresh-files', { folder: refreshArchiveFolderRef.get() });
|
||||
axiosInstance().post('archive/refresh-folders', {});
|
||||
axiosInstance().post('archive/refresh-files', { folder: refreshArchiveFolderRef.get() });
|
||||
$currentArchive = refreshArchiveFolderRef.get();
|
||||
$selectedWidget = 'archive';
|
||||
}
|
||||
@@ -108,7 +108,7 @@
|
||||
const script = await createImpExpScript($extensions, values);
|
||||
executeNumber += 1;
|
||||
let runid = runnerId;
|
||||
const resp = await axiosInstance.post('runners/start', { script });
|
||||
const resp = await axiosInstance().post('runners/start', { script });
|
||||
runid = resp.data.runid;
|
||||
runnerId = runid;
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
axiosInstance.post('runners/cancel', {
|
||||
axiosInstance().post('runners/cancel', {
|
||||
runid: runnerId,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
const handleSubmit = async e => {
|
||||
const { name } = e.detail;
|
||||
await axiosInstance.post('files/save', { folder, file: name, data, format });
|
||||
await axiosInstance().post('files/save', { folder, file: name, data, format });
|
||||
closeCurrentModal();
|
||||
if (onSave) {
|
||||
onSave(name, {
|
||||
@@ -38,7 +38,7 @@
|
||||
const parsed = path.parse(filePath);
|
||||
// if (!parsed.ext) filePath += `.${fileExtension}`;
|
||||
|
||||
await axiosInstance.post('files/save-as', { filePath, data, format });
|
||||
await axiosInstance().post('files/save-as', { filePath, data, format });
|
||||
closeCurrentModal();
|
||||
|
||||
if (onSave) {
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
const loadid = uuidv1();
|
||||
loadRef.set(loadid);
|
||||
busy = true;
|
||||
const response = await axiosInstance.post('database-connections/sql-preview', {
|
||||
const response = await axiosInstance().post('database-connections/sql-preview', {
|
||||
conid,
|
||||
database,
|
||||
objects,
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
dumpSqlSelect(dmp, select);
|
||||
|
||||
isLoading = true;
|
||||
const response = await axiosInstance.request({
|
||||
const response = await axiosInstance().request({
|
||||
url: 'database-connections/query-data',
|
||||
method: 'post',
|
||||
params: {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
loaded: false,
|
||||
loadingPackageName: installed.name,
|
||||
});
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
method: 'get',
|
||||
url: 'plugins/script',
|
||||
params: {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
$: $effect;
|
||||
|
||||
const handleRunnerDone = async () => {
|
||||
const resp = await axiosInstance.get(`runners/files?runid=${runnerId}`);
|
||||
const resp = await axiosInstance().get(`runners/files?runid=${runnerId}`);
|
||||
files = resp.data;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
|
||||
function handleOk(e) {
|
||||
axiosInstance.post(
|
||||
axiosInstance().post(
|
||||
'config/update-settings',
|
||||
_.omitBy(e.detail, (v, k) => k.startsWith(':'))
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
const handleLoad = async () => {
|
||||
isLoading = true;
|
||||
const resp = await axiosInstance.get('config/changelog');
|
||||
const resp = await axiosInstance().get('config/changelog');
|
||||
text = resp.data;
|
||||
isLoading = false;
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
// $: console.log('LOADED ROWS MONGO', loadedRows);
|
||||
|
||||
async function handleConfirmChange(changeSet) {
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
url: 'database-connections/update-collection',
|
||||
method: 'post',
|
||||
params: {
|
||||
|
||||
@@ -228,7 +228,7 @@
|
||||
|
||||
export async function showReport() {
|
||||
saveFileToDisk(async filePath => {
|
||||
await axiosInstance.post('database-connections/generate-db-diff-report', {
|
||||
await axiosInstance().post('database-connections/generate-db-diff-report', {
|
||||
filePath,
|
||||
sourceConid: $values?.sourceConid,
|
||||
sourceDatabase: $values?.sourceDatabase,
|
||||
@@ -261,11 +261,11 @@
|
||||
}
|
||||
|
||||
export function refreshModels() {
|
||||
axiosInstance.post('database-connections/sync-model', {
|
||||
axiosInstance().post('database-connections/sync-model', {
|
||||
conid: $values?.targetConid,
|
||||
database: $values?.targetDatabase,
|
||||
});
|
||||
axiosInstance.post('database-connections/sync-model', {
|
||||
axiosInstance().post('database-connections/sync-model', {
|
||||
conid: $values?.sourceConid,
|
||||
database: $values?.sourceDatabase,
|
||||
});
|
||||
@@ -275,7 +275,7 @@
|
||||
const conid = $values?.targetConid;
|
||||
const database = $values?.targetDatabase;
|
||||
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
url: 'database-connections/run-script',
|
||||
method: 'post',
|
||||
params: { conid, database },
|
||||
@@ -286,7 +286,7 @@
|
||||
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 axiosInstance().post('database-connections/sync-model', { conid, database });
|
||||
showSnackbarSuccess('Saved to database');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
export function save() {
|
||||
try {
|
||||
const data = JSON.parse(getData());
|
||||
axiosInstance.post('files/save', {
|
||||
axiosInstance().post('files/save', {
|
||||
file: savedFile,
|
||||
folder: 'favorites',
|
||||
format: 'json',
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
tabid,
|
||||
loadFromArgs:
|
||||
initialArgs && initialArgs.functionName
|
||||
? () => axiosInstance.post('runners/load-reader', initialArgs).then(x => x.data)
|
||||
? () => axiosInstance().post('runners/load-reader', initialArgs).then(x => x.data)
|
||||
: null,
|
||||
onInitialData: value => {
|
||||
dispatchModel({ type: 'reset', value });
|
||||
@@ -84,7 +84,7 @@
|
||||
}
|
||||
|
||||
const doSave = async (folder, file) => {
|
||||
await axiosInstance.post('archive/save-free-table', { folder, file, data: $modelState.value });
|
||||
await axiosInstance().post('archive/save-free-table', { folder, file, data: $modelState.value });
|
||||
changeTab(tabid, tab => ({
|
||||
...tab,
|
||||
title: file,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
const handleLoad = async () => {
|
||||
isLoading = true;
|
||||
const resp = await axiosInstance.post('files/load', {
|
||||
const resp = await axiosInstance().post('files/load', {
|
||||
folder: 'markdown',
|
||||
file: savedFile,
|
||||
format: 'text',
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
$: isPackaged = $info?.isPackaged;
|
||||
|
||||
const handleInstall = async () => {
|
||||
axiosInstance.post('plugins/install', { packageName });
|
||||
axiosInstance().post('plugins/install', { packageName });
|
||||
};
|
||||
const handleUninstall = async () => {
|
||||
axiosInstance.post('plugins/uninstall', { packageName });
|
||||
axiosInstance().post('plugins/uninstall', { packageName });
|
||||
};
|
||||
const handleUpgrade = async () => {
|
||||
axiosInstance.post('plugins/upgrade', { packageName });
|
||||
axiosInstance().post('plugins/upgrade', { packageName });
|
||||
};
|
||||
|
||||
$: installedFound = $installed?.find(x => x.name == packageName);
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
let sesid = sessionId;
|
||||
if (!sesid) {
|
||||
const resp = await axiosInstance.post('sessions/create', {
|
||||
const resp = await axiosInstance().post('sessions/create', {
|
||||
conid,
|
||||
database,
|
||||
});
|
||||
@@ -114,14 +114,14 @@
|
||||
}
|
||||
busy = true;
|
||||
timerLabel.start();
|
||||
await axiosInstance.post('sessions/execute-query', {
|
||||
await axiosInstance().post('sessions/execute-query', {
|
||||
sesid,
|
||||
sql: sqlPreview,
|
||||
});
|
||||
}
|
||||
|
||||
export async function kill() {
|
||||
await axiosInstance.post('sessions/kill', {
|
||||
await axiosInstance().post('sessions/kill', {
|
||||
sesid: sessionId,
|
||||
});
|
||||
sessionId = null;
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
let sesid = sessionId;
|
||||
if (!sesid) {
|
||||
const resp = await axiosInstance.post('sessions/create', {
|
||||
const resp = await axiosInstance().post('sessions/create', {
|
||||
conid,
|
||||
database,
|
||||
});
|
||||
@@ -159,11 +159,11 @@
|
||||
}
|
||||
busy = true;
|
||||
timerLabel.start();
|
||||
await axiosInstance.post('sessions/execute-query', {
|
||||
await axiosInstance().post('sessions/execute-query', {
|
||||
sesid,
|
||||
sql,
|
||||
});
|
||||
await axiosInstance.post('query-history/write', {
|
||||
await axiosInstance().post('query-history/write', {
|
||||
data: {
|
||||
sql,
|
||||
conid,
|
||||
@@ -184,7 +184,7 @@
|
||||
}
|
||||
|
||||
export async function kill() {
|
||||
await axiosInstance.post('sessions/kill', {
|
||||
await axiosInstance().post('sessions/kill', {
|
||||
sesid: sessionId,
|
||||
});
|
||||
sessionId = null;
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
}
|
||||
|
||||
export async function copyNodeScript() {
|
||||
const resp = await axiosInstance.post('runners/get-node-script', { script: getActiveScript() });
|
||||
const resp = await axiosInstance().post('runners/get-node-script', { script: getActiveScript() });
|
||||
copyTextToClipboard(resp.data);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@
|
||||
executeNumber += 1;
|
||||
|
||||
let runid = runnerId;
|
||||
const resp = await axiosInstance.post('runners/start', {
|
||||
const resp = await axiosInstance().post('runners/start', {
|
||||
script: getActiveScript(),
|
||||
});
|
||||
runid = resp.data.runid;
|
||||
@@ -186,7 +186,7 @@
|
||||
}
|
||||
|
||||
export function kill() {
|
||||
axiosInstance.post('runners/cancel', {
|
||||
axiosInstance().post('runners/cancel', {
|
||||
runid: runnerId,
|
||||
});
|
||||
timerLabel.stop();
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
const [changeSetStore, dispatchChangeSet] = createUndoReducer(createChangeSet());
|
||||
|
||||
async function handleConfirmSql(sql) {
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
url: 'database-connections/run-script',
|
||||
method: 'post',
|
||||
params: {
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
}
|
||||
|
||||
async function handleConfirmSql(sql, createTableName) {
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
url: 'database-connections/run-script',
|
||||
method: 'post',
|
||||
params: {
|
||||
@@ -154,14 +154,14 @@
|
||||
}));
|
||||
}
|
||||
|
||||
await axiosInstance.post('database-connections/sync-model', { conid, database });
|
||||
await axiosInstance().post('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 axiosInstance().post('database-connections/sync-model', { conid, database });
|
||||
clearEditorData();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import localforage from 'localforage';
|
||||
import _ from 'lodash';
|
||||
import { openedTabs } from '../stores';
|
||||
import { getLocalStorage, setLocalStorage } from './storageCache';
|
||||
|
||||
let counter = 0;
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function alterDatabaseDialog(conid, database, updateFunc) {
|
||||
sql,
|
||||
recreates,
|
||||
onConfirm: async () => {
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
url: 'database-connections/run-script',
|
||||
method: 'post',
|
||||
params: {
|
||||
@@ -30,7 +30,7 @@ export async function alterDatabaseDialog(conid, database, updateFunc) {
|
||||
},
|
||||
data: { sql },
|
||||
});
|
||||
await axiosInstance.post('database-connections/sync-model', { conid, database });
|
||||
await axiosInstance().post('database-connections/sync-model', { conid, database });
|
||||
},
|
||||
engine: driver.engine,
|
||||
});
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import axios from 'axios';
|
||||
import resolveApi, { resolveApiHeaders } from './resolveApi';
|
||||
|
||||
let axiosInstance;
|
||||
let instance;
|
||||
|
||||
function recreateAxiosInstance() {
|
||||
axiosInstance = axios.create({
|
||||
instance = axios.create({
|
||||
baseURL: resolveApi(),
|
||||
});
|
||||
|
||||
axiosInstance.defaults.headers = {
|
||||
instance.defaults.headers = {
|
||||
'Cache-Control': 'no-cache',
|
||||
Pragma: 'no-cache',
|
||||
Expires: '0',
|
||||
@@ -20,4 +20,6 @@ window['dbgate_recreateAxiosInstance'] = recreateAxiosInstance;
|
||||
|
||||
recreateAxiosInstance();
|
||||
|
||||
export default axiosInstance;
|
||||
export default function axiosInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ import { openedConnections, currentDatabase } from '../stores';
|
||||
import axiosInstance from './axiosInstance';
|
||||
|
||||
const doServerPing = value => {
|
||||
axiosInstance.post('server-connections/ping', { connections: value });
|
||||
axiosInstance().post('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 });
|
||||
axiosInstance().post('database-connections/ping', { conid, database });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export async function exportElectronFile(dataName, reader, format) {
|
||||
script.copyStream(sourceVar, targetVar);
|
||||
script.put();
|
||||
|
||||
const resp = await axiosInstance.post('runners/start', { script: script.getScript() });
|
||||
const resp = await axiosInstance().post('runners/start', { script: script.getScript() });
|
||||
const runid = resp.data.runid;
|
||||
let isCanceled = false;
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function exportElectronFile(dataName, reader, format) {
|
||||
label: 'Cancel',
|
||||
onClick: () => {
|
||||
isCanceled = true;
|
||||
axiosInstance.post('runners/cancel', { runid });
|
||||
axiosInstance().post('runners/cancel', { runid });
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -74,7 +74,7 @@ export async function saveFileToDisk(
|
||||
await filePathFunc(filePath);
|
||||
electron.shell.openExternal('file:///' + filePath);
|
||||
} else {
|
||||
const resp = await axiosInstance.get('files/generate-uploads-file');
|
||||
const resp = await axiosInstance().get('files/generate-uploads-file');
|
||||
await filePathFunc(resp.data.filePath);
|
||||
window.open(`${resolveApi()}/uploads/get?file=${resp.data.fileName}`, '_blank');
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ async function getCore(loader, args) {
|
||||
const key = stableStringify({ url, ...params });
|
||||
|
||||
async function doLoad() {
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
method: 'get',
|
||||
url,
|
||||
params,
|
||||
@@ -169,7 +169,7 @@ function useCore(loader, args) {
|
||||
subscribe: onChange => {
|
||||
async function handleReload() {
|
||||
async function doLoad() {
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
method: 'get',
|
||||
params,
|
||||
url,
|
||||
|
||||
@@ -12,7 +12,7 @@ export async function openArchiveFolder() {
|
||||
});
|
||||
const linkedFolder = filePaths && filePaths[0];
|
||||
if (!linkedFolder) return;
|
||||
const resp = await axiosInstance.post('archive/create-link', { linkedFolder });
|
||||
const resp = await axiosInstance().post('archive/create-link', { linkedFolder });
|
||||
|
||||
currentArchive.set(resp.data);
|
||||
selectedWidget.set('archive');
|
||||
|
||||
@@ -21,7 +21,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 axiosInstance().post('connections/save', {
|
||||
_id: undefined,
|
||||
databaseFile: filePath,
|
||||
engine: 'sqlite@dbgate-plugin-sqlite',
|
||||
|
||||
@@ -18,10 +18,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 axiosInstance().post('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
|
||||
}
|
||||
if (savedFilePath) {
|
||||
await axiosInstance.post('files/save-as', { filePath: savedFilePath, data, format });
|
||||
await axiosInstance().post('files/save-as', { filePath: savedFilePath, data, format });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
$: files = useArchiveFiles({ folder });
|
||||
|
||||
const handleRefreshFiles = () => {
|
||||
axiosInstance.post('archive/refresh-files', { folder });
|
||||
axiosInstance().post('archive/refresh-files', { folder });
|
||||
};
|
||||
|
||||
function handleNewDataSheet() {
|
||||
@@ -49,7 +49,7 @@
|
||||
label: 'New file name',
|
||||
header: 'Create new data sheet',
|
||||
onConfirm: async file => {
|
||||
await axiosInstance.post('archive/save-free-table', {
|
||||
await axiosInstance().post('archive/save-free-table', {
|
||||
folder: $currentArchive,
|
||||
file,
|
||||
data: createFreeTableModel(),
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
$: folders = useArchiveFolders();
|
||||
|
||||
const handleRefreshFolders = () => {
|
||||
axiosInstance.post('archive/refresh-folders', {});
|
||||
axiosInstance().post('archive/refresh-folders', {});
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
const handleRefreshConnections = () => {
|
||||
for (const conid of $openedConnections) {
|
||||
axiosInstance.post('server-connections/refresh', { conid });
|
||||
axiosInstance().post('server-connections/refresh', { conid });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
let historyItems = [];
|
||||
|
||||
async function reloadItems() {
|
||||
const resp = await axiosInstance.request({
|
||||
const resp = await axiosInstance().request({
|
||||
method: 'get',
|
||||
url: 'query-history/read',
|
||||
params: {
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
// $: objectList = generateObjectList(generateIndex);
|
||||
|
||||
const handleRefreshDatabase = () => {
|
||||
axiosInstance.post('database-connections/refresh', { conid, database });
|
||||
axiosInstance().post('database-connections/refresh', { conid, database });
|
||||
};
|
||||
|
||||
function createAddMenu() {
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
async function handleSyncModel() {
|
||||
if (connection && databaseName) {
|
||||
await axiosInstance.post('database-connections/sync-model', { conid: connection._id, database: databaseName });
|
||||
await axiosInstance().post('database-connections/sync-model', { conid: connection._id, database: databaseName });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user