]> git.ardis.lu - sheets-db/commitdiff
Hide upload button unless properties are set
authorArdis Lu <ardisglu@gmail.com>
Mon, 29 Nov 2021 04:19:03 +0000 (20:19 -0800)
committerArdis Lu <ardisglu@gmail.com>
Mon, 29 Nov 2021 04:19:03 +0000 (20:19 -0800)
Code.gs
query-to-db.html

diff --git a/Code.gs b/Code.gs
index b973178eb4e3d51f876ab0a364aac3a191da8e77..6bc029ea110e40a83c251a5f0895a59e6fddd680 100644 (file)
--- a/Code.gs
+++ b/Code.gs
@@ -99,6 +99,14 @@ function generateDatabaseQuery() {
   return query;
 }
 
+// Helper function to determine if the upload button should be shown on the sidebar
+function backblazeCredentialsExist() {
+  return {
+    'BACKBLAZE_ID': BACKBLAZE_ID ? true : false,
+    'BACKBLAZE_KEY': BACKBLAZE_KEY ? true : false
+  }
+}
+
 // Helper function which will be called from the client-side dialog
 function uploadToBackblaze(byteArray) {
   // b2_authorize_account
index bd4e7d3553ca025a677a47cd102860153aa30533..4a35c69144616950e1dd633d8941e2988bc61b82 100644 (file)
@@ -47,7 +47,7 @@
   <p id="generate-notification"></p>
   <a id="download-link"></a>
 
-  <button id="upload-button" disabled>Upload .sqlite3 file to Backblaze</button>
+  <button id="upload-button" disabled style="display: none;">Upload .sqlite3 file to Backblaze</button>
   <span id="upload-spinner" class="inline-spinner"></span>
   <p id="upload-notification"></p>
 
 
     setState('initial');
 
+    // Only show the upload button if both GAS properties are set
+    google.script.run.withSuccessHandler(exists => {
+      if (exists.BACKBLAZE_ID && exists.BACKBLAZE_KEY) {
+        uploadButton.style.display = '';
+      }
+    }).backblazeCredentialsExist();
+
     // Call the server-side generateDatabaseQuery, then create the SQLite database
     generateButton.addEventListener('click', () => {
       setState('generatingDatabase');
This page took 0.039398 seconds and 4 git commands to generate.