From d31fd6f5a20fe0c522fb32ddfc8ff8ca5e0fb3f0 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 8 Feb 2019 10:10:35 +0000 Subject: [PATCH] !wip --- .../card/discover-card.component.scss | 11 +- .../src/app/discover/discover.component.html | 38 +++++- .../src/app/discover/discover.component.scss | 7 +- .../src/app/discover/discover.component.ts | 29 ++++- .../src/app/my-nav/nav-search.component.html | 2 +- .../src/app/my-nav/nav-search.component.scss | 9 ++ .../src/app/my-nav/nav-search.component.ts | 16 ++- src/Ombi/Startup.cs | 119 ++++++++++++------ src/Ombi/Views/Shared/_Layout.cshtml | 23 ++-- 9 files changed, 185 insertions(+), 69 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/discover/card/discover-card.component.scss b/src/Ombi/ClientApp/src/app/discover/card/discover-card.component.scss index 105be5db7..ed3b52e15 100644 --- a/src/Ombi/ClientApp/src/app/discover/card/discover-card.component.scss +++ b/src/Ombi/ClientApp/src/app/discover/card/discover-card.component.scss @@ -1,14 +1,15 @@ $ombi-primary:#3f3f3f; +$card-background: #2b2b2b; #cardImage { - max-height: 163px; + max-height: 68%; border-radius: 5px 5px 0px 0px; } .dark-card { - background-color: $ombi-primary; + background-color: $card-background; border-radius: 8px; color: white; - height: 360px; + height: 435px; } .card-spacing { @@ -21,13 +22,13 @@ $ombi-primary:#3f3f3f; font-weight: bold; } -$border-width: 2px; +$border-width: 3px; .movie-image { border-bottom: $border-width orange solid; } .tv-image { - border-bottom: $border-width teal solid; + border-bottom: $border-width #1DE9B6 solid; } .expand { diff --git a/src/Ombi/ClientApp/src/app/discover/discover.component.html b/src/Ombi/ClientApp/src/app/discover/discover.component.html index 72b5879c1..a0fe044a6 100644 --- a/src/Ombi/ClientApp/src/app/discover/discover.component.html +++ b/src/Ombi/ClientApp/src/app/discover/discover.component.html @@ -1,7 +1,35 @@
-
-
- -
+ +
+
+ + + +
-
\ No newline at end of file + +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/discover/discover.component.scss b/src/Ombi/ClientApp/src/app/discover/discover.component.scss index 4fc5ac7d6..b4e0e7335 100644 --- a/src/Ombi/ClientApp/src/app/discover/discover.component.scss +++ b/src/Ombi/ClientApp/src/app/discover/discover.component.scss @@ -5,10 +5,11 @@ .small-middle-container{ margin: auto; - width: 95%; + width: 80%; } .small-padding { - padding-left: 5px; - padding-right: 5px; + padding-left: 20px; + padding-right: 20px; + margin-bottom: 28px; } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/discover/discover.component.ts b/src/Ombi/ClientApp/src/app/discover/discover.component.ts index 45f4709a1..147382ea8 100644 --- a/src/Ombi/ClientApp/src/app/discover/discover.component.ts +++ b/src/Ombi/ClientApp/src/app/discover/discover.component.ts @@ -31,6 +31,33 @@ export class DiscoverComponent implements OnInit { this.movies = await this.searchService.popularMovies().toPromise(); this.tvShows = await this.searchService.popularTv().toPromise(); + this.createModel(); + + } + + public async popular() { + this.movies = await this.searchService.popularMovies().toPromise(); + this.tvShows = await this.searchService.popularTv().toPromise(); + + this.createModel(); + } + + public async trending() { + this.movies = await this.searchService.nowPlayingMovies().toPromise(); + this.tvShows = await this.searchService.trendingTv().toPromise(); + + this.createModel(); + } + + public async upcoming() { + this.movies = await this.searchService.upcomingMovies().toPromise(); + this.tvShows = await this.searchService.anticipatedTv().toPromise(); + + this.createModel(); + } + + private createModel() { + this.discoverResults = []; this.movies.forEach(m => { this.discoverResults.push({ available: m.available, @@ -57,7 +84,7 @@ export class DiscoverComponent implements OnInit { overview: m.overview }); }); - + this.shuffle(this.discoverResults); } diff --git a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.html b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.html index c5b907791..28345969f 100644 --- a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.html +++ b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.html @@ -1,3 +1,3 @@ - diff --git a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.scss b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.scss index c05ab8a99..6b6cd428b 100644 --- a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.scss +++ b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.scss @@ -1,4 +1,5 @@ $ombi-primary:#3f3f3f; +$ombi-primary-darker:#2b2b2b; $ombi-accent: #258a6d; .quater-width { @@ -30,4 +31,12 @@ $ombi-accent: #258a6d; ::ng-deep ngb-typeahead-window .dropdown-item.active, .dropdown-item:active { text-decoration: none; background-color: $ombi-accent; +} + +.search-bar { + background-color: $ombi-primary-darker; + border: solid 1px $ombi-primary-darker; +} +.search-bar:focus { + background-color:white; } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.ts b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.ts index 13cad8001..d3838742b 100644 --- a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.ts +++ b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.ts @@ -21,7 +21,21 @@ export class NavSearchComponent { public searchFailed = false; - public formatter = (result: IMultiSearchResult) => result.media_type == "movie" ? result.title + ` (${result.release_date.slice(0,4)})` : result.name + ` (${result.release_date.slice(0,4)})`; + public formatter = (result: IMultiSearchResult) => { + if(result.media_type === "movie") { + let title = result.title; + if(result.release_date) { + title += ` (${result.release_date.slice(0,4)})`; + } + return title; + } else { + let title = result.name; + if(result.release_date) { + title += ` (${result.release_date.slice(0,4)})`; + } + return title; + } + } public searchModel = (text$: Observable) => text$.pipe( diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index de8dbdc25..2211bcbd3 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -1,22 +1,22 @@ -using System; -using System.IO; -using AutoMapper; +using AutoMapper; using AutoMapper.EquivalencyExpression; using Hangfire; using Hangfire.Dashboard; using Hangfire.SQLite; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.SpaServices.AngularCli; -using Microsoft.AspNetCore.SpaServices.Webpack; +using Microsoft.AspNetCore.SpaServices; +using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Ombi.Core.Authentication; using Ombi.Core.Settings; using Ombi.DependencyInjection; @@ -28,12 +28,22 @@ using Ombi.Store.Context; using Ombi.Store.Entities; using Ombi.Store.Repository; using Serilog; +using System; +using System.IO; namespace Ombi { public class Startup { public static StoragePathSingleton StoragePath => StoragePathSingleton.Instance; + + private static readonly Action ConfigureSpaDefaults = + spa => + { + spa.Options.SourcePath = "ClientApp"; + spa.UseProxyToSpaDevelopmentServer("http://localhost:3578"); + }; + public Startup(IHostingEnvironment env) { Console.WriteLine(env.ContentRootPath); @@ -61,6 +71,7 @@ namespace Ombi .WriteTo.RollingFile(Path.Combine(StoragePath.StoragePath, "Logs", "log-{Date}.txt")) .CreateLogger(); } + Log.Logger = config; @@ -105,13 +116,11 @@ namespace Ombi services.AddJwtAuthentication(Configuration); services.AddMvc() - .AddJsonOptions(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); + .AddJsonOptions(x => + x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); services.AddOmbiMappingProfile(); - services.AddAutoMapper(expression => - { - expression.AddCollectionMappers(); - }); + services.AddAutoMapper(expression => { expression.AddCollectionMappers(); }); services.RegisterApplicationDependencies(); // Ioc and EF services.AddSwagger(); @@ -122,6 +131,7 @@ namespace Ombi { i.StoragePath = string.Empty; } + var sqliteStorage = $"Data Source={Path.Combine(i.StoragePath, "Schedules.db")};"; services.AddHangfire(x => @@ -139,10 +149,7 @@ namespace Ombi })); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); - services.AddSpaStaticFiles(configuration => - { - configuration.RootPath = "ClientApp/dist"; - }); + services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); // Build the intermediate service provider return services.BuildServiceProvider(); @@ -195,23 +202,25 @@ namespace Ombi ombiService.SaveSettings(settings); } } + if (settings.BaseUrl.HasValue()) { app.UsePathBase(settings.BaseUrl); } - app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = 1, ServerTimeout = TimeSpan.FromDays(1), ShutdownTimeout = TimeSpan.FromDays(1)}); + app.UseHangfireServer(new BackgroundJobServerOptions + {WorkerCount = 1, ServerTimeout = TimeSpan.FromDays(1), ShutdownTimeout = TimeSpan.FromDays(1)}); if (env.IsDevelopment()) { app.UseHangfireDashboard(settings.BaseUrl.HasValue() ? $"{settings.BaseUrl}/hangfire" : "/hangfire", new DashboardOptions { - Authorization = new[] { new HangfireAuthorizationFilter() } + Authorization = new[] {new HangfireAuthorizationFilter()} }); } - GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 }); - + GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute {Attempts = 3}); + // Setup the scheduler var jobSetup = app.ApplicationServices.GetService(); jobSetup.Setup(); @@ -221,7 +230,7 @@ namespace Ombi settingsctx.Seed(); externalctx.Seed(); - var provider = new FileExtensionContentTypeProvider { Mappings = { [".map"] = "application/octet-stream" } }; + var provider = new FileExtensionContentTypeProvider {Mappings = {[".map"] = "application/octet-stream"}}; app.UseStaticFiles(new StaticFileOptions() { @@ -241,30 +250,62 @@ namespace Ombi c.SwaggerEndpoint("/swagger/v2/swagger.json", "API V2"); }); - app.UseMvc(routes => + app.UseMvcWithDefaultRoute(); + if (env.IsDevelopment()) { - routes.MapRoute( - name: "default", - template: "{controller=Home}/{action=Index}/{id?}"); - }); - - app.UseSpa(spa => - { - spa.Options.SourcePath = "ClientApp"; - if (env.IsDevelopment()) - { - spa.UseProxyToSpaDevelopmentServer("http://localhost:3578"); - //spa.UseAngularCliServer("start"); - } - }); + app.MapWhen(IsSpaRoute, spaApp => { UseSpaWithoutIndexHtml(spaApp, ConfigureSpaDefaults); }); + } } - } - public class HangfireAuthorizationFilter : IDashboardAuthorizationFilter - { - public bool Authorize(DashboardContext context) + private static bool IsSpaRoute(HttpContext context) { - return true; + var path = context.Request.Path; + // This should probably be a compiled regex + return path.StartsWithSegments("/static") + || path.StartsWithSegments("/sockjs-node") + || path.StartsWithSegments("/socket.io") + || path.ToString().Contains(".hot-update."); } + + private static void UseSpaWithoutIndexHtml(IApplicationBuilder app, Action configuration) + { + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + // Use the options configured in DI (or blank if none was configured). We have to clone it + // otherwise if you have multiple UseSpa calls, their configurations would interfere with one another. + var optionsProvider = app.ApplicationServices.GetService>(); + var options = new SpaOptions(); + + var spaBuilder = new DefaultSpaBuilder(app, options); + configuration.Invoke(spaBuilder); + } + + private class DefaultSpaBuilder : ISpaBuilder + { + public IApplicationBuilder ApplicationBuilder { get; } + + public SpaOptions Options { get; } + + public DefaultSpaBuilder(IApplicationBuilder applicationBuilder, SpaOptions options) + { + ApplicationBuilder = applicationBuilder + ?? throw new ArgumentNullException(nameof(applicationBuilder)); + + Options = options + ?? throw new ArgumentNullException(nameof(options)); + } + } + + public class HangfireAuthorizationFilter : IDashboardAuthorizationFilter + { + public bool Authorize(DashboardContext context) + { + return true; + } + } + } } diff --git a/src/Ombi/Views/Shared/_Layout.cshtml b/src/Ombi/Views/Shared/_Layout.cshtml index 0f2340698..824175250 100644 --- a/src/Ombi/Views/Shared/_Layout.cshtml +++ b/src/Ombi/Views/Shared/_Layout.cshtml @@ -59,7 +59,6 @@ --> - @* @@ -81,6 +80,8 @@ @appName + + @@ -92,40 +93,34 @@ - - + + + + @if (s?.CollectAnalyticData ?? true) { } - - - - - - - @{ if (customization.CustomCss.HasValue()) { - } } - - @RenderBody() +

Loading...