From f688ba071d6464f2059028988eed51f3d22fd058 Mon Sep 17 00:00:00 2001
From: Sting <loic.allegre@ensiie.fr>
Date: Mon, 21 Sep 2020 12:22:14 +0200
Subject: [PATCH] MISC: Added a quit button

---
 instance/index.html | 16 ++++++++++++----
 instance/index.js   |  9 +++++++++
 instance/main.js    |  7 +++++--
 3 files changed, 26 insertions(+), 6 deletions(-)
 create mode 100644 instance/index.js

diff --git a/instance/index.html b/instance/index.html
index ef561a5..89eda1f 100644
--- a/instance/index.html
+++ b/instance/index.html
@@ -7,12 +7,20 @@
         <link rel="stylesheet" href="../style/bootstrap-4.5.2-dist/css/bootstrap.min.css">
         <script src="../style/jquery/jquery-3.5.1.js"></script>
         <script src="../style/bootstrap-4.5.2-dist/js/bootstrap.min.js"></script>
+        <script src="./index.js"></script>
     </head>
     <body>
-        <div class="container">
-            <h2 class="text-center">
-                LektorApp Admin Interface
-            </h2>
+        <div class="card">
+            <div class="card-header text-center">
+                <h2 class="text-center">
+                    LektorApp Admin Interface
+                </h2>
+            </div>
+            <div class="card-body text-center">
+                <button id="closeButton" type="button" class="btn btn-outline-primary">
+                    Quit LektorApp
+                </button>
+            </div>       
         </div>
     </body>
 </html>
diff --git a/instance/index.js b/instance/index.js
new file mode 100644
index 0000000..eb0e3e1
--- /dev/null
+++ b/instance/index.js
@@ -0,0 +1,9 @@
+const {ipcRenderer} = require('electron');
+
+
+window.onload = function(){
+    const closeApp = document.getElementById("closeButton");
+    closeApp.addEventListener('click', () => {
+        ipcRenderer.send('close-app')
+    });
+}
\ No newline at end of file
diff --git a/instance/main.js b/instance/main.js
index 31d455e..36f9258 100644
--- a/instance/main.js
+++ b/instance/main.js
@@ -1,6 +1,6 @@
 const electron = require('electron')
 const { app, BrowserWindow } = require('electron')
-
+const {ipcMain} = require('electron')
 
 
 /** Creates the main window and process for the admin interface
@@ -18,7 +18,7 @@ function createInstanceWindow () {
   })
 
   // and load the index.html of the app.
-  win.loadFile('instance/index.html')
+  win.loadFile('instance/index.html');
   
 }
 
@@ -43,6 +43,9 @@ function createExpressClient (){
 
 
 
+ipcMain.on('close-app', (evt, arg) => {
+  app.quit()
+})
 
 
 app.on('ready', () => {
-- 
GitLab