mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-07 10:14:13 -04:00
The people list now uses the new api
This commit is contained in:
parent
8a1de18da4
commit
6aa44360bc
@ -1,6 +1,6 @@
|
|||||||
<div class="scroll-row mb-5">
|
<div class="scroll-row mb-5">
|
||||||
<div class="people-container" #scrollView (scroll)="onScroll()">
|
<div class="people-container" #scrollView (scroll)="onScroll()" infinite-scroll (scrolled)="this.people?.loadNext(this.client)" [horizontal]="true" [scrollWindow]="false">
|
||||||
<a class="people" *ngFor="let people of this.people" routerLink="/people/{{people.slug}}" href="/people/{{people.slug}}">
|
<a class="people" *ngFor="let people of this.people?.items" routerLink="/people/{{people.slug}}" href="/people/{{people.slug}}" #itemsDom>
|
||||||
<div matRipple [style.background-image]="getPeopleIcon(people.slug)"> </div>
|
<div matRipple [style.background-image]="getPeopleIcon(people.slug)"> </div>
|
||||||
<h6 class="name">{{people.name}}</h6>
|
<h6 class="name">{{people.name}}</h6>
|
||||||
<p class="role">{{people.role}}</p>
|
<p class="role">{{people.role}}</p>
|
||||||
|
@ -2,43 +2,22 @@ import { Component, ElementRef, Input, ViewChild } from '@angular/core';
|
|||||||
import { MatButton } from "@angular/material/button";
|
import { MatButton } from "@angular/material/button";
|
||||||
import { DomSanitizer } from "@angular/platform-browser";
|
import { DomSanitizer } from "@angular/platform-browser";
|
||||||
import { People } from "../../../models/people";
|
import { People } from "../../../models/people";
|
||||||
|
import {HorizontalScroller} from "../../misc/horizontal-scroller";
|
||||||
|
import {Page} from "../../../models/page";
|
||||||
|
import {HttpClient} from "@angular/common/http";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-people-list',
|
selector: 'app-people-list',
|
||||||
templateUrl: './people-list.component.html',
|
templateUrl: './people-list.component.html',
|
||||||
styleUrls: ['./people-list.component.scss']
|
styleUrls: ['./people-list.component.scss']
|
||||||
})
|
})
|
||||||
export class PeopleListComponent
|
export class PeopleListComponent extends HorizontalScroller
|
||||||
{
|
{
|
||||||
@Input() people: People[];
|
@Input() people: Page<People>;
|
||||||
@ViewChild("scrollView", { static: true }) private scrollView: ElementRef;
|
|
||||||
@ViewChild("leftBtn", { static: false }) private leftBtn: MatButton;
|
|
||||||
@ViewChild("rightBtn", { static: false }) private rightBtn: MatButton;
|
|
||||||
|
|
||||||
constructor(private sanitizer: DomSanitizer) { }
|
constructor(private sanitizer: DomSanitizer, public client: HttpClient)
|
||||||
|
|
||||||
scrollLeft()
|
|
||||||
{
|
{
|
||||||
let scroll: number = this.scrollView.nativeElement.offsetWidth * 0.80;
|
super();
|
||||||
this.scrollView.nativeElement.scrollBy({ top: 0, left: -scroll, behavior: "smooth" });
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollRight()
|
|
||||||
{
|
|
||||||
let scroll: number = this.scrollView.nativeElement.offsetWidth * 0.80;
|
|
||||||
this.scrollView.nativeElement.scrollBy({ top: 0, left: scroll, behavior: "smooth" });
|
|
||||||
}
|
|
||||||
|
|
||||||
onScroll()
|
|
||||||
{
|
|
||||||
if (this.scrollView.nativeElement.scrollLeft <= 0)
|
|
||||||
this.leftBtn._elementRef.nativeElement.classList.add("d-none");
|
|
||||||
else
|
|
||||||
this.leftBtn._elementRef.nativeElement.classList.remove("d-none");
|
|
||||||
if (this.scrollView.nativeElement.scrollLeft >= this.scrollView.nativeElement.scrollWidth - this.scrollView.nativeElement.clientWidth)
|
|
||||||
this.rightBtn._elementRef.nativeElement.classList.add("d-none");
|
|
||||||
else
|
|
||||||
this.rightBtn._elementRef.nativeElement.classList.remove("d-none");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPeopleIcon(slug: string)
|
getPeopleIcon(slug: string)
|
||||||
|
@ -89,4 +89,4 @@
|
|||||||
<div class="container-fluid mt-5">
|
<div class="container-fluid mt-5">
|
||||||
<h3>Staff</h3>
|
<h3>Staff</h3>
|
||||||
</div>
|
</div>
|
||||||
<app-people-list [people]="show.people"></app-people-list>
|
<app-people-list [people]="people"></app-people-list>
|
||||||
|
@ -8,8 +8,9 @@ import {MatDialog} from "@angular/material/dialog";
|
|||||||
import {TrailerDialogComponent} from "../trailer-dialog/trailer-dialog.component";
|
import {TrailerDialogComponent} from "../trailer-dialog/trailer-dialog.component";
|
||||||
import {MetadataEditComponent} from "../metadata-edit/metadata-edit.component";
|
import {MetadataEditComponent} from "../metadata-edit/metadata-edit.component";
|
||||||
import {Season} from "../../../models/season";
|
import {Season} from "../../../models/season";
|
||||||
import {EpisodeService, SeasonService} from "../../services/api.service";
|
import {EpisodeService, PeopleService, SeasonService} from "../../services/api.service";
|
||||||
import {Page} from "../../../models/page";
|
import {Page} from "../../../models/page";
|
||||||
|
import {People} from "../../../models/people";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-show-details',
|
selector: 'app-show-details',
|
||||||
@ -22,6 +23,7 @@ export class ShowDetailsComponent implements OnInit
|
|||||||
seasons: Season[];
|
seasons: Season[];
|
||||||
season: number = 1;
|
season: number = 1;
|
||||||
episodes: Page<Episode>[] = [];
|
episodes: Page<Episode>[] = [];
|
||||||
|
people: Page<People>;
|
||||||
|
|
||||||
private toolbar: HTMLElement;
|
private toolbar: HTMLElement;
|
||||||
private backdrop: HTMLElement;
|
private backdrop: HTMLElement;
|
||||||
@ -32,7 +34,8 @@ export class ShowDetailsComponent implements OnInit
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private seasonService: SeasonService,
|
private seasonService: SeasonService,
|
||||||
private episodeService: EpisodeService)
|
private episodeService: EpisodeService,
|
||||||
|
private peopleService: PeopleService)
|
||||||
{
|
{
|
||||||
this.route.queryParams.subscribe(params =>
|
this.route.queryParams.subscribe(params =>
|
||||||
{
|
{
|
||||||
@ -57,6 +60,7 @@ export class ShowDetailsComponent implements OnInit
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.getEpisodes(this.season);
|
this.getEpisodes(this.season);
|
||||||
|
this.peopleService.getFromShow(this.show.slug).subscribe(x => this.people = x);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import {LibraryItem} from "../../models/library-item";
|
|||||||
import {map} from "rxjs/operators";
|
import {map} from "rxjs/operators";
|
||||||
import {Season} from "../../models/season";
|
import {Season} from "../../models/season";
|
||||||
import {Episode} from "../../models/episode";
|
import {Episode} from "../../models/episode";
|
||||||
|
import {People} from "../../models/people";
|
||||||
|
|
||||||
export interface ApiArgs
|
export interface ApiArgs
|
||||||
{
|
{
|
||||||
@ -118,3 +119,20 @@ export class EpisodeService extends CrudApi<Episode>
|
|||||||
.pipe(map(x => Object.assign(new Page<Episode>(), x)));
|
.pipe(map(x => Object.assign(new Page<Episode>(), x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class PeopleService extends CrudApi<People>
|
||||||
|
{
|
||||||
|
constructor(client: HttpClient)
|
||||||
|
{
|
||||||
|
super(client, "people");
|
||||||
|
}
|
||||||
|
|
||||||
|
getFromShow(show: string | number, args?: ApiArgs): Observable<Page<People>>
|
||||||
|
{
|
||||||
|
return this.client.get(`/api/shows/${show}/people${this.ArgsAsQuery(args)}`)
|
||||||
|
.pipe(map(x => Object.assign(new Page<People>(), x)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {ExternalID} from "./external-id";
|
import {ExternalID} from "./external-id";
|
||||||
|
import {IResource} from "./resources/resource";
|
||||||
|
|
||||||
export interface People
|
export interface People extends IResource
|
||||||
{
|
{
|
||||||
slug: string;
|
|
||||||
name: string;
|
name: string;
|
||||||
role: string;
|
role: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user