@@ -16,7 +16,7 @@ const routes: Routes = [
|
|
16 |
},
|
17 |
{
|
18 |
path: 'books',
|
19 |
-
loadChildren: () => import('./books/books.
|
20 |
},
|
21 |
{
|
22 |
path: 'admin',
|
16 |
},
|
17 |
{
|
18 |
path: 'books',
|
19 |
+
loadChildren: () => import('./books/books.routes').then(m => m.BOOKS_ROUTES)
|
20 |
},
|
21 |
{
|
22 |
path: 'admin',
|
@@ -1,15 +1,22 @@
|
|
1 |
import { Component } from '@angular/core';
|
2 |
-
import {
|
|
|
3 |
import { Observable } from 'rxjs';
|
4 |
|
5 |
import { BookStoreService } from '../../shared/book-store.service';
|
6 |
import { Book } from '../../shared/book';
|
|
|
|
|
|
|
7 |
|
8 |
@Component({
|
9 |
selector: 'bm-book-details',
|
10 |
templateUrl: './book-details.component.html',
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
13 |
})
|
14 |
export class BookDetailsComponent {
|
15 |
book$: Observable<Book>;
|
1 |
import { Component } from '@angular/core';
|
2 |
+
import { AsyncPipe, DatePipe, NgFor, NgIf } from '@angular/common';
|
3 |
+
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
4 |
import { Observable } from 'rxjs';
|
5 |
|
6 |
import { BookStoreService } from '../../shared/book-store.service';
|
7 |
import { Book } from '../../shared/book';
|
8 |
+
import { IsbnPipe } from '../../shared/isbn.pipe';
|
9 |
+
import { LoggedinOnlyDirective } from '../../shared/loggedin-only.directive';
|
10 |
+
import { ConfirmDirective } from '../../shared/confirm.directive';
|
11 |
|
12 |
@Component({
|
13 |
selector: 'bm-book-details',
|
14 |
templateUrl: './book-details.component.html',
|
15 |
+
styleUrl: './book-details.component.css',
|
16 |
+
imports: [
|
17 |
+
NgIf, NgFor, DatePipe, AsyncPipe, RouterLink,
|
18 |
+
IsbnPipe, LoggedinOnlyDirective, ConfirmDirective
|
19 |
+
]
|
20 |
})
|
21 |
export class BookDetailsComponent {
|
22 |
book$: Observable<Book>;
|
@@ -1,14 +1,19 @@
|
|
|
|
1 |
import { Component } from '@angular/core';
|
2 |
import { Observable } from 'rxjs';
|
3 |
|
4 |
import { Book } from '../../shared/book';
|
5 |
import { BookStoreService } from '../../shared/book-store.service';
|
|
|
6 |
|
7 |
@Component({
|
8 |
selector: 'bm-book-list',
|
9 |
templateUrl: './book-list.component.html',
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
12 |
})
|
13 |
export class BookListComponent {
|
14 |
books$: Observable<Book[]>;
|
1 |
+
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
|
2 |
import { Component } from '@angular/core';
|
3 |
import { Observable } from 'rxjs';
|
4 |
|
5 |
import { Book } from '../../shared/book';
|
6 |
import { BookStoreService } from '../../shared/book-store.service';
|
7 |
+
import { BookListItemComponent } from '../book-list-item/book-list-item.component';
|
8 |
|
9 |
@Component({
|
10 |
selector: 'bm-book-list',
|
11 |
templateUrl: './book-list.component.html',
|
12 |
+
styleUrl: './book-list.component.css',
|
13 |
+
imports: [
|
14 |
+
NgIf, NgFor, AsyncPipe,
|
15 |
+
BookListItemComponent
|
16 |
+
]
|
17 |
})
|
18 |
export class BookListComponent {
|
19 |
books$: Observable<Book[]>;
|
@@ -1,11 +1,15 @@
|
|
|
|
1 |
import { Component, Input } from '@angular/core';
|
|
|
|
|
|
|
2 |
import { Book } from '../../shared/book';
|
3 |
|
4 |
@Component({
|
5 |
selector: 'bm-book-list-item',
|
6 |
templateUrl: './book-list-item.component.html',
|
7 |
-
|
8 |
-
|
9 |
})
|
10 |
export class BookListItemComponent {
|
11 |
@Input() book?: Book;
|
1 |
+
import { NgFor, NgIf } from '@angular/common';
|
2 |
import { Component, Input } from '@angular/core';
|
3 |
+
import { RouterLink } from '@angular/router';
|
4 |
+
|
5 |
+
import { IsbnPipe } from '../../shared/isbn.pipe';
|
6 |
import { Book } from '../../shared/book';
|
7 |
|
8 |
@Component({
|
9 |
selector: 'bm-book-list-item',
|
10 |
templateUrl: './book-list-item.component.html',
|
11 |
+
styleUrl: './book-list-item.component.css',
|
12 |
+
imports: [NgIf, NgFor, RouterLink, IsbnPipe]
|
13 |
})
|
14 |
export class BookListItemComponent {
|
15 |
@Input() book?: Book;
|
@@ -1,26 +0,0 @@
|
|
1 |
-
import { NgModule } from '@angular/core';
|
2 |
-
import { CommonModule } from '@angular/common';
|
3 |
-
|
4 |
-
import { BooksRoutingModule } from './books-routing.module';
|
5 |
-
import { BookListComponent } from './book-list/book-list.component';
|
6 |
-
import { BookListItemComponent } from './book-list-item/book-list-item.component';
|
7 |
-
import { BookDetailsComponent } from './book-details/book-details.component';
|
8 |
-
import { IsbnPipe } from './shared/isbn.pipe';
|
9 |
-
import { ConfirmDirective } from './shared/confirm.directive';
|
10 |
-
import { LoggedinOnlyDirective } from './shared/loggedin-only.directive';
|
11 |
-
|
12 |
-
@NgModule({
|
13 |
-
declarations: [
|
14 |
-
BookListComponent,
|
15 |
-
BookListItemComponent,
|
16 |
-
BookDetailsComponent,
|
17 |
-
IsbnPipe,
|
18 |
-
ConfirmDirective,
|
19 |
-
LoggedinOnlyDirective
|
20 |
-
],
|
21 |
-
imports: [
|
22 |
-
CommonModule,
|
23 |
-
BooksRoutingModule
|
24 |
-
]
|
25 |
-
})
|
26 |
-
export class BooksModule { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,10 +1,8 @@
|
|
1 |
-
import {
|
2 |
-
import { RouterModule, Routes } from '@angular/router';
|
3 |
-
|
4 |
import { BookDetailsComponent } from './book-details/book-details.component';
|
5 |
import { BookListComponent } from './book-list/book-list.component';
|
6 |
|
7 |
-
const
|
8 |
{
|
9 |
path: '',
|
10 |
component: BookListComponent,
|
@@ -14,9 +12,3 @@ const routes: Routes = [
|
|
14 |
component: BookDetailsComponent,
|
15 |
}
|
16 |
];
|
17 |
-
|
18 |
-
@NgModule({
|
19 |
-
imports: [RouterModule.forChild(routes)],
|
20 |
-
exports: [RouterModule]
|
21 |
-
})
|
22 |
-
export class BooksRoutingModule { }
|
1 |
+
import { Routes } from '@angular/router';
|
|
|
|
|
2 |
import { BookDetailsComponent } from './book-details/book-details.component';
|
3 |
import { BookListComponent } from './book-list/book-list.component';
|
4 |
|
5 |
+
export const BOOKS_ROUTES: Routes = [
|
6 |
{
|
7 |
path: '',
|
8 |
component: BookListComponent,
|
12 |
component: BookDetailsComponent,
|
13 |
}
|
14 |
];
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,8 +1,7 @@
|
|
1 |
import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
|
2 |
|
3 |
@Directive({
|
4 |
-
selector: '[bmConfirm]'
|
5 |
-
standalone: false
|
6 |
})
|
7 |
export class ConfirmDirective {
|
8 |
@Input('bmConfirm') confirmText?: string;
|
1 |
import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
|
2 |
|
3 |
@Directive({
|
4 |
+
selector: '[bmConfirm]'
|
|
|
5 |
})
|
6 |
export class ConfirmDirective {
|
7 |
@Input('bmConfirm') confirmText?: string;
|
@@ -1,8 +1,7 @@
|
|
1 |
import { Pipe, PipeTransform } from '@angular/core';
|
2 |
|
3 |
@Pipe({
|
4 |
-
name: 'isbn'
|
5 |
-
standalone: false
|
6 |
})
|
7 |
export class IsbnPipe implements PipeTransform {
|
8 |
|
1 |
import { Pipe, PipeTransform } from '@angular/core';
|
2 |
|
3 |
@Pipe({
|
4 |
+
name: 'isbn'
|
|
|
5 |
})
|
6 |
export class IsbnPipe implements PipeTransform {
|
7 |
|
@@ -1,11 +1,10 @@
|
|
1 |
import { Directive, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
|
2 |
import { Subject, takeUntil } from 'rxjs';
|
3 |
|
4 |
-
import { AuthService } from '
|
5 |
|
6 |
@Directive({
|
7 |
-
selector: '[bmLoggedinOnly]'
|
8 |
-
standalone: false
|
9 |
})
|
10 |
export class LoggedinOnlyDirective implements OnDestroy {
|
11 |
private destroy$ = new Subject<void>();
|
1 |
import { Directive, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
|
2 |
import { Subject, takeUntil } from 'rxjs';
|
3 |
|
4 |
+
import { AuthService } from './auth.service';
|
5 |
|
6 |
@Directive({
|
7 |
+
selector: '[bmLoggedinOnly]'
|
|
|
8 |
})
|
9 |
export class LoggedinOnlyDirective implements OnDestroy {
|
10 |
private destroy$ = new Subject<void>();
|