Repair the blank algorithm select and missing logo in ListenBrainz plugin settings
This commit is contained in:
@@ -18,12 +18,12 @@
|
||||
<div class="selectContainer">
|
||||
<label class="selectLabel" for="algorithm">Similarity Algorithm</label>
|
||||
<select is="emby-select" id="algorithm" class="emby-select-withcolor">
|
||||
<option value="0" selected>~5 years / 1825 days (Recommended)</option>
|
||||
<option value="1">~5 years / 1800 days</option>
|
||||
<option value="2">~20 years / 7500 days</option>
|
||||
<option value="3">~20 years / 7500 days (high contribution)</option>
|
||||
<option value="4">~25 years / 9000 days</option>
|
||||
<option value="5">~75 days (recent)</option>
|
||||
<option value="SessionBased1825Days" selected>~5 years / 1825 days (Recommended)</option>
|
||||
<option value="SessionBased1800Days">~5 years / 1800 days</option>
|
||||
<option value="SessionBased7500Days">~20 years / 7500 days</option>
|
||||
<option value="SessionBased7500DaysHighContribution">~20 years / 7500 days (high contribution)</option>
|
||||
<option value="SessionBased9000Days">~25 years / 9000 days</option>
|
||||
<option value="SessionBased75Days">~75 days (recent)</option>
|
||||
</select>
|
||||
<div class="fieldDescription">The algorithm used for artist similarity calculation.</div>
|
||||
</div>
|
||||
@@ -52,13 +52,26 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var ListenBrainzPluginConfig = {
|
||||
uniquePluginId: "a5b2e8c1-9d4f-4a3b-8c7e-6f1a2b3c4d5e"
|
||||
uniquePluginId: "a5b2e8c1-9d4f-4a3b-8c7e-6f1a2b3c4d5e",
|
||||
defaultAlgorithm: "SessionBased1825Days"
|
||||
};
|
||||
|
||||
document.querySelector('.configPage')
|
||||
.addEventListener('pageshow', function () {
|
||||
Dashboard.showLoadingMsg();
|
||||
document.querySelector('#listenBrainzLogo').src = ApiClient.getUrl('web/ConfigurationPage', { name: 'ListenBrainzLogo' });
|
||||
|
||||
// The logo is served as the plugin's embedded image, which is addressed by id and version.
|
||||
ApiClient.getInstalledPlugins().then(function (plugins) {
|
||||
var wantedId = ListenBrainzPluginConfig.uniquePluginId.replace(/-/g, '');
|
||||
var plugin = plugins.filter(function (installed) {
|
||||
return (installed.Id || '').replace(/-/g, '').toLowerCase() === wantedId;
|
||||
})[0];
|
||||
|
||||
if (plugin) {
|
||||
document.querySelector('#listenBrainzLogo').src = ApiClient.getUrl('Plugins/' + plugin.Id + '/' + plugin.Version + '/Image');
|
||||
}
|
||||
});
|
||||
|
||||
ApiClient.getPluginConfiguration(ListenBrainzPluginConfig.uniquePluginId).then(function (config) {
|
||||
var labsServer = document.querySelector('#labsServer');
|
||||
labsServer.value = config.LabsServer;
|
||||
@@ -67,7 +80,13 @@
|
||||
cancelable: false
|
||||
}));
|
||||
|
||||
document.querySelector('#algorithm').value = config.Algorithm;
|
||||
// The API serialises the algorithm as its enum name, so an unknown value here
|
||||
// means a config written by an older build; fall back to the default.
|
||||
var algorithm = document.querySelector('#algorithm');
|
||||
algorithm.value = config.Algorithm;
|
||||
if (!algorithm.value) {
|
||||
algorithm.value = ListenBrainzPluginConfig.defaultAlgorithm;
|
||||
}
|
||||
|
||||
var rateLimit = document.querySelector('#rateLimit');
|
||||
rateLimit.value = config.RateLimit;
|
||||
@@ -93,7 +112,7 @@
|
||||
|
||||
ApiClient.getPluginConfiguration(ListenBrainzPluginConfig.uniquePluginId).then(function (config) {
|
||||
config.LabsServer = document.querySelector('#labsServer').value;
|
||||
config.Algorithm = parseInt(document.querySelector('#algorithm').value, 10);
|
||||
config.Algorithm = document.querySelector('#algorithm').value;
|
||||
config.RateLimit = document.querySelector('#rateLimit').value;
|
||||
config.SimilarItemsCacheDays = parseInt(document.querySelector('#similarItemsCacheDays').value, 10);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user