mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 09:42:56 -07:00
!wip work in progress for the theme presets
This commit is contained in:
parent
fa774784c0
commit
c8f00c4e8a
11 changed files with 131 additions and 2 deletions
25
src/Ombi.Api.Github/GithubApi.cs
Normal file
25
src/Ombi.Api.Github/GithubApi.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Api.Github.Models;
|
||||||
|
|
||||||
|
namespace Ombi.Api.Github
|
||||||
|
{
|
||||||
|
public class GithubApi : IGithubApi
|
||||||
|
{
|
||||||
|
public GithubApi(IApi api)
|
||||||
|
{
|
||||||
|
_api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly IApi _api;
|
||||||
|
private const string BaseUrl = "https://api.github.com/";
|
||||||
|
|
||||||
|
public async Task<CakeThemesContainer> GetCakeThemes()
|
||||||
|
{
|
||||||
|
var request = new Request("repos/leram84/layer.Cake/contents/Themes", BaseUrl, HttpMethod.Get);
|
||||||
|
|
||||||
|
return await _api.Request<CakeThemesContainer>(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
src/Ombi.Api.Github/IGithubApi.cs
Normal file
10
src/Ombi.Api.Github/IGithubApi.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Api.Github.Models;
|
||||||
|
|
||||||
|
namespace Ombi.Api.Github
|
||||||
|
{
|
||||||
|
public interface IGithubApi
|
||||||
|
{
|
||||||
|
Task<CakeThemesContainer> GetCakeThemes();
|
||||||
|
}
|
||||||
|
}
|
29
src/Ombi.Api.Github/Models/CakeThemes.cs
Normal file
29
src/Ombi.Api.Github/Models/CakeThemes.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
namespace Ombi.Api.Github.Models
|
||||||
|
{
|
||||||
|
public class CakeThemesContainer
|
||||||
|
{
|
||||||
|
public CakeThemes[] Themes { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CakeThemes
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public string path { get; set; }
|
||||||
|
public string sha { get; set; }
|
||||||
|
public int size { get; set; }
|
||||||
|
public string url { get; set; }
|
||||||
|
public string html_url { get; set; }
|
||||||
|
public string git_url { get; set; }
|
||||||
|
public string download_url { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
public _Links _links { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class _Links
|
||||||
|
{
|
||||||
|
public string self { get; set; }
|
||||||
|
public string git { get; set; }
|
||||||
|
public string html { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
11
src/Ombi.Api.Github/Ombi.Api.Github.csproj
Normal file
11
src/Ombi.Api.Github/Ombi.Api.Github.csproj
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -31,6 +31,7 @@ using Ombi.Api;
|
||||||
using Ombi.Api.CouchPotato;
|
using Ombi.Api.CouchPotato;
|
||||||
using Ombi.Api.DogNzb;
|
using Ombi.Api.DogNzb;
|
||||||
using Ombi.Api.FanartTv;
|
using Ombi.Api.FanartTv;
|
||||||
|
using Ombi.Api.Github;
|
||||||
using Ombi.Api.Mattermost;
|
using Ombi.Api.Mattermost;
|
||||||
using Ombi.Api.Pushbullet;
|
using Ombi.Api.Pushbullet;
|
||||||
using Ombi.Api.Pushover;
|
using Ombi.Api.Pushover;
|
||||||
|
@ -100,6 +101,7 @@ namespace Ombi.DependencyInjection
|
||||||
services.AddTransient<ICouchPotatoApi, CouchPotatoApi>();
|
services.AddTransient<ICouchPotatoApi, CouchPotatoApi>();
|
||||||
services.AddTransient<IDogNzbApi, DogNzbApi>();
|
services.AddTransient<IDogNzbApi, DogNzbApi>();
|
||||||
services.AddTransient<ITelegramApi, TelegramApi>();
|
services.AddTransient<ITelegramApi, TelegramApi>();
|
||||||
|
services.AddTransient<IGithubApi, GithubApi>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterStore(this IServiceCollection services) {
|
public static void RegisterStore(this IServiceCollection services) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<ProjectReference Include="..\Ombi.Api.DogNzb\Ombi.Api.DogNzb.csproj" />
|
<ProjectReference Include="..\Ombi.Api.DogNzb\Ombi.Api.DogNzb.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.FanartTv\Ombi.Api.FanartTv.csproj" />
|
<ProjectReference Include="..\Ombi.Api.FanartTv\Ombi.Api.FanartTv.csproj" />
|
||||||
|
<ProjectReference Include="..\Ombi.Api.Github\Ombi.Api.Github.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Mattermost\Ombi.Api.Mattermost.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Mattermost\Ombi.Api.Mattermost.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Pushbullet\Ombi.Api.Pushbullet.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Pushbullet\Ombi.Api.Pushbullet.csproj" />
|
||||||
|
|
|
@ -8,6 +8,8 @@ namespace Ombi.Settings.Settings.Models
|
||||||
public string ApplicationUrl { get; set; }
|
public string ApplicationUrl { get; set; }
|
||||||
public string CustomCssLink { get; set; }
|
public string CustomCssLink { get; set; }
|
||||||
|
|
||||||
|
//public string PresetTheme { get; set; }
|
||||||
|
|
||||||
public void AddToUrl(string part)
|
public void AddToUrl(string part)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(ApplicationUrl))
|
if (string.IsNullOrEmpty(ApplicationUrl))
|
||||||
|
|
|
@ -88,6 +88,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Tests", "Ombi.Tests\Om
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Telegram", "Ombi.Api.Telegram\Ombi.Api.Telegram.csproj", "{CB9DD209-8E09-4E01-983E-C77C89592D36}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Telegram", "Ombi.Api.Telegram\Ombi.Api.Telegram.csproj", "{CB9DD209-8E09-4E01-983E-C77C89592D36}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Github", "Ombi.Api.Github\Ombi.Api.Github.csproj", "{55866DEE-46D1-4AF7-B1A2-62F6190C8EC7}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -226,6 +228,10 @@ Global
|
||||||
{CB9DD209-8E09-4E01-983E-C77C89592D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{CB9DD209-8E09-4E01-983E-C77C89592D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{CB9DD209-8E09-4E01-983E-C77C89592D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{CB9DD209-8E09-4E01-983E-C77C89592D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{CB9DD209-8E09-4E01-983E-C77C89592D36}.Release|Any CPU.Build.0 = Release|Any CPU
|
{CB9DD209-8E09-4E01-983E-C77C89592D36}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{55866DEE-46D1-4AF7-B1A2-62F6190C8EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{55866DEE-46D1-4AF7-B1A2-62F6190C8EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{55866DEE-46D1-4AF7-B1A2-62F6190C8EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{55866DEE-46D1-4AF7-B1A2-62F6190C8EC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -258,6 +264,7 @@ Global
|
||||||
{4F3BF03A-6AAC-4960-A2CD-1EAD7273115E} = {9293CA11-360A-4C20-A674-B9E794431BF5}
|
{4F3BF03A-6AAC-4960-A2CD-1EAD7273115E} = {9293CA11-360A-4C20-A674-B9E794431BF5}
|
||||||
{C12F5276-352A-43CF-8E33-400E768E9757} = {6F42AB98-9196-44C4-B888-D5E409F415A1}
|
{C12F5276-352A-43CF-8E33-400E768E9757} = {6F42AB98-9196-44C4-B888-D5E409F415A1}
|
||||||
{CB9DD209-8E09-4E01-983E-C77C89592D36} = {9293CA11-360A-4C20-A674-B9E794431BF5}
|
{CB9DD209-8E09-4E01-983E-C77C89592D36} = {9293CA11-360A-4C20-A674-B9E794431BF5}
|
||||||
|
{55866DEE-46D1-4AF7-B1A2-62F6190C8EC7} = {9293CA11-360A-4C20-A674-B9E794431BF5}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {192E9BF8-00B4-45E4-BCCC-4C215725C869}
|
SolutionGuid = {192E9BF8-00B4-45E4-BCCC-4C215725C869}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -17,13 +18,13 @@ using Ombi.Core.Settings.Models;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Models;
|
using Ombi.Models;
|
||||||
using Ombi.Schedule.Jobs.Emby;
|
|
||||||
using Ombi.Schedule.Jobs.Radarr;
|
using Ombi.Schedule.Jobs.Radarr;
|
||||||
using Ombi.Settings.Settings.Models;
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Settings.Settings.Models.External;
|
using Ombi.Settings.Settings.Models.External;
|
||||||
using Ombi.Settings.Settings.Models.Notifications;
|
using Ombi.Settings.Settings.Models.Notifications;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
|
using Ombi.Api.Github;
|
||||||
|
|
||||||
namespace Ombi.Controllers
|
namespace Ombi.Controllers
|
||||||
{
|
{
|
||||||
|
@ -45,12 +46,14 @@ namespace Ombi.Controllers
|
||||||
/// <param name="embyApi">The embyApi.</param>
|
/// <param name="embyApi">The embyApi.</param>
|
||||||
/// <param name="radarrCacher">The radarrCacher.</param>
|
/// <param name="radarrCacher">The radarrCacher.</param>
|
||||||
/// <param name="memCache">The memory cache.</param>
|
/// <param name="memCache">The memory cache.</param>
|
||||||
|
/// <param name="githubApi">The memory cache.</param>
|
||||||
public SettingsController(ISettingsResolver resolver,
|
public SettingsController(ISettingsResolver resolver,
|
||||||
IMapper mapper,
|
IMapper mapper,
|
||||||
INotificationTemplatesRepository templateRepo,
|
INotificationTemplatesRepository templateRepo,
|
||||||
IEmbyApi embyApi,
|
IEmbyApi embyApi,
|
||||||
IRadarrCacher radarrCacher,
|
IRadarrCacher radarrCacher,
|
||||||
IMemoryCache memCache)
|
IMemoryCache memCache,
|
||||||
|
IGithubApi githubApi)
|
||||||
{
|
{
|
||||||
SettingsResolver = resolver;
|
SettingsResolver = resolver;
|
||||||
Mapper = mapper;
|
Mapper = mapper;
|
||||||
|
@ -58,6 +61,7 @@ namespace Ombi.Controllers
|
||||||
_embyApi = embyApi;
|
_embyApi = embyApi;
|
||||||
_radarrCacher = radarrCacher;
|
_radarrCacher = radarrCacher;
|
||||||
_cache = memCache;
|
_cache = memCache;
|
||||||
|
_githubApi = githubApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISettingsResolver SettingsResolver { get; }
|
private ISettingsResolver SettingsResolver { get; }
|
||||||
|
@ -66,6 +70,7 @@ namespace Ombi.Controllers
|
||||||
private readonly IEmbyApi _embyApi;
|
private readonly IEmbyApi _embyApi;
|
||||||
private readonly IRadarrCacher _radarrCacher;
|
private readonly IRadarrCacher _radarrCacher;
|
||||||
private readonly IMemoryCache _cache;
|
private readonly IMemoryCache _cache;
|
||||||
|
private readonly IGithubApi _githubApi;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Ombi settings.
|
/// Gets the Ombi settings.
|
||||||
|
@ -216,6 +221,33 @@ namespace Ombi.Controllers
|
||||||
return await Save(settings);
|
return await Save(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("themes")]
|
||||||
|
public async Task<IEnumerable<PresetThemeViewModel>> GetThemes()
|
||||||
|
{
|
||||||
|
var themes = await _githubApi.GetCakeThemes();
|
||||||
|
var cssThemes = themes.Themes.Where(x => x.name.Contains(".css", CompareOptions.IgnoreCase)
|
||||||
|
&& x.type.Equals("file", StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
|
||||||
|
// 001-theBlur-leram84-1.0.css
|
||||||
|
// Number-Name-Author-Version.css
|
||||||
|
var model = new List<PresetThemeViewModel>();
|
||||||
|
foreach (var theme in cssThemes)
|
||||||
|
{
|
||||||
|
var parts = theme.name.Split("-");
|
||||||
|
model.Add(new PresetThemeViewModel
|
||||||
|
{
|
||||||
|
DisplayName = parts[1],
|
||||||
|
FullName = theme.name,
|
||||||
|
Version = parts[3].Replace(".css",string.Empty, StringComparison.CurrentCultureIgnoreCase)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display on UI - Current Theme = theBlur 1.0
|
||||||
|
// In dropdown display as "theBlur 1.1"
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Sonarr Settings.
|
/// Gets the Sonarr Settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
9
src/Ombi/Models/PresetThemeViewModel.cs
Normal file
9
src/Ombi/Models/PresetThemeViewModel.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Ombi.Models
|
||||||
|
{
|
||||||
|
public class PresetThemeViewModel
|
||||||
|
{
|
||||||
|
public string FullName { get; set; }
|
||||||
|
public string DisplayName { get; set; }
|
||||||
|
public string Version { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -77,6 +77,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
|
||||||
|
<ProjectReference Include="..\Ombi.Api.Github\Ombi.Api.Github.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" />
|
<ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.DependencyInjection\Ombi.DependencyInjection.csproj" />
|
<ProjectReference Include="..\Ombi.DependencyInjection\Ombi.DependencyInjection.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Mapping\Ombi.Mapping.csproj" />
|
<ProjectReference Include="..\Ombi.Mapping\Ombi.Mapping.csproj" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue