-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from jellyfin/web-config
Add ability to configure plugin
- Loading branch information
Showing
7 changed files
with
173 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>DLNA</title> | ||
</head> | ||
<body> | ||
<div data-role="page" class="page type-interior pluginConfigurationPage esqConfigurationPage" data-controller="__plugin/dlnajs"> | ||
<div data-role="content"> | ||
<div class="content-primary"> | ||
<form id="dlnaForm" class="esqConfigurationForm"> | ||
<div class="verticalSection verticalSection-extrabottompadding"> | ||
<div class="sectionTitleContainer flex align-items-center"> | ||
<h2 class="sectionTitle">DNLA Settings:</h2> | ||
<a is="emby-button" class="raised button-alt headerHelpButton" target="_blank" href="https://github.com/jellyfin/jellyfin-plugin-dlna">${Help}</a> | ||
</div> | ||
<div class="verticalSection verticalSection-extrabottompadding"> | ||
<div class="checkboxContainer"> | ||
<label> | ||
<input type="checkbox" is="emby-checkbox" id="dlnaPlayTo" /> | ||
<span>Enable Play To</span> | ||
</label> | ||
</div> | ||
|
||
<div class="inputContainer"> | ||
<input is="emby-input" type="text" id="dlnaDiscoveryInterval" label="Client Discovery Interval:" /> | ||
<div class="fieldDescription"> | ||
The SSDP client discovery interval time in seconds. | ||
The is the time after which the server will send a SSDP search request. | ||
</div> | ||
</div> | ||
|
||
<div class="checkboxContainer"> | ||
<label> | ||
<input type="checkbox" is="emby-checkbox" id="dlnaBlastAlive" /> | ||
<span>Blast Alive Messages</span> | ||
</label> | ||
</div> | ||
|
||
<div class="inputContainer"> | ||
<input is="emby-input" type="text" id="dlnaAliveInterval" label="Alive Message Interval:" /> | ||
<div class="fieldDescription"> | ||
The frequency at which SSDP alive notifications are transmitted in seconds. | ||
</div> | ||
</div> | ||
|
||
<div class="checkboxContainer"> | ||
<label> | ||
<input type="checkbox" is="emby-checkbox" id="dlnaMatchedHost" /> | ||
<span>Send only to matched host</span> | ||
</label> | ||
</div> | ||
|
||
<div class="selectContainer"> | ||
<select is="emby-select" id="dlnaSelectUser" label="Default User:"></select> | ||
</div> | ||
</div> | ||
<div> | ||
<button is="emby-button" type="submit" data-theme="b" class="raised button-submit block"> | ||
<span>${Save}</span> | ||
</button> | ||
<button is="emby-button" type="button" class="raised button-cancel block btnCancel" onclick="history.back();"> | ||
<span>${ButtonCancel}</span> | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const DlnaConfigurationPage = { | ||
pluginUniqueId: '33EBA9CD-7DA1-4720-967F-DD7DAE7B74A1', | ||
defaultDiscoveryInterval: 60, | ||
defaultAliveInterval: 100, | ||
loadConfiguration: function (page) { | ||
ApiClient.getPluginConfiguration(this.pluginUniqueId) | ||
.then(function(config) { | ||
page.querySelector('#dlnaPlayTo').checked = config.EnablePlayTo; | ||
page.querySelector('#dlnaDiscoveryInterval').value = parseInt(config.ClientDiscoveryIntervalSeconds) || this.defaultDiscoveryInterval; | ||
page.querySelector('#dlnaBlastAlive').checked = config.BlastAliveMessages; | ||
page.querySelector('#dlnaAliveInterval').value = parseInt(config.AliveMessageIntervalSeconds) || this.defaultAliveInterval; | ||
page.querySelector('#dlnaMatchedHost').checked = config.SendOnlyMatchedHost; | ||
|
||
ApiClient.getUsers() | ||
.then(function(users){ | ||
DlnaConfigurationPage.populateUsers(page, users, config.DefaultUserId); | ||
}) | ||
.finally(function (){ | ||
Dashboard.hideLoadingMsg(); | ||
}); | ||
}); | ||
}, | ||
populateUsers: function(page, users, selectedId){ | ||
let html = ''; | ||
html += '<option value="">None</option>'; | ||
for(let i = 0, length = users.length; i < length; i++) { | ||
const user = users[i]; | ||
html += '<option value="' + user.Id + '">' + user.Name + '</option>'; | ||
} | ||
|
||
page.querySelector('#dlnaSelectUser').innerHTML = html; | ||
page.querySelector('#dlnaSelectUser').value = selectedId; | ||
}, | ||
save: function(page) { | ||
Dashboard.showLoadingMsg(); | ||
return new Promise((_) => { | ||
ApiClient.getPluginConfiguration(this.pluginUniqueId) | ||
.then(function(config) { | ||
config.EnablePlayTo = page.querySelector('#dlnaPlayTo').checked; | ||
config.ClientDiscoveryIntervalSeconds = parseInt(page.querySelector('#dlnaDiscoveryInterval').value) || this.defaultDiscoveryInterval; | ||
config.BlastAliveMessages = page.querySelector('#dlnaBlastAlive').checked; | ||
config.AliveMessageIntervalSeconds = parseInt(page.querySelector('#dlnaAliveInterval').value) || this.defaultAliveInterval; | ||
config.SendOnlyMatchedHost = page.querySelector('#dlnaMatchedHost').checked; | ||
|
||
let selectedUser = page.querySelector('#dlnaSelectUser').value; | ||
config.DefaultUserId = selectedUser.length > 0 ? selectedUser : null; | ||
|
||
ApiClient.updatePluginConfiguration(DlnaConfigurationPage.pluginUniqueId, config).then(Dashboard.processPluginConfigurationUpdateResult); | ||
}); | ||
}) | ||
} | ||
} | ||
|
||
export default function(view) { | ||
view.querySelector('#dlnaForm').addEventListener('submit', function(e) { | ||
DlnaConfigurationPage.save(view); | ||
e.preventDefault(); | ||
return false; | ||
}); | ||
|
||
window.addEventListener('pageshow', function(_) { | ||
Dashboard.showLoadingMsg(); | ||
DlnaConfigurationPage.loadConfiguration(view); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters