fablabbcn / smartcitizen-web

The Smart Citizen Kit platform
https://smartcitizen.me
GNU Affero General Public License v3.0
13 stars 7 forks source link
angularjs sensors smartcitizen

SmartCitizen Web

Deploy to GH Maintainability Test Coverage DOI [PRs Welcome]()

The SmartCitizen front-end. Working together with SmartCitizen API.

Screenshot

Development

Using nvm (recommended but optional) do:

  1. Install the correct Node version:

nvm install

  1. Load the correct version:

nvm use

  1. Install dependencies

npm i

  1. Start development server

gulp serve

To be able to login from localhost:8080 with our real username:password connected to the SC API, we need to comment out the following lines in app.route.js:

/* Allow cookies across *.smartcitizen.me Apps */
$cookiesProvider.defaults.path = '/';
$cookiesProvider.defaults.domain = '.smartcitizen.me';

(We are looking for a better solution).

Prerequisites

You need git to clone the repository. You can get git from http://git-scm.com/.

We also use a number of node.js tools to initialize and test the Web App. You must have node.js and its package manager (npm) installed. You can get them from http://nodejs.org/.

Also gulp: npm install -g gulp (with sudo if you are using Mac).

Clone the project

Clone the repository using:

git clone https://github.com/fablabbcn/smartcitizen-web.git
cd smartcitizen-web

Install dependencies

Docker quickstart (optional)

If you want to use Docker in development mode, you should enable the volume: in docker-compose.yml so you won't need to rebuild after every file change. The image needs you to do npm install locally before running the container. It needs the node_modules/ to exist.

docker-compose up

Use Gulp tasks

Note: in case you see something like:

Error: Command failed: fatal: unable to read c6a8d370f3e95d9110eca4a03b704bd8940ca40b

Run: rm -Rf $(node -e "console.log(require('path').join(require('os').tmpdir(), 'tmpRepo'))")

Talking to a different API

In app.route.js the app can be configured to talk to another API: RestangularProvider.setBaseUrl('http://localhost:3000/v0');

Directory structure

Best Practice Recommendations for Angular App Structure

Git Commit Guidelines

Visit https://github.com/ajoslin/conventional-changelog/blob/master/CONVENTIONS.md

Naming conventions for files

Same for all types of components:

..js Ex: kit.controller.js, sensor.service.js, profileTools.constant.js ### Naming conventions for components Controller: Controller. Ex: MapController Service: . Ex: device, kit, user Constructor: . Ex: User, Kit. Note: Constructors are actually made using services. Constants: . Ex: PROFILE_TOOLS For data that has been resolved from the router, I've normally appended 'Data' to the name. ## Deployment Master branch is auto deployed to https://smartcitizen.me/ which is on Github Pages ## Funding This work has received funding from the European Union's Horizon 2020 research and innovation program under the grant agreement [No. 689954](https://cordis.europa.eu/project/rcn/202639_en.html)