├── .gitignore ├── README.md ├── backend ├── .editorconfig ├── .gitignore ├── Dockerfile ├── README.md ├── Simple Iris Model.ipynb ├── app.py └── requirements.txt ├── docker-compose.yml └── frontend ├── .angular-cli.json ├── .editorconfig ├── .gitignore ├── Dockerfile ├── README.md ├── package.json ├── proxy.conf.dev.json ├── proxy.conf.json ├── src ├── app │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.ts │ ├── app.module.ts │ ├── app.routes.ts │ ├── pages │ │ └── home │ │ │ ├── home.component.html │ │ │ ├── home.component.scss │ │ │ ├── home.component.ts │ │ │ ├── iris.service.ts │ │ │ └── types.ts │ └── shared │ │ ├── layouts │ │ ├── .gitkeep │ │ └── main-layout │ │ │ ├── index.ts │ │ │ ├── main-layout.component.html │ │ │ ├── main-layout.component.scss │ │ │ ├── main-layout.component.ts │ │ │ ├── main-layout.module.ts │ │ │ ├── main-layout.types.ts │ │ │ ├── nav-bar │ │ │ ├── nav-bar.component.html │ │ │ ├── nav-bar.component.scss │ │ │ └── nav-bar.component.ts │ │ │ └── side-nav │ │ │ ├── side-nav.component.html │ │ │ ├── side-nav.component.scss │ │ │ └── side-nav.component.ts │ │ ├── shared.module.ts │ │ └── styles │ │ ├── .gitkeep │ │ ├── _custom.scss │ │ ├── _theming.scss │ │ ├── _variables.scss │ │ └── main.scss ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── index.html ├── main.ts ├── polyfills.ts ├── styles.scss ├── tsconfig.app.json └── typings.d.ts ├── tsconfig.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.db 3 | .ipynb_checkpoints 4 | __pycache__ 5 | tps3_qcontrol/airflow/logs/* 6 | *.pyc 7 | tps3_qcontrol/__pycache__ 8 | *.bmp 9 | *.BMP 10 | *.jpg 11 | *.JPG 12 | *.pid 13 | *.csv 14 | 15 | # IDEs and editors 16 | .idea 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | 32 | # System Files 33 | .DS_Store 34 | Thumbs.db 35 | 36 | # Logs 37 | logs 38 | *.log 39 | npm-debug.log* 40 | yarn-debug.log* 41 | yarn-error.log* 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Data Science Web Application Tutorial 2 | 3 | This repository is meant to demonstrate the use of Flask and Angular to build a simple, but state-of-the-art, web application which can be used for POCs. 4 | Read the corresponding Medium article [here](https://medium.com/@dvelsner/deploying-a-simple-machine-learning-model-in-a-modern-web-application-flask-angular-docker-a657db075280). 5 | 6 | ## Clone/Fork repository 7 | 8 | First fork or clone this repo: 9 | 10 | e.g. `git clone https://github.com/delsner/flask-angular-data-science.git` 11 | 12 | 13 | ## Build images and run containers with docker-compose 14 | 15 | After cloning the repository go inside the project folder: 16 | 17 | `cd flask-angular-data-science` 18 | 19 | Run `docker-compose up` which will start a Flask web application for the backend API (default port `8081`) and an Angular frontend served through a webpack development web server (default port `4200`). 20 | 21 | 22 | ## Access your app 23 | 24 | In your browser navigate to: `http://localhost:4200` (or whatever port you defined for the frontend in `docker-compose.yml`). 25 | 26 | For testing your backend API I recommend using [Postman](https://www.getpostman.com/). 27 | 28 | 29 | ## Working __without__ docker 30 | 31 | I highly recommend the use of docker and docker-compose as it is far simpler to get started than to run all of the following manually. 32 | 33 | 34 | ### Backend development 35 | 36 | Navigate inside the backend directory: `cd backend` 37 | 38 | Install pip dependencies: `pip install -r requirements.txt` 39 | 40 | Run `python app.py` in backend root (will watch files and restart server on port `8081` on change). 41 | 42 | ### Frontend development 43 | 44 | Navigate inside the frontend directory: `cd frontend` 45 | 46 | Assure you have [Nodejs](https://nodejs.org/en/), [Yarn](https://yarnpkg.com/en/docs/install) and the [angular-cli](https://cli.angular.io/) installed. 47 | 48 | Install npm dependencies: `yarn install --pure-lockfile` 49 | 50 | Run `yarn start` in frontend root (will watch files and restart dev-server on port `4200` on change). 51 | All calls made to `/api` will be proxied to backend server (default port for backend `8081`), this can be changed in `proxy.conf.json`. 52 | -------------------------------------------------------------------------------- /backend/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 4 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | .idea 13 | /.idea 14 | .project 15 | .classpath 16 | .c9/ 17 | *.launch 18 | .settings/ 19 | *.sublime-workspace 20 | 21 | # IDE - VSCode 22 | .vscode/* 23 | !.vscode/settings.json 24 | !.vscode/tasks.json 25 | !.vscode/launch.json 26 | !.vscode/extensions.json 27 | 28 | # misc 29 | /.sass-cache 30 | /connect.lock 31 | /coverage 32 | /libpeerconnection.log 33 | npm-debug.log 34 | testem.log 35 | /typings 36 | 37 | # e2e 38 | /e2e/*.js 39 | /e2e/*.map 40 | 41 | # System Files 42 | .DS_Store 43 | Thumbs.db 44 | ======= 45 | # Logs 46 | logs 47 | *.log 48 | npm-debug.log* 49 | yarn-debug.log* 50 | yarn-error.log* 51 | 52 | # Runtime data 53 | pids 54 | *.pid 55 | *.seed 56 | *.pid.lock 57 | 58 | # Directory for instrumented libs generated by jscoverage/JSCover 59 | lib-cov 60 | 61 | # Coverage directory used by tools like istanbul 62 | coverage 63 | 64 | # nyc test coverage 65 | .nyc_output 66 | 67 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 68 | .grunt 69 | 70 | # Bower dependency directory (https://bower.io/) 71 | bower_components 72 | 73 | # node-waf configuration 74 | .lock-wscript 75 | 76 | # Compiled binary addons (http://nodejs.org/api/addons.html) 77 | build/Release 78 | 79 | # Dependency directories 80 | node_modules/ 81 | jspm_packages/ 82 | 83 | # Typescript v1 declaration files 84 | typings/ 85 | 86 | # Optional npm cache directory 87 | .npm 88 | 89 | # Optional eslint cache 90 | .eslintcache 91 | 92 | # Optional REPL history 93 | .node_repl_history 94 | 95 | # Output of 'npm pack' 96 | *.tgz 97 | 98 | # Yarn Integrity file 99 | .yarn-integrity 100 | 101 | # dotenv environment variables file 102 | .env 103 | /env 104 | 105 | # pkl-files 106 | *.pkl 107 | -------------------------------------------------------------------------------- /backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | RUN apt-get update \ 4 | && apt-get install -yq --no-install-recommends \ 5 | python3 \ 6 | python3-pip 7 | RUN pip3 install --upgrade pip==9.0.3 \ 8 | && pip3 install setuptools 9 | 10 | # for flask web server 11 | EXPOSE 8081 12 | 13 | # set working directory 14 | ADD . /app 15 | WORKDIR /app 16 | 17 | # install required libraries 18 | RUN pip3 install -r requirements.txt 19 | 20 | # This is the runtime command for the container 21 | CMD python3 app.py 22 | -------------------------------------------------------------------------------- /backend/README.md: -------------------------------------------------------------------------------- 1 | # Flask backend API 2 | 3 | ## Development server 4 | 5 | Run `python app.py` to start development server on port `8081` to watch files and restart on update. 6 | 7 | ## Use from docker container 8 | 9 | Clone project on your remote machine (needs to have docker daemon installed), then build image (`docker build -t flask-backend .`) and finally run the image by using `docker run -p 8081:8081 -v /HOST/PATH/TO/BACKEND/FOLDER:/app flask-backend`. 10 | -------------------------------------------------------------------------------- /backend/Simple Iris Model.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Iris Plants Database\n", 13 | "====================\n", 14 | "\n", 15 | "Notes\n", 16 | "-----\n", 17 | "Data Set Characteristics:\n", 18 | " :Number of Instances: 150 (50 in each of three classes)\n", 19 | " :Number of Attributes: 4 numeric, predictive attributes and the class\n", 20 | " :Attribute Information:\n", 21 | " - sepal length in cm\n", 22 | " - sepal width in cm\n", 23 | " - petal length in cm\n", 24 | " - petal width in cm\n", 25 | " - class:\n", 26 | " - Iris-Setosa\n", 27 | " - Iris-Versicolour\n", 28 | " - Iris-Virginica\n", 29 | " :Summary Statistics:\n", 30 | "\n", 31 | " ============== ==== ==== ======= ===== ====================\n", 32 | " Min Max Mean SD Class Correlation\n", 33 | " ============== ==== ==== ======= ===== ====================\n", 34 | " sepal length: 4.3 7.9 5.84 0.83 0.7826\n", 35 | " sepal width: 2.0 4.4 3.05 0.43 -0.4194\n", 36 | " petal length: 1.0 6.9 3.76 1.76 0.9490 (high!)\n", 37 | " petal width: 0.1 2.5 1.20 0.76 0.9565 (high!)\n", 38 | " ============== ==== ==== ======= ===== ====================\n", 39 | "\n", 40 | " :Missing Attribute Values: None\n", 41 | " :Class Distribution: 33.3% for each of 3 classes.\n", 42 | " :Creator: R.A. Fisher\n", 43 | " :Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)\n", 44 | " :Date: July, 1988\n", 45 | "\n", 46 | "This is a copy of UCI ML iris datasets.\n", 47 | "http://archive.ics.uci.edu/ml/datasets/Iris\n", 48 | "\n", 49 | "The famous Iris database, first used by Sir R.A Fisher\n", 50 | "\n", 51 | "This is perhaps the best known database to be found in the\n", 52 | "pattern recognition literature. Fisher's paper is a classic in the field and\n", 53 | "is referenced frequently to this day. (See Duda & Hart, for example.) The\n", 54 | "data set contains 3 classes of 50 instances each, where each class refers to a\n", 55 | "type of iris plant. One class is linearly separable from the other 2; the\n", 56 | "latter are NOT linearly separable from each other.\n", 57 | "\n", 58 | "References\n", 59 | "----------\n", 60 | " - Fisher,R.A. \"The use of multiple measurements in taxonomic problems\"\n", 61 | " Annual Eugenics, 7, Part II, 179-188 (1936); also in \"Contributions to\n", 62 | " Mathematical Statistics\" (John Wiley, NY, 1950).\n", 63 | " - Duda,R.O., & Hart,P.E. (1973) Pattern Classification and Scene Analysis.\n", 64 | " (Q327.D83) John Wiley & Sons. ISBN 0-471-22361-1. See page 218.\n", 65 | " - Dasarathy, B.V. (1980) \"Nosing Around the Neighborhood: A New System\n", 66 | " Structure and Classification Rule for Recognition in Partially Exposed\n", 67 | " Environments\". IEEE Transactions on Pattern Analysis and Machine\n", 68 | " Intelligence, Vol. PAMI-2, No. 1, 67-71.\n", 69 | " - Gates, G.W. (1972) \"The Reduced Nearest Neighbor Rule\". IEEE Transactions\n", 70 | " on Information Theory, May 1972, 431-433.\n", 71 | " - See also: 1988 MLC Proceedings, 54-64. Cheeseman et al\"s AUTOCLASS II\n", 72 | " conceptual clustering system finds 3 classes in the data.\n", 73 | " - Many, many more ...\n", 74 | "\n", 75 | "Training Accuracy: 0.993333333333\n", 76 | "Prediction results: [[ 0.50639543 0.44329178 0.05031279]]\n" 77 | ] 78 | } 79 | ], 80 | "source": [ 81 | "from sklearn import svm\n", 82 | "from sklearn import datasets\n", 83 | "\n", 84 | "# read iris dataset\n", 85 | "iris = datasets.load_iris()\n", 86 | "X, y = iris.data, iris.target\n", 87 | "\n", 88 | "print(iris['DESCR'])\n", 89 | "\n", 90 | "# fit model\n", 91 | "clf = svm.SVC(\n", 92 | " C=1.0,\n", 93 | " probability=True, \n", 94 | " random_state=1)\n", 95 | "clf.fit(X, y)\n", 96 | "\n", 97 | "print('Training Accuracy: ', clf.score(X, y))\n", 98 | "\n", 99 | "print('Prediction results: ', clf.predict_proba([[5.2, 3.5, 2.4, 1.2]]))" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": null, 105 | "metadata": { 106 | "collapsed": true 107 | }, 108 | "outputs": [], 109 | "source": [] 110 | } 111 | ], 112 | "metadata": { 113 | "kernelspec": { 114 | "display_name": "Python 3", 115 | "language": "python", 116 | "name": "python3" 117 | }, 118 | "language_info": { 119 | "codemirror_mode": { 120 | "name": "ipython", 121 | "version": 3 122 | }, 123 | "file_extension": ".py", 124 | "mimetype": "text/x-python", 125 | "name": "python", 126 | "nbconvert_exporter": "python", 127 | "pygments_lexer": "ipython3", 128 | "version": "3.6.2" 129 | } 130 | }, 131 | "nbformat": 4, 132 | "nbformat_minor": 2 133 | } 134 | -------------------------------------------------------------------------------- /backend/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, jsonify 2 | from sklearn import svm 3 | from sklearn import datasets 4 | from sklearn.externals import joblib 5 | 6 | # declare constants 7 | HOST = '0.0.0.0' 8 | PORT = 8081 9 | 10 | # initialize flask application 11 | app = Flask(__name__) 12 | 13 | 14 | @app.route('/api/train', methods=['POST']) 15 | def train(): 16 | # get parameters from request 17 | parameters = request.get_json() 18 | 19 | # read iris data set 20 | iris = datasets.load_iris() 21 | X, y = iris.data, iris.target 22 | 23 | # fit model 24 | clf = svm.SVC(C=float(parameters['C']), 25 | probability=True, 26 | random_state=1) 27 | clf.fit(X, y) 28 | 29 | # persist model 30 | joblib.dump(clf, 'model.pkl') 31 | 32 | return jsonify({'accuracy': round(clf.score(X, y) * 100, 2)}) 33 | 34 | 35 | @app.route('/api/predict', methods=['POST']) 36 | def predict(): 37 | # get iris object from request 38 | X = request.get_json() 39 | X = [[float(X['sepalLength']), float(X['sepalWidth']), float(X['petalLength']), float(X['petalWidth'])]] 40 | 41 | # read model 42 | clf = joblib.load('model.pkl') 43 | probabilities = clf.predict_proba(X) 44 | 45 | return jsonify([{'name': 'Iris-Setosa', 'value': round(probabilities[0, 0] * 100, 2)}, 46 | {'name': 'Iris-Versicolour', 'value': round(probabilities[0, 1] * 100, 2)}, 47 | {'name': 'Iris-Virginica', 'value': round(probabilities[0, 2] * 100, 2)}]) 48 | 49 | 50 | if __name__ == '__main__': 51 | # run web server 52 | app.run(host=HOST, 53 | debug=True, # automatic reloading enabled 54 | port=PORT) 55 | -------------------------------------------------------------------------------- /backend/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | scikit-learn[alldeps] 3 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | frontend: 4 | image: frontend-angular 5 | build: 6 | context: ./frontend 7 | dockerfile: Dockerfile 8 | container_name: "frontend-app" 9 | volumes: 10 | - ./frontend/src:/app/src # for watching files 11 | ports: 12 | - "4200:4200" 13 | backend: 14 | image: backend-flask 15 | build: 16 | context: ./backend 17 | dockerfile: Dockerfile 18 | container_name: "backend-app" 19 | volumes: 20 | - ./backend:/app # for watching files 21 | ports: 22 | - "8081:8081" # if changed, please change port in `frontend/proxy.conf.dev.json` 23 | -------------------------------------------------------------------------------- /frontend/.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "data-science-web-app" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "assets": [ 11 | "assets", 12 | "favicon.ico" 13 | ], 14 | "index": "index.html", 15 | "main": "main.ts", 16 | "polyfills": "polyfills.ts", 17 | "test": "test.ts", 18 | "tsconfig": "tsconfig.app.json", 19 | "testTsconfig": "tsconfig.spec.json", 20 | "prefix": "", 21 | "styles": [ 22 | "styles.scss" 23 | ], 24 | "scripts": [], 25 | "environmentSource": "environments/environment.ts", 26 | "environments": { 27 | "dev": "environments/environment.ts", 28 | "prod": "environments/environment.prod.ts" 29 | } 30 | } 31 | ], 32 | "e2e": { 33 | "protractor": { 34 | "config": "./protractor.conf.js" 35 | } 36 | }, 37 | "lint": [ 38 | { 39 | "project": "src/tsconfig.app.json", 40 | "exclude": "**/node_modules/**" 41 | }, 42 | { 43 | "project": "src/tsconfig.spec.json", 44 | "exclude": "**/node_modules/**" 45 | }, 46 | { 47 | "project": "e2e/tsconfig.e2e.json", 48 | "exclude": "**/node_modules/**" 49 | } 50 | ], 51 | "test": { 52 | "karma": { 53 | "config": "./karma.conf.js" 54 | } 55 | }, 56 | "defaults": { 57 | "styleExt": "scss", 58 | "component": { 59 | "spec": false 60 | }, 61 | "directive": { 62 | "spec": false 63 | }, 64 | "class": { 65 | "spec": false 66 | }, 67 | "guard": { 68 | "spec": false 69 | }, 70 | "module": { 71 | "spec": false 72 | }, 73 | "pipe": { 74 | "spec": false 75 | }, 76 | "service": { 77 | "spec": false 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /frontend/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 4 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | testem.log 34 | /typings 35 | 36 | # e2e 37 | /e2e/*.js 38 | /e2e/*.map 39 | 40 | # System Files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:8 2 | 3 | # set up angular cli 4 | RUN yarn global add @angular/cli@1.2.6 5 | 6 | WORKDIR /app 7 | COPY package.json /app 8 | COPY yarn.lock /app 9 | RUN yarn install --pure-lockfile 10 | COPY . /app 11 | 12 | # create watch files 13 | CMD ng serve --host 0.0.0.0 --disable-host-check --proxy-config proxy.conf.dev.json 14 | EXPOSE 4200 15 | -------------------------------------------------------------------------------- /frontend/README.md: -------------------------------------------------------------------------------- 1 | # Webapp Starter 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.2.6. 4 | 5 | ## Development server 6 | 7 | Run `yarn start` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project or `ng build --prod` for the AOT build. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | Before running the tests make sure you are serving the app via `ng serve`. 25 | 26 | ## Further help 27 | 28 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 29 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Data-Science-Web-App", 3 | "version": "1.0.0", 4 | "author": "Daniel Elsner ", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve --proxy-config proxy.conf.json", 8 | "build": "ng build", 9 | "test": "echo \"Error: no test... minimal project\" && exit 1", 10 | "lint": "echo \"Error: no lint... minimal project\" && exit 1", 11 | "e2e": "echo \"Error: no e2e... minimal project\" && exit 1" 12 | }, 13 | "dependencies": { 14 | "@angular/animations": "^4.0.0", 15 | "@angular/cdk": "^2.0.0-beta.8", 16 | "@angular/common": "^4.0.0", 17 | "@angular/compiler": "^4.0.0", 18 | "@angular/core": "^4.0.0", 19 | "@angular/flex-layout": "2.0.0-beta.8", 20 | "@angular/forms": "^4.0.0", 21 | "@angular/http": "^4.0.0", 22 | "@angular/material": "2.0.0-beta.8", 23 | "@angular/platform-browser": "^4.0.0", 24 | "@angular/platform-browser-dynamic": "^4.0.0", 25 | "@angular/router": "^4.0.0", 26 | "@swimlane/ngx-charts": "6.1.0", 27 | "core-js": "^2.4.1", 28 | "d3": "^4.13.0", 29 | "hammerjs": "^2.0.8", 30 | "rxjs": "^5.4.1", 31 | "zone.js": "^0.8.14" 32 | }, 33 | "devDependencies": { 34 | "@angular/cli": "1.2.6", 35 | "@angular/compiler-cli": "^4.0.0", 36 | "@angular/language-service": "^4.0.0", 37 | "typescript": "~2.3.3" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /frontend/proxy.conf.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "/api": { 3 | "target": "http://backend:8081", 4 | "secure": false 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /frontend/proxy.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "/api": { 3 | "target": "http://localhost:8081", 4 | "secure": false 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /frontend/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /frontend/src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | @import "./shared/styles/main"; 2 | 3 | .app__footer { 4 | padding: $unit-lg 0; 5 | } 6 | -------------------------------------------------------------------------------- /frontend/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import {Component} from '@angular/core'; 2 | import {NavigationEnd, Router} from "@angular/router"; 3 | import {Subscription} from "rxjs/Subscription"; 4 | import {ROUTES} from "./app.routes"; 5 | import {NavigationItem} from './shared/layouts/main-layout'; 6 | import 'rxjs/add/operator/filter'; 7 | 8 | @Component({ 9 | selector: 'app', 10 | templateUrl: './app.component.html', 11 | styleUrls: ['./app.component.scss'] 12 | }) 13 | export class AppComponent { 14 | public menuItems: NavigationItem[]; 15 | 16 | private routerSub: Subscription; 17 | 18 | constructor(private router: Router) { 19 | // get all routes and add to menuItems array 20 | this.menuItems = ROUTES.map((route) => { 21 | return { 22 | name: route.component && route.data.title, 23 | route: route.path 24 | }; 25 | }).slice(0, ROUTES.length - 1); 26 | } 27 | 28 | ngOnInit() { 29 | // this will always scroll to the top when routing to another page 30 | this.routerSub = this.router.events 31 | .filter((event) => event instanceof NavigationEnd) 32 | .subscribe((event) => { 33 | window.scrollTo(0, 0); 34 | }) 35 | } 36 | 37 | ngOnDestroy() { 38 | this.routerSub.unsubscribe(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /frontend/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | // external modules 2 | import {BrowserModule} from '@angular/platform-browser'; 3 | import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; 4 | import {NgModule} from '@angular/core'; 5 | import {PreloadAllModules, RouterModule} from "@angular/router"; 6 | import 'hammerjs'; 7 | 8 | // own modules and components 9 | import {AppComponent} from './app.component'; 10 | import {SharedModule} from "./shared/shared.module"; 11 | import {ROUTES} from "./app.routes"; 12 | import {HomeComponent} from "./pages/home/home.component"; 13 | import {IrisService} from "./pages/home/iris.service"; 14 | 15 | @NgModule({ 16 | declarations: [ 17 | AppComponent, 18 | HomeComponent, 19 | ], 20 | imports: [ 21 | BrowserModule, 22 | BrowserAnimationsModule, 23 | RouterModule.forRoot(ROUTES, {useHash: false, preloadingStrategy: PreloadAllModules}), 24 | SharedModule 25 | ], 26 | providers: [IrisService], 27 | bootstrap: [AppComponent] 28 | }) 29 | export class AppModule { 30 | } 31 | -------------------------------------------------------------------------------- /frontend/src/app/app.routes.ts: -------------------------------------------------------------------------------- 1 | import {Routes} from "@angular/router"; 2 | import {HomeComponent} from "./pages/home/home.component"; 3 | 4 | export const ROUTES: Routes = [ 5 | // routes from pages 6 | {path: 'home', component: HomeComponent, data: {title: 'Home'}}, 7 | 8 | // default redirect 9 | {path: '**', redirectTo: '/home'} 10 | ]; 11 | -------------------------------------------------------------------------------- /frontend/src/app/pages/home/home.component.html: -------------------------------------------------------------------------------- 1 |
2 |

Iris Model - Example

3 | 4 |
5 |

Train Classification Model (Support Vector Machine)

6 | 7 |

Set Parameter for Model Training

8 | 9 | 14 | 15 | 18 |
19 | 20 |
23 |

Training Accuracy

24 | 31 | 32 |
33 |
34 | 35 |
38 |

Predict Iris classes

39 | 40 | 41 |

Define Iris

42 |
43 | 44 | 48 | 49 | 50 | 54 | 55 |
56 |
57 | 58 | 62 | 63 | 64 | 68 | 69 |
70 |
71 | 72 |
73 |
74 | 75 |
79 |

Prediction Result

80 | 85 | 86 |
87 |
88 |
89 | -------------------------------------------------------------------------------- /frontend/src/app/pages/home/home.component.scss: -------------------------------------------------------------------------------- 1 | $chart-min-height: 300px; 2 | $chart-width: 600px; 3 | .home__chart-container { 4 | min-height: $chart-min-height; 5 | width: $chart-width; 6 | max-width: 100%; 7 | } 8 | -------------------------------------------------------------------------------- /frontend/src/app/pages/home/home.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, OnInit} from '@angular/core'; 2 | import {IrisService} from "./iris.service"; 3 | import { 4 | Iris, 5 | ProbabilityPrediction, 6 | SVCParameters, 7 | SVCResult 8 | } from "./types"; 9 | 10 | @Component({ 11 | selector: 'home', 12 | templateUrl: './home.component.html', 13 | styleUrls: ['./home.component.scss'] 14 | }) 15 | export class HomeComponent implements OnInit { 16 | 17 | public svcParameters: SVCParameters = new SVCParameters(); 18 | public svcResult: SVCResult; 19 | public iris: Iris = new Iris(); 20 | public probabilityPredictions: ProbabilityPrediction[]; 21 | 22 | // graph styling 23 | public colorScheme = { 24 | domain: ['#1a242c', '#e81746', '#e67303', '#f0f0f0'] 25 | }; 26 | 27 | constructor(private irisService: IrisService) { 28 | } 29 | 30 | ngOnInit() { 31 | } 32 | 33 | public trainModel() { 34 | this.irisService.trainModel(this.svcParameters).subscribe((svcResult) => { 35 | this.svcResult = svcResult; 36 | }); 37 | } 38 | 39 | public predictIris() { 40 | this.irisService.predictIris(this.iris).subscribe((probabilityPredictions) => { 41 | this.probabilityPredictions = probabilityPredictions; 42 | }); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /frontend/src/app/pages/home/iris.service.ts: -------------------------------------------------------------------------------- 1 | import {Injectable} from '@angular/core'; 2 | import {Http} from "@angular/http"; 3 | import {Observable} from "rxjs/Observable"; 4 | import 'rxjs/add/operator/map'; 5 | import { 6 | Iris, 7 | ProbabilityPrediction, 8 | SVCParameters, 9 | SVCResult 10 | } from "./types"; 11 | 12 | const SERVER_URL: string = 'api/'; 13 | 14 | @Injectable() 15 | export class IrisService { 16 | 17 | constructor(private http: Http) { 18 | } 19 | 20 | public trainModel(svcParameters: SVCParameters): Observable { 21 | return this.http.post(`${SERVER_URL}train`, svcParameters).map((res) => res.json()); 22 | } 23 | 24 | public predictIris(iris: Iris): Observable { 25 | return this.http.post(`${SERVER_URL}predict`, iris).map((res) => res.json()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /frontend/src/app/pages/home/types.ts: -------------------------------------------------------------------------------- 1 | export class Iris { 2 | sepalLength: number = 5.0; 3 | sepalWidth: number = 3.5; 4 | petalLength: number = 2.5; 5 | petalWidth: number = 1.2; 6 | } 7 | 8 | export class ProbabilityPrediction { 9 | name: string; 10 | value: number; 11 | } 12 | 13 | export class SVCParameters { 14 | C: number = 2.0; 15 | } 16 | 17 | export class SVCResult { 18 | accuracy: number; 19 | } 20 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/delsner/flask-angular-data-science/ac382881684c8cf8a849007fd4558e255260ce91/frontend/src/app/shared/layouts/.gitkeep -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/index.ts: -------------------------------------------------------------------------------- 1 | export * from './main-layout.types'; 2 | 3 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/main-layout.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 | 6 |
7 | 8 |
9 |
10 |
11 |
12 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/main-layout.component.scss: -------------------------------------------------------------------------------- 1 | @import "../../styles/main"; 2 | 3 | .main-layout__container { 4 | padding-top: $top-nav-height; 5 | max-width: 100%; 6 | height: 100%; 7 | } 8 | 9 | .main-layout__content { 10 | overflow: auto; 11 | &.main-layout__content--padding { 12 | padding: $unit-sm; 13 | } 14 | width: 100%; 15 | max-width: 100%; 16 | } 17 | 18 | $side-nav-bg: #fff; 19 | $side-nav-box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12); 20 | .main-layout__side-nav { 21 | min-width: 250px; 22 | overflow: auto; 23 | padding: $unit-xs 0; 24 | background-color: $side-nav-bg; 25 | box-shadow: $side-nav-box-shadow; 26 | border-right: solid 1px #d9e0e8; 27 | transition: 0.3s;; 28 | } 29 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/main-layout.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, Input, OnInit} from '@angular/core'; 2 | import {NavigationItem} from "./main-layout.types"; 3 | 4 | @Component({ 5 | selector: 'main-layout', 6 | templateUrl: './main-layout.component.html', 7 | styleUrls: ['./main-layout.component.scss'] 8 | }) 9 | 10 | export class MainLayoutComponent implements OnInit { 11 | @Input() 12 | public menuItems: NavigationItem[] = []; 13 | 14 | @Input() 15 | public hasSideNav: boolean = false; 16 | 17 | @Input() 18 | public title: string = ''; 19 | 20 | @Input() 21 | public logoUrl: string = ''; 22 | 23 | @Input() 24 | public hasContentPadding: boolean = true; 25 | 26 | constructor() { 27 | } 28 | 29 | ngOnInit() { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/main-layout.module.ts: -------------------------------------------------------------------------------- 1 | import {NgModule} from '@angular/core'; 2 | 3 | import {MainLayoutComponent} from './main-layout.component'; 4 | import {CommonModule} from "@angular/common"; 5 | import {FlexLayoutModule} from "@angular/flex-layout"; 6 | import {NavBarComponent} from "./nav-bar/nav-bar.component"; 7 | import {MdButtonModule, MdIconModule, MdMenuModule, MdToolbarModule} from "@angular/material"; 8 | import {RouterModule} from "@angular/router"; 9 | import {SideNavComponent} from "./side-nav/side-nav.component"; 10 | 11 | @NgModule({ 12 | imports: [ 13 | CommonModule, 14 | RouterModule, 15 | FlexLayoutModule, 16 | MdMenuModule, 17 | MdButtonModule, 18 | MdIconModule, 19 | MdToolbarModule 20 | ], 21 | exports: [ 22 | MainLayoutComponent, 23 | NavBarComponent, 24 | SideNavComponent], 25 | declarations: [ 26 | MainLayoutComponent, 27 | NavBarComponent, 28 | SideNavComponent 29 | ], 30 | providers: [], 31 | }) 32 | export class MainLayoutModule { 33 | } 34 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/main-layout.types.ts: -------------------------------------------------------------------------------- 1 | export interface NavigationItem { 2 | name: string; 3 | route: string; 4 | } 5 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/nav-bar/nav-bar.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 5 | {{title}} 6 |
7 |
8 | 13 |
14 |
15 | 18 |
19 |
20 |
21 | 22 | 23 | 28 | 29 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/nav-bar/nav-bar.component.scss: -------------------------------------------------------------------------------- 1 | @import "../../../styles/main"; 2 | 3 | $top-nav-box-shadow: 0 0 1px 1px rgba(0, 0, 0, .14), 0 0 2px 2px rgba(0, 0, 0, .098), 0 0 5px 1px rgba(0, 0, 0, .084); 4 | $z-index-top-nav: 999; 5 | $nav-bar-bg: #ffffff; 6 | 7 | md-toolbar { 8 | height: $top-nav-height; 9 | position: fixed; 10 | z-index: $z-index-top-nav; 11 | background-color: $nav-bar-bg !important; 12 | box-shadow: $top-nav-box-shadow; 13 | } 14 | 15 | .navigation-item { 16 | color: $dark-font-color; 17 | text-decoration: none; 18 | padding: $unit-sm; 19 | text-transform: uppercase; 20 | font-weight: $font-bold; 21 | font-size: $font-size-regular; 22 | 23 | &.navigation-item--active { 24 | border-bottom: 3px solid $warn; 25 | } 26 | } 27 | 28 | .navigation-item-menu--active { 29 | color: $warn; 30 | } 31 | 32 | .nav-bar__title { 33 | padding-left: $unit-sm; 34 | } 35 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/nav-bar/nav-bar.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, Input, OnInit} from '@angular/core'; 2 | import {NavigationItem} from "../main-layout.types"; 3 | 4 | @Component({ 5 | selector: 'nav-bar', 6 | templateUrl: './nav-bar.component.html', 7 | styleUrls: ['./nav-bar.component.scss'] 8 | }) 9 | export class NavBarComponent implements OnInit { 10 | 11 | @Input() 12 | public menuItems: NavigationItem[] = []; 13 | 14 | @Input() 15 | public hasSideNav: boolean = false; 16 | 17 | @Input() 18 | public title: string = ''; 19 | 20 | @Input() 21 | public logoUrl: string = ''; 22 | 23 | constructor() { 24 | } 25 | 26 | ngOnInit() { 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/side-nav/side-nav.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 7 | {{ item.name }} 8 | 9 | 10 |
11 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/side-nav/side-nav.component.scss: -------------------------------------------------------------------------------- 1 | @import "../../../styles/main"; 2 | 3 | $side-nav-item-active-bg: rgba(0, 0, 0, .04); 4 | .side-nav__item--active { 5 | background-color: $side-nav-item-active-bg; 6 | border-left: 3px solid $warn; 7 | } 8 | 9 | .side-nav__item { 10 | cursor: pointer; 11 | padding: $unit-sm $unit-xs; 12 | } 13 | -------------------------------------------------------------------------------- /frontend/src/app/shared/layouts/main-layout/side-nav/side-nav.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, Input, OnInit} from '@angular/core'; 2 | import {NavigationItem} from "../main-layout.types"; 3 | 4 | @Component({ 5 | selector: 'side-nav', 6 | templateUrl: './side-nav.component.html', 7 | styleUrls: ['./side-nav.component.scss'] 8 | }) 9 | 10 | export class SideNavComponent implements OnInit { 11 | @Input() 12 | public menuItems: NavigationItem[]; 13 | 14 | constructor() { 15 | } 16 | 17 | ngOnInit() { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /frontend/src/app/shared/shared.module.ts: -------------------------------------------------------------------------------- 1 | import {NgModule} from '@angular/core'; 2 | import {CommonModule} from "@angular/common"; 3 | import {RouterModule} from "@angular/router"; 4 | import {FormsModule, ReactiveFormsModule} from "@angular/forms"; 5 | import {HttpModule} from "@angular/http"; 6 | import { 7 | MdButtonModule, MdCardModule, MdIconModule, MdInputModule, MdListModule, MdSidenavModule, MdToolbarModule, 8 | MdTooltipModule, MdProgressBarModule, MdSlideToggleModule, MdDialogModule, MdMenuModule, MdSliderModule, 9 | MdTabsModule, MdCheckboxModule, MdRadioModule, MdChipsModule, MdDatepickerModule, MdNativeDateModule, MdTableModule, 10 | MdCoreModule, MdSortModule, MdPaginatorModule 11 | } from "@angular/material"; 12 | import {CdkTableModule} from "@angular/cdk"; 13 | import {FlexLayoutModule} from "@angular/flex-layout"; 14 | import {NgxChartsModule} from '@swimlane/ngx-charts'; 15 | import {MainLayoutModule} from "./layouts/main-layout/main-layout.module"; 16 | 17 | @NgModule({ 18 | imports: [ 19 | // Angular Modules 20 | CommonModule, 21 | FormsModule, 22 | ReactiveFormsModule, 23 | RouterModule, 24 | HttpModule, 25 | FlexLayoutModule, 26 | // Material Modules 27 | MdTooltipModule, 28 | MdButtonModule, 29 | MdCardModule, 30 | MdDialogModule, 31 | MdInputModule, 32 | MdSidenavModule, 33 | MdToolbarModule, 34 | MdIconModule, 35 | MdListModule, 36 | MdProgressBarModule, 37 | MdSlideToggleModule, 38 | MdMenuModule, 39 | MdSliderModule, 40 | MdTabsModule, 41 | MdCheckboxModule, 42 | MdRadioModule, 43 | MdChipsModule, 44 | MdDatepickerModule, 45 | MdNativeDateModule, 46 | MdTableModule, 47 | CdkTableModule, 48 | MdCoreModule, 49 | MdSortModule, 50 | MdPaginatorModule, 51 | // Chart module 52 | NgxChartsModule, 53 | MainLayoutModule 54 | ], 55 | exports: [ 56 | // Angular Modules 57 | CommonModule, 58 | FormsModule, 59 | ReactiveFormsModule, 60 | RouterModule, 61 | HttpModule, 62 | FlexLayoutModule, 63 | // Material Modules 64 | MdTooltipModule, 65 | MdButtonModule, 66 | MdCardModule, 67 | MdDialogModule, 68 | MdInputModule, 69 | MdSidenavModule, 70 | MdToolbarModule, 71 | MdIconModule, 72 | MdListModule, 73 | MdProgressBarModule, 74 | MdSlideToggleModule, 75 | MdMenuModule, 76 | MdSliderModule, 77 | MdSliderModule, 78 | MdTabsModule, 79 | MdCheckboxModule, 80 | MdRadioModule, 81 | MdChipsModule, 82 | MdDatepickerModule, 83 | MdNativeDateModule, 84 | MdTableModule, 85 | CdkTableModule, 86 | MdCoreModule, 87 | MdSortModule, 88 | // Chart module 89 | NgxChartsModule, 90 | MainLayoutModule 91 | ], 92 | declarations: [], 93 | providers: [ 94 | ], 95 | entryComponents: [] 96 | }) 97 | export class SharedModule { 98 | } 99 | -------------------------------------------------------------------------------- /frontend/src/app/shared/styles/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/delsner/flask-angular-data-science/ac382881684c8cf8a849007fd4558e255260ce91/frontend/src/app/shared/styles/.gitkeep -------------------------------------------------------------------------------- /frontend/src/app/shared/styles/_custom.scss: -------------------------------------------------------------------------------- 1 | @import "./variables"; 2 | 3 | // get fonts from CDN 4 | @import url('https://fonts.googleapis.com/css?family=Raleway'); 5 | @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); 6 | 7 | // general styles 8 | * { 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | font-family: 'Raleway', sans-serif; 12 | } 13 | 14 | input:focus, 15 | select:focus, 16 | textarea:focus, 17 | button:focus { 18 | outline: none; 19 | } 20 | 21 | html, 22 | body { 23 | width: 100%; 24 | margin: 0; 25 | height: 100%; 26 | background-color: $light-gray-bg; 27 | } 28 | 29 | // helper classes 30 | .full-height { 31 | height: 100%; 32 | } 33 | 34 | .full-width { 35 | max-width: 100%; 36 | } 37 | 38 | .cursor-pointer { 39 | cursor: pointer; 40 | } 41 | 42 | .highlighted { 43 | color: $warn; 44 | } 45 | 46 | .text-color-light { 47 | * { 48 | color: $light-font-color !important; 49 | 50 | } 51 | } 52 | 53 | // custom card style 54 | $card-bg: #ffffff; 55 | .card { 56 | box-shadow: 0 3px 1px -2px rgba(0, 0, 0, .2), 0 2px 2px 0 rgba(0, 0, 0, .14), 0 1px 5px 0 rgba(0, 0, 0, .12); 57 | transition: box-shadow 280ms cubic-bezier(.4, 0, .2, 1); 58 | -webkit-border-radius: 2px; 59 | -moz-border-radius: 2px; 60 | border-radius: 2px; 61 | background-color: $card-bg; 62 | } 63 | 64 | // custom table design 65 | $table-box-shadow: 0 5px 5px -3px rgba(0, 0, 0, .2), 0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12); 66 | .table__box-shadow { 67 | box-shadow: $table-box-shadow; 68 | -moz-box-shadow: $table-box-shadow; 69 | -o-box-shadow: $table-box-shadow; 70 | -webkit-box-shadow: $table-box-shadow; 71 | } 72 | 73 | .table__cell--highlighted { 74 | &:hover { 75 | cursor: pointer; 76 | background-color: $light-gray-bg; 77 | } 78 | } 79 | 80 | // override max width of dialog 81 | md-dialog-container.mat-dialog-container { 82 | max-width: 100vw; 83 | padding: 0; 84 | } 85 | 86 | md-dialog-content.mat-dialog-content { 87 | max-height: inherit; 88 | } 89 | 90 | // removes focus border around elements 91 | :focus { 92 | outline: -webkit-focus-ring-color auto 0; 93 | } 94 | 95 | .material-icons { 96 | font-family: 'Material Icons'; 97 | font-weight: normal; 98 | font-style: normal; 99 | font-size: 24px; /* Preferred icon size */ 100 | display: inline-block; 101 | line-height: 1; 102 | text-transform: none; 103 | letter-spacing: normal; 104 | word-wrap: normal; 105 | white-space: nowrap; 106 | direction: ltr; 107 | 108 | /* Support for all WebKit browsers. */ 109 | -webkit-font-smoothing: antialiased; 110 | /* Support for Safari and Chrome. */ 111 | text-rendering: optimizeLegibility; 112 | 113 | /* Support for Firefox. */ 114 | -moz-osx-font-smoothing: grayscale; 115 | 116 | /* Support for IE. */ 117 | font-feature-settings: 'liga'; 118 | 119 | } 120 | 121 | // browser-specific stuff 122 | // fix safari flex issue (https://github.com/angular/flex-layout/issues/201) 123 | div[fxLayout="column"] > div[fxFlex] { 124 | flex: 1 0 auto !important; 125 | } 126 | -------------------------------------------------------------------------------- /frontend/src/app/shared/styles/_theming.scss: -------------------------------------------------------------------------------- 1 | @import '~@angular/material/theming'; 2 | 3 | $dark-gray: ( 4 | 50 : #e4e5e6, 5 | 100 : #babdc0, 6 | 200 : #8d9296, 7 | 300 : #5f666b, 8 | 400 : #3c454c, 9 | 500 : #1a242c, 10 | 600 : #172027, 11 | 700 : #131b21, 12 | 800 : #0f161b, 13 | 900 : #080d10, 14 | A100 : #54bbff, 15 | A200 : #21a6ff, 16 | A400 : #008eed, 17 | A700 : #007fd4, 18 | contrast: ( 19 | 50 : #000000, 20 | 100 : #000000, 21 | 200 : #000000, 22 | 300 : #ffffff, 23 | 400 : #ffffff, 24 | 500 : #ffffff, 25 | 600 : #ffffff, 26 | 700 : #ffffff, 27 | 800 : #ffffff, 28 | 900 : #ffffff, 29 | A100 : #000000, 30 | A200 : #000000, 31 | A400 : #ffffff, 32 | A700 : #ffffff, 33 | ) 34 | ); 35 | 36 | $light-orange: ( 37 | 50 : #fceee1, 38 | 100 : #f8d5b3, 39 | 200 : #f3b981, 40 | 300 : #ee9d4f, 41 | 400 : #ea8829, 42 | 500 : #e67303, 43 | 600 : #e36b03, 44 | 700 : #df6002, 45 | 800 : #db5602, 46 | 900 : #d54301, 47 | A100 : #fffdfc, 48 | A200 : #ffd7c9, 49 | A400 : #ffb096, 50 | A700 : #ff9d7d, 51 | contrast: ( 52 | 50 : #000000, 53 | 100 : #000000, 54 | 200 : #000000, 55 | 300 : #000000, 56 | 400 : #000000, 57 | 500 : #000000, 58 | 600 : #000000, 59 | 700 : #ffffff, 60 | 800 : #ffffff, 61 | 900 : #ffffff, 62 | A100 : #000000, 63 | A200 : #000000, 64 | A400 : #000000, 65 | A700 : #000000, 66 | ) 67 | ); 68 | 69 | $red: ( 70 | 50 : #fce3e9, 71 | 100 : #f8b9c8, 72 | 200 : #f48ba3, 73 | 300 : #ef5d7e, 74 | 400 : #eb3a62, 75 | 500 : #e81746, 76 | 600 : #e5143f, 77 | 700 : #e21137, 78 | 800 : #de0d2f, 79 | 900 : #d80720, 80 | A100 : #ffffff, 81 | A200 : #ffcfd2, 82 | A400 : #ff9ca4, 83 | A700 : #ff828c, 84 | contrast: ( 85 | 50 : #000000, 86 | 100 : #000000, 87 | 200 : #000000, 88 | 300 : #000000, 89 | 400 : #ffffff, 90 | 500 : #ffffff, 91 | 600 : #ffffff, 92 | 700 : #ffffff, 93 | 800 : #ffffff, 94 | 900 : #ffffff, 95 | A100 : #000000, 96 | A200 : #000000, 97 | A400 : #000000, 98 | A700 : #000000, 99 | ) 100 | ); 101 | 102 | @include mat-core(); 103 | $app-primary: mat-palette($dark-gray); 104 | $app-accent: mat-palette($light-orange); 105 | $app-warn: mat-palette($red); 106 | $app-theme: mat-light-theme($app-primary, $app-accent, $app-warn); 107 | @include angular-material-theme($app-theme); 108 | -------------------------------------------------------------------------------- /frontend/src/app/shared/styles/_variables.scss: -------------------------------------------------------------------------------- 1 | // main colors 2 | $primary: #1a242c; 3 | $accent: #e67303; 4 | $warn: #e81746; 5 | 6 | // other colors 7 | $white-bg: #f7f7f7; 8 | $light-gray-bg: #f0f0f0; 9 | $dark-gray-bg: #121b22; 10 | 11 | // font colors 12 | $light-font-color: $white-bg; 13 | $dark-font-color: $dark-gray-bg; 14 | 15 | // font weights 16 | $font-light: 300; 17 | $font-regular: 400; 18 | $font-bold: 600; 19 | 20 | // font-sizes 21 | $font-size-xlarge: 36px; 22 | $font-size-large: 20px; 23 | $font-size-regular: 14px; 24 | $font-size-small: 12px; 25 | 26 | // sizes 27 | $unit-base: 8px; 28 | $unit-xs: 8px; 29 | $unit-sm: 16px; 30 | $unit-md: 24px; 31 | $unit-lg: 32px; 32 | $unit-xl: 40px; 33 | 34 | // screen sizes 35 | $xs: 0px; 36 | $sm: 600px; 37 | $md: 960px; 38 | $lg: 1280px; 39 | $xl: 1920px; 40 | 41 | $screen-xs-min: 0; 42 | $screen-sm-min: $sm !default; 43 | $screen-md-min: $md !default; 44 | $screen-lg-min: $lg !default; 45 | $screen-xl-min: $xl !default; 46 | 47 | $screen-xs-max: ($screen-sm-min - 1) !default; 48 | $screen-sm-max: ($screen-md-min - 1) !default; 49 | $screen-md-max: ($screen-lg-min - 1) !default; 50 | $screen-lg-max: ($screen-xl-min - 1) !default; 51 | $screen-xl-max: 20000px; 52 | 53 | // components 54 | 55 | $top-nav-height: 60px; 56 | -------------------------------------------------------------------------------- /frontend/src/app/shared/styles/main.scss: -------------------------------------------------------------------------------- 1 | @import 'variables'; 2 | @import 'theming'; 3 | @import 'custom'; 4 | -------------------------------------------------------------------------------- /frontend/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/delsner/flask-angular-data-science/ac382881684c8cf8a849007fd4558e255260ce91/frontend/src/assets/.gitkeep -------------------------------------------------------------------------------- /frontend/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /frontend/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /frontend/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Data Science Web Application 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /frontend/src/main.ts: -------------------------------------------------------------------------------- 1 | import {enableProdMode} from '@angular/core'; 2 | import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; 3 | 4 | import {AppModule} from './app/app.module'; 5 | import {environment} from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule); 12 | -------------------------------------------------------------------------------- /frontend/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | import 'core-js/es6/symbol'; 23 | import 'core-js/es6/object'; 24 | import 'core-js/es6/function'; 25 | import 'core-js/es6/parse-int'; 26 | import 'core-js/es6/parse-float'; 27 | import 'core-js/es6/number'; 28 | import 'core-js/es6/math'; 29 | import 'core-js/es6/string'; 30 | import 'core-js/es6/date'; 31 | import 'core-js/es6/array'; 32 | import 'core-js/es6/regexp'; 33 | import 'core-js/es6/map'; 34 | import 'core-js/es6/weak-map'; 35 | import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** Evergreen browsers require these. **/ 41 | import 'core-js/es6/reflect'; 42 | import 'core-js/es7/reflect'; 43 | 44 | 45 | /** 46 | * Required to support Web Animations `@angular/animation`. 47 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 48 | **/ 49 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 50 | 51 | 52 | /*************************************************************************************************** 53 | * Zone JS is required by Angular itself. 54 | */ 55 | import 'zone.js/dist/zone'; // Included with Angular CLI. 56 | 57 | 58 | /*************************************************************************************************** 59 | * APPLICATION IMPORTS 60 | */ 61 | 62 | /** 63 | * Date, currency, decimal and percent pipes. 64 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 65 | */ 66 | // import 'intl'; // Run `npm install --save intl`. 67 | /** 68 | * Need to import at least one locale-data with intl. 69 | */ 70 | // import 'intl/locale-data/jsonp/en'; 71 | -------------------------------------------------------------------------------- /frontend/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import "./app/shared/styles/main"; 3 | 4 | -------------------------------------------------------------------------------- /frontend/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015", 7 | "types": [] 8 | }, 9 | "exclude": [ 10 | "test.ts", 11 | "**/*.spec.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /frontend/src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: NodeModule; 3 | 4 | interface NodeModule { 5 | id: string; 6 | } 7 | -------------------------------------------------------------------------------- /frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "typeRoots": [ 12 | "node_modules/@types" 13 | ], 14 | "lib": [ 15 | "es2016", 16 | "dom" 17 | ] 18 | } 19 | } 20 | --------------------------------------------------------------------------------