mirror of https://github.com/akveo/blur-admin
add a hot reload page example
parent
f89cdf0916
commit
f47011d6d5
|
@ -9,12 +9,18 @@ var browserSync = require('browser-sync');
|
|||
var $ = require('gulp-load-plugins')();
|
||||
|
||||
|
||||
gulp.task('scripts-reload', function() {
|
||||
gulp.task('scripts-reload', function () {
|
||||
|
||||
var bsOptions = {};
|
||||
if (conf._gulpWatchEvent) {
|
||||
bsOptions.match = conf._gulpWatchEvent.path;
|
||||
}
|
||||
|
||||
return buildScripts()
|
||||
.pipe(browserSync.stream());
|
||||
.pipe(browserSync.stream(bsOptions));
|
||||
});
|
||||
|
||||
gulp.task('scripts', function() {
|
||||
gulp.task('scripts', function () {
|
||||
return buildScripts();
|
||||
});
|
||||
|
||||
|
|
|
@ -47,6 +47,18 @@ browserSync.use(browserSyncSpa({
|
|||
selector: '[ng-app]'// Only needed for angular apps
|
||||
}));
|
||||
|
||||
var bsInjular = require('bs-injular');
|
||||
|
||||
browserSync.use(bsInjular, {
|
||||
templates: ['/app/pages/**/*.html','/app/my-module/**/*.html'],
|
||||
controllers: ['/app/pages/**/*.controller.js','/app/my-module/**/*.controller.js'],
|
||||
directives: ['/app/pages/**/*.directive.js','/app/my-module/**/*.directive.js'],
|
||||
filters: ['/app/pages/**/*.filter.js','/app/pages/**/*.filter.js'],
|
||||
angularFile: '/bower_components/angular/angular.js',
|
||||
moduleFile: '/app/app.js',
|
||||
ngApp: 'BlurAdmin'
|
||||
});
|
||||
|
||||
gulp.task('serve', ['watch'], function () {
|
||||
browserSyncInit([path.join(conf.paths.tmp, '/serve'), conf.paths.src]);
|
||||
});
|
||||
|
|
|
@ -34,6 +34,7 @@ var buildStyles = function () {
|
|||
|
||||
var injectFiles = gulp.src([
|
||||
path.join(conf.paths.src, '/sass/**/_*.scss'),
|
||||
path.join(conf.paths.src, '/app/**/*.scss'),
|
||||
'!' + path.join(conf.paths.src, '/sass/theme/conf/**/*.scss'),
|
||||
'!' + path.join(conf.paths.src, '/sass/404.scss'),
|
||||
'!' + path.join(conf.paths.src, '/sass/auth.scss')
|
||||
|
|
|
@ -16,7 +16,9 @@ gulp.task('watch', ['inject'], function () {
|
|||
|
||||
gulp.watch([
|
||||
path.join(conf.paths.src, '/sass/**/*.css'),
|
||||
path.join(conf.paths.src, '/sass/**/*.scss')
|
||||
path.join(conf.paths.src, '/sass/**/*.scss'),
|
||||
path.join(conf.paths.src, '/app/**/*.scss')
|
||||
|
||||
], function(event) {
|
||||
if(isOnlyChange(event)) {
|
||||
gulp.start('styles-reload');
|
||||
|
@ -26,11 +28,13 @@ gulp.task('watch', ['inject'], function () {
|
|||
});
|
||||
|
||||
gulp.watch(path.join(conf.paths.src, '/app/**/*.js'), function(event) {
|
||||
conf._gulpWatchEvent = event;
|
||||
if(isOnlyChange(event)) {
|
||||
gulp.start('scripts-reload');
|
||||
} else {
|
||||
gulp.start('inject-reload');
|
||||
}
|
||||
delete conf._gulpWatchEvent;
|
||||
});
|
||||
|
||||
gulp.watch(path.join(conf.paths.src, '/app/**/*.html'), function(event) {
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
"name": "blur_admin",
|
||||
"version": "1.2.0",
|
||||
"devDependencies": {
|
||||
"browser-sync": "~2.9.11",
|
||||
"browser-sync": "^2.18.2",
|
||||
"browser-sync-spa": "~1.0.3",
|
||||
"bs-injular": "^0.6.0",
|
||||
"chalk": "~1.1.1",
|
||||
"del": "~2.0.2",
|
||||
"eslint-plugin-angular": "~0.12.0",
|
||||
|
|
|
@ -14,5 +14,6 @@ angular.module('BlurAdmin', [
|
|||
'angular-progress-button-styles',
|
||||
|
||||
'BlurAdmin.theme',
|
||||
'BlurAdmin.pages'
|
||||
'BlurAdmin.pages',
|
||||
'my-module'
|
||||
]);
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
/**
|
||||
* Created by sguilly on 23/10/16.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/* @ngdoc object
|
||||
* @name models
|
||||
* @description
|
||||
*
|
||||
*/
|
||||
angular
|
||||
.module('my-module', [
|
||||
'my-page'
|
||||
]);
|
||||
}());
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Created by sguilly on 22/11/16.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @ngdoc object
|
||||
* @name category.controller:CategoriesCtrl
|
||||
*
|
||||
* @description
|
||||
*
|
||||
*/
|
||||
angular
|
||||
.module('my-page')
|
||||
.controller('MyPageCtrl', MyPageCtrl);
|
||||
|
||||
function MyPageCtrl($scope, $state,MyPageService) {
|
||||
|
||||
var vm = this;
|
||||
vm.ctrlName = 'My Hot Reload Page :)';
|
||||
|
||||
}
|
||||
}());
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Created by sguilly on 21/10/16.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Created by sguilly on 19/10/16.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// <div address-input max="77" ng-model="poi.address"></div>
|
||||
|
||||
angular
|
||||
.module('my-page')
|
||||
.directive('myPageDirective', myPageDirective);
|
||||
|
||||
function myPageDirective() {
|
||||
var directive = {
|
||||
restrict: 'EA',
|
||||
template: '<div class="blue">{{vm.text}} - {{vm.serviceText}}</div>'
|
||||
,
|
||||
scope: {
|
||||
|
||||
text: '=?',
|
||||
ngModel: '=',
|
||||
|
||||
},
|
||||
require: 'ngModel',
|
||||
controller: MyPageDirectiveCtrl,
|
||||
controllerAs: 'vm',
|
||||
bindToController: true
|
||||
};
|
||||
|
||||
return directive;
|
||||
}
|
||||
|
||||
MyPageDirectiveCtrl.$inject = ['HotReloadService'];
|
||||
function MyPageDirectiveCtrl(MyPageService) {
|
||||
var vm = this;
|
||||
|
||||
vm.serviceText = MyPageService.getText()
|
||||
|
||||
}
|
||||
|
||||
}());
|
|
@ -0,0 +1,9 @@
|
|||
<div class="widgets red">
|
||||
|
||||
{{vm.ctrlName}}
|
||||
|
||||
<my-page-directive text="'my directive text'"></my-page-directive>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Created by sguilly on 22/11/16.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/* @ngdoc object
|
||||
* @name categories
|
||||
* @description
|
||||
*
|
||||
*/
|
||||
angular
|
||||
.module('my-page', [
|
||||
'ui.router'
|
||||
]);
|
||||
}());
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Created by sguilly on 22/11/16.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('hotReloadPage')
|
||||
.config(config);
|
||||
|
||||
function config($stateProvider) {
|
||||
$stateProvider
|
||||
.state('my-page', {
|
||||
url: '/my-page',
|
||||
templateUrl: 'app/my-module/my-page/my-page.html',
|
||||
controller: 'MyPageCtrl',
|
||||
controllerAs: 'vm',
|
||||
title: 'my-page',
|
||||
sidebarMeta: {
|
||||
order: 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
}());
|
|
@ -0,0 +1,13 @@
|
|||
.blue {
|
||||
background-color: #777aff;
|
||||
color: white;
|
||||
margin : 20px;
|
||||
padding : 20px;
|
||||
}
|
||||
|
||||
.red {
|
||||
background-color: #e81c2e;
|
||||
color: white;
|
||||
margin : 20px;
|
||||
padding : 20px;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Created by sguilly on 22/11/16.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('my-page')
|
||||
|
||||
.service('MyPageService', function () {
|
||||
|
||||
this.getText = function()
|
||||
{
|
||||
return 'MyService'
|
||||
}
|
||||
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
/**
|
||||
* Created by sguilly on 23/10/16.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/* @ngdoc object
|
||||
* @name models
|
||||
* @description
|
||||
*
|
||||
*/
|
||||
angular
|
||||
.module('BlurAdmin.pages.hotReload', [
|
||||
'hotReloadPage'
|
||||
]);
|
||||
}());
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Created by sguilly on 22/11/16.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @ngdoc object
|
||||
* @name category.controller:CategoriesCtrl
|
||||
*
|
||||
* @description
|
||||
*
|
||||
*/
|
||||
angular
|
||||
.module('hotReloadPage')
|
||||
.controller('HotReloadCtrl', HotReloadCtrl);
|
||||
|
||||
function HotReloadCtrl($scope, $state,MyPageService) {
|
||||
|
||||
var vm = this;
|
||||
vm.ctrlName = 'Hot Reload Page';
|
||||
|
||||
}
|
||||
}());
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Created by sguilly on 21/10/16.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Created by sguilly on 19/10/16.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// <div address-input max="77" ng-model="poi.address"></div>
|
||||
|
||||
angular
|
||||
.module('hotReloadPage')
|
||||
.directive('hotReloadDirective', myPageDirective);
|
||||
|
||||
function myPageDirective() {
|
||||
var directive = {
|
||||
restrict: 'EA',
|
||||
template: '<div class="blue">{{vm.text}} - {{vm.serviceText}}</div>'
|
||||
,
|
||||
scope: {
|
||||
|
||||
text: '=?',
|
||||
ngModel:'=',
|
||||
|
||||
},
|
||||
require: 'ngModel',
|
||||
controller: HotReloadDirectiveCtrl,
|
||||
controllerAs: 'vm',
|
||||
bindToController: true
|
||||
};
|
||||
|
||||
return directive;
|
||||
}
|
||||
|
||||
HotReloadDirectiveCtrl.$inject = ['HotReloadService'];
|
||||
function HotReloadDirectiveCtrl(HotReloadService) {
|
||||
var vm = this;
|
||||
|
||||
vm.serviceText = HotReloadService.getText()
|
||||
|
||||
}
|
||||
|
||||
}());
|
|
@ -0,0 +1,47 @@
|
|||
<div class="widgets red">
|
||||
|
||||
{{vm.ctrlName}}
|
||||
|
||||
<hot-reload-directive text="'!!! Hot Reload Directive !!!'"></hot-reload-directive>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<h1>AngularJS 1.x hot reloading. This is a plugin for the awesome BrowserSync and bs-injular libs.</h1>
|
||||
|
||||
<br>
|
||||
|
||||
<h2>This supports template, controller, directive, component and filter injection.</h2>
|
||||
|
||||
<br>
|
||||
|
||||
<h2>See https://github.com/tfoxy/bs-injular for more details</h2>
|
||||
|
||||
<br>
|
||||
|
||||
<br>
|
||||
|
||||
<h3>Configuration in gulp/server.js</h3>
|
||||
|
||||
<textarea class="form-control" style="height: 400px">
|
||||
|
||||
browserSync.use(bsInjular, {
|
||||
|
||||
templates: ['/app/pages/**/*.html','/app/my-module/**/*.html'],
|
||||
controllers: ['/app/pages/**/*.controller.js','/app/my-module/**/*.controller.js'],
|
||||
directives: ['/app/pages/**/*.directive.js','/app/my-module/**/*.directive.js'],
|
||||
filters: ['/app/pages/**/*.filter.js','/app/pages/**/*.filter.js'],
|
||||
angularFile: '/bower_components/angular/angular.js',
|
||||
moduleFile: '/app/app.js',
|
||||
ngApp: 'BlurAdmin'
|
||||
|
||||
});
|
||||
|
||||
</textarea>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Created by sguilly on 22/11/16.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/* @ngdoc object
|
||||
* @name categories
|
||||
* @description
|
||||
*
|
||||
*/
|
||||
angular
|
||||
.module('hotReloadPage', [
|
||||
'ui.router'
|
||||
]);
|
||||
}());
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Created by sguilly on 22/11/16.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('hotReloadPage')
|
||||
.config(config);
|
||||
|
||||
function config($stateProvider) {
|
||||
$stateProvider
|
||||
.state('hotReload', {
|
||||
url: '/hotReload',
|
||||
templateUrl: 'app/pages/hotReload/hotReloadPage/hotReload.html',
|
||||
controller: 'HotReloadCtrl',
|
||||
controllerAs: 'vm',
|
||||
title: 'hotReloadPage',
|
||||
sidebarMeta: {
|
||||
order: 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
}());
|
|
@ -0,0 +1,7 @@
|
|||
.blue {
|
||||
background-color: #777aff;
|
||||
}
|
||||
|
||||
.red {
|
||||
background-color: #e81c2e;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Created by sguilly on 22/11/16.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('hotReloadPage')
|
||||
|
||||
.service('HotReloadService', function () {
|
||||
|
||||
this.getText = function()
|
||||
{
|
||||
return '[hotReload service text]'
|
||||
}
|
||||
|
||||
});
|
|
@ -16,6 +16,7 @@
|
|||
'BlurAdmin.pages.charts',
|
||||
'BlurAdmin.pages.maps',
|
||||
'BlurAdmin.pages.profile',
|
||||
'BlurAdmin.pages.hotReload',
|
||||
])
|
||||
.config(routeConfig);
|
||||
|
||||
|
|
Loading…
Reference in New Issue