Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
Javi Gallego 2018-02-14 11:34:47 +01:00
commit 225508dd07
24 changed files with 4454 additions and 169 deletions

View File

@ -55,17 +55,17 @@ describe('Directive zoomImage', () => {
let image = getCompiledImage(`<img src="${srcDefault}" zoom-image>`);
image[0].click();
findContainer = document.getElementById(idContainer);
let findNewImage = findContainer.querySelector('img');
let findNewImage = findContainer.querySelector('.zoomImage-background');
expect(findNewImage.src).toEqual(srcDefault);
expect(findNewImage.style.backgroundImage).toEqual(`url("${srcDefault}")`);
});
it('should create new image, into zoom container, with src likes zoomImage value', () => {
let image = getCompiledImage(`<img src="${srcDefault}" zoom-image="${srcZoom}">`);
image[0].click();
findContainer = document.getElementById(idContainer);
let findNewImage = findContainer.querySelector('img');
let findNewImage = findContainer.querySelector('.zoomImage-background');
expect(findNewImage.src).toEqual(srcZoom);
expect(findNewImage.style.backgroundImage).toEqual(`url("${srcZoom}")`);
});
});

View File

@ -4,7 +4,6 @@ export function directive($timeout) {
let idContainer = 'zoomImage';
let container;
let background;
let image;
function createContainers(src) {
if (document.getElementById(idContainer)) {
@ -15,31 +14,21 @@ export function directive($timeout) {
background = document.createElement('div');
background.className = 'zoomImage-background';
background.style.backgroundImage = `url(${src})`;
container.appendChild(background);
image = document.createElement('img');
image.src = src;
container.appendChild(image);
document.body.appendChild(container);
$timeout(() => {
resizeImage();
container.className = 'open';
}, 250);
}
function addListeners() {
background.addEventListener('click', destroyContainers);
document.addEventListener('keydown', e => keyDownHandler(e));
window.addEventListener('resize', resizeImage);
}
function removeListeners() {
if (container) {
background.removeEventListener('click', destroyContainers);
document.removeEventListener('keydown', e => keyDownHandler(e));
window.removeEventListener('resize', resizeImage);
}
}
@ -57,14 +46,6 @@ export function directive($timeout) {
container = undefined;
background = undefined;
image = undefined;
}
function resizeImage() {
if (image) {
image.style.marginLeft = `-${Math.floor(image.clientWidth / 2)}px`;
image.style.marginTop = `-${Math.floor(image.clientHeight / 2)}px`;
}
}
return {

View File

@ -9,32 +9,11 @@ div#zoomImage, div#zoomImage .zoomImage-background {
top: 0;
z-index: 11;
}
div#zoomImage{
opacity: 0;
transition: visibility 0s, opacity 0.5s linear;
}
div#zoomImage .zoomImage-background{
background: rgba(0, 0, 0, 0.7);
background-color: rgba(0, 0, 0, 0.7);
cursor: zoom-out;
}
div#zoomImage img{
z-index: 12;
position: fixed;
max-height: 98%;
max-width: 98%;
left: 50%;
top: 50%;
opacity: 0;
transition: visibility 0s, opacity 1s linear;
}
div#zoomImage.open {
visibility: visible;
opacity: 1;
}
div#zoomImage.open img{
visibility: visible;
opacity: 1;
background-repeat: no-repeat;
background-position: center center;
background-size: auto 98%;
}

View File

@ -1,8 +1,8 @@
salix: []
auth: []
core: []
client: []
production: []
route: []
locator: []
core: []
item: []
locator: []
production: []
salix: []
route: []

View File

@ -1,14 +1,5 @@
<div style="position: fixed; top: 0; right: 0; padding: .8em 1.5em; z-index: 10;">
<vn-icon icon="apps" id="apps" translate-attr="{title: 'Applications'}"></vn-icon>
<ul for="langs" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<li
ng-repeat="lang in ::$ctrl.langs"
class="mdl-menu__item"
ng-click="$ctrl.onChangeLangClick(lang)">
<span>{{::lang}}</span>
</li>
</ul>
<vn-icon icon="language" id="langs" translate-attr="{title: 'Change language'}"></vn-icon>
<ul for="apps" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<li ng-repeat="mod in ::$ctrl.modules" class="mdl-menu__item" ui-sref="{{::mod.route.state}}">
<vn-icon ng-if="::mod.icon && !mod.icon.startsWith('/')" icon="{{::mod.icon}}"></vn-icon>
@ -16,6 +7,16 @@
<span translate="{{::mod.name}}"></span>
</li>
</ul>
<vn-icon id="lang-button" icon="language" translate-attr="{title: 'Change language'}"></vn-icon>
<ul id="langs" for="lang-button" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<li
ng-repeat="lang in ::$ctrl.langs"
name="{{::lang}}"
class="mdl-menu__item"
ng-click="$ctrl.onChangeLangClick(lang)">
<span>{{::lang}}</span>
</li>
</ul>
<vn-icon icon="exit_to_app" translate-attr="{title: 'Logout'}" ng-click="$ctrl.onLogoutClick()"></vn-icon>
<!--
TODO: Keep it commented until they are functional

View File

@ -128,17 +128,17 @@ Nightmare.action('waitForTextInElement', function(selector, name, done) {
});
Nightmare.action('changeLanguageToEnglish', function(done) {
this.wait(selectors.globalItems.languageButton)
this.wait('#lang-button')
.evaluate(selector => {
return document.querySelector(selector).title;
}, selectors.globalItems.languageButton)
.then(result => {
if (result === 'Cambiar idioma') {
this.click(selectors.globalItems.languageButton)
.then(done);
}
if (result === 'Change language') {
}, '#lang-button')
.then(title => {
if (title === 'Change language') {
this.then(done);
} else {
this.click('#lang-button')
.click('#langs > li[name="en"]')
.then(done);
}
});
});

View File

@ -10,7 +10,6 @@ export default {
globalItems: {
topBar: `${components.vnTopbar}`,
logOutButton: `${components.vnIcon}[icon="exit_to_app"]`,
languageButton: `${components.vnIcon}[icon="language"]`,
snackbarIsActive: '.mdl-snackbar--active > .mdl-snackbar__text',
applicationsMenuButton: `${components.vnIcon}[icon="apps"]`,
applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`,

View File

@ -9,28 +9,30 @@ const log = require('fancy-log');
// Configuration
const isWindows = /^win/.test(process.platform);
let isWindows = /^win/.test(process.platform);
if (argv.NODE_ENV)
process.env.NODE_ENV = argv.NODE_ENV;
const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
const langs = ['es', 'en'];
const srcDir = './client';
const servicesDir = './services';
const nginxDir = `${servicesDir}/nginx`;
const buildDir = `${nginxDir}/static`;
let langs = ['es', 'en'];
let srcDir = './client';
let servicesDir = './services';
let wpConfig = require('./webpack.config.yml');
let buildDir = wpConfig.buildDir;
let devServerPort = wpConfig.devServerPort;
let nginxDir = `${servicesDir}/nginx`;
let proxyConf = require(`${nginxDir}/config.yml`);
let proxyEnvFile = `${nginxDir}/config.${env}.yml`;
if (fs.existsSync(proxyEnvFile))
Object.assign(proxyConf, require(proxyEnvFile));
const defaultService = proxyConf.main;
const defaultPort = proxyConf.defaultPort;
const devServerPort = proxyConf.devServerPort;
let defaultService = proxyConf.main;
let defaultPort = proxyConf.defaultPort;
// Development
@ -42,30 +44,51 @@ gulp.task('client', ['build-clean'], () => {
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server');
});
/**
* Starts all backend services, including the nginx proxy and the database.
*/
gulp.task('services', async () => {
await runSequenceP('docker-start', 'services-only', 'nginx');
});
/**
* Starts backend services.
*/
gulp.task('services-only', async () => {
const services = await getServices();
for (let service of services)
require(service.index).start(service.port);
});
/**
* Runs the e2e tests, restoring the fixtures first.
*/
gulp.task('e2e', ['docker-rebuild'], async () => {
await runSequenceP('e2e-only');
});
/**
* Runs the e2e tests.
*/
gulp.task('e2e-only', () => {
const jasmine = require('gulp-jasmine');
return gulp.src('./e2e_tests.js')
.pipe(jasmine({reporter: 'none'}));
});
/**
* Cleans all generated project files.
*/
gulp.task('clean', ['build-clean', 'nginx-clean']);
/**
* Alias for the 'install' task.
*/
gulp.task('i', ['install']);
/**
* Installs node dependencies in all project directories.
*/
gulp.task('install', () => {
const install = require('gulp-install');
const print = require('gulp-print');
@ -123,6 +146,9 @@ gulp.task('docker-compose', async () => {
await fs.writeFile('./docker-compose.yml', ymlString);
});
/**
* Cleans all files generated by the 'build' task.
*/
gulp.task('build-clean', () => {
const del = require('del');
const files = [
@ -139,10 +165,16 @@ gulp.task('build-clean', () => {
let nginxConf = 'temp/nginx.conf';
let nginxTemp = `${nginxDir}/temp`;
/**
* Starts the nginx process, if it is started, restarts it.
*/
gulp.task('nginx', async () => {
await runSequenceP('nginx-stop', 'nginx-start');
});
/**
* Starts the nginx process, generating it's configuration file first.
*/
gulp.task('nginx-start', ['nginx-conf'], async () => {
let nginxBin = await nginxGetBin();
@ -153,6 +185,9 @@ gulp.task('nginx-start', ['nginx-conf'], async () => {
await execP(`${nginxBin} -c "${nginxConf}" -p "${nginxDir}"`);
});
/**
* Stops the nginx process.
*/
gulp.task('nginx-stop', async () => {
try {
let nginxBin = await nginxGetBin();
@ -161,6 +196,11 @@ gulp.task('nginx-stop', async () => {
} catch (e) {}
});
/**
* Generates the nginx configuration file. If NODE_ENV is defined and the
* 'nginx.[environment].mst' file exists, it is used as a template, otherwise,
* the 'nginx.mst' template file is used.
*/
gulp.task('nginx-conf', ['nginx-stop'], async () => {
const mustache = require('mustache');
@ -187,6 +227,9 @@ gulp.task('nginx-conf', ['nginx-stop'], async () => {
await fs.writeFile(`${nginxTemp}/nginx.conf`, nginxConf);
});
/**
* Cleans all files generated by nginx.
*/
gulp.task('nginx-clean', ['nginx-stop'], () => {
const del = require('del');
return del([`${nginxTemp}/*`], {force: true});
@ -280,6 +323,11 @@ gulp.task('webpack-dev-server', function() {
let localeFiles = `${srcDir}/**/locale/*.yml`;
/**
* Mixes all locale files into one JSON file per module and language. It looks
* recursively in all project directories for locale folders with per language
* yaml translation files.
*/
gulp.task('locales', function() {
const extend = require('gulp-extend');
const yaml = require('gulp-yaml');
@ -323,6 +371,10 @@ gulp.task('watch', function() {
// Docker
/**
* Rebuilds the docker and it's image, if these already exist, destroys and
* rebuilds them.
*/
gulp.task('docker-rebuild', async () => {
try {
await execP('docker rm -f dblocal');
@ -334,16 +386,22 @@ gulp.task('docker-rebuild', async () => {
await runSequenceP('docker-run');
});
/**
* Does the minium effort to start the docker, if it doesn't exists calls
* the 'docker-run' task, if it is started does nothing. Keep in mind that when
* you do not rebuild the docker you may be using an outdated version of it.
* See the 'docker-rebuild' task for more info.
*/
gulp.task('docker-start', async () => {
let result;
let state;
try {
result = await execP('docker container inspect -f "{{json .State}}" dblocal');
let result = await execP('docker container inspect -f "{{json .State}}" dblocal');
state = JSON.parse(result.stdout);
} catch (err) {
return await runSequenceP('docker-run');
}
switch (JSON.parse(result.stdout).Status) {
switch (state.Status) {
case 'running':
return;
case 'exited':
@ -353,6 +411,9 @@ gulp.task('docker-start', async () => {
}
});
/**
* Runs the docker, if the container or it's image doesn't exists builds them.
*/
gulp.task('docker-run', async () => {
try {
await execP('docker image inspect -f "{{json .Id}}" dblocal');
@ -364,29 +425,58 @@ gulp.task('docker-run', async () => {
await runSequenceP('docker-wait');
});
/**
* Waits until MySQL docker is started and ready to serve connections.
*/
gulp.task('docker-wait', callback => {
let maxInterval = 30 * 60000;
let interval = 1000;
let timer = 0;
const mysql = require('mysql2');
let interval = 1;
let elapsedTime = 0;
let maxInterval = 30 * 60;
log('Waiting for MySQL init process...');
let waitForLocaldb = setInterval(() => {
if (timer < maxInterval) {
timer += interval;
exec('docker logs --tail 1 dblocal', (err, stdout, stderr) => {
if (stderr.includes('starting as process 1') || err) {
clearInterval(waitForLocaldb);
callback(err);
}
});
} else {
clearInterval(waitForLocaldb);
callback(new Error(`MySQL not initialized whithin ${maxInterval / 1000} secs`));
checker();
async function checker() {
elapsedTime += interval;
let state;
try {
let result = await execP('docker container inspect -f "{{json .State}}" dblocal');
state = JSON.parse(result.stdout);
} catch (err) {
return callback(new Error(err.message));
}
}, interval);
if (state.Status === 'exited')
return callback(new Error('Docker exited, please see the docker logs for more info'));
let conn = mysql.createConnection({
host: 'localhost',
user: 'root'
});
conn.on('error', () => {});
conn.connect(err => {
conn.destroy();
if (!err) return callback();
if (elapsedTime >= maxInterval)
callback(new Error(`MySQL not initialized whithin ${elapsedTime} secs`));
else
setTimeout(checker, interval * 1000);
});
}
});
// Helpers
/**
* Promisified version of exec().
*
* @param {String} command The exec command
* @return {Promise} The promise
*/
function execP(command) {
return new Promise((resolve, reject) => {
exec(command, (err, stdout, stderr) => {
@ -401,6 +491,12 @@ function execP(command) {
});
}
/**
* Promisified version of runSequence().
*
* @param {String} args The list of gulp task names
* @return {Promise} The promise
*/
function runSequenceP() {
return new Promise((resolve, reject) => {
let args = Array.prototype.slice.call(arguments);

247
package-lock.json generated
View File

@ -257,6 +257,12 @@
"integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=",
"dev": true
},
"ansicolors": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/ansicolors/-/ansicolors-0.2.1.tgz",
"integrity": "sha1-vgiVmQl7dKXJxKhKDNvNtivYeu8=",
"dev": true
},
"anymatch": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz",
@ -420,6 +426,38 @@
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=",
"dev": true
},
"assets-webpack-plugin": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/assets-webpack-plugin/-/assets-webpack-plugin-3.5.1.tgz",
"integrity": "sha1-kxzg1m1C6I7V5/GNZVIpQ8V6OH0=",
"dev": true,
"requires": {
"camelcase": "1.2.1",
"escape-string-regexp": "1.0.5",
"lodash.assign": "3.2.0",
"lodash.merge": "3.3.2",
"mkdirp": "0.5.1"
},
"dependencies": {
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
"dev": true
},
"lodash.assign": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-3.2.0.tgz",
"integrity": "sha1-POnwI0tLIiPilrj6CsH+6OvKZPo=",
"dev": true,
"requires": {
"lodash._baseassign": "3.2.0",
"lodash._createassigner": "3.1.1",
"lodash.keys": "3.1.2"
}
}
}
},
"assign-symbols": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
@ -1331,12 +1369,6 @@
"integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=",
"dev": true
},
"bignumber.js": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-4.0.4.tgz",
"integrity": "sha1-fED1q80tZiOre5loLufbgbEYiaQ=",
"dev": true
},
"binary-extensions": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.8.0.tgz",
@ -1825,6 +1857,16 @@
"integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=",
"dev": true
},
"cardinal": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/cardinal/-/cardinal-1.0.0.tgz",
"integrity": "sha1-UOIcGwqjdyn5N33vGWtanOyTLuk=",
"dev": true,
"requires": {
"ansicolors": "0.2.1",
"redeyed": "1.0.1"
}
},
"caseless": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz",
@ -4081,6 +4123,12 @@
"integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=",
"dev": true
},
"denque": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/denque/-/denque-1.2.3.tgz",
"integrity": "sha512-BOjyD1zPf7gqgXlXBCnCsz84cbRNfqpQNvWOUiw3Onu9s7a2afW2LyHzctoie/2KELfUoZkNHTnW02C3hCU20w==",
"dev": true
},
"depd": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
@ -11259,6 +11307,18 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.16.6.tgz",
"integrity": "sha1-0iyaxmAojzhD4Wun0rXQbMon13c="
},
"lodash._arraycopy": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz",
"integrity": "sha1-due3wfH7klRzdIeKVi7Qaj5Q9uE=",
"dev": true
},
"lodash._arrayeach": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz",
"integrity": "sha1-urFWsqkNPxu9XGU0AzSeXlkz754=",
"dev": true
},
"lodash._baseassign": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
@ -11275,6 +11335,12 @@
"integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=",
"dev": true
},
"lodash._basefor": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash._basefor/-/lodash._basefor-3.0.3.tgz",
"integrity": "sha1-dVC06SGO8J+tJDQ7YSAhx5tMIMI=",
"dev": true
},
"lodash._basetostring": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz",
@ -11476,6 +11542,23 @@
"lodash._objecttypes": "2.4.1"
}
},
"lodash.isplainobject": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-3.2.0.tgz",
"integrity": "sha1-moI4rhayAEMpYM1zRlEtASP79MU=",
"dev": true,
"requires": {
"lodash._basefor": "3.0.3",
"lodash.isarguments": "3.1.0",
"lodash.keysin": "3.0.8"
}
},
"lodash.istypedarray": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz",
"integrity": "sha1-yaR3SYYHUB2OhJTSg7h8OSgc72I=",
"dev": true
},
"lodash.keys": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz",
@ -11487,6 +11570,35 @@
"lodash.isarray": "3.0.4"
}
},
"lodash.keysin": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/lodash.keysin/-/lodash.keysin-3.0.8.tgz",
"integrity": "sha1-IsRJPrvtsUJ5YqVLRFssinZ/tH8=",
"dev": true,
"requires": {
"lodash.isarguments": "3.1.0",
"lodash.isarray": "3.0.4"
}
},
"lodash.merge": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-3.3.2.tgz",
"integrity": "sha1-DZDZPtY3sYeEN7s+IWASYNev6ZQ=",
"dev": true,
"requires": {
"lodash._arraycopy": "3.0.0",
"lodash._arrayeach": "3.0.0",
"lodash._createassigner": "3.1.1",
"lodash._getnative": "3.9.1",
"lodash.isarguments": "3.1.0",
"lodash.isarray": "3.0.4",
"lodash.isplainobject": "3.2.0",
"lodash.istypedarray": "3.0.6",
"lodash.keys": "3.1.2",
"lodash.keysin": "3.0.8",
"lodash.toplainobject": "3.0.0"
}
},
"lodash.mergewith": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz",
@ -11532,6 +11644,16 @@
"lodash.escape": "3.2.0"
}
},
"lodash.toplainobject": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash.toplainobject/-/lodash.toplainobject-3.0.0.tgz",
"integrity": "sha1-KHkK2ULSk9eKpmOgfs9/UsoEGY0=",
"dev": true,
"requires": {
"lodash._basecopy": "3.0.1",
"lodash.keysin": "3.0.8"
}
},
"lodash.values": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz",
@ -11596,6 +11718,12 @@
"integrity": "sha1-4PyVEztu8nbNyIh82vJKpvFW+Po=",
"dev": true
},
"long": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==",
"dev": true
},
"longest": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
@ -12000,22 +12128,46 @@
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s="
},
"mysql": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.15.0.tgz",
"integrity": "sha1-6haEEVY0Po8uR/yJhexBzdlXO1w=",
"mysql2": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-1.5.2.tgz",
"integrity": "sha512-976p3FxXdNMRRiF6Qe/FCOwaUYw3KXVJiIYu5iE5shM7ggIASgF6G/9gd9rhpBqP8V6MVa3KQJ6Ao1xBeGBljw==",
"dev": true,
"requires": {
"bignumber.js": "4.0.4",
"readable-stream": "2.3.3",
"cardinal": "1.0.0",
"denque": "1.2.3",
"generate-function": "2.0.0",
"iconv-lite": "0.4.19",
"long": "4.0.0",
"lru-cache": "4.1.1",
"named-placeholders": "1.1.1",
"object-assign": "4.1.1",
"readable-stream": "2.3.2",
"safe-buffer": "5.1.1",
"seq-queue": "0.0.5",
"sqlstring": "2.3.0"
},
"dependencies": {
"lru-cache": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
"integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==",
"dev": true,
"requires": {
"pseudomap": "1.0.2",
"yallist": "2.1.2"
}
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
"dev": true
},
"readable-stream": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
"integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz",
"integrity": "sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=",
"dev": true,
"requires": {
"core-util-is": "1.0.2",
@ -12030,11 +12182,34 @@
"string_decoder": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
"integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=",
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"dev": true,
"requires": {
"safe-buffer": "5.1.1"
}
},
"yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
"dev": true
}
}
},
"named-placeholders": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.1.tgz",
"integrity": "sha1-O3oNJiA910s6nfTJz7gnsvuQfmQ=",
"dev": true,
"requires": {
"lru-cache": "2.5.0"
},
"dependencies": {
"lru-cache": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz",
"integrity": "sha1-2COIrpyWC+y+oMc7uet5tsbOmus=",
"dev": true
}
}
},
@ -13569,6 +13744,23 @@
"strip-indent": "1.0.1"
}
},
"redeyed": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/redeyed/-/redeyed-1.0.1.tgz",
"integrity": "sha1-6WwZO0DAgWsArshCaY5hGF5VSYo=",
"dev": true,
"requires": {
"esprima": "3.0.0"
},
"dependencies": {
"esprima": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-3.0.0.tgz",
"integrity": "sha1-U88kes2ncxPlUcOqLnM0LT+099k=",
"dev": true
}
}
},
"regenerate": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz",
@ -14129,6 +14321,12 @@
}
}
},
"seq-queue": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz",
"integrity": "sha1-1WgS4cAXpuTnw+Ojeh2m143TyT4=",
"dev": true
},
"sequencify": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz",
@ -17049,6 +17247,23 @@
}
}
},
"webpack-merge": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.1.1.tgz",
"integrity": "sha512-geQsZ86YkXOVOjvPC5yv3JSNnL6/X3Kzh935AQ/gJNEYXEfJDQFu/sdFuktS9OW2JcH/SJec8TGfRdrpHshH7A==",
"dev": true,
"requires": {
"lodash": "4.17.5"
},
"dependencies": {
"lodash": {
"version": "4.17.5",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz",
"integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==",
"dev": true
}
}
},
"webpack-sources": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz",

View File

@ -25,6 +25,7 @@
},
"devDependencies": {
"angular-mocks": "^1.6.6",
"assets-webpack-plugin": "^3.5.1",
"babel": "^6.23.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
@ -63,7 +64,7 @@
"merge-stream": "^1.0.1",
"minimist": "^1.2.0",
"mustache": "^2.3.0",
"mysql": "^2.15.0",
"mysql2": "^1.5.2",
"nightmare": "^2.10.0",
"node-sass": "^4.7.2",
"nodemon": "^1.12.1",
@ -74,6 +75,7 @@
"style-loader": "^0.20.1",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.11.1",
"webpack-merge": "^4.1.1",
"yaml-loader": "^0.5.0"
},
"scripts": {

View File

@ -2,6 +2,7 @@ FROM node:8.9.4
COPY auth /app
COPY loopback /loopback
COPY nginx/static/webpack-assets.json /loopback/server/
WORKDIR /app

View File

@ -6,14 +6,8 @@
</head>
<body ng-app="vnAuth">
<vn-login></vn-login>
<script type="text/javascript"
src="/static/bundle.manifest.js">
</script>
<script type="text/javascript"
src="/static/bundle.vendor.js">
</script>
<script type="text/javascript"
src="/static/bundle.auth.js">
</script>
<% for (let jsFile of assets('auth', ['vendor'])) { %>
<script type="text/javascript" src="<%= jsFile %>"></script>
<% } %>
</body>
</html>

View File

@ -11,4 +11,7 @@ RUN chmod -R 755 .
CMD ["mysqld"]
#HEALTHCHECK --interval=5s --timeout=10s --retries=200 \
# CMD mysqladmin ping -h 127.0.0.1 -u root || exit 1
EXPOSE 3306

View File

@ -1,4 +1,4 @@
let mysql = require('mysql');
let mysql = require('mysql2');
let connection = mysql.createConnection({
multipleStatements: true,

View File

@ -4,5 +4,6 @@
"Unable to mark the equivalence surcharge": "Unable to mark the equivalence surcharge",
"The default consignee can not be unchecked": "The default consignee can not be unchecked",
"Unable to default a disabled consignee": "Unable to default a disabled consignee",
"El método de pago seleccionado requiere que se especifique el IBAN": "El método de pago seleccionado requiere que se especifique el IBAN"
"El método de pago seleccionado requiere que se especifique el IBAN": "El método de pago seleccionado requiere que se especifique el IBAN",
"Ya existe un usuario con ese nombre": "Ya existe un usuario con ese nombre"
}

3947
services/loopback/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"fs-extra": "^5.0.0",
"helmet": "^1.3.0",
"i18n": "^0.8.3",
"loopback": "^3.14.0",
@ -16,6 +17,7 @@
"loopback-connector-remote": "^3.1.1",
"loopback-context": "^3.3.0",
"md5": "^2.2.1",
"require-yaml": "0.0.1",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^2.1.0"
},

View File

@ -0,0 +1,38 @@
require('require-yaml');
/**
* Obtains the webpack asset filenames with its hash.
*
* @param {String} main The main asset name
* @param {Array} deps The main asset dependencies
* @return {Array} The assets filenames
*/
function assets(main, deps) {
let jsFiles;
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
if (env === 'development') {
const wpConfig = require('../../../webpack.config.yml');
let publicPath = wpConfig.publicPath;
jsFiles = [`${publicPath}/manifest.js`];
for (let dep of deps)
jsFiles.push(`${publicPath}/${dep}.js`);
jsFiles.push(`${publicPath}/${main}.js`);
} else {
const wpAssets = require('./webpack-assets.json');
let jsFiles = [wpAssets.manifest.js];
for (let dep of deps)
jsFiles.push(wpAssets[dep].js);
jsFiles.push(wpAssets[main].js);
}
return jsFiles;
}
module.exports = assets;

View File

@ -1,9 +1,9 @@
let loopback = require('loopback');
let boot = require('loopback-boot');
let path = require('path');
let fs = require('fs');
let fs = require('fs-extra');
let i18n = require('i18n');
let path = require('path');
module.exports = {
loopback: loopback,
@ -32,6 +32,11 @@ function vnBoot(app, rootDir, rootModule) {
app.set('view engine', 'ejs');
app.set('views', viewDir);
app.use(loopback.static(path.resolve(rootDir, '../client')));
app.get('/', function(req, res) {
res.render(`${viewDir}/index.ejs`, {
assets: require('./assets')
});
});
}
// Initialization

View File

@ -2,4 +2,3 @@ host: localhost
port: 5000
main: salix
defaultPort: 3000
devServerPort: 8081

View File

@ -2,6 +2,7 @@ FROM node:8.9.4
COPY salix /app
COPY loopback /loopback
COPY nginx/static/webpack-assets.json /loopback/server/
WORKDIR /app

View File

@ -10,15 +10,8 @@
<script type="text/javascript"
src="/static/routes.js">
</script>
<script type="text/javascript"
src="/static/bundle.manifest.js">
</script>
<script type="text/javascript"
src="/static/bundle.vendor.js">
</script>
<script type="text/javascript"
src="/static/bundle.salix.js">
</script>
<% for (let jsFile of assets('salix', ['vendor'])) { %>
<script type="text/javascript" src="<%= jsFile %>"></script>
<% } %>
</body>
</html>

View File

@ -1,20 +1,19 @@
require('require-yaml');
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const AssetsWebpackPlugin = require('assets-webpack-plugin');
const wpConfig = require('./webpack.config.yml');
var webpack = require('webpack');
var path = require('path');
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
let devMode = env === 'development';
let outputPath = path.join(__dirname, wpConfig.buildDir);
var devMode = process.env.NODE_ENV !== 'production';
var config = {
entry: {
'bundle.salix': ['salix'],
'bundle.auth': ['auth'],
'bundle.vendor': ['vendor']
},
let baseConfig = {
entry: wpConfig.entry,
output: {
path: path.join(__dirname, './services/nginx/static'),
filename: '[name].js',
publicPath: '/static/',
chunkFilename: 'chunk.[name].[chunkhash].js'
path: outputPath,
publicPath: `${wpConfig.publicPath}/`
},
module: {
rules: [
@ -52,20 +51,41 @@ var config = {
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ['bundle.vendor', 'bundle.manifest']
names: ['vendor', 'manifest']
})
],
devtool: 'source-map'
};
if (!devMode) {
// FIXME: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/132
// config.plugins.push(
// new webpack.optimize.UglifyJsPlugin({
// minimize: true,
// compress: {warnings: false}
// })
// );
}
let prodConfig = {
output: {
filename: '[name].[chunkhash].js',
chunkFilename: 'chunk.[id].[chunkhash].js'
},
plugins: [
// FIXME: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/132
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {warnings: false}
}),
new AssetsWebpackPlugin({
path: outputPath
}),
new webpack.HashedModuleIdsPlugin()
],
devtool: 'source-map'
};
module.exports = config;
let devConfig = {
output: {
filename: '[name].js',
chunkFilename: 'chunk.[id].js'
},
plugins: [
new webpack.NamedModulesPlugin()
],
devtool: 'eval'
};
let mrgConfig = devMode ? devConfig : prodConfig;
module.exports = merge(baseConfig, mrgConfig);

8
webpack.config.yml Normal file
View File

@ -0,0 +1,8 @@
buildDir: services/nginx/static
devServerPort: 3500
publicPath: /static
entry: {
salix: [salix],
auth: [auth],
vendor: [vendor]
}