diff options
Diffstat (limited to 'Zotlabs/Module/Import_progress.php')
-rw-r--r-- | Zotlabs/Module/Import_progress.php | 57 |
1 files changed, 43 insertions, 14 deletions
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 .= '<h3>' . $co . '</h3>'; - if (is_array($c)) - $o .= '<pre>' . htmlspecialchars(print_array($c)) . '</pre>'; + $fprogress_str = ((intval($fprogress)) ? $fprogress . '%' : $fprogress); - $o .= '<h3>' . $fo . '</h3>'; - if (is_array($f)) - $o .= '<pre>' . htmlspecialchars(print_array($f)) . '</pre>'; + if(is_ajax()) { + $ret = [ + 'cprogress' => $cprogress, + 'fprogress' => $fprogress + ]; + + json_return_and_die($ret); + } - $o .= '<hr>'; - $o .= '<h3>Refresh page for updates!</h3>'; + $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; } |