This commit is contained in:
X4Lo committed 2024-06-05 16:53:14 +01:00
commit 710ebcc934
82 files changed
+1422 -386

No files matched your search

+9 -5
View File
@@ -1,26 +1,30 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './features/home/home.component';
import { SearchComponent } from './features/discover/search/search.component';
import { SearchPageComponent } from './features/discover/search-page/search-page.component';
import { TrendingComponent } from './features/discover/trending/trending.component';
import { PopularComponent } from './features/discover/popular/popular.component';
import { LibraryComponent } from './features/library/library.component';
import { FavoritComponent } from './features/favorit/favorit.component';
import { WatchlistComponent } from './features/watchlist/watchlist.component';
import { SettingsComponent } from './features/settings/settings.component';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'search', component: SearchComponent },
{ path: 'search', component: SearchPageComponent },
{ path: 'popular', component: PopularComponent },
{ path: 'trending', component: TrendingComponent },
{ path: 'library', component: LibraryComponent },
{ path: 'favorit', component: FavoritComponent },
{ path: 'watchlist', component: WatchlistComponent },
{ path: 'settings', component: SettingsComponent },
// { path: 'entry', component: LibraryComponent },
{
path: 'settings',
loadChildren: () =>
import('./features/settings/settings.module').then(
(m) => m.SettingsModule
),
},
{
path: 'entries',
loadChildren: () =>
+17 -1
View File
@@ -1,4 +1,7 @@
import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { filter } from 'rxjs';
import PerfectScrollbar from 'perfect-scrollbar';
@Component({
@@ -7,12 +10,25 @@ import PerfectScrollbar from 'perfect-scrollbar';
styleUrl: './app.component.css',
})
export class AppComponent implements AfterViewInit {
title = 'Showy';
@ViewChild('scrollContainer', { static: true }) scrollContainer!: ElementRef;
private ps!: PerfectScrollbar;
title = 'ShowZ';
constructor(private router: Router) {}
ngAfterViewInit() {
this.ps = new PerfectScrollbar(this.scrollContainer.nativeElement);
this.router.events
.pipe(filter(event => event instanceof NavigationEnd))
.subscribe(() => {
this.scrollToTop();
});
}
scrollToTop() {
this.scrollContainer.nativeElement.scrollTop = 0;
this.ps.update();
}
}
+2 -4
View File
@@ -14,7 +14,7 @@ import { CommonModule, DatePipe } from '@angular/common';
import { HomeComponent } from './features/home/home.component';
import { PopularComponent } from './features/discover/popular/popular.component';
import { TrendingComponent } from './features/discover/trending/trending.component';
import { SearchComponent } from './features/discover/search/search.component';
import { SearchPageComponent } from './features/discover/search-page/search-page.component';
import { LibraryComponent } from './features/library/library.component';
import { DynamicEntryListComponent } from './shared/components/lists/dynamic-entry-list/dynamic-entry-list.component';
@@ -23,7 +23,6 @@ import { MainCardComponent } from './shared/components/cards/main-card/main-card
import { FavoritComponent } from './features/favorit/favorit.component';
import { WatchlistComponent } from './features/watchlist/watchlist.component';
import { SharedModule } from './shared/shared.module';
import { SettingsComponent } from './features/settings/settings.component';
import { ToastrModule } from 'ngx-toastr';
@NgModule({
@@ -53,11 +52,10 @@ import { ToastrModule } from 'ngx-toastr';
HomeComponent,
PopularComponent,
TrendingComponent,
SearchComponent,
SearchPageComponent,
LibraryComponent,
FavoritComponent,
WatchlistComponent,
SettingsComponent,
// ? temp shared components
MainCardComponent,
@@ -580,19 +580,19 @@
</div>
</a>
<hr class="dropdown-divider">
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;"><i
class="material-icons-outlined">person_outline</i>Profile</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;"><i
class="material-icons-outlined">local_bar</i>Setting</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;"><i
class="material-icons-outlined">dashboard</i>Dashboard</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;"><i
class="material-icons-outlined">account_balance</i>Earning</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;"><i
class="material-icons-outlined">cloud_download</i>Downloads</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;">
<i class="material-icons-outlined">person_outline</i>Profile</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;">
<i class="material-icons-outlined">local_bar</i>Setting</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;">
<i class="material-icons-outlined">dashboard</i>Dashboard</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;">
<i class="material-icons-outlined">account_balance</i>Earning</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;">
<i class="material-icons-outlined">cloud_download</i>Downloads</a>
<hr class="dropdown-divider">
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;"><i
class="material-icons-outlined">power_settings_new</i>Logout</a>
<a class="dropdown-item d-flex align-items-center gap-2 py-2" href="javascript:;">
<i class="material-icons-outlined">power_settings_new</i>Logout</a>
</div>
</li>
</ul>
@@ -8,7 +8,8 @@ a {
}
.sidebar-wrapper .sidebar-header .logo-img {
width: 48px;
height: 40px;
width: 40px;
}
.sidebar-wrapper .sidebar-header,
@@ -7,7 +7,7 @@
<img src="assets/images/logo3.png" class="logo-img" alt="">
</div>
<div class="logo-name flex-grow-1">
<h5 class="mb-0">ShowzY</h5>
<h5 class="mb-0">Showy</h5>
</div>
<!-- <div class="sidebar-close">
<span class="material-icons-outlined">close</span>
@@ -1,13 +1,13 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { EntrySeen } from '../../shared/models/entrySeen.model';
import { EntryRating } from '../../shared/models/entryRating.model';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
})
export class EntryRatingsService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'entry-ratings';
constructor(private http: HttpClient) {}
@@ -16,7 +16,7 @@ export class EntryRatingsService {
return this.http.put<EntryRating>(
`${this.backend_apiUrl}/${this.apiAction}/${entryRatings.id}`,
{
entryR: entryRatings
entryR: entryRatings,
}
);
}
@@ -1,12 +1,13 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { EntrySeen } from '../../shared/models/entrySeen.model';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
})
export class EntrySeenService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'entry-seen';
constructor(private http: HttpClient) {}
@@ -22,6 +23,16 @@ export class EntrySeenService {
);
}
updateEntrySeen(entrySeen: EntrySeen) {
return this.http.put<EntrySeen>(
`${this.backend_apiUrl}/${this.apiAction}/${entrySeen.id}`,
{
date_seen: entrySeen.date_seen,
seen_with: entrySeen.seen_with,
}
);
}
// get entry seen by entry id
getEntrySeenById(id: string) {
return this.http.get<EntrySeen[]>(
@@ -4,13 +4,13 @@ import { Observable, map } from 'rxjs';
import { Entry } from '../../shared/models/entry.model';
import { EntryId } from '../../shared/models/entryId.model';
import { EntryRating } from '../../shared/models/entryRating.model';
// import { environment } from '../../../environments/environment';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
})
export class EntryService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'entries';
constructor(private http: HttpClient) {}
@@ -2,12 +2,13 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { EpisodeSeen } from '../../shared/models/episodeSeen.model';
import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
})
export class EpisodeSeenService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'episode-seen';
constructor(private http: HttpClient) {}
@@ -1,11 +1,12 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
})
export class EpisodeService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'episodes';
constructor(private http: HttpClient) {}
@@ -2,12 +2,13 @@ import { Injectable } from '@angular/core';
import { MovieDateSeen } from '../../shared/models/dtos/movieDateSeen.model';
import { HttpClient } from '@angular/common/http';
import { Entry } from '../../shared/models/entry.model';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
})
export class ImporterService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'entries';
constructor(private http: HttpClient) {}
@@ -5,6 +5,7 @@ import { catchError, switchMap, tap } from 'rxjs/operators';
import { Entry } from '../../shared/models/entry.model';
import { EntryId } from '../../shared/models/entryId.model';
import { EntryRating } from '../../shared/models/entryRating.model';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
@@ -13,7 +14,8 @@ export class LibraryService implements OnInit {
private libraryEntriesSubject = new ReplaySubject<Entry[]>(1);
private entriesLoaded = false;
private backend_apiUrl = ' http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'entries';
constructor(private http: HttpClient) {}
@@ -48,7 +50,7 @@ export class LibraryService implements OnInit {
}
private fetchAllEntries(forceFetch: boolean = false): Observable<Entry[]> {
const endPoint = `${this.backend_apiUrl}/entries`;
const endPoint = `${this.backend_apiUrl}/${this.apiAction}`;
// If data is already loaded and not force fetching, immediately return the cached observable.
if (this.entriesLoaded && !forceFetch) {
@@ -80,10 +82,13 @@ export class LibraryService implements OnInit {
if (existingEntry) {
return of(existingEntry);
} else {
return this.http.post<Entry>(`${this.backend_apiUrl}/entries`, {
tmdb_id: tmdb_id,
is_tvserie: is_tvserie,
});
return this.http.post<Entry>(
`${this.backend_apiUrl}/${this.apiAction}`,
{
tmdb_id: tmdb_id,
is_tvserie: is_tvserie,
}
);
}
})
);
@@ -91,7 +96,7 @@ export class LibraryService implements OnInit {
deleteEntry(id: number): Observable<any> {
// Directly attempt to delete the entry without fetching all entries first.
return this.http.delete(`${this.backend_apiUrl}/entries/${id}`);
return this.http.delete(`${this.backend_apiUrl}/${this.apiAction}/${id}`);
}
isInLibrary(tmdb_id: string): Observable<Entry | null> {
@@ -2,12 +2,13 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Season } from '../../shared/models/season.model';
import { Episode } from '../../shared/models/episode.models';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
})
export class SeasonService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'seasons';
constructor(private http: HttpClient) {}
@@ -31,4 +32,10 @@ export class SeasonService {
`${this.backend_apiUrl}/${this.apiAction}/${id}/episodes`
);
}
getSeasonsWithEpisodesByEntryId(entryId: number) {
return this.http.get<Season[]>(
`${this.backend_apiUrl}/entries/${entryId}/seasons`
);
}
}
@@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../../environments/environment.prod';
import { Settings } from '../../shared/models/settings.model';
@Injectable({
providedIn: 'root',
})
export class SettingsService {
private backend_apiUrl = environment.API_URL;
private apiAction = 'settings';
constructor(private http: HttpClient) {}
getSettings() {
return this.http.get<Settings>(`${this.backend_apiUrl}/${this.apiAction}`);
}
updateSettings(settings: Settings) {
return this.http.put<any>(
`${this.backend_apiUrl}/${this.apiAction}`,
settings
);
}
}
@@ -4,6 +4,7 @@ import { Observable, from, map, of, switchMap, toArray } from 'rxjs';
import { Entry } from '../../shared/models/entry.model';
import { EntryId } from '../../shared/models/entryId.model';
import { EntryRating } from '../../shared/models/entryRating.model';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
@@ -14,8 +15,8 @@ export class TmdbService {
constructor(private http: HttpClient) {}
// private apiUrl = environment.apiBaseUrl;
private tmdb_apiUrl = 'https://api.themoviedb.org/3';
private tmdb_apiKey = '5323ef3dc430df54dcb9e58c37fd22bb';
private tmdb_apiUrl = environment.TMDB_API_URL;
private tmdb_apiKey = environment.TMDB_API_KEY;
fetchdata(endPoint: string): Observable<any> {
if (this.cach[endPoint]) {
@@ -34,9 +35,6 @@ export class TmdbService {
getEntriesUsingEndPoint(endPoint: string): Observable<Entry[]> {
return this.fetchdata(endPoint).pipe(
// map((response) =>
// response.results.map((movie: any) => this.adaptMovieToEntry(movie))
// )
map((response) => {
// Check if the data is from cache and has `exist` property
if (response.exist) {
@@ -4,12 +4,13 @@ import { Observable } from 'rxjs';
import { UserCollection } from '../../shared/models/userCollection.model';
import { UserCollectionEntry } from '../../shared/models/userCollectionEntry.model';
import { Entry } from '../../shared/models/entry.model';
import { environment } from '../../../environments/environment.prod';
@Injectable({
providedIn: 'root',
})
export class UserCollectionService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private backend_apiUrl = environment.API_URL;
private apiAction = 'user-collections';
constructor(private http: HttpClient) {}
@@ -4,7 +4,7 @@
<td>
<div class="d-flex align-items-center gap-3">
<div class="product-box">
<img src="https://picsum.photos/70" width="70" class="rounded-3" alt="">
<img [src]="getLogoPath()" width="80" class="rounded-3" alt="">
</div>
<div class="product-info">
<a href="javascript:;" class="product-title">{{entry.title}}</a>
@@ -64,6 +64,28 @@ export class CollectionTableLineComponent implements OnInit {
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path;
}
getLogoPath() {
// * Is in library: use a local logo
if (this.entry.medias) {
const selectedLogos = this.entry.medias.filter(
(m) => m.type == 'logo' && m.is_selected
);
if (
selectedLogos.length &&
selectedLogos[0] &&
selectedLogos[0].path
) {
const name = selectedLogos[0].path.split('.')[0];
const extention = selectedLogos[0].path.split('.')[1];
return `http://localhost:4000/api/v1/media/entries/logos/${name}.${extention}`;
}
}
// * No poster found, use default poster image as a last stand
return 'assets/images/default/default-logo.png';
}
removeEntryFromList() {
const dialogRef = this.dialog.open(ConfirmModalComponent, {
width: '400px',
@@ -6,15 +6,29 @@
font-size: 20px;
}
.list-line {
.collection-card {
border-radius: 1px;
padding: 2px;
padding: 5px;
min-height: 225px;
margin: 10px 10px;
}
.card-coat{
height: 100%;
border-radius: 5px;
cursor: pointer;
}
.list-line:hover {
.card-coat:hover {
background-color: var(--shz-light-bgh);
}
:host-context([data-bs-theme="dark"]) .list-line:hover {
:host-context([data-bs-theme="dark"]) .card-coat:hover {
background-color: var(--shz-dark-bgh);
}
#poster {
border-radius: 5px;
min-height: 225px;
height: 225px;
object-fit:cover;
}
@@ -1,11 +1,10 @@
<div class="d-flex align-items-start gap-2 list-line" @fadeInOut>
<img [src]="getPostPath()" width="70" height="105" class="" alt="List poster" (click)="redirectTo()">
<div class="flex-grow-1 list-item-1">
<h6 class="mb-0 list-title" (click)="redirectTo()">{{list.name}}</h6>
<p class="mb-0">Created: {{getCreatedDate() | dateFormat}}</p>
<p class="mb-0">Contains: {{list.userCollectionEntries.length}} title(s)</p>
<div class="card-coat">
<div class="d-flex flex-column align-items-center collection-card" @fadeInOut>
<img id="poster" [src]="getPostPath()" width="150" class="" alt="List poster" (click)="redirectTo()">
<div class="list-item-1 mt-2 text-center">
<h6 class="mb-0 list-title" (click)="redirectTo()">{{list.name}}</h6>
<!-- <p class="mb-0">Created: {{getCreatedDate() | dateFormat}}</p> -->
<!-- <p class="mb-0">Contains: {{list.userCollectionEntries.length}} title(s)</p> -->
</div>
</div>
<!-- <div class="form-check form-check-inline me-0">
<input class="form-check-input ms-0" type="checkbox">
</div> -->
</div>
@@ -0,0 +1,6 @@
.collections-container{
display: grid;
grid-template-columns: repeat(auto-fill,
minmax(150px, 2fr));
gap: 20px;
}
@@ -30,14 +30,19 @@
</div>
<div class="card-body p-0">
<div class="p-3 ps ps--active-y">
<div class="collections-container">
<app-userCollections-list-item *ngFor="let list of collectionsToShow"
[list]="list" @animateDestroy></app-userCollections-list-item>
</div>
<!-- <div class="p-3 ps ps--active-y">
<div class="d-flex flex-column gap-3">
<!-- item start -->
<app-userCollections-list-item *ngFor="let list of collectionsToShow"
[list]="list" @animateDestroy></app-userCollections-list-item>
<!-- item end -->
</div>
</div>
</div> -->
</div>
</div>
</div>
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SearchPageComponent } from './search-page.component';
describe('SearchPageComponent', () => {
let component: SearchPageComponent;
let fixture: ComponentFixture<SearchPageComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [SearchPageComponent]
});
fixture = TestBed.createComponent(SearchPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -5,11 +5,11 @@ import { FormControl } from '@angular/forms';
import { debounceTime, distinctUntilChanged } from 'rxjs';
@Component({
selector: 'app-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.css'],
selector: 'app-search-page',
templateUrl: './search-page.component.html',
styleUrls: ['./search-page.component.css'],
})
export class SearchComponent implements OnInit {
export class SearchPageComponent implements OnInit {
entryType: boolean = true;
entries: Entry[] = [];
isSearchLocked: boolean = false;
@@ -1,21 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SearchComponent } from './search.component';
describe('SearchComponent', () => {
let component: SearchComponent;
let fixture: ComponentFixture<SearchComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [SearchComponent]
});
fixture = TestBed.createComponent(SearchComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -15,7 +15,7 @@
}
.background-wrapper::after {
content: '';
content: "";
position: absolute;
top: 0;
left: 0;
@@ -25,13 +25,17 @@
z-index: 2;
}
[data-bs-theme=dark] .background-wrapper::after {
[data-bs-theme="dark"] .background-wrapper::after {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 60%, #181c1f 100%);
}
.content-wrapper {
color: #212529;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.461) 10%, #eff1f3 100%);
background: linear-gradient(
to bottom,
rgba(255, 255, 255, 0.461) 10%,
#eff1f3 100%
);
backdrop-filter: blur(10px);
padding: 20px;
@@ -40,17 +44,15 @@
/* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */
}
[data-bs-theme=dark] .content-wrapper {
[data-bs-theme="dark"] .content-wrapper {
color: #a7acb1;
background: linear-gradient(to bottom, rgba(33,
37,
41,
0.7) 50%, #181c1f 100%);
background: linear-gradient(
to bottom,
rgba(33, 37, 41, 0.7) 50%,
#181c1f 100%
);
background-color: rgba(33,
37,
41,
0.7);
background-color: rgba(33, 37, 41, 0.7);
border: 1px solid #181c1f;
}
@@ -79,7 +81,6 @@
margin: 10px 0;
}
.side-info .list-group-item {
background-color: rgba(255, 255, 255, 0.461) !important;
background-color: transparent !important;
@@ -96,7 +97,7 @@
font-size: 2.9rem !important;
}
[data-bs-theme=dark] .title {
[data-bs-theme="dark"] .title {
color: white;
}
@@ -105,7 +106,7 @@
font-size: 2rem;
}
[data-bs-theme=dark] .right-col .entry-actions span {
[data-bs-theme="dark"] .right-col .entry-actions span {
color: white;
}
@@ -158,9 +159,25 @@
}
.faved {
font-variation-settings:
'FILL' 1,
'wght' 400,
'GRAD' 0,
'opsz' 24
}
font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}
.info-item {
color: var(--shz-blue-default);
}
.info-card {
background-color: transparent;
margin-bottom: 0;
}
.info-card hr {
margin-top: 5px;
}
.info-card .accordion .accordion-item,
.info-card .accordion .accordion-header,
.info-card .accordion .accordion-header .accordion-button {
background-color: transparent;
border-radius: 0;
}
@@ -14,7 +14,7 @@
</rating>
</div>
<!-- Movie Side Info -->
<ul class="list-group side-info">
<!-- <ul class="list-group side-info">
<li class="list-group-item" *ngIf="entry.entryRating.tmdb_rating"><strong>TMDB Rating:</strong>
{{entry.entryRating.tmdb_rating | floatFormat:1}}/10</li>
<li class="list-group-item" *ngIf="entry.entryRating.imdb_rating"><strong>IMDB Rating:</strong>
@@ -32,14 +32,61 @@
<li class="list-group-item" *ngIf="entry.date_last_seen"><strong>Last Seen:</strong> {{entry.date_last_seen |
dateFormat:'MMM dd, yyyy'}}
</li>
</ul>
<!-- End Movie Side Info -->
<br>
<!-- watch history -->
<div class="card" *ngIf="entry.entrySeen.length > 0">
</ul> -->
<div class="card info-card">
<div class="card-body">
<h5 class="card-title">Watch History</h5>
<h6 class="card-title">Info</h6>
<hr>
<li class="list-group-item">
<strong class="info-item">Premiere:</strong>
{{this.entry.release_date | dateFormat:'MMM dd, yyyy'}}
</li>
<li class="list-group-item" *ngIf="entry.is_tvseries">
<strong class="info-item">Next Episode:</strong>
{{nextEpisode}}
</li>
<li class="list-group-item">
<strong class="info-item">Status:</strong>
{{status}}
</li>
<br>
<li class="list-group-item" *ngIf="entry.date_first_seen">
<strong class="info-item">First Seen:</strong>
{{entry.date_first_seen | dateFormat:'MMM dd, yyyy'}}
</li>
<li class="list-group-item" *ngIf="entry.date_last_seen">
<strong class="info-item">Last Seen:</strong>
{{entry.date_last_seen | dateFormat:'MMM dd, yyyy'}}
</li>
</div>
</div>
<div class="card info-card">
<div class="card-body">
<h6 class="card-title">Rating</h6>
<hr>
<li class="list-group-item" *ngIf="entry.entryRating.tmdb_rating">
<strong class="info-item">TMDB Rating:</strong>
{{entry.entryRating.tmdb_rating | floatFormat:1}}/10
</li>
<li class="list-group-item" *ngIf="entry.entryRating.imdb_rating">
<strong class="info-item">IMDB Rating:</strong>
{{entry.entryRating.imdb_rating | floatFormat:1}}/10
</li>
<li class="list-group-item" *ngIf="entry.entryRating.rotten_tomatoes_rating">
<strong class="info-item">Rotten Romatoes:</strong>
{{entry.entryRating.rotten_tomatoes_rating | floatFormat:1}}/10
</li>
</div>
</div>
<!-- watch history -->
<div class="card info-card" *ngIf="entry.entrySeen.length > 0">
<div class="card-body">
<h6 class="card-title">Watch History</h6>
<!-- <hr> -->
<div class="accordion" id="accordionWatchHistory">
<!-- start watch history - item -->
<div class="accordion-item" *ngFor="let seen of entry.entrySeen">
@@ -61,7 +108,11 @@
<span class="material-symbols-outlined" (click)="removeEntrySeen(seen.id)">
delete_forever
</span>
<!-- TODO add edit button -->
</button>
<button type="button" class="btn btn-icon-only">
<span class="material-symbols-outlined" (click)="editEntrySeen(seen)">
edit
</span>
</button>
</div>
</div>
@@ -72,7 +123,6 @@
</div>
</div>
<!-- end watch history -->
</div>
<div class="col-md-8 right-col">
@@ -113,14 +163,18 @@
</div>
<!-- End Interraction buttons -->
</div>
<!-- Movie Release Date -->
<p>{{this.entry.release_date | dateFormat:'yyyy'}} • {{genres}}</p>
<!-- Movie Overview -->
<p *ngIf="this.entry.title != this.entry.original_title">{{this.entry.original_title}}</p>
<p><strong>{{this.entry.tagline}}</strong></p>
<p>{{this.entry.storyline}}</p>
<div class="row p-3 pt-0">
<!-- Movie Release Date -->
<p class="p-0 m-0">
<span *ngIf="this.entry.title != this.entry.original_title">{{this.entry.original_title}} • </span>
{{this.entry.release_date | dateFormat:'yyyy'}} • {{genres}}
</p>
<!-- Movie Overview -->
<p class="p-0"><strong>{{this.entry.tagline}}</strong></p>
<p class="p-0">{{this.entry.storyline}}</p>
</div>
<!-- Series Seasons -->
<div class="row" *ngIf="entry.is_tvseries">
<h3>Seasons</h3>
@@ -149,57 +203,71 @@
<!-- <div class="row">
<h3>Collections</h3>
</div> -->
<div class="row" *ngIf="this.entry.is_tvseries && this.seenHistory.length != 0">
<h3>Watch History</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Season</th>
<th>Episode</th>
<th>Date Seen</th>
<th>Seen With</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of seenHistoryToShow; let i = index">
<td>{{ item.season_number == 0 ? 'Special' : 'Season '+ item.season_number }}</td>
<td>{{ item.episode_number }}</td>
<td>{{ item.date_seen | dateFormat:'MMM dd, yyyy' }}</td>
<td>{{ item.seen_with }}</td>
<td>
<div class="dropdown">
<button class="btn btn-sm btn-filter dropdown-toggle dropdown-toggle-nocaret" type="button"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-three-dots"></i>
</button>
<ul class="dropdown-menu" style="cursor: pointer;">
<li (click)="editEpisodeSeen(item)"><a class="dropdown-item">Edit</a></li>
<li (click)="deleteEpisodeSeen(item)"><a class="dropdown-item">Delete</a></li>
</ul>
</div>
</td>
<div class="d-flex justify-content-between align-items-center mb-2">
<h3>Watch History</h3>
<div class="dropdown">
<button class="btn btn-sm btn-filter dropdown-toggle dropdown-toggle-nocaret bg-transparent" type="button"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-three-dots"></i>
</button>
<ul class="dropdown-menu" style="cursor: pointer;">
<li (click)="addEpisodeSeen()"><a class="dropdown-item">Add a watch date</a></li>
</ul>
</div>
</div>
</tr>
</tbody>
</table>
<div class="card-body p-3">
<table class="table table-striped">
<thead>
<tr>
<th>Season</th>
<th>Episode</th>
<th>Date Seen</th>
<th>Seen With</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of seenHistoryToShow; let i = index">
<td>{{ item.season_number == 0 ? 'Special' : 'Season '+ item.season_number }}</td>
<td>{{ item.episode_number }}</td>
<td>{{ item.date_seen | dateFormat:'MMM dd, yyyy' }}</td>
<td>{{ item.seen_with }}</td>
<td>
<div class="dropdown">
<button class="btn btn-sm btn-filter dropdown-toggle dropdown-toggle-nocaret" type="button"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-three-dots"></i>
</button>
<ul class="dropdown-menu" style="cursor: pointer;">
<li (click)="editEpisodeSeen(item)"><a class="dropdown-item">Edit</a></li>
<li (click)="deleteEpisodeSeen(item)"><a class="dropdown-item">Delete</a></li>
</ul>
</div>
</td>
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage > 1">
<ul class="pagination pagination-sm">
<li class="page-item" [class.disabled]="currentPage === 1">
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage - 1)">Previous</a>
</li>
<!-- Dynamically generate page numbers -->
<li class="page-item" *ngFor="let page of pageNumbers" [class.active]="currentPage === page">
<a class="page-link" href="javascript:;" (click)="goToPage(page)">{{ page }}</a>
</li>
<li class="page-item" [class.disabled]="currentPage == maxPage">
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage + 1)">Next</a>
</li>
</ul>
</tr>
</tbody>
</table>
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage > 1">
<ul class="pagination pagination-sm">
<li class="page-item" [class.disabled]="currentPage === 1">
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage - 1)">Previous</a>
</li>
<!-- Dynamically generate page numbers -->
<li class="page-item" *ngFor="let page of pageNumbers" [class.active]="currentPage === page">
<a class="page-link" href="javascript:;" (click)="goToPage(page)">{{ page }}</a>
</li>
<li class="page-item" [class.disabled]="currentPage == maxPage">
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage + 1)">Next</a>
</li>
</ul>
</div>
</div>
</div>
</div>
@@ -18,6 +18,8 @@ import { EpisodeSeenService } from '../../../core/services/episode-seen.service'
import { SeasonService } from '../../../core/services/season.service';
import { LibraryService } from '../../../core/services/library.service';
import { ToastrService } from 'ngx-toastr';
import { EntrySeen } from '../../../shared/models/entrySeen.model';
import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component';
@Component({
selector: 'app-entry-page',
@@ -125,51 +127,6 @@ export class EntryPageComponent implements OnInit {
this.getEpisodesSeenHistory();
}
openEntrySeenModal() {
if (!this.entry) return;
const dialogRef = this.dialog.open(SeenModalComponent, {
width: '360px',
});
dialogRef.afterClosed().subscribe((result) => {
if (result) {
// console.log('Seen dialog closed with:', result);
if (result.watchDate == '') {
// TODO show no was passed date notification
return;
}
let watchDate = result.watchDate;
let watchedWith = result.watchedWith.split('\n').join(', ');
this.entrySeenService
.createEntrySeen(this.entry.id.toString(), watchDate, watchedWith)
.subscribe({
next: (entrySeen) => {
if (entrySeen) {
// TODO show confirm notification
// console.log(`EntrySeen Added`, entrySeen);
this.entry.entrySeen.push(entrySeen);
if (this.entry.watchlist) {
this.libraryService.refrechEntries().subscribe();
}
}
},
error: (error) => {
console.error('Error adding entrySeen:', error);
},
});
// TODO show notification
} else {
// console.log('Seen dialog was cancelled');
}
});
}
onRatingChange(event: Event) {
this.entryRatingsService
.updateEntryRatings(this.entry.entryRating)
@@ -187,6 +144,88 @@ export class EntryPageComponent implements OnInit {
});
}
// ! ENTRY SEEN
openEntrySeenModal(entrySeen: EntrySeen = {} as EntrySeen) {
if (!this.entry) return;
let oldData = {} as { watchDate: Date; watchedWith: string };
if (entrySeen.id) {
oldData.watchDate = entrySeen.date_seen;
oldData.watchedWith = entrySeen.seen_with;
}
const dialogRef = this.dialog.open(SeenModalComponent, {
width: '360px',
data: oldData.watchDate ? oldData : {},
});
dialogRef.afterClosed().subscribe((result) => {
if (result) {
if (result.watchDate == '') {
// TODO show no was passed date notification
return;
}
let watchDate = result.watchDate;
let watchedWith = result.watchedWith.split('\n').join(', ');
if (entrySeen.id) {
const es = {
id: entrySeen.id,
date_seen: watchDate,
seen_with: watchedWith,
} as EntrySeen;
// * Update
this.entrySeenService.updateEntrySeen(es).subscribe({
next: (updatedEntrySeen) => {
if (updatedEntrySeen) {
// TODO show confirm notification
// ? replace the entry-seen object with the updated one
for (let i = 0; i < this.entry.entrySeen.length; i++) {
if (this.entry.entrySeen[i].id == updatedEntrySeen.id)
this.entry.entrySeen[i] = updatedEntrySeen;
}
}
},
error: (error) => {
console.error('Error adding entrySeen:', error);
},
});
} else {
// * Create
this.entrySeenService
.createEntrySeen(this.entry.id.toString(), watchDate, watchedWith)
.subscribe({
next: (entrySeen) => {
if (entrySeen) {
// TODO show confirm notification
this.entry.entrySeen.push(entrySeen);
// ? if the entry was in watch list creating and entry-seen would have removed it
// ? from the watchlist, so now we need to refrech libraryService in order to
// ? update the watchlist page
if (this.entry.watchlist) {
this.libraryService.refrechEntries().subscribe();
}
}
},
error: (error) => {
console.error('Error adding entrySeen:', error);
},
});
}
// TODO show notification
} else {
// console.log('Seen dialog was cancelled');
}
});
}
editEntrySeen(entrySeen: EntrySeen) {
this.openEntrySeenModal(entrySeen);
}
removeEntrySeen(id: number) {
const dialogRef = this.dialog.open(ConfirmModalComponent, {
width: '400px',
@@ -359,6 +398,45 @@ export class EntryPageComponent implements OnInit {
this.seenHistoryToShow = temp.slice(startIndex, endIndex);
}
addEpisodeSeen() {
if (!this.entry) return;
const dialogRef = this.dialog.open(EpisodeSeenModalComponent, {
width: '360px',
data: {
entryId: this.entry.id,
},
});
dialogRef.afterClosed().subscribe((result) => {
// ? if an episode-seen was created then refresh the watch history table
if (result && result.created) {
// ? call this function to fetch the new episode-seen history
this.getEpisodesSeenHistory();
// ? Updating the episodes seen progress bar in the season card
// ? by fetching a new updated episodes list
this.entry.seasons.forEach(async (season) => {
if (season.season_number == result.season_number) {
this.seasonService.getSeasonEpisodes(season.id).subscribe({
next: (episodes) => {
// console.log(
// `Loaded Season ${season.season_number} Episodes (${episodes.length})`
// );
season.episodes = episodes;
},
error: (error) => {
console.log(`Couldn't fetch season episodes data:`, error);
// TODO show notification
season.episodes = [];
},
});
}
});
}
});
}
editEpisodeSeen(episodeSeen: EpisodeSeenDto) {
if (episodeSeen == null) return;
@@ -418,11 +496,11 @@ export class EntryPageComponent implements OnInit {
this.episodeSeenService.removeEpisodeSeen(episodeSeen.id).subscribe({
next: () => {
// console.log(`Episode seen deleted.`);
// call this function to fetch the new episode-seen history
// ? call this function to fetch the new episode-seen history
this.getEpisodesSeenHistory();
// trying to update the episodes seen progress bar in the season card
// by fetching a new updated episodes list
// ? Updating the episodes seen progress bar in the season card
// ? by fetching a new updated episodes list
this.entry.seasons.forEach(async (season) => {
if (season.season_number == episodeSeen.season_number) {
this.seasonService.getSeasonEpisodes(season.id).subscribe({
@@ -297,7 +297,7 @@
<div class="">
<p class="mb-1 fs-6 fw-bold">Movies</p>
<h2 class="mb-0">{{this.watchCount.moviesTotal}}</h2>
<p class="mb-0"><span class="text-success me-2 fw-medium">16.5%</span><span>55.21 USD</span></p>
<!-- <p class="mb-0"><span class="text-success me-2 fw-medium">16.5%</span><span>55.21 USD</span></p> -->
</div>
</div>
<div class="vr"></div>
@@ -319,7 +319,7 @@
<div class="">
<p class="mb-1 fs-6 fw-bold">Tv-Series</p>
<h2 class="mb-0">{{this.watchCount.seriesTotal}}</h2>
<p class="mb-0"><span class="text-success me-2 fw-medium">24.9%</span><span>267.35 USD</span></p>
<!-- <p class="mb-0"><span class="text-success me-2 fw-medium">24.9%</span><span>267.35 USD</span></p> -->
</div>
</div>
</div>
@@ -3,7 +3,7 @@ import ApexCharts from 'apexcharts';
import { EntrySeenService } from '../../core/services/entry-seen.service';
import { LibraryService } from '../../core/services/library.service';
import { EpisodeSeenService } from '../../core/services/episode-seen.service';
import { Observable, forkJoin } from 'rxjs';
import { forkJoin } from 'rxjs';
@Component({
selector: 'app-home-page',
@@ -50,7 +50,7 @@
<!-- Match All Criteria -->
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="matchAllSwitch"
[(ngModel)]="filterCriteria.matchAll" (ngModelChange)="onFilterChange()">
[(ngModel)]="filterCriteria.matchAll" (click)="onFilterChange()" >
<label class="form-check-label" for="matchAllSwitch">Match All Criteria</label>
</div>
@@ -102,7 +102,7 @@
<div class="dataTables_info" role="status" aria-live="polite">
Total entries {{entriesCount}}
</div>
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage != 1 && entries.length != 0">
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage > 1 && entries.length != 0">
<ul class="pagination pagination-sm">
<li class="page-item" [class.disabled]="currentPage === 1">
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage - 1)">Previous</a>
@@ -125,7 +125,7 @@
<!-- Pagination -->
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage != 1 && entries.length != 0">
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage > 1 && entries.length != 0">
<ul class="pagination pagination-sm">
<li class="page-item" [class.disabled]="currentPage === 1">
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage - 1)">Previous</a>
@@ -105,6 +105,7 @@ export class LibraryComponent implements OnInit, AfterViewInit {
});
}
// ! FILTER
getQueryParameters() {
this.route.queryParams.subscribe((params) => {
this.currentPage = params['page'] ? parseInt(params['page'], 10) : 1;
@@ -133,46 +134,38 @@ export class LibraryComponent implements OnInit, AfterViewInit {
setQueryParameters() {
let params = { page: this.currentPage } as LibraryQueryParams;
// ? title
if (this.filterCriteria.title?.trim() != '') {
params.title = this.filterCriteria.title?.trim();
} else {
delete params.title;
}
// ? years
if (this.filterCriteria.years?.length) {
params.years = this.filterCriteria.years.join(',');
} else {
delete params.years;
}
// ? genres
if (this.filterCriteria.genres?.length) {
params.genres = this.filterCriteria.genres.join(',');
} else {
delete params.genres;
}
// ? type
if (this.filterCriteria.type != 0) {
params.type = this.filterCriteria.type;
} else {
delete params.type;
}
// ? favorit
if (this.filterCriteria.favorit != false) {
params.favorit = this.filterCriteria.favorit;
} else {
delete params.favorit;
}
// ? hidden
if (this.filterCriteria.hidden != false) {
params.hidden = this.filterCriteria.hidden;
} else {
delete params.hidden;
}
// ? matchAll
if (this.filterCriteria.matchAll != true) {
params.matchAll = this.filterCriteria.matchAll;
} else {
delete params.matchAll;
}
this.router.navigate([], {
@@ -182,7 +175,6 @@ export class LibraryComponent implements OnInit, AfterViewInit {
});
}
// ! FILTER
ngAfterViewInit() {
$('#year-select')
.select2({
@@ -244,14 +236,14 @@ export class LibraryComponent implements OnInit, AfterViewInit {
const formattedTitle =
this.filterCriteria.title?.toLowerCase().trim() || '';
temp = await this.entries.filter((entry) => {
// Type check
// * Type check
let filterType = this.filterCriteria.type - 1 == 0 ? false : true;
if (this.filterCriteria.type != 0 && filterType != entry.is_tvseries) {
return false; // Skip entry if the type does not match, unless type is 'all' (0)
}
// Hidden check
// skip hidden if show hidden is not check
// * Hidden check
// ? skip hidden if show hidden is not checked
if (!this.filterCriteria.hidden && entry.hidden) {
return false;
}
@@ -0,0 +1 @@
<p>settings-api-keys works!</p>
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SettingsApiKeysComponent } from './settings-api-keys.component';
describe('SettingsApiKeysComponent', () => {
let component: SettingsApiKeysComponent;
let fixture: ComponentFixture<SettingsApiKeysComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SettingsApiKeysComponent]
})
.compileComponents();
fixture = TestBed.createComponent(SettingsApiKeysComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-settings-api-keys',
templateUrl: './settings-api-keys.component.html',
styleUrl: './settings-api-keys.component.css'
})
export class SettingsApiKeysComponent {
}
@@ -0,0 +1,11 @@
.form-group {
margin-bottom: 1rem;
}
.is-invalid {
border-color: #dc3545;
}
.invalid-feedback {
display: block;
}
@@ -0,0 +1,65 @@
<form [formGroup]="settingsForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="userDataPath">User Data Path</label>
<input id="userDataPath" formControlName="userDataPath" type="text" class="form-control"
[ngClass]="{'is-invalid': f['userDataPath'].touched && f['userDataPath'].invalid}">
<div *ngIf="f['userDataPath'].touched && f['userDataPath'].invalid" class="invalid-feedback">
User Data Path is required.
</div>
</div>
<div class="form-group">
<label for="tmdbApiUrl">TMDB API URL</label>
<input id="tmdbApiUrl" formControlName="tmdbApiUrl" type="text" class="form-control"
[ngClass]="{'is-invalid': f['tmdbApiUrl'].touched && f['tmdbApiUrl'].invalid}">
<div *ngIf="f['tmdbApiUrl'].touched && f['tmdbApiUrl'].invalid" class="invalid-feedback">
TMDB API URL is required.
</div>
</div>
<div class="form-group">
<label for="tmdbApiKey">TMDB API Key</label>
<input id="tmdbApiKey" formControlName="tmdbApiKey" type="text" class="form-control"
[ngClass]="{'is-invalid': f['tmdbApiKey'].touched && f['tmdbApiKey'].invalid}">
<div *ngIf="f['tmdbApiKey'].touched && f['tmdbApiKey'].invalid" class="invalid-feedback">
TMDB API Key is required.
</div>
</div>
<div class="form-group">
<label for="frontPort">Front Port</label>
<input id="frontPort" formControlName="frontPort" type="text" class="form-control"
[ngClass]="{'is-invalid': f['frontPort'].touched && f['frontPort'].invalid}">
<div *ngIf="f['frontPort'].touched && f['frontPort'].invalid" class="invalid-feedback">
Front Port is required and must be a number.
</div>
</div>
<div class="form-group">
<label for="backPort">Back Port</label>
<input id="backPort" formControlName="backPort" type="text" class="form-control"
[ngClass]="{'is-invalid': f['backPort'].touched && f['backPort'].invalid}">
<div *ngIf="f['backPort'].touched && f['backPort'].invalid" class="invalid-feedback">
Back Port is required and must be a number.
</div>
</div>
<div class="form-group">
<label for="portableMode">Portable Mode</label>
<input id="portableMode" formControlName="portableMode" type="text" class="form-control"
[ngClass]="{'is-invalid': f['portableMode'].touched && f['portableMode'].invalid}">
<div *ngIf="f['portableMode'].touched && f['portableMode'].invalid" class="invalid-feedback">
Portable Mode is required.
</div>
</div>
<button type="submit" class="btn btn-primary" [disabled]="settingsForm.invalid">Submit</button>
</form>
<script>
document.getElementById('userDataPath').addEventListener('click', () => {
window.postMessage({
type: 'select-dirs'
})
})
</script>
@@ -1,18 +1,18 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SettingsComponent } from './settings.component';
import { SettingsGeneralComponent } from './settings-general.component';
describe('SettingsComponent', () => {
let component: SettingsComponent;
let fixture: ComponentFixture<SettingsComponent>;
describe('SettingsGeneralComponent', () => {
let component: SettingsGeneralComponent;
let fixture: ComponentFixture<SettingsGeneralComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SettingsComponent]
imports: [SettingsGeneralComponent]
})
.compileComponents();
fixture = TestBed.createComponent(SettingsComponent);
fixture = TestBed.createComponent(SettingsGeneralComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
@@ -0,0 +1,72 @@
import { Component, OnInit } from '@angular/core';
import { Settings } from '../../../shared/models/settings.model';
import { SettingsService } from '../../../core/services/settings.service';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-settings-general',
templateUrl: './settings-general.component.html',
styleUrl: './settings-general.component.css',
})
export class SettingsGeneralComponent implements OnInit {
settings: Settings = {} as Settings;
settingsForm!: FormGroup;
constructor(
private settingsService: SettingsService,
private fb: FormBuilder
) {}
ngOnInit(): void {
this.settingsForm = this.fb.group({
userDataPath: [this.settings.userDataPath],
tmdbApiUrl: [this.settings.tmdbApiUrl],
tmdbApiKey: [this.settings.tmdbApiKey, Validators.required],
frontPort: [this.settings.frontPort, Validators.pattern('^[0-9]{4,5}$')],
backPort: [
this.settings.backPort,
[Validators.required, Validators.pattern('^[0-9]{4,5}$')],
],
portableMode: [this.settings.portableMode],
});
this.settingsService.getSettings().subscribe({
next: (s) => {
this.settings = s;
// Update the form with fetched settings
this.settingsForm.patchValue({
userDataPath: this.settings.userDataPath,
tmdbApiUrl: this.settings.tmdbApiUrl,
tmdbApiKey: this.settings.tmdbApiKey,
frontPort: this.settings.frontPort,
backPort: this.settings.backPort,
portableMode: this.settings.portableMode,
});
},
error: (error) => {
console.log(`Error getting settings...`);
},
});
}
get f() {
return this.settingsForm.controls;
}
onSubmit(): void {
if (this.settingsForm.valid) {
const settings: Settings = this.settingsForm.value;
this.settingsService.updateSettings(settings).subscribe({
next: (s) => {
// TODO: SHOW SUCCESS TOAST
console.log(`Settings updated: `);
},
error: (error) => {
// TODO: SHOW ERROR TOAST
console.log(`Error updating settings: `, error);
},
});
}
}
}
@@ -0,0 +1,51 @@
<div class="card mb-0" style="height: 82vh;">
<div class="card-body">
<div id="settingsStepper" class="bs-stepper gap-4 vertical">
<!-- ! STEPPER HEADERS -->
<div class="bs-stepper-header" role="tablist" style="height: 78vh;">
<!-- ? step 1 -->
<div class="step" data-target="#test-vl-1" (click)="setStep(1)" [ngClass]="{ 'active': step == 1 }">
<div class="step-trigger" role="tab" aria-controls="test-vl-3" aria-selected="true">
<div class="bs-stepper-circle"><i class="material-icons-outlined">settings</i></div>
<div class="">
<h5 class="mb-0 steper-title">Application Settings</h5>
<p class="mb-0 steper-sub-title">General application settings</p>
</div>
</div>
</div>
<!-- ? step 1 -->
<div class="step" data-target="#test-vl-1" (click)="setStep(2)" [ngClass]="{ 'active': step == 2 }">
<div class="step-trigger" role="tab" aria-controls="test-vl-3" aria-selected="true">
<div class="bs-stepper-circle"><i class="material-icons-outlined">key</i></div>
<div class="">
<h5 class="mb-0 steper-title">API keys</h5>
<p class="mb-0 steper-sub-title">Setup your API keys</p>
</div>
</div>
</div>
</div>
<!-- ! STEPPER CONTENT -->
<div class="bs-stepper-content w-100">
<!-- ? step 1 -->
<div id="test-vl-3" class="bs-stepper-pane content fade dstepper-block" [ngClass]="{ 'active': step == 1 }"
*ngIf="step == 1">
<h5 class="mb-1">Application Settings</h5>
<p class="mb-4">General application settings</p>
<app-settings-general></app-settings-general>
</div>
<!-- ? step 2 -->
<div id="test-vl-3" class="bs-stepper-pane content fade dstepper-block" [ngClass]="{ 'active': step == 2 }"
*ngIf="step == 2">
<h5 class="mb-1">API keys</h5>
<p class="mb-4">Setup your API keys</p>
<app-settings-api-keys></app-settings-api-keys>
</div>
</div>
</div>
</div>
</div>
@@ -0,0 +1,30 @@
import { AfterViewInit, ChangeDetectorRef, Component } from '@angular/core';
@Component({
selector: 'app-settings-page',
templateUrl: './settings-page.component.html',
styleUrl: './settings-page.component.css',
})
export class SettingsPageComponent implements AfterViewInit {
// stepper!: Stepper;
step: number = 1;
constructor(private cdRef: ChangeDetectorRef) {}
ngAfterViewInit() {
// const stepperElement = document.querySelector('#settingsStepper');
// if (stepperElement) {
// this.stepper = new Stepper(stepperElement, {
// linear: false,
// animation: true,
// });
// this.cdRef.detectChanges();
// } else {
// console.error('Stepper element not found!');
// }
}
setStep(step: number) {
this.step = step;
}
}
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SettingsPageComponent } from './settings-page/settings-page.component';
// ! /user-collections
const routes: Routes = [
{
path: '',
component: SettingsPageComponent,
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class SettingsRoutingModule {}
@@ -1,4 +0,0 @@
<!--breadcrumb-->
<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
<div class="breadcrumb-title pe-3">Settings</div>
</div>
@@ -1,10 +0,0 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-settings',
templateUrl: './settings.component.html',
styleUrl: './settings.component.css',
})
export class SettingsComponent {
constructor() {}
}
@@ -0,0 +1,33 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SharedModule } from '../../shared/shared.module';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { SettingsRoutingModule } from './settings-routing.module';
import { SettingsPageComponent } from './settings-page/settings-page.component';
import { SettingsGeneralComponent } from './settings-general/settings-general.component';
import { SettingsApiKeysComponent } from './settings-api-keys/settings-api-keys.component';
@NgModule({
imports: [
CommonModule,
SharedModule,
FormsModule,
ReactiveFormsModule,
SettingsRoutingModule,
DragDropModule,
],
declarations: [
SettingsPageComponent,
SettingsGeneralComponent,
SettingsApiKeysComponent,
],
exports: [],
})
export class SettingsModule {}
@@ -1,6 +1,6 @@
<div class="movie-card" [@fadeInOut]="animationDirection">
<div class="card-head">
<img class="card-img" [src]="posterPath" alt="Movie Poster">
<img class="card-img" [src]="posterPath" alt="Movie Poster" onerror="this.src='assets/images/default/default-poster.png'">
<div class="loading-overlay" *ngIf="lockActions" @animateDestroy>
<div class="d-flex justify-content-center align-items-center" style="height: 100%;">
@@ -37,8 +37,8 @@
</div>
<!-- card body : title, -->
<div class="card-body">
<a (click)="cardClick()" rel="noopener noreferrer">
<div class="card-body" (click)="cardClick()">
<a rel="noopener noreferrer">
<h3 class="card-title">{{ entry.title }}</h3>
</a>
<div class="card-info">
@@ -1,6 +1,5 @@
import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FormBuilder } from '@angular/forms';
@Component({
selector: 'app-confirm-modal',
@@ -0,0 +1,43 @@
<div class="card border-top border-3 border-primary rounded-0" style="margin-bottom: 0 !important;">
<div class="modal-header card-header py-3 px-4">
<h5 class="mb-0 text-primary">Watch Details</h5>
<button type="button" class="btn-close" (click)="onClose()" aria-label="Close"></button>
</div>
<div class="card-body p-4">
<form class="row g-3">
<div class="col-md-6 mb-3">
<label class="form-label">Seasons</label>
<select name="seasons" class="form-select" [(ngModel)]="selectedSeason" (change)="onSeasonChange($event)" aria-placeholder="Select a season">
<option value="" disabled selected>Select a season</option>
<option [ngValue]="season" *ngFor="let season of seasons">Season {{ season.season_number }}</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Episodes</label>
<select name="episodes" class="form-select" [(ngModel)]="selectedEpisode">
<option value="" disabled selected>Select an episode</option>
<option [ngValue]="episode" *ngFor="let episode of selectedSeason?.episodes">Episode {{ episode.episode_number }}</option>
</select>
</div>
<div class="col-md-12">
<label class="form-label">Seen With</label>
<textarea class="form-control rounded-0" [(ngModel)]="watchedWith" [ngModelOptions]="{ standalone: true }"
placeholder="Enter names" rows="3"></textarea>
</div>
<div class="col-md-12">
<label class="form-label">Date Watched</label>
<input type="text" class="form-control rounded-0" name="watch-date" [(ngModel)]="watchDate" id="myDatepicker">
</div>
<div class="col-md-12">
<div class="d-md-flex d-grid align-items-center gap-3">
<button type="button" class="btn btn-primary px-4 rounded-0" (click)="onConfirm()">OK</button>
<button type="button" class="btn btn-secondary px-4 rounded-0" (click)="onClose()">Cancel</button>
</div>
</div>
</form>
</div>
</div>
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { EpisodeSeenModalComponent } from './episode-seen-modal.component';
describe('EpisodeSeenModalComponent', () => {
let component: EpisodeSeenModalComponent;
let fixture: ComponentFixture<EpisodeSeenModalComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [EpisodeSeenModalComponent]
})
.compileComponents();
fixture = TestBed.createComponent(EpisodeSeenModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,133 @@
import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import {
trigger,
state,
style,
transition,
animate,
} from '@angular/animations';
import { formatDate } from '@angular/common';
import flatpickr from 'flatpickr';
import { Season } from '../../../models/season.model';
import { SeasonService } from '../../../../core/services/season.service';
import { Episode } from '../../../models/episode.models';
import { EpisodeSeenService } from '../../../../core/services/episode-seen.service';
@Component({
selector: 'app-episode-seen-modal',
templateUrl: './episode-seen-modal.component.html',
styleUrl: './episode-seen-modal.component.css',
animations: [
trigger('fadeInOut', [
state('in', style({ opacity: 1 })),
transition(':enter', [style({ opacity: 0 }), animate(600)]),
transition(':leave', [animate(600, style({ opacity: 0 }))]),
]),
trigger('scaleInOut', [
transition(':enter', [
state('in', style({ opacity: 1 })),
style({ transform: 'scale(0)' }),
animate('200ms ease-in-out', style({ transform: 'scale(1)' })),
]),
transition(':leave', [
animate('200ms ease-in-out', style({ transform: 'scale(0)' })),
]),
]),
],
})
export class EpisodeSeenModalComponent {
public entryId: number = 0;
public watchDate: string = '';
public watchedWith: string = '';
public seasons: Season[] = [];
public selectedSeason: Season | null = {} as Season;
public selectedEpisode: Episode | null = {} as Episode;
constructor(
public dialogRef: MatDialogRef<EpisodeSeenModalComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private seasonsService: SeasonService,
private episodeSeenService: EpisodeSeenService
) {}
ngOnInit(): void {
if (!this.data.entryId) return;
this.entryId = this.data.entryId;
this.seasonsService
.getSeasonsWithEpisodesByEntryId(this.data.entryId)
.subscribe({
next: (seasons) => {
this.seasons = seasons;
},
error: (error) => {
console.log(`Error gettings seasons: `, error);
},
});
flatpickr('#myDatepicker', {
inline: true,
defaultDate: this.watchDate,
altInput: true,
allowInput: false,
altFormat: 'F j, Y',
dateFormat: 'Y-m-d',
});
}
onSeasonChange(event: any): void {
this.selectedEpisode = null;
}
onConfirm(): void {
if (!this.selectedSeason) {
return;
}
if (!this.selectedEpisode) {
return;
}
if (!this.watchDate) {
return;
}
const date_seen = new Date(this.watchDate);
const seen_with = this.watchedWith.split('\n').join(', ');
this.episodeSeenService
.createEpisodeSeen(
this.entryId,
this.selectedEpisode?.id,
date_seen,
seen_with
)
.subscribe({
next: (episodeSeen) => {
if (episodeSeen) {
return this.dialogRef.close({
created: true,
// ? returning the season number so it can be used to refrech the-
// ? season card progress bar in the entry page
season_number: this.selectedSeason?.season_number,
});
}
},
error: (error) => {
console.log(`Episode seen create error: `, error);
// TODO show notification
},
});
this.dialogRef.close({
created: false,
});
}
onClose(): void {
this.dialogRef.close();
}
}
@@ -2,7 +2,6 @@
<div class="modal-header card-header py-3 px-4" >
<h5 class="mb-0 text-primary">Watch Details</h5>
<button type="button" class="btn-close" (click)="onClose()" aria-label="Close"></button>
</div>
<div class="card-body p-4">
<form class="row g-3">
@@ -43,7 +43,7 @@ export class SeenModalComponent implements OnInit {
) {}
ngOnInit(): void {
if (this.data == null) {
if (!this.data || !this.data.watchDate) {
// ? no initial data was passed: populate date field with current date
this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US');
} else {
@@ -0,0 +1,8 @@
export interface Settings {
userDataPath: string;
tmdbApiUrl: string;
tmdbApiKey: string;
frontPort: number;
backPort: number;
portableMode: string;
}
@@ -5,14 +5,6 @@ import { format } from 'date-fns';
name: 'dateFormat',
})
export class DateFormatPipe implements PipeTransform {
// transform(value: string): string {
// if (!value) return '';
// const date = new Date(value);
// const formatter = new Intl.DateTimeFormat('en-US', { month: 'long', day: '2-digit', year: 'numeric' });
// return formatter.format(date);
// }
transform(
value: Date | string | number,
formatString: string = 'yyyy-MM-dd'
+2 -2
View File
@@ -1,7 +1,6 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
// * modals
import { SeenModalComponent } from './components/modals/seen-modal/seen-modal.component';
import { ConfirmModalComponent } from './components/modals/confirm-modal/confirm-modal.component';
@@ -14,6 +13,7 @@ import { RatingModule } from 'ngx-bootstrap/rating';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CollectionEditModalComponent } from '../features/collections/user-collection-info/collection-edit-modal/collection-edit-modal.component';
import { FloatFormatPipe } from './pipes/float-format/float-format.pipe';
import { EpisodeSeenModalComponent } from './components/modals/episode-seen-modal/episode-seen-modal.component';
@NgModule({
imports: [
@@ -33,7 +33,7 @@ import { FloatFormatPipe } from './pipes/float-format/float-format.pipe';
SeenModalComponent,
CollectionEditModalComponent,
ConfirmModalComponent,
EpisodeSeenModalComponent,
],
exports: [
// * pipes