Git Product home page Git Product logo

riskmap-ng's Introduction

Build Status DOI Coverage Status

๐Ÿšซ DEPRECATED


Riskmap

UrbanRiskMap web app Angular project using Mapbox GL JS. UrbanRiskMap reports flooding in real-time

Development server

Machine setup

  1. Install NodeJS >= 4.x
  2. Install NPM 5.7.x
    • Even though you may have the latest NodeJS, that doesn't mean you have the latest version of NPM. You can check your version with npm -v. If you need to update, run npm install npm -g.
  3. Install Angular CLI
    • npm install -g @angular/cli

Application setup

  • Install the project dependencies
    • npm install

Start development server

Run npm start for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

For configuring dev server to serve a specific deployment, say PetaBencana.id (deployment key: id):

  1. Set dep=id in package.json > scripts.start
  2. Replace src/environments/environment.ts with src/environments/id/environment.ts

Deployments & Instances

Deployments are projects deployed in a macro-region / country with one or more supported instance regions (cities / counties). Each deployment shall be supported by a separate data server and data base, with map layers and content across instances of a deployment sharing the same properties and structure.

Currently supported deployments with their instances include:

  1. PetaBencana.id
    • Jakarta
    • Bandung
    • Surabaya
    • Semarang
  2. Riskmap.in
    • Chennai
  3. Riskmap.us
    • Broward

The app comprises of a common source code and a few shared assets across these deployments. However, majority of assets and resources are dependent on the deployment. These are picked from the deployments/ folder using the specified deployment key (id | in | us) and placed in the src/ folder before the build process. Ref. tasks/fetch-assets


Project structure

The project structure is as follows:

  • deployments: Deployment specific assets and resources are located here, in directories named with the deployment key.
  • src
    • app
    • assets
      • fonts: Webfont icons, app typography resources
      • icons [DS]: Browser tab icons (favicons), Phone app icons
      • images [DS]: Images, graphics used in app
      • locales [DS]: Locale files for supported languages
      • logos [DS]: Project author, partner's, supporter's logos
    • environments: Environment files are located here, in directories named with the deployment key. Use default angular naming convention, eg.:
      • dev: environment.ts
      • prod: environment.prod.ts
      • stage: environment.stage.ts
    • resources [DS]: Contains app, map content that changes with deployments, but remains the same across environments and instances.
    • styles: Contains global SASS (.scss) style sheets and Angular Material configurations.
    • index.html [DS]: App landing page. Each deployment requires a separate index file for configuring various <meta> tags.
  • tasks: Pre-build tasks are located here.
  • .angular-cli.json: Config file for angular project. When adding a new deployment, insert a directory map for the deployment's environment files here.

NOTE: Folders marked as Deployment Specific [DS] are generated ahead of build scripts. Changes made in the src/ folder will not be tracked and will be overwritten with content from files located in /deployments folder.


Steps to add a new deployment

  1. Choose a two-letter key for deployment, say xy
  2. Create a directory xy under src/environments/
  • Copy dev environment (environment.ts) from any existing deployment, and configure values
  • Open .angular-cli.json, add following keys to environments:
    • "dev-xy": "environments/xy/environment.ts"
  1. Create a directory xy under deployments/
  • Copy contents from any existing deployment, modify accordingly
    • assets/icons: Use this web service to generate web, app icons
    • assets/locales: Must contain a locale file for each language specified in environment > locales > supported languages. Refer to language codes here
    • assets/logos: Must contain app_logo.svg; rest as required
    • resources/info-content: Content for the 'Info' tab
    • resources/instances: Add instance regions along with bounding boxes, and instance codes as used in Back-end config
    • resources/layers: Add configuration values for all layers supported in the deployment. Refer Mapbox layer style specs here
    • resources/moment-locales: Export moment locale from node module for languages other than English
    • resources/report-content: Content for the 'How to report' tab
    • index.html: Modify <meta> tags as required
  1. Refer Development server > Start development server steps as listed above, to run app locally.
  2. Add build scripts in package.json:
  • Add "build-dev-xy" and "build-prod-xy" keys with respective scripts
  • Include "npm run build-dev-xy" in "build-dev" script
  1. Configure .travis.yml to deploy bundle from dist/dev-xy

Progressive Web App testing

Install Chrome lighthouse extension. Run npm run serve-prod-ngsw to locally serve an app over node http-server. Navigate to http://localhost:8080/broward, press lighthouse icon, then 'Generate report'.

Run npm run build to generate files for deployment.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

riskmap-ng's People

Contributors

abrahamq avatar angular-cli avatar asbarve avatar maz888 avatar ojha-url avatar tomasholderness avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

riskmap-ng's Issues

Add /?id=N to map URL

Current there is no easy way to share a report by ID outside of the share buttons.

E.g. I tried to share a report with the lab via email (or slack) and I can't. I have to click the twitter button and copy the link (n.b. I tried Facebook first but the report URL isn't human readable).

I would propose appending ?id= string to the URL each time a user clicks on a report.

https://riskmap.us/broward?report_id=102

Share reports IDs are in the wrong format

Clicking share report via Twitter generates the following URL to report:

https://riskmap.us/broward?report_id=102

As per the new version, this should be

https://riskmap.us/broward?id=102

Double counting 'Thumbs down'

To recreate:

make a new report
refresh, downvote that report in two different windows.
Report should now be at 2 downvotes, instead it is at -3.

Maybe a race condition somewhere?

Update README

update README.md

  • specify deployment parameters for building and deployment
  • project structure (remove references to cards)
  • add deployment specific directory information
  • update how environments are described in configuration
  • remove local environment from configuration
  • add deployments configuration instructions
  • update details of build scripts
  • add a license details

Fix linting errors and add linting to build process?


> [email protected] lint /home/abrahamq/riskmap-ng
> ng lint


ERROR: /home/abrahamq/riskmap-ng/src/app/services/http.service.ts[86, 25]: comment must start with a space
ERROR: /home/abrahamq/riskmap-ng/src/app/services/http.service.ts[99, 14]: Identifier 'flag' is never reassigned; use 'const' instead of 'let'.
ERROR: /home/abrahamq/riskmap-ng/src/app/services/http.service.ts[133, 16]: Identifier 'flag' is never reassigned; use 'const' instead of 'let'.
ERROR: /home/abrahamq/riskmap-ng/src/app/services/http.service.ts[77, 22]: Missing semicolon
ERROR: /home/abrahamq/riskmap-ng/src/app/map/map.component.ts[240, 7]: if statements must be braced
ERROR: /home/abrahamq/riskmap-ng/src/app/map/map.component.ts[263, 7]: if statements must be braced
ERROR: /home/abrahamq/riskmap-ng/src/app/map/map.component.ts[289, 9]: Identifier 'notificationMsg' is never reassigned; use 'const' instead of 'let'.
ERROR: /home/abrahamq/riskmap-ng/src/app/map/map.component.ts[263, 86]: Missing semicolon

Lint errors found in the listed files.```

Fix starting location for the map

  • GPS detected and is one of the instances - automatically load the map
  • GPS is detected and not one of the instance regions - show city selector
  • GPS is not detected and not one of the instance regions - show city selector

Add notifications

  • Reports in past {{timeperiod}}
  • Queried Report id not found in instance
    • Lookup archived report in DB
      • in selected instance
      • in some-other instance - options:
        i. Ignore
        ii. Fly-to other instance, show only queried report
        iii. Reload page with instance, reports and queried report
    • If none of a., notify 'Report with :id does not exist'
  • Geolocation
    • Error
    • (onFound) x flood reports around you?

Can use https://material.angular.io/components/snack-bar/overview
Only takes one msg at a time, create custom component with stacking possibilities.

UI/UX bug in closeup picture

To reproduce:

Submit a report with picture.
Click on the picture. It becomes bigger and fills the entire page, but the only way to go back to the map view is to click the x on the top right. Clicking outside of the image should also take you back to the map as this is a common affordance.

UI/UX Development

  • Overall UX layout for Angular web app
  • toggle for gauges and other layers
  • Legend
  • Report info design
  • Any outstanding UX redesign issues from the previous version

Feature enhancement and UI fixes

- Make region selection mandatory on landing.

  • add instance region rectangles on the map from zoom level 6 - 9/10; on clicking those users would automatically be redirected to the appropriate instance region.

Reduce size of bundle

vendor bundle is ~7 mb before compression. I don't think tree shaking is working.

Deprecated?

Hi there,

I'm only finding deprecated repos -- any idea if there's a code base that's not deprecated, from which new projects should be started?

Many thanks,
Ross

Full-screen image error notification

Option 1
Prevent opening of full-screen overlay if image not available

Option 2
Show error message - "Full-size image temporarily unavailable"

@talltom - do we need to deploy changes we made in image resize lambda to prod?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.