People page finished.

This commit is contained in:
Zoe Roux 2019-10-22 16:44:07 +02:00
parent f3d207cb4e
commit 729a58ad2f
7 changed files with 20 additions and 13 deletions

View File

@ -1,7 +1,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-md-4 col-lg-3 col-xl-2 collection-info"> <div class="col-md-4 col-lg-3 col-xl-2 collection-info">
<img src="poster/{{collection.slug}}" /> <div [style.background-image]="getThumb()"></div>
</div> </div>
<div class="col-md-8 col-lg-9 col-xl-10"> <div class="col-md-8 col-lg-9 col-xl-10">
<h3 class="text-center text-md-left p-2 p-md-3">{{collection.name}}</h3> <h3 class="text-center text-md-left p-2 p-md-3">{{collection.name}}</h3>

View File

@ -2,7 +2,7 @@
{ {
width: 60%; width: 60%;
> img > div
{ {
width: 100%; width: 100%;
height: 0; height: 0;

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Collection } from "../../models/collection"; import { Collection } from "../../models/collection";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { DomSanitizer } from "@angular/platform-browser";
@Component({ @Component({
selector: 'app-collection', selector: 'app-collection',
@ -11,11 +12,15 @@ export class CollectionComponent implements OnInit
{ {
collection: Collection; collection: Collection;
constructor(private route: ActivatedRoute) { } constructor(private route: ActivatedRoute, private sanitizer: DomSanitizer) { }
ngOnInit() ngOnInit()
{ {
this.collection = this.route.snapshot.data.collection; this.collection = this.route.snapshot.data.collection;
} }
getThumb()
{
return this.sanitizer.bypassSecurityTrustStyle("url(" + this.collection.poster + ")");
}
} }

View File

@ -4,6 +4,7 @@ export interface Collection
{ {
slug: string; slug: string;
name: string; name: string;
poster: string;
overview: string; overview: string;
startYear: number, startYear: number,
endYear: number, endYear: number,

View File

@ -16,19 +16,17 @@ namespace Kyoo.Controllers
this.libraryManager = libraryManager; this.libraryManager = libraryManager;
} }
[HttpGet("{people-slug}")] [HttpGet("{peopleSlug}")]
public ActionResult<Collection> GetPeople(string slug) public ActionResult<Collection> GetPeople(string peopleSlug)
{ {
People people = libraryManager.GetPeopleBySlug(slug); People people = libraryManager.GetPeopleBySlug(peopleSlug);
//This always return not found
if (people == null) if (people == null)
return NotFound(); return NotFound();
Debug.WriteLine("&People: " + people.Name);
Collection collection = new Collection(0, people.slug, people.Name, null, null) Collection collection = new Collection(0, people.slug, people.Name, null, null)
{ {
Shows = libraryManager.GetShowsByPeople(people.id) Shows = libraryManager.GetShowsByPeople(people.id),
Poster = "peopleimg/" + people.slug
}; };
return collection; return collection;
} }

View File

@ -601,7 +601,7 @@ namespace Kyoo.InternalAPI
public IEnumerable<Show> GetShowsInCollection(long collectionID) public IEnumerable<Show> GetShowsInCollection(long collectionID)
{ {
string query = "SELECT * FROM shows JOIN collectionsLinks l ON l.showID = shows.id WHERE l.collectionID = $id;"; string query = "SELECT * FROM shows JOIN collectionsLinks l ON l.showID = shows.id WHERE l.collectionID = $id ORDER BY title;";
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection)) using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
{ {
@ -633,7 +633,7 @@ namespace Kyoo.InternalAPI
public IEnumerable<Show> GetShowsByPeople(long peopleID) public IEnumerable<Show> GetShowsByPeople(long peopleID)
{ {
string query = "SELECT * FROM shows JOIN peopleLinks l ON l.showID = shows.id WHERE l.peopleID = $id;"; string query = "SELECT * FROM shows JOIN peopleLinks l ON l.showID = shows.id WHERE l.peopleID = $id ORDER BY title;";
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection)) using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
{ {

View File

@ -9,6 +9,7 @@ namespace Kyoo.Models
[JsonIgnore] public long id; [JsonIgnore] public long id;
public string Slug; public string Slug;
public string Name; public string Name;
public string Poster;
public string Overview; public string Overview;
[JsonIgnore] public string ImgPrimary; [JsonIgnore] public string ImgPrimary;
public IEnumerable<Show> Shows; public IEnumerable<Show> Shows;
@ -26,11 +27,13 @@ namespace Kyoo.Models
public static Collection FromReader(System.Data.SQLite.SQLiteDataReader reader) public static Collection FromReader(System.Data.SQLite.SQLiteDataReader reader)
{ {
return new Collection((long)reader["id"], Collection col = new Collection((long)reader["id"],
reader["slug"] as string, reader["slug"] as string,
reader["name"] as string, reader["name"] as string,
reader["overview"] as string, reader["overview"] as string,
reader["imgPrimary"] as string); reader["imgPrimary"] as string);
col.Poster = "poster/" + col.Slug;
return col;
} }
public Show AsShow() public Show AsShow()