This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new dafacac  autoupdate cache page
dafacac is described below

commit dafacac3376eb485186f1f9cf9b801de754fe1fb
Author: Sam Ruby <[email protected]>
AuthorDate: Fri Dec 8 17:17:39 2017 -0500

    autoupdate cache page
---
 www/board/agenda/views/pages/cache.js.rb | 44 +++++++++++++++++---------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/www/board/agenda/views/pages/cache.js.rb 
b/www/board/agenda/views/pages/cache.js.rb
index 928357b..37f897b 100644
--- a/www/board/agenda/views/pages/cache.js.rb
+++ b/www/board/agenda/views/pages/cache.js.rb
@@ -66,8 +66,8 @@ class CacheStatus < Vue
 
   end
 
-  # update caches
-  def created()
+  # update information
+  def collect_data()
     if defined? caches
       caches.open('board/agenda').then do |cache|
         cache.matchAll().then do |responses|
@@ -82,36 +82,38 @@ class CacheStatus < Vue
       end
     end
   end
+
+  def mounted()
+    # initial observations
+    collect_data()
+
+    # update observations every 5 seconds
+    CacheStatus.timer = setInterval 5_000 do
+      collect_data()
+    end
+
+    # export method to allow update in response to button presses
+    CacheStatus.collect_data = self.collect_data
+  end
+
+  def beforeDestroy()
+    clearInterval CacheStatus.timer if CacheStatus.timer
+    CacheStatus.timer = nil
+  end
 end
 
 #
 # A button that clear the cache
 #
 class ClearCache < Vue
-  def initialize
-    @disabled = true
-  end
-
   def render
-    _button.btn.btn_primary 'Clear Cache', onClick: self.click,
-      disabled: @disabled
+    _button.btn.btn_primary 'Clear Cache', onClick: self.click
   end 
 
-  # enable button if there is anything in the cache
-  def created()
-    if defined? caches
-      caches.open('board/agenda').then do |cache|
-        cache.matchAll().then do |responses|
-          @disabled = responses.empty?
-        end
-      end
-    end
-  end
-
   def click(event)
     if defined? caches
       caches.delete('board/agenda').then do |status|
-        Main.refresh()
+        CacheStatus.collect_data()
       end
     end
   end
@@ -133,7 +135,7 @@ class UnregisterWorker < Vue
         registrations.each do |registration|
           if registration.scope == base
             registration.unregister().then do |status|
-              Main.refresh()
+              CacheStatus.collect_data()
             end
           end
         end

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to