1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import { Component } from '@angular/core';
|
7 | import { Location } from '@angular/common';
|
8 | import { NbAuthService } from '../services/auth.service';
|
9 | import { takeUntil } from 'rxjs/operators';
|
10 | import { Subject } from 'rxjs';
|
11 | export class NbAuthComponent {
|
12 |
|
13 | constructor(auth, location) {
|
14 | this.auth = auth;
|
15 | this.location = location;
|
16 | this.destroy$ = new Subject();
|
17 | this.authenticated = false;
|
18 | this.token = '';
|
19 | this.subscription = auth.onAuthenticationChange()
|
20 | .pipe(takeUntil(this.destroy$))
|
21 | .subscribe((authenticated) => {
|
22 | this.authenticated = authenticated;
|
23 | });
|
24 | }
|
25 | back() {
|
26 | this.location.back();
|
27 | return false;
|
28 | }
|
29 | ngOnDestroy() {
|
30 | this.destroy$.next();
|
31 | this.destroy$.complete();
|
32 | }
|
33 | }
|
34 | NbAuthComponent.decorators = [
|
35 | { type: Component, args: [{
|
36 | selector: 'nb-auth',
|
37 | template: `
|
38 | <nb-layout>
|
39 | <nb-layout-column>
|
40 | <nb-card>
|
41 | <nb-card-header>
|
42 | <nav class="navigation">
|
43 | <a href="#" (click)="back()" class="link back-link" aria-label="Back">
|
44 | <nb-icon icon="arrow-back"></nb-icon>
|
45 | </a>
|
46 | </nav>
|
47 | </nb-card-header>
|
48 | <nb-card-body>
|
49 | <nb-auth-block>
|
50 | <router-outlet></router-outlet>
|
51 | </nb-auth-block>
|
52 | </nb-card-body>
|
53 | </nb-card>
|
54 | </nb-layout-column>
|
55 | </nb-layout>
|
56 | `,
|
57 | styles: ["/*!\n * @license\n * Copyright Akveo. All Rights Reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n */:host nb-card{margin:0;height:calc(100vh - 2 * 2.5rem)}:host .navigation .link{display:inline-block;text-decoration:none}:host .navigation .link nb-icon{font-size:2rem;vertical-align:middle}:host .links nb-icon{font-size:2.5rem}:host nb-card-body{display:flex;width:100%}:host nb-auth-block{margin:auto}@media (max-width: 767.98px){:host nb-card{border-radius:0;height:100vh}}:host ::ng-deep nb-layout .layout .layout-container .content .columns nb-layout-column{padding:2.5rem}@media (max-width: 767.98px){:host ::ng-deep nb-layout .layout .layout-container .content .columns nb-layout-column{padding:0}}\n"]
|
58 | },] }
|
59 | ];
|
60 | NbAuthComponent.ctorParameters = () => [
|
61 | { type: NbAuthService },
|
62 | { type: Location }
|
63 | ];
|
64 |
|
\ | No newline at end of file |