Radarr-Sonarr-Integration #12
@@ -3,46 +3,6 @@ var MediaCleanerConfig = {
|
|||||||
pluginUniqueId: 'fef007a8-3e8f-4aa8-a22e-486a387f4192'
|
pluginUniqueId: 'fef007a8-3e8f-4aa8-a22e-486a387f4192'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handlers
|
|
||||||
document.querySelector('#RadarrTestConnectionButton')
|
|
||||||
.addEventListener('click', testConnectionRadarr);
|
|
||||||
|
|
||||||
document.querySelector('#SonarrTestConnectionButton')
|
|
||||||
.addEventListener('click', testConnectionSonarr);
|
|
||||||
|
|
||||||
document.querySelector('#MediaCleanerConfigPage')
|
|
||||||
.addEventListener('pageshow', function() {
|
|
||||||
Dashboard.showLoadingMsg();
|
|
||||||
ApiClient.getPluginConfiguration(MediaCleanerConfig.pluginUniqueId).then(function (config) {
|
|
||||||
document.querySelector('#RadarrAPIKey').value = config.RadarrAPIKey;
|
|
||||||
document.querySelector('#RadarrAddress').value = config.RadarrAddress;
|
|
||||||
document.querySelector('#SonarrAPIKey').value = config.SonarrAPIKey;
|
|
||||||
document.querySelector('#SonarrAddress').value = config.SonarrAddress;
|
|
||||||
document.querySelector('#StaleMediaCutoff').value = config.StaleMediaCutoff;
|
|
||||||
document.querySelector('#DebugMode').checked = config.DebugMode;
|
|
||||||
Dashboard.hideLoadingMsg();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelector('#MediaCleanerConfigForm')
|
|
||||||
.addEventListener('submit', function(e) {
|
|
||||||
Dashboard.showLoadingMsg();
|
|
||||||
ApiClient.getPluginConfiguration(MediaCleanerConfig.pluginUniqueId).then(function (config) {
|
|
||||||
config.RadarrAPIKey = document.querySelector('#RadarrAPIKey').value;
|
|
||||||
config.RadarrAddress = document.querySelector('#RadarrAddress').value;
|
|
||||||
config.SonarrAPIKey = document.querySelector('#SonarrAPIKey').value;
|
|
||||||
config.SonarrAddress = document.querySelector('#SonarrAddress').value;
|
|
||||||
config.StaleMediaCutoff = document.querySelector('#StaleMediaCutoff').value;
|
|
||||||
config.DebugMode = document.querySelector('#DebugMode').checked;
|
|
||||||
ApiClient.updatePluginConfiguration(MediaCleanerConfig.pluginUniqueId, config).then(function (result) {
|
|
||||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fades
|
// Fades
|
||||||
const startFadeOut = (element, interval = 100) => {
|
const startFadeOut = (element, interval = 100) => {
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
@@ -88,7 +48,6 @@ const testConnectionRadarr = async () => {
|
|||||||
await validateConnection(apiKeyElement, addressElement, validationElement);
|
await validateConnection(apiKeyElement, addressElement, validationElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Validation and Normalization
|
// Validation and Normalization
|
||||||
const normalizeUrl = (url) => {
|
const normalizeUrl = (url) => {
|
||||||
let normalizedUrl = url.trim();
|
let normalizedUrl = url.trim();
|
||||||
@@ -159,3 +118,43 @@ const processValidationElement = (validationElement, success) => {
|
|||||||
setTimeout(() => startFadeOut(validationElement, 50), 2000);
|
setTimeout(() => startFadeOut(validationElement, 50), 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Handlers
|
||||||
|
document.querySelector('#RadarrTestConnectionButton')
|
||||||
|
.addEventListener('click', testConnectionRadarr);
|
||||||
|
|
||||||
|
document.querySelector('#SonarrTestConnectionButton')
|
||||||
|
.addEventListener('click', testConnectionSonarr);
|
||||||
|
|
||||||
|
document.querySelector('#MediaCleanerConfigPage')
|
||||||
|
.addEventListener('pageshow', function() {
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
ApiClient.getPluginConfiguration(MediaCleanerConfig.pluginUniqueId).then(function (config) {
|
||||||
|
document.querySelector('#RadarrAPIKey').value = config.RadarrAPIKey;
|
||||||
|
document.querySelector('#RadarrAddress').value = config.RadarrAddress;
|
||||||
|
document.querySelector('#SonarrAPIKey').value = config.SonarrAPIKey;
|
||||||
|
document.querySelector('#SonarrAddress').value = config.SonarrAddress;
|
||||||
|
document.querySelector('#StaleMediaCutoff').value = config.StaleMediaCutoff;
|
||||||
|
document.querySelector('#DebugMode').checked = config.DebugMode;
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector('#MediaCleanerConfigForm')
|
||||||
|
.addEventListener('submit', function(e) {
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
ApiClient.getPluginConfiguration(MediaCleanerConfig.pluginUniqueId).then(function (config) {
|
||||||
|
config.RadarrAPIKey = document.querySelector('#RadarrAPIKey').value;
|
||||||
|
config.RadarrAddress = document.querySelector('#RadarrAddress').value;
|
||||||
|
config.SonarrAPIKey = document.querySelector('#SonarrAPIKey').value;
|
||||||
|
config.SonarrAddress = document.querySelector('#SonarrAddress').value;
|
||||||
|
config.StaleMediaCutoff = document.querySelector('#StaleMediaCutoff').value;
|
||||||
|
config.DebugMode = document.querySelector('#DebugMode').checked;
|
||||||
|
ApiClient.updatePluginConfiguration(MediaCleanerConfig.pluginUniqueId, config).then(function (result) {
|
||||||
|
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user