Add Season Page

This commit is contained in:
X4Lo committed 2025-02-18 17:54:45 +01:00
1 parent cc1d1cdadf
commit 387686ad0f
13 files changed
+622 -36

No files matched your search

+1 -2
View File
@@ -363,9 +363,8 @@ class EntryService {
where: { where: {
entry_id: id entry_id: id
}, },
attributes: ['id', 'season_number'],
include: [ include: [
{ model: Episode, as: 'episodes', attributes: ['id', 'episode_number'], } { model: Episode, as: 'episodes' }
], ],
order: [ order: [
['season_number', 'ASC'], ['season_number', 'ASC'],
@@ -6,6 +6,7 @@ import { EntryId } from '../../shared/models/entryId.model';
import { EntryRating } from '../../shared/models/entry-rating.model'; import { EntryRating } from '../../shared/models/entry-rating.model';
import { Media } from '../../shared/models/media.model'; import { Media } from '../../shared/models/media.model';
import { ConfigService } from './config.service'; import { ConfigService } from './config.service';
import { Season } from '../../shared/models/season.model';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@@ -32,6 +33,12 @@ export class EntryService {
); );
} }
getEntrySeasons(entryId: number) {
return this.http.get<Season[]>(
`${this.backend_apiUrl}/${this.apiAction}/${entryId}/seasons`
);
}
// update entry // update entry
updateEntry(entryId: number, entryData: any) { updateEntry(entryId: number, entryData: any) {
return this.http.put<Entry>( return this.http.put<Entry>(
@@ -38,6 +38,12 @@ export class EpisodeSeenService {
); );
} }
getEpisodeSeenBySeasonId(entryId: number) {
return this.http.get<any[]>(
`${this.backend_apiUrl}/${this.apiAction}/by-season/${entryId}`
);
}
// get episode-seen by episode Id // get episode-seen by episode Id
getEpisodeSeenById(id: number) { getEpisodeSeenById(id: number) {
return this.http.get<EpisodeSeen[]>( return this.http.get<EpisodeSeen[]>(
@@ -3,6 +3,7 @@ import { Routes, RouterModule } from '@angular/router';
import { EntryPageComponent } from './entry-page/entry-page.component'; import { EntryPageComponent } from './entry-page/entry-page.component';
import { EntryResolverService } from '../../core/resolvers/entry-resolver.service'; import { EntryResolverService } from '../../core/resolvers/entry-resolver.service';
import { AlternateEntryPageComponent } from './alternate-entry-page/alternate-entry-page.component'; import { AlternateEntryPageComponent } from './alternate-entry-page/alternate-entry-page.component';
import { SeasonPageComponent } from './season-page/season-page.component';
const routes: Routes = [ const routes: Routes = [
{ {
@@ -19,6 +20,10 @@ const routes: Routes = [
entry: EntryResolverService, entry: EntryResolverService,
}, },
}, },
{
path: ':id/seasons/:seasonNumber',
component: SeasonPageComponent,
},
]; ];
@NgModule({ @NgModule({
@@ -9,6 +9,7 @@ import { MediaModalComponent } from './media-modal/media-modal.component';
import { MediaUploadModalComponent } from './media-upload-modal/media-upload-modal.component'; import { MediaUploadModalComponent } from './media-upload-modal/media-upload-modal.component';
import { EntrySettingsModalComponent } from './entry-settings-modal/entry-settings-modal.component'; import { EntrySettingsModalComponent } from './entry-settings-modal/entry-settings-modal.component';
import { AlternateEntryPageComponent } from './alternate-entry-page/alternate-entry-page.component'; import { AlternateEntryPageComponent } from './alternate-entry-page/alternate-entry-page.component';
import { SeasonPageComponent } from './season-page/season-page.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
@@ -17,7 +18,8 @@ import { AlternateEntryPageComponent } from './alternate-entry-page/alternate-en
SeasonMainCardComponent, SeasonMainCardComponent,
MediaModalComponent, MediaModalComponent,
MediaUploadModalComponent, MediaUploadModalComponent,
EntrySettingsModalComponent EntrySettingsModalComponent,
SeasonPageComponent,
], ],
imports: [ imports: [
CommonModule, CommonModule,
@@ -1,37 +1,120 @@
.list-item-1 { /* Background Wrapper Adjustments */
padding-top: 1px; .background-wrapper {
} position: absolute;
top: 0;
.list-title { left: 0;
font-size: 20px; width: 100%;
} height: 200px; /* Reduced height for a subtler background */
z-index: -1;
.list-line {
max-height: 105px;
border-radius: 1px;
overflow: hidden; overflow: hidden;
padding: 2px; }
box-sizing: border-box; .background-wrapper img {
width: 100%;
height: 100%;
object-fit: cover;
}
.background-wrapper::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 50%, transparent 100%);
z-index: 2;
}
[data-bs-theme="dark"] .background-wrapper::after {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 50%, transparent 100%);
} }
/* Main Container Adjustments */
.main-container {
margin-top: 100px !important; /* Reduced margin to align with season details */
}
/* Left Column (Poster Section) */
.left-col {
min-width: 240px;
display: flex;
flex-direction: column;
align-items: center;
}
.poster {
padding: 10px;
cursor: pointer;
}
.poster img {
border-radius: 5px;
max-width: 100%;
max-height: 150px; /* Adjusted size for compactness */
}
/* Right Column (Details Section) */
.right-col {
flex-grow: 1;
padding-left: 20px;
}
.title {
font-size: 2rem !important; /* Reduced font size for compactness */
margin-bottom: 10px;
}
.info-item {
font-size: 1rem;
color: var(--shz-blue-default);
}
/* Progress Bar and Episode Count */
.progress {
margin-top: 10px;
height: 7px;
margin-bottom: 10px;
}
.progress-bar {
background-color: var(--shz-gold-1); /* Custom progress bar color */
}
.episode-count {
font-size: 1rem;
color: var(--shz-blue-default);
margin-right: 10px;
}
/* Hover Effects */
.list-line {
display: flex;
align-items: start;
gap: 20px;
padding: 10px;
border-radius: 5px;
transition: background-color 0.3s ease;
}
.list-line:hover {
background-color: var(--shz-light-bgh);
}
:host-context([data-bs-theme="dark"]) .list-line:hover {
background-color: var(--shz-dark-bgh);
}
/* Overview Text */
.overview { .overview {
font-size: 1rem;
margin-top: 10px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
max-height: 50px; max-height: 40px;
} }
.list-line:hover { /* Button Styles */
background-color: var(--shz-light-bgh); .btn-icon-only {
background-color: transparent;
border: none;
color: inherit;
margin: 0 5px 3px 0;
font-size: 1.5rem;
} }
.btn-icon-only:hover {
:host-context([data-bs-theme="dark"]) .list-line:hover { color: #fc185a;
background-color: var(--shz-dark-bgh);
}
.progress {
flex-grow: 1; /* Makes the progress bar expand to fill available space */
margin-right: 10px; /* Adds some space between the progress bar and the checkbox */
} }
@@ -1,4 +1,4 @@
<div class="d-flex align-items-start gap-2 list-line" @fadeInOut> <div class="d-flex align-items-start gap-2 list-line cursor-pointer" (click)="handleClick()" @fadeInOut>
<img [src]="posterPath" width="70" height="105" class="" alt="Episode poster"> <img [src]="posterPath" width="70" height="105" class="" alt="Episode poster">
<div class="flex-grow-1 list-item-1"> <div class="flex-grow-1 list-item-1">
<h6 class="mb-0 list-title">{{season.name}}</h6> <h6 class="mb-0 list-title">{{season.name}}</h6>
@@ -1,16 +1,12 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Season } from '../../../shared/models/season.model'; import { Season } from '../../../shared/models/season.model';
import { SeasonService } from '../../../core/services/season.service'; import { SeasonService } from '../../../core/services/season.service';
import { import { trigger, style, transition, animate } from '@angular/animations';
trigger,
style,
transition,
animate,
} from '@angular/animations';
import { Episode } from '../../../shared/models/episode.models'; import { Episode } from '../../../shared/models/episode.models';
import { EpisodeSeenService } from '../../../core/services/episode-seen.service'; import { EpisodeSeenService } from '../../../core/services/episode-seen.service';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component'; import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-season-main-card', selector: 'app-season-main-card',
@@ -39,7 +35,8 @@ export class SeasonMainCardComponent implements OnInit {
constructor( constructor(
private seasonService: SeasonService, private seasonService: SeasonService,
private episodeSeenService: EpisodeSeenService, private episodeSeenService: EpisodeSeenService,
public dialog: MatDialog public dialog: MatDialog,
private router: Router
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
@@ -84,6 +81,7 @@ export class SeasonMainCardComponent implements OnInit {
return count; return count;
} }
async episodeMarkSeenClick() { async episodeMarkSeenClick() {
if (this.lockActions) return; if (this.lockActions) return;
this.lockActions = true; this.lockActions = true;
@@ -172,4 +170,10 @@ export class SeasonMainCardComponent implements OnInit {
} }
}); });
} }
handleClick() {
this.router.navigate([
`/entries/${this.season.entry_id}/seasons/${this.season.season_number}`,
]);
}
} }
@@ -0,0 +1,245 @@
:host {
--bg-opacity: 0.9;
--bg-color: rgba(255, 255, 255, var(--bg-opacity));
--text-color: #333;
--text-muted: #666;
--border-color: #dee2e6;
--card-bg: rgba(255, 255, 255, 0.8);
--hover-bg: #e9ecef;
--shadow-color: rgba(0, 0, 0, 0.1);
}
[data-bs-theme="dark"] :host {
--bg-opacity: 0.9;
--bg-color: rgba(33, 37, 41, var(--bg-opacity));
--text-color: #fff;
--text-muted: #adb5bd;
--border-color: #495057;
--card-bg: rgba(33, 37, 41, 0.8);
--hover-bg: #495057;
--shadow-color: rgba(0, 0, 0, 0.3);
}
.fixed-image {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
filter: brightness(0.5);
z-index: -1;
}
.content-wrapper {
position: relative;
margin-top: 2rem;
margin-bottom: 2rem;
background: var(--bg-color);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-radius: 15px;
box-shadow: 0 0 20px var(--shadow-color);
padding: 20px;
color: var(--text-color);
}
.poster img {
border-radius: 10px;
box-shadow: 0 4px 8px var(--shadow-color);
width: 100%;
}
.info-card {
margin-bottom: 20px;
border-radius: 10px;
box-shadow: 0 2px 4px var(--shadow-color);
background: var(--card-bg);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
color: var(--text-color);
}
.info-card .card-title {
color: var(--text-color);
font-weight: 600;
}
.list-group-item {
border: none;
padding: 8px 0;
background: transparent;
color: var(--text-color);
}
.info-item {
color: var(--text-muted);
margin-right: 8px;
}
.season-nav .btn-pill {
border-radius: 20px;
padding: 5px 15px;
background: var(--card-bg);
border: 1px solid var(--border-color);
margin-right: 10px;
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
color: var(--text-color);
}
.season-nav .btn-pill.active {
background: #007bff;
color: white;
border-color: #007bff;
}
.episode-cards .card {
border-radius: 10px;
overflow: hidden;
border: none;
box-shadow: 0 2px 4px var(--shadow-color);
background: var(--card-bg);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
color: var(--text-color);
}
.episode-cards .card-title {
font-size: 1.1rem;
font-weight: 600;
margin-bottom: 0.5rem;
color: var(--text-color);
}
.episode-image-container {
height: 180px;
overflow: hidden;
padding: 0;
}
.episode-still {
width: 100%;
height: 100%;
object-fit: cover;
}
.btn-icon-only-success {
width: 40px;
height: 40px;
padding: 0;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
margin-left: 8px;
background: var(--card-bg);
border: none;
color: var(--text-color);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
}
.btn-icon-only-success:hover {
background: var(--hover-bg);
color: #007bff;
}
.watch-history-section {
background: var(--card-bg);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
border-radius: 10px;
padding: 20px;
color: var(--text-color);
}
.material-symbols-outlined {
font-size: 20px;
line-height: 1;
}
.title {
color: var(--text-color);
margin-bottom: 0;
}
.episode-actions {
display: flex;
gap: 0.5rem;
}
.card-text {
margin-bottom: 0.5rem;
color: var(--text-color);
}
.card-text small.text-muted {
color: var(--text-muted) !important;
}
.table {
margin-bottom: 0;
color: var(--text-color);
}
.table th {
border-top: none;
color: var(--text-color);
}
.table td {
color: var(--text-color);
border-color: var(--border-color);
}
.btn-outline-primary {
color: var(--text-color);
border-color: var(--border-color);
}
.btn-outline-primary:hover {
background-color: var(--hover-bg);
border-color: #007bff;
color: #007bff;
}
.btn-outline-secondary {
color: var(--text-color);
border-color: var(--border-color);
}
.btn-outline-secondary:hover {
background-color: var(--hover-bg);
border-color: var(--text-muted);
color: var(--text-muted);
}
.btn-link {
color: var(--text-color);
}
.btn-link:hover {
color: #007bff;
}
.btn-link.text-danger {
color: #dc3545 !important;
}
.btn-link.text-danger:hover {
color: #bd2130 !important;
}
@media (max-width: 768px) {
.episode-image-container {
height: 200px;
}
.content-wrapper {
margin-top: 1rem;
padding: 15px;
}
}
@@ -0,0 +1,145 @@
<!-- Fixed Background -->
<div class="fixed-image" [style.background-image]="'url(http://localhost:4000/api/v1/media/entries/backdrops/original/1fb338bd-46ee-4caf-b736-f3c0e797ed88.jpg)'"></div>
<div class="container content-wrapper main-container">
<div class="row">
<!-- Left Column -->
<div class="col-md-3 left-col">
<div class="poster">
<img [src]="posterPath(selectedSeason.poster_path)" alt="Season Poster" class="img-fluid mb-3">
</div>
<div class="card info-card">
<div class="card-body">
<h6 class="card-title">Season Info</h6>
<hr>
<li class="list-group-item">
<strong class="info-item">Air Date:</strong>
{{selectedSeason.air_date | date:'MMM dd, yyyy'}}
</li>
<li class="list-group-item">
<strong class="info-item">Episodes:</strong>
{{selectedSeason.episode_count}}
</li>
</div>
</div>
<div class="card info-card">
<div class="card-body">
<h6 class="card-title">Ratings</h6>
<hr>
<li class="list-group-item" *ngIf="selectedSeason.tmdb_rating">
<strong class="info-item">TMDB:</strong>
{{selectedSeason.tmdb_rating}}/10
</li>
<li class="list-group-item" *ngIf="selectedSeason.imdb_rating">
<strong class="info-item">IMDB:</strong>
{{selectedSeason.imdb_rating}}/10
</li>
<li class="list-group-item">
<strong class="info-item">Your Rating:</strong>
{{selectedSeason.user_rating}}/10
</li>
</div>
</div>
</div>
<!-- Right Column -->
<div class="col-md-9 right-col">
<!-- Season Navigation -->
<div class="season-nav mb-4">
<div class="d-flex justify-content-between align-items-center">
<h2 class="title">{{selectedSeason.name}}</h2>
<div class="season-actions">
<button class="btn btn-icon-only-success wh-48">
<span class="material-symbols-outlined">playlist_add_check</span>
</button>
<button class="btn btn-icon-only-success wh-48" (click)="addToPlaylist()">
<span class="material-symbols-outlined">playlist_add</span>
</button>
</div>
</div>
<div class="season-pills mt-3">
<ng-container *ngFor="let season of seasons">
<a [routerLink]="['/entries', entryId, 'seasons', season.season_number]" class="btn btn-pill me-2 mb-2"
[class.active]="season.season_number === selectedSeason.season_number">
{{ season.season_number === 0 ? 'Specials' : 'Season ' + season.season_number }}
</a>
</ng-container>
</div>
</div>
<!-- Season Overview -->
<div class="season-overview mb-4">
<p>{{selectedSeason.overview}}</p>
</div>
<!-- Episodes List -->
<div class="episodes-section">
<h3 class="mb-3">Episodes</h3>
<div class="episode-cards">
<div class="card mb-3" *ngFor="let episode of selectedSeason.episodes">
<div class="row g-0">
<div class="col-md-3 episode-image-container">
<img [src]="posterPath(episode.still_path)" class="episode-still" alt="Episode Still">
</div>
<div class="col-md-9">
<div class="card-body">
<div class="d-flex justify-content-between">
<h5 class="card-title">{{episode.episode_number}}. {{episode.name}}</h5>
<div class="episode-actions">
<button class="btn btn-sm btn-outline-primary me-2">
<span class="material-symbols-outlined">check</span>
</button>
<button class="btn btn-sm btn-outline-secondary">
<span class="material-symbols-outlined">info</span>
</button>
</div>
</div>
<p class="card-text">{{episode.overview}}</p>
<p class="card-text">
<small class="text-muted">Air date: {{episode.air_date | date:'MMM dd, yyyy'}}</small>
<small class="text-muted" *ngIf="episode.runtime"> • Runtime: {{episode.runtime}} minutes</small>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Watch History -->
<div class="watch-history-section mt-4">
<h3 class="mb-3">Watch History</h3>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Episode</th>
<th>Date Watched</th>
<th>Watched With</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let history of watchHistory">
<td>Episode {{history.episode_number}}</td>
<td>{{history.date_seen | date:'MMM dd, yyyy'}}</td>
<td>{{history.seen_with}}</td>
<td>
<button class="btn btn-sm btn-link">
<span class="material-symbols-outlined">edit</span>
</button>
<button class="btn btn-sm btn-link text-danger">
<span class="material-symbols-outlined">delete</span>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@@ -0,0 +1,28 @@
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { SeasonPageComponent } from './season-page.component';
describe('SeasonPageComponent', () => {
let component: SeasonPageComponent;
let fixture: ComponentFixture<SeasonPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SeasonPageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SeasonPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,62 @@
import { Component, OnInit } from '@angular/core';
import { EntryService } from '../../../core/services/entry.service';
import { Season } from '../../../shared/models/season.model';
import { ActivatedRoute } from '@angular/router';
import { EpisodeSeenService } from '../../../core/services/episode-seen.service';
import { EpisodeSeenDto } from '../../../shared/models/dtos/episode-seen.dto';
@Component({
selector: 'app-season-page',
templateUrl: './season-page.component.html',
styleUrls: ['./season-page.component.css'],
})
export class SeasonPageComponent implements OnInit {
entryId!: number;
seasonNumber!: number;
seasons: Season[] = [];
selectedSeason!: Season;
watchHistory: EpisodeSeenDto[] = [];
constructor(
private route: ActivatedRoute,
private entryService: EntryService,
private episodeSeenService: EpisodeSeenService
) {}
ngOnInit() {
this.route.paramMap.subscribe((params) => {
this.entryId = Number(params.get('id'));
this.seasonNumber = Number(params.get('seasonNumber'));
// Fetch all seasons for the entryId
this.entryService.getEntrySeasons(this.entryId).subscribe({
next: (result) => {
this.seasons = result;
this.selectedSeason = this.seasons.find(
(season) => season.season_number === this.seasonNumber
)!;
console.log(this.selectedSeason);
},
});
this.episodeSeenService.getEpisodeSeenByEntryId(this.entryId).subscribe({
next: (result) => {
this.watchHistory = result;
},
});
});
}
posterPath(path: string | undefined) {
if (path) {
return `https://image.tmdb.org/t/p/w300` + path;
}
return 'assets/images/default/default-poster.png';
}
markAsWatched() {}
addToPlaylist() {}
}
@@ -21,7 +21,7 @@ export interface Episode {
imdb_rating: number; imdb_rating: number;
// temp fields // temp fields
poster_path: string; still_path: string;
banner_path: string; banner_path: string;
date_first_seen: Date; date_first_seen: Date;