-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce network/memory load by not pre-fetching programs (#57)
* lazy load programs * Do not preload programs * Re-implementation of adding a program as fav from program details * ProgramFavoritesComponent * Program favorites * test * test * Bugfix title on audioplayer
- Loading branch information
1 parent
8a8a446
commit 42d8d7b
Showing
18 changed files
with
308 additions
and
160 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
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
52 changes: 52 additions & 0 deletions
52
src/app/components/programs/program-favorites.component.html
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,52 @@ | ||
<p-accordion> | ||
<p-accordionTab header="{{ 'Favorites' | translate }}"> | ||
<p-table #dt2 [value]="programs" responsiveLayout="stack" [lazy]="false" | ||
[globalFilterFields]="['name','channel.name','description']" styleClass="sr-table"> | ||
<ng-template pTemplate="header"> | ||
<tr> | ||
<th pSortableColumn="name">{{'ProgramNameTitle' | translate | uppercase }}<p-sortIcon field="name"> | ||
</p-sortIcon> | ||
</th> | ||
<th pSortableColumn="channel.name">{{'ChannelNameTitle' | translate | uppercase }}<p-sortIcon | ||
field="channel.name"> | ||
</p-sortIcon> | ||
</th> | ||
|
||
<th>{{'Description' | translate | uppercase}}</th> | ||
</tr> | ||
</ng-template> | ||
<ng-template pTemplate="body" let-program> | ||
<tr> | ||
<td> | ||
<div class="p-grid" style="width:100%"> | ||
<span (click)="onProgramDetails(program)" class="clickable p-col-8"> | ||
<img src={{program.programimage}} height="50" width="50" | ||
style="padding: 4px; vertical-align:middle" /> | ||
<span *ngIf="program?.channel" class="prg-chan"> | ||
{{program.channel.name}} | ||
</span> | ||
<span class="prg-title"> | ||
{{program.name}} | ||
</span> | ||
</span> | ||
<span class="p-col-4" style="float:right;padding-top:0px"> | ||
<span class="clickable" (click)="onProgramDetails(program)"><i | ||
class="pi pi-info-circle details-btn"></i> | ||
</span> | ||
</span> | ||
</div> | ||
</td> | ||
<td class="prg-chan-td"> | ||
<div *ngIf="program?.channel"> | ||
{{program.channel.name}} | ||
</div> | ||
</td> | ||
<td class="description-td" style="border:none"> | ||
{{program.description}} | ||
</td> | ||
</tr> | ||
</ng-template> | ||
</p-table> | ||
|
||
</p-accordionTab> | ||
</p-accordion> |
11 changes: 11 additions & 0 deletions
11
src/app/components/programs/program-favorites.component.scss
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,11 @@ | ||
.category { | ||
margin-top: 10px; | ||
} | ||
:host ::ng-deep { | ||
.p-datatable .p-datatable-header { | ||
display: none; | ||
} | ||
.ep-desc { | ||
display: none !important; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/app/components/programs/program-favorites.component.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,47 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Subject } from 'rxjs'; | ||
import { filter, takeUntil } from 'rxjs/operators'; | ||
import { FavoriteChangedMessage } from 'src/app/messages/favorite-changed.message'; | ||
import { ShowProgramDetailsMessage } from 'src/app/messages/show-programdetails.message'; | ||
import { Program } from 'src/app/models/program'; | ||
import { MessageBrokerService } from 'src/app/services/message-broker.service'; | ||
import { ProgramsService } from 'src/app/services/programs.service'; | ||
|
||
@Component({ | ||
selector: 'app-program-favorites', | ||
templateUrl: './program-favorites.component.html', | ||
styleUrls: ['./program-favorites.component.scss'] | ||
}) | ||
export class ProgramFavoritesComponent implements OnInit { | ||
programs: Program[]; | ||
totalHits = 0; | ||
pageSize = 100; | ||
private unsubscribe$ = new Subject(); | ||
|
||
constructor( | ||
private readonly service: ProgramsService, | ||
private readonly broker: MessageBrokerService | ||
) {} | ||
|
||
ngOnInit(): void { | ||
const messages = this.broker.getMessage(); | ||
messages | ||
.pipe( | ||
takeUntil(this.unsubscribe$), | ||
filter((message) => message instanceof FavoriteChangedMessage) | ||
) | ||
.subscribe((message: FavoriteChangedMessage) => { | ||
this.fetch(); | ||
}); | ||
|
||
this.fetch(); | ||
} | ||
|
||
async fetch() { | ||
this.programs = await this.service.fetchAllFavoritePrograms(); | ||
} | ||
|
||
onProgramDetails(program: Program) { | ||
this.broker.sendMessage(new ShowProgramDetailsMessage(program.id)); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Message } from './message'; | ||
|
||
export class FavoriteChangedMessage extends Message { | ||
programId: number; | ||
isFavorite: boolean; | ||
constructor(programId: number, isFavorite: boolean) { | ||
super(); | ||
this.programId = programId; | ||
this.isFavorite = isFavorite; | ||
} | ||
|
||
get Type(): string { | ||
return 'FavoriteChangedMessage'; | ||
} | ||
} |
Oops, something went wrong.