patch fo redirection

master
Boris Voropaev 2024-03-13 11:15:31 +03:00
parent 658f921ce6
commit 2e5fce6c23
4 changed files with 125 additions and 0 deletions

View File

@ -104,6 +104,10 @@
"replace": "src/app/_modules/layout/footer/footer.component.ts",
"with": "src/vniigaz-v2/component/layout/footer/footer.component.ts"
},
{
"replace": "src/app/_modules/pages/page/page.component.ts",
"with": "src/vniigaz-v2/component/pages/page/page.component.ts"
},
{
"replace": "src/app/_modules/layout/jumbotron/jumbotron.component.ts",
"with": "src/vniigaz-v2/component/layout/jumbotron/jumbotron.component.ts"
@ -163,6 +167,10 @@
"replace": "src/app/_modules/layout/footer/footer.component.ts",
"with": "src/vniigaz-v2/component/layout/footer/footer.component.ts"
},
{
"replace": "src/app/_modules/pages/page/page.component.ts",
"with": "src/vniigaz-v2/component/pages/page/page.component.ts"
},
{
"replace": "src/app/_modules/layout/jumbotron/jumbotron.component.ts",
"with": "src/vniigaz-v2/component/layout/jumbotron/jumbotron.component.ts"

View File

@ -0,0 +1,17 @@
<div *ngIf="page">
<!-- <div class="limiter">
<page-breadcrumbs [page]="page"></page-breadcrumbs>
</div> -->
<div class="pages" [ngSwitch]="page?.type?.name || page?.type">
<content-page *ngSwitchCase="'content'" [page]="page" [editMode]="editMode"></content-page>
<publications-page *ngSwitchCase="'publications'" [page]="page" [editMode]="editMode"></publications-page>
<registry-page *ngSwitchCase="'registry'" [page]="page" [editMode]="editMode"></registry-page>
<publication-page *ngSwitchCase="'publication'" [page]="page" [editMode]="editMode"></publication-page>
<tk-structure-page *ngSwitchCase="'tk-structure'" [page]="page" [editMode]="editMode"></tk-structure-page>
<p *ngSwitchDefault>Page type {{page?.type?.name}} is undefined</p>
</div>
</div>
<div *ngIf="!loading && !page">
<page-not-found></page-not-found>
</div>
<!--div class="loader" *ngIf="loading"></div-->

View File

@ -0,0 +1,9 @@
@media screen and (min-width: 1330px){
}
@media screen and (max-width: 480px) {
}

View File

@ -0,0 +1,91 @@
import {Component} from '@angular/core';
import {NavigationEnd, Router} from "@angular/router";
import {Subscription} from "rxjs";
import {PagesService} from "@app/_services/pages.service";
import {ListsService} from "@app/_services";
import {Title} from "@angular/platform-browser";
@Component({
templateUrl: 'page.component.html',
styleUrls: ['page.component.scss']
})
export class PageComponent {
public page: any;
public loading = false;
private url: string;
private inited = false;
routeSubscription?: Subscription;
listSubscription: Subscription;
constructor(
private router: Router,
private pagesService: PagesService,
private listsService: ListsService,
private titleService:Title){
this.routeSubscription = this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) this.onNavigationEnd(event);
});
}
get editMode() {
return this.pagesService.editMode;
}
get permissions() {
return this.page?.permissions;
}
get isEditable() {
return this.permissions?.edit || this.permissions?.anything;
}
ngOnInit() {
this.listSubscription = this.listsService.controls().subscribe(res => {
this.inited ? this.fetch() : this.inited = true;
});
}
ngOnDestroy() {
this.routeSubscription?.unsubscribe();
this.listSubscription?.unsubscribe()
}
onNavigationEnd(event: NavigationEnd) {
let url = event.url.split('(')[0].split('?')[0];
if (url !== this.url) {
this.url = url;
this.fetch();
this.pagesService.editMode = false;
}
}
fetch() {
this.loading = true;
let include = [
'parents.children',
'parents.picture',
'children',
'sections.type',
'sections.groups.fields.value',
'sections.objects.groups.fields.value',
'sidebars.groups.fields.value',
'sidebars.type',
'permissions',
'picture',
'posters'
];
if (this.url == '/certification/voluntary/main') this.url = '/sertifikaciya/obyazatelnaya-sertifikaciya'
this.pagesService.find(this.url, {include: include.join(',')}).subscribe(res => {
this.page = res?.data;
if (this.page) {
this.pagesService.currentPage = this.page;
// this.titleService.setTitle(this.page.title||this.page.h1||this.page.name)
}
this.loading = false;
}, error => {
this.loading = false;
});
}
}