WIP: Permissions
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
<div class="w-full h-[calc(100vh-6.6rem)] overflow-y-auto border rounded-lg p-4 enclosing-container">
|
||||
<div class="w-full h-[calc(100vh-12.1rem)] overflow-y-auto border rounded-lg p-4 enclosing-container">
|
||||
<p class="text-3xl font-semibold">Preferences</p>
|
||||
<p-divider></p-divider>
|
||||
|
||||
|
||||
-1
@@ -65,7 +65,6 @@ export class BookPreferences implements OnInit {
|
||||
if (settings) {
|
||||
this.populateSettings(settings);
|
||||
this.currentMetadataOptions = settings.metadataRefreshOptions;
|
||||
console.log(this.currentMetadataOptions)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
<div class="card">
|
||||
<div class="card" *ngIf="userService.userData$ | async as userData">
|
||||
<p-tabs value="0">
|
||||
<p-tablist>
|
||||
<p-tab value="0">Book Preferences</p-tab>
|
||||
<p-tab value="1">Admin</p-tab>
|
||||
<ng-container *ngIf="userData.permissions.isAdmin">
|
||||
<p-tab value="1">Admin</p-tab>
|
||||
</ng-container>
|
||||
|
||||
</p-tablist>
|
||||
|
||||
<p-tabpanels>
|
||||
<p-tabpanel value="0">
|
||||
<app-book-preferences></app-book-preferences>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="1">
|
||||
<app-admin></app-admin>
|
||||
</p-tabpanel>
|
||||
<ng-container *ngIf="userData.permissions.isAdmin">
|
||||
<p-tabpanel value="1">
|
||||
<app-admin></app-admin>
|
||||
</p-tabpanel>
|
||||
</ng-container>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {BookPreferences} from './book-preferences/book-preferences.component';
|
||||
import {AdminComponent} from './admin/admin.component';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
@@ -12,11 +14,15 @@ import {AdminComponent} from './admin/admin.component';
|
||||
TabPanels,
|
||||
TabPanel,
|
||||
BookPreferences,
|
||||
AdminComponent
|
||||
AdminComponent,
|
||||
NgIf,
|
||||
AsyncPipe
|
||||
],
|
||||
templateUrl: './settings.component.html',
|
||||
styleUrl: './settings.component.scss'
|
||||
})
|
||||
export class SettingsComponent {
|
||||
|
||||
protected userService = inject(UserService);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { inject, Injectable, Injector } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable, tap } from 'rxjs';
|
||||
import { RxStompService } from '../../shared/websocket/rx-stomp.service';
|
||||
import { createRxStompConfig } from '../../shared/websocket/rx-stomp.config';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -11,14 +10,15 @@ export class AuthService {
|
||||
private apiUrl = 'http://localhost:7050/api/v1/auth/login';
|
||||
private rxStompService?: RxStompService;
|
||||
|
||||
constructor(private http: HttpClient, private injector: Injector) {}
|
||||
private http = inject(HttpClient);
|
||||
private injector = inject(Injector);
|
||||
|
||||
login(credentials: { username: string; password: string }): Observable<any> {
|
||||
return this.http.post<{ token: string }>(this.apiUrl, credentials).pipe(
|
||||
tap((response) => {
|
||||
if (response.token) {
|
||||
this.saveToken(response.token);
|
||||
this.startWebSocket();
|
||||
this.getRxStompService().activate();
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -37,15 +37,6 @@ export class AuthService {
|
||||
this.getRxStompService().deactivate();
|
||||
}
|
||||
|
||||
private startWebSocket(): void {
|
||||
const token = this.getToken();
|
||||
if (token) {
|
||||
const rxStompService = this.getRxStompService();
|
||||
rxStompService.configure(createRxStompConfig(this));
|
||||
rxStompService.activate();
|
||||
}
|
||||
}
|
||||
|
||||
private getRxStompService(): RxStompService {
|
||||
if (!this.rxStompService) {
|
||||
this.rxStompService = this.injector.get(RxStompService);
|
||||
|
||||
Reference in New Issue
Block a user