aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-09-24 19:56:15 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-24 19:56:15 +0200
commit13a522dfbd64d1eb14b6e3715289753b0506ded0 (patch)
treeb71e24a29ab0495f405d9002e1f3a29765c3c6cf /src/Wallabag/ImportBundle
parente10f3b1e914ee94a698281a4cc7efdbfa79c5248 (diff)
downloadwallabag-13a522dfbd64d1eb14b6e3715289753b0506ded0.tar.gz
wallabag-13a522dfbd64d1eb14b6e3715289753b0506ded0.tar.zst
wallabag-13a522dfbd64d1eb14b6e3715289753b0506ded0.zip
Display a message when async import won’t work
Mostly if Redis or RabbitMQ isn’t installed / launched. I guess it’ll avoid some issues.
Diffstat (limited to 'src/Wallabag/ImportBundle')
-rw-r--r--src/Wallabag/ImportBundle/Controller/ImportController.php36
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig16
2 files changed, 36 insertions, 16 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php
index ea4f7d7b..36a2a399 100644
--- a/src/Wallabag/ImportBundle/Controller/ImportController.php
+++ b/src/Wallabag/ImportBundle/Controller/ImportController.php
@@ -25,33 +25,41 @@ class ImportController extends Controller
25 { 25 {
26 $nbRedisMessages = null; 26 $nbRedisMessages = null;
27 $nbRabbitMessages = null; 27 $nbRabbitMessages = null;
28 $redisNotInstalled = false;
29 $rabbitNotInstalled = false;
28 30
29 if (!$this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) { 31 if (!$this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
30 return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [ 32 return $this->render('WallabagImportBundle:Import:check_queue.html.twig');
31 'nbRedisMessages' => $nbRedisMessages,
32 'nbRabbitMessages' => $nbRabbitMessages,
33 ]);
34 } 33 }
35 34
36 if ($this->get('craue_config')->get('import_with_rabbitmq')) { 35 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
37 $nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket') 36 // in case rabbit is activated but not installed
38 + $this->getTotalMessageInRabbitQueue('readability') 37 try {
39 + $this->getTotalMessageInRabbitQueue('wallabag_v1') 38 $nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket')
40 + $this->getTotalMessageInRabbitQueue('wallabag_v2') 39 + $this->getTotalMessageInRabbitQueue('readability')
41 ; 40 + $this->getTotalMessageInRabbitQueue('wallabag_v1')
41 + $this->getTotalMessageInRabbitQueue('wallabag_v2');
42 } catch (\Exception $e) {
43 $rabbitNotInstalled = true;
44 }
42 } elseif ($this->get('craue_config')->get('import_with_redis')) { 45 } elseif ($this->get('craue_config')->get('import_with_redis')) {
43 $redis = $this->get('wallabag_core.redis.client'); 46 $redis = $this->get('wallabag_core.redis.client');
44 47
45 $nbRedisMessages = $redis->llen('wallabag.import.pocket') 48 try {
46 + $redis->llen('wallabag.import.readability') 49 $nbRedisMessages = $redis->llen('wallabag.import.pocket')
47 + $redis->llen('wallabag.import.wallabag_v1') 50 + $redis->llen('wallabag.import.readability')
48 + $redis->llen('wallabag.import.wallabag_v2') 51 + $redis->llen('wallabag.import.wallabag_v1')
49 ; 52 + $redis->llen('wallabag.import.wallabag_v2');
53 } catch (\Exception $e) {
54 $redisNotInstalled = true;
55 }
50 } 56 }
51 57
52 return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [ 58 return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [
53 'nbRedisMessages' => $nbRedisMessages, 59 'nbRedisMessages' => $nbRedisMessages,
54 'nbRabbitMessages' => $nbRabbitMessages, 60 'nbRabbitMessages' => $nbRabbitMessages,
61 'redisNotInstalled' => $redisNotInstalled,
62 'rabbitNotInstalled' => $rabbitNotInstalled,
55 ]); 63 ]);
56 } 64 }
57 65
diff --git a/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig b/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig
index 7168ea35..a2633698 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig
@@ -1,11 +1,23 @@
1{% if nbRedisMessages > 0 %} 1{% if nbRedisMessages is defined and nbRedisMessages > 0 %}
2 <script> 2 <script>
3 Materialize.toast('Messages in queue: {{ nbRedisMessages }}', 4000); 3 Materialize.toast('Messages in queue: {{ nbRedisMessages }}', 4000);
4 </script> 4 </script>
5{% endif %} 5{% endif %}
6 6
7{% if nbRabbitMessages > 0 %} 7{% if nbRabbitMessages is defined and nbRabbitMessages > 0 %}
8 <script> 8 <script>
9 Materialize.toast('Messages in queue: {{ nbRabbitMessages }}', 4000); 9 Materialize.toast('Messages in queue: {{ nbRabbitMessages }}', 4000);
10 </script> 10 </script>
11{% endif %} 11{% endif %}
12
13{% if redisNotInstalled is defined and redisNotInstalled %}
14 <div class="card-panel red darken-1 white-text">
15 {{ 'flashes.import.error.redis_enabled_not_installed'|trans|raw }}
16 </div>
17{% endif %}
18
19{% if rabbitNotInstalled is defined and rabbitNotInstalled %}
20 <div class="card-panel red darken-1 white-text">
21 {{ 'flashes.import.error.rabbit_enabled_not_installed'|trans|raw }}
22 </div>
23{% endif %}