Skip to content

Commit 15924ff

Browse files
jonschzqwerty12
andauthored
Merge pull request #2 from jonschz/power-requests
Power requests, delay before reenabling sleep, further improvements Co-authored-by: Faheem Pervez <[email protected]>
2 parents 2094b99 + 07caecd commit 15924ff

File tree

6 files changed

+386
-160
lines changed

6 files changed

+386
-160
lines changed

Directory.Build.props

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.0.1.0</Version>
4-
<AssemblyVersion>0.0.1.0</AssemblyVersion>
5-
<FileVersion>0.0.1.0</FileVersion>
3+
<Version>0.1.0.0</Version>
4+
<AssemblyVersion>0.1.0.0</AssemblyVersion>
5+
<FileVersion>0.1.0.0</FileVersion>
66
</PropertyGroup>
77
</Project>

Jellyfin.Plugin.PreventSleep/Configuration/PluginConfiguration.cs

+3-37
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22

33
namespace Jellyfin.Plugin.PreventSleep.Configuration;
44

5-
/// <summary>
6-
/// The configuration options.
7-
/// </summary>
8-
public enum SomeOptions
9-
{
10-
/// <summary>
11-
/// Option one.
12-
/// </summary>
13-
OneOption,
14-
15-
/// <summary>
16-
/// Second option.
17-
/// </summary>
18-
AnotherOption
19-
}
20-
215
/// <summary>
226
/// Plugin configuration.
237
/// </summary>
@@ -29,29 +13,11 @@ public class PluginConfiguration : BasePluginConfiguration
2913
public PluginConfiguration()
3014
{
3115
// set default options here
32-
Options = SomeOptions.AnotherOption;
33-
TrueFalseSetting = true;
34-
AnInteger = 2;
35-
AString = "string";
16+
UnblockSleepDelay = 1;
3617
}
3718

3819
/// <summary>
39-
/// Gets or sets a value indicating whether some true or false setting is enabled..
40-
/// </summary>
41-
public bool TrueFalseSetting { get; set; }
42-
43-
/// <summary>
44-
/// Gets or sets an integer setting.
45-
/// </summary>
46-
public int AnInteger { get; set; }
47-
48-
/// <summary>
49-
/// Gets or sets a string setting.
50-
/// </summary>
51-
public string AString { get; set; }
52-
53-
/// <summary>
54-
/// Gets or sets an enum option.
20+
/// Gets or sets the amount of minutes to wait before re-enabling sleep.
5521
/// </summary>
56-
public SomeOptions Options { get; set; }
22+
public int UnblockSleepDelay { get; set; }
5723
}

Jellyfin.Plugin.PreventSleep/Configuration/configPage.html

+14-38
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,17 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>Template</title>
5+
<title>Prevent Sleep</title>
66
</head>
77
<body>
8-
<div id="TemplateConfigPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button,emby-select,emby-checkbox">
8+
<div id="PreventSleepConfigPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button,emby-select,emby-checkbox">
99
<div data-role="content">
1010
<div class="content-primary">
11-
<form id="TemplateConfigForm">
12-
<div class="selectContainer">
13-
<label class="selectLabel" for="Options">Several Options</label>
14-
<select is="emby-select" id="Options" name="Options" class="emby-select-withcolor emby-select">
15-
<option id="optOneOption" value="OneOption">One Option</option>
16-
<option id="optAnotherOption" value="AnotherOption">Another Option</option>
17-
</select>
18-
</div>
19-
<div class="inputContainer">
20-
<label class="inputLabel inputLabelUnfocused" for="AnInteger">An Integer</label>
21-
<input id="AnInteger" name="AnInteger" type="number" is="emby-input" min="0" />
22-
<div class="fieldDescription">A Description</div>
23-
</div>
24-
<div class="checkboxContainer checkboxContainer-withDescription">
25-
<label class="emby-checkbox-label">
26-
<input id="TrueFalseSetting" name="TrueFalseCheckBox" type="checkbox" is="emby-checkbox" />
27-
<span>A Checkbox</span>
28-
</label>
29-
</div>
11+
<form id="PreventSleepConfigForm">
3012
<div class="inputContainer">
31-
<label class="inputeLabel inputLabelUnfocused" for="AString">A String</label>
32-
<input id="AString" name="AString" type="text" is="emby-input" />
33-
<div class="fieldDescription">Another Description</div>
13+
<label class="inputLabel inputLabelUnfocused" for="UnblockSleepDelay">Delay before unblocking sleep (in minutes)</label>
14+
<input id="UnblockSleepDelay" name="UnblockSleepDelay" type="number" is="emby-input" min="1" />
15+
<div class="fieldDescription">Wait for the specified time after all playback has ended before allowing sleep again.</div>
3416
</div>
3517
<div>
3618
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
@@ -41,31 +23,25 @@
4123
</div>
4224
</div>
4325
<script type="text/javascript">
44-
var TemplateConfig = {
26+
var PreventSleepConfig = {
4527
pluginUniqueId: 'd6b0196a-9885-4d87-b25c-562a57ebbe0b'
4628
};
4729

48-
document.querySelector('#TemplateConfigPage')
30+
document.querySelector('#PreventSleepConfigPage')
4931
.addEventListener('pageshow', function() {
5032
Dashboard.showLoadingMsg();
51-
ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) {
52-
document.querySelector('#Options').value = config.Options;
53-
document.querySelector('#AnInteger').value = config.AnInteger;
54-
document.querySelector('#TrueFalseSetting').checked = config.TrueFalseSetting;
55-
document.querySelector('#AString').value = config.AString;
33+
ApiClient.getPluginConfiguration(PreventSleepConfig.pluginUniqueId).then(function (config) {
34+
document.querySelector('#UnblockSleepDelay').value = config.UnblockSleepDelay;
5635
Dashboard.hideLoadingMsg();
5736
});
5837
});
5938

60-
document.querySelector('#TemplateConfigForm')
39+
document.querySelector('#PreventSleepConfigForm')
6140
.addEventListener('submit', function(e) {
6241
Dashboard.showLoadingMsg();
63-
ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) {
64-
config.Options = document.querySelector('#Options').value;
65-
config.AnInteger = document.querySelector('#AnInteger').value;
66-
config.TrueFalseSetting = document.querySelector('#TrueFalseSetting').checked;
67-
config.AString = document.querySelector('#AString').value;
68-
ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) {
42+
ApiClient.getPluginConfiguration(PreventSleepConfig.pluginUniqueId).then(function (config) {
43+
config.UnblockSleepDelay = document.querySelector('#UnblockSleepDelay').value;
44+
ApiClient.updatePluginConfiguration(PreventSleepConfig.pluginUniqueId, config).then(function (result) {
6945
Dashboard.processPluginConfigurationUpdateResult(result);
7046
});
7147
});

0 commit comments

Comments
 (0)