mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-07 09:26:34 +00:00

* 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
122 lines
2.8 KiB
JavaScript
122 lines
2.8 KiB
JavaScript
const fs = require('fs');
|
|
const gulp = require('gulp');
|
|
const rollupEach = require('gulp-rollup-each');
|
|
const commonjs = require('rollup-plugin-commonjs');
|
|
const nodeResolve = require('rollup-plugin-node-resolve');
|
|
const replace = require('rollup-plugin-replace');
|
|
const babel = require('rollup-plugin-babel');
|
|
const uglify = require('../common/gulp-uglify.js');
|
|
|
|
const DEV = !!JSON.parse(process.env.BUILD_DEV || 'true');
|
|
const DEMO = !!JSON.parse(process.env.BUILD_DEMO || 'false');
|
|
const version = fs.readFileSync('setup.py', 'utf8').match(/\d{8}[^']*/);
|
|
if (!version) {
|
|
throw Error('Version not found');
|
|
}
|
|
const VERSION = version[0];
|
|
|
|
function getRollupInputOptions(es6) {
|
|
const babelOpts = {
|
|
babelrc: false,
|
|
plugins: [
|
|
'external-helpers',
|
|
'transform-object-rest-spread',
|
|
[
|
|
'transform-react-jsx',
|
|
{
|
|
pragma: 'h'
|
|
}
|
|
],
|
|
]
|
|
};
|
|
|
|
if (!es6) {
|
|
babelOpts.presets = [
|
|
[
|
|
'env',
|
|
{
|
|
modules: false
|
|
}
|
|
]
|
|
];
|
|
}
|
|
|
|
return {
|
|
plugins: [
|
|
babel(babelOpts),
|
|
|
|
nodeResolve({
|
|
jsnext: true,
|
|
main: true,
|
|
}),
|
|
|
|
commonjs(),
|
|
|
|
replace({
|
|
values: {
|
|
__DEV__: JSON.stringify(DEV),
|
|
__DEMO__: JSON.stringify(DEMO),
|
|
__BUILD__: JSON.stringify(es6 ? 'latest' : 'es5'),
|
|
__VERSION__: JSON.stringify(VERSION),
|
|
__ROOT__: JSON.stringify(es6 ? 'frontend_latest' : 'frontend_es5'),
|
|
},
|
|
}),
|
|
],
|
|
};
|
|
}
|
|
|
|
const rollupOutputOptions = {
|
|
format: 'iife',
|
|
exports: 'none',
|
|
};
|
|
|
|
gulp.task('run_rollup_es5', () => gulp.src([
|
|
'js/core.js',
|
|
'js/compatibility.js',
|
|
'demo_data/demo_data.js',
|
|
])
|
|
.pipe(rollupEach(getRollupInputOptions(/* es6= */ false), rollupOutputOptions))
|
|
.on('error', err => console.error(err.message))
|
|
.pipe(gulp.dest('build-temp-es5')));
|
|
|
|
gulp.task('run_rollup', () => gulp.src([
|
|
'js/core.js',
|
|
'js/panel-config/panel-config.js',
|
|
'js/util.js',
|
|
'demo_data/demo_data.js',
|
|
])
|
|
.pipe(rollupEach(getRollupInputOptions(/* es6= */ true), rollupOutputOptions))
|
|
.on('error', err => console.error(err.message))
|
|
.pipe(gulp.dest('build-temp')));
|
|
|
|
gulp.task('ru_all_es5', ['run_rollup_es5'], () => {
|
|
gulp.src([
|
|
'build-temp-es5/core.js',
|
|
'build-temp-es5/compatibility.js',
|
|
])
|
|
.pipe(uglify(/* es6= */ false, { sourceMap: false }))
|
|
.pipe(gulp.dest('build-es5/'));
|
|
});
|
|
|
|
gulp.task('ru_all', ['run_rollup'], () => {
|
|
gulp.src([
|
|
'build-temp/core.js',
|
|
])
|
|
.pipe(uglify(/* es6= */ true, { sourceMap: false }))
|
|
.pipe(gulp.dest('build/'));
|
|
});
|
|
|
|
gulp.task('watch_ru_all', ['ru_all'], () => {
|
|
gulp.watch([
|
|
'js/**/*.js',
|
|
'demo_data/**/*.js'
|
|
], ['ru_all']);
|
|
});
|
|
|
|
gulp.task('watch_ru_all_es5', ['ru_all_es5'], () => {
|
|
gulp.watch([
|
|
'js/**/*.js',
|
|
'demo_data/**/*.js'
|
|
], ['ru_all_es5']);
|
|
});
|