Implement restart support for all platforms
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<!--Restart Sunshine-->
|
||||
<div class="card p-2 my-4" v-if="restartSupported">
|
||||
<div class="card p-2 my-4">
|
||||
<div class="card-body">
|
||||
<h2>Restart Sunshine</h2>
|
||||
<br />
|
||||
@@ -31,12 +31,9 @@
|
||||
If Sunshine isn't working properly, you can try restarting it.
|
||||
This will terminate any running sessions.
|
||||
</p>
|
||||
<div class="alert alert-success" v-if="restartStatus === true">
|
||||
<div class="alert alert-success" v-if="restartPressed === true">
|
||||
Sunshine is restarting
|
||||
</div>
|
||||
<div class="alert alert-danger" v-if="restartStatus === false">
|
||||
Error restarting Sunshine
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-warning" :disabled="restartPressed" @click="restart">
|
||||
Restart Sunshine
|
||||
@@ -90,9 +87,7 @@
|
||||
closeAppStatus: null,
|
||||
unpairAllPressed: false,
|
||||
unpairAllStatus: null,
|
||||
restartSupported: false,
|
||||
restartPressed: false,
|
||||
restartStatus: null,
|
||||
logs: 'Loading...',
|
||||
logFilter: null,
|
||||
logInterval: null,
|
||||
@@ -111,11 +106,6 @@
|
||||
this.refreshLogs();
|
||||
}, 5000);
|
||||
this.refreshLogs();
|
||||
fetch("/api/config")
|
||||
.then((r) => r.json())
|
||||
.then((r) => {
|
||||
this.restartSupported = (r.restart_supported === "true");
|
||||
});
|
||||
},
|
||||
beforeDestroy(){
|
||||
clearInterval(this.logInterval);
|
||||
@@ -157,17 +147,11 @@
|
||||
},
|
||||
restart() {
|
||||
this.restartPressed = true;
|
||||
setTimeout(() => {
|
||||
this.restartPressed = false;
|
||||
}, 5000);
|
||||
fetch("/api/restart", {
|
||||
method: "POST",
|
||||
}).then((r) => {
|
||||
this.restartPressed = false;
|
||||
|
||||
// We won't get a response in the success case
|
||||
this.restartStatus = r.status.toString() !== "false";
|
||||
|
||||
setTimeout(() => {
|
||||
this.restartStatus = null;
|
||||
}, 5000);
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user