aboutsummaryrefslogtreecommitdiff
path: root/new-connection.js
diff options
context:
space:
mode:
Diffstat (limited to 'new-connection.js')
-rw-r--r--new-connection.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/new-connection.js b/new-connection.js
new file mode 100644
index 0000000..2493c25
--- /dev/null
+++ b/new-connection.js
@@ -0,0 +1,46 @@
+"use strict";
+
+const { remote, ipcRenderer } = require("electron");
+const $ = window.jQuery = require("jquery");
+
+function cancel() {
+ let confirm = remote.dialog.showMessageBox(remote.getCurrentWindow(), {
+ type: "question",
+ buttons: ["Yes", "No"],
+ title: "Confirm",
+ message: "Remove this connection?"
+ });
+
+ if (confirm === 0) {
+ remote.getCurrentWindow().close();
+ }
+}
+
+function parseForm() {
+ let formData = {};
+
+ $("form").serializeArray().forEach((input) => {
+ formData[input.name] = input.value;
+ });
+
+ return formData;
+}
+
+function createConnection() {
+ let connectionProps = parseForm();
+ ipcRenderer.send("newConnection.createConnection", connectionProps);
+}
+
+$(document).ready(() => {
+ $("#create-connection").click(() => {
+ createConnection();
+ });
+
+ $("#test-connection").click(() => {
+ //TODO
+ });
+
+ $("#cancel").click(() => {
+ cancel();
+ });
+}); \ No newline at end of file