Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/summitcollie/ncas-equipment
Asset management platform for NCAS
https://github.com/summitcollie/ncas-equipment
Last synced: 8 days ago
JSON representation
Asset management platform for NCAS
- Host: GitHub
- URL: https://github.com/summitcollie/ncas-equipment
- Owner: SummitCollie
- License: other
- Created: 2021-01-02T18:08:18.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-22T00:55:00.000Z (over 2 years ago)
- Last Synced: 2025-01-09T11:12:11.209Z (16 days ago)
- Language: Ruby
- Size: 1.46 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# NCAS Equipment
## How to run locally
1. Follow the below instructions to set up Postgres, rails credentials, Google auth, etc.
2. Run the server with `rails s`
3. Optionally, run `yarn start` in another process to start the webpack dev server.
Enables hot-reloading, much faster builds, etc. for front-end code.## Database creation
Uses postgres 12.6 locally and in production.
### Local DB
Locally, set postgres to listen on port 5432 and put credentials for a
superuser in rails credentials:`EDITOR=nano rails credentials:edit`
```yml
postgres:
username: username_here
password: password_here
```## Production DB
Just attach a postgres database on Heroku, the app will automatically use
Heroku's `DATABASE_URL` env var to connect rather than the stuff in rails
credentials.## Database initialization
Run `rails db:setup` once to set up tables. Adds test data on local.
Local test data can be seeded by running `rails db:seed`.
Running `rails db:seed` on prod will just add a default admin account, as
specified in your rails credentials.Default seeded users in development are:
| username | password | admin? |
|---------------|:--------:|:------:|
|[email protected]| 123456 | ✔️ |
|[email protected]| 123456 | |(although now that Google auth is implemented, password auth is disabled so
there's no login page where you can enter these passwords.)## Environment Variables
Only env var of note that doesn't go in application.yml or rails credentials is
`BASE_URL`, which sets the base URL on production. It should be declared in
Heroku (or other host) config:```
BASE_URL=ncas.equipment
```### config/application.yml
Copy contents of `config/application.yml.EXAMPLE` into `config/application.yml`
and customize as-needed.### Rails credentials
`EDITOR=nano rails credentials:edit`
```yml
# Default admin (google account) account to add on prod if
# you run `rails db:seed` on your Heroku app
prod_default_admin: [email protected]# Only used for local dev, app automatically overrides with
# Heroku DATABASE_URL in prod
postgres:
username: username_here
password: password_here# Used in both dev and prod for google oauth
google_oauth2:
client_id: long_string_here
client_secret: long_string_2_here# Used to control telegram bot for sending magic links, etc.
telegram:
bot_name: NCAS_Equipment_Bot # without the @
bot_token: paste_bot_token_here# Used as the base secret for all MessageVerifiers in Rails,
# including the one protecting cookies.
secret_key_base: long_secure_string_here
```Make sure you set the environment var `RAILS_MASTER_KEY` on Heroku with
the value of whatever's in config/master.key so the app can decrypt the stuff
in Rails credentials.## Google Authentication
Make a project in the
[Google API Console](https://console.developers.google.com/apis/), hit
"Credentials" on the left, set up the Consent Screen, and then put your
CLIENT_ID and CLIENT_SECRET in rails credentials:`EDITOR=nano rails credentials:edit`
```yml
google_oauth2:
client_id: long_string_here
client_secret: long_string_2_here
```In the google console, also set up your Authorized Redirect URIs for both local
and any hosted environments. Examples:Authorized Redirect URIs:
```
http://localhost:3000/users/auth/google_oauth2/callback
https://ncas.equipment/users/auth/google_oauth2/callback
https://ncas-equipment.herokuapp.com/users/auth/google_oauth2/callback
```## Example barcodes
![Example Barcodes](./example-barcodes.png)