From 7064afb780e1a86ce684a46fec501908573e11cf Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Tue, 9 May 2017 16:27:14 +0100 Subject: [PATCH] Some series information stuff, changes the pace theme too. --- Ombi/Ombi.Core/Engine/TvSearchEngine.cs | 31 +++++- Ombi/Ombi.Core/Ombi.Core.csproj | 1 + Ombi/Ombi.Core/TvSender.cs | 84 ++++++++++++++ Ombi/Ombi/Views/Shared/_Layout.cshtml | 2 +- Ombi/Ombi/gulpfile.js | 8 +- Ombi/Ombi/package.json | 1 + Ombi/Ombi/wwwroot/app/app.module.ts | 4 +- .../wwwroot/app/interfaces/ISearchTvResult.ts | 2 +- .../search/seriesinformation.component.html | 104 +++++++++--------- .../app/search/seriesinformation.component.ts | 13 ++- 10 files changed, 186 insertions(+), 64 deletions(-) create mode 100644 Ombi/Ombi.Core/TvSender.cs diff --git a/Ombi/Ombi.Core/Engine/TvSearchEngine.cs b/Ombi/Ombi.Core/Engine/TvSearchEngine.cs index d030a20d1..04c66aa99 100644 --- a/Ombi/Ombi.Core/Engine/TvSearchEngine.cs +++ b/Ombi/Ombi.Core/Engine/TvSearchEngine.cs @@ -59,14 +59,33 @@ namespace Ombi.Core.Engine foreach (var e in episodes) { var season = mapped.SeasonRequests.FirstOrDefault(x => x.SeasonNumber == e.season); - season?.Episodes.Add(new EpisodesRequested + if (season == null) { - Url = e.url, - Title = e.name, - AirDate = DateTime.Parse(e.airstamp), - EpisodeNumber = e.number, + var newSeason = new SeasonRequestModel + { + SeasonNumber = e.season, + }; + newSeason.Episodes.Add(new EpisodesRequested + { + Url = e.url, + Title = e.name, + AirDate = DateTime.Parse(e.airstamp), + EpisodeNumber = e.number, + }); + mapped.SeasonRequests.Add(newSeason); - }); + } + else + { + season.Episodes.Add(new EpisodesRequested + { + Url = e.url, + Title = e.name, + AirDate = DateTime.Parse(e.airstamp), + EpisodeNumber = e.number, + + }); + } } var existingRequests = await GetTvRequests(); diff --git a/Ombi/Ombi.Core/Ombi.Core.csproj b/Ombi/Ombi.Core/Ombi.Core.csproj index 6f02e21b2..45d89121c 100644 --- a/Ombi/Ombi.Core/Ombi.Core.csproj +++ b/Ombi/Ombi.Core/Ombi.Core.csproj @@ -17,6 +17,7 @@ + diff --git a/Ombi/Ombi.Core/TvSender.cs b/Ombi/Ombi.Core/TvSender.cs new file mode 100644 index 000000000..359bde003 --- /dev/null +++ b/Ombi/Ombi.Core/TvSender.cs @@ -0,0 +1,84 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Ombi.Api.Sonarr; +using Ombi.Core.Models.Requests; +using Ombi.Core.Settings.Models.External; + +namespace Ombi.Core +{ + public class TvSender + { + public TvSender(ISonarrApi sonarrApi, ILogger log) + { + SonarrApi = sonarrApi; + Logger = log; + } + + private ISonarrApi SonarrApi { get; } + private ILogger Logger { get; } + + //public async Task SendToSonarr(SonarrSettings sonarrSettings, TvRequestModel model, + // string qualityId) + //{ + // var qualityProfile = 0; + // if (!string.IsNullOrEmpty(qualityId)) // try to parse the passed in quality, otherwise use the settings default quality + // { + // int.TryParse(qualityId, out qualityProfile); + // } + + // if (qualityProfile <= 0) + // { + // int.TryParse(sonarrSettings.QualityProfile, out qualityProfile); + // } + // var rootFolderPath = model.RootFolderSelected <= 0 ? sonarrSettings.FullRootPath : await GetSonarrRootPath(model.RootFolderSelected, sonarrSettings); + + // //var episodeRequest = model.Episodes.Any(); + // //var requestAll = model.SeasonsRequested?.Equals("All", StringComparison.CurrentCultureIgnoreCase); + // //var first = model.SeasonsRequested?.Equals("First", StringComparison.CurrentCultureIgnoreCase); + // //var latest = model.SeasonsRequested?.Equals("Latest", StringComparison.CurrentCultureIgnoreCase); + // //var specificSeasonRequest = model.SeasonList?.Any(); + + // //if (episodeRequest) + // //{ + // // return await ProcessSonarrEpisodeRequest(sonarrSettings, model, qualityProfile, rootFolderPath); + // //} + + // //if (requestAll ?? false) + // //{ + // // return await ProcessSonarrRequestSeason(sonarrSettings, model, qualityProfile, rootFolderPath); + // //} + + // //if (first ?? false) + // //{ + // // return await ProcessSonarrRequestSeason(sonarrSettings, model, qualityProfile, rootFolderPath); + // //} + + // //if (latest ?? false) + // //{ + // // return await ProcessSonarrRequestSeason(sonarrSettings, model, qualityProfile, rootFolderPath); + // //} + + // //if (specificSeasonRequest ?? false) + // //{ + // // return await ProcessSonarrRequestSeason(sonarrSettings, model, qualityProfile, rootFolderPath); + // //} + + // return null; + //} + + private async Task GetSonarrRootPath(int pathId, SonarrSettings sonarrSettings) + { + var rootFoldersResult = await SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri); + + foreach (var r in rootFoldersResult.Where(r => r.id == pathId)) + { + return r.path; + } + return string.Empty; + } + + + } +} \ No newline at end of file diff --git a/Ombi/Ombi/Views/Shared/_Layout.cshtml b/Ombi/Ombi/Views/Shared/_Layout.cshtml index cffc02a60..3dd96968a 100644 --- a/Ombi/Ombi/Views/Shared/_Layout.cshtml +++ b/Ombi/Ombi/Views/Shared/_Layout.cshtml @@ -6,7 +6,7 @@ Ombi - + @**@ diff --git a/Ombi/Ombi/gulpfile.js b/Ombi/Ombi/gulpfile.js index 273ed969e..0b46a534a 100644 --- a/Ombi/Ombi/gulpfile.js +++ b/Ombi/Ombi/gulpfile.js @@ -34,6 +34,7 @@ var paths = { '@angular/router', '@angular/forms', '@angular/platform-browser/animations', + '@angular/material', 'ngx-infinite-scroll' ], dest: './lib' @@ -62,8 +63,13 @@ var paths = { libcss: [ // Normal css files to be copied { src: [ - './bower_components/PACE/themes/purple/pace-theme-minimal.css', './bower_components/font-awesome/css/font-awesome.css', + './bower_components/PACE/themes/orange/pace-theme-barber-shop.css', + './bower_components/PACE/themes/orange/pace-theme-big-counter.css', + './bower_components/PACE/themes/orange/pace-theme-fill-left.css', + './bower_components/PACE/themes/orange/pace-theme-flash.css', + './bower_components/PACE/themes/orange/pace-theme-flat-top.css', + './bower_components/PACE/themes/orange/pace-theme-loading-bar.css', './node_modules/primeng/resources/primeng.css', './node_modules/tether/dist/css/tether.css' ], diff --git a/Ombi/Ombi/package.json b/Ombi/Ombi/package.json index a752a5410..c6800452a 100644 --- a/Ombi/Ombi/package.json +++ b/Ombi/Ombi/package.json @@ -10,6 +10,7 @@ "@angular/core": "^4.1.0", "@angular/forms": "^4.1.0", "@angular/http": "^4.1.0", + "@angular/material": "^2.0.0-beta.3", "@angular/platform-browser": "^4.1.0", "@angular/platform-browser-dynamic": "^4.1.0", "@angular/platform-server": "^4.1.0", diff --git a/Ombi/Ombi/wwwroot/app/app.module.ts b/Ombi/Ombi/wwwroot/app/app.module.ts index 11e0b66e1..9af92c40b 100644 --- a/Ombi/Ombi/wwwroot/app/app.module.ts +++ b/Ombi/Ombi/wwwroot/app/app.module.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { FormsModule } from '@angular/forms'; +import { MdButtonModule} from '@angular/material'; import { AppComponent } from './app.component'; @@ -73,7 +74,8 @@ const routes: Routes = [ InfiniteScrollModule, AuthModule, WizardModule, - DialogModule + DialogModule, + MdButtonModule ], declarations: [ AppComponent, diff --git a/Ombi/Ombi/wwwroot/app/interfaces/ISearchTvResult.ts b/Ombi/Ombi/wwwroot/app/interfaces/ISearchTvResult.ts index 7f30f9c4b..0c52813b8 100644 --- a/Ombi/Ombi/wwwroot/app/interfaces/ISearchTvResult.ts +++ b/Ombi/Ombi/wwwroot/app/interfaces/ISearchTvResult.ts @@ -21,7 +21,7 @@ export interface ISearchTvResult { siteRating: number, trailer: string, homepage:string, - seasonsRequested: ISeasonRequests[], + seasonsRequests: ISeasonRequests[], requestAll:boolean, approved: boolean, requested: boolean, diff --git a/Ombi/Ombi/wwwroot/app/search/seriesinformation.component.html b/Ombi/Ombi/wwwroot/app/search/seriesinformation.component.html index c476baf8f..c8569d0da 100644 --- a/Ombi/Ombi/wwwroot/app/search/seriesinformation.component.html +++ b/Ombi/Ombi/wwwroot/app/search/seriesinformation.component.html @@ -1,64 +1,66 @@ 
+ + -
+

Season: {{season.seasonNumber}}

- - - - - - + + + + + + - - - - - + + + + - - - + + + + +
- - # - - - - Title - - - - Air Date - - - - Status - -
+ + # + + + + Title + + + + Air Date + + + + Status + +
- {{ep.episodeNumber}} - - {{ep.title}} - - {{ep.airDate | date: 'dd/MM/yyyy' }} - - Available - Processing Request -
- +
+ {{ep.episodeNumber}} + + {{ep.title}} + + {{ep.airDate | date: 'dd/MM/yyyy' }} + + Available + Processing Request +
+ - -
- Details/Edit -
+ + +
- -
\ No newline at end of file +
diff --git a/Ombi/Ombi/wwwroot/app/search/seriesinformation.component.ts b/Ombi/Ombi/wwwroot/app/search/seriesinformation.component.ts index 5cf5bd441..58ddef3a5 100644 --- a/Ombi/Ombi/wwwroot/app/search/seriesinformation.component.ts +++ b/Ombi/Ombi/wwwroot/app/search/seriesinformation.component.ts @@ -10,7 +10,7 @@ import { NotificationService } from '../services/notification.service'; import { ISearchTvResult } from '../interfaces/ISearchTvResult'; import { IRequestEngineResult } from '../interfaces/IRequestEngineResult'; - +import { IEpisodesRequested } from"../interfaces/IRequestModel"; @Component({ selector: 'ombi', moduleId: module.id, @@ -33,12 +33,14 @@ export class SeriesInformationComponent implements OnInit, OnDestroy { seriesId: number; series: ISearchTvResult; + requestedEpisodes: IEpisodesRequested[] = []; + ngOnInit(): void { this.searchService.getShowInformation(this.seriesId) .takeUntil(this.subscriptions) .subscribe(x => { - this.series = x; + this.series = x as ISearchTvResult; }); } @@ -48,7 +50,7 @@ export class SeriesInformationComponent implements OnInit, OnDestroy { this.requestService.requestTv(this.series) .takeUntil(this.subscriptions) .subscribe(x => { - this.result = x; + this.result = x as IRequestEngineResult; if (this.result.requestAdded) { this.notificationService.success("Request Added", `Request for ${this.series.seriesName} has been added successfully`); @@ -58,6 +60,11 @@ export class SeriesInformationComponent implements OnInit, OnDestroy { }); } + addRequest(episode: IEpisodesRequested) { + this.requestedEpisodes.push(episode); + episode.requested = true; + + } ngOnDestroy(): void {