whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Only parse PDF on demand
Date Thu, 28 Nov 2019 15:29:10 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb 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 d7463a9  Only parse PDF on demand
d7463a9 is described below

commit d7463a9bd9f30806fa0860d1de06ec2767bd72db
Author: Sebb <sebb@apache.org>
AuthorDate: Thu Nov 28 15:28:54 2019 +0000

    Only parse PDF on demand
---
 www/secretary/workbench/views/forms/icla.js.rb | 32 ++++++++++++++++++--------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/www/secretary/workbench/views/forms/icla.js.rb b/www/secretary/workbench/views/forms/icla.js.rb
index 1aa4b8a..a8a232f 100644
--- a/www/secretary/workbench/views/forms/icla.js.rb
+++ b/www/secretary/workbench/views/forms/icla.js.rb
@@ -3,6 +3,8 @@ class ICLA < Vue
     @filed = false
     @checked = nil
     @submitted = false
+    @pdfdata = nil # not yet parsed file
+    @pdfdisabled = false # true if parse fails
   end
 
   def render
@@ -11,8 +13,10 @@ class ICLA < Vue
     _div.buttons do
       _button 'clear form', disabled: @filed,
         onClick: lambda {@pubname = @realname = @email = @filename = ''}
-      _button 'revert to mail data', disabled: @filed,
+      _button 'Use mail data', disabled: @filed,
         onClick: lambda {process_response({})}
+      _button (@pdfdata.nil? ? 'Parse/use PDF data' : @pdfdisabled ? 'No PDF data found'
: 'Use PDF data'), disabled: (@filed or @pdfdisabled),
+        onClick: lambda {getpdfdata()}
     end
 
     _form method: 'post', action: '../../tasklist/icla', target: 'content' do
@@ -107,18 +111,26 @@ class ICLA < Vue
     @project = parsed.Project
   end
 
+  def getpdfdata()
+    if @pdfdata # use existing data if present
+      process_response(@pdfdata)
+    else
+      data = {message: window.parent.location.pathname, attachment: @@selected}
+      HTTP.post('../../actions/parse-icla', data).then {|result|
+            @pdfdata = result.parsed
+            @pdfdisabled = @pdfdata.keys().length <= 1 # response contains dataSource
key
+            process_response(@pdfdata)
+          }.catch {|message|
+            alert message
+          }
+    end
+  end
+
   # on initial display, default various fields based on headers, and update
   # state 
   def mounted()
-    # Parse the ICLA if possible
-    data = {message: window.parent.location.pathname, attachment: @@selected}
-    HTTP.post('../../actions/parse-icla', data).then {|result|
-          process_response(result.parsed)
-        }.catch {|message|
-          process_response({})
-          alert message
-        }
-
+    @pdfdata = nil # Not yet parsed
+    process_response({}) # preset with message data
     # watch for status updates
     window.addEventListener 'message', self.status_update
   end


Mime
View raw message