Log battery sign-outs with the battery number, time signed out/in, and battery stats (rint and state of charge) before and after use, all with kiosk mode chromium running on xserver.
- mongoose
- node-cron
- google-apis
- dotenv
Note: These instructions are specifically for Ubuntu server 20.04.4LTS (64bit ARM64). For help on installing this operating system, please click here.
Warning: You MUST install the 64 bit version (ARM64 architecture) of Ubuntu server.
git clone https://github.com/Mikecerc/DigitalBatteryLog.git
An installer script is currently planned, however setup at this point is manual. The steps to installing all the software needed is as follows:
- Install all the node dependencies with the following command:
npm i
- follow the steps located here to install mongoDB version 4.4 for Ubuntu 20.04 LTS:
- Add the following to your
~/.bash_profile
(create one if it does not exist):
source ~/.profile
if [[ -z $DISPLAY ]] && [[ $(/dev/tty) = /dev/tty1 ]]; do
cd DigitalBatteryLog/
git pull
node . &
startx -- --nocursor
fi
- Add the following to your
~/.xinitrc
(create one if it does not exist):
chromium-browser --kiosk http://localhost:3000 --disable-infobars --start-maximized --window-position=0,0 --window-size=480,640
- Install Xorg and chromium with the following:
sudo apt-get install xserver-xorg x11-server-utils xinit
sudo apt-get install -y chromium-browser
- create a .env file in the repository folder with the following content:
syncInterval=[time in minutes that you want to scan db for updates]
sheetURL=[full url of the google sheet you are updating]
databaseAddress=mongodb://localhost:27017/batteryLogs
scopes=[\"https://www.googleapis.com/auth/spreadsheets\"]
Next, you must create an app via Google Cloud Platform in order to use the Google Sheets API. Follow the steps below to successfully setup the application, Oauth2 and Google Sheets API
-
Using internet explorer, navigate to the Google Cloud Platform
-
agree to the terms of service and continue onto the master dashboard.
-
Create a new Project by giving the project a name. Proceed by clicking create.
-
Return Back to the master dashboard of Google Cloud Platform
-
While on the dashboard, navigate to the
APIs & Services
tab and selectLibrary
.
-
Next we will have to create credentials. On the top of the page you are now at, you should see a button labeled
CREATE CREDENTIALS
. Click it.
-
You should now see a prompt labeled
Which API are you using?
Select User Data and then click next.
-
In the next section, name the app something you would recognize (Digital Battery Log) and enter the email address you are using in boxes labeled
User support email
andEmail addresses
. You do not need to submit an App logo. Clicksave and continue
when done. -
You should now be prompted with a section labeled
Scopes
. ClickAdd and Remove scopes
. Navigate to the last page of the scopes menu and find the scope:.../auth/spreadsheets
. Hit the check box next to it and scroll to the bottom of the page. click theupdate
button.
-
At the bottom of the scopes page, click
SAVE AND CONTINUE
. -
You should now see a tab labeled
OAuth Client ID
. Under theApplication type
dropdown, selectDesktop app
. Give the client a name you will remember. ClickCreate
.
-
The final tab should be labeled
Credentials
. Click the download button. Move the JSON file you downloaded into[REPOSITORY-FOLDER]/config/auth
and rename the file tocredentials.json
. -
Return to the
API & Services Tab
and navigate to theOAuth consent screen
tab.
-
Scroll down until you see the section labeled
Test Users
. Click theAdd Users
Button
WARNING: The email address you enter MUST have edit permissions on the Google Sheets you are editing.
-
You may now close your internet explorer browser.
-
In order to use the Google Sheets API, you need an access token. To generate an access token, run the following command in the main folder of the repository:
node run getToken