This commit is contained in:
Juan Ferrer Toribio 2017-03-01 09:55:17 +01:00
parent 0ef8995724
commit 2cc7d96dce
18 changed files with 37 additions and 87 deletions

View File

@ -6,7 +6,7 @@ root = true
[*] [*]
indent_style = space indent_style = space
indent_size = 2 indent_size = 4
end_of_line = lf end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true

View File

@ -1 +1 @@
export * from './src/auth' export * from './src/auth';

View File

@ -1,4 +1,4 @@
export * from './module'; export * from './module';
import './config'; import './config';
export {component as Login} from './login/login' export {component as Login} from './login/login';

View File

@ -7,8 +7,8 @@ export const component = {
}; };
module.component('vnLogin', component); module.component('vnLogin', component);
controller.$inject = ['$http', '$element']; controller.$inject = ['$http', '$element', '$window'];
function controller($http, $element) { function controller($http, $element, $window) {
Object.assign(this, { Object.assign(this, {
submit: function() { submit: function() {
let model = this.model; let model = this.model;
@ -19,16 +19,16 @@ function controller($http, $element) {
} }
this.loading = true; this.loading = true;
model.appId = window.location.href; model.appId = $window.location.href;
$http.post('/auth', this.model).then( $http.post('/auth', this.model).then(
(json) => this.onLoginOk(json), json => this.onLoginOk(json),
(json) => this.onLoginErr(json) json => this.onLoginErr(json)
); );
}, },
onLoginOk: function(json) { onLoginOk: function(json) {
this.loading = false; this.loading = false;
let data = json.data; let data = json.data;
window.location = `${data.location}?access_token=${data.location}`; $window.location = `${data.location}?access_token=${data.location}`;
}, },
onLoginErr: function(json) { onLoginErr: function(json) {
this.loading = false; this.loading = false;
@ -37,14 +37,14 @@ function controller($http, $element) {
let message; let message;
switch (json.status) { switch (json.status) {
case 401: case 401:
message = 'Invalid credentials'; message = 'Invalid credentials';
break; break;
case -1: case -1:
message = 'Can\'t contact with server'; message = 'Can\'t contact with server';
break; break;
default: default:
message = 'Something went wrong'; message = 'Something went wrong';
} }
this.showMessage(message); this.showMessage(message);

View File

@ -1,2 +1 @@
export * from './src/core' export * from './src/core';

View File

@ -1,4 +1,3 @@
var path = require('path');
var gulp = require('gulp'); var gulp = require('gulp');
var gutil = require('gulp-util'); var gutil = require('gulp-util');
var wrap = require('gulp-wrap'); var wrap = require('gulp-wrap');
@ -12,7 +11,7 @@ var WebpackDevServer = require('webpack-dev-server');
// Configuration // Configuration
var srcDir = './client' var srcDir = './client';
var buildDir = './services/nginx/static'; var buildDir = './services/nginx/static';
var langs = ['es', 'en']; var langs = ['es', 'en'];
@ -33,21 +32,21 @@ gulp.task('spliting', function() {
var importTpl = fs.readFileSync('./spliting/import.tpl.js', 'utf8'); var importTpl = fs.readFileSync('./spliting/import.tpl.js', 'utf8');
var requireTpl = fs.readFileSync('./spliting/require.tpl.js', 'utf8'); var requireTpl = fs.readFileSync('./spliting/require.tpl.js', 'utf8');
for(var modName in modules) { for (var modName in modules) {
var deps = modules[modName]; var deps = modules[modName];
var splitFile = `${srcDir}/${modName}/src/spliting.js`; var splitFile = `${srcDir}/${modName}/src/spliting.js`;
try { try {
fs.unlinkSync(splitFile); fs.unlinkSync(splitFile);
} } catch (e) {}
catch(e) {}
fs.appendFileSync(splitFile, importTpl); fs.appendFileSync(splitFile, importTpl);
var i = deps.length; var i = deps.length;
while(i--) while (i--) {
fs.appendFileSync(splitFile, fs.appendFileSync(splitFile,
requireTpl.replace(/\$module/g, deps[i])); requireTpl.replace(/\$module/g, deps[i]));
}
} }
}); });
@ -67,12 +66,13 @@ gulp.task('webpack', ['spliting'], function(callback) {
gulp.task('webpack-dev-server', ['spliting'], function(callback) { gulp.task('webpack-dev-server', ['spliting'], function(callback) {
var configCopy = Object.create(webpackConfig); var configCopy = Object.create(webpackConfig);
for (var entry in configCopy.entry) for (var entry in configCopy.entry) {
configCopy.entry[entry] configCopy.entry[entry]
.unshift('webpack-dev-server/client?http://0.0.0.0:8081/'); .unshift('webpack-dev-server/client?http://0.0.0.0:8081/');
}
var compiler = webpack(configCopy); var compiler = webpack(configCopy);
var devServer = new WebpackDevServer(compiler, { new WebpackDevServer(compiler, {
publicPath: '/', publicPath: '/',
contentBase: buildDir, contentBase: buildDir,
quiet: false, quiet: false,
@ -100,12 +100,13 @@ var localeFiles = `./${srcDir}/**/locale/*.json`;
gulp.task('locales', function() { gulp.task('locales', function() {
var streams = []; var streams = [];
for(var mod in modules) for (var mod in modules) {
for(var lang of langs) { for (var lang of langs) {
var localeFiles = `./client/${mod}/**/locale/${lang}.json`; var localeFiles = `./client/${mod}/**/locale/${lang}.json`;
streams.push(gulp.src(localeFiles) streams.push(gulp.src(localeFiles)
.pipe(extend(`${lang}.json`)) .pipe(extend(`${lang}.json`))
.pipe(gulp.dest(`${buildDir}/locale/${mod}`))); .pipe(gulp.dest(`${buildDir}/locale/${mod}`)));
}
} }
return merge(streams); return merge(streams);

View File

@ -27,9 +27,10 @@
"cors": "^2.8.1", "cors": "^2.8.1",
"css-loader": "^0.25.0", "css-loader": "^0.25.0",
"del": "^2.2.2", "del": "^2.2.2",
"eslint": "^3.7.1", "eslint": "^3.16.1",
"eslint-config-angular": "^0.5.0", "eslint-config-angular": "^0.5.0",
"eslint-config-google": "^0.6.0", "eslint-config-google": "^0.6.0",
"eslint-config-xo": "^0.17.0",
"eslint-plugin-angular": "^1.4.1", "eslint-plugin-angular": "^1.4.1",
"file-loader": "^0.9.0", "file-loader": "^0.9.0",
"gulp": "^3.9.1", "gulp": "^3.9.1",

View File

@ -1,13 +0,0 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

View File

@ -1 +0,0 @@
/client/

View File

@ -1,3 +0,0 @@
{
"extends": "loopback"
}

View File

@ -1,13 +0,0 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

View File

@ -1 +0,0 @@
/client/

View File

@ -1,3 +0,0 @@
{
"extends": "loopback"
}

View File

@ -80,7 +80,6 @@
"description": "Send invoices by email" "description": "Send invoices by email"
} }
}, },
"validations": [],
"relations": { "relations": {
"account": { "account": {
"type": "hasOne", "type": "hasOne",
@ -98,6 +97,7 @@
"where": {"name": "Verdnatura"} "where": {"name": "Verdnatura"}
} }
}, },
"validations": [],
"acls": [], "acls": [],
"methods": {} "methods": {}
} }

View File

@ -1,13 +0,0 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

View File

@ -1 +0,0 @@
/client/

View File

@ -1,3 +0,0 @@
{
"extends": "loopback"
}