!wip integrated with the layer#cake repo. Just need to do the UI

pull/1654/head
tidusjar 7 years ago
parent c8f00c4e8a
commit b1d59452ef

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Api.Github.Models; using Ombi.Api.Github.Models;
@ -15,11 +16,12 @@ namespace Ombi.Api.Github
private readonly IApi _api; private readonly IApi _api;
private const string BaseUrl = "https://api.github.com/"; private const string BaseUrl = "https://api.github.com/";
public async Task<CakeThemesContainer> GetCakeThemes() public async Task<List<CakeThemes>> GetCakeThemes()
{ {
var request = new Request("repos/leram84/layer.Cake/contents/Themes", BaseUrl, HttpMethod.Get); var request = new Request("repos/leram84/layer.Cake/contents/ombi/themes", BaseUrl, HttpMethod.Get);
request.AddHeader("Accept", "application/vnd.github.v3+json");
return await _api.Request<CakeThemesContainer>(request); request.AddHeader("User-Agent", "Ombi");
return await _api.Request<List<CakeThemes>>(request);
} }
} }
} }

@ -1,10 +1,11 @@
using System.Threading.Tasks; using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Api.Github.Models; using Ombi.Api.Github.Models;
namespace Ombi.Api.Github namespace Ombi.Api.Github
{ {
public interface IGithubApi public interface IGithubApi
{ {
Task<CakeThemesContainer> GetCakeThemes(); Task<List<CakeThemes>> GetCakeThemes();
} }
} }

@ -1,10 +1,5 @@
namespace Ombi.Api.Github.Models namespace Ombi.Api.Github.Models
{ {
public class CakeThemesContainer
{
public CakeThemes[] Themes { get; set; }
}
public class CakeThemes public class CakeThemes
{ {
public string name { get; set; } public string name { get; set; }

@ -1,4 +1,6 @@
using Newtonsoft.Json; using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Ombi.Helpers;
namespace Ombi.Settings.Settings.Models namespace Ombi.Settings.Settings.Models
{ {
@ -7,9 +9,14 @@ namespace Ombi.Settings.Settings.Models
public string ApplicationName { get; set; } public string ApplicationName { get; set; }
public string ApplicationUrl { get; set; } public string ApplicationUrl { get; set; }
public string CustomCssLink { get; set; } public string CustomCssLink { get; set; }
public string Logo { get; set; }
public string PresetThemeName { get; set; }
public string PresetThemeContent { get; set; }
[NotMapped]
public bool HasPresetTheme => PresetThemeName.HasValue() || PresetThemeContent.HasValue();
//public string PresetTheme { get; set; }
public void AddToUrl(string part) public void AddToUrl(string part)
{ {
if (string.IsNullOrEmpty(ApplicationUrl)) if (string.IsNullOrEmpty(ApplicationUrl))
@ -27,6 +34,5 @@ namespace Ombi.Settings.Settings.Models
} }
ApplicationUrl = ApplicationUrl + part; ApplicationUrl = ApplicationUrl + part;
} }
public string Logo { get; set; }
} }
} }

@ -96,6 +96,13 @@ export interface ICustomizationSettings extends ISettings {
customCssLink: string; customCssLink: string;
} }
export interface IThemes {
fullName: string;
displayName: string;
version: string;
url: string;
}
export interface IAuthenticationSettings extends ISettings { export interface IAuthenticationSettings extends ISettings {
allowExternalUsersToAuthenticate: boolean; allowExternalUsersToAuthenticate: boolean;

@ -23,6 +23,7 @@ import {
ISlackNotificationSettings, ISlackNotificationSettings,
ISonarrSettings, ISonarrSettings,
ITelegramNotifcationSettings, ITelegramNotifcationSettings,
IThemes,
IUpdateSettings, IUpdateSettings,
IUserManagementSettings, IUserManagementSettings,
} from "../interfaces"; } from "../interfaces";
@ -122,6 +123,10 @@ export class SettingsService extends ServiceAuthHelpers {
.map(this.extractData).catch(this.handleError); .map(this.extractData).catch(this.handleError);
} }
public getThemes(): Observable<IThemes[]> {
return this.httpAuth.get(`${this.url}/themes`).map(this.extractData).catch(this.handleError);
}
public getEmailNotificationSettings(): Observable<IEmailNotificationSettings> { public getEmailNotificationSettings(): Observable<IEmailNotificationSettings> {
return this.httpAuth.get(`${this.url}/notifications/email`).map(this.extractData).catch(this.handleError); return this.httpAuth.get(`${this.url}/notifications/email`).map(this.extractData).catch(this.handleError);
} }

@ -1,6 +1,6 @@
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { ICustomizationSettings } from "../../interfaces"; import { ICustomizationSettings, IThemes } from "../../interfaces";
import { NotificationService } from "../../services"; import { NotificationService } from "../../services";
import { SettingsService } from "../../services"; import { SettingsService } from "../../services";
@ -10,12 +10,13 @@ import { SettingsService } from "../../services";
export class CustomizationComponent implements OnInit { export class CustomizationComponent implements OnInit {
public settings: ICustomizationSettings; public settings: ICustomizationSettings;
public themes: IThemes[];
constructor(private settingsService: SettingsService, private notificationService: NotificationService) { } constructor(private settingsService: SettingsService, private notificationService: NotificationService) { }
public ngOnInit() { public ngOnInit() {
this.settingsService.getCustomization().subscribe(x => this.settings = x); this.settingsService.getCustomization().subscribe(x => this.settings = x);
this.settingsService.getThemes().subscribe(x => this.themes = x);
} }
public save() { public save() {

@ -225,7 +225,7 @@ namespace Ombi.Controllers
public async Task<IEnumerable<PresetThemeViewModel>> GetThemes() public async Task<IEnumerable<PresetThemeViewModel>> GetThemes()
{ {
var themes = await _githubApi.GetCakeThemes(); var themes = await _githubApi.GetCakeThemes();
var cssThemes = themes.Themes.Where(x => x.name.Contains(".css", CompareOptions.IgnoreCase) var cssThemes = themes.Where(x => x.name.Contains(".css", CompareOptions.IgnoreCase)
&& x.type.Equals("file", StringComparison.CurrentCultureIgnoreCase)); && x.type.Equals("file", StringComparison.CurrentCultureIgnoreCase));
// 001-theBlur-leram84-1.0.css // 001-theBlur-leram84-1.0.css
@ -238,7 +238,8 @@ namespace Ombi.Controllers
{ {
DisplayName = parts[1], DisplayName = parts[1],
FullName = theme.name, FullName = theme.name,
Version = parts[3].Replace(".css",string.Empty, StringComparison.CurrentCultureIgnoreCase) Version = parts[3].Replace(".css",string.Empty, StringComparison.CurrentCultureIgnoreCase),
Url = theme.download_url
}); });
} }

@ -5,5 +5,6 @@
public string FullName { get; set; } public string FullName { get; set; }
public string DisplayName { get; set; } public string DisplayName { get; set; }
public string Version { get; set; } public string Version { get; set; }
public string Url { get; set; }
} }
} }

@ -3679,11 +3679,6 @@
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.4.tgz", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.4.tgz",
"integrity": "sha1-ggzdWIuGj/sZGoCVBtbJyPISsbA=" "integrity": "sha1-ggzdWIuGj/sZGoCVBtbJyPISsbA="
}, },
"intro.js-mit": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/intro.js-mit/-/intro.js-mit-3.0.0.tgz",
"integrity": "sha1-vMQHKQrn4FT68+uImVumyTfZRVA="
},
"invert-kv": { "invert-kv": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",

Loading…
Cancel
Save