From c1c247baf4634a7d2569d58465a8f71979d37a5f Mon Sep 17 00:00:00 2001 From: aliakseiTraihel Date: Fri, 13 Dec 2024 10:09:09 +0100 Subject: [PATCH 1/3] [ELI_72] Refactoring job status message. --- .../link-inspector-ui/js/console-ui.run.js | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js b/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js index c93e3c4..f9bf703 100644 --- a/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js +++ b/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js @@ -21,18 +21,19 @@ const TRIGGER_DATA_FEED_GENERATION = '/content/etoolbox-link-inspector/servlet/triggerDataFeedGeneration'; const CHECK_JOB_STATUS = '/content/etoolbox-link-inspector/servlet/jobStatus'; + let $jobStatusContainer = null; - function jobIsActive() { - let isActive = false; + function jobIsActive(callback) { $.ajax({ url: CHECK_JOB_STATUS, type: 'GET', async: false, success: function (data) { - isActive = data && data.status && data.status == 'ACTIVE' | 'QUEUED' | 'GIVEN_UP'; + if (data && $.inArray(data.status ,['ACTIVE','QUEUED','GIVEN_UP']) !== -1) { + callback(); + } } }); - return isActive; } function onRunAction(callback) { @@ -43,12 +44,12 @@ }); } - function createInProgressMessage($popover) { - const $container = $('

').text('Job status: '); - $('...in progress').appendTo($container); - $('
').appendTo($container); - $('scan may take some time to complete').appendTo($container);; - $popover.find('coral-popover-content').append($container); + function addJobStatusMessage($popover) { + $jobStatusContainer = $('

').text('Job status: '); + $('...in progress').appendTo($jobStatusContainer); + $('
').appendTo($jobStatusContainer); + $('scan may take some time to complete').appendTo($jobStatusContainer);; + $popover.find('coral-popover-content').append($jobStatusContainer); } function createRunJobMessage($popover) { @@ -58,16 +59,15 @@ } function beforeOpenPopover(e) { - jobIsActive() ? createInProgressMessage($(e.currentTarget)) : createRunJobMessage($(e.currentTarget)); + !$jobStatusContainer && jobIsActive(function () {addJobStatusMessage($(e.currentTarget));}); } function beforeClosePopover(e) { - removeLastChild($(e.currentTarget)); + removeJobStatusMessage(); } - function removeLastChild($popover){ - const $popoverContent = $popover.find('coral-popover-content'); - $popoverContent.children().last().remove(); + function removeJobStatusMessage() { + $jobStatusContainer && $jobStatusContainer.remove() && ($jobStatusContainer = null); } $(document).on('coral-overlay:beforeopen', '.elc-coral-popover', beforeOpenPopover); @@ -83,9 +83,8 @@ url: TRIGGER_DATA_FEED_GENERATION, type: 'GET', success: function () { - const $popover = $('.elc-coral-popover'); - removeLastChild($popover); - createInProgressMessage($popover); + removeJobStatusMessage(); + addJobStatusMessage($('.elc-coral-popover')); } }).error(function (e) { ui.notify('Error', e.responseText || e.statusText, 'error'); From eead5d134b486f9857d6942bfabcd0ba9a42a252 Mon Sep 17 00:00:00 2001 From: aliakseiTraihel Date: Fri, 13 Dec 2024 10:26:16 +0100 Subject: [PATCH 2/3] [ELI_72] Code refactoring . --- .../clientlibs/link-inspector-ui/js/console-ui.run.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js b/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js index f9bf703..bd92b98 100644 --- a/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js +++ b/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js @@ -22,6 +22,7 @@ const TRIGGER_DATA_FEED_GENERATION = '/content/etoolbox-link-inspector/servlet/triggerDataFeedGeneration'; const CHECK_JOB_STATUS = '/content/etoolbox-link-inspector/servlet/jobStatus'; let $jobStatusContainer = null; + let $alertPopup = null; function jobIsActive(callback) { $.ajax({ @@ -81,11 +82,7 @@ formData.append('exclusive', 'true'); $.ajax({ url: TRIGGER_DATA_FEED_GENERATION, - type: 'GET', - success: function () { - removeJobStatusMessage(); - addJobStatusMessage($('.elc-coral-popover')); - } + type: 'GET' }).error(function (e) { ui.notify('Error', e.responseText || e.statusText, 'error'); }); From 6334805103ac7c2c6163f2834668a6d7aa1f7d0f Mon Sep 17 00:00:00 2001 From: aliakseiTraihel Date: Fri, 13 Dec 2024 10:27:33 +0100 Subject: [PATCH 3/3] =?UTF-8?q?[ELI=5F72]=20Redundant=20=D1=81ode.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clientlibs/link-inspector-ui/js/console-ui.run.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js b/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js index bd92b98..5a6bb85 100644 --- a/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js +++ b/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.run.js @@ -22,7 +22,6 @@ const TRIGGER_DATA_FEED_GENERATION = '/content/etoolbox-link-inspector/servlet/triggerDataFeedGeneration'; const CHECK_JOB_STATUS = '/content/etoolbox-link-inspector/servlet/jobStatus'; let $jobStatusContainer = null; - let $alertPopup = null; function jobIsActive(callback) { $.ajax({