Skip to content

Commit 6ae5ab1

Browse files
authored
Merge branch 'LizardByte:master' into master
2 parents 23fd2a5 + 0523ceb commit 6ae5ab1

6 files changed

Lines changed: 111 additions & 10 deletions

File tree

src/confighttp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,7 @@ namespace confighttp {
19731973
server.resource["^/clients/?$"]["GET"] = page_handler("clients.html");
19741974
server.resource["^/config/?$"]["GET"] = page_handler("config.html");
19751975
server.resource["^/featured/?$"]["GET"] = page_handler("featured.html");
1976+
server.resource["^/logout/?$"]["GET"] = page_handler("logout.html", false);
19761977
server.resource["^/password/?$"]["GET"] = page_handler("password.html");
19771978
server.resource["^/pin/?$"]["GET"] = page_handler("pin.html");
19781979
server.resource["^/troubleshooting/?$"]["GET"] = page_handler("troubleshooting.html");

src_assets/common/assets/web/Navbar.vue

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,38 @@
4141
{{ $t('navbar.configuration') }}
4242
</a>
4343
</li>
44-
<li class="nav-item">
45-
<a class="nav-link" href="./password">
46-
<Shield :size="18" class="icon"></Shield>
47-
{{ $t('navbar.password') }}
48-
</a>
49-
</li>
5044
<li class="nav-item">
5145
<a class="nav-link" href="./troubleshooting">
5246
<Info :size="18" class="icon"></Info>
5347
{{ $t('navbar.troubleshoot') }}
5448
</a>
5549
</li>
50+
</ul>
51+
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
5652
<li class="nav-item">
5753
<ThemeToggle/>
5854
</li>
55+
<li class="nav-item dropdown">
56+
<button class="nav-link dropdown-toggle" type="button" id="navbarUserMenu"
57+
data-bs-toggle="dropdown" aria-expanded="false" aria-label="User menu" title="User menu">
58+
<CircleUserRound :size="18" class="icon"></CircleUserRound>
59+
</button>
60+
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarUserMenu">
61+
<li>
62+
<a class="dropdown-item d-flex align-items-center" href="./password">
63+
<Shield :size="18" class="icon"></Shield>
64+
{{ $t('navbar.password') }}
65+
</a>
66+
</li>
67+
<li><hr class="dropdown-divider"></li>
68+
<li>
69+
<button type="button" class="dropdown-item d-flex align-items-center" @click="logout">
70+
<LogOut :size="18" class="icon"></LogOut>
71+
{{ $t('navbar.logout') }}
72+
</button>
73+
</li>
74+
</ul>
75+
</li>
5976
</ul>
6077
</div>
6178
</div>
@@ -65,7 +82,7 @@
6582
</template>
6683

6784
<script>
68-
import { Home, Lock, Layers, Star, Settings, Shield, Info } from 'lucide-vue-next'
85+
import { CircleUserRound, Home, Info, Layers, Lock, LogOut, Settings, Shield, Star } from 'lucide-vue-next'
6986
import ThemeToggle from './ThemeToggle.vue'
7087
import Notification from './Notification.vue'
7188
@@ -79,14 +96,48 @@ export default {
7996
Star,
8097
Settings,
8198
Shield,
82-
Info
99+
Info,
100+
CircleUserRound,
101+
LogOut
83102
},
84103
created() {
85104
console.log("Header mounted!")
86105
},
87106
mounted() {
88-
let el = document.querySelector("a[href='" + document.location.pathname + "']");
89-
if (el) el.classList.add("active")
107+
const currentPath = globalThis.location.pathname.replace(/\/$/, '') || '/'
108+
const links = document.querySelectorAll('.navbar-sunshine a[href]')
109+
110+
for (const link of links) {
111+
const href = link.getAttribute('href')
112+
if (!href || href === '#') {
113+
continue
114+
}
115+
116+
const linkPath = new URL(href, globalThis.location.href).pathname.replace(/\/$/, '') || '/'
117+
if (linkPath !== currentPath) {
118+
continue
119+
}
120+
121+
link.classList.add('active')
122+
}
123+
},
124+
methods: {
125+
logout() {
126+
const cacheBuster = Date.now().toString()
127+
const logoutPageUrl = new URL('/logout', globalThis.location.href)
128+
const request = new XMLHttpRequest()
129+
const finish = () => {
130+
globalThis.location.replace(logoutPageUrl.toString())
131+
}
132+
133+
request.open('GET', '/', true, 'sunshine-logout', cacheBuster)
134+
request.setRequestHeader('Cache-Control', 'no-store')
135+
request.onload = finish
136+
request.onerror = finish
137+
request.ontimeout = finish
138+
request.timeout = 5000
139+
request.send()
140+
}
90141
}
91142
}
92143
</script>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en" data-bs-theme="auto">
3+
4+
<head>
5+
<%- header %>
6+
</head>
7+
8+
<body id="app" v-cloak>
9+
<div class="container py-5">
10+
<div class="row justify-content-center">
11+
<div class="col-md-8 col-lg-6">
12+
<div class="card">
13+
<div class="card-body text-center">
14+
<img src="/images/logo-sunshine-45.png" height="45" alt="Sunshine" class="mb-3">
15+
<h1 class="h3 mb-3">{{ $t('logout.logged_out') }}</h1>
16+
<p class="text-muted mb-4">{{ $t('logout.logged_out_desc') }}</p>
17+
<a class="btn btn-primary" href="./">
18+
<log-in :size="18" class="icon"></log-in>
19+
{{ $t('logout.login') }}
20+
</a>
21+
</div>
22+
</div>
23+
</div>
24+
</div>
25+
</div>
26+
</body>
27+
<script type="module">
28+
import { createApp } from 'vue'
29+
import { initApp } from './init'
30+
import { LogIn } from 'lucide-vue-next'
31+
32+
const app = createApp({
33+
components: {
34+
LogIn,
35+
},
36+
});
37+
38+
initApp(app);
39+
</script>
40+
41+
</html>

src_assets/common/assets/web/public/assets/css/sunshine.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ body {
802802
color: var(--navbar-text-muted) !important;
803803
font-weight: 500;
804804
padding: 0.5rem 1rem !important;
805+
min-height: calc(1.5em + 1rem);
805806
border-radius: var(--radius-md);
806807
transition: all var(--transition-fast);
807808
display: flex;

src_assets/common/assets/web/public/assets/locale/en.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@
465465
"configuration": "Configuration",
466466
"featured": "Featured Apps",
467467
"home": "Home",
468+
"logout": "Log Out",
468469
"password": "Change Password",
469470
"pin": "PIN",
470471
"theme_auto": "Auto",
@@ -485,6 +486,11 @@
485486
"toggle_theme": "Theme",
486487
"troubleshoot": "Troubleshooting"
487488
},
489+
"logout": {
490+
"logged_out": "Logged Out",
491+
"logged_out_desc": "You have successfully logged out.",
492+
"login": "Log In"
493+
},
488494
"password": {
489495
"confirm_password": "Confirm Password",
490496
"current_creds": "Current Credentials",

vite.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default defineConfig({
7070
config: resolve(assetsSrcPath, 'config.html'),
7171
featured: resolve(assetsSrcPath, 'featured.html'),
7272
index: resolve(assetsSrcPath, 'index.html'),
73+
logout: resolve(assetsSrcPath, 'logout.html'),
7374
password: resolve(assetsSrcPath, 'password.html'),
7475
pin: resolve(assetsSrcPath, 'pin.html'),
7576
troubleshooting: resolve(assetsSrcPath, 'troubleshooting.html'),

0 commit comments

Comments
 (0)