diff options
-rw-r--r-- | Zotlabs/Daemon/Content_importer.php | 4 | ||||
-rw-r--r-- | Zotlabs/Daemon/File_importer.php | 1 | ||||
-rw-r--r-- | Zotlabs/Module/Import_progress.php | 47 | ||||
-rw-r--r-- | view/js/mod_import_progress.js | 12 | ||||
-rw-r--r-- | view/tpl/import_progress.tpl | 20 |
5 files changed, 57 insertions, 27 deletions
diff --git a/Zotlabs/Daemon/Content_importer.php b/Zotlabs/Daemon/Content_importer.php index 4a07b4cf4..67f1c8e80 100644 --- a/Zotlabs/Daemon/Content_importer.php +++ b/Zotlabs/Daemon/Content_importer.php @@ -48,11 +48,9 @@ class Content_importer { } $j = json_decode($x['body'],true); - if (! $j) { - return; - } if(! is_array($j['item']) || ! count($j['item'])) { + PConfig::Set($channel['channel_id'], 'import', 'content_completed', 1); return; } diff --git a/Zotlabs/Daemon/File_importer.php b/Zotlabs/Daemon/File_importer.php index 28fb172a7..7067e152d 100644 --- a/Zotlabs/Daemon/File_importer.php +++ b/Zotlabs/Daemon/File_importer.php @@ -49,6 +49,7 @@ class File_importer { $j = json_decode($x['body'],true); if(! is_array($j['results'][0]['attach']) || ! count($j['results'][0]['attach'])) { + PConfig::Set($channel['channel_id'], 'import', 'files_completed', 1); return; } 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; diff --git a/view/js/mod_import_progress.js b/view/js/mod_import_progress.js index acfb78de8..7aed56365 100644 --- a/view/js/mod_import_progress.js +++ b/view/js/mod_import_progress.js @@ -8,39 +8,41 @@ $(document).ready(function() { } function update_progress(data){ + + // items if (typeof data.cprogress == 'number') { $('#cprogress-label').html(data.cprogress + '%'); $('#cprogress-bar').css('width', data.cprogress + '%'); if (data.cprogress == 100) { $('#cprogress-resume').addClass('d-none'); - $('#cprogress-complete').removeClass('d-none'); + $('#cprogress-completed').removeClass('d-none'); $('#cprogress-bar').removeClass('progress-bar-animated'); } else if (data.cprogress < 100) { $('#cprogress-resume').removeClass('d-none'); - $('#cprogress-complete').addClass('d-none'); + $('#cprogress-completed').addClass('d-none'); $('#cprogress-bar').addClass('progress-bar-animated'); } } else { $('#cprogress-label').html(data.cprogress); $('#cprogress-bar').css('width', '0%'); - } + // files if (typeof data.fprogress == 'number') { $('#fprogress-label').html(data.fprogress + '%'); $('#fprogress-bar').css('width', data.fprogress + '%'); if (data.fprogress == 100) { $('#fprogress-resume').addClass('d-none'); - $('#fprogress-complete').removeClass('d-none'); + $('#fprogress-completed').removeClass('d-none'); $('#fprogress-bar').removeClass('progress-bar-animated'); } else if (data.fprogress < 100) { $('#fprogress-resume').removeClass('d-none'); - $('#fprogress-complete').addClass('d-none'); + $('#fprogress-completed').addClass('d-none'); $('#fprogress-bar').addClass('progress-bar-animated'); } } diff --git a/view/tpl/import_progress.tpl b/view/tpl/import_progress.tpl index 997adad22..05f6c09e3 100644 --- a/view/tpl/import_progress.tpl +++ b/view/tpl/import_progress.tpl @@ -1,42 +1,42 @@ -<h3>Channel clone status: 100%</h3> +<h3>{{$chtitle_str}}: 100%</h3> <div> <div class="progress mb-2"> <div class="progress-bar progress-bar-striped bg-primary" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div> </div> <div> - <span class="text-muted">Channel cloning completed!</span> + <span class="text-muted">{{$chcompleted_str}}</span> </div> </div> <hr> -<h3>Item sync status: <span id="cprogress-label">{{$cprogress_str}}</span></h3> +<h3>{{$ctitle_str}}: <span id="cprogress-label">{{$cprogress_str}}</span></h3> <div id="cprogress"> <div class="progress mb-2"> <div id="cprogress-bar" class="progress-bar progress-bar-striped bg-warning{{if $cprogress < 100}} progress-bar-animated{{/if}}" role="progressbar" style="width: {{$cprogress}}%" aria-valuenow="{{$cprogress}}" aria-valuemin="0" aria-valuemax="100"></div> </div> <div id="cprogress-resume" class="{{if $cprogress == 100}}d-none{{/if}}"> - <a href="/import_progress/resume_itemsync">[ RESUME ]</a> <span class="text-muted">Only resume if sync stalled!</span> + <a href="/import_progress/resume_itemsync" class="text-capitalize">[ {{$resume_str}} ]</a> <span class="text-muted">{{$resume_helper_str}}</span> </div> - <div id="cprogress-complete" class="{{if $cprogress < 100}}d-none{{/if}}"> - <span class="text-muted">Item sync completed!</span> + <div id="cprogress-completed" class="{{if $cprogress < 100}}d-none{{/if}}"> + <span class="text-muted">{{$ccompleted_str}}</span> </div> </div> <hr> -<h3>File sync status: <span id="fprogress-label">{{$fprogress_str}}</span></h3> +<h3>{{$ftitle_str}}: <span id="fprogress-label">{{$fprogress_str}}</span></h3> <div id="fprogress"> <div class="progress mb-2"> <div id="fprogress-bar" class="progress-bar progress-bar-striped bg-info{{if $fprogress < 100}} progress-bar-animated{{/if}}" role="progressbar" style="width: {{$fprogress}}%" aria-valuenow="{{$fprogress}}" aria-valuemin="0" aria-valuemax="100"></div> </div> <div id="fprogress-resume" class="{{if $fprogress == 100}}d-none{{/if}}"> - <a href="/import_progress/resume_filesync">[ RESUME ]</a> <span class="text-muted">Only resume if sync stalled!</span> + <a href="/import_progress/resume_filesync" class="text-capitalize">[ {{$resume_str}} ]</a> <span class="text-muted">{{$resume_helper_str}}</span> </div> - <div id="fprogress-complete" class="{{if $fprogress < 100}}d-none{{/if}}"> - <span class="text-muted">File sync completed!</span> + <div id="fprogress-completed" class="{{if $fprogress < 100}}d-none{{/if}}"> + <span class="text-muted">{{$fcompleted_str}}</span> </div> </div> |