improved version

pull/2092/head
Anojh 6 years ago
parent df27ea743c
commit 3a99f75daa

@ -1,5 +1,5 @@
import { PlatformLocation } from "@angular/common";
import { AfterViewInit, Component, OnDestroy, OnInit } from "@angular/core";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { IMediaServerStatus } from "../interfaces";
import { ICustomizationSettings, ILandingPageSettings } from "../interfaces";
@ -17,13 +17,14 @@ import { fadeInOutAnimation } from "../animations/fadeinout";
animations: [fadeInOutAnimation],
styleUrls: ["./landingpage.component.scss"],
})
export class LandingPageComponent implements AfterViewInit, OnInit, OnDestroy {
export class LandingPageComponent implements OnDestroy, OnInit {
public customizationSettings: ICustomizationSettings;
public landingPageSettings: ILandingPageSettings;
public background: any;
public mediaServerStatus: IMediaServerStatus;
public baseUrl: string;
private timer: any;
constructor(private settingsService: SettingsService,
private images: ImageService, private sanitizer: DomSanitizer, private landingPageService: LandingPageService,
@ -35,6 +36,9 @@ export class LandingPageComponent implements AfterViewInit, OnInit, OnDestroy {
this.images.getRandomBackground().subscribe(x => {
this.background = this.sanitizer.bypassSecurityTrustStyle("linear-gradient(-10deg, transparent 20%, rgba(0,0,0,0.7) 20.0%, rgba(0,0,0,0.7) 80.0%, transparent 80%), url(" + x.url + ")");
});
this.timer = setInterval(() => {
this.cycleBackground();
}, 10000);
const base = this.location.getBaseHrefFromDOM();
if (base.length > 1) {
@ -47,6 +51,10 @@ export class LandingPageComponent implements AfterViewInit, OnInit, OnDestroy {
}
public ngOnDestroy() {
clearInterval(this.timer);
}
public cycleBackground() {
setTimeout(() => {
this.images.getRandomBackground().subscribe(x => {
this.background = "";
@ -59,10 +67,4 @@ export class LandingPageComponent implements AfterViewInit, OnInit, OnDestroy {
});
}, 1000);
}
public ngAfterViewInit() {
setInterval(() => {
this.ngOnDestroy();
}, 10000);
}
}

@ -1,4 +1,4 @@
import { AfterViewInit, Component, OnDestroy, OnInit } from "@angular/core";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
@ -20,7 +20,7 @@ import { fadeInOutAnimation } from "../animations/fadeinout";
animations: [fadeInOutAnimation],
styleUrls: ["./login.component.scss"],
})
export class LoginComponent implements AfterViewInit, OnDestroy, OnInit {
export class LoginComponent implements OnDestroy, OnInit {
public form: FormGroup;
public customizationSettings: ICustomizationSettings;
@ -28,6 +28,7 @@ export class LoginComponent implements AfterViewInit, OnDestroy, OnInit {
public background: any;
public landingFlag: boolean;
public baseUrl: string;
private timer: any;
private errorBody: string;
private errorValidation: string;
@ -70,6 +71,10 @@ export class LoginComponent implements AfterViewInit, OnDestroy, OnInit {
this.images.getRandomBackground().subscribe(x => {
this.background = this.sanitizer.bypassSecurityTrustStyle("linear-gradient(-10deg, transparent 20%, rgba(0,0,0,0.7) 20.0%, rgba(0,0,0,0.7) 80.0%, transparent 80%),url(" + x.url + ")");
});
this.timer = setInterval(() => {
this.cycleBackground();
}, 10000);
const base = this.location.getBaseHrefFromDOM();
if (base.length > 1) {
this.baseUrl = base;
@ -107,6 +112,10 @@ export class LoginComponent implements AfterViewInit, OnDestroy, OnInit {
}
public ngOnDestroy() {
clearInterval(this.timer);
}
private cycleBackground() {
setTimeout(() => {
this.images.getRandomBackground().subscribe(x => {
this.background = "";
@ -120,9 +129,4 @@ export class LoginComponent implements AfterViewInit, OnDestroy, OnInit {
}, 1000);
}
public ngAfterViewInit() {
setInterval(() => {
this.ngOnDestroy();
}, 10000);
}
}

Loading…
Cancel
Save