Implement restart support for all platforms

This commit is contained in:
Cameron Gutman
2023-04-23 18:09:13 -05:00
parent 4668ff59e5
commit 50f689ff80
10 changed files with 128 additions and 82 deletions

View File

@@ -965,18 +965,15 @@
</div>
</div>
</div>
<div class="alert alert-success my-4" v-if="saved && restart_supported">
<div class="alert alert-success my-4" v-if="saved && !restarted">
<b>Success!</b> Click 'Apply' to restart Sunshine and apply changes. This will terminate any running sessions.
</div>
<div class="alert alert-success my-4" v-if="saved && !restart_supported">
<b>Success!</b> Restart Sunshine to apply changes.
</div>
<div class="alert alert-success my-4" v-if="restarted">
<b>Success!</b> Sunshine is restarting to apply changes.
</div>
<div class="mb-3 buttons">
<button class="btn btn-primary" @click="save">Save</button>
<button class="btn btn-success" @click="apply" v-if="saved && restart_supported && !restarted">Apply</button>
<button class="btn btn-success" @click="apply" v-if="saved && !restarted">Apply</button>
</div>
</div>
@@ -1023,7 +1020,6 @@
data() {
return {
platform: "",
restart_supported: false,
saved: false,
restarted: false,
config: null,
@@ -1087,7 +1083,6 @@
.then((r) => {
this.config = r;
this.platform = this.config.platform;
this.restart_supported = (this.config.restart_supported === "true");
var app = document.getElementById("app");
if (this.platform === "windows") {
@@ -1108,7 +1103,6 @@
// remove values we don't want in the config file
delete this.config.platform;
delete this.config.restart_supported;
delete this.config.status;
delete this.config.version;
//Populate default values if not present in config
@@ -1197,10 +1191,12 @@
saved.then((result) => {
if (result === true) {
this.restarted = true;
setTimeout(() => {
this.saved = this.restarted = false;
}, 5000);
fetch("/api/restart", {
method: "POST"
}).then((r) => {
if (r.status === 200) this.restarted = true;
});
}
});