!wip added the custom page into the settings

pull/2728/head
TidusJar 6 years ago
parent edf87bf296
commit 656f8511b4

@ -2,7 +2,6 @@
{
public class CustomPageSettings : Settings
{
public bool Enabled { get; set; }
public string Title { get; set; }
public string Html { get; set; }
}

@ -10,6 +10,7 @@
public string CustomDonationMessage { get; set; }
public string Logo { get; set; }
public bool RecentlyAddedPage { get; set; }
public bool UseCustomPage { get; set; }
public void AddToUrl(string part)
{

@ -1,6 +1,7 @@
using Ombi.Helpers;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
namespace Ombi.Store.Entities.Requests
{
@ -26,6 +27,7 @@ namespace Ombi.Store.Entities.Requests
public string LangCode { get; set; }
[NotMapped]
[JsonIgnore]
public string LanguageCode => LangCode.IsNullOrEmpty() ? "en" : LangCode;
}
}

@ -1,7 +1,22 @@
<button class="btn btn-info-outline" (click)="isEditing = !isEditing">Edit</button>
<div *ngIf="isEditing" >
<app-ngx-editor [placeholder]="'Enter text here...'" [minHeight]="100" [(ngModel)]="html"></app-ngx-editor>
<button class="btn btn-primary-outline" (click)="isEditing = !isEditing">Save</button>
<hr />
</div>
<div [innerHTML]="html"></div>
<div *ngIf="form">
<form [formGroup]="form" (ngSubmit)="onSubmit()">
<button type="button" *ngIf="isAdmin" class="btn btn-info-outline" (click)="isEditing = !isEditing">Edit</button>
<div *ngIf="isEditing">
<div class="form-group">
<label for="Ip" class="control-label">Page Title
<i *ngIf="form.get('title').hasError('required')" class="fa fa-exclamation-circle error-text" pTooltip="Title is required"></i>
</label>
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" formControlName="title" [ngClass]="{'form-error': form.get('title').hasError('required')}">
</div>
<app-ngx-editor [placeholder]="'Enter text here...'" [minHeight]="100" formControlName="html"></app-ngx-editor>
<button type="submit" class="btn btn-primary-outline">Save</button>
<hr />
</div>
</form>
<div [innerHTML]="form.controls['html'].value"></div>
</div>

@ -1,4 +1,7 @@
import { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { AuthService } from "../auth/auth.service";
import { NotificationService, SettingsService } from "../services";
@Component({
templateUrl: "./custompage.component.html",
@ -6,14 +9,37 @@
})
export class CustomPageComponent implements OnInit {
public html: string;
public form: FormGroup;
public isEditing: boolean;
public isAdmin: boolean;
constructor() {
//
constructor(private auth: AuthService, private settings: SettingsService, private fb: FormBuilder,
private notificationService: NotificationService) {
}
public ngOnInit() {
//
this.settings.getCustomPage().subscribe(x => {
this.form = this.fb.group({
enabled: [x.enabled],
title: [x.title, [Validators.required]],
html: [x.html, [Validators.required]],
});
});
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
}
public onSubmit() {
if (this.form.invalid) {
this.notificationService.error("Please check your entered values");
return;
}
this.settings.saveCustomPage(this.form.value).subscribe(x => {
if (x) {
this.notificationService.success("Successfully saved Custom Page settings");
} else {
this.notificationService.success("There was an error when saving the Custom Page settings");
}
});
}
}

@ -120,6 +120,7 @@ export interface ICustomizationSettings extends ISettings {
customDonationUrl: string;
customDonationMessage: string;
recentlyAddedPage: boolean;
useCustomPage: boolean;
}
export interface IJobSettings {
@ -158,6 +159,12 @@ export interface IAuthenticationSettings extends ISettings {
enableOAuth: boolean;
}
export interface ICustomPage extends ISettings {
enabled: boolean;
title: string;
html: string;
}
export interface IUserManagementSettings extends ISettings {
importPlexUsers: boolean;
importPlexAdmin: boolean;

@ -10,6 +10,7 @@ import {
ICronTestModel,
ICronViewModelBody,
ICustomizationSettings,
ICustomPage,
IDiscordNotifcationSettings,
IDogNzbSettings,
IEmailNotificationSettings,
@ -112,6 +113,14 @@ export class SettingsService extends ServiceHelpers {
return this.http.get<IAuthenticationSettings>(`${this.url}/Authentication`, {headers: this.headers});
}
public getCustomPage(): Observable<ICustomPage> {
return this.http.get<ICustomPage>(`${this.url}/CustomPage`, {headers: this.headers});
}
public saveCustomPage(model: ICustomPage): Observable<boolean> {
return this.http.post<boolean>(`${this.url}/CustomPage`, model, {headers: this.headers});
}
public getClientId(): Observable<string> {
return this.http.get<string>(`${this.url}/clientid`, {headers: this.headers});
}

@ -69,6 +69,13 @@
tooltipPosition="top" pTooltip="Set a custom message to be displayed in the navigation bar.">
</div>
</div>
<div class="form-group" *ngIf="settings.useCustomPage">
<label for="customPage" class="control-label">Use Custom Page</label>
<div>
<input [disabled]="!settings.useCustomPage" type="text" [(ngModel)]="settings.useCustomPage" class="form-control form-control-custom " name="customPage" value="{{settings.useCustomPage}}"
tooltipPosition="top" pTooltip="Enabled a custom page for you to fully edit and customize.">
</div>
</div>

@ -721,7 +721,7 @@ namespace Ombi.Controllers
/// Saves the Custom Page Settings.
/// </summary>
/// <returns></returns>
[HttpGet("CustomPage")]
[HttpPost("CustomPage")]
public async Task<bool> CustomPageSettings([FromBody] CustomPageSettings page)
{
return await Save(page);

Loading…
Cancel
Save