feat: add collection or playlist choice to config page and dto.
Refs: #1
This commit is contained in:
parent
111faaf126
commit
457755d743
2 changed files with 31 additions and 0 deletions
|
@ -50,6 +50,7 @@ namespace Jellyfin.Plugin.SmartPlaylist {
|
|||
public string SortProgram { get; set; }
|
||||
public string? Filename { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public bool CollectionInsteadOfPlaylist { get; set; }
|
||||
|
||||
public SmartPlaylistDto() {
|
||||
Id = "";
|
||||
|
@ -59,6 +60,7 @@ namespace Jellyfin.Plugin.SmartPlaylist {
|
|||
SortProgram = DEFAULT_SORT_PROGRAM;
|
||||
Filename = null;
|
||||
Enabled = true;
|
||||
CollectionInsteadOfPlaylist = false;
|
||||
}
|
||||
|
||||
protected SmartPlaylistDto(SerializationInfo info, StreamingContext context) {
|
||||
|
@ -97,6 +99,11 @@ namespace Jellyfin.Plugin.SmartPlaylist {
|
|||
} else {
|
||||
Enabled = true;
|
||||
}
|
||||
if (info.GetValue("CollectionInsteadOfPlaylist", typeof(bool)) is bool _CollectionInsteadOfPlaylist) {
|
||||
Enabled = _CollectionInsteadOfPlaylist;
|
||||
} else {
|
||||
Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context) {
|
||||
|
@ -106,6 +113,7 @@ namespace Jellyfin.Plugin.SmartPlaylist {
|
|||
info.AddValue("Program", Program);
|
||||
info.AddValue("Filename", Filename);
|
||||
info.AddValue("Enabled", Enabled);
|
||||
info.AddValue("CollectionInsteadOfPlaylist", CollectionInsteadOfPlaylist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,19 @@
|
|||
<div class="fieldDescription">Is the playlist enabled.</div>
|
||||
<input id="SmartplaylistEditEnabled" type="checkbox" class="emby-input"/>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<fieldset>
|
||||
<legend>Should a playlist or a collection be generated:</legend>
|
||||
<div>
|
||||
<input id="SmartplaylistEditPlaylistChoice" type="radio" name="PlaylistOrCollection" class="emby-input" checked/>
|
||||
<label class="inputLabel inputLabelUnfocused" for="SmartplaylistEditPlaylistChoice">Playlist</label>
|
||||
</div>
|
||||
<div>
|
||||
<input id="SmartplaylistEditCollectionChoice" type="radio" name="PlaylistOrCollection" class="emby-input"/>
|
||||
<label class="inputLabel inputLabelUnfocused" for="SmartplaylistEditCollectionChoice">Collection</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
|
||||
<span>Save</span>
|
||||
|
@ -69,6 +82,8 @@
|
|||
const editSortProgram = document.querySelector('#SmartplaylistEditSortProgram');
|
||||
const editUsers = document.querySelector('#SmartplaylistEditUsers');
|
||||
const editEnabled = document.querySelector('#SmartplaylistEditEnabled');
|
||||
const editPlaylistChoice = document.querySelector('#SmartplaylistEditPlaylistChoice');
|
||||
const editCollectionChoice = document.querySelector('#SmartplaylistEditCollectionChoice');
|
||||
if (id === null) {
|
||||
selection.selectedIndex = 0;
|
||||
editName.value = 'My New Smartplaylist';
|
||||
|
@ -83,6 +98,8 @@
|
|||
editUsers.appendChild(o);
|
||||
}
|
||||
editEnabled.checked = true;
|
||||
editPlaylistChoice.checked = true;
|
||||
editCollectionChoice.checked = false;
|
||||
return;
|
||||
}
|
||||
function matchId(p) {
|
||||
|
@ -105,6 +122,8 @@
|
|||
editUsers.appendChild(o);
|
||||
}
|
||||
editEnabled.checked = p.Enabled;
|
||||
editPlaylistChoice.checked = !p.CollectionInsteadOfPlaylist;
|
||||
editCollectionChoice.checked = p.CollectionInsteadOfPlaylist;
|
||||
}
|
||||
|
||||
function fillPlaylistSelect(config) {
|
||||
|
@ -154,6 +173,8 @@
|
|||
const editSortProgram = document.querySelector('#SmartplaylistEditSortProgram');
|
||||
const editUsers = document.querySelector('#SmartplaylistEditUsers');
|
||||
const editEnabled = document.querySelector('#SmartplaylistEditEnabled');
|
||||
const editPlaylistChoice = document.querySelector('#SmartplaylistEditPlaylistChoice');
|
||||
const editCollectionChoice = document.querySelector('#SmartplaylistEditCollectionChoice');
|
||||
var index = selection.selectedIndex;
|
||||
if (index === 0) {
|
||||
const o = {
|
||||
|
@ -166,6 +187,7 @@
|
|||
return m;
|
||||
}),
|
||||
Enabled: editEnabled.checked,
|
||||
CollectionInsteadOfPlaylist: !editPlaylistChoice.checked,
|
||||
};
|
||||
config.Playlists.push(o);
|
||||
} else {
|
||||
|
@ -179,6 +201,7 @@
|
|||
return m;
|
||||
}),
|
||||
config.Playlists[index-1].Enabled = editEnabled.checked;
|
||||
config.Playlists[index-1].CollectionInsteadOfPlaylist = !editPlaylistChoice.checked;
|
||||
}
|
||||
ApiClient.updatePluginConfiguration(SmartPlaylistConfig.pluginUniqueId, config).then(function (result) {
|
||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||
|
|
Loading…
Add table
Reference in a new issue