This repository has been archived by the owner on Jul 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ChapterComponent): add page for chapters
- Loading branch information
1 parent
a5cad0c
commit 7e53e4e
Showing
20 changed files
with
280 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { ChapterGuard } from '@guards/chapter.guard'; | ||
|
||
import { ChapterComponent } from './chapter.component'; | ||
|
||
const routes: Routes = [ | ||
{ path: ':key', component: ChapterComponent, canActivate: [ChapterGuard] }, | ||
{ path: '', redirectTo: '/' } | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule] | ||
}) | ||
export class ChapterRoutingModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<section class="banner" [style.background-image]="(about?.key_photo?.highres_link) | bannerImage"></section> | ||
|
||
<section class="over-banner"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<mat-card> | ||
<mat-card-title>{{ about?.name || 'GDG' }}</mat-card-title> | ||
<mat-card-subtitle>{{ about?.localized_location }}</mat-card-subtitle> | ||
<mat-card-content> | ||
<div [innerHTML]="about?.description"></div> | ||
</mat-card-content> | ||
<mat-card-actions> | ||
<a mat-button target="_blank" [href]="about?.link || 'https://www.meetup.com/pro/gdg'">JOIN MEETUP</a> | ||
</mat-card-actions> | ||
</mat-card> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<mat-card> | ||
<mat-card-title>Events</mat-card-title> | ||
<mat-card-content> | ||
<mat-list> | ||
<div *ngFor="let event of events; last as last"> | ||
<a mat-list-item target="_blank" [href]="event.link"> | ||
<img matListAvatar src="./assets/gdg-logo.jpg" alt="GDG Logo"> | ||
<h3 matLine>{{event.name}}</h3> | ||
<p matLine>{{event.time | date}}</p> | ||
</a> | ||
<mat-divider *ngIf="!last"></mat-divider> | ||
</div> | ||
<div *ngIf="!events || events.length === 0"> | ||
<mat-list-item> | ||
<img matListAvatar src="./assets/gdg-logo.jpg" alt="GDG Logo"> | ||
<h3 matLine>No upcoming events</h3> | ||
</mat-list-item> | ||
</div> | ||
</mat-list> | ||
</mat-card-content> | ||
</mat-card> | ||
</div> | ||
</div> | ||
</div> | ||
</section> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ChapterComponent } from './chapter.component'; | ||
|
||
describe('ChapterComponent', () => { | ||
let component: ChapterComponent; | ||
let fixture: ComponentFixture<ChapterComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ChapterComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ChapterComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { Subscription } from 'rxjs'; | ||
|
||
import { ChaptersService } from '@services/chapters.service'; | ||
|
||
@Component({ | ||
selector: 'gdg-chapter', | ||
templateUrl: './chapter.component.html', | ||
styleUrls: ['./chapter.component.scss'] | ||
}) | ||
export class ChapterComponent implements OnInit, OnDestroy { | ||
private _about: any; | ||
private _events: any; | ||
private _keySubscription: Subscription; | ||
|
||
constructor(private _cs: ChaptersService, private _route: ActivatedRoute) { } | ||
|
||
ngOnInit() { | ||
this._keySubscription = this._route.params.subscribe((params: any) => { | ||
this._cs.about(params.key).subscribe((about) => this._about = about); | ||
this._cs.events(params.key).subscribe((events) => this._events = events); | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
this._keySubscription.unsubscribe(); | ||
} | ||
|
||
get about(): any { | ||
return this._about; | ||
} | ||
|
||
get events(): any { | ||
return this._events; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
import { MatListModule } from '@angular/material/list'; | ||
|
||
import { SharedModule } from '@shared'; | ||
|
||
import { ChapterRoutingModule } from './chapter-routing.module'; | ||
import { ChapterComponent } from './chapter.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
ChapterComponent | ||
], | ||
imports: [ | ||
CommonModule, | ||
ChapterRoutingModule, | ||
SharedModule, | ||
MatButtonModule, | ||
MatCardModule, | ||
MatListModule | ||
] | ||
}) | ||
export class ChapterModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { TestBed, async, inject } from '@angular/core/testing'; | ||
|
||
import { ChapterGuard } from './chapter.guard'; | ||
|
||
describe('ChapterGuard', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [ChapterGuard] | ||
}); | ||
}); | ||
|
||
it('should ...', inject([ChapterGuard], (guard: ChapterGuard) => { | ||
expect(guard).toBeTruthy(); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { CanActivate, CanActivateChild, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router'; | ||
import { Observable, of } from 'rxjs'; | ||
import { map, catchError } from 'rxjs/operators'; | ||
|
||
import { ChaptersService } from '@services/chapters.service'; | ||
import { ToastService } from '@services/toast.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ChapterGuard implements CanActivate, CanActivateChild { | ||
constructor(private _cs: ChaptersService, private _router: Router, private _toast: ToastService) { } | ||
|
||
canActivate(next: ActivatedRouteSnapshot): Observable<boolean> { | ||
return this._cs.findOne(next.params.key).pipe( | ||
map((chapter) => { | ||
if (!chapter) { throw Error(); } | ||
return true; | ||
}), | ||
catchError(() => { | ||
this._toast.make('Chapter not found'); | ||
this._router.navigate(['/']); | ||
return of(false); | ||
}) | ||
); | ||
} | ||
|
||
canActivateChild(next: ActivatedRouteSnapshot): Observable<boolean> { | ||
return this.canActivate(next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +0,0 @@ | ||
agm-map { | ||
height: 500px; | ||
width: 100%; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<section> | ||
<section class="over-banner"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-12"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { BannerImagePipe } from './banner-image.pipe'; | ||
|
||
describe('BannerImagePipe', () => { | ||
it('create an instance', () => { | ||
const pipe = new BannerImagePipe(); | ||
expect(pipe).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DomSanitizer, SafeStyle } from '@angular/platform-browser'; | ||
|
||
@Pipe({ | ||
name: 'bannerImage' | ||
}) | ||
export class BannerImagePipe implements PipeTransform { | ||
constructor(private _sanitizer: DomSanitizer) { } | ||
|
||
transform(url: string): SafeStyle { | ||
return url ? this._sanitizer.bypassSecurityTrustStyle('url(' + url + ')') : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { BannerImagePipe } from './pipes/banner-image.pipe'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
BannerImagePipe | ||
], | ||
exports: [ | ||
BannerImagePipe | ||
], | ||
imports: [ | ||
CommonModule | ||
] | ||
}) | ||
export class SharedModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters