mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -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> {
|
public getLog(logName: string): Observable<string> {
|
||||||
return this.http.get(`${this.url}logs/${logName}`, {responseType: 'text'});
|
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>
|
<settings-menu></settings-menu>
|
||||||
<div *ngIf="about" class="small-middle-container">
|
<div *ngIf="about" class="small-middle-container">
|
||||||
<legend>About</legend>
|
<legend>About</legend>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
<div class="mat-table">
|
<div class="mat-table">
|
||||||
<div class="mat-row" style="background:red;" *ngIf="notSupported">
|
<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>
|
<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>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<h2>News</h2>
|
||||||
|
<div [innerHTML]="newsHtml"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -24,3 +24,17 @@
|
||||||
width: 85%;
|
width: 85%;
|
||||||
margin-top:10px;
|
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 { Component, OnInit } from "@angular/core";
|
||||||
import { IAbout } from "../../interfaces/ISettings";
|
import { IAbout } from "../../interfaces/ISettings";
|
||||||
import { JobService, SettingsService, HubService } from "../../services";
|
import { JobService, SettingsService, HubService, SystemService } from "../../services";
|
||||||
import { IConnectedUser } from "../../interfaces";
|
import { IConnectedUser } from "../../interfaces";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -12,14 +12,16 @@ export class AboutComponent implements OnInit {
|
||||||
public about: IAbout;
|
public about: IAbout;
|
||||||
public newUpdate: boolean;
|
public newUpdate: boolean;
|
||||||
public connectedUsers: IConnectedUser[];
|
public connectedUsers: IConnectedUser[];
|
||||||
|
public newsHtml: string;
|
||||||
|
|
||||||
constructor(private readonly settingsService: SettingsService,
|
constructor(private readonly settingsService: SettingsService,
|
||||||
private readonly jobService: JobService,
|
private readonly jobService: JobService,
|
||||||
private readonly hubService: HubService) { }
|
private readonly hubService: HubService,
|
||||||
|
private readonly systemService: SystemService) { }
|
||||||
|
|
||||||
public async ngOnInit() {
|
public async ngOnInit() {
|
||||||
this.settingsService.about().subscribe(x => this.about = x);
|
this.settingsService.about().subscribe(x => this.about = x);
|
||||||
|
this.newsHtml = await this.systemService.getNews().toPromise();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// this.jobService.getCachedUpdate().subscribe(x => {
|
// this.jobService.getCachedUpdate().subscribe(x => {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Markdig;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
|
@ -12,16 +14,27 @@ namespace Ombi.Controllers.V2
|
||||||
public class SystemController : V2Controller
|
public class SystemController : V2Controller
|
||||||
{
|
{
|
||||||
private readonly IWebHostEnvironment _hosting;
|
private readonly IWebHostEnvironment _hosting;
|
||||||
|
private readonly HttpClient _client;
|
||||||
|
|
||||||
public SystemController(IWebHostEnvironment hosting)
|
public SystemController(IWebHostEnvironment hosting, IHttpClientFactory httpClientFactory)
|
||||||
{
|
{
|
||||||
_hosting = hosting;
|
_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")]
|
[HttpGet("logs")]
|
||||||
public IActionResult GetLogFiles()
|
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
|
var files = Directory
|
||||||
.EnumerateFiles(logsFolder, "*.txt", SearchOption.TopDirectoryOnly)
|
.EnumerateFiles(logsFolder, "*.txt", SearchOption.TopDirectoryOnly)
|
||||||
.Select(Path.GetFileName)
|
.Select(Path.GetFileName)
|
||||||
|
@ -33,7 +46,7 @@ namespace Ombi.Controllers.V2
|
||||||
[HttpGet("logs/{logFileName}")]
|
[HttpGet("logs/{logFileName}")]
|
||||||
public async Task<IActionResult> ReadLogFile(string logFileName, CancellationToken token)
|
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 (var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
using (StreamReader reader = new StreamReader(fs))
|
using (StreamReader reader = new StreamReader(fs))
|
||||||
{
|
{
|
||||||
|
@ -44,7 +57,7 @@ namespace Ombi.Controllers.V2
|
||||||
[HttpGet("logs/download/{logFileName}")]
|
[HttpGet("logs/download/{logFileName}")]
|
||||||
public IActionResult Download(string logFileName, CancellationToken token)
|
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 (var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
using (StreamReader reader = new StreamReader(fs))
|
using (StreamReader reader = new StreamReader(fs))
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace Ombi
|
||||||
// setup.AddHealthCheckEndpoint("Ombi", "/health");
|
// setup.AddHealthCheckEndpoint("Ombi", "/health");
|
||||||
//});
|
//});
|
||||||
services.AddMemoryCache();
|
services.AddMemoryCache();
|
||||||
|
services.AddHttpClient();
|
||||||
|
|
||||||
services.AddJwtAuthentication(Configuration);
|
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