You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/11/24 01:56:31 UTC

[whimsy] branch master updated (c135935 -> 69e0755)

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

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


    from c135935  reapply offline changes on restart
     new 08903ca  apply offline updates
     new 69e0755  keep tabs in sync

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 www/board/agenda/views/actions/batch.json.rb | 44 ++++++++++++++++++++++++++++
 www/board/agenda/views/buttons/offline.js.rb | 44 ++++++++++++++++++++++++++--
 www/board/agenda/views/models/events.js.rb   |  7 +++++
 www/board/agenda/views/models/pending.js.rb  |  6 +++-
 4 files changed, 97 insertions(+), 4 deletions(-)
 create mode 100644 www/board/agenda/views/actions/batch.json.rb

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].

[whimsy] 02/02: keep tabs in sync

Posted by ru...@apache.org.
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

commit 69e07556c453212370c2b468f10ac774fb6da73a
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Nov 23 20:56:20 2017 -0500

    keep tabs in sync
---
 www/board/agenda/views/models/events.js.rb  | 7 +++++++
 www/board/agenda/views/models/pending.js.rb | 6 +++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/www/board/agenda/views/models/events.js.rb b/www/board/agenda/views/models/events.js.rb
index 946bfa1..f5dc73c 100644
--- a/www/board/agenda/views/models/events.js.rb
+++ b/www/board/agenda/views/models/events.js.rb
@@ -160,6 +160,13 @@ class Events
     self.log e
   end
 
+  # set message to all processes
+  def self.broadcast(event)
+    event = event.inspect
+    localStorage.setItem("#{@@prefix}-event", event)
+    self.dispatch event
+  end
+
   # dispatch logic (common to all tabs)
   def self.dispatch(data)
     message = JSON.parse(data)
diff --git a/www/board/agenda/views/models/pending.js.rb b/www/board/agenda/views/models/pending.js.rb
index 6fc0504..81388ad 100644
--- a/www/board/agenda/views/models/pending.js.rb
+++ b/www/board/agenda/views/models/pending.js.rb
@@ -228,7 +228,11 @@ class Pending
         end
 
         Pending.dbput pending
-        block(Server.pending) if block
+
+        if block 
+          block(Server.pending)
+          Events.broadcast type: 'pending', value: Server.pending
+        end
       end
     else
       post request, data do |pending|

-- 
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.

[whimsy] 01/02: apply offline updates

Posted by ru...@apache.org.
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

commit 08903ca01bcfc90dc70a0bb498bb81e134629101
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Nov 23 20:56:08 2017 -0500

    apply offline updates
---
 www/board/agenda/views/actions/batch.json.rb | 44 ++++++++++++++++++++++++++++
 www/board/agenda/views/buttons/offline.js.rb | 44 ++++++++++++++++++++++++++--
 2 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/www/board/agenda/views/actions/batch.json.rb b/www/board/agenda/views/actions/batch.json.rb
new file mode 100644
index 0000000..3654c2a
--- /dev/null
+++ b/www/board/agenda/views/actions/batch.json.rb
@@ -0,0 +1,44 @@
+#
+# Batch apply offline updates
+
+Pending.update(env.user, @agenda) do |pending|
+  agenda = Agenda.parse @agenda, :full
+  @initials ||= pending['initials']
+
+  approved = pending['approved']
+  unapproved = pending['unapproved']
+  flagged = pending['flagged']
+  unflagged = pending['unflagged']
+
+  if @pending['approve']
+    @pending['approve'].each do |attach, request|
+      if request == 'approve'
+        unapproved.delete attach
+        approved << attach unless approved.include? attach or
+          agenda.find {|item| item[:attach] == attach and
+            item['approved'].include? @initials}
+      else
+        approved.delete attach
+        unapproved << attach unless unapproved.include? attach or
+          not agenda.find {|item| item[:attach] == attach and
+            item['approved'].include? @initials}
+      end
+    end
+  end
+
+  if @pending['flag']
+    @pending['flag'].each do |attach, request|
+      if request == 'flag'
+	unflagged.delete attach
+	flagged << attach unless flagged.include? attach or
+	  agenda.find {|item| item[:attach] == attach and
+	    Array(item['flagged_by']).include? @initials}
+      else
+	flagged.delete attach
+	unflagged << attach unless unflagged.include? attach or
+	  not agenda.find {|item| item[:attach] == attach and
+	    Array(item['flagged_by']).include? @initials}
+      end
+    end
+  end
+end
diff --git a/www/board/agenda/views/buttons/offline.js.rb b/www/board/agenda/views/buttons/offline.js.rb
index 0433d5c..e6415ca 100644
--- a/www/board/agenda/views/buttons/offline.js.rb
+++ b/www/board/agenda/views/buttons/offline.js.rb
@@ -2,15 +2,53 @@
 # A button that will toggle offline status
 #
 class Offline < Vue
+  def initialize
+    @disabled = false
+  end
+
   def render
     if Server.offline
-      _button.btn.btn_primary 'go online', onClick: click
+      _button.btn.btn_primary 'go online', onClick: click, disabled: @disabled
     else
-      _button.btn.btn_primary 'go offline', onClick: click
+      _button.btn.btn_primary 'go offline', onClick: click, disabled: @disabled
     end
   end
 
   def click(event)
-    Pending.setOffline(!Server.offline)
+    if Server.offline
+      @disabled = true
+
+      Pending.dbget do |pending|
+	# construct arguments to fetch
+	args = {
+	  method: 'post',
+	  credentials: 'include',
+	  headers: {'Content-Type' => 'application/json'},
+	  body: {agenda: Agenda.file, pending: pending}.inspect
+	}
+
+        fetch('../json/batch', args).then {|response|
+          if response.ok
+            Pending.dbput({})
+            response.json().then do |pending| 
+              Server.pending = pending
+            end
+            Pending.setOffline(false)
+          else
+            response.text().then do |text| 
+              alert("Server error: #{response.status}")
+              console.log text
+            end
+          end
+
+          @disabled = false
+        }.catch {|error|
+          alert(error)
+          @disabled = false
+        }
+      end
+    else
+      Pending.setOffline(true)
+    end
   end
 end

-- 
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.