rodekruis / helpful-information

A web-app for People Affected to lookup useful organizations and information.
Apache License 2.0
1 stars 2 forks source link
angular google-sheets humanitarian-aid static-web-app

Helpful Information

A web-app People Affected can use to lookup useful organizations and information.

⚠️
To quickly create a new instance, follow the Guide: How to set up an instance (quickly)


Status

Latest releases and notable changes are in the CHANGELOG.


How it works

The Helpful Information App (HIA) is a web-app that can show a list of 1 or more "regions", each of which is a separate dataset of structured content. This consists of "Offers", sorted in "Categories" and (optional) "Sub-Categories".

The web-app is a pre-build, static web-app that lists links to "regions", which are all separate data-sources contained in Google Sheets 'files'.

The different sheets within these 'files' each have a different data-model. So that their content can be used to display in the web-app.

The contents of these sheets is loaded at runtime by the visitor's browser from the "Google Sheets API".

How to use

Once the web-app is configured (See Configuration) and deployed (See Deployment) its content can be managed via the Google Sheets interface.

Security

⚠️ All content of the web-app can be controlled by the contents of the Google Sheet in use.

So take appropriate precautions regarding file-ownership and "edit"-permissions of these files and the related Google Accounts.

Working with Google Sheets 'files'

⚠️ Everything is visible on the website on every 'save' (so, immediately, most of the times).

Optional:

Text formatting

To support (some) formatting and structuring in some (multi-line) fields, the Markdown-syntax can be used.

An explanation of (a lot of) the features of this syntax can be found in the Markdown Guide Cheat Sheet. Not everything beyond the "Basic Syntax" is supported in all fields.


Getting Started

Configuration

Some specific information needs to be configured before use:

Using the Google Sheets API

Local development

As part of the installed dev-dependencies, we use Prettier to format our code.
To use these settings without a local setup, use the Prettier Playground in your browser.

When installing locally, we use husky to automate the formatting and testing (when not already handled by your editor).

Local API

To use a local API, without the need for any Google account/credentials:

  1. Update the local environment.ts-file with:

       regions: 'test-local-1',
       regionsLabels: 'Test Local 1',
       regionsSheetIds: 'test-sheet-id-1',
    
       google_sheets_api_key: '<can be anything, will be ignored>';
       google_sheets_api_url: 'http://localhost:3001',
  2. Run (in a separate process/terminal):

    npm run serve:local-data

  3. Adjust the JSON-files in the data-directory to try out different content.

Testing

Automated tests are configured and can be run (once) with:

npm test

During development, an automated watch-process can be run with:

npm run test:watch

Recommended tools

Libraries/frameworks in use

Updating dependencies

Most (development-)dependencies in this repository are monitored by the GitHub Dependabot service, to keep them up-to-date.
Unfortunately most individual dependencies are 'linked' to related dependencies that need to stay 'in sync'.

To update all Angular and ESLint related dependencies, run:

npm run upgrade:angular

Data Model

Based on the data fetched from the Google Sheets, an internal data-structure is build. This is used to render the interface.

The following are illustrations only, to help get an overview, it might not be up-to-date with the actual code.

Data Model (internal)

The code below can be easily edited/previewed using the Mermaid.live editor.

%%{ init:{ 'theme':'base', 'themeVariables':{'lineColor':'blue'} }}%%

classDiagram
  class App {
    ENV
    regions
    regionLabels
    regionSheetIds
  }

  class Region {
    slug
    label
    googleSheetId
  }

  class Category {
    int categoryID
    slug
    bool isVisible
    icon
    description
  }

  class SubCategory {
    int subCategoryID
    slug
    bool isVisible
    icon
    description
  }

  class Offer {
    int categoryID
    int subCategoryID
    chapterName
    chapterSlug
    bool isVisible
    int offerId
    slug
    offerName
    icon
    + ...many more properties
  }

  class QASet {
    int categoryID
    int subCategoryID
    bool isVisible
    int id
    slug
    parentSlug
    question
    answer
    Date updated
    bool isHighlight
    array~QASet~ children
  }

  direction LR
    App -- "1..*" Region
    Region -- "1..*" Category
    Category -- "0..*" SubCategory
    SubCategory -- "0..*" Offer
    SubCategory -- "0..*" QASet
    QASet -- "0..*" QASet : children

Data Model (external)

The code below can be easily edited/previewed using the Mermaid.live editor.

%%{ init:{ 'theme':'base', 'themeVariables':{'lineColor':'blue'} }}%%

classDiagram
  class GoogleSheet {
    string id
  }
  class ReferralPage {
    Key-Value rows [];
  }

  class Help {
    Documentation only
  }
  class Options {
    Only for uses in the Sheet itself
  }

  direction TB
    GoogleSheet -- "1" ReferralPage
    GoogleSheet .. "1" Help
    GoogleSheet .. "1" Options

    GoogleSheet -- "1" Categories
    GoogleSheet -- "1" SubCategories
    GoogleSheet -- "1" Offers
    GoogleSheet -- "1" Q_As

    Categories : rows []
    SubCategories : rows []
    Offers : rows []
    Q_As : rows []

Features

Build level configuration

See the options in the .env.example-file.

Each Instance:

Sheet level configuration

See the options in the "Referral Page"-sheet:

(Sub-)Category features

Each (Sub-)Category:

Offer features

Each Offer

Q&A features

Each Q&A-set

Highlighted-overview ("Recent changes")

Search

Using the search-input Q&A-sets can be filtered to match 1 or more keywords to the Question OR the Answer values of a Q&A-set.


Deployment

The web-app can be deployed as a static single-page-app or PWA.

Using Azure Static Web Apps

To deploy the web-app using Azure Static Web App service:

Using static file hosting (i.e. Surge.sh, GitHub/GitLab Pages or similar)

To deploy the web-app using or a static-files web-host, see options at: https://jamstack-deploy.vercel.app/ or articles like: https://www.hostingadvice.com/how-to/best-static-web-hosting/.

Configure and build a 'production'-build of the web-app following the steps defined at "Deployment".

Follow one of these 'guides' from Surge.


License

Released under the Apache 2.0 License. See LICENSE.