diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2018-02-25 13:31:00 +0000 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2018-02-25 13:31:00 +0000 |
| commit | 1c9e90c1619d56f199c119874d09263acd827b07 (patch) | |
| tree | ea474cb0809d4ad27ba0460165d10eacb749fbe0 /main.js | |
| parent | 11e98009906651acb110cd3b1625a771b1e2f472 (diff) | |
| download | sql-plus-plus-1c9e90c1619d56f199c119874d09263acd827b07.tar.xz sql-plus-plus-1c9e90c1619d56f199c119874d09263acd827b07.zip | |
Report connection errors. Add test connection functionality
Diffstat (limited to 'main.js')
| -rw-r--r-- | main.js | 33 |
1 files changed, 24 insertions, 9 deletions
@@ -43,7 +43,7 @@ app.on("activate", () => { function createNewConnectionDialog() { newConnectionDialog = new BrowserWindow({ width: 400, - height: 540 + height: 600 }); newConnectionDialog.loadURL(url.format({ pathname: path.join(__dirname, "new-connection.html"), @@ -83,17 +83,32 @@ ipcMain.on("newConnection.createConnection", (event, payload) => { }); -ipcMain.on("queryExecutor.initialiseConnectionCallback", (event, executorId) => { - // TODO - handle connection initialisation errors +ipcMain.on("queryExecutor.initialiseConnectionCallback", (event, payload) => { + + if (payload.error !== undefined) { + queryExecutors.pop().close(); + newConnectionDialog.webContents.send("newConnection.initialisationFailed", payload.error); + } + else { + let connectionConfig = getQueryExecutorInstance().connectionConfig; + + if(connectionConfig.isTest) { + newConnectionDialog.webContents.send("newConnection.connectionTestOk"); + queryExecutors.pop().close(); + } + else{ + uiWindow.webContents.send("instanceManager.registerNewInstance", { assignedQueryExecutorId: payload.executorId, connectionName: connectionConfig.name }); + newConnectionDialog.close(); + } + } - // Bit of a hack, cant guarantee this was the executor which just got initalised.executor - // Should pass it back from the executor via the payload - let connectionName = queryExecutors[queryExecutors.length -1].connectionConfig.name; - - uiWindow.webContents.send("instanceManager.registerNewInstance", {assignedQueryExecutorId: executorId, connectionName: connectionName}); - newConnectionDialog.close(); }); +function getQueryExecutorInstance() { + // Bit of a hack, cant guarantee this was the executor which just got initalised + // Should pass it back from the executor via the payload + return queryExecutors[queryExecutors.length - 1]; +} const { webContents } = require('electron'); |