mirror of
https://github.com/CaramelFur/Picsur.git
synced 2025-11-13 15:25:39 +01:00
improve a bunch of ui
This commit is contained in:
@@ -4,7 +4,7 @@ import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { SnackBarType } from "src/app/models/dto/snack-bar-type.dto";
|
||||
import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto';
|
||||
import { PermissionService } from 'src/app/services/api/permission.service';
|
||||
import { UserService } from 'src/app/services/api/user.service';
|
||||
import { UtilService } from 'src/app/util/util-module/util.service';
|
||||
@@ -19,7 +19,11 @@ export class HeaderComponent implements OnInit {
|
||||
@Output('onHamburgerClick') onHamburgerClick = new EventEmitter<void>();
|
||||
|
||||
private currentUser: EUser | null = null;
|
||||
private permissions: string[] = [];
|
||||
|
||||
public canLogIn: boolean = false;
|
||||
public canAccessSettings: boolean = false;
|
||||
public canUpload: boolean = false;
|
||||
public canRegister: boolean = false;
|
||||
|
||||
public get user() {
|
||||
return this.currentUser;
|
||||
@@ -29,14 +33,6 @@ export class HeaderComponent implements OnInit {
|
||||
return this.currentUser !== null;
|
||||
}
|
||||
|
||||
public get canLogIn() {
|
||||
return this.permissions.includes(Permission.UserLogin);
|
||||
}
|
||||
|
||||
public get canAccessSettings() {
|
||||
return this.permissions.includes(Permission.Settings);
|
||||
}
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private userService: UserService,
|
||||
@@ -59,7 +55,10 @@ export class HeaderComponent implements OnInit {
|
||||
@AutoUnsubscribe()
|
||||
subscribePermissions() {
|
||||
return this.permissionService.live.subscribe((permissions) => {
|
||||
this.permissions = permissions;
|
||||
this.canLogIn = permissions.includes(Permission.UserLogin);
|
||||
this.canAccessSettings = permissions.includes(Permission.Settings);
|
||||
this.canUpload = permissions.includes(Permission.ImageUpload);
|
||||
this.canRegister = permissions.includes(Permission.UserRegister);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,4 +79,8 @@ export class HeaderComponent implements OnInit {
|
||||
doSettings() {
|
||||
this.router.navigate(['/settings']);
|
||||
}
|
||||
|
||||
doUpload() {
|
||||
this.router.navigate(['/upload']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user