Working on the landing page #1458 #865

pull/1488/head
tidusjar 7 years ago
parent 1eb18b3187
commit 08b5527891

@ -44,7 +44,11 @@
</nav> </nav>
<div class="container top-spacing"> <div *ngIf="showNav" class="container top-spacing">
<router-outlet></router-outlet>
</div>
<div *ngIf="!showNav">
<router-outlet></router-outlet> <router-outlet></router-outlet>
</div> </div>

@ -31,6 +31,7 @@ import { AuthGuard } from './auth/auth.guard';
import { AuthModule } from './auth/auth.module'; import { AuthModule } from './auth/auth.module';
import { IdentityService } from './services/identity.service'; import { IdentityService } from './services/identity.service';
import { StatusService } from './services/status.service'; import { StatusService } from './services/status.service';
import { ImageService } from './services/image.service';
// Modules // Modules
@ -94,6 +95,7 @@ const routes: Routes = [
SettingsService, SettingsService,
IdentityService, IdentityService,
StatusService, StatusService,
ImageService,
//DragulaService //DragulaService
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]

@ -0,0 +1,3 @@
export interface IImages {
url: string
}

@ -1,51 +1,35 @@
<div *ngIf="landingPageSettings && customizationSettings"> <div *ngIf="landingPageSettings && customizationSettings && background">
<div *ngIf="customizationSettings.logo" class="landing-logo"> <style>
<img [src]="customizationSettings.logo" /> landingDiv {
</div> -webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
<h1> img.bg {
Hey! Welcome back to /* Set rules to fill background */
<span *ngIf="customizationSettings.applicationName"> min-height: 100%;
{{customizationSettings.applicationName}} min-width: 1024px;
</span> /* Set up proportionate scaling */
<span *ngIf="!customizationSettings.applicationName"> width: 100%;
Ombi height: auto;
</span> /* Set up positioning */
</h1> position: fixed;
<br /> top: 0;
<br /> left: 0;
<br /> }
<h3 *ngIf="landingPageSettings.noticeEnabled" [innerHtml]="landingPageSettings.noticeText" style="background-color: {{landingPageSettings.noticeBackgroundColor}}"></h3>
<div class="col-md-3 landing-box" [routerLink]="['/search']">
<div>
Search
</div>
</div>
<div class="col-md-3 col-md-offset-1 landing-box" [routerLink]="['/requests']"> @media screen and (max-width: 1024px) { /* Specific to this particular image */
<div> img.bg {
View all your requests left: 50%;
<br /> margin-left: -512px; /* 50% */
<br /> }
<br /> }
<div *ngIf="requestCount">
Pending Requests: <span>{{requestCount.pending}}</span>
<br />
Approved Requests: <span>{{requestCount.approved}}</span>
<br />
Available Requests: <span>{{requestCount.available}}</span>
</div>
</div>
</div>
<div class="col-md-3 col-md-offset-1 landing-box"> </style>
<div> <img class="landingDiv bg" [style.background-image]="background" />
Media Server Status:
<span *ngIf="mediaServerStatus"><i class="fa fa-check-circle" style="color: #00c853"></i></span>
<span *ngIf="!mediaServerStatus"><i class="fa fa-times-circle" style="color: #d50000"></i></span>
</div>
</div>

@ -4,6 +4,9 @@ import { RequestService } from '../services/request.service';
import { ILandingPageSettings, ICustomizationSettings } from '../interfaces/ISettings'; import { ILandingPageSettings, ICustomizationSettings } from '../interfaces/ISettings';
import { IRequestCountModel } from '../interfaces/IRequestModel'; import { IRequestCountModel } from '../interfaces/IRequestModel';
import { DomSanitizer } from '@angular/platform-browser';
import { ImageService } from '../services/image.service';
@Component({ @Component({
templateUrl: './landingpage.component.html', templateUrl: './landingpage.component.html',
@ -11,11 +14,13 @@ import { IRequestCountModel } from '../interfaces/IRequestModel';
}) })
export class LandingPageComponent implements OnInit { export class LandingPageComponent implements OnInit {
constructor(private settingsService: SettingsService, private requestService : RequestService) { } constructor(private settingsService: SettingsService, private requestService: RequestService,
private images: ImageService, private sanitizer: DomSanitizer) { }
customizationSettings : ICustomizationSettings; customizationSettings : ICustomizationSettings;
landingPageSettings: ILandingPageSettings; landingPageSettings: ILandingPageSettings;
requestCount: IRequestCountModel; requestCount: IRequestCountModel;
background: any;
mediaServerStatus: boolean; mediaServerStatus: boolean;
@ -23,7 +28,10 @@ export class LandingPageComponent implements OnInit {
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x); this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
this.settingsService.getLandingPage().subscribe(x => this.landingPageSettings = x); this.settingsService.getLandingPage().subscribe(x => this.landingPageSettings = x);
this.requestService.getRequestsCount().subscribe(x => this.requestCount = x); this.requestService.getRequestsCount().subscribe(x => this.requestCount = x);
this.images.getRandomBackground().subscribe(x => {
this.background = this.sanitizer.bypassSecurityTrustStyle('url(' + x.url + ')');
});
this.mediaServerStatus = true; this.mediaServerStatus = true;
} }
} }

@ -0,0 +1,17 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { ServiceHelpers } from './service.helpers';
import { IImages } from '../interfaces/IImages';
@Injectable()
export class ImageService extends ServiceHelpers {
constructor(public http : Http) {
super(http, '/api/v1/Images/');
}
getRandomBackground(): Observable<IImages> {
return this.http.get(`${this.url}background/`, { headers: this.headers }).map(this.extractData);
}
}

@ -3,8 +3,12 @@
namespace Ombi.Controllers namespace Ombi.Controllers
{ {
[Route(ApiBase)] [Route(ApiBase)]
public class BaseV1ApiController : Controller public class ApiV1Attribute : RouteAttribute
{ {
protected const string ApiBase = "api/v1/[controller]"; protected const string ApiBase = "api/v1/[controller]";
public ApiV1Attribute() : base(ApiBase)
{
}
} }
} }

@ -13,7 +13,8 @@ namespace Ombi.Controllers.External
/// ///
/// </summary> /// </summary>
[Admin] [Admin]
public class EmbyController : BaseV1ApiController [ApiV1]
public class EmbyController : Controller
{ {
/// <summary> /// <summary>
/// ///

@ -14,7 +14,8 @@ using Ombi.Models.External;
namespace Ombi.Controllers.External namespace Ombi.Controllers.External
{ {
[Admin] [Admin]
public class PlexController : BaseV1ApiController [ApiV1]
public class PlexController : Controller
{ {
public PlexController(IPlexApi plexApi, ISettingsService<PlexSettings> plexSettings) public PlexController(IPlexApi plexApi, ISettingsService<PlexSettings> plexSettings)
{ {

@ -10,7 +10,8 @@ using Ombi.Settings.Settings.Models.External;
namespace Ombi.Controllers.External namespace Ombi.Controllers.External
{ {
[Admin] [Admin]
public class RadarrController : BaseV1ApiController [ApiV1]
public class RadarrController : Controller
{ {
public RadarrController(IRadarrApi radarr, ISettingsService<RadarrSettings> settings) public RadarrController(IRadarrApi radarr, ISettingsService<RadarrSettings> settings)
{ {

@ -11,7 +11,8 @@ using Ombi.Core.Settings.Models.External;
namespace Ombi.Controllers.External namespace Ombi.Controllers.External
{ {
[Admin] [Admin]
public class SonarrController : BaseV1ApiController [ApiV1]
public class SonarrController : Controller
{ {
public SonarrController(ISonarrApi sonarr, ISettingsService<SonarrSettings> settings) public SonarrController(ISonarrApi sonarr, ISettingsService<SonarrSettings> settings)
{ {

@ -15,7 +15,8 @@ namespace Ombi.Controllers.External
/// </summary> /// </summary>
/// <seealso cref="Ombi.Controllers.BaseV1ApiController" /> /// <seealso cref="Ombi.Controllers.BaseV1ApiController" />
[Admin] [Admin]
public class TesterController : BaseV1ApiController [ApiV1]
public class TesterController : Controller
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TesterController" /> class. /// Initializes a new instance of the <see cref="TesterController" /> class.

@ -34,7 +34,8 @@ namespace Ombi.Controllers
/// </summary> /// </summary>
/// <seealso cref="Ombi.Controllers.BaseV1ApiController" /> /// <seealso cref="Ombi.Controllers.BaseV1ApiController" />
[PowerUser] [PowerUser]
public class IdentityController : BaseV1ApiController [ApiV1]
public class IdentityController : Controller
{ {
public IdentityController(UserManager<OmbiUser> user, IMapper mapper, RoleManager<IdentityRole> rm, IEmailProvider prov, public IdentityController(UserManager<OmbiUser> user, IMapper mapper, RoleManager<IdentityRole> rm, IEmailProvider prov,
ISettingsService<EmailNotificationSettings> s, ISettingsService<EmailNotificationSettings> s,

@ -0,0 +1,47 @@
using Microsoft.AspNetCore.Mvc;
using Ombi.Api.FanartTv;
using Ombi.Store.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Ombi.Controllers
{
[ApiV1]
public class ImagesController : Controller
{
public ImagesController(IFanartTvApi api, IApplicationConfigRepository config)
{
Api = api;
Config = config;
}
private IFanartTvApi Api { get; }
private IApplicationConfigRepository Config { get; }
[HttpGet("background")]
public async Task<object> GetBackgroundImage()
{
var moviesArray = new[]{
278,
238,
431483,
372058,
244786,
680,
155,
13,
1891,
399106
};
var key = await Config.Get(Store.Entities.ConfigurationTypes.FanartTv);
var result = await Api.GetMovieImages(155, key.Value);
return new { url = result.moviebackground[0].url };
}
}
}

@ -7,7 +7,8 @@ using System;
namespace Ombi.Controllers namespace Ombi.Controllers
{ {
[Authorize] [Authorize]
public class LoggingController : BaseV1ApiController [ApiV1]
public class LoggingController : Controller
{ {
public LoggingController(ILogger logger) public LoggingController(ILogger logger)
{ {

@ -12,7 +12,8 @@ using System.Diagnostics;
namespace Ombi.Controllers namespace Ombi.Controllers
{ {
[Authorize] [Authorize]
public class RequestController : BaseV1ApiController [ApiV1]
public class RequestController : Controller
{ {
public RequestController(IMovieRequestEngine engine, ITvRequestEngine tvRequestEngine) public RequestController(IMovieRequestEngine engine, ITvRequestEngine tvRequestEngine)
{ {

@ -14,7 +14,8 @@ using StackExchange.Profiling;
namespace Ombi.Controllers namespace Ombi.Controllers
{ {
[Authorize] [Authorize]
public class SearchController : BaseV1ApiController [ApiV1]
public class SearchController : Controller
{ {
public SearchController(IMovieEngine movie, ITvSearchEngine tvEngine, ILogger<SearchController> logger) public SearchController(IMovieEngine movie, ITvSearchEngine tvEngine, ILogger<SearchController> logger)
{ {

@ -24,7 +24,8 @@ namespace Ombi.Controllers
/// </summary> /// </summary>
/// <seealso cref="Ombi.Controllers.BaseV1ApiController" /> /// <seealso cref="Ombi.Controllers.BaseV1ApiController" />
[Admin] [Admin]
public class SettingsController : BaseV1ApiController [ApiV1]
public class SettingsController : Controller
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SettingsController" /> class. /// Initializes a new instance of the <see cref="SettingsController" /> class.

@ -36,8 +36,8 @@ using Ombi.Settings.Settings.Models;
namespace Ombi.Controllers namespace Ombi.Controllers
{ {
[ApiV1]
public class StatusController : BaseV1ApiController public class StatusController : Controller
{ {
public StatusController(ISettingsService<OmbiSettings> ombi) public StatusController(ISettingsService<OmbiSettings> ombi)
{ {

@ -40,6 +40,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper" Version="6.1.0" /> <PackageReference Include="AutoMapper" Version="6.1.0" />
<PackageReference Include="CommandLineParser" Version="2.1.1-beta" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.6.14" /> <PackageReference Include="Hangfire.AspNetCore" Version="1.6.14" />
<PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" /> <PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" />
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" /> <PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />

@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Ombi.Store.Context; using Ombi.Store.Context;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using CommandLine;
namespace Ombi namespace Ombi
{ {
@ -13,35 +14,18 @@ namespace Ombi
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.Title = "Ombi"; Console.Title = "Ombi";
var port = 5000; var options = new Options();
var urlArgs = $"http://*:{port}"; int port = 0;
if (args.Length <= 0) string host = string.Empty;
{ Parser.Default.ParseArguments<Options>(args)
Console.WriteLine("No URL provided, we will run on \"http://localhost:5000\""); .WithParsed(o =>
//Console.WriteLine("Please provider the argument -url e.g. \"ombi.exe -url http://ombi.io:80/\"");
}
else
{
if (args[0].Contains("-url"))
{ {
try port = o.Port;
{ host = o.Host;
urlArgs = args[0].Replace("-url ", string.Empty); });
var index = urlArgs.IndexOf(':', urlArgs.IndexOf(':') + 1);
var portString = urlArgs.Substring(index + 1, urlArgs.Length - index - 1); var urlArgs = $"{host}:{port}";
port = int.Parse(portString);
urlArgs = urlArgs.Substring(0, urlArgs.Length - portString.Length - 1);
}
catch (Exception e)
{
Console.WriteLine("Port is not defined or correctly formatted");
Console.WriteLine(e.Message);
Console.ReadLine();
Environment.Exit(1);
}
}
}
var urlValue = string.Empty; var urlValue = string.Empty;
using (var ctx = new OmbiContext()) using (var ctx = new OmbiContext())
{ {
@ -67,7 +51,7 @@ namespace Ombi
urlValue = url.Value; urlValue = url.Value;
port = int.Parse(dbPort.Value); port = int.Parse(dbPort.Value);
} }
else if (!url.Value.Equals(urlArgs)) if (url != null && !url.Value.Equals(host))
{ {
url.Value = urlArgs; url.Value = urlArgs;
ctx.SaveChanges(); ctx.SaveChanges();
@ -84,16 +68,25 @@ namespace Ombi
Console.WriteLine($"We are running on {urlValue}"); Console.WriteLine($"We are running on {urlValue}");
var host = new WebHostBuilder() var webHost = new WebHostBuilder()
.UseKestrel() .UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() .UseIISIntegration()
.UseUrls($"{urlValue}:{port}") .UseUrls(urlArgs)
.UseStartup<Startup>() .UseStartup<Startup>()
.Build(); .Build();
host.Run(); webHost.Run();
} }
} }
public class Options
{
[Option('h', "host", Required = false, HelpText = "The Hostname default is http://*", Default ="http://*")]
public string Host { get; set; }
[Option('p', "port", Required = false, HelpText = "The port, default is 5000", Default =5000)]
public int Port { get; set; }
}
} }

@ -193,7 +193,7 @@ namespace Ombi
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{ {
#if !DEBUG #if !DEBUG
Authority = $"{url.Value}:{port.Value}", Authority = $"http://localhost:{port.Value}",
#else #else
Authority = $"http://localhost:52038/", Authority = $"http://localhost:52038/",
#endif #endif

Loading…
Cancel
Save