]> git.ardis.lu - sheets-db/commitdiff
Use a sidebar instead of a modal
authorArdis Lu <ardisglu@gmail.com>
Sun, 28 Nov 2021 04:36:51 +0000 (20:36 -0800)
committerArdis Lu <ardisglu@gmail.com>
Sun, 28 Nov 2021 04:36:51 +0000 (20:36 -0800)
The sidebar persistence allows client-side caching, which improves speed for repeated loads.

Code.gs

diff --git a/Code.gs b/Code.gs
index 5ac807e6eb11864b36d045e9f75897c355e840e7..bd6b977ba598f4b735b58eed375ba4619e1de1e4 100644 (file)
--- a/Code.gs
+++ b/Code.gs
@@ -9,7 +9,7 @@ const BACKBLAZE_KEY = PROPERTIES.getProperty('BACKBLAZE_KEY');
 function onOpen() {
   UI.createMenu('🔥 SQLite')
     .addItem('❓ Help', 'showHelp')
-    .addItem('Download SQLite database', 'showDatabaseDownloadDialog')
+    .addItem('🟢 Open sidebar', 'openSidebar')
     .addItem('Upload to Backblaze', 'uploadToBackblaze')
     .addToUi();
 }
@@ -19,7 +19,7 @@ function showHelp() {
 
 USAGE:
 - Edit the data on this workbook like you would on any other Google Sheet, noting KEY ASSUMPTIONS below.
-- When ready, press the "Download SQLite database" button to generate and download a SQLite database from the workbook's data!
+- When ready, press the "Open sidebar" button to generate a SQLite database from the data on this workbook!
 
 KEY ASSUMPTIONS: 
 - Each tab in this workbook is a data table
@@ -32,6 +32,11 @@ KEY ASSUMPTIONS:
   UI.alert('Help', helpMessage, UI.ButtonSet.OK);
 }
 
+function openSidebar() {
+  const html = HtmlService.createHtmlOutputFromFile('query-to-db').setTitle('🔥 SQLite');
+  UI.showSidebar(html);
+}
+
 // Helper function which will be called from the client-side dialog
 function generateDatabaseQuery() {
   const sheets = WORKBOOK.getSheets();
@@ -96,11 +101,6 @@ function generateDatabaseQuery() {
   return query;
 }
 
-function showDatabaseDownloadDialog() {
-  const html = HtmlService.createHtmlOutputFromFile('query-to-db');
-  UI.showModalDialog(html, 'Generating database...');
-}
-
 function uploadToBackblaze() {
   // b2_authorize_account
   const credentials = `Basic ${Utilities.base64Encode(`${BACKBLAZE_ID}:${BACKBLAZE_KEY}`)}`;
This page took 0.035564 seconds and 4 git commands to generate.