diff options
author | Linnea Gräf <nea@nea.moe> | 2024-08-11 21:47:46 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-08-11 21:47:46 +0200 |
commit | f60e3645e18a7f590dc913d0f555fcb82f072d07 (patch) | |
tree | 3e74108cecc54086c5c5241ad9751efa549fd298 /Configuration | |
download | JCoverXtremePro-f60e3645e18a7f590dc913d0f555fcb82f072d07.tar.gz JCoverXtremePro-f60e3645e18a7f590dc913d0f555fcb82f072d07.tar.bz2 JCoverXtremePro-f60e3645e18a7f590dc913d0f555fcb82f072d07.zip |
init
Diffstat (limited to 'Configuration')
-rw-r--r-- | Configuration/PluginConfiguration.cs | 57 | ||||
-rw-r--r-- | Configuration/configPage.html | 80 |
2 files changed, 137 insertions, 0 deletions
diff --git a/Configuration/PluginConfiguration.cs b/Configuration/PluginConfiguration.cs new file mode 100644 index 0000000..8268858 --- /dev/null +++ b/Configuration/PluginConfiguration.cs @@ -0,0 +1,57 @@ +using MediaBrowser.Model.Plugins; + +namespace Jellyfin.Plugin.JellyFed.Configuration; + +/// <summary> +/// The configuration options. +/// </summary> +public enum SomeOptions +{ + /// <summary> + /// Option one. + /// </summary> + OneOption, + + /// <summary> + /// Second option. + /// </summary> + AnotherOption +} + +/// <summary> +/// Plugin configuration. +/// </summary> +public class PluginConfiguration : BasePluginConfiguration +{ + /// <summary> + /// Initializes a new instance of the <see cref="PluginConfiguration" /> class. + /// </summary> + public PluginConfiguration() + { + // set default options here + Options = SomeOptions.AnotherOption; + TrueFalseSetting = true; + AnInteger = 2; + AString = "string"; + } + + /// <summary> + /// Gets or sets a value indicating whether some true or false setting is enabled. + /// </summary> + public bool TrueFalseSetting { get; set; } + + /// <summary> + /// Gets or sets an integer setting. + /// </summary> + public int AnInteger { get; set; } + + /// <summary> + /// Gets or sets a string setting. + /// </summary> + public string AString { get; set; } + + /// <summary> + /// Gets or sets an enum option. + /// </summary> + public SomeOptions Options { get; set; } +}
\ No newline at end of file diff --git a/Configuration/configPage.html b/Configuration/configPage.html new file mode 100644 index 0000000..b72df9f --- /dev/null +++ b/Configuration/configPage.html @@ -0,0 +1,80 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>Template</title> +</head> +<body> +<div class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button,emby-select,emby-checkbox" data-role="page" + id="TemplateConfigPage"> + <div data-role="content"> + <div class="content-primary"> + <form id="TemplateConfigForm"> + <div class="selectContainer"> + <label class="selectLabel" for="Options">Several Options</label> + <select class="emby-select-withcolor emby-select" id="Options" is="emby-select" name="Options"> + <option id="optOneOption" value="OneOption">One Option</option> + <option id="optAnotherOption" value="AnotherOption">Another Option</option> + </select> + </div> + <div class="inputContainer"> + <label class="inputLabel inputLabelUnfocused" for="AnInteger">An Integer</label> + <input id="AnInteger" is="emby-input" min="0" name="AnInteger" type="number"/> + <div class="fieldDescription">A Description</div> + </div> + <div class="checkboxContainer checkboxContainer-withDescription"> + <label class="emby-checkbox-label"> + <input id="TrueFalseSetting" is="emby-checkbox" name="TrueFalseCheckBox" type="checkbox"/> + <span>A Checkbox</span> + </label> + </div> + <div class="inputContainer"> + <label class="inputLabel inputLabelUnfocused" for="AString">A String</label> + <input id="AString" is="emby-input" name="AString" type="text"/> + <div class="fieldDescription">Another Description</div> + </div> + <div> + <button class="raised button-submit block emby-button" is="emby-button" type="submit"> + <span>Save</span> + </button> + </div> + </form> + </div> + </div> + <script type="text/javascript"> + var TemplateConfig = { + pluginUniqueId: 'eb5d7894-8eef-4b36-aa6f-5d124e828ce1' + }; + + document.querySelector('#TemplateConfigPage') + .addEventListener('pageshow', function () { + Dashboard.showLoadingMsg(); + ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) { + document.querySelector('#Options').value = config.Options; + document.querySelector('#AnInteger').value = config.AnInteger; + document.querySelector('#TrueFalseSetting').checked = config.TrueFalseSetting; + document.querySelector('#AString').value = config.AString; + Dashboard.hideLoadingMsg(); + }); + }); + + document.querySelector('#TemplateConfigForm') + .addEventListener('submit', function (e) { + Dashboard.showLoadingMsg(); + ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) { + config.Options = document.querySelector('#Options').value; + config.AnInteger = document.querySelector('#AnInteger').value; + config.TrueFalseSetting = document.querySelector('#TrueFalseSetting').checked; + config.AString = document.querySelector('#AString').value; + ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) { + Dashboard.processPluginConfigurationUpdateResult(result); + }); + }); + + e.preventDefault(); + return false; + }); + </script> +</div> +</body> +</html> |