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