Random changes

This commit is contained in:
X4Lo committed 2024-10-21 16:06:32 +01:00
1 parent 7160669468
commit 0b1a1d989f
17 files changed
+205 -159

No files matched your search

@@ -19,7 +19,7 @@
<!-- filter -->
<div class="d-flex align-items-baseline gap-3 flex-wrap">
<div class="product-count d-flex align-items-center gap-3 gap-lg-4 mb-4 fw-medium flex-wrap font-text1">
<div class="product-count d-flex align-items-center gap-3 gap-lg-4 mb-3 fw-medium flex-wrap font-text1">
<a href="javascript:;" (click)="onEntryTypeChange(0)"><span class="me-1">All</span><span
class="text-secondary">({{entries.length}})</span></a>
<a href="javascript:;" (click)="onEntryTypeChange(1)"><span class="me-1">Movies</span><span
@@ -1,11 +1,10 @@
import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core';
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { Entry } from '../../../shared/models/entry.model';
import { LibraryService } from '../../../core/services/library.service';
import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
import { ActivatedRoute, Event, Router } from '@angular/router';
import { LibraryQueryParams } from '../../../shared/models/library-query-params';
import { SettingsService } from '../../../core/services/settings.service';
import { Settings } from '../../../shared/models/settings.model';
import { ValueSetter } from 'date-fns/parse/_lib/Setter';
declare var $: any;
@Component({
@@ -267,6 +266,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
const formattedTitle =
this.filterCriteria.title?.toLowerCase().trim() || '';
temp = await this.entries.filter((entry) => {
// * Type check
let filterType = this.filterCriteria.type - 1 == 0 ? false : true;
@@ -308,6 +308,10 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
? entry.title.toLowerCase().includes(formattedTitle) ||
entry.original_title.toLowerCase().includes(formattedTitle)
: true) ||
(entry.network_studio
? entry.network_studio.toLowerCase() ==
formattedTitle.replace('studio:', '')
: true) ||
(this.filterCriteria.genres?.length &&
this.filterCriteria.genres.some((genre) =>
entry.genres.includes(genre)
@@ -319,6 +323,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
);
});
console.log(temp);
// ? sort filter
temp = await this.sortEntries(temp);
@@ -75,7 +75,7 @@
</div>
</div>
<div class="tab-pane fade" id="logos-content" role="tabpanel">
<div class="row row-cols-1 row-cols-md-2 g-4">
<div class="row row-cols-1 row-cols-md-5 g-4">
<div class="col" *ngFor="let media of filterMedia('logo')">
<div class="card image-hover-container">
<img [src]="getPath('logos', media)" class="card-img-top" alt="Media Image">
@@ -1,4 +1,5 @@
<div class="movie-card" [@fadeInOut]="animationDirection">
<div class="movie-card" [@fadeInOut]="animationDirection" appContextMenuTrigger
[menuOptions]="contextMenuOptions">
<div class="card-head">
<img class="card-img" [src]="posterPath" alt="Movie Poster"
onerror="this.src='assets/images/default/default-poster.png'">
@@ -13,6 +13,7 @@ import { LibraryService } from '../../../../core/services/library.service';
import { Router } from '@angular/router';
import { ConfirmModalComponent } from '../../modals/confirm-modal/confirm-modal.component';
import { environment } from '../../../../../environments/environment.prod';
import { CONTEXT_MENU_OPTIONS } from '../../../constants/context-menu-options';
@Component({
selector: 'app-main-card',
@@ -251,4 +252,22 @@ export class MainCardComponent implements OnInit {
if (this.entry.runtime == null) return '';
return this.entry.runtime;
}
get contextMenuOptions() {
let options = [];
// ? 1 - is in library
if (this.entry.isInLibrary) {
if (this.entry.watchlist) {
options.push(CONTEXT_MENU_OPTIONS.removeFromWatchlist);
} else {
options.push(CONTEXT_MENU_OPTIONS.addToWatchlist);
}
} else {
// ? 2 - not in library
options.push(CONTEXT_MENU_OPTIONS.addToLibrary);
}
return options;
}
}
@@ -1,3 +1,4 @@
import { Collection } from './collection.model';
import { Entry } from './entry.model';
export interface Media {
@@ -7,12 +8,15 @@ export interface Media {
mediaable: string;
mediaableId: number;
entry: Entry;
collection: Collection;
type: string;
path: string;
isLocal: boolean;
isSelected: boolean;
isCustom: boolean;
isFavorit: boolean;
createdAt: Date;
updatedAt: Date;
@@ -1,3 +1,4 @@
import { Entry } from './entry.model';
import { Episode } from './episode.models';
export interface Season {
@@ -9,6 +10,7 @@ export interface Season {
imdb_id: string;
entry_id: number;
entry: Entry;
name: string;
overview: string;
@@ -1,109 +0,0 @@
import {
Injectable,
ComponentFactoryResolver,
ApplicationRef,
Injector,
EmbeddedViewRef,
ComponentRef,
} from '@angular/core';
import { NotificationPopupComponent } from '../components/notification-popup/notification-popup.component';
@Injectable({
providedIn: 'root',
})
export class NotificationService {
private notificationComponents: ComponentRef<NotificationPopupComponent>[] =
[];
private notificationBottomMargin = 10; // Margin between notifications
private baseBottomPosition = 20; // Starting bottom position for the first notification
constructor(
private componentFactoryResolver: ComponentFactoryResolver,
private appRef: ApplicationRef,
private injector: Injector
) {}
public showNotification(
title: string,
message: string,
type: string = 'alert',
timeout: number = 5000
): void {
// Create a component reference for the notification
const componentRef = this.componentFactoryResolver
.resolveComponentFactory(NotificationPopupComponent)
.create(this.injector);
// Assign the message and type to the instance
componentRef.instance.title = title;
componentRef.instance.message = message;
componentRef.instance.type = type;
// Attach the component to the application
this.appRef.attachView(componentRef.hostView);
// Convert the component's host view into a DOM element and append it to the body
const domElem = (componentRef.hostView as EmbeddedViewRef<any>)
.rootNodes[0] as HTMLElement;
document.body.appendChild(domElem);
const position =
this.baseBottomPosition +
this.notificationComponents.length *
(domElem.offsetHeight + this.notificationBottomMargin);
domElem.style.bottom = `${position}px`;
domElem.style.position = 'fixed';
domElem.style.right = '20px';
// Store the component reference for later removal
this.notificationComponents.push(componentRef);
// Remove the notification after a delay
setTimeout(() => {
domElem.style.visibility = 'hidden';
}, timeout);
setTimeout(() => {
this.removeNotification(componentRef);
}, timeout + 1000); // Customize this value as needed
}
// private removeNotification(
// componentRef: ComponentRef<NotificationPopupComponent>
// ): void {
// this.appRef.detachView(componentRef.hostView);
// componentRef.destroy();
// this.notificationComponents = this.notificationComponents.filter(
// (c) => c !== componentRef
// );
// }
private removeNotification(
componentRef: ComponentRef<NotificationPopupComponent>
): void {
const domElem = (componentRef.hostView as EmbeddedViewRef<any>)
.rootNodes[0] as HTMLElement;
this.appRef.detachView(componentRef.hostView);
document.body.removeChild(domElem); // Make sure to remove the element from the body
componentRef.destroy();
// Filter out the destroyed notification
this.notificationComponents = this.notificationComponents.filter(
(c) => c !== componentRef
);
// Adjust positions of remaining notifications
this.adjustPositions();
}
private adjustPositions(): void {
// Start from the initial position again and reposition each remaining notification
this.notificationComponents.forEach((componentRef, index) => {
const domElem = (componentRef.hostView as EmbeddedViewRef<any>)
.rootNodes[0] as HTMLElement;
const position =
this.baseBottomPosition +
index * (domElem.offsetHeight + this.notificationBottomMargin);
domElem.style.bottom = `${position}px`;
});
}
}
@@ -0,0 +1,43 @@
import { Injectable } from '@angular/core';
import { ProgressAnimationType, ToastrService } from 'ngx-toastr';
@Injectable({
providedIn: 'root',
})
export class ToastService {
constructor(private toastr: ToastrService) {}
public show(title: string, message: string, type: string = 'success'): void {
const options = {
tapToDismiss: true,
progressBar: true,
positionClass: 'top-right',
progressAnimation: 'increasing' as ProgressAnimationType,
};
if (type == 'success') this.toastr.show(title, message, options);
else if (type == 'error') this.toastr.error(title, message, options);
else if (type == 'warning') this.toastr.warning(title, message, options);
else if (type == 'info') this.toastr.info(title, message, options);
}
public showWithOptions(
title: string,
message: string,
type: string = 'success',
extraOptions: any
): void {
const options = {
tapToDismiss: true,
progressBar: true,
positionClass: 'top-right',
progressAnimation: 'increasing' as ProgressAnimationType,
...extraOptions,
};
if (type == 'success') this.toastr.success(title, message, options);
else if (type == 'error') this.toastr.error(title, message, options);
else if (type == 'warning') this.toastr.warning(title, message, options);
else if (type == 'info') this.toastr.info(title, message, options);
}
}