From ec84a767967adf8af6bc7ef732faf5babddfb54c Mon Sep 17 00:00:00 2001 From: Boris Voropaev Date: Tue, 21 Nov 2023 17:31:56 +0300 Subject: [PATCH] root Pages --- .../_modules/pages/menu/pages-menu.component.ts | 2 -- .../basic/images/images-section.component.ts | 1 - .../_modules/widjet/locale/locale.component.ts | 17 +++++++++++++---- src/app/_services/pages.service.ts | 2 +- src/app/app.component.ts | 8 ++++++++ 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/app/_modules/pages/menu/pages-menu.component.ts b/src/app/_modules/pages/menu/pages-menu.component.ts index 639abd5..f96d1cd 100644 --- a/src/app/_modules/pages/menu/pages-menu.component.ts +++ b/src/app/_modules/pages/menu/pages-menu.component.ts @@ -27,7 +27,6 @@ export class PagesMenuComponent implements OnInit { this.pagesService.rootPageSubject ]).subscribe( resp=>{ - console.log(resp) let [currentPage, rootPage] = resp if(currentPage){ let menuTree = currentPage.parents.data.reduceRight( @@ -40,7 +39,6 @@ export class PagesMenuComponent implements OnInit { }, currentPage); this.items = menuTree.children.data; }else{ - console.log(rootPage) this.items = rootPage?.data[0].children.data } } diff --git a/src/app/_modules/pages/sections/types/basic/images/images-section.component.ts b/src/app/_modules/pages/sections/types/basic/images/images-section.component.ts index 30bbb32..cb07c34 100644 --- a/src/app/_modules/pages/sections/types/basic/images/images-section.component.ts +++ b/src/app/_modules/pages/sections/types/basic/images/images-section.component.ts @@ -47,7 +47,6 @@ export class ImagesSectionComponent { return type.name; } get imageClass(){ - console.log(this.imageType) return { small : this.imageType=='tiles', large : this.imageType=='full-width', diff --git a/src/app/_modules/widjet/locale/locale.component.ts b/src/app/_modules/widjet/locale/locale.component.ts index b9ec9b1..1d98ece 100644 --- a/src/app/_modules/widjet/locale/locale.component.ts +++ b/src/app/_modules/widjet/locale/locale.component.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import {PagesService} from "@app/_services/pages.service"; import { environment } from '@environments/environment'; +import {Subscription} from "rxjs"; @Component({ selector: 'locale', @@ -11,16 +12,24 @@ export class LocaleComponent { public locales = []; public ddMenu:boolean; + private rootSubscription: Subscription constructor( public pagesService: PagesService ){} ngOnInit() { - this.pagesService.root({include:'children'}).subscribe(res => { - this.locales = res.data; - this.pagesService.rootPage = res - }); + this.pagesService.rootPageSubject.subscribe( + + res=>{ + console.log(res) + this.locales = res?.data + } + ) + } + + ngOnDestroy() { + this.rootSubscription.unsubscribe() } get rootPage() { diff --git a/src/app/_services/pages.service.ts b/src/app/_services/pages.service.ts index 9a6293e..415825b 100644 --- a/src/app/_services/pages.service.ts +++ b/src/app/_services/pages.service.ts @@ -22,7 +22,7 @@ export class PagesService { } set currentPage(val: any) { this.currentPageSubject.next(val); - this.rootPage = val?.parents?.data[0] || val; + // this.rootPage = val?.parents?.data[0] || val; this.setMetaFromPage(val); } get rootPage() { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7908d3d..3f91a51 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -10,6 +10,7 @@ import {Subscription} from "rxjs"; styleUrls: ['app.component.scss']}) export class AppComponent { public subscription: Subscription; + private rootSubscription: Subscription constructor(private authService: AuthenticationService, private pagesService: PagesService, private titleService: Title, private metaService: Meta) { authService.checkUser(); @@ -18,8 +19,15 @@ export class AppComponent { }); } + ngOnInit() { + this.rootSubscription = this.pagesService.root({include:'children'}).subscribe(res => { + this.pagesService.rootPage = res + }); + } + ngOnDestroy() { this.subscription?.unsubscribe(); + this.rootSubscription.unsubscribe() } applyMetaData(data: any) {