Skip to content

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

chore(frontend:user): update quota and user account info

johavena08176cbf678
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 49a3695a..8b76c9b3 100644
--- a/frontend/src/app/applications/users/components/user-account.component.ts
+++ b/frontend/src/app/applications/users/components/user-account.component.ts
@@ -1,6 +1,6 @@
import { KeyValuePipe } from '@angular/common'
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http'
-import { Component, inject, OnDestroy } from '@angular/core'
+import { Component, inject, OnDestroy, OnInit } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { FaIconComponent } from '@fortawesome/angular-fontawesome'
import { faCopy, faKey } from '@fortawesome/free-solid-svg-icons'
@@ -52,7 +52,7 @@ import { UserAuthManageAppPasswordsDialogComponent } from './dialogs/user-auth-m
],
templateUrl: 'user-account.component.html'
})
-export class UserAccountComponent implements OnDestroy {
+export class UserAccountComponent implements OnInit, OnDestroy {
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
protected readonly i18nLanguageText = i18nLanguageText
protected readonly allNotifications = Object.values(USER_NOTIFICATION_TEXT)
@@ -107,6 +107,10 @@ export class UserAccountComponent implements OnDestroy {
})
}
+ ngOnInit() {
+ this.userService.refreshUser()
+ }
+
ngOnDestroy() {
this.subscriptions.forEach((s) => s.unsubscribe())
}
diff --git a/frontend/src/app/applications/users/user.service.ts b/frontend/src/app/applications/users/user.service.ts
index d98c5ebf..1d81a602 100644
--- a/frontend/src/app/applications/users/user.service.ts
+++ b/frontend/src/app/applications/users/user.service.ts
@@ -6,6 +6,7 @@ import { SPACE_OPERATION } from '@sync-in-server/backend/src/applications/spaces
import { SYNC_ROUTE } from '@sync-in-server/backend/src/applications/sync/constants/routes'
import { AppStoreManifest } from '@sync-in-server/backend/src/applications/sync/interfaces/store-manifest.interface'
import {
+ API_USERS_ME,
API_USERS_MY_APP_PASSWORDS,
API_USERS_MY_AVATAR,
API_USERS_MY_GROUPS,
@@ -66,6 +67,7 @@ import { GuestUserModel } from './models/guest.model'
import { MemberModel } from './models/member.model'
import { UserOnlineModel } from './models/user-online.model'
import { myAvatarUrl } from './user.functions'
+import type { LoginResponseDto } from '@sync-in-server/backend/src/authentication/dto/login-response.dto'
@Injectable({ providedIn: 'root' })
export class UserService {
@@ -99,13 +101,24 @@ export class UserService {
this.layout.setLanguage(user.language).catch(console.error)
this.store.userImpersonate.set(impersonate || user.impersonated)
this.store.user.next(user)
- this.checkQuota(this.store.user.getValue())
+ this.checkQuota(this.user)
if (impersonate) {
this.disconnectWebSocket()
}
this.connectWebSocket()
}
+ loadUser(): Observable<Omit<LoginResponseDto, 'token'>> {
+ return this.http.get<Omit<LoginResponseDto, 'token'>>(API_USERS_ME)
+ }
+
+ refreshUser() {
+ this.loadUser().subscribe({
+ next: (r: Omit<LoginResponseDto, 'token'>) => this.store.user.next(r.user),
+ error: (e: HttpErrorResponse) => console.error(e)
+ })
+ }
+
connectWebSocket() {
this.webSocket.ioSocket.io.opts.query = { onlineStatus: this.user.onlineStatus }
this.webSocket.connect()
diff --git a/frontend/src/app/auth/auth.service.ts b/frontend/src/app/auth/auth.service.ts
index a8e66421..cf8b1354 100644
--- a/frontend/src/app/auth/auth.service.ts
+++ b/frontend/src/app/auth/auth.service.ts
@@ -5,7 +5,7 @@ import { CLIENT_TOKEN_EXPIRED_ERROR } from '@sync-in-server/backend/src/applicat
import { API_SYNC_AUTH_COOKIE, API_SYNC_REGISTER_AUTH } from '@sync-in-server/backend/src/applications/sync/constants/routes'
import type { SyncClientAuthDto } from '@sync-in-server/backend/src/applications/sync/dtos/sync-client-auth.dto'
import { SyncClientAuthCookie, SyncClientAuthRegistration } from '@sync-in-server/backend/src/applications/sync/interfaces/sync-client-auth.interface'
-import { API_ADMIN_IMPERSONATE_LOGOUT, API_USERS_ME } from '@sync-in-server/backend/src/applications/users/constants/routes'
+import { API_ADMIN_IMPERSONATE_LOGOUT } from '@sync-in-server/backend/src/applications/users/constants/routes'
import { CSRF_KEY } from '@sync-in-server/backend/src/authentication/constants/auth'
import {
API_AUTH_LOGIN,
@@ -162,7 +162,7 @@ export class AuthService {
this.logout()
return of(false)
} else if (!this.store.user.getValue()) {
- return this.http.get<Omit<LoginResponseDto, 'token'>>(API_USERS_ME).pipe(
+ return this.userService.loadUser().pipe(
tap((r: Omit<LoginResponseDto, 'token'>) => {
this.initUser(r)
if (authFromOIDC) {
diff --git a/frontend/src/styles/components/_sidebar_left.scss b/frontend/src/styles/components/_sidebar_left.scss
index 2b1020e7..82b30497 100755
--- a/frontend/src/styles/components/_sidebar_left.scss
+++ b/frontend/src/styles/components/_sidebar_left.scss
@@ -90,13 +90,13 @@
border-right: .5px solid transparent;
.app-shortcut {
- flex: 0 0 calc(#{$sidebar-apps-height} - 8px);
+ flex: 0 0 calc(#{$sidebar-apps-height} - 7px);
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: calc(#{$sidebar-apps-height} - 8px);
- height: calc(#{$sidebar-apps-height} - 8px);
+ height: calc(#{$sidebar-apps-height} - 9px);
border: .5px solid transparent;
border-radius: $btn-border-radius;
background: transparent;
@@ -169,7 +169,7 @@
gap: .5rem;
flex: 1 1 auto;
width: auto;
- height: calc(#{$sidebar-apps-height} - 5px);
+ height: calc(#{$sidebar-apps-height} - 4px);
margin: 0 6px;
padding: 0 10px;
border-radius: $btn-border-radius;