Code Monkey home page Code Monkey logo

workshop-openflight's Introduction

Heroku SonarCoverage SonarLines SonarGate

Workshop "OpenFlight" by TECC-SE

This complementary user interface belongs to the workshop material during the Schiphol Developers Group on June 14th 2018 @ KLM. However the workshop can be followed by anybody interested in playing with some features from Spring's WebFlux module. With this user interface we are able to plot markers on a map or simply show a list.

overview

workshop is provided by TECC-SE innovation lab at AFKLM

A - Development server with mock backend (nodeJS)

  1. npm run dev:mock. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files. If you want to run on another port npm run dev:mock -- port=4444
  2. npm start (only departures: 'DPS', 'LAX' and 'SVO' are based on real data)

B - Development server with real backend (Java)

  1. Run your backend server and fill in your endpoint in './proxy-backend.conf.json'
  2. npm run dev:backend. Navigate to http://localhost:4200/

WORKSHOP

When you finished your backend you can now start with the frontend (or if you don't want to make your own backend you can run the frontend mock one). You can choose between creating a 'map application' and a 'list application'.

In the development branch we created an Angular/Rxjs scaffold where we put the service which you can use to start with.

Service

get(origin: string): Observable<OpenFlight> {

  const url = `${environment.api}/offers/${origin}`;

  return Observable.create((observer) => {

    const eventSource = new window['EventSource'](url);

    eventSource.onmessage = ((event) => this.ngZone.run(() => {
      const json = JSON.parse(event.data);
      return observer.next(json);
    }));

    eventSource.onerror = ((error) => this.ngZone.run(() => {
      if (eventSource.readyState === 0) {
        eventSource.close();
        return observer.complete();
      } else {
        return observer.error('EventSource error: ' + error);
      }
    }));

    return () => eventSource.close();
  });

}

List view

Try to alter the service so it will give back the complete list as a result. When you have a listview try adding a sparkline for historical prices (ChartJS is added by default). example layout

Map view

When you are more familiair with Google Maps API it will be possible to plot the markers on the Map and update them accordingly. For this you will need to know the limitations of their API (no destroy, no repaint on marker update). help

Please note that my personal key for Google Maps is used and this key is limmited on hits and in time (without any key it will not work at all). So after our workshop this key may not work anymore. Please use your own key in environments

Build

  • Testing build: npm run dev -- --port=4444 --configuration=production --prod
  • Running build npm run build:prod. The build artifacts will be stored in the dist/ directory.

Help

Simply ask the people walking or sitting near you :)

EventSource interface background information

"The EventSource interface is web content's interface to server-sent events. An EventSource instance opens a persistent connection to an HTTP server, which sends events in text/event-stream format." EventSource can-i-use

Browsers

Supported by allmost al browsers but IE, so we are using 'eventsource-polyfill' for most of them.

Spoiler allert!!! a possible solution is in the other branch :) and online at afkl-workshop.herokuapp.com

workshop-openflight's People

Contributors

maapteh avatar

Stargazers

 avatar

Watchers

 avatar

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.