diff --git a/src/Ombi/ClientApp/app/app.module.ts b/src/Ombi/ClientApp/app/app.module.ts
index 1bcdd5a46..898d2eb0a 100644
--- a/src/Ombi/ClientApp/app/app.module.ts
+++ b/src/Ombi/ClientApp/app/app.module.ts
@@ -32,6 +32,7 @@ import { AuthModule } from './auth/auth.module';
import { IdentityService } from './services/identity.service';
import { StatusService } from './services/status.service';
import { ImageService } from './services/image.service';
+import { LandingPageService } from './services/landingpage.service';
// Modules
@@ -96,6 +97,7 @@ const routes: Routes = [
SettingsService,
IdentityService,
StatusService,
+ LandingPageService,
ImageService,
//DragulaService
],
diff --git a/src/Ombi/ClientApp/app/interfaces/IMediaServerStatus.ts b/src/Ombi/ClientApp/app/interfaces/IMediaServerStatus.ts
new file mode 100644
index 000000000..b8f4e3d20
--- /dev/null
+++ b/src/Ombi/ClientApp/app/interfaces/IMediaServerStatus.ts
@@ -0,0 +1,8 @@
+export interface IMediaServerStatus {
+ serversAvailable: number,
+ serversUnavailable: number,
+ partiallyDown: boolean,
+ completelyDown: boolean,
+ fullyAvailable: boolean,
+ totalServers:number
+}
\ No newline at end of file
diff --git a/src/Ombi/ClientApp/app/landingpage/landingpage.component.html b/src/Ombi/ClientApp/app/landingpage/landingpage.component.html
index af4329fd6..951756ebc 100644
--- a/src/Ombi/ClientApp/app/landingpage/landingpage.component.html
+++ b/src/Ombi/ClientApp/app/landingpage/landingpage.component.html
@@ -19,10 +19,24 @@
-
+
Currently Online
The media server is currently online
-
Check this page for continous site updates.
+
Check this page for continous site updates.
+
+
+
+
Partially Online
+
The media server is partially online.
+
1">There are {{mediaServerStatus.serversUnavailable}} servers offline out of {{mediaServerStatus.totalServers}}.
+
There is {{mediaServerStatus.serversUnavailable}} server offline out of {{mediaServerStatus.totalServers}}.
+
Check this page for continous site updates.
+
+
+
+
Currently Offline
+
The media server is currently offline
+
Check this page for continous site updates.
diff --git a/src/Ombi/ClientApp/app/landingpage/landingpage.component.scss b/src/Ombi/ClientApp/app/landingpage/landingpage.component.scss
index 26a13eb4d..e978b0d5f 100644
--- a/src/Ombi/ClientApp/app/landingpage/landingpage.component.scss
+++ b/src/Ombi/ClientApp/app/landingpage/landingpage.component.scss
@@ -36,10 +36,20 @@ img.bg {
color:lightgreen;
}
+
+.partial {
+ color: #ffd800
+}
+
.offline {
color: #F44336
}
+p {
+ font-size: 14px !important;
+}
+
+
@media screen and (max-width: 1024px) { /* Specific to this particular image */
img.bg {
left: 50%;
diff --git a/src/Ombi/ClientApp/app/landingpage/landingpage.component.ts b/src/Ombi/ClientApp/app/landingpage/landingpage.component.ts
index 90a816409..8ffb98712 100644
--- a/src/Ombi/ClientApp/app/landingpage/landingpage.component.ts
+++ b/src/Ombi/ClientApp/app/landingpage/landingpage.component.ts
@@ -1,8 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { SettingsService } from '../services/settings.service';
-import { RequestService } from '../services/request.service';
+import { LandingPageService } from '../services/landingpage.service';
import { ILandingPageSettings, ICustomizationSettings } from '../interfaces/ISettings';
-import { IRequestCountModel } from '../interfaces/IRequestModel';
+import { IMediaServerStatus } from '../interfaces/IMediaServerStatus';
import { DomSanitizer } from '@angular/platform-browser';
import { ImageService } from '../services/image.service';
@@ -14,24 +14,23 @@ import { ImageService } from '../services/image.service';
})
export class LandingPageComponent implements OnInit {
- constructor(private settingsService: SettingsService, private requestService: RequestService,
- private images: ImageService, private sanitizer: DomSanitizer) { }
+ constructor(private settingsService: SettingsService,
+ private images: ImageService, private sanitizer: DomSanitizer, private landingPageService: LandingPageService) { }
customizationSettings : ICustomizationSettings;
landingPageSettings: ILandingPageSettings;
- requestCount: IRequestCountModel;
background: any;
- mediaServerStatus: boolean;
+ mediaServerStatus: IMediaServerStatus;
ngOnInit(): void {
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
this.settingsService.getLandingPage().subscribe(x => this.landingPageSettings = x);
- this.requestService.getRequestsCount().subscribe(x => this.requestCount = x);
this.images.getRandomBackground().subscribe(x => {
this.background = this.sanitizer.bypassSecurityTrustStyle('linear-gradient(-10deg, transparent 20%, rgba(0,0,0,0.7) 20.0%, rgba(0,0,0,0.7) 80.0%, transparent 80%), url(' + x.url + ')');
});
- this.mediaServerStatus = true;
+
+ this.landingPageService.getServerStatus().subscribe(x => this.mediaServerStatus = x);
}
}
\ No newline at end of file
diff --git a/src/Ombi/ClientApp/app/services/landingpage.service.ts b/src/Ombi/ClientApp/app/services/landingpage.service.ts
new file mode 100644
index 000000000..7dacc6778
--- /dev/null
+++ b/src/Ombi/ClientApp/app/services/landingpage.service.ts
@@ -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 { IMediaServerStatus } from '../interfaces/IMediaServerStatus';
+
+@Injectable()
+export class LandingPageService extends ServiceHelpers {
+ constructor(public http : Http) {
+ super(http, '/api/v1/LandingPage/');
+ }
+
+ getServerStatus(): Observable {
+ return this.http.get(`${this.url}`, { headers: this.headers }).map(this.extractData);
+ }
+}
\ No newline at end of file
diff --git a/src/Ombi/Controllers/LandingPageController.cs b/src/Ombi/Controllers/LandingPageController.cs
new file mode 100644
index 000000000..c913d2498
--- /dev/null
+++ b/src/Ombi/Controllers/LandingPageController.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Ombi.Api.Emby;
+using Ombi.Api.Plex;
+using Ombi.Core.Settings;
+using Ombi.Core.Settings.Models.External;
+using Ombi.Models;
+
+namespace Ombi.Controllers
+{
+ [ApiV1]
+ [AllowAnonymous]
+ public class LandingPageController
+ {
+ public LandingPageController(ISettingsService plex, ISettingsService emby,
+ IPlexApi plexApi, IEmbyApi embyApi)
+ {
+ _plexSettings = plex;
+ _embySettings = emby;
+ _plexApi = plexApi;
+ _embyApi = embyApi;
+ }
+
+ private readonly IPlexApi _plexApi;
+ private readonly IEmbyApi _embyApi;
+ private readonly ISettingsService _plexSettings;
+ private readonly ISettingsService _embySettings;
+
+
+ [HttpGet]
+ public async Task GetMediaServerStatus()
+ {
+ var model = new MediaSeverAvailibilityViewModel();
+
+ model.ServersAvailable = 3;
+ model.ServersUnavailable = 1;
+ return model;
+ //var plex = await _plexSettings.GetSettingsAsync();
+ //if (plex.Enable)
+ //{
+
+ // foreach (var s in plex.Servers)
+ // {
+ // try
+ // {
+ // var result = await _plexApi.GetStatus(s.PlexAuthToken, s.FullUri);
+ // if (!string.IsNullOrEmpty(result.MediaContainer?.version))
+ // {
+ // model.ServersAvailable++;
+ // }
+ // else
+ // {
+ // model.ServersUnavailable++;
+ // }
+ // }
+ // catch (Exception)
+ // {
+ // model.ServersUnavailable++;
+ // }
+ // }
+ //}
+
+ //var emby = await _embySettings.GetSettingsAsync();
+ //if (emby.Enable)
+ //{
+ // foreach (var server in emby.Servers)
+ // {
+ // try
+ // {
+ // var result = await _embyApi.GetUsers(server.FullUri, server.ApiKey);
+ // if (result.Any())
+ // {
+ // model.ServersAvailable++;
+ // }
+ // else
+ // {
+ // model.ServersUnavailable++;
+ // }
+ // }
+ // catch (Exception)
+ // {
+ // model.ServersUnavailable++;
+ // }
+ // }
+ //}
+ //return model;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Ombi/Models/MediaSeverAvailibilityViewModel.cs b/src/Ombi/Models/MediaSeverAvailibilityViewModel.cs
new file mode 100644
index 000000000..788742e14
--- /dev/null
+++ b/src/Ombi/Models/MediaSeverAvailibilityViewModel.cs
@@ -0,0 +1,12 @@
+namespace Ombi.Models
+{
+ public class MediaSeverAvailibilityViewModel
+ {
+ public int ServersAvailable { get; set; }
+ public int ServersUnavailable { get; set; }
+ public bool PartiallyDown => ServersUnavailable > 0 && ServersAvailable > 0;
+ public bool CompletlyDown => ServersUnavailable > 0 && ServersAvailable == 0;
+ public bool FullyAvailable => ServersUnavailable == 0 && ServersAvailable > 0;
+ public int TotalServers => ServersUnavailable + ServersAvailable;
+ }
+}
\ No newline at end of file