2023-12-28 00:25:49 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<%- header %>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body id="app">
|
|
|
|
<Navbar></Navbar>
|
|
|
|
<div id="content" class="container">
|
|
|
|
<h1 class="my-4">Hello, Sunshine!</h1>
|
|
|
|
<p>Sunshine is a self-hosted game stream host for Moonlight.</p>
|
|
|
|
<div class="alert alert-danger" v-if="fancyLogs.find(x => x.level === 'Fatal')">
|
|
|
|
<div style="line-height: 32px;">
|
|
|
|
<i class="fas fa-circle-exclamation" style="font-size: 32px;margin-right: 0.25em;"></i>
|
2023-12-30 03:18:47 +00:00
|
|
|
<b>Attention!</b> Sunshine detected these errors during startup. We <b>STRONGLY RECOMMEND</b> fixing them
|
|
|
|
before streaming.<br>
|
2023-03-27 19:55:21 +00:00
|
|
|
</div>
|
2023-12-28 00:25:49 +00:00
|
|
|
<ul>
|
|
|
|
<li v-for="v in fancyLogs.filter(x => x.level === 'Fatal')">{{v.value}}</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2024-01-07 18:32:32 +00:00
|
|
|
<!-- Version -->
|
2023-12-28 00:25:49 +00:00
|
|
|
<div class="card p-2 my-4">
|
|
|
|
<div class="card-body" v-if="version">
|
|
|
|
<h2>Version {{version}}</h2>
|
2024-01-07 18:32:32 +00:00
|
|
|
<br>
|
2023-12-28 00:25:49 +00:00
|
|
|
<div v-if="loading">
|
|
|
|
Loading Latest Release...
|
2023-03-09 23:13:57 +00:00
|
|
|
</div>
|
2023-12-28 00:25:49 +00:00
|
|
|
<div class="alert alert-success" v-if="buildVersionIsDirty">
|
|
|
|
Thank you for helping to make Sunshine a better software! 🌇
|
|
|
|
</div>
|
|
|
|
<div v-else-if="!nightlyBuildAvailable && !stableBuildAvailable && !buildVersionIsDirty">
|
|
|
|
<div class="alert alert-success">
|
|
|
|
You're running the latest version of Sunshine
|
2023-03-09 23:13:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-12-28 00:25:49 +00:00
|
|
|
<div v-if="nightlyBuildAvailable">
|
|
|
|
<div class="alert alert-warning">
|
|
|
|
<div class="d-flex justify-content-between">
|
|
|
|
<div class="my-2">A new <b>Nightly</b> Version is Available!</div>
|
|
|
|
<a class="btn btn-success m-1" href="https://github.com/LizardByte/Sunshine/releases/nightly-dev"
|
|
|
|
target="_blank">Download</a>
|
|
|
|
</div>
|
|
|
|
<pre><b>{{nightlyData.head_sha}}</b></pre>
|
|
|
|
<pre>{{nightlyData.display_title}}</pre>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="stableBuildAvailable">
|
|
|
|
<div class="alert alert-warning">
|
|
|
|
<div class="d-flex justify-content-between">
|
|
|
|
<div class="my-2">A new <b>Stable</b> Version is Available!</div>
|
|
|
|
<a class="btn btn-success m-1" :href="githubVersion.html_url" target="_blank">Download</a>
|
|
|
|
</div>
|
|
|
|
<h3>{{githubVersion.name}}</h3>
|
|
|
|
<pre>{{githubVersion.body}}</pre>
|
2023-03-09 23:13:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-07 18:32:32 +00:00
|
|
|
<!-- Resources -->
|
2023-12-28 00:25:49 +00:00
|
|
|
<div class="my-4">
|
|
|
|
<Resource-Card></Resource-Card>
|
2021-05-30 13:56:13 +00:00
|
|
|
</div>
|
2021-08-17 17:12:15 +00:00
|
|
|
</div>
|
2023-12-28 00:25:49 +00:00
|
|
|
</body>
|
2023-03-09 23:13:57 +00:00
|
|
|
|
2023-12-28 00:25:49 +00:00
|
|
|
<script type="module">
|
|
|
|
import { createApp } from 'vue'
|
|
|
|
import Navbar from './Navbar.vue'
|
|
|
|
import ResourceCard from './ResourceCard.vue'
|
|
|
|
console.log("Hello, Sunshine!")
|
|
|
|
let app = createApp({
|
|
|
|
components: {
|
|
|
|
Navbar,
|
|
|
|
ResourceCard
|
|
|
|
},
|
2023-03-09 23:13:57 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
version: null,
|
|
|
|
githubVersion: null,
|
|
|
|
nightlyData: null,
|
|
|
|
loading: true,
|
2023-09-16 18:53:38 +00:00
|
|
|
logs: null,
|
2023-03-09 23:13:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async created() {
|
|
|
|
try {
|
|
|
|
this.version = (await fetch("/api/config").then((r) => r.json())).version;
|
|
|
|
this.githubVersion = (await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then((r) => r.json()));
|
2023-06-06 22:31:15 +00:00
|
|
|
if (this.buildVersionIsNightly) {
|
2023-06-25 21:10:35 +00:00
|
|
|
this.nightlyData = (await fetch("https://api.github.com/repos/LizardByte/Sunshine/actions/workflows/CI.yml/runs?branch=nightly&event=push&exclude_pull_requests=true&per_page=1").then((r) => r.json())).workflow_runs[0];
|
2023-03-09 23:13:57 +00:00
|
|
|
}
|
2023-09-16 18:53:38 +00:00
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
this.logs = (await fetch("/api/logs").then(r => r.text()))
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
2023-03-09 23:13:57 +00:00
|
|
|
}
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
computed: {
|
2023-03-26 23:28:57 +00:00
|
|
|
stableBuildAvailable() {
|
2023-03-09 23:13:57 +00:00
|
|
|
// If we can't get versions, return false
|
|
|
|
if (!this.githubVersion || !this.version) return false;
|
|
|
|
// Get the GitHub version tag
|
|
|
|
let v = this.githubVersion.name;
|
|
|
|
// If the version starts with a v, remove it
|
|
|
|
if (v.indexOf("v") === 0) v = v.substring(1);
|
2023-03-26 23:28:57 +00:00
|
|
|
|
2023-03-27 19:55:21 +00:00
|
|
|
// if nightly or dirty, we do an additional check to make sure it's an actual upgrade.
|
2023-06-06 22:31:15 +00:00
|
|
|
if (this.buildVersionIsNightly || this.buildVersionIsDirty) {
|
2023-03-26 23:28:57 +00:00
|
|
|
const stableVersion = this.version.split('.').slice(0, 3).join('.');
|
|
|
|
return this.githubVersion.tag_name.substring(1) > stableVersion;
|
|
|
|
}
|
|
|
|
|
2023-03-09 23:13:57 +00:00
|
|
|
// return true if the version is different, otherwise false
|
2023-06-06 22:31:15 +00:00
|
|
|
return v !== this.version;
|
2023-03-09 23:13:57 +00:00
|
|
|
},
|
2023-03-26 23:28:57 +00:00
|
|
|
nightlyBuildAvailable() {
|
|
|
|
// Verify nightly data is available and the build version is not stable
|
|
|
|
// This is important to ensure the UI does not try to load undefined values.
|
2023-06-06 22:31:15 +00:00
|
|
|
if (!this.nightlyData || this.buildVersionIsStable) return false;
|
2023-03-09 23:13:57 +00:00
|
|
|
// If built with dirty git tree, return false
|
2023-06-06 22:31:15 +00:00
|
|
|
if (this.buildVersionIsDirty) return false;
|
2023-03-09 23:13:57 +00:00
|
|
|
// Get the commit hash
|
2023-03-26 23:28:57 +00:00
|
|
|
let commit = this.version?.split(".").pop();
|
2023-03-09 23:13:57 +00:00
|
|
|
// return true if the commit hash is different, otherwise false
|
|
|
|
return this.nightlyData.head_sha.indexOf(commit) !== 0;
|
2023-06-06 22:31:15 +00:00
|
|
|
},
|
2023-09-16 18:53:38 +00:00
|
|
|
buildVersionIsDirty() {
|
2023-03-27 19:55:21 +00:00
|
|
|
return this.version?.split(".").length === 5 &&
|
|
|
|
this.version.indexOf("dirty") !== -1
|
2023-03-26 23:28:57 +00:00
|
|
|
},
|
2023-09-16 18:53:38 +00:00
|
|
|
buildVersionIsNightly() {
|
2023-03-26 23:28:57 +00:00
|
|
|
return this.version?.split(".").length === 4
|
2023-03-27 19:55:21 +00:00
|
|
|
},
|
|
|
|
buildVersionIsStable() {
|
|
|
|
return this.version?.split(".").length === 3
|
2023-09-16 18:53:38 +00:00
|
|
|
},
|
|
|
|
/** Parse the text errors, calculating the text, the timestamp and the level */
|
|
|
|
fancyLogs() {
|
|
|
|
if (!this.logs) return [];
|
|
|
|
let regex = /(\[\d{4}:\d{2}:\d{2}:\d{2}:\d{2}:\d{2}\]):\s/g;
|
|
|
|
let rawLogLines = (this.logs.split(regex)).splice(1);
|
|
|
|
let logLines = []
|
|
|
|
for (let i = 0; i < rawLogLines.length; i += 2) {
|
|
|
|
logLines.push({ timestamp: rawLogLines[i], level: rawLogLines[i + 1].split(":")[0], value: rawLogLines[i + 1] });
|
|
|
|
}
|
|
|
|
return logLines;
|
2023-03-26 23:28:57 +00:00
|
|
|
}
|
2023-03-09 23:13:57 +00:00
|
|
|
}
|
|
|
|
});
|
2023-12-28 00:25:49 +00:00
|
|
|
app.mount('#app');
|
2023-03-09 23:13:57 +00:00
|
|
|
</script>
|