Add data source properties retrieval and update related components

This commit is contained in:
liosha84
2025-06-30 19:14:15 +03:00
parent 5fce34dfb8
commit 0eeb93cd57
15 changed files with 209 additions and 15 deletions
@@ -1,8 +1,8 @@
import {Component, CUSTOM_ELEMENTS_SCHEMA, inject} from '@angular/core';
import {Component, CUSTOM_ELEMENTS_SCHEMA, inject, OnInit} from '@angular/core';
//import {NavigationComponent} from '../navigation/navigation.component';
import {NgClass} from '@angular/common';
import {NavigationComponent} from '../../layouts/admin-layout/navigation/navigation.component';
import {RouterLink, RouterOutlet} from '@angular/router';
import {Router, RouterLink, RouterOutlet} from '@angular/router';
import {BreadcrumbComponent} from '../../components/breadcrumb/breadcrumb.component';
import {NavBarComponent} from '../../layouts/admin-layout/nav-bar/nav-bar.component';
import {MatToolbar} from '@angular/material/toolbar';
@@ -29,7 +29,7 @@ import {DialogComponent} from '../../components/dialog/dialog.component';
templateUrl: './main.component.html',
styleUrl: './main.component.scss'
})
export class MainComponent {
export class MainComponent implements OnInit{
// public props
navCollapsed: boolean = false;
navCollapsedMob: boolean = false;
@@ -52,13 +52,24 @@ export class MainComponent {
private authService: AuthService = inject(AuthService);
private eventBusService: EventBusService = inject(EventBusService);
constructor(
constructor(private router: Router) {
) {}
}
goToHome() {
this.router.navigate(['main/home']);
}
ngOnInit(): void {
this.isLoggedIn = this.storageService.isLoggedIn();
this.refreshToolbar();
this.eventBusSub = this.eventBusService.on('logout', () => {
this.logout();
});
}
refreshToolbar() {
if (this.isLoggedIn) {
const user = this.storageService.getUser();
this.roles = user.roles;
@@ -68,10 +79,12 @@ export class MainComponent {
this.username = user.username;
}
}
this.eventBusSub = this.eventBusService.on('logout', () => {
this.logout();
});
ngOnDestroy() {
if (this.eventBusSub) {
this.eventBusSub.unsubscribe();
}
}
// public method
@@ -142,7 +155,8 @@ export class MainComponent {
let user = this.storageService.getUser();
this.roles = user.roles;
//this.username = user.username;
this.reloadPage();
//this.reloadPage();
this.refreshToolbar();
},
err => {
this.errorMessage = err.error.message;