This project creates a Google Sheets add-on that interfaces with Decisions for Heroes (D4H) to create a call list with basic contact information. There are some additional features that are specific to the San Mateo County Search and Rescue (SMCSAR) callout process.
- Add the DO Management add-on to your account
- Create a new Google Sheet
- Go to "Add-ons" -> "DO Management" -> "Populate Call Sheet"
This project uses the workflow outlined here, using our fork of the node-google-apps-script project.
Specific steps are outlined below.
- Make sure you have node.js installed (at least v0.12.x) - https://nodejs.org/en/download/
git clone https://github.com/smcsar/node-google-apps-script.git
cd
into the above project and runnpm install -g
- Test gapps installation by running
gapps -V
(you should see a version number 1.0.0)
- Click "New" -> "More" -> "Connect more apps" and search for "Apps Script"
- Add "Google Apps Script"
You only need to do this the first time you setup your Developers Console Project. This will create a file in your home directory that allows you to push files to a Google Developers Console Project.
- Click this link to create a new Google Developers Console Project
- Select
Create a new project
and click "Continue" - Click "Go to credentials"
- Click "Add credentials"
- Select "OAuth 2.0 client ID"
- Click "Configure consent screen"
- Fill in product name (e.g. "SMCSAR DO Addon") and click "Save"
- Select "Other" for Application type and fill in "Name" (e.g. )
- Click "OK"
- Click on the download icon for your newly created credentials and remember where you downloaded it. This will download a JSON file
- You may close the Google Developers Console window
- Go to your command-line window
- Run `gapps auth
- Follow the directions generated by the above command - you should see a URL that you can copy/paste into a web browser
- Click "Allow" to give your project appropriate permissions
- You may now delete the JSON credentials file
- Clone the fork/repository
- Using SSH (Mac/Linux):
git clone [email protected]:<username>/duty-officer-addon.git
- Using HTTPS (Windows/Mac/Linux):
git clone https://github.com/<username>/duty-officer-addon.git
- Using SSH (Mac/Linux):
cd
into the above project- Run
gapps init -s src
to initialize the DO project - Open http://console.developers.google.com in a new tab and select your Developers Console Project that you previously created
- Copy the
Project Number
- Open a web browser and goto https://drive.google.com
- Click "New" -> "More" -> "Google Apps Script" to create a new Apps Script project
- Select "Blank Project"
- Go to "Resources" -> "Developers Console Project"
- Name your project (e.g. "DO Manager") and click "OK"
- Under "Change Project", paste the Developers Console project number and click "Set Project"
- Follow instructions for confirming project change
- You should see "Success! Project Changed" next to the project name
- Click "Close"
- Copy your Project ID from the address bar - your project id is the random string after
/d/
and before/edit
- Go to your command-line window and run
gapps add dev <project id>
. This will add a deployment target called "dev" - Run
gapps deploy dev
to push files to Google's environment - If you don't see "Great success!", go to a corner and cry
- Go back to your web browser with your Google Drive project and refresh - you should see
code.gs
and several other HTML files
If you have already followed this readme but would like to start work in a new directory or on a new fork, please follow these steps:
- Clone the fork/repository
- Using SSH (Mac/Linux):
git clone [email protected]:<your username>/duty-officer-addon.git
- Using HTTPS (Windows/Mac/Linux):
git clone https://github.com/<your username>/duty-officer-addon.git
- Using SSH (Mac/Linux):
cd
into the above project- Run
gapps init -s src
to initialize the DO project - Open a web browser and goto https://drive.google.com
- Select your Apps Script project that you previously created (blue icon with white arrow)
- Copy your Project ID from the address bar - your project id is the random string after
/d/
and before/edit
- Go to your command-line window and run
gapps add dev <project id>
. This will add a deployment target called "dev" - Run
gapps deploy dev
to push files to Google's environment - If you don't see "Great success!", go to a corner and cry
- Go back to your web browser with your Google Drive project and refresh - you should see
code.gs
and several other HTML files
All code modifications should be done locally on your computer and not in the Google Drive web interface
- Comment out the
setupCheckResponseTrigger()
. This will disable the auto-highlighting related to those responding but will allow you to test your code without needing to deploy it - Run
gapps deploy dev
to push your code to Google's servers - Switch to the project within Google Chrome and continue testing from there:
- Create a new spreadsheet in Google Drive and rename it to something you can find
- Go to your Apps Script project and select "Publish" -> "Test as Add-on"
- Under "Configure New Test", click "Select Doc"
- Click "Spreadsheets" and select the sheet you created earlier and click "Select"
- Click "Save"
- Select your "Saved Test" (radio button) and click "Test"
- Go to "Add-ons" -> <Project Name> -> "Set D4H Token" (If this is the first time you're running the add-on, you will need to authorize the add-on.)
- In a new tab, go to https://smcsar.d4h.org and click on the setup gear at the top right corner
- Click "Generate API Access Key"
- Copy "Generated Token"
- Go back to your project and paste the API token and click "Save"
- To test, go to "Add-ons" -> -> "Populate Call Sheet"
- Open your project in Google Drive via a web browser
- Go to "Publish" -> "Test as Add-on" and select your previously saved test and click "Test"
- The sheet you previously created and associated with the test should automatically open
- Modify code in editor of choice (locally on your workstation)
gapps deploy dev
to sync code - DON'T FORGET THIS STEP AFTER EVERY CHANGE! (You may consider setting up something that watches the files and executes this command every time there is a change.)- Go to the spreadsheet associated with your project and refresh (you only need to refresh the sheet itself and not the Apps Script project)
- Javascript files use the .js extension in order to enable proper file
handling by editors/IDE's. This will be automatically changed to .gs when
gapps deploy
is called - While files may be organized in directories within this project, Google Apps Script will flatten out the directory structure on the server. As a result, you must ensure that all filenames are unique throughout the entire project - even if they are in different directories!
- Don't ever make changes within the web-based Apps Script IDE; otherwise, the version on the server and in this project will conflict
Detailed instructions TBD
- Increment version number when deploying the add-on (via web interface)
If you'd like to contribute, please reach out! We're happy to review pull requests.
Copyright 2015, Andrew Nguyen
Distributed under the GNU Affero General Public License Version 3.