Skip to content

Commit

Permalink
Refresh interval doesn't require restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Oct 1, 2023
1 parent b6cc680 commit 0856299
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
4 changes: 4 additions & 0 deletions core/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public MainWindow() {
APIRefresher.Start();
}

// Refresh API
public void RefreshAPI(object sender, object e) {
System.Threading.Tasks.Task.Run(() => {
App.GlobalHardwareInfo.Refresh();
Expand All @@ -57,6 +58,7 @@ public void RefreshAPI(object sender, object e) {
SendAPI();
}

// Start webview
private async void Init() {
await webView.EnsureCoreWebView2Async();
webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
Expand Down Expand Up @@ -125,6 +127,8 @@ public async void WebView_WebMessageReceived(object sender, CoreWebView2WebMessa
case "newSettings":
App.GlobalSettings = JsonSerializer.Deserialize<Settings>(content.Content, App.SerializerOptions);

APIRefresher.Interval = new TimeSpan(0, 0, App.GlobalSettings.interval);

setSettings(App.GlobalSettings);
break;

Expand Down
55 changes: 50 additions & 5 deletions interface/pages/settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="transparent-800 flex w-full flex-row items-center justify-between rounded-xl p-10 text-left">
<div>
<h2>Refresh interval</h2>
<h3>How often does Cores refreshes the sensors and displays the data. Restart required.</h3>
<h3>How often does Cores refreshes the sensors and displays the data.</h3>
</div>
<div class="ml-20 flex gap-3">
<Select options={["1s", "2s", "3s", "5s", "15s"]} setting={"interval"} values={[1, 2, 3, 5, 15]} />
Expand All @@ -45,7 +45,24 @@
</div>
<div class="ml-20 flex gap-3">
<button class="button" on:click={debug}>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6V4a2 2 0 0 1 2-2h8.5L20 7.5V20a2 2 0 0 1-2 2H4" /><polyline points="14 2 14 8 20 8" /><circle cx="6" cy="14" r="3" /><path d="M6 10v1" /><path d="M6 17v1" /><path d="M10 14H9" /><path d="M3 14H2" /><path d="m9 11-.88.88" /><path d="M3.88 16.12 3 17" /><path d="m9 17-.88-.88" /><path d="M3.88 11.88 3 11" /></svg>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
><path d="M4 6V4a2 2 0 0 1 2-2h8.5L20 7.5V20a2 2 0 0 1-2 2H4" /><polyline points="14 2 14 8 20 8" /><circle
cx="6"
cy="14"
r="3"
/><path d="M6 10v1" /><path d="M6 17v1" /><path d="M10 14H9" /><path d="M3 14H2" /><path d="m9 11-.88.88" /><path
d="M3.88 16.12 3 17"
/><path d="m9 17-.88-.88" /><path d="M3.88 11.88 3 11" /></svg
>
Save
</button>
</div>
Expand All @@ -63,7 +80,20 @@
open("https://github.com/levminer/cores/issues")
}}
>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4" /><path d="M9 18c-4.51 2-5-2-7-2" /></svg>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
><path
d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"
/><path d="M9 18c-4.51 2-5-2-7-2" /></svg
>
GitHub
</button>
</div>
Expand All @@ -76,7 +106,18 @@
</div>
<div class="ml-20 flex gap-3">
<button on:click={about} class="button">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" /></svg>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
><circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" /></svg
>
About Cores
</button>
</div>
Expand All @@ -91,7 +132,11 @@
import Select from "../components/select.svelte"
import Toggle from "../components/toggle.svelte"
let message = `Cores: ${$hardwareInfo.system.os.app} \n\nRuntime: ${$hardwareInfo.system.os.runtime} \nChromium: ${$hardwareInfo.system.os.webView}\n\nOS version: ${$hardwareInfo.system.os.name} \nHardware info: ${$hardwareInfo.cpu.name} ${Math.round($hardwareInfo.ram.load[0].value + $hardwareInfo.ram.load[1].value)} GB RAM\n\nRelease date: ${build.date} \nBuild number: ${build.number} \n\nCreated by: Lőrik Levente`
let message = `Cores: ${$hardwareInfo.system.os.app} \n\nRuntime: ${$hardwareInfo.system.os.runtime} \nChromium: ${
$hardwareInfo.system.os.webView
}\n\nOS version: ${$hardwareInfo.system.os.name} \nHardware info: ${$hardwareInfo.cpu.name} ${Math.round(
$hardwareInfo.ram.load[0].value + $hardwareInfo.ram.load[1].value,
)} GB RAM\n\nRelease date: ${build.date} \nBuild number: ${build.number} \n\nCreated by: Lőrik Levente`
const launchOnStartup = () => {
// @ts-ignore
Expand Down

0 comments on commit 0856299

Please sign in to comment.