Skip to content

Commit b4028e1

Browse files
committed
add person component, more episode rendering
1 parent 35fb0d1 commit b4028e1

14 files changed

+133
-59
lines changed

src/app/app.component.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,21 @@
1515
<section id="title" class="center">
1616
<h1>AngularAir</h1>
1717
<h2>
18-
A <strong>live</strong> video podcast all about Angular
18+
A <strong>live</strong> weekly video podcast covering the Angular JavaScript platform.
1919
</h2>
2020
<p>
2121
Brought to you with support from <a href="http://angularclass.com">AngularClass</a>
2222
</p>
2323
</section>
24+
<section>
25+
<h2>Host</h2>
26+
<app-person-card *ngFor="let person of (model | async)?.hosts" [person]="person"></app-person-card>
27+
</section>
28+
<section>
29+
<h2>Panelists</h2>
30+
<p>AngularAir is fortunate to have a panel of awesome Angular developers from the community!</p>
31+
<app-person-card *ngFor="let person of (model | async)?.panelists" [person]="person"></app-person-card>
32+
</section>
2433
<hr />
2534
<section id="podcast-links" class="center">
2635
<app-subscribe-icon icon="apple" network="iTunes" link="https://itunes.apple.com/us/podcast/angular-air/id940806858?mt=2"></app-subscribe-icon>

src/app/app.component.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,39 @@ export class AppComponent {
1515

1616
constructor(store: Store<AppState>, dateService: DateService) {
1717
let featuredDateRange = dateService.getWeekStartAndEndDateTimeUtc();
18-
console.log(featuredDateRange);
1918
this.model = Observable.combineLatest(
20-
store.select((state: AppState) => {
21-
return state.episodes
22-
}),
23-
(episodes) => {
19+
store.select(state => state),
20+
({episodes, people, currentHostsIds, currentPanelistsIds}) => {
21+
let currentDateUtc = Date.now();
22+
let mapEpisode = (episode: Episode) => {
23+
return Object.assign(episode, {
24+
guests: episode.guestIds.map(id => people[id]),
25+
isFeatured: episode.dateTimeUtc > featuredDateRange.start && episode.dateTimeUtc < featuredDateRange.end,
26+
isUpcoming: episode.dateTimeUtc > featuredDateRange.end,
27+
isPast: episode.dateTimeUtc < featuredDateRange.start,
28+
published: episode.dateTimeUtc < currentDateUtc
29+
});
30+
};
2431
return {
32+
hosts: currentHostsIds.map(id => people[id]),
33+
panelists: currentPanelistsIds.map(id => people[id]),
2534
featuredEpisode: episodes
26-
.find((episode: Episode) => episode.dateTimeUtc > featuredDateRange.start && episode.dateTimeUtc < featuredDateRange.end),
35+
.map(mapEpisode)
36+
.find(episode => episode.isFeatured),
2737
upcomingEpisodes: episodes
28-
.filter((episode: Episode) => episode.dateTimeUtc > featuredDateRange.end)
38+
.map(mapEpisode)
39+
.filter(episode => episode.isUpcoming)
2940
.sort((episode1: Episode, episode2: Episode) => {
3041
return episode1.dateTimeUtc - episode2.dateTimeUtc;
31-
}),
42+
})
43+
.map(mapEpisode),
3244
pastEpisodes: episodes
33-
.filter((episode: Episode) => episode.dateTimeUtc < featuredDateRange.start)
45+
.map(mapEpisode)
46+
.filter(episode => episode.isPast)
3447
.sort((episode1: Episode, episode2: Episode) => {
3548
return episode2.dateTimeUtc - episode1.dateTimeUtc;
3649
})
50+
3751
}
3852
});
3953
}

src/app/app.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ import { LinkIconComponent } from './shared/link-icon/link-icon.component';
88
import { SubscribeIconComponent } from './shared/subscribe-icon/subscribe-icon.component';
99
import { DateService } from "./shared/date.service";
1010
import { StoreModule } from "@ngrx/store";
11-
import { rootReducer } from "./shared/state/root.reducer";
11+
import { rootReducer } from "./shared/state/reducers/root.reducer";
1212

1313
import appState from './data.json';
1414
import { EpisodeCardComponent } from './shared/episode-card/episode-card.component';
15+
import { PersonCardComponent } from './shared/person-card/person-card.component';
1516

1617
@NgModule({
1718
declarations: [
1819
AppComponent,
1920
LinkIconComponent,
2021
SubscribeIconComponent,
21-
EpisodeCardComponent
22+
EpisodeCardComponent,
23+
PersonCardComponent
2224
],
2325
imports: [
2426
BrowserModule,

src/app/data.json

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,85 @@
66
{
77
"id": 96,
88
"title": "Discovering Angular Content",
9-
"dateTimeUtc": 1484046000000,
10-
"url": "http://ngair.io/content-2017"
9+
"dateTimeUtc": 1484074800000,
10+
"url": "http://ngair.io/content-2017",
11+
"guestIds": []
1112
},
1213
{
1314
"id": 95,
1415
"title": "TIL #2",
15-
"dateTimeUtc": 1483441200000,
16-
"url": "http://ngair.io/til2-2017"
16+
"dateTimeUtc": 1483470000000,
17+
"url": "http://ngair.io/til2-2017",
18+
"guestIds": []
1719
},
1820
{
1921
"id": 94,
2022
"title": "Life On and Beyond the Angular Core Team",
21-
"dateTimeUtc": 1482836400000,
22-
"url": "http://ngair.io/nrwl-2016"
23+
"dateTimeUtc": 1482865200000,
24+
"url": "http://ngair.io/nrwl-2016",
25+
"guestIds": [10,11]
2326
},
2427
{
2528
"id": 93,
2629
"title": "Techniques for Testing",
27-
"dateTimeUtc": 1482231600000,
28-
"url": "http://ngair.io/testing-2016"
30+
"dateTimeUtc": 1482260400000,
31+
"url": "http://ngair.io/testing-2016",
32+
"guestIds": [12,13]
2933
}
3034
],
31-
"people": [
32-
{
33-
"id": 1,
34-
"fullName": "Kent C. Dodds",
35-
"twitterHandle": "kentcdodds"
35+
"people": {
36+
"13": {
37+
"fullName": "Adam Stephensen",
38+
"twitterHandle": "adamstephensen"
3639
},
37-
{
38-
"id": 2,
39-
"fullName": "Todd Motto",
40-
"twitterHandle": "toddmotto"
40+
"12": {
41+
"fullName": "Duncan Hunter",
42+
"twitterHandle": "dunchunter"
4143
},
42-
{
43-
"id": 3,
44-
"fullName": "Jeff Whelpley",
45-
"twitterHandle": "jeffwhelpley"
44+
"11": {
45+
"fullName": "Jeff Cross",
46+
"twitterHandle": "jeffbcross"
4647
},
47-
{
48-
"id": 4,
49-
"fullName": "Justin Schwartzenberger",
50-
"twitterHandle": "schwarty"
48+
"10": {
49+
"fullName": "Victor Savkin",
50+
"twitterHandle": "victorsavkin"
5151
},
52-
{
53-
"id": 5,
54-
"fullName": "Patrick Stapleton",
55-
"twitterHandle": "gdi2290"
52+
"9": {
53+
"fullName": "Alyssa Nicoll",
54+
"twitterHandle": "AlyssaNicoll"
5655
},
57-
{
58-
"id": 6,
59-
"fullName": "Olivier Combe",
60-
"twitterHandle": "ocombe"
56+
"8": {
57+
"fullName": "Austin McDaniel",
58+
"twitterHandle": "amcdnl"
6159
},
62-
{
63-
"id": 7,
60+
"7": {
6461
"fullName": "Mike Brocchi",
6562
"twitterHandle": "brocco"
6663
},
67-
{
68-
"id": 8,
69-
"fullName": "Austin McDaniel",
70-
"twitterHandle": "amcdnl"
64+
"6": {
65+
"fullName": "Olivier Combe",
66+
"twitterHandle": "ocombe"
7167
},
72-
{
73-
"id": 9,
74-
"fullName": "Alyssa Nicoll",
75-
"twitterHandle": "AlyssaNicoll"
68+
"5": {
69+
"fullName": "Patrick Stapleton",
70+
"twitterHandle": "gdi2290"
71+
},
72+
"4": {
73+
"fullName": "Justin Schwartzenberger",
74+
"twitterHandle": "schwarty"
75+
},
76+
"3": {
77+
"fullName": "Jeff Whelpley",
78+
"twitterHandle": "jeffwhelpley"
79+
},
80+
"2": {
81+
"fullName": "Todd Motto",
82+
"twitterHandle": "toddmotto"
83+
},
84+
"1": {
85+
"fullName": "Kent C. Dodds",
86+
"twitterHandle": "kentcdodds"
7687
}
77-
]
88+
}
7889
}
7990
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
<a href="{{episode.url}}">ngAir {{episode.id}} - {{episode.title}}</a>
2-
<div>{{episode.dateTimeUtc | date:'medium'}}</div>
2+
<div>
3+
{{episode.published ? 'Aired On' : 'Live on'}}:
4+
{{episode.dateTimeUtc | date:'fullDate'}} at {{episode.dateTimeUtc | date:'h:mm a (Z)'}}
5+
</div>
6+
<div *ngIf="episode.guests?.length > 0">
7+
Guests:
8+
<span *ngFor="let person of episode.guests">
9+
{{person.fullName}} <a href="https://twitter.com/{{person.twitterHandle}}">@{{person.twitterHandle}}</a>
10+
</span>
11+
</div>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{person.fullName}}
2+
<a href="https://twitter.com/{{person.twitterHandle}}">@{{person.twitterHandle}}</a>

src/app/shared/person-card/person-card.component.scss

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {Component, ChangeDetectionStrategy, Input} from '@angular/core';
2+
import {Person} from "../state/app-state";
3+
4+
@Component({
5+
selector: 'app-person-card',
6+
templateUrl: './person-card.component.html',
7+
styleUrls: ['./person-card.component.scss'],
8+
changeDetection: ChangeDetectionStrategy.OnPush
9+
})
10+
export class PersonCardComponent {
11+
@Input() person : Person;
12+
}

src/app/shared/state/app-state.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export interface Episode {
1616
}
1717

1818
export interface Person {
19-
id: number,
2019
fullName: string,
2120
twitterHandle: string
2221
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const currentHostsIdsReducer = (state, action) => {
2+
switch(action.type) {
3+
default:
4+
return state;
5+
}
6+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const currentPanelistsIdsReducer = (state, action) => {
2+
switch(action.type) {
3+
default:
4+
return state;
5+
}
6+
};

src/app/shared/state/root.reducer.ts renamed to src/app/shared/state/reducers/root.reducer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ import {compose} from "@ngrx/core";
22
import {combineReducers} from "@ngrx/store";
33
import {episodesReducer} from "./episodes.reducer";
44
import {peopleReducer} from "./people.reducer";
5+
import {currentHostsIdsReducer} from "./current-hosts-ids.reducer";
6+
import {currentPanelistsIdsReducer} from "./current-panelists-ids.reducer";
57

68
export const reducers = {
79
episodes: episodesReducer,
8-
people: peopleReducer
10+
people: peopleReducer,
11+
currentHostsIds: currentHostsIdsReducer,
12+
currentPanelistsIds: currentPanelistsIdsReducer
913
};
1014

1115
export function rootReducer(state, action) {

0 commit comments

Comments
 (0)