diff --git a/src/Ombi/ClientApp/app/interfaces/ISearchMusicResult.ts b/src/Ombi/ClientApp/app/interfaces/ISearchMusicResult.ts new file mode 100644 index 000000000..ecf705f0e --- /dev/null +++ b/src/Ombi/ClientApp/app/interfaces/ISearchMusicResult.ts @@ -0,0 +1,21 @@ +export interface ISearchArtistResult { + artistName: string; + forignArtistId: string; + + banner: string; + overview: string; + poster: string; + monitored: boolean; + approved: boolean; + requested: boolean; + requestId: number; + available: boolean; + + subscribed: boolean; + showSubscribe: boolean; + + // for the UI + requestProcessing: boolean; + processed: boolean; + background: any; +} diff --git a/src/Ombi/ClientApp/app/interfaces/index.ts b/src/Ombi/ClientApp/app/interfaces/index.ts index 013d4278d..74a39099e 100644 --- a/src/Ombi/ClientApp/app/interfaces/index.ts +++ b/src/Ombi/ClientApp/app/interfaces/index.ts @@ -15,3 +15,4 @@ export * from "./IUser"; export * from "./IIssues"; export * from "./IRecentlyAdded"; export * from "./ILidarr"; +export * from "./ISearchMusicResult"; diff --git a/src/Ombi/ClientApp/app/search/music/musicsearch.component.html b/src/Ombi/ClientApp/app/search/music/musicsearch.component.html index 44dc345bc..347864be8 100644 --- a/src/Ombi/ClientApp/app/search/music/musicsearch.component.html +++ b/src/Ombi/ClientApp/app/search/music/musicsearch.component.html @@ -3,18 +3,6 @@
-
@@ -22,33 +10,32 @@
-
-
+
+
-
+
- poster + poster
- -

{{result.title}} ({{result.releaseDate | date: 'yyyy'}})

+
+

{{result.artistName}}

- {{ 'Search.TheatricalRelease' | translate: {date: result.releaseDate | date: 'mediumDate'} }} + @@ -60,7 +47,7 @@
-

{{result.overview}}

+

{{result.overview | truncate: 350 }}

@@ -68,8 +55,8 @@
- - +
@@ -81,25 +68,22 @@ - + {{ 'Common.Request' | translate }}
- +
- + diff --git a/src/Ombi/ClientApp/app/search/music/musicsearch.component.ts b/src/Ombi/ClientApp/app/search/music/musicsearch.component.ts index bf739f783..4007b5b9a 100644 --- a/src/Ombi/ClientApp/app/search/music/musicsearch.component.ts +++ b/src/Ombi/ClientApp/app/search/music/musicsearch.component.ts @@ -1,11 +1,13 @@ import { PlatformLocation } from "@angular/common"; import { Component, Input, OnInit } from "@angular/core"; +import { DomSanitizer } from "@angular/platform-browser"; import { TranslateService } from "@ngx-translate/core"; import { Subject } from "rxjs"; import { debounceTime, distinctUntilChanged } from "rxjs/operators"; import { AuthService } from "../../auth/auth.service"; import { IIssueCategory, IRequestEngineResult, ISearchMovieResult } from "../../interfaces"; +import { ISearchArtistResult } from "../../interfaces/ISearchMusicResult"; import { NotificationService, RequestService, SearchService } from "../../services"; @Component({ @@ -16,10 +18,10 @@ export class MusicSearchComponent implements OnInit { public searchText: string; public searchChanged: Subject = new Subject(); - public movieResults: ISearchMovieResult[]; + public artistResult: ISearchArtistResult[]; public result: IRequestEngineResult; public searchApplied = false; - public searchArtist: boolean; + public searchAlbum: boolean; @Input() public issueCategories: IIssueCategory[]; @Input() public issuesEnabled: boolean; @@ -34,7 +36,8 @@ export class MusicSearchComponent implements OnInit { private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService, private authService: AuthService, private readonly translate: TranslateService, - private readonly platformLocation: PlatformLocation) { + private readonly platformLocation: PlatformLocation, + private sanitizer: DomSanitizer) { this.searchChanged.pipe( debounceTime(600), // Wait Xms after the last event before emitting last event @@ -45,20 +48,21 @@ export class MusicSearchComponent implements OnInit { this.clearResults(); return; } - if(this.searchArtist) { - this.searchService.searchArtist(this.searchText) + if(this.searchAlbum) { + this.searchService.searchAlbum(this.searchText) .subscribe(x => { - this.movieResults = x; + this.artistResult = x; this.searchApplied = true; + this.setBackground(); }); } else { - this.searchService.searchAlbum(this.searchText) + this.searchService.searchArtist(this.searchText) .subscribe(x => { - this.movieResults = x; + this.artistResult = x; this.searchApplied = true; + this.setBackground(); }); } - }); this.defaultPoster = "../../../images/default_movie_poster.png"; const base = this.platformLocation.getBaseHrefFromDOM(); @@ -69,7 +73,7 @@ export class MusicSearchComponent implements OnInit { public ngOnInit() { this.searchText = ""; - this.movieResults = []; + this.artistResult = []; this.result = { message: "", result: false, @@ -121,7 +125,17 @@ export class MusicSearchComponent implements OnInit { } private clearResults() { - this.movieResults = []; + this.artistResult = []; this.searchApplied = false; } + + private setBackground() { + this.artistResult.forEach((val, index) => { + if (val.poster === null) { + val.poster = this.defaultPoster; + } + val.background = this.sanitizer.bypassSecurityTrustStyle + ("url(" + val.banner + ")"); + }); + } } diff --git a/src/Ombi/ClientApp/app/services/search.service.ts b/src/Ombi/ClientApp/app/services/search.service.ts index 7d2783dd9..f6a5271f5 100644 --- a/src/Ombi/ClientApp/app/services/search.service.ts +++ b/src/Ombi/ClientApp/app/services/search.service.ts @@ -7,6 +7,7 @@ import { Observable } from "rxjs"; import { TreeNode } from "primeng/primeng"; import { ISearchMovieResult } from "../interfaces"; import { ISearchTvResult } from "../interfaces"; +import { ISearchArtistResult } from "../interfaces/ISearchMusicResult"; import { ServiceHelpers } from "./service.helpers"; @Injectable() @@ -69,8 +70,8 @@ export class SearchService extends ServiceHelpers { return this.http.get(`${this.url}/Tv/trending`, {headers: this.headers}); } // Music - public searchArtist(searchTerm: string): Observable { - return this.http.get(`${this.url}/Music/Artist/` + searchTerm); + public searchArtist(searchTerm: string): Observable { + return this.http.get(`${this.url}/Music/Artist/` + searchTerm); } public searchAlbum(searchTerm: string): Observable { return this.http.get(`${this.url}/Music/Album/` + searchTerm); diff --git a/src/Ombi/ClientApp/app/shared/shared.module.ts b/src/Ombi/ClientApp/app/shared/shared.module.ts index 41a7a66fc..08b46aed4 100644 --- a/src/Ombi/ClientApp/app/shared/shared.module.ts +++ b/src/Ombi/ClientApp/app/shared/shared.module.ts @@ -2,6 +2,7 @@ import { CommonModule } from "@angular/common"; import { NgModule } from "@angular/core"; import { FormsModule } from "@angular/forms"; import { TranslateModule } from "@ngx-translate/core"; +import { TruncateModule } from "@yellowspot/ng-truncate"; import { IssuesReportComponent } from "./issues-report.component"; @@ -15,6 +16,7 @@ import { SidebarModule } from "primeng/primeng"; SidebarModule, FormsModule, CommonModule, + TruncateModule, ], exports: [ TranslateModule, @@ -22,6 +24,7 @@ import { SidebarModule } from "primeng/primeng"; FormsModule, SidebarModule, IssuesReportComponent, + TruncateModule, ], }) export class SharedModule {} diff --git a/src/Ombi/package.json b/src/Ombi/package.json index b51f76523..5fac0c31a 100644 --- a/src/Ombi/package.json +++ b/src/Ombi/package.json @@ -35,6 +35,7 @@ "@types/webpack": "^4.4.4", "@types/webpack-bundle-analyzer": "^2.9.2", "@types/webpack-merge": "^4.1.3", + "@yellowspot/ng-truncate": "^1.4.0", "angular-router-loader": "^0.8.5", "angular2-template-loader": "^0.6.2", "aspnet-webpack": "^3.0.0", diff --git a/src/Ombi/webpack.config.vendor.ts b/src/Ombi/webpack.config.vendor.ts index e4ad442ab..dc7c282bd 100644 --- a/src/Ombi/webpack.config.vendor.ts +++ b/src/Ombi/webpack.config.vendor.ts @@ -52,6 +52,7 @@ module.exports = (env: any) => { "@ngx-translate/core", "@ngx-translate/http-loader", "ngx-order-pipe", + "@yellowspot/ng-truncate", ]), }, plugins: prod ? [] : [ diff --git a/src/Ombi/yarn.lock b/src/Ombi/yarn.lock index 2fed0fb72..68381bf9d 100644 --- a/src/Ombi/yarn.lock +++ b/src/Ombi/yarn.lock @@ -320,6 +320,10 @@ text-table "^0.2.0" webpack-log "^1.1.2" +"@yellowspot/ng-truncate@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@yellowspot/ng-truncate/-/ng-truncate-1.4.0.tgz#dcb40f5571ef71a9cf09f6a24e83e1f43b2d2a6c" + abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"