TheCacophonyProject / cacophony-web

API server where Cacophony Project recordings are stored & managed + the web interface where recordings can be viewed, tagged, and analysed.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cacophony-web

This is a mono-repo pulling together three older repositories: cacophony-api, cacophony-browse, and integration-tests

cacophony-api

cacophony-api is a node server that is accessed through a RESTful API. This allows uploading, processing and retrieving media collected for The Cacophony Project.

Project cacophony-web Status
Platform Linux
Requires
Previous names Full Noise
Licence Affero General Public License

Instructions

Download and install the latest release from Github.

Development instructions

For development and testing purposes it is easiest to run cacophony-api using Docker. To do this:

  • Ensure your user account is set up to run commands as root using sudo.
  • Ensure the Docker is installed (sudo apt install docker.io and docker-compose (https://docs.docker.com/compose/install/) on Ubuntu)
  • Run either npm run dev (if npm is installed) or docker-compose build && docker-compose up --force-recreate.

This will build and then run a Docker container which includes all the services needed to run the server.

Once the container is running, you can start a bash session inside the container with npm run dev:bash or docker-compose exec server bash.

To start psql to query the database in base use the alias psqltest

Running the cypress tests

See Cypress Tests for details on running the cypress tests.

API Documentation

API documentation can be generated by running npm run apidoc. The resulting documentation ends up in the apidoc directory.

The API server also serves up the generated API documentation at it's root URL.

Database Migrations

These are run automatically when you start the server.

To create a new database migration file: npm run new-migration <name>

Docker base image

To make the project build fast on our build servers (and your computer) we use a base docker image that contains nodejs, postgis, minio and most of our js dependencies. The code for building this server is in the folder docker-base

Releases

Releases are created using travis and git and saved on Github. Follow our release instructions to create a new release.

cacophony-browse

This is a web interface for querying with and interacting with Cacophony Project recordings using the project's API. It is based on the Vue framework and uses Vuex for state management.

Build Setup

# enter browse package
cd browse

# install dependencies
npm install

# create config file
cp dev-config.js.TEMPLATE dev-config.js
# now edit the config file to point to correct API server

# serve with hot reload at localhost:8080
npm run dev

# build for staging & production with minification
npm run release

For detailed explanation on how things work, consult the docs for vue-loader.

Development

Please follow the Vue style guide for all development: https://vuejs.org/v2/style-guide/#ad

The project is configured to use eslint and prettier. Please ensure your development setup included a recent version of prettier. Pull requests will be checked to ensure there are no code formatting or eslint issues.

To run eslint:

npm run lint

To run eslint and automatically fix issues:

npm run lint:fix

Releases

  • Ensure all changes have been merged and are pulled into the local copy.
  • Tag the release (starting with a "v"), e.g.: git tag -a v1.2.3 -m "1.2.3 release"
  • Push the tag to Github, e.g.: git push origin v1.2.3
  • TravisCI will run the tests, create a release package and create a Github Release

Web Server Configuration

The /srv/cacophony/cacophony-browse directory in the release package should be served by a web server.

Sample configuration for the Caddy web server:

# Update the host and port to match desired
http://localhost:9000 {
    gzip
    root  /srv/cacophony/cacophony-browse

    rewrite {
        ext !.jpg !.png !.svg !.js
        to /index-prod.html  # or index-staging.html
    }
}

Sample config for Nginx:

server {
    root /srv/cacophony/cacophony-browse;
    index index-prod.html;


    server_name browse.cacophony.org.nz;

    location / {
            try_files $uri $uri/ /index-prod.html;
    }
}

Note: you may also need to add a correct mime-type for WebAssembly (*.wasm)

About

API server where Cacophony Project recordings are stored & managed + the web interface where recordings can be viewed, tagged, and analysed.

License:GNU Affero General Public License v3.0


Languages

Language:JavaScript 39.1%Language:TypeScript 37.6%Language:Vue 22.5%Language:HTML 0.6%Language:Shell 0.1%Language:PLpgSQL 0.0%Language:SCSS 0.0%Language:CSS 0.0%Language:Dockerfile 0.0%Language:EJS 0.0%Language:Less 0.0%