electron app starting

This commit is contained in:
Jan Prochazka
2021-12-16 11:46:33 +01:00
parent 0a7c56dace
commit e636987f31
60 changed files with 132 additions and 129 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,
}),

View File

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

View File

@@ -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 {

View File

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

View File

@@ -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;