Skip to content

Commit 75ee852

Browse files
starting point
1 parent c55b978 commit 75ee852

File tree

63 files changed

+1282
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1282
-111
lines changed

db.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
{
44
"id": "1",
55
"name": "Interstellar",
6-
"rating": 4.5
6+
"description": "Space",
7+
"earnings": 25000000
78
},
89
{
910
"id": "2",
1011
"name": "Inception",
11-
"rating": 1.0
12+
"description": "I forgot",
13+
"earnings": 50000000
1214
}
13-
]
14-
}
15+
],
16+
"books": []
17+
}

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "0.0.0",
44
"scripts": {
55
"ng": "ng",
6-
"start": "ng serve",
6+
"start": "concurrently \"npm run server\" \"ng serve\"",
7+
"server": "json-server db.json --watch",
78
"build": "ng build",
89
"test": "jest",
910
"lint": "ng lint",
@@ -18,16 +19,20 @@
1819
"private": true,
1920
"dependencies": {
2021
"@angular/animations": "~7.2.0",
22+
"@angular/cdk": "~7.3.0",
2123
"@angular/common": "~7.2.0",
2224
"@angular/compiler": "~7.2.0",
2325
"@angular/core": "~7.2.0",
2426
"@angular/forms": "~7.2.0",
27+
"@angular/material": "~7.3.0",
2528
"@angular/platform-browser": "~7.2.0",
2629
"@angular/platform-browser-dynamic": "~7.2.0",
2730
"@angular/router": "~7.2.0",
2831
"@ngrx/effects": "^7.4.0",
2932
"@ngrx/entity": "^7.4.0",
33+
"@ngrx/router-store": "^7.4.0",
3034
"@ngrx/store": "^7.4.0",
35+
"@ngrx/store-devtools": "^7.4.0",
3136
"core-js": "^2.5.4",
3237
"rxjs": "~6.3.3",
3338
"tslib": "^1.9.0",

src/app/app-routing.module.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/app/app.component.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
:host {
2+
display: flex;
3+
flex-direction: column;
4+
flex: 1;
5+
}
6+
7+
.nav-link {
8+
color: rgba(0,0,0,.54);
9+
display: flex;
10+
align-items:center;
11+
padding-top: 5px;
12+
padding-bottom: 5px;
13+
}
14+
15+
mat-toolbar {
16+
box-shadow: 0 3px 5px -1px rgba(0,0,0,.2), 0 6px 10px 0 rgba(0,0,0,.14), 0 1px 18px 0 rgba(0,0,0,.12);
17+
z-index: 1;
18+
}
19+
20+
mat-toolbar > .mat-mini-fab {
21+
margin-right: 10px;
22+
}
23+
24+
mat-sidenav {
25+
box-shadow: 3px 0 6px rgba(0,0,0,.24);
26+
width: 200px;
27+
}
28+
29+
.mat-sidenav-container {
30+
background: #f5f5f5;
31+
flex: 1;
32+
}

src/app/app.component.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<mat-toolbar color="primary">
2+
<button (click)="sidenav.toggle()" mat-mini-fab><mat-icon>menu</mat-icon></button>
3+
<span>
4+
{{ title }}
5+
</span>
6+
</mat-toolbar>
7+
8+
<mat-sidenav-container>
9+
<mat-sidenav #sidenav mode="side" class="app-sidenav">
10+
<nav>
11+
<a mat-button
12+
class="nav-link"
13+
*ngFor="let link of links"
14+
[routerLink]="link.path"
15+
routerLinkActive="active">
16+
<mat-icon>{{link.icon}}</mat-icon>
17+
{{link.label}}
18+
</a>
19+
</nav>
20+
</mat-sidenav>
21+
22+
<div class="app-content">
23+
<router-outlet></router-outlet>
24+
</div>
25+
</mat-sidenav-container>

src/app/app.component.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { Component } from "@angular/core";
22

33
@Component({
4-
selector: "ngrx-root",
5-
template: `
6-
<h1>NgRx Workshop Example</h1>
7-
<router-outlet></router-outlet>
8-
`,
9-
styles: []
4+
selector: "app-root",
5+
templateUrl: './app.component.html',
6+
styleUrls: ['./app.component.css']
107
})
11-
export class AppComponent {}
8+
export class AppComponent {
9+
title = 'NgRx Workshop';
10+
links = [
11+
{ path: '/movies', icon: 'movie', label: 'Movies'},
12+
{ path: '/books', icon: 'book', label: 'Books'}
13+
];
14+
}

src/app/app.module.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
11
import { BrowserModule } from "@angular/platform-browser";
2+
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
23
import { NgModule } from "@angular/core";
4+
import { RouterModule } from '@angular/router';
5+
import { HttpClientModule } from '@angular/common/http';
36

4-
import { AppRoutingModule } from "./app-routing.module";
5-
import { AppComponent } from "./app.component";
67
import { StoreModule } from "@ngrx/store";
7-
import { reducers, metaReducers } from "./shared/state";
8+
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
89
import { EffectsModule } from "@ngrx/effects";
10+
11+
import { MaterialModule } from './material.module';
912
import { MoviesModule } from "./movies/movies.module";
1013

14+
import { AppComponent } from "./app.component";
15+
16+
import { reducers, metaReducers } from "./shared/state";
17+
import { BooksModule } from './books/books.module';
18+
1119
@NgModule({
1220
declarations: [AppComponent],
1321
imports: [
1422
BrowserModule,
15-
AppRoutingModule,
23+
BrowserAnimationsModule,
24+
HttpClientModule,
25+
RouterModule.forRoot([
26+
{ path: '', pathMatch: 'full', redirectTo: '/movies' }
27+
]),
1628
StoreModule.forRoot(reducers, { metaReducers }),
29+
StoreDevtoolsModule.instrument(),
1730
EffectsModule.forRoot([]),
18-
MoviesModule
31+
MaterialModule,
32+
MoviesModule,
33+
BooksModule
1934
],
20-
providers: [],
2135
bootstrap: [AppComponent]
2236
})
2337
export class AppModule {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { Book } from "src/app/shared/models/book.model";
2+
import { Action } from "@ngrx/store";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { Book } from "src/app/shared/models/book.model";
2+
import { Action } from "@ngrx/store";

src/app/books/actions/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as BooksPageActions from './books-page.actions';
2+
import * as BooksApiActions from './books-api.actions';
3+
4+
export { BooksPageActions, BooksApiActions };

0 commit comments

Comments
 (0)