Git Product home page Git Product logo

olekstomek / mcod-frontend-dane.gov.pl Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 6.57 MB

Mirror frontend dane.gov.pl from https://gitlab.dane.gov.pl/otwarte-dane/mcod-frontend

Home Page: https://dane.gov.pl/

Shell 0.05% Batchfile 0.02% Dockerfile 0.05% JavaScript 0.21% TypeScript 67.51% HTML 26.02% CSS 0.11% SCSS 6.04%
angular gov goverment government-data mirror open-data open-source open-source-project otwarte-dane popc public-data public-data-api

mcod-frontend-dane.gov.pl's Introduction

Otwarte Dane 2018 Frontend App

Installation

Recommended node and npm versions

  • node > 8.9.1
  • npm > 6.4.1

Main installation script is simply npm install. Other commands are optional, in case you need Angular CLI for code generation or your Node Package Manager is outdated. Check your version with npm --version command.

# Global installations are optional
npm install -g npm@latest
npm install -g @angular/cli
 
npm install
./create-env.sh

Start application locally

If you run application for the first time you need to build the app.

npm run build

To run your application locally, all you need to run is npm script. Script definition can be found inside package.json.

npm run start

Building application for production

There are multiple scripts that builds frontend application, however only one of them creates final production release code.

npm run build:prod

API Proxy settings

Local frontend application does not serve API. Instead, frontend uses proxy to redirect request to running API instance. Proxy settings are stored in proxy.conf.json file. This file is used when frontend is run on localhost with npm run start. Change the target path if you want services to refer to different API address. You can copy, rename and change proxy.conf.json file contents according to your needs.

Usage:

ng serve --host 0.0.0.0 --proxy-config my-proxy.conf.json

Proxy options:

  • target - what is the target domain for that path
  • pathRewrite - this option allows you to change parts of your local url to match API urls
  • secure - determines if https requests are secure and signed with known authority, leave false for self-signed ssl certificates
  • logLevel - verbosity of proxy server in your command line tool
  • changeOrigin - important setting for cross origin calls, needs to stay true unless frontend and backend are served on the same domain

for example if your API stands on localhost:8000, you need change target for /api in proxy.conf.json file, for your cms you need do the same; change target for /cms (in this example is localhost:8001).

Example proxy.conf.json file:

{
    "/api": {
        "target": "http://localhost:8000",
        "secure": false,
        "pathRewrite": {
            "^/api": ""
        },
        "logLevel": "debug",
        "changeOrigin": true
    },
    "/media": {
        "target": "http://localhost:8000",
        "secure": false,
        "logLevel": "debug",
        "changeOrigin": true
    },
    "/flags": {
        "target": "https://dane.gov.pl/",
        "secure": false,
        "logLevel": "debug",
        "changeOrigin": true
    },
    "/cms": {
        "target": "https://localhost:8001",
        "secure": false,
        "logLevel": "debug",
        "changeOrigin": true,
        "pathRewrite": {
            "^/cms": ""
        }
    }
}

Creating environment file

Environment file contains information about last build and last commit hash number, and looks like this:

env.json

{
    "COMMIT_HASH":"826df9e2",
    "COMMIT_DATE":"10-10-2018 10:10:10"
}

You can create this file manually or simply run following script:

# Linux only command 
chmod +x create_env.sh

# Linux or Git Bash
./create-env.sh

# Windows CMD or PowerShell (double click might not work)
create-env.bat

If you want to get last commits hash, you can also run

git rev-parse --short=8 HEAD

mcod-frontend-dane.gov.pl's People

Contributors

olekstomek avatar

Watchers

 avatar  avatar

Forkers

saisai

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.