From 6236869ebed317aa06078f606156edcec9f9b55b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 30 Sep 2021 17:34:30 +0200 Subject: implement file totals and add mod import_progress --- Zotlabs/Module/Import_progress.php | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Zotlabs/Module/Import_progress.php (limited to 'Zotlabs/Module/Import_progress.php') diff --git a/Zotlabs/Module/Import_progress.php b/Zotlabs/Module/Import_progress.php new file mode 100644 index 000000000..3bae94bbb --- /dev/null +++ b/Zotlabs/Module/Import_progress.php @@ -0,0 +1,66 @@ +' . $co . ''; + if (is_array($c)) + $o .= '
' . htmlspecialchars(print_array($c)) . '
'; + + $o .= '

' . $fo . '

'; + if (is_array($f)) + $o .= '
' . htmlspecialchars(print_array($f)) . '
'; + + $o .= '

Refresh page for updates!

'; + + return $o; + } + +} -- cgit v1.2.3 From d462230b820c4f349dcd0fb4202745d018551120 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 30 Sep 2021 17:43:29 +0200 Subject: minor display change --- Zotlabs/Module/Import_progress.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module/Import_progress.php') diff --git a/Zotlabs/Module/Import_progress.php b/Zotlabs/Module/Import_progress.php index 3bae94bbb..40cddd4a8 100644 --- a/Zotlabs/Module/Import_progress.php +++ b/Zotlabs/Module/Import_progress.php @@ -58,7 +58,8 @@ class Import_progress extends \Zotlabs\Web\Controller { if (is_array($f)) $o .= '
' . htmlspecialchars(print_array($f)) . '
'; - $o .= '

Refresh page for updates!

'; + $o .= '
'; + $o .= '

Refresh page for updates!

'; return $o; } -- cgit v1.2.3 From 6ed160e4fa05e880bc81720b626f2bdc68a20db8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 30 Sep 2021 17:50:36 +0200 Subject: wording --- Zotlabs/Module/Import_progress.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module/Import_progress.php') diff --git a/Zotlabs/Module/Import_progress.php b/Zotlabs/Module/Import_progress.php index 40cddd4a8..f255dcbe9 100644 --- a/Zotlabs/Module/Import_progress.php +++ b/Zotlabs/Module/Import_progress.php @@ -22,7 +22,7 @@ class Import_progress extends \Zotlabs\Web\Controller { $c = PConfig::Get(local_channel(), 'import', 'content_progress'); if (!$c) { - $co = 'Status items: waiting to start...'; + $co = 'Item sync status: waiting to start...'; } else { $total_cpages = floor(intval($c['items_total']) / intval($c['items_page'])); @@ -31,14 +31,14 @@ class Import_progress extends \Zotlabs\Web\Controller { $cpage = $c['last_page'] + 1; // because page count start at 0 - $co = 'Status items: ' . floor((intval($cpage) * 100) / $total_cpages) . '%'; + $co = 'Item sync status: ' . floor((intval($cpage) * 100) / $total_cpages) . '%'; } // files $f = PConfig::Get(local_channel(), 'import', 'files_progress'); if (!$f) { - $fo = 'Status files: waiting to start...'; + $fo = 'File sync status: waiting to start...'; } else { $total_fpages = floor(intval($f['files_total']) / intval($f['files_page'])); @@ -47,7 +47,7 @@ class Import_progress extends \Zotlabs\Web\Controller { $fpage = $f['last_page'] + 1; - $fo = 'Status files: ' . floor((intval($fpage) * 100) / $total_fpages) . '%'; + $fo = 'File sync status: ' . floor((intval($fpage) * 100) / $total_fpages) . '%'; } $o .= '

' . $co . '

'; -- cgit v1.2.3 From b1eaa810ce37e4af88fdb41f0067b56f8725ef31 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Oct 2021 17:09:36 +0200 Subject: improve channel import progress page --- Zotlabs/Module/Import_progress.php | 57 ++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) (limited to 'Zotlabs/Module/Import_progress.php') diff --git a/Zotlabs/Module/Import_progress.php b/Zotlabs/Module/Import_progress.php index f255dcbe9..cc4f0c0ea 100644 --- a/Zotlabs/Module/Import_progress.php +++ b/Zotlabs/Module/Import_progress.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module; use Zotlabs\Lib\PConfig; +use Zotlabs\Daemon\Master; class Import_progress extends \Zotlabs\Web\Controller { @@ -18,48 +19,76 @@ class Import_progress extends \Zotlabs\Web\Controller { return; } + nav_set_selected('Channel Import'); + // items $c = PConfig::Get(local_channel(), 'import', 'content_progress'); if (!$c) { - $co = 'Item sync status: waiting to start...'; + $cprogress = 'waiting to start...'; } else { + + if(argv(1) === 'restart_itemsync') { + Master::Summon($c['next_cmd']); + goaway('/import_progress'); + } + $total_cpages = floor(intval($c['items_total']) / intval($c['items_page'])); - if(!$total_cpages) + if(!$total_cpages) { $total_cpages = 1; // because of floor + } $cpage = $c['last_page'] + 1; // because page count start at 0 - $co = 'Item sync status: ' . floor((intval($cpage) * 100) / $total_cpages) . '%'; + $cprogress = intval(floor((intval($cpage) * 100) / $total_cpages)); + + } + $cprogress_str = ((intval($cprogress)) ? $cprogress . '%' : $cprogress); + // files $f = PConfig::Get(local_channel(), 'import', 'files_progress'); if (!$f) { - $fo = 'File sync status: waiting to start...'; + $fprogress = 'waiting to start...'; } else { + + if(argv(1) === 'restart_filesync') { + Master::Summon($f['next_cmd']); + goaway('/import_progress'); + } + $total_fpages = floor(intval($f['files_total']) / intval($f['files_page'])); - if(!$total_fpages) + if(!$total_fpages) { $total_fpages = 1; + } $fpage = $f['last_page'] + 1; - $fo = 'File sync status: ' . floor((intval($fpage) * 100) / $total_fpages) . '%'; + $fprogress = intval(floor((intval($fpage) * 100) / $total_fpages)); + } - $o .= '

' . $co . '

'; - if (is_array($c)) - $o .= '
' . htmlspecialchars(print_array($c)) . '
'; + $fprogress_str = ((intval($fprogress)) ? $fprogress . '%' : $fprogress); - $o .= '

' . $fo . '

'; - if (is_array($f)) - $o .= '
' . htmlspecialchars(print_array($f)) . '
'; + if(is_ajax()) { + $ret = [ + 'cprogress' => $cprogress, + 'fprogress' => $fprogress + ]; + + json_return_and_die($ret); + } - $o .= '
'; - $o .= '

Refresh page for updates!

'; + $o = replace_macros(get_markup_template("import_progress.tpl"), [ + '$cprogress_str' => $cprogress_str, + '$cprogress' => intval($cprogress), + '$fprogress_str' => $fprogress_str, + '$fprogress' => intval($fprogress), + ]); return $o; } -- cgit v1.2.3 From 9a87b8bf1b4384660822f6cb820dbc09e308d07f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Oct 2021 17:24:19 +0200 Subject: only allow resume if we are not completed yet --- Zotlabs/Module/Import_progress.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'Zotlabs/Module/Import_progress.php') diff --git a/Zotlabs/Module/Import_progress.php b/Zotlabs/Module/Import_progress.php index cc4f0c0ea..06498f649 100644 --- a/Zotlabs/Module/Import_progress.php +++ b/Zotlabs/Module/Import_progress.php @@ -29,11 +29,6 @@ class Import_progress extends \Zotlabs\Web\Controller { } else { - if(argv(1) === 'restart_itemsync') { - Master::Summon($c['next_cmd']); - goaway('/import_progress'); - } - $total_cpages = floor(intval($c['items_total']) / intval($c['items_page'])); if(!$total_cpages) { $total_cpages = 1; // because of floor @@ -43,7 +38,10 @@ class Import_progress extends \Zotlabs\Web\Controller { $cprogress = intval(floor((intval($cpage) * 100) / $total_cpages)); - + if(argv(1) === 'resume_itemsync' && $cprogress < 100) { + Master::Summon($c['next_cmd']); + goaway('/import_progress'); + } } $cprogress_str = ((intval($cprogress)) ? $cprogress . '%' : $cprogress); @@ -55,12 +53,6 @@ class Import_progress extends \Zotlabs\Web\Controller { $fprogress = 'waiting to start...'; } else { - - if(argv(1) === 'restart_filesync') { - Master::Summon($f['next_cmd']); - goaway('/import_progress'); - } - $total_fpages = floor(intval($f['files_total']) / intval($f['files_page'])); if(!$total_fpages) { $total_fpages = 1; @@ -70,6 +62,11 @@ class Import_progress extends \Zotlabs\Web\Controller { $fprogress = intval(floor((intval($fpage) * 100) / $total_fpages)); + if(argv(1) === 'resume_filesync' && $fprogress < 100) { + Master::Summon($f['next_cmd']); + goaway('/import_progress'); + } + } $fprogress_str = ((intval($fprogress)) ? $fprogress . '%' : $fprogress); -- cgit v1.2.3 From 47e83a15c1168cfd8ebc7905db853f3db6b3b31b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Oct 2021 21:52:30 +0200 Subject: import_progress: deal with the situation where items/files are being imported but there are none to import --- Zotlabs/Module/Import_progress.php | 47 ++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'Zotlabs/Module/Import_progress.php') diff --git a/Zotlabs/Module/Import_progress.php b/Zotlabs/Module/Import_progress.php index 06498f649..761d2f215 100644 --- a/Zotlabs/Module/Import_progress.php +++ b/Zotlabs/Module/Import_progress.php @@ -24,11 +24,7 @@ class Import_progress extends \Zotlabs\Web\Controller { // items $c = PConfig::Get(local_channel(), 'import', 'content_progress'); - if (!$c) { - $cprogress = 'waiting to start...'; - } - else { - + if ($c) { $total_cpages = floor(intval($c['items_total']) / intval($c['items_page'])); if(!$total_cpages) { $total_cpages = 1; // because of floor @@ -37,22 +33,35 @@ class Import_progress extends \Zotlabs\Web\Controller { $cpage = $c['last_page'] + 1; // because page count start at 0 $cprogress = intval(floor((intval($cpage) * 100) / $total_cpages)); + $ccompleted_str = t('Item sync completed!'); if(argv(1) === 'resume_itemsync' && $cprogress < 100) { Master::Summon($c['next_cmd']); goaway('/import_progress'); } } + else { + $cprogress = 'waiting to start...'; + + if (PConfig::Get(local_channel(), 'import', 'content_completed')) { + // There was nothing todo. Fake 100% and mention that there were no files found + $cprogress = 100; + } + + $ccompleted_str = t('Item sync completed but no items were found!'); + + if(argv(1) === 'resume_itemsync') { + Master::Summon(["Content_importer","0","0001-01-01 00:00:00","2021-10-02 19:49:14","ct5","https%3A%2F%2Fhub.somaton.com"]); + goaway('/import_progress'); + } + } $cprogress_str = ((intval($cprogress)) ? $cprogress . '%' : $cprogress); // files $f = PConfig::Get(local_channel(), 'import', 'files_progress'); - if (!$f) { - $fprogress = 'waiting to start...'; - } - else { + if ($f) { $total_fpages = floor(intval($f['files_total']) / intval($f['files_page'])); if(!$total_fpages) { $total_fpages = 1; @@ -61,12 +70,24 @@ class Import_progress extends \Zotlabs\Web\Controller { $fpage = $f['last_page'] + 1; $fprogress = intval(floor((intval($fpage) * 100) / $total_fpages)); + $fcompleted_str = t('File sync completed!'); if(argv(1) === 'resume_filesync' && $fprogress < 100) { Master::Summon($f['next_cmd']); goaway('/import_progress'); } + + } + else { + $fprogress = 'waiting to start...'; + + if (PConfig::Get(local_channel(), 'import', 'files_completed')) { + // There was nothing todo. Fake 100% and mention that there were no files found + $fprogress = 100; + } + + $fcompleted_str = t('File sync completed but no files were found!'); } $fprogress_str = ((intval($fprogress)) ? $fprogress . '%' : $fprogress); @@ -81,10 +102,18 @@ class Import_progress extends \Zotlabs\Web\Controller { } $o = replace_macros(get_markup_template("import_progress.tpl"), [ + '$chtitle_str' => t('Channel clone status'), + '$ctitle_str' => t('Item sync status'), + '$ftitle_str' => t('File sync status'), '$cprogress_str' => $cprogress_str, '$cprogress' => intval($cprogress), '$fprogress_str' => $fprogress_str, '$fprogress' => intval($fprogress), + '$fcompleted_str' => $fcompleted_str, + '$ccompleted_str' => $ccompleted_str, + '$chcompleted_str' => t('Channel cloning completed!'), + '$resume_str' => t('Resume'), + '$resume_helper_str' => t('Only resume if sync stalled!') ]); return $o; -- cgit v1.2.3