From 0b49518b0b3569aee97c8079a8eda3a21e12a4d3 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 3 May 2020 03:05:36 +0200 Subject: [PATCH] Adding identify of external shows --- .../episodes-list.component.scss | 4 +- .../metadata-edit.component.html | 13 ++++-- .../metadata-edit.component.scss | 18 ++++++++ .../metadata-edit/metadata-edit.component.ts | 42 +++++++++++++++---- src/app/show-grid/show-grid.component.html | 2 +- src/app/show-grid/show-grid.component.ts | 3 +- src/models/external-id.ts | 6 ++- src/models/provider.ts | 5 +++ 8 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 src/models/provider.ts diff --git a/src/app/episodes-list/episodes-list.component.scss b/src/app/episodes-list/episodes-list.component.scss index b51e4ec7..6135891e 100644 --- a/src/app/episodes-list/episodes-list.component.scss +++ b/src/app/episodes-list/episodes-list.component.scss @@ -1,6 +1,6 @@ -@import "~bootstrap//scss/functions"; +@import "~bootstrap/scss/functions"; @import "~bootstrap/scss/variables"; -@import "~bootstrap/scss//mixins/breakpoints"; +@import "~bootstrap/scss/mixins/breakpoints"; .root { diff --git a/src/app/metadata-edit/metadata-edit.component.html b/src/app/metadata-edit/metadata-edit.component.html index a5f2b959..32d8162d 100644 --- a/src/app/metadata-edit/metadata-edit.component.html +++ b/src/app/metadata-edit/metadata-edit.component.html @@ -84,15 +84,22 @@ Identify show Search on metadata providers - + Search for - + + {{provider.name}} ID + + +
- +
diff --git a/src/app/metadata-edit/metadata-edit.component.scss b/src/app/metadata-edit/metadata-edit.component.scss index e69de29b..1c4773f4 100644 --- a/src/app/metadata-edit/metadata-edit.component.scss +++ b/src/app/metadata-edit/metadata-edit.component.scss @@ -0,0 +1,18 @@ +@import "~bootstrap/scss/functions"; +@import "~bootstrap/scss/variables"; +@import "~bootstrap/scss/mixins/breakpoints"; + +.provider +{ + width: 100%; + + @include media-breakpoint-up(md) + { + width: 33%; + } + + @include media-breakpoint-up(lg) + { + width: 25%; + } +} \ No newline at end of file diff --git a/src/app/metadata-edit/metadata-edit.component.ts b/src/app/metadata-edit/metadata-edit.component.ts index efa7351c..d0965f61 100644 --- a/src/app/metadata-edit/metadata-edit.component.ts +++ b/src/app/metadata-edit/metadata-edit.component.ts @@ -9,22 +9,25 @@ import {Observable, of} from "rxjs"; import {tap} from "rxjs/operators"; import {Studio} from "../../models/studio"; import {ShowGridComponent} from "../show-grid/show-grid.component"; +import {Provider} from "../../models/provider"; @Component({ selector: 'app-metadata-edit', templateUrl: './metadata-edit.component.html', styleUrls: ['./metadata-edit.component.scss'] }) -export class MetadataEditComponent implements OnInit +export class MetadataEditComponent { - @ViewChild("genreInput") genreInput: ElementRef; - + @ViewChild("genreInput") private genreInput: ElementRef; private allGenres: Genre[]; private allStudios: Studio[]; + @ViewChild("identifyGrid") private identifyGrid: ShowGridComponent; private identifing: Observable; private identifiedShows: [string, Show[]]; - @ViewChild("identifyGrid") private identifyGrid: ShowGridComponent; + private providers: Provider[]; + + public metadataChanged: boolean = false; constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public show: Show, private http: HttpClient) { @@ -36,13 +39,13 @@ export class MetadataEditComponent implements OnInit { this.allStudios = result; }); + this.http.get("/api/providers").subscribe(result => + { + this.providers = result; + }); this.reIdentify(this.show.title); } - - ngOnInit(): void - { - } apply(): void { @@ -103,7 +106,28 @@ export class MetadataEditComponent implements OnInit reIdentify(search: string) { - console.log("Searching for " + search); this.identityShow(search).subscribe(x => this.identifyGrid.shows = x); } + + getMetadataID(show: Show, provider: Provider) + { + return show.externalIDs.find(x => x.provider.name == provider.name); + } + + setMetadataID(show: Show, provider: Provider, id: string) + { + let i = show.externalIDs.findIndex(x => x.provider.name == provider.name); + + this.metadataChanged = true; + if (i != -1) + show.externalIDs[i].dataID = id; + else + show.externalIDs.push({provider: provider, dataID: id, link: undefined}); + } + + identifyID(show: Show) + { + for (let id of show.externalIDs) + this.setMetadataID(this.show, id.provider, id.dataID); + } } diff --git a/src/app/show-grid/show-grid.component.html b/src/app/show-grid/show-grid.component.html index 1f505bc6..1826ecb6 100644 --- a/src/app/show-grid/show-grid.component.html +++ b/src/app/show-grid/show-grid.component.html @@ -1,7 +1,7 @@