pull/2814/head
TidusJar 6 years ago
parent 183c242334
commit c2c8a772dd

@ -15,5 +15,6 @@
public const string Disabled = nameof(Disabled);
public const string ReceivesNewsletter = nameof(ReceivesNewsletter);
public const string ManageOwnRequests = nameof(ManageOwnRequests);
public const string EditCustomPage = nameof(EditCustomPage);
}
}

@ -39,7 +39,7 @@ import { ImageService } from "./services";
import { LandingPageService } from "./services";
import { NotificationService } from "./services";
import { SettingsService } from "./services";
import { IssuesService, JobService, PlexTvService, StatusService } from "./services";
import { CustomPageService, IssuesService, JobService, PlexTvService, StatusService } from "./services";
const routes: Routes = [
{ path: "*", component: PageNotFoundComponent },
@ -144,6 +144,7 @@ export function JwtTokenGetter() {
JobService,
IssuesService,
PlexTvService,
CustomPageService,
],
bootstrap: [AppComponent],
})

@ -2,7 +2,7 @@
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { DomSanitizer } from "@angular/platform-browser";
import { AuthService } from "../auth/auth.service";
import { NotificationService, SettingsService } from "../services";
import { CustomPageService, NotificationService } from "../services";
@Component({
templateUrl: "./custompage.component.html",
@ -14,7 +14,7 @@ export class CustomPageComponent implements OnInit {
public isEditing: boolean;
public isAdmin: boolean;
constructor(private auth: AuthService, private settings: SettingsService, private fb: FormBuilder,
constructor(private auth: AuthService, private settings: CustomPageService, private fb: FormBuilder,
private notificationService: NotificationService,
private sanitizer: DomSanitizer) {
}
@ -29,7 +29,7 @@ export class CustomPageComponent implements OnInit {
fontAwesomeIcon: [x.fontAwesomeIcon, [Validators.required]],
});
});
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
this.isAdmin = this.auth.hasRole("EditCustomPage");
}
public onSubmit() {

@ -0,0 +1,25 @@
import { PlatformLocation } from "@angular/common";
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import {
ICustomPage,
} from "../interfaces";
import { ServiceHelpers } from "./service.helpers";
@Injectable()
export class CustomPageService extends ServiceHelpers {
constructor(public http: HttpClient, public platformLocation: PlatformLocation) {
super(http, "/api/v1/CustomPage", platformLocation);
}
public getCustomPage(): Observable<ICustomPage> {
return this.http.get<ICustomPage>(this.url, {headers: this.headers});
}
public saveCustomPage(model: ICustomPage): Observable<boolean> {
return this.http.post<boolean>(this.url, model, {headers: this.headers});
}
}

@ -16,3 +16,4 @@ export * from "./notificationMessage.service";
export * from "./recentlyAdded.service";
export * from "./vote.service";
export * from "./requestretry.service";
export * from "./custompage.service";

@ -75,7 +75,7 @@
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="useCustomPage" name="useCustomPage" [(ngModel)]="settings.useCustomPage">
<label for="useCustomPage" tooltipPosition="top" pTooltip="Enabled a custom page where you can fully edit">Use
<label for="useCustomPage" tooltipPosition="top" pTooltip="Enabled a custom page where you can fully edit. You will need the Edit Custom Page role.">Use
Custom Page</label>
</div>

@ -0,0 +1,53 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models;
namespace Ombi.Controllers
{
[ApiV1]
[Produces("application/json")]
[ApiController]
public class CustomPageController : ControllerBase
{
public CustomPageController(ISettingsService<CustomPageSettings> settings)
{
_settings = settings;
}
private readonly ISettingsService<CustomPageSettings> _settings;
/// <summary>
/// Gets the Custom Page Settings.
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<CustomPageSettings> CustomPageSettings()
{
return await Get();
}
/// <summary>
/// Saves the Custom Page Settings.
/// </summary>
/// <returns></returns>
[HttpPost]
[Authorize(OmbiRoles.EditCustomPage)]
public async Task<bool> CustomPageSettings([FromBody] CustomPageSettings page)
{
return await Save(page);
}
private async Task<CustomPageSettings> Get()
{
return await _settings.GetSettingsAsync();
}
private async Task<bool> Save(CustomPageSettings settingsModel)
{
return await _settings.SaveSettingsAsync(settingsModel);
}
}
}

@ -239,6 +239,7 @@ namespace Ombi.Controllers
await CreateRole(OmbiRoles.Disabled);
await CreateRole(OmbiRoles.ReceivesNewsletter);
await CreateRole(OmbiRoles.ManageOwnRequests);
await CreateRole(OmbiRoles.EditCustomPage);
}
private async Task CreateRole(string role)

@ -707,27 +707,6 @@ namespace Ombi.Controllers
return emailSettings.Enabled;
}
/// <summary>
/// Gets the Custom Page Settings.
/// </summary>
/// <returns></returns>
[HttpGet("CustomPage")]
[AllowAnonymous]
public async Task<CustomPageSettings> CustomPageSettings()
{
return await Get<CustomPageSettings>();
}
/// <summary>
/// Saves the Custom Page Settings.
/// </summary>
/// <returns></returns>
[HttpPost("CustomPage")]
public async Task<bool> CustomPageSettings([FromBody] CustomPageSettings page)
{
return await Save(page);
}
/// <summary>
/// Saves the discord notification settings.
/// </summary>

@ -26,6 +26,7 @@ using Ombi.Store.Context;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Serilog;
using ILogger = Serilog.ILogger;
namespace Ombi
{
@ -42,35 +43,12 @@ namespace Ombi
.AddEnvironmentVariables();
Configuration = builder.Build();
//if (env.IsDevelopment())
//{
Serilog.ILogger config;
if (string.IsNullOrEmpty(StoragePath.StoragePath))
{
config = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.RollingFile(Path.Combine(env.ContentRootPath, "Logs", "log-{Date}.txt"))
.CreateLogger();
}
else
{
config = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.RollingFile(Path.Combine(StoragePath.StoragePath, "Logs", "log-{Date}.txt"))
.CreateLogger();
}
Log.Logger = config;
ILogger config = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.RollingFile(Path.Combine(StoragePath.StoragePath.IsNullOrEmpty() ? env.ContentRootPath : StoragePath.StoragePath, "Logs", "log-{Date}.txt"))
.CreateLogger();
//}
//if (env.IsProduction())
//{
// Log.Logger = new LoggerConfiguration()
// .MinimumLevel.Debug()
// .WriteTo.RollingFile(Path.Combine(env.ContentRootPath, "Logs", "log-{Date}.txt"))
// .WriteTo.SQLite("Ombi.db", "Logs", LogEventLevel.Debug)
// .CreateLogger();
//}
Log.Logger = config;
}
public IConfigurationRoot Configuration { get; }
@ -126,7 +104,6 @@ namespace Ombi
{
x.UseSQLiteStorage(sqliteStorage);
x.UseActivator(new IoCJobActivator(services.BuildServiceProvider()));
//x.UseConsole();
});
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>

Loading…
Cancel
Save