Fixed ui loading
This commit is contained in:
parent
603fe8ad26
commit
8f60c65771
@ -4,12 +4,14 @@ import { NotFoundComponent } from "src/app/components/error/not-found/not-found.
|
|||||||
import { AuthGuard } from "src/app/core/guard/auth.guard";
|
import { AuthGuard } from "src/app/core/guard/auth.guard";
|
||||||
import { HomeComponent } from "src/app/components/home/home.component";
|
import { HomeComponent } from "src/app/components/home/home.component";
|
||||||
import { RedirectComponent } from "src/app/components/redirect/redirect.component";
|
import { RedirectComponent } from "src/app/components/redirect/redirect.component";
|
||||||
|
import { LogoutComponent } from "src/app/components/logout/logout.component";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: "",
|
path: "",
|
||||||
component: HomeComponent,
|
component: HomeComponent,
|
||||||
},
|
},
|
||||||
|
{ path: "logout", component: LogoutComponent },
|
||||||
{
|
{
|
||||||
path: "admin",
|
path: "admin",
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<main *ngIf="isLoggedIn && showSidebar; else home">
|
<main *ngIf="isLoggedIn && !hideUI; else home">
|
||||||
<app-header></app-header>
|
<app-header></app-header>
|
||||||
|
|
||||||
<div class="app">
|
<div class="app">
|
||||||
<aside>
|
<aside *ngIf="showSidebar">
|
||||||
<app-sidebar></app-sidebar>
|
<app-sidebar></app-sidebar>
|
||||||
</aside>
|
</aside>
|
||||||
<section class="component">
|
<section class="component">
|
||||||
|
@ -3,6 +3,7 @@ import { SidebarService } from "src/app/service/sidebar.service";
|
|||||||
import { Subject } from "rxjs";
|
import { Subject } from "rxjs";
|
||||||
import { takeUntil } from "rxjs/operators";
|
import { takeUntil } from "rxjs/operators";
|
||||||
import { AuthService } from "src/app/service/auth.service";
|
import { AuthService } from "src/app/service/auth.service";
|
||||||
|
import { GuiService } from "src/app/service/gui.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-root",
|
selector: "app-root",
|
||||||
@ -11,12 +12,14 @@ import { AuthService } from "src/app/service/auth.service";
|
|||||||
})
|
})
|
||||||
export class AppComponent implements OnDestroy {
|
export class AppComponent implements OnDestroy {
|
||||||
showSidebar = false;
|
showSidebar = false;
|
||||||
|
hideUI = false;
|
||||||
isLoggedIn = false;
|
isLoggedIn = false;
|
||||||
unsubscribe$ = new Subject<void>();
|
unsubscribe$ = new Subject<void>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private sidebar: SidebarService,
|
private sidebar: SidebarService,
|
||||||
private auth: AuthService,
|
private auth: AuthService,
|
||||||
|
private gui: GuiService,
|
||||||
) {
|
) {
|
||||||
this.auth.loadUser();
|
this.auth.loadUser();
|
||||||
|
|
||||||
@ -29,6 +32,10 @@ export class AppComponent implements OnDestroy {
|
|||||||
.subscribe((visible) => {
|
.subscribe((visible) => {
|
||||||
this.showSidebar = visible;
|
this.showSidebar = visible;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.gui.hideGui$.pipe(takeUntil(this.unsubscribe$)).subscribe((hide) => {
|
||||||
|
this.hideUI = hide;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
@ -23,6 +23,7 @@ import { ErrorHandlingService } from "src/app/service/error-handling.service";
|
|||||||
import { HomeComponent } from "./components/home/home.component";
|
import { HomeComponent } from "./components/home/home.component";
|
||||||
import { RedirectComponent } from "./components/redirect/redirect.component";
|
import { RedirectComponent } from "./components/redirect/redirect.component";
|
||||||
import { SettingsService } from "src/app/service/settings.service";
|
import { SettingsService } from "src/app/service/settings.service";
|
||||||
|
import { LogoutComponent } from './components/logout/logout.component';
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
Logger.enableProductionMode();
|
Logger.enableProductionMode();
|
||||||
@ -58,6 +59,7 @@ export function appInitializerFactory(
|
|||||||
SidebarComponent,
|
SidebarComponent,
|
||||||
HomeComponent,
|
HomeComponent,
|
||||||
RedirectComponent,
|
RedirectComponent,
|
||||||
|
LogoutComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -2,10 +2,11 @@ import { Component, OnInit } from "@angular/core";
|
|||||||
import { SidebarService } from "src/app/service/sidebar.service";
|
import { SidebarService } from "src/app/service/sidebar.service";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { environment } from "src/environments/environment";
|
|
||||||
import { ShortUrlDto } from "src/app/model/entities/short-url";
|
import { ShortUrlDto } from "src/app/model/entities/short-url";
|
||||||
import { SettingsService } from "src/app/service/settings.service";
|
import { SettingsService } from "src/app/service/settings.service";
|
||||||
import { AppSettings } from "src/app/model/config/app-settings";
|
import { AppSettings } from "src/app/model/config/app-settings";
|
||||||
|
import { GuiService } from "src/app/service/gui.service";
|
||||||
|
import { SpinnerService } from "src/app/service/spinner.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-redirect",
|
selector: "app-redirect",
|
||||||
@ -23,8 +24,10 @@ export class RedirectComponent implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
private settingsService: SettingsService,
|
private settingsService: SettingsService,
|
||||||
|
private gui: GuiService,
|
||||||
) {
|
) {
|
||||||
this.sidebar.hide();
|
this.sidebar.hide();
|
||||||
|
this.gui.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -13,6 +13,8 @@ export class GuiService {
|
|||||||
isMobile$ = new BehaviorSubject<boolean>(this.isMobileByWindowWith());
|
isMobile$ = new BehaviorSubject<boolean>(this.isMobileByWindowWith());
|
||||||
isTablet$ = new BehaviorSubject<boolean>(this.isTabletByWindowWith());
|
isTablet$ = new BehaviorSubject<boolean>(this.isTabletByWindowWith());
|
||||||
|
|
||||||
|
hideGui$ = new BehaviorSubject<boolean>(false);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private sidebarService: SidebarService,
|
private sidebarService: SidebarService,
|
||||||
@ -67,4 +69,12 @@ export class GuiService {
|
|||||||
return "rgb(" + r + ", " + g + ", " + b + ")";
|
return "rgb(" + r + ", " + g + ", " + b + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public show() {
|
||||||
|
this.hideGui$.next(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public hide() {
|
||||||
|
this.hideGui$.next(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user