From 7bdce37fd3f18e2712e18c4e2c64cac69af0aca1 Mon Sep 17 00:00:00 2001
From: Jakob Stendahl <jakob.stendahl@outlook.com>
Date: Sun, 19 Sep 2021 19:43:11 +0200
Subject: :boom: Introduce new UI based on svelte, and rewrite a lot of the
 node app and the NeoRuntime

---
 src_frontend/Components/Settings/Version.svelte | 60 +++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 src_frontend/Components/Settings/Version.svelte

(limited to 'src_frontend/Components/Settings/Version.svelte')

diff --git a/src_frontend/Components/Settings/Version.svelte b/src_frontend/Components/Settings/Version.svelte
new file mode 100644
index 0000000..29d04ae
--- /dev/null
+++ b/src_frontend/Components/Settings/Version.svelte
@@ -0,0 +1,60 @@
+<script>
+    import { onMount } from 'svelte';
+    import FloatingButton from "../../ComponentLib/Button/FloatingButton.svelte";
+    import PrettyVar from "../../ComponentLib/PrettyVar.svelte";
+    import { authorizedSocket } from "../../stores/socketStore.js";
+
+    let version = "-";
+    let branch = "-";
+    let newVer = "-";
+    
+    authorizedSocket.on("version:branch", _branch => branch = _branch);
+    authorizedSocket.on("version:current_number", _version => version = _version);
+    authorizedSocket.on("version:newest_number", _version => newVer = _version);
+
+    let checkVersionPromise;
+    function checkForUpdate() {
+        checkVersionPromise = new Promise((resolve, reject) => {
+            authorizedSocket.emit("version:check_for_update", () => {
+                resolve();
+            });
+        });
+    }
+    
+    onMount(async() => {
+        authorizedSocket.emit("version:branch");
+        authorizedSocket.emit("version:current_number");
+        authorizedSocket.emit("version:newest_number");
+    });
+</script>
+
+<style>
+    h1, p { margin: 0; }
+    .label {
+        font-weight: 100;
+        font-style: italic;
+        color: var(--grey-600);
+    }
+    .button-row {
+        /* display: flex; */
+        margin-top: 20px;
+        width: 100%;
+        /* justify-content: center; */
+        /* align-items: center; */
+    }
+    .update-available {
+        color: var(--green-300);
+    }
+</style>
+
+<div>
+    <h1>Version</h1>
+    <p><span class="label">Current version</span> <PrettyVar varText={version}/></p>
+    <p><span class="label">Current branch</span> <PrettyVar bind:varText={branch}/></p>
+    {#if newVer != version}
+    <p><span class="update-available">Version <PrettyVar bind:varText={newVer} /> available.</span></p>
+    {/if}
+    <div class="button-row">
+        <FloatingButton on:click={checkForUpdate} bind:loadingPromise={checkVersionPromise} fullWidth=true>Check for updates</FloatingButton>
+    </div>
+</div>
\ No newline at end of file
-- 
cgit v1.2.3


From d962cdaa317b384b2e82d0f9dc5b9d15a5733869 Mon Sep 17 00:00:00 2001
From: Jakob Stendahl <jakobste@uio.no>
Date: Wed, 6 Oct 2021 17:24:43 +0200
Subject: :children_crossing: Add update button to ui

---
 src/SocketIO/index.js                           | 2 ++
 src_frontend/Components/Settings/Version.svelte | 6 ++++++
 2 files changed, 8 insertions(+)

(limited to 'src_frontend/Components/Settings/Version.svelte')

diff --git a/src/SocketIO/index.js b/src/SocketIO/index.js
index 2a625ed..1803845 100644
--- a/src/SocketIO/index.js
+++ b/src/SocketIO/index.js
@@ -194,6 +194,8 @@ function createAuthorizedNamespace(io) {
             fn({success: true});
         });
         socket.on("system:update_version", () => {
+            let p = exec('luxcena-neo-cli.sh update');
+            p.unref();
         });
 
         /* SSLCert */
diff --git a/src_frontend/Components/Settings/Version.svelte b/src_frontend/Components/Settings/Version.svelte
index 29d04ae..35c8f96 100644
--- a/src_frontend/Components/Settings/Version.svelte
+++ b/src_frontend/Components/Settings/Version.svelte
@@ -20,6 +20,11 @@
             });
         });
     }
+
+    let updateVersionPromise;
+    function doUpdate() {
+        authorizedSocket.emit("system:update_version");
+    }
     
     onMount(async() => {
         authorizedSocket.emit("version:branch");
@@ -53,6 +58,7 @@
     <p><span class="label">Current branch</span> <PrettyVar bind:varText={branch}/></p>
     {#if newVer != version}
     <p><span class="update-available">Version <PrettyVar bind:varText={newVer} /> available.</span></p>
+    <FloatingButton on:click={doUpdate} bind:loadingPromise={updateVersionPromise} fullWidth=true>Update luxcena-neo</FloatingButton>
     {/if}
     <div class="button-row">
         <FloatingButton on:click={checkForUpdate} bind:loadingPromise={checkVersionPromise} fullWidth=true>Check for updates</FloatingButton>
-- 
cgit v1.2.3

