Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(frontend): add logout actions to sidebar and user account

johaven68c2d2ed30c1
diff --git a/frontend/src/app/applications/users/components/sidebar/user-profile.component.html b/frontend/src/app/applications/users/components/sidebar/user-profile.component.html
index 582f0180..d9aec237 100755
--- a/frontend/src/app/applications/users/components/sidebar/user-profile.component.html
+++ b/frontend/src/app/applications/users/components/sidebar/user-profile.component.html
@@ -26,8 +26,8 @@
@if (!store.isElectronApp() || store.isElectronApp() && store.userImpersonate()) {
<button (click)="logOut()"
class="btn btn-default"
- [attr.aria-label]="'logout' | translate:locale.language"
- [title]="'logout' | translate:locale.language"
+ [attr.aria-label]="'Logout' | translate:locale.language"
+ [title]="'Logout' | translate:locale.language"
type="button">
<svg [lucideIcon]="store.userImpersonate() ? icons.LucideVenetianMask : icons.LucideLogOut"></svg>
</button>
diff --git a/frontend/src/app/applications/users/components/user-account.component.html b/frontend/src/app/applications/users/components/user-account.component.html
index 60e1bac0..f10ed352 100755
--- a/frontend/src/app/applications/users/components/user-account.component.html
+++ b/frontend/src/app/applications/users/components/user-account.component.html
@@ -339,6 +339,19 @@
</button>
</div>
</div>
+
+ @if (!store.isElectronApp() || store.userImpersonate()) {
+ <div class="row g-2 align-items-center">
+ <div class="form-label col-12 col-md-6 mb-0" l10nTranslate>Session</div>
+ <div class="col-12 col-md-6 d-flex align-items-center">
+ <button (click)="logOut()"
+ class="btn btn-danger"
+ type="button">
+ <span l10nTranslate>Logout</span>
+ </button>
+ </div>
+ </div>
+ }
</div>
</div>
</div>
diff --git a/frontend/src/app/applications/users/components/user-account.component.ts b/frontend/src/app/applications/users/components/user-account.component.ts
index 179996a4..e3601eff 100644
--- a/frontend/src/app/applications/users/components/user-account.component.ts
+++ b/frontend/src/app/applications/users/components/user-account.component.ts
@@ -27,6 +27,7 @@ import { ClipboardService } from 'ngx-clipboard'
import { Subscription } from 'rxjs'
import { filter, take } from 'rxjs/operators'
import { i18nLanguageText } from '../../../../i18n/l10n'
+import { AuthService } from '../../../auth/auth.service'
import { InputPasswordComponent } from '../../../common/components/input-password.component'
import { PasswordStrengthBarComponent } from '../../../common/components/password-strength-bar.component'
import { StorageUsageComponent } from '../../../common/components/storage-usage.component'
@@ -88,6 +89,7 @@ export class UserAccountComponent implements OnInit, OnDestroy {
protected readonly originalOrderKeyValue = originalOrderKeyValue
private readonly layout = inject(LayoutService)
protected languages = this.layout.getLanguages(true)
+ private readonly authService = inject(AuthService)
private readonly userService = inject(UserService)
private readonly clipBoardService = inject(ClipboardService)
private subscriptions: Subscription[] = []
@@ -136,6 +138,10 @@ export class UserAccountComponent implements OnInit, OnDestroy {
this.subscriptions.forEach((s) => s.unsubscribe())
}
+ logOut() {
+ this.authService.logout()
+ }
+
setOnlineStatus(status: number) {
this.userService.changeOnlineStatus(status)
}
diff --git a/frontend/src/app/layout/sidebar/sidebar.left.component.html b/frontend/src/app/layout/sidebar/sidebar.left.component.html
index ba153bb5..3214da3b 100644
--- a/frontend/src/app/layout/sidebar/sidebar.left.component.html
+++ b/frontend/src/app/layout/sidebar/sidebar.left.component.html
@@ -43,9 +43,19 @@
</button>
}
}
- @if (store.userImpersonate()) {
+ @if (showLogoutShortcut) {
<button (click)="logOut()"
- (mouseenter)="previewMenuTitle('logout')"
+ (mouseenter)="previewMenuTitle('Logout')"
+ (mouseleave)="restoreMenuTitle()"
+ aria-label="Logout"
+ class="app-shortcut"
+ type="button">
+ <svg [lucideIcon]="icons.LucideLogOut"></svg>
+ </button>
+ }
+ @if (store.userImpersonate()) {
+ <button (click)="logOutImpersonate()"
+ (mouseenter)="previewMenuTitle('Logout')"
(mouseleave)="restoreMenuTitle()"
class="app-shortcut"
type="button">
diff --git a/frontend/src/app/layout/sidebar/sidebar.left.component.ts b/frontend/src/app/layout/sidebar/sidebar.left.component.ts
index fd5ba85d..7b3aa451 100644
--- a/frontend/src/app/layout/sidebar/sidebar.left.component.ts
+++ b/frontend/src/app/layout/sidebar/sidebar.left.component.ts
@@ -1,7 +1,7 @@
import { AsyncPipe, Location, NgTemplateOutlet } from '@angular/common'
import { Component, inject, OnDestroy } from '@angular/core'
import { ResolveEnd, Router, RouterLink } from '@angular/router'
-import { LucideChevronLeft, LucideChevronRight, LucideDynamicIcon, LucideVenetianMask } from '@lucide/angular'
+import { LucideChevronLeft, LucideChevronRight, LucideDynamicIcon, LucideLogOut, LucideVenetianMask } from '@lucide/angular'
import { L10nTranslateDirective } from 'angular-l10n'
import { Subscription } from 'rxjs'
import { filter } from 'rxjs/operators'
@@ -25,12 +25,15 @@ import { NavbarSearchService } from '../navbar/services/navbar-search.service'
})
export class SideBarLeftComponent implements OnDestroy {
protected readonly store = inject(StoreService)
- protected readonly icons = { LucideChevronLeft, LucideChevronRight, LucideVenetianMask }
+ protected readonly icons = { LucideChevronLeft, LucideChevronRight, LucideLogOut, LucideVenetianMask }
protected readonly appName = APP_NAME
protected readonly appMenus = [SPACES_MENU, SEARCH_MENU, SYNC_MENU, USER_MENU, ADMIN_MENU]
protected dynamicTitle: string
+ protected navigationSubmenus: AppMenuEntry[] = (this.appMenus[0].navigationMenu ?? this.appMenus[0]).submenus ?? []
+ protected showLogoutShortcut = false
protected readonly isMenu = isAppMenu
private currentMenu: AppMenu = this.appMenus[0]
+ private visibleShortcutCount = 0
private readonly location = inject(Location)
private readonly router = inject(Router)
private readonly authService = inject(AuthService)
@@ -53,10 +56,15 @@ export class SideBarLeftComponent implements OnDestroy {
loadMenus() {
this.userService.setMenusVisibility(this.appMenus)
+ this.updateAppShortcutsVisibility()
this.updateUrl(this.router.url)
}
logOut() {
+ this.authService.logout()
+ }
+
+ logOutImpersonate() {
this.authService.logout(true)
}
@@ -106,12 +114,7 @@ export class SideBarLeftComponent implements OnDestroy {
protected showAppShortcut(menu: AppMenu): boolean {
if (menu.hide) return false
- const visibleButtons = this.appMenus.filter((appMenu) => !appMenu.hide).length + (this.store.userImpersonate() ? 1 : 0)
- return menu !== SEARCH_MENU || visibleButtons <= 4
- }
-
- protected get navigationSubmenus(): AppMenuEntry[] {
- return (this.currentMenu?.navigationMenu ?? this.currentMenu)?.submenus ?? []
+ return menu !== SEARCH_MENU || this.visibleShortcutCount <= 4
}
protected showMenuSeparator(menus: AppMenuEntry[] | undefined, separatorIndex: number, separator: AppMenuEntry): boolean {
@@ -177,9 +180,16 @@ export class SideBarLeftComponent implements OnDestroy {
}
}
}
+ this.navigationSubmenus = (this.currentMenu.navigationMenu ?? this.currentMenu).submenus ?? []
this.updateDynamicTitle()
}
+ private updateAppShortcutsVisibility() {
+ const isImpersonated = this.store.userImpersonate()
+ this.visibleShortcutCount = this.appMenus.filter((menu) => !menu.hide).length + (isImpersonated ? 1 : 0)
+ this.showLogoutShortcut = !this.store.isElectronApp() && !isImpersonated && this.appMenus.filter((menu) => this.showAppShortcut(menu)).length <= 3
+ }
+
private updateDynamicTitle(title?: string) {
this.dynamicTitle = title ?? this.currentMenu.title
}
diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.json
index 62cfae03..f1f92ba7 100644
--- a/frontend/src/i18n/de.json
+++ b/frontend/src/i18n/de.json
@@ -527,7 +527,8 @@
"offline": "offline",
"Session has expired": "Sitzung ist abgelaufen",
"Please sign in": "Bitte melden Sie sich an",
- "logout": "abmelden",
+ "Logout": "Abmelden",
+ "Session": "Sitzung",
"days": "Tage",
"day": "Tag",
"Delete": "Löschen",
diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.json
index fa26dcd7..76a6f032 100644
--- a/frontend/src/i18n/es.json
+++ b/frontend/src/i18n/es.json
@@ -527,7 +527,8 @@
"offline": "desconectado",
"Session has expired": "La sesión ha expirado",
"Please sign in": "Por favor, inicie sesión",
- "logout": "cerrar sesión",
+ "Logout": "Cerrar sesión",
+ "Session": "Sesión",
"days": "días",
"day": "día",
"Delete": "Eliminar",
diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.json
index a8ebc751..c8c2ee72 100644
--- a/frontend/src/i18n/fr.json
+++ b/frontend/src/i18n/fr.json
@@ -527,7 +527,8 @@
"offline": "hors ligne",
"Session has expired": "La session a expiré",
"Please sign in": "Veuillez vous reconnecter",
- "logout": "déconnexion",
+ "Logout": "Déconnexion",
+ "Session": "Session",
"days": "jours",
"day": "jour",
"Delete": "Supprimer",
diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.json
index df1aa71f..89d8b509 100644
--- a/frontend/src/i18n/hi.json
+++ b/frontend/src/i18n/hi.json
@@ -527,7 +527,8 @@
"offline": "ऑफ़लाइन",
"Session has expired": "सत्र समाप्त हो गया है",
"Please sign in": "कृपया साइन इन करें",
- "logout": "साइन आउट",
+ "Logout": "साइन आउट",
+ "Session": "सत्र",
"days": "दिन",
"day": "दिन",
"Delete": "हटाएँ",
diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.json
index b4acdabb..e9e45628 100644
--- a/frontend/src/i18n/it.json
+++ b/frontend/src/i18n/it.json
@@ -527,7 +527,8 @@
"offline": "offline",
"Session has expired": "La sessione è scaduta",
"Please sign in": "Per favore, accedi",
- "logout": "esci",
+ "Logout": "Esci",
+ "Session": "Sessione",
"days": "giorni",
"day": "giorno",
"Delete": "Elimina",
diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.json
index 83508363..27e6cb7d 100644
--- a/frontend/src/i18n/ja.json
+++ b/frontend/src/i18n/ja.json
@@ -527,7 +527,8 @@
"offline": "オフライン",
"Session has expired": "セッションの有効期限が切れました",
"Please sign in": "再度サインインしてください",
- "logout": "ログアウト",
+ "Logout": "ログアウト",
+ "Session": "セッション",
"days": "日",
"day": "日",
"Delete": "削除",
diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.json
index a126bbd0..3b74623e 100644
--- a/frontend/src/i18n/ko.json
+++ b/frontend/src/i18n/ko.json
@@ -527,7 +527,8 @@
"offline": "오프라인",
"Session has expired": "세션이 만료되었습니다",
"Please sign in": "다시 로그인해 주세요",
- "logout": "로그아웃",
+ "Logout": "로그아웃",
+ "Session": "세션",
"days": "일",
"day": "일",
"Delete": "삭제",
diff --git a/frontend/src/i18n/nl.json b/frontend/src/i18n/nl.json
index 5d90ac59..f1b9f298 100644
--- a/frontend/src/i18n/nl.json
+++ b/frontend/src/i18n/nl.json
@@ -527,7 +527,8 @@
"offline": "offline",
"Session has expired": "Sessie is verlopen",
"Please sign in": "Inloggen",
- "logout": "uitloggen",
+ "Logout": "Uitloggen",
+ "Session": "Sessie",
"days": "dagen",
"day": "dag",
"Delete": "Verwijderen",
diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.json
index 0a92a8e7..71acff85 100644
--- a/frontend/src/i18n/pl.json
+++ b/frontend/src/i18n/pl.json
@@ -527,7 +527,8 @@
"offline": "offline",
"Session has expired": "Sesja wygasła",
"Please sign in": "Zaloguj się ponownie",
- "logout": "wyloguj",
+ "Logout": "Wyloguj",
+ "Session": "Sesja",
"days": "dni",
"day": "dzień",
"Delete": "Usuń",
diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.json
index e52e4e21..341a46d8 100644
--- a/frontend/src/i18n/pt-BR.json
+++ b/frontend/src/i18n/pt-BR.json
@@ -527,7 +527,8 @@
"offline": "offline",
"Session has expired": "A sessão expirou",
"Please sign in": "Faça login novamente",
- "logout": "sair",
+ "Logout": "Sair",
+ "Session": "Sessão",
"days": "dias",
"day": "dia",
"Delete": "Excluir",
diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.json
index 26ffa2a2..08ef2d9b 100644
--- a/frontend/src/i18n/pt.json
+++ b/frontend/src/i18n/pt.json
@@ -527,7 +527,8 @@
"offline": "desconectado",
"Session has expired": "A sessão expirou",
"Please sign in": "Por favor, faça login",
- "logout": "sair",
+ "Logout": "Sair",
+ "Session": "Sessão",
"days": "dias",
"day": "dia",
"Delete": "Excluir",
diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.json
index ac36c569..a2ff5e38 100644
--- a/frontend/src/i18n/ru.json
+++ b/frontend/src/i18n/ru.json
@@ -527,7 +527,8 @@
"offline": "не в сети",
"Session has expired": "Сессия истекла",
"Please sign in": "Пожалуйста, войдите",
- "logout": "выйти",
+ "Logout": "Выйти",
+ "Session": "Сеанс",
"days": "дней",
"day": "день",
"Delete": "Удалить",
diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.json
index 5999b877..228e9403 100644
--- a/frontend/src/i18n/tr.json
+++ b/frontend/src/i18n/tr.json
@@ -527,7 +527,8 @@
"offline": "çevrimdışı",
"Session has expired": "Oturumun süresi doldu",
"Please sign in": "Lütfen yeniden giriş yapın",
- "logout": "çıkış",
+ "Logout": "Çıkış",
+ "Session": "Oturum",
"days": "gün",
"day": "gün",
"Delete": "Sil",
diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.json
index 7b45bc0a..17ad231b 100644
--- a/frontend/src/i18n/zh.json
+++ b/frontend/src/i18n/zh.json
@@ -527,7 +527,8 @@
"offline": "离线",
"Session has expired": "会话已过期",
"Please sign in": "请登录",
- "logout": "退出登录",
+ "Logout": "退出登录",
+ "Session": "会话",
"days": "天",
"day": "天",
"Delete": "删除",