frontend/script/build_frontend
Boyi C c6030e6edc Replace Google Charts with Chart.js (#429)
* chartjs test

* [WIP] Modified for Chart.js

* Tweaking styles ( tooltips and lines )

* Almost done
TODO:
Change tooltips to HTML tag
Improve color function

* More work on Tooltips

* Improve update logic
Fix linting

* resolve conflict

* [WIP]
Create new tooltip mode hack.
Add axis padding to top and botton to prevent axis cutoff

* TODO: cleanup

* FIXME: tooltip in history graph not working correctly
reorganize some code

* fix build problem

* Fix color and tooltip issue
Fix label max width for timeline chart

* update dep

* Fix strange color after build due to `uglify` bug with reference the minified version.
Make line chart behavior more similar to Google Charts.
Make the chart honor to `unknown` and other state by manually calculate point value.

* fix bugs

* Remove label for only one data in timeline chart.
Fix bug for infinite loop in some cases

* Add HTML legend to chart.

* Fix isSingleDevice bug due to calculation.
Add isSingleDevice property support.

* fix for lint

* Replace innerHTML code with polymer node.

* Replace tooltip with HTML code

* fix tooltip style

* move default tooltip mode to plugin

* LINTING

* fix
Move localize history data to Timeline Chart.
Fix timeline static color.
Rework on chart resize.

* Bug fix:
Chart may disappear on some case.
Timeline chart calculation issue.
Change timeline chart hidden logic.

* fix tooltip
rework for resize event

* lint

* element

* Replace `var` to `let`.
Move import and ChartJs injection code to `ha-chart-scripts.html`.

* lint: convert more let to const

* fix font
fix undef

* update bower.json

* move

* Load chart code on demand
2018-02-09 22:39:15 -08:00

71 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
# Builds the frontend for production
# Stop on errors
set -e
cd "$(dirname "$0")/.."
OUTPUT_DIR=hass_frontend
OUTPUT_DIR_ES5=hass_frontend_es5
rm -rf $OUTPUT_DIR $OUTPUT_DIR_ES5
cp -r public $OUTPUT_DIR
mkdir $OUTPUT_DIR_ES5
cp -r public/__init__.py $OUTPUT_DIR_ES5/
# Build frontend
BUILD_DEV=0 ./node_modules/.bin/gulp
# Entry points
cp build/*.js build/*.html $OUTPUT_DIR
cp build-es5/*.js build-es5/*.html $OUTPUT_DIR_ES5
# Panels
mkdir $OUTPUT_DIR/panels
cp build/panels/*.html $OUTPUT_DIR/panels
mkdir $OUTPUT_DIR_ES5/panels
cp build-es5/panels/*.html $OUTPUT_DIR_ES5/panels
# Chart code
cp build/src/resources/ha-chart-scripts.html $OUTPUT_DIR
cp build-es5/src/resources/ha-chart-scripts.html $OUTPUT_DIR_ES5
# Translations
cp -r build-translations/output $OUTPUT_DIR/translations
# Local Roboto
cp -r bower_components/font-roboto-local/fonts $OUTPUT_DIR
# Polyfill web components
cp bower_components/webcomponentsjs/webcomponents-lite.js $OUTPUT_DIR
cp bower_components/webcomponentsjs/custom-elements-es5-adapter.js $OUTPUT_DIR_ES5
# Icons
script/update_mdi.py
# Leaflet
mkdir $OUTPUT_DIR/images/leaflet
cp bower_components/leaflet/dist/leaflet.css $OUTPUT_DIR/images/leaflet
cp -r bower_components/leaflet/dist/images $OUTPUT_DIR/images/leaflet/
# Generate service worker
BUILD_DEV=0 ./node_modules/.bin/gulp gen-service-worker-es5
cp build-es5/service_worker.js $OUTPUT_DIR_ES5
BUILD_DEV=0 ./node_modules/.bin/gulp gen-service-worker
cp build/service_worker.js $OUTPUT_DIR
./node_modules/.bin/gulp compress
# Generate the __init__ file
echo "VERSION = '`git rev-parse HEAD`'" >> $OUTPUT_DIR/__init__.py
echo "CREATED_AT = `date +%s`" >> $OUTPUT_DIR/__init__.py
echo "VERSION = '`git rev-parse HEAD`'" >> $OUTPUT_DIR_ES5/__init__.py
echo "CREATED_AT = `date +%s`" >> $OUTPUT_DIR_ES5/__init__.py
# Generate the MD5 hash of the new frontend
script/fingerprint_frontend.py --base_dir $OUTPUT_DIR
script/fingerprint_frontend.py --base_dir $OUTPUT_DIR_ES5
./node_modules/.bin/gulp gen-index-html
./node_modules/.bin/gulp gen-index-html-es5