mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
#865 Finished the landing page, we now check the server's status
This commit is contained in:
parent
391308ddeb
commit
5d0e317315
8 changed files with 164 additions and 10 deletions
|
@ -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
|
||||
],
|
||||
|
|
8
src/Ombi/ClientApp/app/interfaces/IMediaServerStatus.ts
Normal file
8
src/Ombi/ClientApp/app/interfaces/IMediaServerStatus.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export interface IMediaServerStatus {
|
||||
serversAvailable: number,
|
||||
serversUnavailable: number,
|
||||
partiallyDown: boolean,
|
||||
completelyDown: boolean,
|
||||
fullyAvailable: boolean,
|
||||
totalServers:number
|
||||
}
|
|
@ -19,10 +19,24 @@
|
|||
<span [innerHtml]="landingPageSettings.noticeText"></span>
|
||||
</div>
|
||||
<div>
|
||||
<div *ngIf="mediaServerStatus">
|
||||
<div *ngIf="mediaServerStatus.fullyAvailable">
|
||||
<h3 class="online"><i class="fa fa-check-circle "></i> Currently Online</h3>
|
||||
<span>The media server is currently online</span>
|
||||
<span>Check this page for continous site updates.</span>
|
||||
<p>Check this page for continous site updates.</p>
|
||||
</div>
|
||||
|
||||
<div *ngIf="mediaServerStatus.partiallyDown">
|
||||
<h3 class="partial"><i class="fa fa-exclamation-triangle "></i> Partially Online</h3>
|
||||
<span>The media server is partially online. </span>
|
||||
<p *ngIf="mediaServerStatus.serversUnavailable > 1">There are {{mediaServerStatus.serversUnavailable}} servers offline out of {{mediaServerStatus.totalServers}}.</p>
|
||||
<p *ngIf="mediaServerStatus.serversUnavailable == 1">There is {{mediaServerStatus.serversUnavailable}} server offline out of {{mediaServerStatus.totalServers}}.</p>
|
||||
<p>Check this page for continous site updates.</p>
|
||||
</div>
|
||||
|
||||
<div *ngIf="mediaServerStatus.completelyDown">
|
||||
<h3 class="offline"><i class="fa fa-times "></i> Currently Offline</h3>
|
||||
<span>The media server is currently offline</span>
|
||||
<p>Check this page for continous site updates.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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%;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
17
src/Ombi/ClientApp/app/services/landingpage.service.ts
Normal file
17
src/Ombi/ClientApp/app/services/landingpage.service.ts
Normal file
|
@ -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<IMediaServerStatus> {
|
||||
return this.http.get(`${this.url}`, { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
}
|
92
src/Ombi/Controllers/LandingPageController.cs
Normal file
92
src/Ombi/Controllers/LandingPageController.cs
Normal file
|
@ -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<PlexSettings> plex, ISettingsService<EmbySettings> 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> _plexSettings;
|
||||
private readonly ISettingsService<EmbySettings> _embySettings;
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<MediaSeverAvailibilityViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
12
src/Ombi/Models/MediaSeverAvailibilityViewModel.cs
Normal file
12
src/Ombi/Models/MediaSeverAvailibilityViewModel.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue