- Have an existing Firebase/Google account
- Have a Firebase project set up
- Have Firebase CLI installed on your workstation
- Have the code on your workstation (this is the downloaded zip)
- Have access to a unix based terminal on your workstation
- Have NPM and NodeJS (nvm recommended) installed on your workstation
- Open this project in VS Code and open the terminal inside VS Code (or open your terminal and
cd
to the project root directory) firebase login
firebase use --add
- When prompted for which project you want to add, select the project you created in the prequisite step
- Write your alias (can be anything like e.g. satcap-prod)
- You are now using your own Firebase project
To switch projects run the following, changing ALIAS to a defined alias
firebase use ALIAS
Please note, if you're on a project that your Google account does not have access to, you won't be able to deploy.
- Login to Firebase console
- Open your project
- Click on Build -> Firestore Database
- Click "Create Database"
- Follow the prompts
- Login to Firebase console
- Open your project
- Click on Build -> Storage
- Follow the prompts
- Login to Firebase console
- Open your project
- Click on Build -> Authentication
- Go to the "Sign-in method" tab
- Click "Add new provider"
- Turn on "Email/Password"
ADMIN_SITE_ID and USER_SITE_ID has to be replaced with a value of your choosing.
riis-satcap-admin riis-satcap-user
This would however need to be unique across the entire Firebase platform so if you use a value that already exists, you will get an error similar to the below:
Error: HTTP Error: 400, Invalid name: `admin-satcap-research` is reserved by another project; try something like `admin-satcap-research-51aa9` instead
firebase hosting:sites:create ADMIN_SITE_ID
firebase hosting:sites:create USER_SITE_ID
firebase target:apply hosting admin ADMIN_SITE_ID
firebase target:apply hosting user USER_SITE_ID
You will need to update the firebase configurations for each app (user & admin) respectively.
cd admin/src/
- Open firebase.ts in your favourite editor
- Replace the
config
object with your app's Firebase project configuration
cd user/public/_scripts
- Open init.js in your favourite editor
- Replace the
firebaseConfig
object with your app's Firebase project configuration
cd admin/
- Open .env in your favourite editor
- Set VITE_USER_URL=https://USER_SITE_ID.web.app
PLEASE NOTE: Blaze (Pay As You Go) billing option is required to use cloud functions
cd functions/
npm i
- Open .env in your favourite editor
- Set ADMIN_URL=https://ADMIN_SITE_ID.web.app
- Set USER_URL=https://USER_SITE_ID.web.app
Because of the admin website requiring a build before deployment, it is not adivsed to run the global firebase deploy
command as this will cause unforeseen problems.
firebase deploy --only firestore:indexes
firebase deploy --only firestore:rules
firebase deploy --only storage
cd admin/
npm i && npm run build
cd ../
firebase deploy --only hosting:admin
firebase deploy --only hosting:user
You can read here for more details about Firebase Functions and deployments
Before deploying all functions, we need to have an existing mine in the Firestore Database so that the relevant trigger functions on the mines
collection will deploy successfully.
firebase deploy --only functions:addMine
Please see Initial data import/Add Mine for how to execute this function before running the below:
firebase deploy --only functions
To start using the application, you can easily add mines and import packages using cloud functions before accessing the application on the web.
The current version of the application does not support the creation of mines or packages within the application itself.
To create your mine without adding it manually on Firebase console you can run the addMine
cloud function deployed in the previous step.
Please change the following:
- {LOCATION} = The location in which the project was deployed e.g. us-central1
- PROJECT_ID} = The ID of the Firebase Project e.g. satcap-research
- {NAME} = The name of the mine you're wanting to create
https://{LOCATION}-{PROJECT_ID}.cloudfunctions.net/addMine?name={NAME}
Please see the data architecture to understand what can be edited/added to the mine information
In order for the mine to create survey links, the packages collection needs to have the predefined data in it.
To acheive this, you can run the importPackages
cloud function deployed in the previous step.
Please change the following:
- {LOCATION} = The location in which the project was deployed e.g. us-central1
- {PROJECT_ID} = The ID of the Firebase Project e.g. satcap-research
https://{LOCATION}-{PROJECT_ID}.cloudfunctions.net/importPackages
To use the default questions provided per package, you will need to run the importQuestions
cloud function.
You can view and add questions to each package by going to the "Tool Editor" tab within the admin application.
https://{LOCATION}-{PROJECT_ID}.cloudfunctions.net/importQuestions
Initially, you will have to manually add a person to the "backend" to get started.
All subsequent users can be added the traditional way on the "People" tab within the admin application.
Please see Data Architecture for more information before proceeding to the below steps
- Login to Firebase console
- Open your project
- Click on Build -> Authentication
- Under the "Users" tab, click "Add user"
- Enter details and "Add User"
- Copy UID generated
- Click on Build -> Firestore Database
- Click on "mines" collection
- Click on the mine you're wanting to add the person to
- Click on the Sub-collection "users" (If not there, create it by clicking "Start collection" within the mine document and skip step 11)
- Click "Add document"
- Click "Auto-Id" and add the following fields
It is advised to protect yourself as best you can by following the Firebase's security checklist.
We have basic secure rules set up for storage and firestore but you can improve on this by limiting the type of collections allowed if you so desire. You can update the firestore.rules
and storage.rules
accordingly.
You will need to enable the following extensions within Firebase:
- Link to extension
- Setup with your own SMTP account
- Use mail as the collection name
- Link to extension
- Setup with your own Twilio account
- Use messages as the collection name
Collection Id: packages
Field | Type | Value |
---|---|---|
docId | string | Redundant copy of actual doc UID |
name | string | Name of work package |
survey | map | Survey information this package links to |
survey.complete | map | Custom messages on completion of a survey |
survey.complete[surveyKey].message | string | Custom message |
survey.complete[surveyKey].type | string | Custom heading |
survey.shortDescription | string | Summary description of survey |
survey.description | string | Full description of survey |
survey.key | string | Unique key of survey or parent key of surveys |
survey.title | string | Title of survey or parent title of surveys |
survey.surveys | array[map] | (Optional) list of surveys if package provides more than one |
survey.surveys[0].color | string | HEX value of theme colour for survey |
survey.surveys[0].description | string | Description of survey |
survey.surveys[0].faqUrl | string | URL link to FAQ's for survey |
survey.surveys[0].key | string | Unique key of survey |
survey.surveys[0].title | string | Title of survey |
scopes | array[string] | List of all menu items this package has access to on the user side |
Scope |
---|
home |
survey |
information |
queries |
Collection Id: mines
Field | Type | Value |
---|---|---|
address | string | Area of mine |
name | string | Name of mine |
description | string | Description of mine |
featureImageUrl | string | URL link to header image |
imageUrl | string | URL link to logo of mine |
packages | array[string] | Document ID's of all packages this admin has access to |
Sub-collection of mines
Collection Id: users
Field | Type | Value |
---|---|---|
authUid | string | Value of UID according to authentication user |
name | string | Name of user |
mobile | string | Mobile number of user |
string | Email of user (must be contactable - not required to be same as authentication email) | |
isAdmin | boolean | true if can manage mine (operations / about etc.) and add people to mine |
jobTitle | string | Job title of user |
mineId | string | Document ID of current mine |
locationAdmin | array[string] | Document ID's of all locations (operations) this user can manage (is allowed to be null if isAdmin is true) |
Sub-collection of mines
Collection Id: locations
Field | Type | Value |
---|---|---|
name | string | Name of location |