From: Ardis Lu Date: Mon, 29 Nov 2021 04:19:03 +0000 (-0800) Subject: Hide upload button unless properties are set X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=c02a674e1a418302469f2fe5519a72a51b7bd72a;p=sheets-db Hide upload button unless properties are set --- diff --git a/Code.gs b/Code.gs index b973178..6bc029e 100644 --- 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 diff --git a/query-to-db.html b/query-to-db.html index bd4e7d3..4a35c69 100644 --- a/query-to-db.html +++ b/query-to-db.html @@ -47,7 +47,7 @@

- +

@@ -94,6 +94,13 @@ 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');