mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Added a news section
This commit is contained in:
parent
2bb006e9a2
commit
4710445538
7 changed files with 63 additions and 10 deletions
|
@ -18,4 +18,7 @@ export class SystemService extends ServiceHelpers {
|
|||
public getLog(logName: string): Observable<string> {
|
||||
return this.http.get(`${this.url}logs/${logName}`, {responseType: 'text'});
|
||||
}
|
||||
public getNews(): Observable<string> {
|
||||
return this.http.get(`${this.url}news`, {responseType: 'text'});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<settings-menu></settings-menu>
|
||||
<div *ngIf="about" class="small-middle-container">
|
||||
<legend>About</legend>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="mat-table">
|
||||
<div class="mat-row" style="background:red;" *ngIf="notSupported">
|
||||
<div class="mat-cell" style="text-align: center;"><b>NOT SUPPORTED OS. Please use the docker image available on the Container Station (It's free)</b></div>
|
||||
|
@ -91,6 +92,11 @@
|
|||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>News</h2>
|
||||
<div [innerHTML]="newsHtml"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -23,4 +23,18 @@
|
|||
margin: auto;
|
||||
width: 85%;
|
||||
margin-top:10px;
|
||||
}
|
||||
|
||||
:host ::ng-deep strong {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
display: inline-block;
|
||||
padding: 0.25em 0.4em;
|
||||
font-size: 75%;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: baseline;
|
||||
border-radius: 0.25rem;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
import { IAbout } from "../../interfaces/ISettings";
|
||||
import { JobService, SettingsService, HubService } from "../../services";
|
||||
import { JobService, SettingsService, HubService, SystemService } from "../../services";
|
||||
import { IConnectedUser } from "../../interfaces";
|
||||
|
||||
@Component({
|
||||
|
@ -12,14 +12,16 @@ export class AboutComponent implements OnInit {
|
|||
public about: IAbout;
|
||||
public newUpdate: boolean;
|
||||
public connectedUsers: IConnectedUser[];
|
||||
public newsHtml: string;
|
||||
|
||||
constructor(private readonly settingsService: SettingsService,
|
||||
private readonly jobService: JobService,
|
||||
private readonly hubService: HubService) { }
|
||||
private readonly jobService: JobService,
|
||||
private readonly hubService: HubService,
|
||||
private readonly systemService: SystemService) { }
|
||||
|
||||
public async ngOnInit() {
|
||||
this.settingsService.about().subscribe(x => this.about = x);
|
||||
|
||||
this.newsHtml = await this.systemService.getNews().toPromise();
|
||||
|
||||
// TODO
|
||||
// this.jobService.getCachedUpdate().subscribe(x => {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Markdig;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Ombi.Attributes;
|
||||
|
@ -12,16 +14,27 @@ namespace Ombi.Controllers.V2
|
|||
public class SystemController : V2Controller
|
||||
{
|
||||
private readonly IWebHostEnvironment _hosting;
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public SystemController(IWebHostEnvironment hosting)
|
||||
public SystemController(IWebHostEnvironment hosting, IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
_hosting = hosting;
|
||||
_client = httpClientFactory.CreateClient();
|
||||
}
|
||||
|
||||
[HttpGet("news")]
|
||||
public async Task<IActionResult> GetNews()
|
||||
{
|
||||
var result = await _client.GetAsync("https://raw.githubusercontent.com/tidusjar/Ombi.News/main/README.md");
|
||||
var content = await result.Content.ReadAsStringAsync();
|
||||
var md = Markdown.ToHtml(content);
|
||||
return Ok(md);
|
||||
}
|
||||
|
||||
[HttpGet("logs")]
|
||||
public IActionResult GetLogFiles()
|
||||
{
|
||||
var logsFolder = Path.Combine(_hosting.ContentRootPath, "Logs");
|
||||
var logsFolder = Path.Combine(string.IsNullOrEmpty(Ombi.Helpers.StartupSingleton.Instance.StoragePath) ? _hosting.ContentRootPath : Helpers.StartupSingleton.Instance.StoragePath, "Logs");
|
||||
var files = Directory
|
||||
.EnumerateFiles(logsFolder, "*.txt", SearchOption.TopDirectoryOnly)
|
||||
.Select(Path.GetFileName)
|
||||
|
@ -33,7 +46,7 @@ namespace Ombi.Controllers.V2
|
|||
[HttpGet("logs/{logFileName}")]
|
||||
public async Task<IActionResult> ReadLogFile(string logFileName, CancellationToken token)
|
||||
{
|
||||
var logFile = Path.Combine(_hosting.ContentRootPath, "Logs", logFileName);
|
||||
var logFile = Path.Combine(string.IsNullOrEmpty(Ombi.Helpers.StartupSingleton.Instance.StoragePath) ? _hosting.ContentRootPath : Helpers.StartupSingleton.Instance.StoragePath, "Logs", logFileName);
|
||||
using (var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (StreamReader reader = new StreamReader(fs))
|
||||
{
|
||||
|
@ -44,7 +57,7 @@ namespace Ombi.Controllers.V2
|
|||
[HttpGet("logs/download/{logFileName}")]
|
||||
public IActionResult Download(string logFileName, CancellationToken token)
|
||||
{
|
||||
var logFile = Path.Combine(_hosting.ContentRootPath, "Logs", logFileName);
|
||||
var logFile = Path.Combine(string.IsNullOrEmpty(Ombi.Helpers.StartupSingleton.Instance.StoragePath) ? _hosting.ContentRootPath : Helpers.StartupSingleton.Instance.StoragePath, "Logs", logFileName);
|
||||
using (var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (StreamReader reader = new StreamReader(fs))
|
||||
{
|
||||
|
|
|
@ -84,6 +84,7 @@ namespace Ombi
|
|||
// setup.AddHealthCheckEndpoint("Ombi", "/health");
|
||||
//});
|
||||
services.AddMemoryCache();
|
||||
services.AddHttpClient();
|
||||
|
||||
services.AddJwtAuthentication(Configuration);
|
||||
|
||||
|
|
14
src/Ombi/databasej.json
Normal file
14
src/Ombi/databasej.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"OmbiDatabase": {
|
||||
"Type": "MySQL",
|
||||
"ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi"
|
||||
},
|
||||
"SettingsDatabase": {
|
||||
"Type": "MySQL",
|
||||
"ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi"
|
||||
},
|
||||
"ExternalDatabase": {
|
||||
"Type": "MySQL",
|
||||
"ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue