mirror of https://github.com/Ombi-app/Ombi
commit
4db54dbd6b
@ -1,29 +1,29 @@
|
||||
<mat-card class="mat-elevation-z8 spacing-below">
|
||||
<mat-card-header>{{'MediaDetails.Casts.CastTitle' | translate}}</mat-card-header>
|
||||
<mat-card-content>
|
||||
<p-carousel [value]="cast" [numVisible]="5" easing="easeOutStrong">
|
||||
<ng-template let-item pTemplate="item">
|
||||
<div class="row justify-content-md-center mat-card mat-card-flat">
|
||||
<div class="col-12">
|
||||
<a *ngIf="item.profile_path" [routerLink]="'/discover/actor/' + item.id">
|
||||
<img class="cast-profile-img" src="https://image.tmdb.org/t/p/w300/{{item.profile_path}}">
|
||||
</a>
|
||||
<a *ngIf="item.character?.image?.medium" [routerLink]="'/discover/actor/' + item.person.id">
|
||||
<img class="cast-profile-img" [src]="item.character.image.medium">
|
||||
</a>
|
||||
<!-- TODO get profile image default -->
|
||||
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<span *ngIf="!item.character?.name"><strong>{{'MediaDetails.Casts.Character' | translate}}:</strong> {{item.character}}</span>
|
||||
<span *ngIf="item.character.name"><strong>{{'MediaDetails.Casts.Character' | translate}}:</strong> {{item.character.name}}</span>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<span *ngIf="item.name"><strong>{{'MediaDetails.Casts.Actor' | translate}}:</strong> {{item.name}}</span>
|
||||
<span *ngIf="item.person?.name"><strong>{{'MediaDetails.Casts.Actor' | translate}}:</strong> {{item.person.name}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-carousel>
|
||||
<p-carousel [value]="cast" [numVisible]="5" easing="easeOutStrong">
|
||||
<ng-template let-item pTemplate="item">
|
||||
<div class="row justify-content-md-center mat-card mat-card-flat col-12 carousel-item">
|
||||
<div class="col-12 bottom-space">
|
||||
<a *ngIf="item.profile_path" [routerLink]="'/discover/actor/' + item.id">
|
||||
<img class="cast-profile-img" src="https://image.tmdb.org/t/p/w300/{{item.profile_path}}">
|
||||
</a>
|
||||
<a *ngIf="item.character?.image?.medium" [routerLink]="'/discover/actor/' + item.person.id">
|
||||
<img class="cast-profile-img" [src]="item.character.image.medium">
|
||||
</a>
|
||||
<!-- TODO get profile image default -->
|
||||
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<span *ngIf="!item.character?.name"><strong>{{'MediaDetails.Casts.Character' | translate}}:</strong> {{item.character}}</span>
|
||||
<span *ngIf="item.character.name"><strong>{{'MediaDetails.Casts.Character' | translate}}:</strong> {{item.character.name}}</span>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<span *ngIf="item.name"><strong>{{'MediaDetails.Casts.Actor' | translate}}:</strong> {{item.name}}</span>
|
||||
<span *ngIf="item.person?.name"><strong>{{'MediaDetails.Casts.Actor' | translate}}:</strong> {{item.person.name}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-carousel>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-card>
|
@ -1,7 +1,64 @@
|
||||
@import "~@angular/material/theming";
|
||||
@import "~styles/variables.scss";
|
||||
.actor-background {
|
||||
.dark & {
|
||||
background: $backgroundTint-dark;
|
||||
}
|
||||
}
|
||||
::ng-deep body .ui-carousel .ui-carousel-content .ui-carousel-prev,
|
||||
body .ui-carousel .ui-carousel-content .ui-carousel-next {
|
||||
background-color: #ffffff;
|
||||
border: solid 1px rgba(178, 193, 205, 0.64);
|
||||
-moz-border-radius: 50%;
|
||||
-webkit-border-radius: 50%;
|
||||
border-radius: 50%;
|
||||
margin: 0.2em;
|
||||
color: #333333;
|
||||
-moz-transition: color 0.2s;
|
||||
-o-transition: color 0.2s;
|
||||
-webkit-transition: color 0.2s;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
::ng-deep body .ui-carousel .ui-carousel-content .ui-carousel-prev:not(.ui-state-disabled):hover,
|
||||
body .ui-carousel .ui-carousel-content .ui-carousel-next:not(.ui-state-disabled):hover {
|
||||
background-color: #ffffff;
|
||||
color: #000;
|
||||
border-color: solid 1px rgba(178, 193, 205, 0.64);
|
||||
}
|
||||
|
||||
::ng-deep body .ui-carousel .ui-carousel-dots-container .ui-carousel-dot-item>.ui-button {
|
||||
border-color: transparent;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
::ng-deep body .ui-carousel .ui-carousel-dots-container .ui-carousel-dot-item .ui-carousel-dot-icon {
|
||||
width: 20px;
|
||||
height: 6px;
|
||||
background-color: rgba(255, 255, 255, 0.44);
|
||||
margin: 0 0.2em;
|
||||
}
|
||||
|
||||
::ng-deep body .ui-carousel .ui-carousel-dots-container .ui-carousel-dot-item .ui-carousel-dot-icon::before {
|
||||
content: " ";
|
||||
}
|
||||
|
||||
::ng-deep body .ui-carousel .ui-carousel-dots-container .ui-carousel-dot-item.ui-state-highlight .ui-carousel-dot-icon {
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.carousel-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
::ng-deep .ui-carousel-next {
|
||||
background-color: #ffffff;
|
||||
border: solid 1px rgba(178, 193, 205, 0.64);
|
||||
border-radius: 50%;
|
||||
margin: 0.2em;
|
||||
color: #333333;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
::ng-deep .ui-carousel-content button:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
padding-bottom: 10px;
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
<h1>Recently Added</h1>
|
||||
<input type="checkbox" [(ngModel)]="groupTv" (click)="change()" />
|
||||
<hr />
|
||||
<p-calendar [(ngModel)]="range" showButtonBar="true" selectionMode="range" (onClose)="close()"></p-calendar>
|
||||
<hr />
|
||||
<style>
|
||||
.img-conatiner {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Bottom left text */
|
||||
.bottom-left {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
left: 16px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<ngu-carousel [inputs]="carouselTile">
|
||||
<ngu-tile NguCarouselItem *ngFor="let movie of movies">
|
||||
<div class="img-container">
|
||||
<img class="img-responsive poster" src="{{movie.posterPath}}" style="width: 300px" alt="poster">
|
||||
<div class="bottom-left"> {{movie.title}}</div>
|
||||
</div>
|
||||
|
||||
|
||||
</ngu-tile>
|
||||
|
||||
<button NguCarouselPrev class='leftRs'><i class="fa fa-arrow-left"></i></button>
|
||||
<button NguCarouselNext class='rightRs'><i class="fa fa-arrow-right"></i></button>
|
||||
</ngu-carousel>
|
||||
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<ngu-carousel [inputs]="carouselTile">
|
||||
<ngu-tile NguCarouselItem *ngFor="let t of tv">
|
||||
<img class="img-responsive poster" src="{{t.posterPath}}" style="width: 300px" alt="poster">
|
||||
<b>{{t.title}}</b>
|
||||
<br>
|
||||
<b>Season: {{t.seasonNumber}}</b>
|
||||
<br>
|
||||
<b>Episode: {{t.episodeNumber}}</b>
|
||||
</ngu-tile>
|
||||
|
||||
<button NguCarouselPrev class='leftRs'><i class="fa fa-arrow-left"></i></button>
|
||||
<button NguCarouselNext class='rightRs'><i class="fa fa-arrow-right"></i></button>
|
||||
</ngu-carousel>
|
@ -1,131 +0,0 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { NguCarouselConfig } from "@ngu/carousel";
|
||||
|
||||
import { IRecentlyAddedMovies, IRecentlyAddedTvShows } from "../interfaces";
|
||||
import { ImageService, RecentlyAddedService } from "../services";
|
||||
|
||||
@Component({
|
||||
templateUrl: "recentlyAdded.component.html",
|
||||
styles: [`
|
||||
.leftRs {
|
||||
position: absolute;
|
||||
margin: auto;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
box-shadow: 1px 2px 10px -1px rgba(0, 0, 0, .3);
|
||||
border-radius: 100%;
|
||||
left: 0;
|
||||
background: #df691a;
|
||||
}
|
||||
|
||||
.rightRs {
|
||||
position: absolute;
|
||||
margin: auto;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
box-shadow: 1px 2px 10px -1px rgba(0, 0, 0, .3);
|
||||
border-radius: 100%;
|
||||
right: 0;
|
||||
background: #df691a;
|
||||
}
|
||||
`],
|
||||
})
|
||||
|
||||
export class RecentlyAddedComponent implements OnInit {
|
||||
public movies: IRecentlyAddedMovies[];
|
||||
public tv: IRecentlyAddedTvShows[];
|
||||
public range: Date[];
|
||||
|
||||
public groupTv: boolean = false;
|
||||
|
||||
// https://github.com/sheikalthaf/ngu-carousel
|
||||
public carouselTile: NguCarouselConfig;
|
||||
|
||||
constructor(private recentlyAddedService: RecentlyAddedService,
|
||||
private imageService: ImageService) {}
|
||||
|
||||
public ngOnInit() {
|
||||
this.getMovies();
|
||||
this.getShows();
|
||||
|
||||
this.carouselTile = {
|
||||
grid: {xs: 2, sm: 3, md: 3, lg: 5, all: 0},
|
||||
slide: 2,
|
||||
speed: 400,
|
||||
animation: "lazy",
|
||||
point: {
|
||||
visible: true,
|
||||
},
|
||||
load: 2,
|
||||
touch: true,
|
||||
easing: "ease",
|
||||
};
|
||||
}
|
||||
|
||||
public close() {
|
||||
if (this.range.length < 2) {
|
||||
return;
|
||||
}
|
||||
if (!this.range[1]) {
|
||||
// If we do not have a second date then just set it to now
|
||||
this.range[1] = new Date();
|
||||
}
|
||||
this.getMovies();
|
||||
}
|
||||
|
||||
public change() {
|
||||
this.getShows();
|
||||
}
|
||||
|
||||
private getShows() {
|
||||
if (this.groupTv) {
|
||||
this.recentlyAddedService.getRecentlyAddedTvGrouped().subscribe(x => {
|
||||
this.tv = x;
|
||||
|
||||
this.tv.forEach((t) => {
|
||||
this.imageService.getTvPoster(t.tvDbId).subscribe(p => {
|
||||
if (p) {
|
||||
t.posterPath = p;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.recentlyAddedService.getRecentlyAddedTv().subscribe(x => {
|
||||
this.tv = x;
|
||||
|
||||
this.tv.forEach((t) => {
|
||||
this.imageService.getTvPoster(t.tvDbId).subscribe(p => {
|
||||
if (p) {
|
||||
t.posterPath = p;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private getMovies() {
|
||||
this.recentlyAddedService.getRecentlyAddedMovies().subscribe(x => {
|
||||
this.movies = x;
|
||||
|
||||
this.movies.forEach((movie) => {
|
||||
if (movie.theMovieDbId) {
|
||||
this.imageService.getMoviePoster(movie.theMovieDbId).subscribe(p => {
|
||||
movie.posterPath = p;
|
||||
});
|
||||
} else if (movie.imdbId) {
|
||||
this.imageService.getMoviePoster(movie.imdbId).subscribe(p => {
|
||||
movie.posterPath = p;
|
||||
});
|
||||
} else {
|
||||
movie.posterPath = "";
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -1,386 +1,386 @@
|
||||
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
|
||||
import { Component, Input, OnInit, Inject } from "@angular/core";
|
||||
import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { Subject } from "rxjs";
|
||||
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
||||
|
||||
import { AuthService } from "../auth/auth.service";
|
||||
import { FilterType, IFilter, IIssueCategory, IMovieRequests, IPagenator, IRadarrProfile, IRadarrRootFolder, OrderType } from "../interfaces";
|
||||
import { NotificationService, RadarrService, RequestService } from "../services";
|
||||
|
||||
@Component({
|
||||
selector: "movie-requests",
|
||||
templateUrl: "./movierequests.component.html",
|
||||
})
|
||||
export class MovieRequestsComponent implements OnInit {
|
||||
public movieRequests: IMovieRequests[];
|
||||
public defaultPoster: string;
|
||||
|
||||
public searchChanged: Subject<string> = new Subject<string>();
|
||||
public searchText: string;
|
||||
|
||||
public isAdmin: boolean; // Also PowerUser
|
||||
|
||||
public radarrProfiles: IRadarrProfile[];
|
||||
public radarrRootFolders: IRadarrRootFolder[];
|
||||
|
||||
@Input() public issueCategories: IIssueCategory[];
|
||||
@Input() public issuesEnabled: boolean;
|
||||
public issuesBarVisible = false;
|
||||
public issueRequest: IMovieRequests;
|
||||
public issueProviderId: string;
|
||||
public issueCategorySelected: IIssueCategory;
|
||||
|
||||
public filterDisplay: boolean;
|
||||
public filter: IFilter;
|
||||
public filterType = FilterType;
|
||||
|
||||
public orderType: OrderType = OrderType.RequestedDateDesc;
|
||||
public OrderType = OrderType;
|
||||
public denyDisplay: boolean;
|
||||
public requestToDeny: IMovieRequests;
|
||||
public rejectionReason: string;
|
||||
|
||||
public totalMovies: number = 100;
|
||||
public currentlyLoaded: number;
|
||||
private amountToLoad: number;
|
||||
private href: string;
|
||||
|
||||
constructor(
|
||||
private requestService: RequestService,
|
||||
private auth: AuthService,
|
||||
private notificationService: NotificationService,
|
||||
private radarrService: RadarrService,
|
||||
private sanitizer: DomSanitizer,
|
||||
@Inject(APP_BASE_HREF) href:string) {
|
||||
this.href = href;
|
||||
this.searchChanged.pipe(
|
||||
debounceTime(600), // Wait Xms after the last event before emitting last event
|
||||
distinctUntilChanged(), // only emit if value is different from previous value
|
||||
).subscribe(x => {
|
||||
this.searchText = x as string;
|
||||
if (this.searchText === "") {
|
||||
this.resetSearch();
|
||||
return;
|
||||
}
|
||||
this.requestService.searchMovieRequests(this.searchText)
|
||||
.subscribe(m => {
|
||||
this.setOverrides(m);
|
||||
this.movieRequests = m;
|
||||
});
|
||||
});
|
||||
this.defaultPoster = "../../../images/default_movie_poster.png";
|
||||
const base = this.href;
|
||||
if (base) {
|
||||
this.defaultPoster = "../../.." + base + "/images/default_movie_poster.png";
|
||||
}
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.amountToLoad = 10;
|
||||
this.currentlyLoaded = 10;
|
||||
this.filter = {
|
||||
availabilityFilter: FilterType.None,
|
||||
statusFilter: FilterType.None,
|
||||
};
|
||||
this.loadInit();
|
||||
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
|
||||
}
|
||||
|
||||
public paginate(event: IPagenator) {
|
||||
const skipAmount = event.first;
|
||||
this.loadRequests(this.amountToLoad, skipAmount);
|
||||
}
|
||||
|
||||
public search(text: any) {
|
||||
this.searchChanged.next(text.target.value);
|
||||
}
|
||||
|
||||
public removeRequest(request: IMovieRequests) {
|
||||
this.requestService.removeMovieRequest(request.id);
|
||||
this.removeRequestFromUi(request);
|
||||
this.loadRequests(this.amountToLoad, this.currentlyLoaded = 0);
|
||||
}
|
||||
|
||||
public changeAvailability(request: IMovieRequests, available: boolean) {
|
||||
request.available = available;
|
||||
|
||||
if (available) {
|
||||
this.requestService.markMovieAvailable({ id: request.id }).subscribe(x => {
|
||||
if (x.result) {
|
||||
this.notificationService.success(
|
||||
`${request.title} Is now available`);
|
||||
} else {
|
||||
this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||
request.approved = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.requestService.markMovieUnavailable({ id: request.id }).subscribe(x => {
|
||||
if (x.result) {
|
||||
this.notificationService.success(
|
||||
`${request.title} Is now unavailable`);
|
||||
} else {
|
||||
this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||
request.approved = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public approve(request: IMovieRequests) {
|
||||
request.approved = true;
|
||||
this.approveRequest(request);
|
||||
}
|
||||
|
||||
public deny(request: IMovieRequests) {
|
||||
this.requestToDeny = request;
|
||||
this.denyDisplay = true;
|
||||
}
|
||||
|
||||
public denyRequest() {
|
||||
this.requestService.denyMovie({ id: this.requestToDeny.id, reason: this.rejectionReason })
|
||||
.subscribe(x => {
|
||||
this.denyDisplay = false;
|
||||
if (x.result) {
|
||||
this.notificationService.success(
|
||||
`Request for ${this.requestToDeny.title} has been denied successfully`);
|
||||
const index = this.movieRequests.indexOf(this.requestToDeny, 0);
|
||||
if (index > -1) {
|
||||
this.movieRequests[index].denied = true;
|
||||
}
|
||||
} else {
|
||||
this.notificationService.warning("Request Denied", x.message ? x.message : x.errorMessage);
|
||||
this.requestToDeny.denied = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public selectRootFolder(searchResult: IMovieRequests, rootFolderSelected: IRadarrRootFolder, event: any) {
|
||||
event.preventDefault();
|
||||
searchResult.rootPathOverride = rootFolderSelected.id;
|
||||
this.setOverride(searchResult);
|
||||
this.updateRequest(searchResult);
|
||||
}
|
||||
|
||||
public selectQualityProfile(searchResult: IMovieRequests, profileSelected: IRadarrProfile, event: any) {
|
||||
event.preventDefault();
|
||||
searchResult.qualityOverride = profileSelected.id;
|
||||
this.setOverride(searchResult);
|
||||
this.updateRequest(searchResult);
|
||||
}
|
||||
|
||||
public reportIssue(catId: IIssueCategory, req: IMovieRequests) {
|
||||
this.issueRequest = req;
|
||||
this.issueCategorySelected = catId;
|
||||
this.issuesBarVisible = true;
|
||||
this.issueProviderId = req.theMovieDbId.toString();
|
||||
}
|
||||
|
||||
public ignore(event: any): void {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
public clearFilter(el: any) {
|
||||
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
el = el.parentElement;
|
||||
el = el.querySelectorAll("INPUT");
|
||||
for (el of el) {
|
||||
el.checked = false;
|
||||
el.parentElement.classList.remove("active");
|
||||
}
|
||||
|
||||
this.filterDisplay = false;
|
||||
this.filter.availabilityFilter = FilterType.None;
|
||||
this.filter.statusFilter = FilterType.None;
|
||||
|
||||
this.resetSearch();
|
||||
}
|
||||
|
||||
public filterAvailability(filter: FilterType, el: any) {
|
||||
this.filterActiveStyle(el);
|
||||
this.filter.availabilityFilter = filter;
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
public filterStatus(filter: FilterType, el: any) {
|
||||
this.filterActiveStyle(el);
|
||||
this.filter.statusFilter = filter;
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
public setOrder(value: OrderType, el: any) {
|
||||
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
const parent = el.parentElement;
|
||||
const previousFilter = parent.querySelector(".active");
|
||||
|
||||
previousFilter.className = "";
|
||||
el.className = "active";
|
||||
|
||||
this.orderType = value;
|
||||
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
public subscribe(request: IMovieRequests) {
|
||||
request.subscribed = true;
|
||||
this.requestService.subscribeToMovie(request.id)
|
||||
.subscribe(x => {
|
||||
this.notificationService.success("Subscribed To Movie!");
|
||||
});
|
||||
}
|
||||
|
||||
public unSubscribe(request: IMovieRequests) {
|
||||
request.subscribed = false;
|
||||
this.requestService.unSubscribeToMovie(request.id)
|
||||
.subscribe(x => {
|
||||
this.notificationService.success("Unsubscribed Movie!");
|
||||
});
|
||||
}
|
||||
|
||||
public isRequestUser(request: IMovieRequests) {
|
||||
if (request.requestedUser.userName === this.auth.claims().name) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private filterActiveStyle(el: any) {
|
||||
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
el = el.parentElement; //gets radio div
|
||||
el = el.parentElement; //gets form group div
|
||||
el = el.parentElement; //gets status filter div
|
||||
el = el.querySelectorAll("INPUT");
|
||||
for (el of el) {
|
||||
if (el.checked) {
|
||||
if (!el.parentElement.classList.contains("active")) {
|
||||
el.parentElement.className += " active";
|
||||
}
|
||||
} else {
|
||||
el.parentElement.classList.remove("active");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private loadRequests(amountToLoad: number, currentlyLoaded: number) {
|
||||
this.requestService.getMovieRequests(amountToLoad, currentlyLoaded, this.orderType, this.filter)
|
||||
.subscribe(x => {
|
||||
this.setOverrides(x.collection);
|
||||
if (!this.movieRequests) {
|
||||
this.movieRequests = [];
|
||||
}
|
||||
this.movieRequests = x.collection;
|
||||
this.totalMovies = x.total;
|
||||
this.currentlyLoaded = currentlyLoaded + amountToLoad;
|
||||
});
|
||||
}
|
||||
|
||||
private updateRequest(request: IMovieRequests) {
|
||||
this.requestService.updateMovieRequest(request)
|
||||
.subscribe(x => {
|
||||
this.setOverride(x);
|
||||
request = x;
|
||||
});
|
||||
}
|
||||
|
||||
private approveRequest(request: IMovieRequests) {
|
||||
this.requestService.approveMovie({ id: request.id })
|
||||
.subscribe(x => {
|
||||
request.approved = true;
|
||||
if (x.result) {
|
||||
this.notificationService.success(
|
||||
`Request for ${request.title} has been approved successfully`);
|
||||
} else {
|
||||
this.notificationService.warning("Request Approved", x.message ? x.message : x.errorMessage);
|
||||
request.approved = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private loadInit() {
|
||||
this.requestService.getMovieRequests(this.amountToLoad, 0, this.orderType, this.filter)
|
||||
.subscribe(x => {
|
||||
this.movieRequests = x.collection;
|
||||
this.totalMovies = x.total;
|
||||
|
||||
this.movieRequests.forEach((req) => {
|
||||
this.setBackground(req);
|
||||
this.setPoster(req);
|
||||
});
|
||||
if (this.isAdmin) {
|
||||
this.radarrService.getQualityProfilesFromSettings().subscribe(c => {
|
||||
this.radarrProfiles = c;
|
||||
this.movieRequests.forEach((req) => this.setQualityOverrides(req));
|
||||
});
|
||||
this.radarrService.getRootFoldersFromSettings().subscribe(c => {
|
||||
this.radarrRootFolders = c;
|
||||
this.movieRequests.forEach((req) => this.setRootFolderOverrides(req));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private resetSearch() {
|
||||
this.currentlyLoaded = 5;
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
private removeRequestFromUi(key: IMovieRequests) {
|
||||
const index = this.movieRequests.indexOf(key, 0);
|
||||
if (index > -1) {
|
||||
this.movieRequests.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private setOverrides(requests: IMovieRequests[]): void {
|
||||
requests.forEach((req) => {
|
||||
this.setOverride(req);
|
||||
});
|
||||
}
|
||||
|
||||
private setQualityOverrides(req: IMovieRequests): void {
|
||||
if (this.radarrProfiles) {
|
||||
const profile = this.radarrProfiles.filter((p) => {
|
||||
return p.id === req.qualityOverride;
|
||||
});
|
||||
if (profile.length > 0) {
|
||||
req.qualityOverrideTitle = profile[0].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
private setRootFolderOverrides(req: IMovieRequests): void {
|
||||
if (this.radarrRootFolders) {
|
||||
const path = this.radarrRootFolders.filter((folder) => {
|
||||
return folder.id === req.rootPathOverride;
|
||||
});
|
||||
if (path.length > 0) {
|
||||
req.rootPathOverrideTitle = path[0].path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setOverride(req: IMovieRequests): void {
|
||||
this.setPoster(req);
|
||||
this.setBackground(req);
|
||||
this.setQualityOverrides(req);
|
||||
this.setRootFolderOverrides(req);
|
||||
}
|
||||
|
||||
private setPoster(req: IMovieRequests): void {
|
||||
if (req.posterPath === null) {
|
||||
req.posterPath = this.defaultPoster;
|
||||
} else {
|
||||
req.posterPath = "https://image.tmdb.org/t/p/w300/" + req.posterPath;
|
||||
}
|
||||
}
|
||||
|
||||
private setBackground(req: IMovieRequests): void {
|
||||
req.backgroundPath = this.sanitizer.bypassSecurityTrustStyle
|
||||
("url(" + "https://image.tmdb.org/t/p/w1280" + req.background + ")");
|
||||
}
|
||||
|
||||
}
|
||||
// import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
|
||||
// import { Component, Input, OnInit, Inject } from "@angular/core";
|
||||
// import { DomSanitizer } from "@angular/platform-browser";
|
||||
// import { Subject } from "rxjs";
|
||||
// import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
||||
|
||||
// import { AuthService } from "../auth/auth.service";
|
||||
// import { FilterType, IFilter, IIssueCategory, IMovieRequests, IPagenator, IRadarrProfile, IRadarrRootFolder, OrderType } from "../interfaces";
|
||||
// import { NotificationService, RadarrService, RequestService } from "../services";
|
||||
|
||||
// @Component({
|
||||
// selector: "movie-requests",
|
||||
// templateUrl: "./movierequests.component.html",
|
||||
// })
|
||||
// export class MovieRequestsComponent implements OnInit {
|
||||
// public movieRequests: IMovieRequests[];
|
||||
// public defaultPoster: string;
|
||||
|
||||
// public searchChanged: Subject<string> = new Subject<string>();
|
||||
// public searchText: string;
|
||||
|
||||
// public isAdmin: boolean; // Also PowerUser
|
||||
|
||||
// public radarrProfiles: IRadarrProfile[];
|
||||
// public radarrRootFolders: IRadarrRootFolder[];
|
||||
|
||||
// @Input() public issueCategories: IIssueCategory[];
|
||||
// @Input() public issuesEnabled: boolean;
|
||||
// public issuesBarVisible = false;
|
||||
// public issueRequest: IMovieRequests;
|
||||
// public issueProviderId: string;
|
||||
// public issueCategorySelected: IIssueCategory;
|
||||
|
||||
// public filterDisplay: boolean;
|
||||
// public filter: IFilter;
|
||||
// public filterType = FilterType;
|
||||
|
||||
// public orderType: OrderType = OrderType.RequestedDateDesc;
|
||||
// public OrderType = OrderType;
|
||||
// public denyDisplay: boolean;
|
||||
// public requestToDeny: IMovieRequests;
|
||||
// public rejectionReason: string;
|
||||
|
||||
// public totalMovies: number = 100;
|
||||
// public currentlyLoaded: number;
|
||||
// private amountToLoad: number;
|
||||
// private href: string;
|
||||
|
||||
// constructor(
|
||||
// private requestService: RequestService,
|
||||
// private auth: AuthService,
|
||||
// private notificationService: NotificationService,
|
||||
// private radarrService: RadarrService,
|
||||
// private sanitizer: DomSanitizer,
|
||||
// @Inject(APP_BASE_HREF) href:string) {
|
||||
// this.href = href;
|
||||
// this.searchChanged.pipe(
|
||||
// debounceTime(600), // Wait Xms after the last event before emitting last event
|
||||
// distinctUntilChanged(), // only emit if value is different from previous value
|
||||
// ).subscribe(x => {
|
||||
// this.searchText = x as string;
|
||||
// if (this.searchText === "") {
|
||||
// this.resetSearch();
|
||||
// return;
|
||||
// }
|
||||
// this.requestService.searchMovieRequests(this.searchText)
|
||||
// .subscribe(m => {
|
||||
// this.setOverrides(m);
|
||||
// this.movieRequests = m;
|
||||
// });
|
||||
// });
|
||||
// this.defaultPoster = "../../../images/default_movie_poster.png";
|
||||
// const base = this.href;
|
||||
// if (base) {
|
||||
// this.defaultPoster = "../../.." + base + "/images/default_movie_poster.png";
|
||||
// }
|
||||
// }
|
||||
|
||||
// public ngOnInit() {
|
||||
// this.amountToLoad = 10;
|
||||
// this.currentlyLoaded = 10;
|
||||
// this.filter = {
|
||||
// availabilityFilter: FilterType.None,
|
||||
// statusFilter: FilterType.None,
|
||||
// };
|
||||
// this.loadInit();
|
||||
// this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
|
||||
// }
|
||||
|
||||
// public paginate(event: IPagenator) {
|
||||
// const skipAmount = event.first;
|
||||
// this.loadRequests(this.amountToLoad, skipAmount);
|
||||
// }
|
||||
|
||||
// public search(text: any) {
|
||||
// this.searchChanged.next(text.target.value);
|
||||
// }
|
||||
|
||||
// public removeRequest(request: IMovieRequests) {
|
||||
// this.requestService.removeMovieRequest(request.id);
|
||||
// this.removeRequestFromUi(request);
|
||||
// this.loadRequests(this.amountToLoad, this.currentlyLoaded = 0);
|
||||
// }
|
||||
|
||||
// public changeAvailability(request: IMovieRequests, available: boolean) {
|
||||
// request.available = available;
|
||||
|
||||
// if (available) {
|
||||
// this.requestService.markMovieAvailable({ id: request.id }).subscribe(x => {
|
||||
// if (x.result) {
|
||||
// this.notificationService.success(
|
||||
// `${request.title} Is now available`);
|
||||
// } else {
|
||||
// this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||
// request.approved = false;
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// this.requestService.markMovieUnavailable({ id: request.id }).subscribe(x => {
|
||||
// if (x.result) {
|
||||
// this.notificationService.success(
|
||||
// `${request.title} Is now unavailable`);
|
||||
// } else {
|
||||
// this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||
// request.approved = false;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// public approve(request: IMovieRequests) {
|
||||
// request.approved = true;
|
||||
// this.approveRequest(request);
|
||||
// }
|
||||
|
||||
// public deny(request: IMovieRequests) {
|
||||
// this.requestToDeny = request;
|
||||
// this.denyDisplay = true;
|
||||
// }
|
||||
|
||||
// public denyRequest() {
|
||||
// this.requestService.denyMovie({ id: this.requestToDeny.id, reason: this.rejectionReason })
|
||||
// .subscribe(x => {
|
||||
// this.denyDisplay = false;
|
||||
// if (x.result) {
|
||||
// this.notificationService.success(
|
||||
// `Request for ${this.requestToDeny.title} has been denied successfully`);
|
||||
// const index = this.movieRequests.indexOf(this.requestToDeny, 0);
|
||||
// if (index > -1) {
|
||||
// this.movieRequests[index].denied = true;
|
||||
// }
|
||||
// } else {
|
||||
// this.notificationService.warning("Request Denied", x.message ? x.message : x.errorMessage);
|
||||
// this.requestToDeny.denied = false;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// public selectRootFolder(searchResult: IMovieRequests, rootFolderSelected: IRadarrRootFolder, event: any) {
|
||||
// event.preventDefault();
|
||||
// searchResult.rootPathOverride = rootFolderSelected.id;
|
||||
// this.setOverride(searchResult);
|
||||
// this.updateRequest(searchResult);
|
||||
// }
|
||||
|
||||
// public selectQualityProfile(searchResult: IMovieRequests, profileSelected: IRadarrProfile, event: any) {
|
||||
// event.preventDefault();
|
||||
// searchResult.qualityOverride = profileSelected.id;
|
||||
// this.setOverride(searchResult);
|
||||
// this.updateRequest(searchResult);
|
||||
// }
|
||||
|
||||
// public reportIssue(catId: IIssueCategory, req: IMovieRequests) {
|
||||
// this.issueRequest = req;
|
||||
// this.issueCategorySelected = catId;
|
||||
// this.issuesBarVisible = true;
|
||||
// this.issueProviderId = req.theMovieDbId.toString();
|
||||
// }
|
||||
|
||||
// public ignore(event: any): void {
|
||||
// event.preventDefault();
|
||||
// }
|
||||
|
||||
// public clearFilter(el: any) {
|
||||
// el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
// el = el.parentElement;
|
||||
// el = el.querySelectorAll("INPUT");
|
||||
// for (el of el) {
|
||||
// el.checked = false;
|
||||
// el.parentElement.classList.remove("active");
|
||||
// }
|
||||
|
||||
// this.filterDisplay = false;
|
||||
// this.filter.availabilityFilter = FilterType.None;
|
||||
// this.filter.statusFilter = FilterType.None;
|
||||
|
||||
// this.resetSearch();
|
||||
// }
|
||||
|
||||
// public filterAvailability(filter: FilterType, el: any) {
|
||||
// this.filterActiveStyle(el);
|
||||
// this.filter.availabilityFilter = filter;
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// public filterStatus(filter: FilterType, el: any) {
|
||||
// this.filterActiveStyle(el);
|
||||
// this.filter.statusFilter = filter;
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// public setOrder(value: OrderType, el: any) {
|
||||
// el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
// const parent = el.parentElement;
|
||||
// const previousFilter = parent.querySelector(".active");
|
||||
|
||||
// previousFilter.className = "";
|
||||
// el.className = "active";
|
||||
|
||||
// this.orderType = value;
|
||||
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// public subscribe(request: IMovieRequests) {
|
||||
// request.subscribed = true;
|
||||
// this.requestService.subscribeToMovie(request.id)
|
||||
// .subscribe(x => {
|
||||
// this.notificationService.success("Subscribed To Movie!");
|
||||
// });
|
||||
// }
|
||||
|
||||
// public unSubscribe(request: IMovieRequests) {
|
||||
// request.subscribed = false;
|
||||
// this.requestService.unSubscribeToMovie(request.id)
|
||||
// .subscribe(x => {
|
||||
// this.notificationService.success("Unsubscribed Movie!");
|
||||
// });
|
||||
// }
|
||||
|
||||
// public isRequestUser(request: IMovieRequests) {
|
||||
// if (request.requestedUser.userName === this.auth.claims().name) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// private filterActiveStyle(el: any) {
|
||||
// el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
// el = el.parentElement; //gets radio div
|
||||
// el = el.parentElement; //gets form group div
|
||||
// el = el.parentElement; //gets status filter div
|
||||
// el = el.querySelectorAll("INPUT");
|
||||
// for (el of el) {
|
||||
// if (el.checked) {
|
||||
// if (!el.parentElement.classList.contains("active")) {
|
||||
// el.parentElement.className += " active";
|
||||
// }
|
||||
// } else {
|
||||
// el.parentElement.classList.remove("active");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// private loadRequests(amountToLoad: number, currentlyLoaded: number) {
|
||||
// this.requestService.getMovieRequests(amountToLoad, currentlyLoaded, this.orderType, this.filter)
|
||||
// .subscribe(x => {
|
||||
// this.setOverrides(x.collection);
|
||||
// if (!this.movieRequests) {
|
||||
// this.movieRequests = [];
|
||||
// }
|
||||
// this.movieRequests = x.collection;
|
||||
// this.totalMovies = x.total;
|
||||
// this.currentlyLoaded = currentlyLoaded + amountToLoad;
|
||||
// });
|
||||
// }
|
||||
|
||||
// private updateRequest(request: IMovieRequests) {
|
||||
// this.requestService.updateMovieRequest(request)
|
||||
// .subscribe(x => {
|
||||
// this.setOverride(x);
|
||||
// request = x;
|
||||
// });
|
||||
// }
|
||||
|
||||
// private approveRequest(request: IMovieRequests) {
|
||||
// this.requestService.approveMovie({ id: request.id })
|
||||
// .subscribe(x => {
|
||||
// request.approved = true;
|
||||
// if (x.result) {
|
||||
// this.notificationService.success(
|
||||
// `Request for ${request.title} has been approved successfully`);
|
||||
// } else {
|
||||
// this.notificationService.warning("Request Approved", x.message ? x.message : x.errorMessage);
|
||||
// request.approved = false;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// private loadInit() {
|
||||
// this.requestService.getMovieRequests(this.amountToLoad, 0, this.orderType, this.filter)
|
||||
// .subscribe(x => {
|
||||
// this.movieRequests = x.collection;
|
||||
// this.totalMovies = x.total;
|
||||
|
||||
// this.movieRequests.forEach((req) => {
|
||||
// this.setBackground(req);
|
||||
// this.setPoster(req);
|
||||
// });
|
||||
// if (this.isAdmin) {
|
||||
// this.radarrService.getQualityProfilesFromSettings().subscribe(c => {
|
||||
// this.radarrProfiles = c;
|
||||
// this.movieRequests.forEach((req) => this.setQualityOverrides(req));
|
||||
// });
|
||||
// this.radarrService.getRootFoldersFromSettings().subscribe(c => {
|
||||
// this.radarrRootFolders = c;
|
||||
// this.movieRequests.forEach((req) => this.setRootFolderOverrides(req));
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// private resetSearch() {
|
||||
// this.currentlyLoaded = 5;
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// private removeRequestFromUi(key: IMovieRequests) {
|
||||
// const index = this.movieRequests.indexOf(key, 0);
|
||||
// if (index > -1) {
|
||||
// this.movieRequests.splice(index, 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private setOverrides(requests: IMovieRequests[]): void {
|
||||
// requests.forEach((req) => {
|
||||
// this.setOverride(req);
|
||||
// });
|
||||
// }
|
||||
|
||||
// private setQualityOverrides(req: IMovieRequests): void {
|
||||
// if (this.radarrProfiles) {
|
||||
// const profile = this.radarrProfiles.filter((p) => {
|
||||
// return p.id === req.qualityOverride;
|
||||
// });
|
||||
// if (profile.length > 0) {
|
||||
// req.qualityOverrideTitle = profile[0].name;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private setRootFolderOverrides(req: IMovieRequests): void {
|
||||
// if (this.radarrRootFolders) {
|
||||
// const path = this.radarrRootFolders.filter((folder) => {
|
||||
// return folder.id === req.rootPathOverride;
|
||||
// });
|
||||
// if (path.length > 0) {
|
||||
// req.rootPathOverrideTitle = path[0].path;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// private setOverride(req: IMovieRequests): void {
|
||||
// this.setPoster(req);
|
||||
// this.setBackground(req);
|
||||
// this.setQualityOverrides(req);
|
||||
// this.setRootFolderOverrides(req);
|
||||
// }
|
||||
|
||||
// private setPoster(req: IMovieRequests): void {
|
||||
// if (req.posterPath === null) {
|
||||
// req.posterPath = this.defaultPoster;
|
||||
// } else {
|
||||
// req.posterPath = "https://image.tmdb.org/t/p/w300/" + req.posterPath;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private setBackground(req: IMovieRequests): void {
|
||||
// req.backgroundPath = this.sanitizer.bypassSecurityTrustStyle
|
||||
// ("url(" + "https://image.tmdb.org/t/p/w1280" + req.background + ")");
|
||||
// }
|
||||
|
||||
// }
|
||||
|
@ -1,349 +1,349 @@
|
||||
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
|
||||
import { Component, Input, OnInit, Inject } from "@angular/core";
|
||||
import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { Subject } from "rxjs";
|
||||
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
||||
|
||||
import { AuthService } from "../../auth/auth.service";
|
||||
import { FilterType, IAlbumRequest, IFilter, IIssueCategory, IPagenator, OrderType } from "../../interfaces";
|
||||
import { NotificationService, RequestService } from "../../services";
|
||||
|
||||
@Component({
|
||||
selector: "music-requests",
|
||||
templateUrl: "./musicrequests.component.html",
|
||||
})
|
||||
export class MusicRequestsComponent implements OnInit {
|
||||
public albumRequests: IAlbumRequest[];
|
||||
public defaultPoster: string;
|
||||
|
||||
public searchChanged: Subject<string> = new Subject<string>();
|
||||
public searchText: string;
|
||||
|
||||
public isAdmin: boolean; // Also PowerUser
|
||||
|
||||
@Input() public issueCategories: IIssueCategory[];
|
||||
@Input() public issuesEnabled: boolean;
|
||||
public issuesBarVisible = false;
|
||||
public issueRequest: IAlbumRequest;
|
||||
public issueProviderId: string;
|
||||
public issueCategorySelected: IIssueCategory;
|
||||
|
||||
public filterDisplay: boolean;
|
||||
public filter: IFilter;
|
||||
public filterType = FilterType;
|
||||
|
||||
public orderType: OrderType = OrderType.RequestedDateDesc;
|
||||
public OrderType = OrderType;
|
||||
public denyDisplay: boolean;
|
||||
public requestToDeny: IAlbumRequest;
|
||||
public rejectionReason: string;
|
||||
|
||||
public totalAlbums: number = 100;
|
||||
public currentlyLoaded: number;
|
||||
private amountToLoad: number;
|
||||
private href: string;
|
||||
|
||||
constructor(
|
||||
private requestService: RequestService,
|
||||
private auth: AuthService,
|
||||
private notificationService: NotificationService,
|
||||
private sanitizer: DomSanitizer,
|
||||
@Inject(APP_BASE_HREF) href:string) {
|
||||
this.href = href;
|
||||
this.searchChanged.pipe(
|
||||
debounceTime(600), // Wait Xms after the last event before emitting last event
|
||||
distinctUntilChanged(), // only emit if value is different from previous value
|
||||
).subscribe(x => {
|
||||
this.searchText = x as string;
|
||||
if (this.searchText === "") {
|
||||
this.resetSearch();
|
||||
return;
|
||||
}
|
||||
this.requestService.searchAlbumRequests(this.searchText)
|
||||
.subscribe(m => {
|
||||
this.setOverrides(m);
|
||||
this.albumRequests = m;
|
||||
});
|
||||
});
|
||||
this.defaultPoster = "../../../images/default-music-placeholder.png";
|
||||
const base = this.href;
|
||||
if (base) {
|
||||
this.defaultPoster = "../../.." + base + "/images/default-music-placeholder.png";
|
||||
}
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.amountToLoad = 10;
|
||||
this.currentlyLoaded = 10;
|
||||
this.filter = {
|
||||
availabilityFilter: FilterType.None,
|
||||
statusFilter: FilterType.None,
|
||||
};
|
||||
this.loadInit();
|
||||
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
}
|
||||
|
||||
public paginate(event: IPagenator) {
|
||||
const skipAmount = event.first;
|
||||
this.loadRequests(this.amountToLoad, skipAmount);
|
||||
}
|
||||
|
||||
public search(text: any) {
|
||||
this.searchChanged.next(text.target.value);
|
||||
}
|
||||
|
||||
public async removeRequest(request: IAlbumRequest) {
|
||||
await this.requestService.removeAlbumRequest(request).toPromise();
|
||||
this.removeRequestFromUi(request);
|
||||
this.loadRequests(this.amountToLoad, this.currentlyLoaded = 0);
|
||||
}
|
||||
|
||||
public changeAvailability(request: IAlbumRequest, available: boolean) {
|
||||
request.available = available;
|
||||
|
||||
if (available) {
|
||||
this.requestService.markAlbumAvailable({ id: request.id }).subscribe(x => {
|
||||
if (x.result) {
|
||||
this.notificationService.success(
|
||||
`${request.title} Is now available`);
|
||||
} else {
|
||||
this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||
request.approved = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.requestService.markAlbumUnavailable({ id: request.id }).subscribe(x => {
|
||||
if (x.result) {
|
||||
this.notificationService.success(
|
||||
`${request.title} Is now unavailable`);
|
||||
} else {
|
||||
this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||
request.approved = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public approve(request: IAlbumRequest) {
|
||||
request.approved = true;
|
||||
this.approveRequest(request);
|
||||
}
|
||||
|
||||
public deny(request: IAlbumRequest) {
|
||||
this.requestToDeny = request;
|
||||
this.denyDisplay = true;
|
||||
}
|
||||
|
||||
public denyRequest() {
|
||||
this.requestService.denyAlbum({ id: this.requestToDeny.id, reason: this.rejectionReason })
|
||||
.subscribe(x => {
|
||||
if (x.result) {
|
||||
this.notificationService.success(
|
||||
`Request for ${this.requestToDeny.title} has been denied successfully`);
|
||||
} else {
|
||||
this.notificationService.warning("Request Denied", x.message ? x.message : x.errorMessage);
|
||||
this.requestToDeny.denied = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public reportIssue(catId: IIssueCategory, req: IAlbumRequest) {
|
||||
this.issueRequest = req;
|
||||
this.issueCategorySelected = catId;
|
||||
this.issuesBarVisible = true;
|
||||
this.issueProviderId = req.foreignAlbumId;
|
||||
}
|
||||
|
||||
public ignore(event: any): void {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
public clearFilter(el: any) {
|
||||
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
el = el.parentElement;
|
||||
el = el.querySelectorAll("INPUT");
|
||||
for (el of el) {
|
||||
el.checked = false;
|
||||
el.parentElement.classList.remove("active");
|
||||
}
|
||||
|
||||
this.filterDisplay = false;
|
||||
this.filter.availabilityFilter = FilterType.None;
|
||||
this.filter.statusFilter = FilterType.None;
|
||||
|
||||
this.resetSearch();
|
||||
}
|
||||
|
||||
public filterAvailability(filter: FilterType, el: any) {
|
||||
this.filterActiveStyle(el);
|
||||
this.filter.availabilityFilter = filter;
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
public filterStatus(filter: FilterType, el: any) {
|
||||
this.filterActiveStyle(el);
|
||||
this.filter.statusFilter = filter;
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
public setOrder(value: OrderType, el: any) {
|
||||
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
const parent = el.parentElement;
|
||||
const previousFilter = parent.querySelector(".active");
|
||||
|
||||
previousFilter.className = "";
|
||||
el.className = "active";
|
||||
|
||||
this.orderType = value;
|
||||
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
public isRequestUser(request: IAlbumRequest) {
|
||||
if (request.requestedUser.userName === this.auth.claims().name) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// public subscribe(request: IAlbumRequest) {
|
||||
// request.subscribed = true;
|
||||
// this.requestService.subscribeToMovie(request.id)
|
||||
// .subscribe(x => {
|
||||
// this.notificationService.success("Subscribed To Movie!");
|
||||
// });
|
||||
// }
|
||||
|
||||
// public unSubscribe(request: IMovieRequests) {
|
||||
// request.subscribed = false;
|
||||
// this.requestService.unSubscribeToMovie(request.id)
|
||||
// .subscribe(x => {
|
||||
// this.notificationService.success("Unsubscribed Movie!");
|
||||
// });
|
||||
// }
|
||||
|
||||
private filterActiveStyle(el: any) {
|
||||
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
el = el.parentElement; //gets radio div
|
||||
el = el.parentElement; //gets form group div
|
||||
el = el.parentElement; //gets status filter div
|
||||
el = el.querySelectorAll("INPUT");
|
||||
for (el of el) {
|
||||
if (el.checked) {
|
||||
if (!el.parentElement.classList.contains("active")) {
|
||||
el.parentElement.className += " active";
|
||||
}
|
||||
} else {
|
||||
el.parentElement.classList.remove("active");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private loadRequests(amountToLoad: number, currentlyLoaded: number) {
|
||||
this.requestService.getAlbumRequests(amountToLoad, currentlyLoaded, this.orderType, this.filter)
|
||||
.subscribe(x => {
|
||||
this.setOverrides(x.collection);
|
||||
if (!this.albumRequests) {
|
||||
this.albumRequests = [];
|
||||
}
|
||||
this.albumRequests = x.collection;
|
||||
this.totalAlbums = x.total;
|
||||
this.currentlyLoaded = currentlyLoaded + amountToLoad;
|
||||
});
|
||||
}
|
||||
|
||||
private approveRequest(request: IAlbumRequest) {
|
||||
this.requestService.approveAlbum({ id: request.id })
|
||||
.subscribe(x => {
|
||||
request.approved = true;
|
||||
if (x.result) {
|
||||
this.notificationService.success(
|
||||
`Request for ${request.title} has been approved successfully`);
|
||||
} else {
|
||||
this.notificationService.warning("Request Approved", x.message ? x.message : x.errorMessage);
|
||||
request.approved = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private loadInit() {
|
||||
this.requestService.getAlbumRequests(this.amountToLoad, 0, this.orderType, this.filter)
|
||||
.subscribe(x => {
|
||||
this.albumRequests = x.collection;
|
||||
this.totalAlbums = x.total;
|
||||
|
||||
this.setOverrides(this.albumRequests);
|
||||
|
||||
if (this.isAdmin) {
|
||||
// this.radarrService.getQualityProfilesFromSettings().subscribe(c => {
|
||||
// this.radarrProfiles = c;
|
||||
// this.albumRequests.forEach((req) => this.setQualityOverrides(req));
|
||||
// });
|
||||
// this.radarrService.getRootFoldersFromSettings().subscribe(c => {
|
||||
// this.radarrRootFolders = c;
|
||||
// this.albumRequests.forEach((req) => this.setRootFolderOverrides(req));
|
||||
// });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private resetSearch() {
|
||||
this.currentlyLoaded = 5;
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
private removeRequestFromUi(key: IAlbumRequest) {
|
||||
const index = this.albumRequests.indexOf(key, 0);
|
||||
if (index > -1) {
|
||||
this.albumRequests.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private setOverrides(requests: IAlbumRequest[]): void {
|
||||
requests.forEach((req) => {
|
||||
this.setOverride(req);
|
||||
});
|
||||
}
|
||||
|
||||
// private setQualityOverrides(req: IMovieRequests): void {
|
||||
// if (this.radarrProfiles) {
|
||||
// const profile = this.radarrProfiles.filter((p) => {
|
||||
// return p.id === req.qualityOverride;
|
||||
// });
|
||||
// if (profile.length > 0) {
|
||||
// req.qualityOverrideTitle = profile[0].name;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private setRootFolderOverrides(req: IMovieRequests): void {
|
||||
// if (this.radarrRootFolders) {
|
||||
// const path = this.radarrRootFolders.filter((folder) => {
|
||||
// return folder.id === req.rootPathOverride;
|
||||
// });
|
||||
// if (path.length > 0) {
|
||||
// req.rootPathOverrideTitle = path[0].path;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private setOverride(req: IAlbumRequest): void {
|
||||
this.setAlbumBackground(req);
|
||||
// this.setQualityOverrides(req);
|
||||
// this.setRootFolderOverrides(req);
|
||||
}
|
||||
private setAlbumBackground(req: IAlbumRequest) {
|
||||
if (req.disk === null) {
|
||||
if (req.cover === null) {
|
||||
req.disk = this.defaultPoster;
|
||||
} else {
|
||||
req.disk = req.cover;
|
||||
}
|
||||
}
|
||||
req.background = this.sanitizer.bypassSecurityTrustStyle
|
||||
("url(" + req.cover + ")");
|
||||
}
|
||||
|
||||
}
|
||||
// import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
|
||||
// import { Component, Input, OnInit, Inject } from "@angular/core";
|
||||
// import { DomSanitizer } from "@angular/platform-browser";
|
||||
// import { Subject } from "rxjs";
|
||||
// import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
||||
|
||||
// import { AuthService } from "../../auth/auth.service";
|
||||
// import { FilterType, IAlbumRequest, IFilter, IIssueCategory, IPagenator, OrderType } from "../../interfaces";
|
||||
// import { NotificationService, RequestService } from "../../services";
|
||||
|
||||
// @Component({
|
||||
// selector: "music-requests",
|
||||
// templateUrl: "./musicrequests.component.html",
|
||||
// })
|
||||
// export class MusicRequestsComponent implements OnInit {
|
||||
// public albumRequests: IAlbumRequest[];
|
||||
// public defaultPoster: string;
|
||||
|
||||
// public searchChanged: Subject<string> = new Subject<string>();
|
||||
// public searchText: string;
|
||||
|
||||
// public isAdmin: boolean; // Also PowerUser
|
||||
|
||||
// @Input() public issueCategories: IIssueCategory[];
|
||||
// @Input() public issuesEnabled: boolean;
|
||||
// public issuesBarVisible = false;
|
||||
// public issueRequest: IAlbumRequest;
|
||||
// public issueProviderId: string;
|
||||
// public issueCategorySelected: IIssueCategory;
|
||||
|
||||
// public filterDisplay: boolean;
|
||||
// public filter: IFilter;
|
||||
// public filterType = FilterType;
|
||||
|
||||
// public orderType: OrderType = OrderType.RequestedDateDesc;
|
||||
// public OrderType = OrderType;
|
||||
// public denyDisplay: boolean;
|
||||
// public requestToDeny: IAlbumRequest;
|
||||
// public rejectionReason: string;
|
||||
|
||||
// public totalAlbums: number = 100;
|
||||
// public currentlyLoaded: number;
|
||||
// private amountToLoad: number;
|
||||
// private href: string;
|
||||
|
||||
// constructor(
|
||||
// private requestService: RequestService,
|
||||
// private auth: AuthService,
|
||||
// private notificationService: NotificationService,
|
||||
// private sanitizer: DomSanitizer,
|
||||
// @Inject(APP_BASE_HREF) href:string) {
|
||||
// this.href = href;
|
||||
// this.searchChanged.pipe(
|
||||
// debounceTime(600), // Wait Xms after the last event before emitting last event
|
||||
// distinctUntilChanged(), // only emit if value is different from previous value
|
||||
// ).subscribe(x => {
|
||||
// this.searchText = x as string;
|
||||
// if (this.searchText === "") {
|
||||
// this.resetSearch();
|
||||
// return;
|
||||
// }
|
||||
// this.requestService.searchAlbumRequests(this.searchText)
|
||||
// .subscribe(m => {
|
||||
// this.setOverrides(m);
|
||||
// this.albumRequests = m;
|
||||
// });
|
||||
// });
|
||||
// this.defaultPoster = "../../../images/default-music-placeholder.png";
|
||||
// const base = this.href;
|
||||
// if (base) {
|
||||
// this.defaultPoster = "../../.." + base + "/images/default-music-placeholder.png";
|
||||
// }
|
||||
// }
|
||||
|
||||
// public ngOnInit() {
|
||||
// this.amountToLoad = 10;
|
||||
// this.currentlyLoaded = 10;
|
||||
// this.filter = {
|
||||
// availabilityFilter: FilterType.None,
|
||||
// statusFilter: FilterType.None,
|
||||
// };
|
||||
// this.loadInit();
|
||||
// this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
// }
|
||||
|
||||
// public paginate(event: IPagenator) {
|
||||
// const skipAmount = event.first;
|
||||
// this.loadRequests(this.amountToLoad, skipAmount);
|
||||
// }
|
||||
|
||||
// public search(text: any) {
|
||||
// this.searchChanged.next(text.target.value);
|
||||
// }
|
||||
|
||||
// public async removeRequest(request: IAlbumRequest) {
|
||||
// await this.requestService.removeAlbumRequest(request).toPromise();
|
||||
// this.removeRequestFromUi(request);
|
||||
// this.loadRequests(this.amountToLoad, this.currentlyLoaded = 0);
|
||||
// }
|
||||
|
||||
// public changeAvailability(request: IAlbumRequest, available: boolean) {
|
||||
// request.available = available;
|
||||
|
||||
// if (available) {
|
||||
// this.requestService.markAlbumAvailable({ id: request.id }).subscribe(x => {
|
||||
// if (x.result) {
|
||||
// this.notificationService.success(
|
||||
// `${request.title} Is now available`);
|
||||
// } else {
|
||||
// this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||
// request.approved = false;
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// this.requestService.markAlbumUnavailable({ id: request.id }).subscribe(x => {
|
||||
// if (x.result) {
|
||||
// this.notificationService.success(
|
||||
// `${request.title} Is now unavailable`);
|
||||
// } else {
|
||||
// this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||
// request.approved = false;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// public approve(request: IAlbumRequest) {
|
||||
// request.approved = true;
|
||||
// this.approveRequest(request);
|
||||
// }
|
||||
|
||||
// public deny(request: IAlbumRequest) {
|
||||
// this.requestToDeny = request;
|
||||
// this.denyDisplay = true;
|
||||
// }
|
||||
|
||||
// public denyRequest() {
|
||||
// this.requestService.denyAlbum({ id: this.requestToDeny.id, reason: this.rejectionReason })
|
||||
// .subscribe(x => {
|
||||
// if (x.result) {
|
||||
// this.notificationService.success(
|
||||
// `Request for ${this.requestToDeny.title} has been denied successfully`);
|
||||
// } else {
|
||||
// this.notificationService.warning("Request Denied", x.message ? x.message : x.errorMessage);
|
||||
// this.requestToDeny.denied = false;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// public reportIssue(catId: IIssueCategory, req: IAlbumRequest) {
|
||||
// this.issueRequest = req;
|
||||
// this.issueCategorySelected = catId;
|
||||
// this.issuesBarVisible = true;
|
||||
// this.issueProviderId = req.foreignAlbumId;
|
||||
// }
|
||||
|
||||
// public ignore(event: any): void {
|
||||
// event.preventDefault();
|
||||
// }
|
||||
|
||||
// public clearFilter(el: any) {
|
||||
// el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
// el = el.parentElement;
|
||||
// el = el.querySelectorAll("INPUT");
|
||||
// for (el of el) {
|
||||
// el.checked = false;
|
||||
// el.parentElement.classList.remove("active");
|
||||
// }
|
||||
|
||||
// this.filterDisplay = false;
|
||||
// this.filter.availabilityFilter = FilterType.None;
|
||||
// this.filter.statusFilter = FilterType.None;
|
||||
|
||||
// this.resetSearch();
|
||||
// }
|
||||
|
||||
// public filterAvailability(filter: FilterType, el: any) {
|
||||
// this.filterActiveStyle(el);
|
||||
// this.filter.availabilityFilter = filter;
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// public filterStatus(filter: FilterType, el: any) {
|
||||
// this.filterActiveStyle(el);
|
||||
// this.filter.statusFilter = filter;
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// public setOrder(value: OrderType, el: any) {
|
||||
// el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
// const parent = el.parentElement;
|
||||
// const previousFilter = parent.querySelector(".active");
|
||||
|
||||
// previousFilter.className = "";
|
||||
// el.className = "active";
|
||||
|
||||
// this.orderType = value;
|
||||
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// public isRequestUser(request: IAlbumRequest) {
|
||||
// if (request.requestedUser.userName === this.auth.claims().name) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// // public subscribe(request: IAlbumRequest) {
|
||||
// // request.subscribed = true;
|
||||
// // this.requestService.subscribeToMovie(request.id)
|
||||
// // .subscribe(x => {
|
||||
// // this.notificationService.success("Subscribed To Movie!");
|
||||
// // });
|
||||
// // }
|
||||
|
||||
// // public unSubscribe(request: IMovieRequests) {
|
||||
// // request.subscribed = false;
|
||||
// // this.requestService.unSubscribeToMovie(request.id)
|
||||
// // .subscribe(x => {
|
||||
// // this.notificationService.success("Unsubscribed Movie!");
|
||||
// // });
|
||||
// // }
|
||||
|
||||
// private filterActiveStyle(el: any) {
|
||||
// el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
// el = el.parentElement; //gets radio div
|
||||
// el = el.parentElement; //gets form group div
|
||||
// el = el.parentElement; //gets status filter div
|
||||
// el = el.querySelectorAll("INPUT");
|
||||
// for (el of el) {
|
||||
// if (el.checked) {
|
||||
// if (!el.parentElement.classList.contains("active")) {
|
||||
// el.parentElement.className += " active";
|
||||
// }
|
||||
// } else {
|
||||
// el.parentElement.classList.remove("active");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// private loadRequests(amountToLoad: number, currentlyLoaded: number) {
|
||||
// this.requestService.getAlbumRequests(amountToLoad, currentlyLoaded, this.orderType, this.filter)
|
||||
// .subscribe(x => {
|
||||
// this.setOverrides(x.collection);
|
||||
// if (!this.albumRequests) {
|
||||
// this.albumRequests = [];
|
||||
// }
|
||||
// this.albumRequests = x.collection;
|
||||
// this.totalAlbums = x.total;
|
||||
// this.currentlyLoaded = currentlyLoaded + amountToLoad;
|
||||
// });
|
||||
// }
|
||||
|
||||
// private approveRequest(request: IAlbumRequest) {
|
||||
// this.requestService.approveAlbum({ id: request.id })
|
||||
// .subscribe(x => {
|
||||
// request.approved = true;
|
||||
// if (x.result) {
|
||||
// this.notificationService.success(
|
||||
// `Request for ${request.title} has been approved successfully`);
|
||||
// } else {
|
||||
// this.notificationService.warning("Request Approved", x.message ? x.message : x.errorMessage);
|
||||
// request.approved = false;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// private loadInit() {
|
||||
// this.requestService.getAlbumRequests(this.amountToLoad, 0, this.orderType, this.filter)
|
||||
// .subscribe(x => {
|
||||
// this.albumRequests = x.collection;
|
||||
// this.totalAlbums = x.total;
|
||||
|
||||
// this.setOverrides(this.albumRequests);
|
||||
|
||||
// if (this.isAdmin) {
|
||||
// // this.radarrService.getQualityProfilesFromSettings().subscribe(c => {
|
||||
// // this.radarrProfiles = c;
|
||||
// // this.albumRequests.forEach((req) => this.setQualityOverrides(req));
|
||||
// // });
|
||||
// // this.radarrService.getRootFoldersFromSettings().subscribe(c => {
|
||||
// // this.radarrRootFolders = c;
|
||||
// // this.albumRequests.forEach((req) => this.setRootFolderOverrides(req));
|
||||
// // });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// private resetSearch() {
|
||||
// this.currentlyLoaded = 5;
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// private removeRequestFromUi(key: IAlbumRequest) {
|
||||
// const index = this.albumRequests.indexOf(key, 0);
|
||||
// if (index > -1) {
|
||||
// this.albumRequests.splice(index, 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private setOverrides(requests: IAlbumRequest[]): void {
|
||||
// requests.forEach((req) => {
|
||||
// this.setOverride(req);
|
||||
// });
|
||||
// }
|
||||
|
||||
// // private setQualityOverrides(req: IMovieRequests): void {
|
||||
// // if (this.radarrProfiles) {
|
||||
// // const profile = this.radarrProfiles.filter((p) => {
|
||||
// // return p.id === req.qualityOverride;
|
||||
// // });
|
||||
// // if (profile.length > 0) {
|
||||
// // req.qualityOverrideTitle = profile[0].name;
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// // private setRootFolderOverrides(req: IMovieRequests): void {
|
||||
// // if (this.radarrRootFolders) {
|
||||
// // const path = this.radarrRootFolders.filter((folder) => {
|
||||
// // return folder.id === req.rootPathOverride;
|
||||
// // });
|
||||
// // if (path.length > 0) {
|
||||
// // req.rootPathOverrideTitle = path[0].path;
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// private setOverride(req: IAlbumRequest): void {
|
||||
// this.setAlbumBackground(req);
|
||||
// // this.setQualityOverrides(req);
|
||||
// // this.setRootFolderOverrides(req);
|
||||
// }
|
||||
// private setAlbumBackground(req: IAlbumRequest) {
|
||||
// if (req.disk === null) {
|
||||
// if (req.cover === null) {
|
||||
// req.disk = this.defaultPoster;
|
||||
// } else {
|
||||
// req.disk = req.cover;
|
||||
// }
|
||||
// }
|
||||
// req.background = this.sanitizer.bypassSecurityTrustStyle
|
||||
// ("url(" + req.cover + ")");
|
||||
// }
|
||||
|
||||
// }
|
||||
|
@ -1,226 +1,226 @@
|
||||
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
|
||||
import { Component, Input, OnInit, Inject } from "@angular/core";
|
||||
import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { Subject } from "rxjs";
|
||||
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
||||
|
||||
import { AuthService } from "../auth/auth.service";
|
||||
import { FilterType, IIssueCategory, IPagenator, IRequestsViewModel, ISonarrProfile, ISonarrRootFolder, ITvRequests, OrderType } from "../interfaces";
|
||||
import { NotificationService, RequestService, SonarrService } from "../services";
|
||||
import { ImageService } from "../services/image.service";
|
||||
|
||||
@Component({
|
||||
selector: "tv-requests",
|
||||
templateUrl: "./tvrequests.component.html",
|
||||
styleUrls: ["./tvrequests.component.scss"],
|
||||
})
|
||||
export class TvRequestsComponent implements OnInit {
|
||||
|
||||
public tvRequests: IRequestsViewModel<ITvRequests>;
|
||||
public searchChanged = new Subject<string>();
|
||||
public searchText: string;
|
||||
public isAdmin: boolean;
|
||||
public currentUser: string;
|
||||
public showChildDialogue = false; // This is for the child modal popup
|
||||
public selectedSeason: ITvRequests;
|
||||
public defaultPoster: string;
|
||||
|
||||
@Input() public issueCategories: IIssueCategory[];
|
||||
@Input() public issuesEnabled: boolean;
|
||||
public issueProviderId: string;
|
||||
public issuesBarVisible = false;
|
||||
public issueRequest: ITvRequests;
|
||||
public issueCategorySelected: IIssueCategory;
|
||||
|
||||
public sonarrProfiles: ISonarrProfile[] = [];
|
||||
public sonarrRootFolders: ISonarrRootFolder[] = [];
|
||||
|
||||
public totalTv: number = 100;
|
||||
private currentlyLoaded: number;
|
||||
private amountToLoad: number;
|
||||
private href: string;
|
||||
|
||||
constructor(
|
||||
private requestService: RequestService,
|
||||
private auth: AuthService,
|
||||
private sanitizer: DomSanitizer,
|
||||
private imageService: ImageService,
|
||||
private sonarrService: SonarrService,
|
||||
private notificationService: NotificationService,
|
||||
@Inject(APP_BASE_HREF) href:string) {
|
||||
this.href= href;
|
||||
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
this.currentUser = this.auth.claims().name;
|
||||
if (this.isAdmin) {
|
||||
this.sonarrService.getQualityProfilesWithoutSettings()
|
||||
.subscribe(x => this.sonarrProfiles = x);
|
||||
// import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
|
||||
// import { Component, Input, OnInit, Inject } from "@angular/core";
|
||||
// import { DomSanitizer } from "@angular/platform-browser";
|
||||
// import { Subject } from "rxjs";
|
||||
// import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
||||
|
||||
// import { AuthService } from "../auth/auth.service";
|
||||
// import { FilterType, IIssueCategory, IPagenator, IRequestsViewModel, ISonarrProfile, ISonarrRootFolder, ITvRequests, OrderType } from "../interfaces";
|
||||
// import { NotificationService, RequestService, SonarrService } from "../services";
|
||||
// import { ImageService } from "../services/image.service";
|
||||
|
||||
// @Component({
|
||||
// selector: "tv-requests",
|
||||
// templateUrl: "./tvrequests.component.html",
|
||||
// styleUrls: ["./tvrequests.component.scss"],
|
||||
// })
|
||||
// export class TvRequestsComponent implements OnInit {
|
||||
|
||||
// public tvRequests: IRequestsViewModel<ITvRequests>;
|
||||
// public searchChanged = new Subject<string>();
|
||||
// public searchText: string;
|
||||
// public isAdmin: boolean;
|
||||
// public currentUser: string;
|
||||
// public showChildDialogue = false; // This is for the child modal popup
|
||||
// public selectedSeason: ITvRequests;
|
||||
// public defaultPoster: string;
|
||||
|
||||
// @Input() public issueCategories: IIssueCategory[];
|
||||
// @Input() public issuesEnabled: boolean;
|
||||
// public issueProviderId: string;
|
||||
// public issuesBarVisible = false;
|
||||
// public issueRequest: ITvRequests;
|
||||
// public issueCategorySelected: IIssueCategory;
|
||||
|
||||
// public sonarrProfiles: ISonarrProfile[] = [];
|
||||
// public sonarrRootFolders: ISonarrRootFolder[] = [];
|
||||
|
||||
// public totalTv: number = 100;
|
||||
// private currentlyLoaded: number;
|
||||
// private amountToLoad: number;
|
||||
// private href: string;
|
||||
|
||||
// constructor(
|
||||
// private requestService: RequestService,
|
||||
// private auth: AuthService,
|
||||
// private sanitizer: DomSanitizer,
|
||||
// private imageService: ImageService,
|
||||
// private sonarrService: SonarrService,
|
||||
// private notificationService: NotificationService,
|
||||
// @Inject(APP_BASE_HREF) href:string) {
|
||||
// this.href= href;
|
||||
// this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
// this.currentUser = this.auth.claims().name;
|
||||
// if (this.isAdmin) {
|
||||
// this.sonarrService.getQualityProfilesWithoutSettings()
|
||||
// .subscribe(x => this.sonarrProfiles = x);
|
||||
|
||||
this.sonarrService.getRootFoldersWithoutSettings()
|
||||
.subscribe(x => this.sonarrRootFolders = x);
|
||||
}
|
||||
}
|
||||
|
||||
public openClosestTab(node: ITvRequests,el: any) {
|
||||
el.preventDefault();
|
||||
node.open = !node.open;
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.amountToLoad = 10;
|
||||
this.currentlyLoaded = 10;
|
||||
this.tvRequests = {collection:[], total:0};
|
||||
|
||||
this.searchChanged.pipe(
|
||||
debounceTime(600), // Wait Xms after the last event before emitting last event
|
||||
distinctUntilChanged(), // only emit if value is different from previous value
|
||||
).subscribe(x => {
|
||||
this.searchText = x as string;
|
||||
if (this.searchText === "") {
|
||||
this.resetSearch();
|
||||
return;
|
||||
}
|
||||
this.requestService.searchTvRequests(this.searchText)
|
||||
.subscribe(m => {
|
||||
this.tvRequests.collection = m;
|
||||
this.tvRequests.collection.forEach((val) => this.loadBackdrop(val));
|
||||
this.tvRequests.collection.forEach((val) => this.setOverride(val));
|
||||
});
|
||||
});
|
||||
this.defaultPoster = "../../../images/default_tv_poster.png";
|
||||
const base = this.href;
|
||||
if (base) {
|
||||
this.defaultPoster = "../../.." + base + "/images/default_tv_poster.png";
|
||||
}
|
||||
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
public paginate(event: IPagenator) {
|
||||
const skipAmount = event.first;
|
||||
|
||||
this.requestService.getTvRequests(this.amountToLoad, skipAmount, OrderType.RequestedDateDesc, FilterType.None, FilterType.None)
|
||||
.subscribe(x => {
|
||||
this.tvRequests = x;
|
||||
this.currentlyLoaded = this.currentlyLoaded + this.amountToLoad;
|
||||
});
|
||||
}
|
||||
|
||||
public search(text: any) {
|
||||
this.searchChanged.next(text.target.value);
|
||||
}
|
||||
|
||||
public showChildren(request: ITvRequests) {
|
||||
this.selectedSeason = request;
|
||||
this.showChildDialogue = true;
|
||||
}
|
||||
|
||||
public childRequestDeleted(childId: number): void {
|
||||
// Refresh the UI, hackly way around reloading the data
|
||||
this.ngOnInit();
|
||||
}
|
||||
|
||||
public selectRootFolder(searchResult: ITvRequests, rootFolderSelected: ISonarrRootFolder, event: any) {
|
||||
event.preventDefault();
|
||||
searchResult.rootFolder = rootFolderSelected.id;
|
||||
this.setOverride(searchResult);
|
||||
this.setRootFolder(searchResult);
|
||||
}
|
||||
|
||||
public selectQualityProfile(searchResult: ITvRequests, profileSelected: ISonarrProfile, event: any) {
|
||||
event.preventDefault();
|
||||
searchResult.qualityOverride = profileSelected.id;
|
||||
this.setOverride(searchResult);
|
||||
this.setQualityProfile(searchResult);
|
||||
}
|
||||
|
||||
public reportIssue(catId: IIssueCategory, req: ITvRequests) {
|
||||
this.issueRequest = req;
|
||||
this.issueCategorySelected = catId;
|
||||
this.issuesBarVisible = true;
|
||||
this.issueProviderId = req.id.toString();
|
||||
}
|
||||
|
||||
private setOverride(req: ITvRequests): void {
|
||||
this.setQualityOverrides(req);
|
||||
this.setRootFolderOverrides(req);
|
||||
}
|
||||
|
||||
private setQualityProfile(req: ITvRequests) {
|
||||
this.requestService.setQualityProfile(req.id, req.qualityOverride).subscribe(x => {
|
||||
if(x) {
|
||||
this.notificationService.success("Quality profile updated");
|
||||
} else {
|
||||
this.notificationService.error("Could not update the quality profile");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private setRootFolder(req: ITvRequests) {
|
||||
this.requestService.setRootFolder(req.id, req.rootFolder).subscribe(x => {
|
||||
if(x) {
|
||||
this.notificationService.success("Quality profile updated");
|
||||
} else {
|
||||
this.notificationService.error("Could not update the quality profile");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private setQualityOverrides(req: ITvRequests): void {
|
||||
if (this.sonarrProfiles) {
|
||||
const profile = this.sonarrProfiles.filter((p) => {
|
||||
return p.id === req.qualityOverride;
|
||||
});
|
||||
if (profile.length > 0) {
|
||||
req.qualityOverrideTitle = profile[0].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
private setRootFolderOverrides(req: ITvRequests): void {
|
||||
if (this.sonarrRootFolders) {
|
||||
const path = this.sonarrRootFolders.filter((folder) => {
|
||||
return folder.id === req.rootFolder;
|
||||
});
|
||||
if (path.length > 0) {
|
||||
req.rootPathOverrideTitle = path[0].path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private loadInit() {
|
||||
this.requestService.getTotalTv().subscribe(x => this.totalTv = x);
|
||||
this.requestService.getTvRequests(this.amountToLoad, 0, OrderType.RequestedDateDesc, FilterType.None, FilterType.None)
|
||||
.subscribe(x => {
|
||||
this.tvRequests = x;
|
||||
this.tvRequests.collection.forEach((val, index) => {
|
||||
this.setDefaults(val);
|
||||
this.loadBackdrop(val);
|
||||
this.setOverride(val);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private resetSearch() {
|
||||
this.currentlyLoaded = 5;
|
||||
this.loadInit();
|
||||
}
|
||||
|
||||
private setDefaults(val: ITvRequests) {
|
||||
if (val.posterPath === null) {
|
||||
val.posterPath = this.defaultPoster;
|
||||
}
|
||||
}
|
||||
|
||||
private loadBackdrop(val: ITvRequests): void {
|
||||
if (val.background != null) {
|
||||
val.background = this.sanitizer.bypassSecurityTrustStyle
|
||||
("url(https://image.tmdb.org/t/p/w1280" + val.background + ")");
|
||||
} else {
|
||||
this.imageService.getTvBanner(val.tvDbId).subscribe(x => {
|
||||
if (x) {
|
||||
val.background = this.sanitizer.bypassSecurityTrustStyle
|
||||
("url(" + x + ")");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// this.sonarrService.getRootFoldersWithoutSettings()
|
||||
// .subscribe(x => this.sonarrRootFolders = x);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public openClosestTab(node: ITvRequests,el: any) {
|
||||
// el.preventDefault();
|
||||
// node.open = !node.open;
|
||||
// }
|
||||
|
||||
// public ngOnInit() {
|
||||
// this.amountToLoad = 10;
|
||||
// this.currentlyLoaded = 10;
|
||||
// this.tvRequests = {collection:[], total:0};
|
||||
|
||||
// this.searchChanged.pipe(
|
||||
// debounceTime(600), // Wait Xms after the last event before emitting last event
|
||||
// distinctUntilChanged(), // only emit if value is different from previous value
|
||||
// ).subscribe(x => {
|
||||
// this.searchText = x as string;
|
||||
// if (this.searchText === "") {
|
||||
// this.resetSearch();
|
||||
// return;
|
||||
// }
|
||||
// this.requestService.searchTvRequests(this.searchText)
|
||||
// .subscribe(m => {
|
||||
// this.tvRequests.collection = m;
|
||||
// this.tvRequests.collection.forEach((val) => this.loadBackdrop(val));
|
||||
// this.tvRequests.collection.forEach((val) => this.setOverride(val));
|
||||
// });
|
||||
// });
|
||||
// this.defaultPoster = "../../../images/default_tv_poster.png";
|
||||
// const base = this.href;
|
||||
// if (base) {
|
||||
// this.defaultPoster = "../../.." + base + "/images/default_tv_poster.png";
|
||||
// }
|
||||
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// public paginate(event: IPagenator) {
|
||||
// const skipAmount = event.first;
|
||||
|
||||
// this.requestService.getTvRequests(this.amountToLoad, skipAmount, OrderType.RequestedDateDesc, FilterType.None, FilterType.None)
|
||||
// .subscribe(x => {
|
||||
// this.tvRequests = x;
|
||||
// this.currentlyLoaded = this.currentlyLoaded + this.amountToLoad;
|
||||
// });
|
||||
// }
|
||||
|
||||
// public search(text: any) {
|
||||
// this.searchChanged.next(text.target.value);
|
||||
// }
|
||||
|
||||
// public showChildren(request: ITvRequests) {
|
||||
// this.selectedSeason = request;
|
||||
// this.showChildDialogue = true;
|
||||
// }
|
||||
|
||||
// public childRequestDeleted(childId: number): void {
|
||||
// // Refresh the UI, hackly way around reloading the data
|
||||
// this.ngOnInit();
|
||||
// }
|
||||
|
||||
// public selectRootFolder(searchResult: ITvRequests, rootFolderSelected: ISonarrRootFolder, event: any) {
|
||||
// event.preventDefault();
|
||||
// searchResult.rootFolder = rootFolderSelected.id;
|
||||
// this.setOverride(searchResult);
|
||||
// this.setRootFolder(searchResult);
|
||||
// }
|
||||
|
||||
// public selectQualityProfile(searchResult: ITvRequests, profileSelected: ISonarrProfile, event: any) {
|
||||
// event.preventDefault();
|
||||
// searchResult.qualityOverride = profileSelected.id;
|
||||
// this.setOverride(searchResult);
|
||||
// this.setQualityProfile(searchResult);
|
||||
// }
|
||||
|
||||
// public reportIssue(catId: IIssueCategory, req: ITvRequests) {
|
||||
// this.issueRequest = req;
|
||||
// this.issueCategorySelected = catId;
|
||||
// this.issuesBarVisible = true;
|
||||
// this.issueProviderId = req.id.toString();
|
||||
// }
|
||||
|
||||
// private setOverride(req: ITvRequests): void {
|
||||
// this.setQualityOverrides(req);
|
||||
// this.setRootFolderOverrides(req);
|
||||
// }
|
||||
|
||||
// private setQualityProfile(req: ITvRequests) {
|
||||
// this.requestService.setQualityProfile(req.id, req.qualityOverride).subscribe(x => {
|
||||
// if(x) {
|
||||
// this.notificationService.success("Quality profile updated");
|
||||
// } else {
|
||||
// this.notificationService.error("Could not update the quality profile");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// private setRootFolder(req: ITvRequests) {
|
||||
// this.requestService.setRootFolder(req.id, req.rootFolder).subscribe(x => {
|
||||
// if(x) {
|
||||
// this.notificationService.success("Quality profile updated");
|
||||
// } else {
|
||||
// this.notificationService.error("Could not update the quality profile");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// private setQualityOverrides(req: ITvRequests): void {
|
||||
// if (this.sonarrProfiles) {
|
||||
// const profile = this.sonarrProfiles.filter((p) => {
|
||||
// return p.id === req.qualityOverride;
|
||||
// });
|
||||
// if (profile.length > 0) {
|
||||
// req.qualityOverrideTitle = profile[0].name;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private setRootFolderOverrides(req: ITvRequests): void {
|
||||
// if (this.sonarrRootFolders) {
|
||||
// const path = this.sonarrRootFolders.filter((folder) => {
|
||||
// return folder.id === req.rootFolder;
|
||||
// });
|
||||
// if (path.length > 0) {
|
||||
// req.rootPathOverrideTitle = path[0].path;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// private loadInit() {
|
||||
// this.requestService.getTotalTv().subscribe(x => this.totalTv = x);
|
||||
// this.requestService.getTvRequests(this.amountToLoad, 0, OrderType.RequestedDateDesc, FilterType.None, FilterType.None)
|
||||
// .subscribe(x => {
|
||||
// this.tvRequests = x;
|
||||
// this.tvRequests.collection.forEach((val, index) => {
|
||||
// this.setDefaults(val);
|
||||
// this.loadBackdrop(val);
|
||||
// this.setOverride(val);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
// private resetSearch() {
|
||||
// this.currentlyLoaded = 5;
|
||||
// this.loadInit();
|
||||
// }
|
||||
|
||||
// private setDefaults(val: ITvRequests) {
|
||||
// if (val.posterPath === null) {
|
||||
// val.posterPath = this.defaultPoster;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private loadBackdrop(val: ITvRequests): void {
|
||||
// if (val.background != null) {
|
||||
// val.background = this.sanitizer.bypassSecurityTrustStyle
|
||||
// ("url(https://image.tmdb.org/t/p/w1280" + val.background + ")");
|
||||
// } else {
|
||||
// this.imageService.getTvBanner(val.tvDbId).subscribe(x => {
|
||||
// if (x) {
|
||||
// val.background = this.sanitizer.bypassSecurityTrustStyle
|
||||
// ("url(" + x + ")");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
@ -1,2 +1,6 @@
|
||||
/***************************************************************************************************
|
||||
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
|
||||
*/
|
||||
import '@angular/localize/init';
|
||||
import "core-js/es7/reflect";
|
||||
import "zone.js/dist/zone";
|
||||
|
@ -1,7 +1,11 @@
|
||||
.lg-form-field .mat-form-field-infix {
|
||||
width: 480px;
|
||||
width: 480px;
|
||||
}
|
||||
|
||||
.md-form-field .mat-form-field-infix {
|
||||
width: 380px;
|
||||
width: 380px;
|
||||
}
|
||||
|
||||
td.mat-cell {
|
||||
padding: 0.75rem !important;
|
||||
}
|
@ -1,22 +1,30 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"outDir": "./dist/out-tsc",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "es5",
|
||||
"types": ["node"],
|
||||
"resolveJsonModule":true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
]
|
||||
}
|
||||
}
|
||||
"module": "esnext",
|
||||
"outDir": "./dist/out-tsc",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "es5",
|
||||
"types": ["node"],
|
||||
"resolveJsonModule":true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
]
|
||||
}
,
|
||||
"files": [
|
||||
"main.ts",
|
||||
"polyfills.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in new issue