Reloading broser when helpers change
diff --git a/views/ngXosLib/.gitignore b/views/ngXosLib/.gitignore
index 9b2df09..34bf3a1 100644
--- a/views/ngXosLib/.gitignore
+++ b/views/ngXosLib/.gitignore
@@ -1,3 +1,4 @@
node_modules
bower_components
-docs
\ No newline at end of file
+docs
+xosHelpers/.tmp
\ No newline at end of file
diff --git a/views/ngXosLib/gulp/ngXosHelpers.js b/views/ngXosLib/gulp/ngXosHelpers.js
index f833fb8..7424218 100644
--- a/views/ngXosLib/gulp/ngXosHelpers.js
+++ b/views/ngXosLib/gulp/ngXosHelpers.js
@@ -5,10 +5,33 @@
var angularFilesort = require('gulp-angular-filesort');
var gulpDocs = require('gulp-ngdocs');
var del = require('del');
+var babel = require('gulp-babel');
+const sourcemaps = require('gulp-sourcemaps');
module.exports = function(options){
- gulp.task('helpers', function(){
- return gulp.src([options.xosHelperSource + '**/*.js'])
+
+ // transpile js with sourceMaps
+ gulp.task('babel', function(){
+ return gulp.src(options.xosHelperSource + '**/*.js')
+ .pipe(babel({
+ presets: ['es2015']
+ }))
+ .pipe(gulp.dest(options.xosHelperTmp));
+ });
+
+ gulp.task('babelDev', function(){
+ return gulp.src(options.xosHelperSource + '**/*.js')
+ .pipe(sourcemaps.init())
+ .pipe(babel({
+ presets: ['es2015']
+ }))
+ .pipe(sourcemaps.write('./maps'))
+ .pipe(gulp.dest(options.xosHelperTmp));
+ });
+
+ // build
+ gulp.task('helpers', ['babel'], function(){
+ return gulp.src([options.xosHelperTmp + '**/*.js'])
.pipe(angularFilesort())
.pipe(concat('ngXosHelpers.js'))
.pipe(ngAnnotate())
@@ -16,6 +39,15 @@
.pipe(gulp.dest(options.ngXosVendor));
});
+ // build Dev (no minify, sourcemaps)
+ gulp.task('helpersDev', ['babelDev'], function(){
+ return gulp.src([options.xosHelperTmp + '**/*.js'])
+ .pipe(angularFilesort())
+ .pipe(concat('ngXosHelpers.js'))
+ .pipe(ngAnnotate())
+ .pipe(gulp.dest(options.ngXosVendor));
+ });
+
gulp.task('cleanDocs', function(){
console.log(options);
return del([options.docs + '**/*']);
@@ -49,4 +81,8 @@
}
}).pipe(gulpDocs.process(ngOptions)).pipe(gulp.dest('./docs'));
});
+
+ gulp.task('dev', function(){
+ gulp.watch(options.xosHelperSource + '**/*.js', ['helpersDev']);
+ });
};
\ No newline at end of file
diff --git a/views/ngXosLib/gulpfile.js b/views/ngXosLib/gulpfile.js
index bb6bc5e..77a5c07 100644
--- a/views/ngXosLib/gulpfile.js
+++ b/views/ngXosLib/gulpfile.js
@@ -6,6 +6,7 @@
var options = {
ngXosVendor: '../../xos/core/xoslib/static/js/vendor/', //save here the minfied vendor file, this is automatically loaded in the django page
xosHelperSource: './xosHelpers/src/',
+ xosHelperTmp: './xosHelpers/.tmp/',
docs: './docs'
};
diff --git a/views/ngXosLib/package.json b/views/ngXosLib/package.json
index 486db22..c25c24a 100644
--- a/views/ngXosLib/package.json
+++ b/views/ngXosLib/package.json
@@ -28,9 +28,11 @@
"del": "^2.2.0",
"gulp": "^3.9.0",
"gulp-angular-filesort": "^1.1.1",
+ "gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.0",
"gulp-ng-annotate": "^1.1.0",
"gulp-ngdocs": "^0.2.13",
+ "gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.4.2",
"http-server": "^0.9.0",
"jasmine-core": "^2.4.1",
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js b/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
index faeaa26..692b49d 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
@@ -9,6 +9,7 @@
(function () {
'use strict';
+
angular.module('xos.uiComponents.table', [])
.directive('xosTable', function(){
return {
@@ -17,25 +18,26 @@
data: '=',
columns: '='
},
- template: [
- '<!--<pre>{{vm.data | json}}</pre>-->',
- '<table class="table table-striped" ng-show="vm.data.length > 0">',
- '<thead>',
- '<tr>',
- '<th ng-repeat="col in vm.columns">{{col}}</th>',
- '</tr>',
- '</thead>',
- '<tbody>',
- '<tr ng-repeat="item in vm.data">',
- '<td ng-repeat="col in vm.columns">{{item[col]}}</td>',
- '</tr>',
- '</tbody>',
- '</table>'
- ].join(),
+ template: `
+ <!--<pre>{{vm.data | json}}</pre>-->
+ <table class="table table-striped" ng-show="vm.data.length > 0">
+ <thead>
+ <tr>
+ <th ng-repeat="col in vm.columns">{{col}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat="item in vm.data">
+ <td ng-repeat="col in vm.columns">{{item[col]}}</td>
+ </tr>
+ </tbody>
+ </table>
+ `,
bindToController: true,
controllerAs: 'vm',
controller: function(){
console.log(this.data, this.columns);
+ console.log('Bella dello zio, RELOAD');
}
}
})
diff --git a/views/ngXosViews/sampleView/gulp/server.js b/views/ngXosViews/sampleView/gulp/server.js
index fe55ce3..3c6a8e3 100644
--- a/views/ngXosViews/sampleView/gulp/server.js
+++ b/views/ngXosViews/sampleView/gulp/server.js
@@ -3,6 +3,7 @@
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var inject = require('gulp-inject');
+var es = require('event-stream');
var runSequence = require('run-sequence');
var angularFilesort = require('gulp-angular-filesort');
var babel = require('gulp-babel');
@@ -10,6 +11,7 @@
var httpProxy = require('http-proxy');
var del = require('del');
var sass = require('gulp-sass');
+var debug = require('gulp-debug');
const environment = process.env.NODE_ENV;
@@ -60,7 +62,6 @@
// req.url.indexOf('/hpcapi/') !== -1 ||
req.url.indexOf('/api/') !== -1
){
- console.log('proxyed' + req.url);
if(conf.xoscsrftoken && conf.xossessionid){
req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
req.headers['x-csrftoken'] = conf.xoscsrftoken;
@@ -84,6 +85,11 @@
gulp.watch(options.css + '**/*.css', function(){
browserSync.reload();
});
+
+ gulp.watch(options.helpers + 'ngXosHelpers.js', function(){
+ browserSync.reload();
+ });
+
gulp.watch(`${options.sass}/**/*.scss`, ['sass'], function(){
browserSync.reload();
});
@@ -103,16 +109,40 @@
.pipe(gulp.dest(options.tmp));
});
+ // // inject sourceMap
+ // gulp.task('injectMaps', function(){
+ // return gulp.src(options.src + 'index.html')
+ // .pipe(
+ // inject(
+ // gulp.src([
+ // options.helpersSourceMaps + '**/*.js.map'
+ // ], {read: false}).pipe(debug()),
+ // {
+ // starttag: '<!-- inject:maps -->',
+ // // ignorePath: [options.src, '/../../ngXosLib']
+ // }
+ // )
+ // )
+ // .pipe(gulp.dest(options.src));
+ // });
+
// inject scripts
gulp.task('injectScript', ['cleanTmp', 'babel'], function(){
+
+ var appScripts = gulp.src([
+ options.tmp + '**/*.js',
+ options.helpers + 'ngXosHelpers.js'
+ ])
+ .pipe(angularFilesort()).pipe(debug());
+
+ var helpersSourceMaps = gulp.src([
+ options.helpersSourceMaps + '**/*.js.map'
+ ]).pipe(debug());
+
return gulp.src(options.src + 'index.html')
.pipe(
inject(
- gulp.src([
- options.tmp + '**/*.js',
- options.helpers + 'ngXosHelpers.js'
- ])
- .pipe(angularFilesort()),
+ es.merge(appScripts, helpersSourceMaps),
{
ignorePath: [options.src, '/../../ngXosLib']
}
diff --git a/views/ngXosViews/sampleView/gulpfile.js b/views/ngXosViews/sampleView/gulpfile.js
index 08df554..8b50345 100644
--- a/views/ngXosViews/sampleView/gulpfile.js
+++ b/views/ngXosViews/sampleView/gulpfile.js
@@ -12,6 +12,7 @@
dist: 'dist/',
api: '../../ngXosLib/api/',
helpers: '../../../xos/core/xoslib/static/js/vendor/',
+ helpersSourceMaps: '../../ngXosLib/xosHelpers/.tmp/maps/',
static: '../../../xos/core/xoslib/static/', // this is the django static folder
dashboards: '../../../xos/core/xoslib/dashboards/' // this is the django html folder
};
diff --git a/views/ngXosViews/sampleView/package.json b/views/ngXosViews/sampleView/package.json
index 0ffe32c..e92f937 100644
--- a/views/ngXosViews/sampleView/package.json
+++ b/views/ngXosViews/sampleView/package.json
@@ -28,12 +28,14 @@
"easy-mocker": "^1.2.0",
"eslint": "^1.8.0",
"eslint-plugin-angular": "linkmesrl/eslint-plugin-angular",
+ "event-stream": "^3.3.2",
"gulp": "^3.9.0",
"gulp-angular-filesort": "^1.1.1",
"gulp-angular-templatecache": "^1.8.0",
"gulp-babel": "^5.3.0",
"gulp-concat": "^2.6.0",
"gulp-concat-util": "^0.5.5",
+ "gulp-debug": "^2.1.2",
"gulp-eslint": "^1.0.0",
"gulp-inject": "^3.0.0",
"gulp-minify-html": "^1.0.4",
diff --git a/views/ngXosViews/sampleView/src/index.html b/views/ngXosViews/sampleView/src/index.html
index 5779012..d04fc3b 100644
--- a/views/ngXosViews/sampleView/src/index.html
+++ b/views/ngXosViews/sampleView/src/index.html
@@ -24,3 +24,6 @@
<script src="/../../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js"></script>
<script src="/.tmp/main.js"></script>
<!-- endinject -->
+
+<!-- inject:map -->
+<!-- endinject -->
\ No newline at end of file