67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { Component } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { Subscription } from "rxjs";
|
|
import { PagesService } from '@app/_services/pages.service';
|
|
import { FormsService } from '@app/_services';
|
|
|
|
@Component({
|
|
selector: 'jumbotron',
|
|
templateUrl: './jumbotron.component.html',
|
|
styleUrls: ['./jumbotron.component.scss']
|
|
})
|
|
export class Jumbotron {
|
|
public url: string = "";
|
|
public background:string;
|
|
public pageName:string;
|
|
public editable:string;
|
|
public editMode: boolean = false;
|
|
private pageID: string;
|
|
private routeSubscription: Subscription;
|
|
|
|
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private pagesService:PagesService,
|
|
private formsService: FormsService) {
|
|
|
|
}
|
|
|
|
ngOnInit(){
|
|
this.pagesService.editMode.subscribe(
|
|
mode => {
|
|
this.editMode = mode;
|
|
}
|
|
)
|
|
this.pagesService.currentPage.subscribe(
|
|
page => {
|
|
if (page){
|
|
this.background = page.image?.data?.links?.full;
|
|
if (this.background) this.background = `url(${this.background})`;
|
|
this.pageName = (page.parents?.data[2]||page).name;
|
|
this.editable = page.permissions?.edit || page.permissions?.anything;
|
|
this.pageID = page.id
|
|
}else{
|
|
this.pageName = null;
|
|
this.editable = null;
|
|
this.pagesService.editMode.next(false)
|
|
}
|
|
}
|
|
)
|
|
}
|
|
|
|
editBackground() {
|
|
this.formsService.createModel('page-background', {extraProps: {attach: {pageId: this.pageID}}});
|
|
}
|
|
|
|
removeBackground() {
|
|
if (confirm('Вы деествительно хотите удалить этот фон?')) {
|
|
this.pagesService.deleteBackground(this.pageID).subscribe(res => {
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|