From 58f802e11016d74f885c613a530cedd131431747 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 27 Nov 2021 20:36:51 -0800 Subject: [PATCH] Use a sidebar instead of a modal The sidebar persistence allows client-side caching, which improves speed for repeated loads. --- Code.gs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Code.gs b/Code.gs index 5ac807e..bd6b977 100644 --- 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}`)}`; -- 2.47.3