mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
wip on the movie db exclusion
This commit is contained in:
parent
23be71d8d9
commit
95ba89df44
3 changed files with 102 additions and 7 deletions
|
@ -6,14 +6,37 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<input type="checkbox" id="showAdultMovies" name="showAdultMovies" [(ngModel)]="settings.showAdultMovies">
|
<input type="checkbox" id="showAdultMovies" name="showAdultMovies" [(ngModel)]="settings.showAdultMovies">
|
||||||
<label for="showAdultMovies" tooltipPosition="top" pTooltip="Include adult movies (pornography) in results">Show Adult Movies</label>
|
<label for="showAdultMovies" matTooltip="Include adult movies (pornography) in results">Show Adult Movies</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label" pTooltip="Prevent movies with certain keywords from being suggested. May require a restart to take effect.">
|
<label class="control-label" matTooltip="Prevent movies with certain keywords from being suggested. May require a restart to take effect.">
|
||||||
Excluded Keyword IDs for Movie Suggestions
|
Excluded Keyword IDs for Movie Suggestions
|
||||||
</label>
|
</label>
|
||||||
|
<form [formGroup]='tagForm'>
|
||||||
|
<mat-form-field class="example-chip-list">
|
||||||
|
<mat-chip-list #chipList>
|
||||||
|
<mat-chip *ngFor="let fruit of excludedKeywords" [selectable]="false"
|
||||||
|
[removable]="true" (removed)="remove(fruit)">
|
||||||
|
{{fruit.name}}
|
||||||
|
<mat-icon matChipRemove >cancel</mat-icon>
|
||||||
|
</mat-chip>
|
||||||
|
<input placeholder="New Keyword"
|
||||||
|
#fruitInput
|
||||||
|
formControlName='input'
|
||||||
|
[matChipInputFor]="chipList"
|
||||||
|
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
|
||||||
|
[matChipInputAddOnBlur]="true"
|
||||||
|
>
|
||||||
|
</mat-chip-list>
|
||||||
|
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)">
|
||||||
|
<mat-option *ngFor="let fruit of filteredTags" [value]="fruit">
|
||||||
|
{{fruit.name}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-autocomplete>
|
||||||
|
</mat-form-field>
|
||||||
|
</form>
|
||||||
<!-- <tag-input #input
|
<!-- <tag-input #input
|
||||||
[(ngModel)]="excludedKeywords"
|
[(ngModel)]="excludedKeywords"
|
||||||
[identifyBy]="'id'" [displayBy]="'name'"
|
[identifyBy]="'id'" [displayBy]="'name'"
|
||||||
|
|
|
@ -9,3 +9,7 @@
|
||||||
box-shadow: 0 5px 11px 0 rgba(255, 255, 255, 0.18), 0 4px 15px 0 rgba(255, 255, 255, 0.15);
|
box-shadow: 0 5px 11px 0 rgba(255, 255, 255, 0.18), 0 4px 15px 0 rgba(255, 255, 255, 0.15);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.example-chip-list {
|
||||||
|
width: 100%;
|
||||||
|
}
|
|
@ -1,10 +1,15 @@
|
||||||
import { Component, OnInit } from "@angular/core";
|
import {COMMA, ENTER} from "@angular/cdk/keycodes";
|
||||||
import { empty, of } from "rxjs";
|
import { Component, OnInit, ElementRef, ViewChild } from "@angular/core";
|
||||||
|
import { MatChipInputEvent } from "@angular/material/chips";
|
||||||
|
import { MatAutocompleteSelectedEvent, MatAutocomplete } from "@angular/material/autocomplete";
|
||||||
|
import { empty, of, Observable } from "rxjs";
|
||||||
|
|
||||||
import { ITheMovieDbSettings } from "../../interfaces";
|
import { ITheMovieDbSettings, IMovieDbKeyword } from "../../interfaces";
|
||||||
import { NotificationService } from "../../services";
|
import { NotificationService } from "../../services";
|
||||||
import { SettingsService } from "../../services";
|
import { SettingsService } from "../../services";
|
||||||
import { TheMovieDbService } from "../../services";
|
import { TheMovieDbService } from "../../services";
|
||||||
|
import { FormControl, FormBuilder, FormGroup } from "@angular/forms";
|
||||||
|
import { startWith, map, debounceTime, tap, switchMap, finalize } from "rxjs/operators";
|
||||||
|
|
||||||
interface IKeywordTag {
|
interface IKeywordTag {
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -20,12 +25,22 @@ export class TheMovieDbComponent implements OnInit {
|
||||||
|
|
||||||
public settings: ITheMovieDbSettings;
|
public settings: ITheMovieDbSettings;
|
||||||
public excludedKeywords: IKeywordTag[];
|
public excludedKeywords: IKeywordTag[];
|
||||||
|
public tagForm: FormGroup;
|
||||||
|
public filteredTags: IMovieDbKeyword[];
|
||||||
|
@ViewChild('fruitInput') public fruitInput: ElementRef<HTMLInputElement>;
|
||||||
|
@ViewChild('auto') public matAutocomplete: MatAutocomplete;
|
||||||
|
|
||||||
|
private readonly separatorKeysCodes: number[] = [ENTER, COMMA];
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService,
|
constructor(private settingsService: SettingsService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
private tmdbService: TheMovieDbService) { }
|
private tmdbService: TheMovieDbService,
|
||||||
|
private fb: FormBuilder) { }
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
|
this.tagForm = this.fb.group({
|
||||||
|
input: null,
|
||||||
|
});
|
||||||
this.settingsService.getTheMovieDbSettings().subscribe(settings => {
|
this.settingsService.getTheMovieDbSettings().subscribe(settings => {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.excludedKeywords = settings.excludedKeywordIds
|
this.excludedKeywords = settings.excludedKeywordIds
|
||||||
|
@ -36,6 +51,34 @@ export class TheMovieDbComponent implements OnInit {
|
||||||
}))
|
}))
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.tagForm
|
||||||
|
.get("input")
|
||||||
|
.valueChanges.pipe(
|
||||||
|
debounceTime(600),
|
||||||
|
switchMap((value: string) => {
|
||||||
|
if (value) {
|
||||||
|
return this.tmdbService.getKeywords(value);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe((r) => (this.filteredTags = r));
|
||||||
|
|
||||||
|
// this.tagForm.controls.input.valueChanges
|
||||||
|
// .pipe(
|
||||||
|
// debounceTime(500),
|
||||||
|
// switchMap(value => this.tmdbService.getKeywords(value))
|
||||||
|
// )
|
||||||
|
// .subscribe((data: IMovieDbKeyword[]) => {
|
||||||
|
// this.filteredTags = data;
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async selected(event: MatAutocompleteSelectedEvent) {
|
||||||
|
const keywordId = await this.tmdbService.getKeyword(+event.option.value).toPromise();
|
||||||
|
this.excludedKeywords.push({ id: keywordId.id, name: keywordId.name, initial: false});
|
||||||
|
this.fruitInput.nativeElement.value = '';
|
||||||
|
this.tagForm.controls.input.setValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public autocompleteKeyword = (text: string) => this.tmdbService.getKeywords(text);
|
public autocompleteKeyword = (text: string) => this.tmdbService.getKeywords(text);
|
||||||
|
@ -59,6 +102,31 @@ export class TheMovieDbComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async add(event: MatChipInputEvent) {
|
||||||
|
const input = event.input;
|
||||||
|
const value = event.value;
|
||||||
|
|
||||||
|
// Add our fruit
|
||||||
|
if ((value || '').trim()) {
|
||||||
|
const keyword = await this.tmdbService.getKeywords(value).toPromise();
|
||||||
|
this.excludedKeywords.push({ id: keyword[0].id, name: keyword[0].name, initial: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset the input value
|
||||||
|
if (input) {
|
||||||
|
input.value = '';
|
||||||
|
}
|
||||||
|
this.tagForm.controls.input.setValue(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public remove(tag: IKeywordTag): void {
|
||||||
|
const index = this.excludedKeywords.indexOf(tag);
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
this.excludedKeywords.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public save() {
|
public save() {
|
||||||
this.settings.excludedKeywordIds = this.excludedKeywords.map(k => k.id);
|
this.settings.excludedKeywordIds = this.excludedKeywords.map(k => k.id);
|
||||||
this.settingsService.saveTheMovieDbSettings(this.settings).subscribe(x => {
|
this.settingsService.saveTheMovieDbSettings(this.settings).subscribe(x => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue