Sunshine/src_assets/common/assets/web/index.html

158 lines
5.6 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
2024-05-25 01:28:39 +00:00
<html lang="en" data-bs-theme="auto">
<head>
<%- header %>
</head>
<body id="app" v-cloak>
<Navbar></Navbar>
<div id="content" class="container">
<h1 class="my-4">{{ $t('index.welcome') }}</h1>
<p>{{ $t('index.description') }}</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>
<p v-html="$t('index.startup_errors')"></p>
<br>
</div>
<ul>
<li v-for="v in fancyLogs.filter(x => x.level === 'Fatal')">{{v.value}}</li>
</ul>
<a class="btn btn-danger" href="/troubleshooting/#logs">View Logs</a>
</div>
<!-- Version -->
<div class="card p-2 my-4">
<div class="card-body" v-if="version">
<h2>Version {{version.version}}</h2>
<br>
<div v-if="loading">
{{ $t('index.loading_latest') }}
</div>
<div class="alert alert-success" v-if="buildVersionIsDirty">
{{ $t('index.version_dirty') }} 🌇
</div>
<div class="alert alert-info" v-if="installedVersionNotStable">
{{ $t('index.installed_version_not_stable') }}
</div>
<div v-else-if="(!preReleaseBuildAvailable || !notifyPreReleases) && !stableBuildAvailable && !buildVersionIsDirty">
<div class="alert alert-success">
{{ $t('index.version_latest') }}
</div>
</div>
2024-05-24 01:42:06 +00:00
<div v-if="notifyPreReleases && preReleaseBuildAvailable">
<div class="alert alert-warning">
<div class="d-flex justify-content-between">
<div class="my-2">
2024-05-24 01:42:06 +00:00
<p>{{ $t('index.new_pre_release') }}</p>
</div>
<a class="btn btn-success m-1" :href="preReleaseVersion.release.html_url" target="_blank">{{ $t('index.download') }}</a>
</div>
<pre><b>{{preReleaseVersion.release.name}}</b></pre>
<pre>{{preReleaseVersion.release.body}}</pre>
</div>
</div>
<div v-if="stableBuildAvailable">
<div class="alert alert-warning">
<div class="d-flex justify-content-between">
<div class="my-2">
2024-05-24 01:42:06 +00:00
<p>{{ $t('index.new_stable') }}</p>
</div>
<a class="btn btn-success m-1" :href="githubVersion.release.html_url" target="_blank">{{ $t('index.download') }}</a>
</div>
<h3>{{githubVersion.release.name}}</h3>
<pre>{{githubVersion.release.body}}</pre>
</div>
</div>
</div>
</div>
<!-- Resources -->
<div class="my-4">
<Resource-Card></Resource-Card>
2021-05-30 13:56:13 +00:00
</div>
</div>
</body>
<script type="module">
import { createApp } from 'vue'
import { initApp } from './init'
import Navbar from './Navbar.vue'
import ResourceCard from './ResourceCard.vue'
import SunshineVersion from './sunshine_version'
console.log("Hello, Sunshine!")
let app = createApp({
components: {
Navbar,
ResourceCard
},
data() {
return {
version: null,
githubVersion: null,
2024-05-24 01:42:06 +00:00
notifyPreReleases: false,
preReleaseVersion: null,
loading: true,
2023-09-16 18:53:38 +00:00
logs: null,
}
},
async created() {
try {
2024-05-24 01:42:06 +00:00
let config = await fetch("/api/config").then((r) => r.json());
this.notifyPreReleases = config.notify_pre_releases;
this.version = new SunshineVersion(null, config.version);
console.log("Version: ", this.version.version)
this.githubVersion = new SunshineVersion(await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then((r) => r.json()), null);
console.log("GitHub Version: ", this.githubVersion.version)
this.preReleaseVersion = new SunshineVersion((await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases").then((r) => r.json())).find(release => release.prerelease), null);
console.log("Pre-Release Version: ", this.preReleaseVersion.version)
2023-09-16 18:53:38 +00:00
} catch (e) {
console.error(e);
2023-09-16 18:53:38 +00:00
}
try {
this.logs = (await fetch("/api/logs").then(r => r.text()))
} catch (e) {
console.error(e);
}
this.loading = false;
},
computed: {
installedVersionNotStable() {
2024-05-24 01:42:06 +00:00
if (!this.githubVersion || !this.version) {
return false;
}
return this.version.isGreater(this.githubVersion);
},
stableBuildAvailable() {
if (!this.githubVersion || !this.version) {
return false;
2023-03-26 23:28:57 +00:00
}
return this.githubVersion.isGreater(this.version);
},
2024-05-24 01:42:06 +00:00
preReleaseBuildAvailable() {
if (!this.preReleaseVersion || !this.githubVersion || !this.version) {
2024-05-24 01:42:06 +00:00
return false;
}
return this.preReleaseVersion.isGreater(this.version) && this.preReleaseVersion.isGreater(this.githubVersion);
},
2023-09-16 18:53:38 +00:00
buildVersionIsDirty() {
return this.version.version?.split(".").length === 5 &&
this.version.version.indexOf("dirty") !== -1
2023-03-26 23:28:57 +00:00
},
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
}
}
});
initApp(app);
</script>