-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add list and play episode page
- Loading branch information
Showing
21 changed files
with
381 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
17 changes: 17 additions & 0 deletions
17
src/app/pages/sagas/list-episodes/list-episodes-routing.module.ts
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 { ListSeasonsPage } from './list-episodes.page'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: ListSeasonsPage | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class ListSeasonsPageRoutingModule {} |
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,20 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { ListSeasonsPageRoutingModule } from './list-episodes-routing.module'; | ||
|
||
import { ListSeasonsPage } from './list-episodes.page'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
IonicModule, | ||
ListSeasonsPageRoutingModule | ||
], | ||
declarations: [ListSeasonsPage] | ||
}) | ||
export class ListSeasonsPageModule {} |
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,36 @@ | ||
<ion-header [translucent]="true"> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"> | ||
<ion-menu-button></ion-menu-button> | ||
<ion-back-button></ion-back-button> | ||
</ion-buttons> | ||
<ion-title>{{ item.title }}</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content> | ||
<ion-list> | ||
<div *ngFor="let season of item.seasons"> | ||
<ion-list-header color="primary"> | ||
<ion-label>Saison {{ season.number }} {{ season.name }}</ion-label> | ||
</ion-list-header> | ||
<ion-item *ngFor="let episode of season.episodes" lines="none" routerLink="/sagas/{{ item.id }}/episode/{{ episode.id }}" routerDirection="forward"> | ||
<ion-label> | ||
<ion-icon name="play-outline"></ion-icon> Episode 1 | ||
</ion-label> | ||
</ion-item> | ||
</div> | ||
</ion-list> | ||
<ion-fab vertical="bottom" horizontal="end" slot="fixed" *ngIf="authService.currentTokenValue"> | ||
<ion-fab-button><ion-icon name="pencil-outline"></ion-icon></ion-fab-button> | ||
<ion-fab-list side="top"> | ||
<ion-fab-button (click)="create()" > | ||
<ion-icon name="add"></ion-icon> | ||
</ion-fab-button> | ||
<ion-fab-button> | ||
<ion-icon name="pencil-outline"></ion-icon> | ||
</ion-fab-button> | ||
</ion-fab-list> | ||
</ion-fab> | ||
|
||
</ion-content> |
Empty file.
24 changes: 24 additions & 0 deletions
24
src/app/pages/sagas/list-episodes/list-episodes.page.spec.ts
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,24 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { ListSeasonsPage } from './list-episodes.page'; | ||
|
||
describe('ListSeasonsPage', () => { | ||
let component: ListSeasonsPage; | ||
let fixture: ComponentFixture<ListSeasonsPage>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ListSeasonsPage ], | ||
imports: [IonicModule.forRoot()] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ListSeasonsPage); | ||
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,72 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { LoadingController } from '@ionic/angular'; | ||
import { Episode } from 'src/app/entities/episode'; | ||
import { Saga } from 'src/app/entities/saga'; | ||
import { Season } from 'src/app/entities/season'; | ||
import { SeasonModel } from 'src/app/models/season.model'; | ||
import { AuthService } from 'src/app/services/auth/auth.service'; | ||
import { ConfigService } from 'src/app/services/config/config.service'; | ||
import { EpisodesService } from 'src/app/services/episodes/episodes.service'; | ||
import { SagaService } from 'src/app/services/sagas/saga.service'; | ||
import { SeasonService } from 'src/app/services/seasons/season.service'; | ||
|
||
@Component({ | ||
selector: 'app-list-episodes', | ||
templateUrl: './list-episodes.page.html', | ||
styleUrls: ['./list-episodes.page.scss'], | ||
}) | ||
export class ListSeasonsPage implements OnInit { | ||
|
||
public item: Saga = new Saga(); | ||
|
||
constructor( | ||
private activatedRoute: ActivatedRoute, | ||
public loadingController: LoadingController, | ||
private authService: AuthService, | ||
public configService: ConfigService, | ||
private episodeService: EpisodesService, | ||
private sagaService: SagaService, | ||
private seasonService: SeasonService) { } | ||
|
||
|
||
ngOnInit() { | ||
var itemId: number = +this.activatedRoute.snapshot.paramMap.get('id'); | ||
this.loadingController.create({ | ||
message: 'Téléchargement...' | ||
}).then((loading) => { | ||
loading.present(); | ||
this.sagaService.getById(itemId) | ||
.subscribe(data => { | ||
this.item = Saga.fromModel(data); | ||
this.seasonService.getAllByIds(data.seasonsRef) | ||
.subscribe(data => { | ||
this.item.seasons = Season.fromModels(data); | ||
let episodeIds = []; | ||
this.item.seasons.forEach(season => { | ||
episodeIds.push(season.episodesRef); | ||
}); | ||
this.episodeService.getAllByIds(episodeIds) | ||
.subscribe(data => { | ||
const episodes = Episode.fromModels(data); | ||
episodes.forEach(episode => { | ||
this.item.seasons.find(season => season.id === episode.seasonRef).episodes.push(episode); | ||
}) | ||
loading.dismiss(); | ||
}) | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
create() { | ||
const season = new SeasonModel(); | ||
season.sagaRef = this.item.id; | ||
season.number = this.item.seasons.length + 1; | ||
this.seasonService.create(season) | ||
.subscribe(() => { | ||
this.ngOnInit(); | ||
}) | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/app/pages/sagas/play-episode/play-episode-routing.module.ts
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 { PlayEpisodePage } from './play-episode.page'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: PlayEpisodePage | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class PlayEpisodePageRoutingModule {} |
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,20 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { PlayEpisodePageRoutingModule } from './play-episode-routing.module'; | ||
|
||
import { PlayEpisodePage } from './play-episode.page'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
IonicModule, | ||
PlayEpisodePageRoutingModule | ||
], | ||
declarations: [PlayEpisodePage] | ||
}) | ||
export class PlayEpisodePageModule {} |
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,21 @@ | ||
<ion-header [translucent]="true"> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"> | ||
<ion-menu-button></ion-menu-button> | ||
<ion-back-button></ion-back-button> | ||
</ion-buttons> | ||
<ion-title>{{ saga.title }}</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content> | ||
<ion-card> | ||
<ion-img class="cover" [src]="coverUrl()"></ion-img> | ||
<ion-card-header class="ion-text-center"> | ||
<ion-card-title>{{ episode.title }}</ion-card-title> | ||
<ion-card-subtitle>#{{ episode.number }}</ion-card-subtitle> | ||
</ion-card-header> | ||
|
||
</ion-card> | ||
|
||
</ion-content> |
Empty file.
24 changes: 24 additions & 0 deletions
24
src/app/pages/sagas/play-episode/play-episode.page.spec.ts
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,24 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { PlayEpisodePage } from './play-episode.page'; | ||
|
||
describe('PlayEpisodePage', () => { | ||
let component: PlayEpisodePage; | ||
let fixture: ComponentFixture<PlayEpisodePage>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ PlayEpisodePage ], | ||
imports: [IonicModule.forRoot()] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PlayEpisodePage); | ||
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,56 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { LoadingController } from '@ionic/angular'; | ||
import { Episode } from 'src/app/entities/episode'; | ||
import { Saga } from 'src/app/entities/saga'; | ||
import { AuthService } from 'src/app/services/auth/auth.service'; | ||
import { ConfigService } from 'src/app/services/config/config.service'; | ||
import { EpisodesService } from 'src/app/services/episodes/episodes.service'; | ||
import { SagaService } from 'src/app/services/sagas/saga.service'; | ||
|
||
@Component({ | ||
selector: 'app-play-episode', | ||
templateUrl: './play-episode.page.html', | ||
styleUrls: ['./play-episode.page.scss'], | ||
}) | ||
export class PlayEpisodePage implements OnInit { | ||
|
||
public saga: Saga = new Saga(); | ||
public episode: Episode = new Episode(); | ||
|
||
constructor( | ||
private activatedRoute: ActivatedRoute, | ||
public loadingController: LoadingController, | ||
private authService: AuthService, | ||
public configService: ConfigService, | ||
private sagaService: SagaService, | ||
private episodeService: EpisodesService) { } | ||
|
||
|
||
ngOnInit() { | ||
var sagaId: number = +this.activatedRoute.snapshot.paramMap.get('saga'); | ||
var episodeId: number = +this.activatedRoute.snapshot.paramMap.get('episode'); | ||
this.loadingController.create({ | ||
message: 'Téléchargement...' | ||
}).then((loading) => { | ||
loading.present(); | ||
this.sagaService.getById(sagaId) | ||
.subscribe(data => { | ||
this.saga = Saga.fromModel(data); | ||
this.episodeService.getById(episodeId) | ||
.subscribe(data => { | ||
this.episode = Episode.fromModel(data); | ||
loading.dismiss(); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
coverUrl(): string { | ||
if(this.saga.coverUrl) { | ||
return this.configService.get('appUrl') + this.saga.coverUrl; | ||
} else { | ||
return ''; | ||
} | ||
} | ||
} |
Oops, something went wrong.