Errores eslint, scripts dev

This commit is contained in:
Juan Ferrer Toribio 2017-05-16 12:37:48 +02:00
parent 30ad456eea
commit c4978b24fb
13 changed files with 72 additions and 72 deletions

View File

@ -2,12 +2,12 @@
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Notas</vn-title> <vn-title>Notas</vn-title>
<vn-horizontal ng-repeat="n in observation.observations" margin-small-bottom style="align-items: center;"> <vn-horizontal ng-repeat="n in observation.observations" margin-small-bottom style="align-items: center;">
<vn-auto style="border-radius: .3em;" class="pad-small border-solid"> <vn-auto style="border-radius: .3em;" class="pad-small border-solid">
<div class="notes-date">{{n.created | date:'dd/MM/yyyy HH:mm'}}</div> <div class="notes-date">{{n.created | date:'dd/MM/yyyy HH:mm'}}</div>
<div class="notes-date">{{n.employee.name}}</div> <div class="notes-date">{{n.employee.name}}</div>
<div>{{n.text}}</div> <div>{{n.text}}</div>
</vn-auto> </vn-auto>
</vn-horizontal> </vn-horizontal>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>
<vn-float-button <vn-float-button

View File

@ -6,18 +6,17 @@ import {kebabToCamel} from '../lib/string';
* Registers a click handler on the element that opens the dialog id * Registers a click handler on the element that opens the dialog id
* specified as value. * specified as value.
*/ */
directive.$inject = ['$document']; export function directive() {
export function directive($document) {
return { return {
restrict: 'A', restrict: 'A',
link: function($scope, $element, $attrs) { link: function($scope, $element, $attrs) {
$element.on('click', function(event) { $element.on('click', function(event) {
let dialog = $scope[kebabToCamel($attrs['vnDialog'])]; let dialog = $scope[kebabToCamel($attrs.vnDialog)];
if(dialog instanceof Dialog) if (dialog instanceof Dialog)
dialog.show(); dialog.show();
event.preventDefault(); event.preventDefault();
}); });
} }
} };
} }
module.directive('vnDialog', directive); module.directive('vnDialog', directive);

View File

@ -11,17 +11,17 @@ export function directive() {
let input = $element[0]; let input = $element[0];
let selector = 'input, textarea, button, submit'; let selector = 'input, textarea, button, submit';
if(!input.matches(selector)) if (!input.matches(selector))
input = input.querySelector(selector); input = input.querySelector(selector);
if(!input) { if (!input) {
console.warn(`vnFocus: Can't find a focusable element`); console.warn(`vnFocus: Can't find a focusable element`);
return; return;
} }
input.focus(); input.focus();
if(input.select) if (input.select)
input.select(); input.select();
}); });
} }

View File

@ -10,15 +10,15 @@ export function directive() {
restrict: 'A', restrict: 'A',
link: function($scope, $element, $attrs) { link: function($scope, $element, $attrs) {
let id = kebabToCamel($attrs.vnId); let id = kebabToCamel($attrs.vnId);
let controller = $element[0].$ctrl; let controller = $element.controller($element[0].tagName.toLowerCase());
if(!id) if (!id)
throw new Error(`vnId: Attribute can't be null`); throw new Error(`vnId: Attribute can't be null`);
if(!controller) if (!controller)
throw new Error(`vnId: Can't find controller for element '${id}'`); throw new Error(`vnId: Can't find controller for element '${id}'`);
$scope[id] = controller; $scope[id] = controller;
} }
}; };
}; }
module.directive('vnId', directive); module.directive('vnId', directive);

View File

@ -1,4 +1,4 @@
import './id'; import './id';
import './focus'; import './focus';
import './dialog'; import './dialog';
import './validation'; import './validation';

View File

@ -14,14 +14,14 @@ export default class Paging {
$scope.$watch('$ctrl.index.model.length', () => this.onModelUpdated()); $scope.$watch('$ctrl.index.model.length', () => this.onModelUpdated());
} }
$onChanges() { $onChanges() {
if(!this.index) return; if (!this.index) return;
this.numPerPage = this.index.filter.size; this.numPerPage = this.index.filter.size;
} }
onModelUpdated() { onModelUpdated() {
let index = this.index; let index = this.index;
let filter = index.filter; let filter = index.filter;
if(filter.page >= this.numPages if (filter.page >= this.numPages
&& index.model.length >= this.numPerPage) && index.model.length >= this.numPerPage)
this.numItems = filter.page * filter.size + 1; this.numItems = filter.page * filter.size + 1;
} }

View File

@ -5,13 +5,13 @@ directive.$inject = ['vnPopover'];
export function directive(popover) { export function directive(popover) {
return { return {
restrict: 'A', restrict: 'A',
link: function($scope, $element, $attrs, $ctrl) { link: function($scope, $element, $attrs) {
$element.on('click', function(event) { $element.on('click', function(event) {
popover.showComponent($attrs.vnDialog, $scope, $element); popover.showComponent($attrs.vnDialog, $scope, $element);
event.preventDefault(); event.preventDefault();
}); });
} }
} };
} }
module.directive('vnPopover', directive); module.directive('vnPopover', directive);
@ -24,7 +24,7 @@ export class Popover {
let popover = this.document.createElement('div'); let popover = this.document.createElement('div');
popover.className = 'vn-popover'; popover.className = 'vn-popover';
popover.addEventListener('mousedown', popover.addEventListener('mousedown',
(event) => this.onPopoverMouseDown(event)); event => this.onPopoverMouseDown(event));
popover.appendChild(childElement); popover.appendChild(childElement);
this.popover = popover; this.popover = popover;
@ -39,38 +39,38 @@ export class Popover {
let innerWidth = window.innerWidth; let innerWidth = window.innerWidth;
let innerHeight = window.innerHeight; let innerHeight = window.innerHeight;
if(width + dblMargin > innerWidth) { if (width + dblMargin > innerWidth) {
width = innerWidth - dblMargin; width = innerWidth - dblMargin;
style.width = width +'px'; style.width = width + 'px';
} }
if(height + dblMargin > innerHeight) { if (height + dblMargin > innerHeight) {
height = innerHeight - dblMargin; height = innerHeight - dblMargin;
style.height = height +'px'; style.height = height + 'px';
} }
if(parent) { if (parent) {
let parentNode = parent; let parentNode = parent;
let rect = parentNode.getBoundingClientRect(); let rect = parentNode.getBoundingClientRect();
let left = rect.left; let left = rect.left;
let top = rect.top + spacing + parentNode.offsetHeight; let top = rect.top + spacing + parentNode.offsetHeight;
if(left + width > innerWidth) if (left + width > innerWidth)
left -= (left + width) - innerWidth + margin; left -= (left + width) - innerWidth + margin;
if(top + height > innerHeight) if (top + height > innerHeight)
top -= height + parentNode.offsetHeight + spacing * 2; top -= height + parentNode.offsetHeight + spacing * 2;
if(left < 0) if (left < 0)
left = screenMargin; left = screenMargin;
if(top < 0) if (top < 0)
top = screenMargin; top = screenMargin;
style.top = (top) +'px'; style.top = (top) + 'px';
style.left = (left) +'px'; style.left = (left) + 'px';
style.minWidth = (rect.width) +'px'; style.minWidth = (rect.width) + 'px';
} }
this.document.body.appendChild(popover); this.document.body.appendChild(popover);
this.docMouseDownHandler = (event) => this.onDocMouseDown(event); this.docMouseDownHandler = event => this.onDocMouseDown(event);
this.document.addEventListener('mousedown', this.docMouseDownHandler); this.document.addEventListener('mousedown', this.docMouseDownHandler);
} }
showComponent(childComponent, $scope, parent) { showComponent(childComponent, $scope, parent) {
@ -79,7 +79,7 @@ export class Popover {
this.show(childElement, parent); this.show(childElement, parent);
} }
hide() { hide() {
if(!this.popover) return; if (!this.popover) return;
this.document.removeEventListener('mousedown', this.docMouseDownHandler); this.document.removeEventListener('mousedown', this.docMouseDownHandler);
this.document.body.removeChild(this.popover); this.document.body.removeChild(this.popover);
this.popover = null; this.popover = null;

View File

@ -17,7 +17,7 @@ class Controller {
// XXX: ¿Existe una forma más adecuada de acceder al controlador de un componente? // XXX: ¿Existe una forma más adecuada de acceder al controlador de un componente?
var childCtrl = angular.element(child).isolateScope().$ctrl; var childCtrl = angular.element(child).isolateScope().$ctrl;
childCtrl.onSubmit = (filter) => this.onChildSubmit(filter); childCtrl.onSubmit = filter => this.onChildSubmit(filter);
event.preventDefault(); event.preventDefault();
} }
@ -36,7 +36,7 @@ class Controller {
} }
Controller.$inject = ['$element', '$scope', '$document', '$compile', 'vnPopover', '$window']; Controller.$inject = ['$element', '$scope', '$document', '$compile', 'vnPopover', '$window'];
export const NAME = 'vnSearchbar' export const NAME = 'vnSearchbar';
export const COMPONENT = { export const COMPONENT = {
template: require('./searchbar.html'), template: require('./searchbar.html'),
bindings: { bindings: {

View File

@ -11,14 +11,13 @@ goto caseUsage
:caseStart :caseStart
call "%0" stop call "%0" stop
echo "################################ Starting services" echo "Starting nginx."
if not exist "%nginxPrefix%\temp" (mkdir "%nginxPrefix%\temp") if not exist "%nginxPrefix%\temp" (mkdir "%nginxPrefix%\temp")
start /I nginx -c "%nginxConf%" -p "%nginxPrefix%" start /I nginx -c "%nginxConf%" -p "%nginxPrefix%"
node dev.js
goto caseEnd goto caseEnd
:caseStop :caseStop
echo "################################ Stoping services" echo "Stoping nginx."
if exist "%nginxPrefix%\temp\nginx.pid" (nginx -c "%nginxConf%" -p "%nginxPrefix%" -s stop) if exist "%nginxPrefix%\temp\nginx.pid" (nginx -c "%nginxConf%" -p "%nginxPrefix%" -s stop)
goto caseEnd goto caseEnd

11
dev.js
View File

@ -1,11 +0,0 @@
require('./gulpfile');
var auth = require('./services/auth/server/server.js');
var client = require('./services/client/server/server.js');
var server = require('./services/salix/server/server.js');
var gulp = require('gulp');
gulp.start(['default']);
auth.start();
client.start();
server.start();

5
dev.sh
View File

@ -11,12 +11,11 @@ fi
case "$1" in case "$1" in
start|"") start|"")
$0 stop $0 stop
echo "################################ Starting services" echo "Starting nginx."
"$nginxBin" -c "$nginxConf" -p "$nginxPrefix" "$nginxBin" -c "$nginxConf" -p "$nginxPrefix"
node dev.js
;; ;;
stop) stop)
echo "################################ Stoping services" echo "Stoping nginx."
"$nginxBin" -c "$nginxConf" -p "$nginxPrefix" -s stop "$nginxBin" -c "$nginxConf" -p "$nginxPrefix" -s stop
;; ;;
*) *)

View File

@ -18,7 +18,19 @@ var langs = ['es', 'en'];
var modules = require('./spliting/modules.json'); var modules = require('./spliting/modules.json');
var webpackConfig = require('./webpack.config.js'); var webpackConfig = require('./webpack.config.js');
// Clean // Main tasks
gulp.task('build', ['clean'], function() {
return gulp.start('routes', 'locales', 'webpack');
});
gulp.task('default', ['clean'], function() {
return gulp.start('services', 'watch', 'routes', 'locales', 'webpack-dev-server');
});
gulp.task('client', ['clean'], function() {
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server');
});
gulp.task('clean', function() { gulp.task('clean', function() {
return del(`${buildDir}/*`, {force: true}); return del(`${buildDir}/*`, {force: true});
@ -140,12 +152,14 @@ gulp.task('watch', function() {
gulp.watch(localeFiles, ['locales']); gulp.watch(localeFiles, ['locales']);
}); });
// Default // Services
gulp.task('build', ['clean'], function() { gulp.task('services', function() {
return gulp.start('routes', 'locales', 'webpack'); var auth = require('./services/auth/server/server.js');
}); var client = require('./services/client/server/server.js');
var server = require('./services/salix/server/server.js');
gulp.task('default', ['clean'], function() { auth.start();
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server'); client.start();
server.start();
}); });

View File

@ -8,10 +8,10 @@ var config = {
entry: { entry: {
'bundle.salix': ['salix'], 'bundle.salix': ['salix'],
'bundle.auth': ['auth'], 'bundle.auth': ['auth'],
'bundle.vendor': ['vendor'] 'bundle.vendor': ['vendor']
}, },
output: { output: {
path: path.join (__dirname, './services/nginx/static'), path: path.join(__dirname, './services/nginx/static'),
filename: '[name].js', filename: '[name].js',
publicPath: '/static/', publicPath: '/static/',
chunkFilename: 'chunk.[name].[chunkhash].js' chunkFilename: 'chunk.[name].[chunkhash].js'
@ -49,22 +49,22 @@ var config = {
path.join(__dirname, 'client'), path.join(__dirname, 'client'),
__dirname, __dirname,
'node_modules', 'node_modules',
'/usr/lib/node_modules' '/usr/lib/node_modules'
] ]
}, },
plugins: [ plugins: [
new webpack.optimize.CommonsChunkPlugin({ new webpack.optimize.CommonsChunkPlugin({
names: ['bundle.vendor', 'bundle.manifest'] names: ['bundle.vendor', 'bundle.manifest']
}) })
], ],
devtool: 'source-map' devtool: 'source-map'
}; };
if (!devMode) { if (!devMode) {
config.plugins.push ( config.plugins.push(
new webpack.optimize.UglifyJsPlugin({ new webpack.optimize.UglifyJsPlugin({
minimize: true, minimize: true,
compress: { warnings: false } compress: {warnings: false}
}) })
); );
} }