mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Added the new Config API with the frontend services
This commit is contained in:
parent
cd99a876c9
commit
069b8b5632
5 changed files with 71 additions and 13 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
export interface IOmbiConfigModel {
|
||||||
|
applicationName: string;
|
||||||
|
applicationUrl: string;
|
||||||
|
logo: string;
|
||||||
|
}
|
18
src/Ombi/ClientApp/src/app/wizard/services/wizard.service.ts
Normal file
18
src/Ombi/ClientApp/src/app/wizard/services/wizard.service.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
|
||||||
|
import { HttpClient } from "@angular/common/http";
|
||||||
|
import { Injectable, Inject } from "@angular/core";
|
||||||
|
import { ICustomizationSettings } from "../../interfaces";
|
||||||
|
import { ServiceHelpers } from "../../services";
|
||||||
|
import { IOmbiConfigModel } from "../models/OmbiConfigModel";
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class WizardService extends ServiceHelpers {
|
||||||
|
constructor(public http: HttpClient, @Inject(APP_BASE_HREF) href:string) {
|
||||||
|
super(http, "/api/v2/wizard/", href);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async downvoteAlbum(config: IOmbiConfigModel): Promise<ICustomizationSettings> {
|
||||||
|
return await this.http.post<ICustomizationSettings>(`${this.url}config`, config, {headers: this.headers}).toPromise();
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ import { JellyfinService } from "../services";
|
||||||
import { PlexService } from "../services";
|
import { PlexService } from "../services";
|
||||||
import { IdentityService } from "../services";
|
import { IdentityService } from "../services";
|
||||||
import { PlexOAuthService } from "../services";
|
import { PlexOAuthService } from "../services";
|
||||||
|
import { WizardService } from "./services/wizard.service";
|
||||||
|
|
||||||
import { SharedModule } from "../shared/shared.module";
|
import { SharedModule } from "../shared/shared.module";
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ const routes: Routes = [
|
||||||
EmbyService,
|
EmbyService,
|
||||||
JellyfinService,
|
JellyfinService,
|
||||||
PlexOAuthService,
|
PlexOAuthService,
|
||||||
|
WizardService,
|
||||||
],
|
],
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
|
using Ombi.Helpers;
|
||||||
|
using Ombi.Models.V2;
|
||||||
using Ombi.Settings.Settings.Models;
|
using Ombi.Settings.Settings.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ombi.Controllers.V2
|
namespace Ombi.Controllers.V2
|
||||||
|
@ -16,20 +13,42 @@ namespace Ombi.Controllers.V2
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class WizardController : V2Controller
|
public class WizardController : V2Controller
|
||||||
{
|
{
|
||||||
|
private ISettingsService<CustomizationSettings> _customizationSettings { get; }
|
||||||
|
|
||||||
private ISettingsService<OmbiSettings> _ombiSettings { get; }
|
public WizardController(ISettingsService<CustomizationSettings> customizationSettings)
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Ok()
|
|
||||||
{
|
{
|
||||||
return Ok();
|
_customizationSettings = customizationSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("config")]
|
||||||
|
[ApiExplorerSettings(IgnoreApi =true)]
|
||||||
|
public async Task<IActionResult> OmbiConfig([FromBody] OmbiConfigModel config)
|
||||||
|
{
|
||||||
|
if (config == null)
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
var settings = await _customizationSettings.GetSettingsAsync();
|
||||||
|
|
||||||
|
if (config.ApplicationName.HasValue())
|
||||||
|
{
|
||||||
|
settings.ApplicationName = config.ApplicationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(config.ApplicationUrl.HasValue())
|
||||||
|
{
|
||||||
|
settings.ApplicationUrl = config.ApplicationUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(config.Logo.HasValue())
|
||||||
|
{
|
||||||
|
settings.Logo = config.Logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _customizationSettings.SaveSettingsAsync(settings);
|
||||||
|
|
||||||
|
return new OkObjectResult(settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
14
src/Ombi/Models/V2/OmbiConfigModel.cs
Normal file
14
src/Ombi/Models/V2/OmbiConfigModel.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Ombi.Models.V2
|
||||||
|
{
|
||||||
|
public class OmbiConfigModel
|
||||||
|
{
|
||||||
|
public string ApplicationName { get; set; }
|
||||||
|
public string ApplicationUrl { get; set; }
|
||||||
|
public string Logo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue