From 121177a369c2fe173f91106169229dc7e6d008a2 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 1 May 2023 23:22:25 +0200 Subject: [PATCH 1/3] Shares: enable CLEAN UP button only when unused files are present --- plugins/dynamix/ShareList.page | 16 +++++++--------- plugins/dynamix/include/ShareList.php | 5 ++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/dynamix/ShareList.page b/plugins/dynamix/ShareList.page index 75ec81f9a..b22d0512d 100644 --- a/plugins/dynamix/ShareList.page +++ b/plugins/dynamix/ShareList.page @@ -31,7 +31,7 @@ i.fa-fw{margin-right:2px}
- +
:share_list_help: @@ -54,15 +54,13 @@ function cleanup() { swal({title:"_(CLEAN UP)_",text:"_(Remove unused share configurations)_",type:'info',html:true,animation:'none',showCancelButton:true,closeOnConfirm:false,confirmButtonText:"",cancelButtonText:""},function(cleanup){ if (!cleanup) return; $.post('/webGui/include/ShareList.php',{cleanup:1},function(data){ - let text = "_(No unused share configurations present)_"; - let type = "info"; - if (data > 0) { - text = "_(Removed share configurations)_: "+data; - type = "success"; - } - swal({title:"_(CLEAN UP)_",text:text,type:type,html:true,confirmButtonText:"_(Ok)_"}); + swal({title:"_(CLEAN UP)_",text:"_(Removed share configurations)_: "+data,type:"success",html:true,confirmButtonText:"_(Ok)_"},function(esc){$('#cleanup-button').prop('disabled',true);}); }); }); } -$(shareList('',0)); +$(function(){ + // enable CLEAN_UP button only when unused files are present + $.post('/webGui/include/ShareList.php',{cleanup:0},function(data){if (data>0) $('#cleanup-button').prop('disabled',false);}); + shareList('',0); +}); diff --git a/plugins/dynamix/include/ShareList.php b/plugins/dynamix/include/ShareList.php index 1e50ea855..96d6ad93c 100644 --- a/plugins/dynamix/include/ShareList.php +++ b/plugins/dynamix/include/ShareList.php @@ -22,7 +22,10 @@ if (isset($_POST['cleanup'])) { $shares = array_keys(parse_ini_file('state/shares.ini',true)); // stored shares foreach (glob("/boot/config/shares/*.cfg",GLOB_NOSORT) as $name) { - if (!in_array(basename($name,'.cfg'),$shares)) {$n++; unlink($name);} + if (!in_array(basename($name,'.cfg'),$shares)) { + $n++; + if ($_POST['cleanup']==1) unlink($name); + } } // return number of deleted files die((string)$n); From eb02e0b62ece1943240ad599896e55568d9bdaab Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 2 May 2023 05:59:14 +0200 Subject: [PATCH 2/3] Legacy: Openbox display DONE button inside iframe --- logging.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging.htm b/logging.htm index 28ce22972..9ce9b2ec3 100644 --- a/logging.htm +++ b/logging.htm @@ -78,7 +78,7 @@ function addLog(logLine) { } function addCloseButton() { var done = location.search.split('&').pop().split('=')[1]; - addLog("

"); + addLog("

"); } From 4f88952835dddfe3bac786c6931d9952dc713613 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 2 May 2023 21:47:04 +0200 Subject: [PATCH 3/3] Shares CLEAN UP: compare names case non-sensitive --- plugins/dynamix/include/ShareList.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dynamix/include/ShareList.php b/plugins/dynamix/include/ShareList.php index 96d6ad93c..72a78e56a 100644 --- a/plugins/dynamix/include/ShareList.php +++ b/plugins/dynamix/include/ShareList.php @@ -19,10 +19,10 @@ if (isset($_POST['scan'])) { if (isset($_POST['cleanup'])) { $n = 0; // active shares - $shares = array_keys(parse_ini_file('state/shares.ini',true)); + $shares = array_map('strtolower',array_keys(parse_ini_file('state/shares.ini',true))); // stored shares foreach (glob("/boot/config/shares/*.cfg",GLOB_NOSORT) as $name) { - if (!in_array(basename($name,'.cfg'),$shares)) { + if (!in_array(strtolower(basename($name,'.cfg')),$shares)) { $n++; if ($_POST['cleanup']==1) unlink($name); }