From 57ed1956871b24fc9eb8c853d7571a0019f92584 Mon Sep 17 00:00:00 2001 From: Steve HOLWEG Date: Fri, 27 Jul 2018 22:27:48 +0200 Subject: [PATCH] Fix #15 : Hide Organize button when a task is running --- .../Configuration/autoorganizelog.html | 3 ++- Emby.AutoOrganize/Configuration/autoorganizelog.js | 14 +++++++++++--- Emby.AutoOrganize/Core/OrganizerScheduledTask.cs | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Emby.AutoOrganize/Configuration/autoorganizelog.html b/Emby.AutoOrganize/Configuration/autoorganizelog.html index 72bc58f..e865355 100644 --- a/Emby.AutoOrganize/Configuration/autoorganizelog.html +++ b/Emby.AutoOrganize/Configuration/autoorganizelog.html @@ -11,9 +11,10 @@ - + +
diff --git a/Emby.AutoOrganize/Configuration/autoorganizelog.js b/Emby.AutoOrganize/Configuration/autoorganizelog.js index 595f089..47e5520 100644 --- a/Emby.AutoOrganize/Configuration/autoorganizelog.js +++ b/Emby.AutoOrganize/Configuration/autoorganizelog.js @@ -354,7 +354,7 @@ html += ''; var hide = item.IsInProgress ? '' : ' hide'; - html += ''; + html += ''; html += ''; html += ''; @@ -514,7 +514,15 @@ progressElem: view.querySelector('.organizeProgress'), panel: view.querySelector('.organizeTaskPanel'), taskKey: 'AutoOrganize', - button: view.querySelector('.btnOrganize') + button: view.querySelector('#btnOrganize') + }); + + view.querySelector('#btnOrganize').addEventListener('DOMSubtreeModified', function () { + if (view.querySelector('#btnOrganize').disabled) { + view.querySelector('#btnOrganize').classList.add('hide'); + } else { + view.querySelector('#btnOrganize').classList.remove('hide'); + } }); }); @@ -531,7 +539,7 @@ // off here taskButton({ mode: 'off', - button: view.querySelector('.btnOrganize') + button: view.querySelector('#btnOrganize') }); }); }; diff --git a/Emby.AutoOrganize/Core/OrganizerScheduledTask.cs b/Emby.AutoOrganize/Core/OrganizerScheduledTask.cs index 2e7729d..3017cf8 100644 --- a/Emby.AutoOrganize/Core/OrganizerScheduledTask.cs +++ b/Emby.AutoOrganize/Core/OrganizerScheduledTask.cs @@ -57,10 +57,11 @@ public async Task Execute(CancellationToken cancellationToken, IProgress var options = GetAutoOrganizeOptions(); + var fileOrganizationService = PluginEntryPoint.Current.FileOrganizationService; + if (options.TvOptions.IsEnabled) { queueTv = options.TvOptions.QueueLibraryScan; - var fileOrganizationService = PluginEntryPoint.Current.FileOrganizationService; await new TvFolderOrganizer(_libraryManager, _logger, _fileSystem, _libraryMonitor, fileOrganizationService, _config, _providerManager) .Organize(options.TvOptions, cancellationToken, progress).ConfigureAwait(false); @@ -70,7 +71,6 @@ public async Task Execute(CancellationToken cancellationToken, IProgress if (options.MovieOptions.IsEnabled) { queueMovie = options.MovieOptions.QueueLibraryScan; - var fileOrganizationService = PluginEntryPoint.Current.FileOrganizationService; await new MovieFolderOrganizer(_libraryManager, _logger, _fileSystem, _libraryMonitor, fileOrganizationService, _config, _providerManager) .Organize(options.MovieOptions, cancellationToken, progress).ConfigureAwait(false);