mirror of
https://github.com/danieladov/jellyfin-plugin-skin-manager.git
synced 2026-01-18 16:37:31 +01:00
remove unneecessary code
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MediaBrowser.Model.Branding;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Api;
|
||||
|
||||
namespace Jellyfin.Plugin.SkinManager.Api
|
||||
{
|
||||
[Route("/Css/Set", "POST", Summary = "Downloads theme songs")]
|
||||
[Authenticated]
|
||||
public class DownloadRequest : IReturnVoid
|
||||
{
|
||||
public string css {get;set;}
|
||||
}
|
||||
|
||||
public class cssService : IService
|
||||
{
|
||||
private readonly CssManager _themeSongsManager;
|
||||
private readonly ILogger<BrandingService> _logger;
|
||||
|
||||
public cssService(
|
||||
ILogger<BrandingService> logger, IServerConfigurationManager serverConfigurationManager, IHttpResultFactory httpResultFactory)
|
||||
{
|
||||
_themeSongsManager = new CssManager(logger, serverConfigurationManager, httpResultFactory);
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Post(DownloadRequest request)
|
||||
{
|
||||
_logger.LogInformation(request.css + "Will be setted");
|
||||
_themeSongsManager.setCss();
|
||||
_logger.LogInformation("Completed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
<head>
|
||||
<title>Css</title>
|
||||
<title>Skin Manager</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="content-primary">
|
||||
<form class="tbsConfigurationPage">
|
||||
<div class="sectionTitleContainer flex align-items-center">
|
||||
<h2 class="sectionTitle">Theme Songs</h2>
|
||||
<h2 class="sectionTitle">Skin Manager</h2>
|
||||
<a is="emby-linkbutton" class="raised button-alt headerHelpButton emby-button" target="_blank"
|
||||
href="https://github.com/danieladov/jellyfin-plugin-themesongs">Help</a>
|
||||
</div>
|
||||
@@ -62,33 +62,27 @@
|
||||
loadSkins();
|
||||
|
||||
function setSkin() {
|
||||
var request = {
|
||||
url: ApiClient.getUrl('/Css/Set'),
|
||||
type: 'POST'
|
||||
};
|
||||
|
||||
ApiClient.getPluginConfiguration(plugin.guid).then(function (config) {
|
||||
config.selectedCss = $('#cssOptions').val();
|
||||
ApiClient.getServerConfiguration().then(function (config) {
|
||||
|
||||
ApiClient.updateServerConfiguration(config).then(function() {
|
||||
ApiClient.getNamedConfiguration('branding').then(function(brandingConfig) {
|
||||
brandingConfig.CustomCss = $('#cssOptions').val();
|
||||
|
||||
ApiClient.updatePluginConfiguration(plugin.guid, config).then(function (result) {
|
||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||
|
||||
|
||||
Dashboard.alert("Changing skin...");
|
||||
ApiClient.fetch(request).then(function () {
|
||||
ApiClient.updateNamedConfiguration('branding', brandingConfig).then(function () {
|
||||
Dashboard.processServerConfigurationUpdateResult();
|
||||
window.location.reload(true);
|
||||
}).catch(function () {
|
||||
Dashboard.alert({
|
||||
message: "Unexpected error occurred!"
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MediaBrowser.Model.Branding;
|
||||
using MediaBrowser.Api;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Net;
|
||||
|
||||
namespace Jellyfin.Plugin.SkinManager
|
||||
{
|
||||
public class CssManager : IServerEntryPoint
|
||||
{
|
||||
|
||||
private readonly Timer _timer;
|
||||
private readonly BrandingOptions _branding;
|
||||
private readonly ILogger<BrandingService> _logger;
|
||||
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly IHttpResultFactory _httpResultFactory;
|
||||
private readonly BrandingOptions brandingOptions;
|
||||
|
||||
public CssManager(ILogger<BrandingService> logger, IServerConfigurationManager serverConfigurationManager, IHttpResultFactory httpResultFactory)
|
||||
{
|
||||
_logger = logger;
|
||||
_timer = new Timer(_ => OnTimerElapsed(), null, Timeout.Infinite, Timeout.Infinite);
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_httpResultFactory = httpResultFactory;
|
||||
BrandingService brandingService = new BrandingService(_logger, _serverConfigurationManager, _httpResultFactory);
|
||||
|
||||
brandingOptions = (BrandingOptions) brandingService.Get(new GetBrandingOptions());
|
||||
}
|
||||
|
||||
public void setCss()
|
||||
{
|
||||
string css = Plugin.Instance.Configuration.selectedCss;
|
||||
brandingOptions.CustomCss = css;
|
||||
}
|
||||
|
||||
public void removeCss()
|
||||
{
|
||||
brandingOptions.CustomCss = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void OnTimerElapsed()
|
||||
{
|
||||
// Stop the timer until next update
|
||||
_timer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
}
|
||||
|
||||
public Task RunAsync()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user