i11n en modulos app y crud
This commit is contained in:
parent
a2ff16b9a2
commit
85c22f4523
|
@ -1,8 +1,9 @@
|
|||
<div style="position: fixed; top: 0; right: 0; padding: .8em 1.5em; z-index: 10;">
|
||||
<vn-icon icon="apps" id="apps" title="Applications"></vn-icon>
|
||||
<vn-icon icon="notifications" title="Notifications"></vn-icon>
|
||||
<vn-icon icon="exit_to_app" title="Logout" ng-click="mainMenu.onLogoutClick()"></vn-icon>
|
||||
<vn-icon icon="account_circle" title="Profile" style="font-size: 35px;"></vn-icon>
|
||||
<vn-icon icon="apps" id="apps" translate-attr="{title: 'Applications'}"></vn-icon>
|
||||
<vn-icon icon="notifications" translate-attr="{title: 'Notifications'}"></vn-icon>
|
||||
<vn-icon icon="language" translate-attr="{title: 'Change language'}" ng-click="mainMenu.onChangeLanguage()"></vn-icon>
|
||||
<vn-icon icon="exit_to_app" translate-attr="{title: 'Logout'}" ng-click="mainMenu.onLogoutClick()"></vn-icon>
|
||||
<vn-icon icon="account_circle" translate-attr="{title: 'Profile'}" style="font-size: 35px;"></vn-icon>
|
||||
<!--
|
||||
<vn-popover pad-medium for="apps">
|
||||
<a ui-sref="clients"><vn-icon icon=""></vn-icon></a>
|
||||
|
|
|
@ -6,12 +6,20 @@ export const NAME = 'vnMainMenu';
|
|||
export const COMPONENT = {
|
||||
template: template,
|
||||
controllerAs: "mainMenu",
|
||||
controller: function() {
|
||||
this.onLogoutClick = function() {
|
||||
let appName = 'salix';
|
||||
document.cookie = `${appName}-session=; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
|
||||
window.location = `/account?api_key=${appName}`;
|
||||
};
|
||||
}
|
||||
controller: controller
|
||||
};
|
||||
module.component(NAME, COMPONENT);
|
||||
|
||||
controller.$inject = ['$translate'];
|
||||
function controller($translate, $translatePartialLoader) {
|
||||
this.onLogoutClick = function() {
|
||||
let appName = 'salix';
|
||||
document.cookie = `${appName}-session=; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
|
||||
window.location = `/account?api_key=${appName}`;
|
||||
};
|
||||
this.onChangeLanguage = function() {
|
||||
let lang = $translate.use() == 'en' ? 'es' : 'en';
|
||||
$translate.use(lang);
|
||||
console.log (`Locale changed: ${lang}`);
|
||||
};
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"Applications": "Applications",
|
||||
"Notifications":"Notifications",
|
||||
"Logout": "Logout",
|
||||
"Change language": "Change language",
|
||||
"Profile": "Profile"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"Applications": "Aplicaciones",
|
||||
"Notifications":"Notificaciones",
|
||||
"Logout": "Cerrar sesión",
|
||||
"Change language": "Cambiar idioma",
|
||||
"Profile": "Perfil"
|
||||
}
|
|
@ -1,9 +1,14 @@
|
|||
import {module} from './module';
|
||||
|
||||
export const configNgTranslate = function($translateProvider) {
|
||||
configNgTranslate.$inject = ['$translateProvider', '$translatePartialLoaderProvider'];
|
||||
export function configNgTranslate($translateProvider, $translatePartialLoaderProvider) {
|
||||
for(let mod of ['app', 'crud'])
|
||||
$translatePartialLoaderProvider.addPart(mod);
|
||||
|
||||
let conf = {urlTemplate: '/static/locale/{part}/{lang}.json'};
|
||||
$translateProvider
|
||||
.translations('es', {/* Traducciones */})
|
||||
.useSanitizeValueStrategy(null)
|
||||
.useLoader('$translatePartialLoader', conf)
|
||||
.preferredLanguage('es');
|
||||
}
|
||||
configNgTranslate.$inject = ['$translateProvider'];
|
||||
module.config(configNgTranslate);
|
||||
|
|
|
@ -3,13 +3,12 @@ export {factory as mdlFactory} from './index.mdl';
|
|||
require('./style.scss');
|
||||
|
||||
export const component = {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
bindings: {
|
||||
url: '@',
|
||||
showField: '@',
|
||||
valueField: '@',
|
||||
model: '<'
|
||||
model: '='
|
||||
},
|
||||
template: template,
|
||||
controller: controller
|
||||
|
|
|
@ -17,7 +17,7 @@ module.directive('vnPopover', directive);
|
|||
|
||||
provider.$inject = ['$document', '$compile'];
|
||||
function provider($document, $compile) {
|
||||
let self = {
|
||||
return {
|
||||
show: function(childElement, parent) {
|
||||
let popover = $document[0].createElement('div');
|
||||
popover.className = 'vn-popover';
|
||||
|
@ -92,6 +92,5 @@ function provider($document, $compile) {
|
|||
this.lastEvent = event;
|
||||
}
|
||||
};
|
||||
return self;
|
||||
}
|
||||
module.provider('vnPopover', function() {this.$get = provider;});
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{}
|
|
@ -0,0 +1 @@
|
|||
{}
|
|
@ -4,6 +4,7 @@ var gulp = require('gulp');
|
|||
var gutil = require('gulp-util');
|
||||
var wrap = require('gulp-wrap');
|
||||
var concat = require('gulp-concat');
|
||||
var extend = require('gulp-extend');
|
||||
var babel = require('gulp-babel');
|
||||
var fs = require('fs');
|
||||
var del = require('del');
|
||||
|
@ -22,19 +23,18 @@ gulp.task('clean', function() {
|
|||
// Spliting
|
||||
|
||||
var splitingDir = './app/src/spliting';
|
||||
var splitingFiles = splitingDir + '/*';
|
||||
var splitingFiles = splitingDir +'/*';
|
||||
|
||||
gulp.task('spliting', function() {
|
||||
var jsonDeps = fs.readFileSync(splitingDir + '/deps.json');
|
||||
var jsonDeps = fs.readFileSync(splitingDir +'/deps.json');
|
||||
var modules = JSON.parse(jsonDeps);
|
||||
|
||||
var importTpl = fs.readFileSync(splitingDir + '/import.tpl.js', 'utf8');
|
||||
var requireTpl = fs.readFileSync(splitingDir + '/require.tpl.js', 'utf8');
|
||||
var importTpl = fs.readFileSync(splitingDir +'/import.tpl.js', 'utf8');
|
||||
var requireTpl = fs.readFileSync(splitingDir +'/require.tpl.js', 'utf8');
|
||||
|
||||
for (var modName in modules)
|
||||
{
|
||||
for (var modName in modules) {
|
||||
var deps = modules[modName];
|
||||
var splitFile = './' + modName + '/src/spliting.js';
|
||||
var splitFile = './'+ modName +'/src/spliting.js';
|
||||
|
||||
try {
|
||||
fs.unlinkSync(splitFile);
|
||||
|
@ -90,9 +90,26 @@ gulp.task('webpack-dev-server', ['spliting'], function() {
|
|||
}
|
||||
})
|
||||
.listen(8081, '0.0.0.0', function(err) {
|
||||
if (err) throw new gutil.PluginError('webpack-dev-server', err);
|
||||
gutil.log('[webpack-dev-server]', 'Listening');
|
||||
if (err) throw new gutil.PluginError('webpack-dev-server', err);
|
||||
gutil.log('[webpack-dev-server]', 'Listening');
|
||||
});
|
||||
});
|
||||
|
||||
// Locale
|
||||
|
||||
var localeFiles = './**/locale/*.json';
|
||||
|
||||
gulp.task('locales', function() {
|
||||
var modules = ['core', 'crud', 'app', 'login'];
|
||||
var langs = ['es', 'en'];
|
||||
|
||||
for(var mod of modules)
|
||||
for(var lang of langs) {
|
||||
var localeFiles = `./${mod}/**/locale/${lang}.json`;
|
||||
gulp.src(localeFiles)
|
||||
.pipe(extend(`${lang}.json`))
|
||||
.pipe(gulp.dest(`${buildDir}/locale/${mod}`));
|
||||
}
|
||||
});
|
||||
|
||||
// Routes
|
||||
|
@ -121,16 +138,17 @@ gulp.task('routes', function() {
|
|||
// Watch
|
||||
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch(routeFiles, ['routes']);
|
||||
gulp.watch(splitingFiles, ['spliting']);
|
||||
gulp.watch(routeFiles, ['routes']);
|
||||
gulp.watch(localeFiles, ['locales']);
|
||||
});
|
||||
|
||||
// Default
|
||||
|
||||
gulp.task('build', ['clean'], function() {
|
||||
return gulp.start('routes', 'webpack');
|
||||
return gulp.start('routes', 'webpack', 'locales');
|
||||
});
|
||||
|
||||
gulp.task('default', ['clean'], function() {
|
||||
return gulp.start('watch', 'routes', 'webpack-dev-server');
|
||||
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server');
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"angular": "^1.5.8",
|
||||
"angular-paging": "^2.2.2",
|
||||
"angular-translate": "^2.13.1",
|
||||
"angular-translate-loader-partial": "^2.13.1",
|
||||
"angular-ui-router": "^1.0.0-beta.3",
|
||||
"express": "^4.14.0",
|
||||
"material-design-lite": "^1.3.0",
|
||||
|
@ -32,6 +33,7 @@
|
|||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-concat": "^2.6.0",
|
||||
"gulp-extend": "^0.2.0",
|
||||
"gulp-insert": "^0.5.0",
|
||||
"gulp-util": "^3.0.7",
|
||||
"gulp-wrap": "^0.13.0",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as _ngTranslate from 'angular-translate';
|
||||
import * as _ngTranslateLoader from 'angular-translate-loader-partial';
|
||||
|
||||
export const ngTranslate = {
|
||||
name: 'pascalprecht.translate'
|
||||
|
|
4
db.json
4
db.json
|
@ -20,8 +20,8 @@
|
|||
"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue": "{\"id\":\"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue\",\"ttl\":1209600,\"created\":\"2016-11-21T11:06:11.113Z\",\"userId\":1}"
|
||||
},
|
||||
"Client": {
|
||||
"12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":\"1\",\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"963242101d\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":2345,\"credit\":1000,\"iban\":\"456\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"46013\",\"mobile\":\"654654654\",\"dueDay\":10,\"gestdoc\":23452343,\"province\":\"2\",\"country\":\"1\",\"modify\":\"BasicData\",\"navigate\":true,\"payMethod\":\"1\"}",
|
||||
"14": "{\"name\":\"Cliente 1\",\"id\":14,\"street\":\"Aaaaaaaaaa\",\"fi\":\"1234567890A\",\"socialName\":\"Cliente 1\",\"fax\":\"963242100\",\"dischargeDate\":\"01/01/2017\",\"telefono\":\"963242100\",\"salesPerson\":\"2\",\"email\":\"informatica@verdnatura.es\",\"city\":\"asdf\",\"postcode\":\"asdf\",\"phone\":\"asdf\",\"mobile\":\"asdf\",\"credit\":2345,\"cyc\":123,\"iban\":\"asdf\",\"dueDay\":345,\"gestdoc\":2435,\"surcharge\":true,\"navigate\":true}",
|
||||
"12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":\"1\",\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"963242101d\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":56,\"credit\":1000,\"iban\":\"456\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"46013\",\"mobile\":\"654654654\",\"dueDay\":10,\"gestdoc\":23452343,\"province\":\"2\",\"country\":\"1\",\"modify\":\"BasicData\",\"navigate\":true,\"payMethod\":\"1\"}",
|
||||
"14": "{\"name\":\"Cliente 1\",\"id\":14,\"street\":\"Aaaaaaaaaa\",\"fi\":\"1234567890A\",\"socialName\":\"Cliente 1\",\"fax\":\"963242100\",\"dischargeDate\":\"01/01/2017\",\"telefono\":\"963242100\",\"salesPerson\":\"2\",\"email\":\"informatica@verdnatura.es\",\"city\":\"asdf\",\"postcode\":\"asdf\",\"phone\":\"asdf\",\"mobile\":\"asdf\",\"credit\":2345,\"cyc\":8547,\"iban\":\"asdf\",\"dueDay\":345,\"gestdoc\":2435,\"surcharge\":true,\"navigate\":true}",
|
||||
"15": "{\"name\":\"afsdf\",\"fi\":\"12341234rasf\",\"socialName\":\"asdfasd\",\"dueDay\":5,\"id\":15,\"payMethod\":\"2\",\"salesPerson\":\"1\",\"modify\":\"BasicData\",\"iban\":\"sdfgsdfgsdfg\"}",
|
||||
"16": "{\"name\":\"floristeria laasdfas\",\"fi\":\"2345234523d\",\"socialName\":\"23452345assdfgsdfgt\",\"active\":true,\"dueDay\":5,\"id\":16,\"modify\":\"FiscalData\",\"email\":\"asdfopi jso@aosijf.com\",\"phone\":\"654654654\",\"mobile\":\"654456456\",\"fax\":\"456456456\",\"street\":\"asdfasdf\"}",
|
||||
"17": "{\"name\":\"ccccdddddd\",\"fi\":\"asasdadsa\",\"socialName\":\"asdadasda\",\"active\":false,\"dueDay\":5,\"id\":17,\"modify\":\"BasicData\"}"
|
||||
|
|
46
forever.json
46
forever.json
|
@ -1,26 +1,24 @@
|
|||
[
|
||||
{
|
||||
"uid": "salix",
|
||||
"append": true,
|
||||
"watch": true,
|
||||
"script": "server.js",
|
||||
"sourceDir": "./services/salix/server",
|
||||
"workingDir": "."
|
||||
},
|
||||
{
|
||||
"uid": "account",
|
||||
"append": true,
|
||||
"watch": true,
|
||||
"script": "server.js",
|
||||
"sourceDir": "./services/account/server",
|
||||
"workingDir": "."
|
||||
},
|
||||
{
|
||||
"uid": "client",
|
||||
"append": true,
|
||||
"watch": true,
|
||||
"script": "server.js",
|
||||
"sourceDir": "./services/client/server",
|
||||
"workingDir": "."
|
||||
}
|
||||
{
|
||||
"uid": "salix",
|
||||
"append": true,
|
||||
"watch": true,
|
||||
"script": "server.js",
|
||||
"sourceDir": "./services/salix/server",
|
||||
"workingDir": "."
|
||||
}, {
|
||||
"uid": "account",
|
||||
"append": true,
|
||||
"watch": true,
|
||||
"script": "server.js",
|
||||
"sourceDir": "./services/account/server",
|
||||
"workingDir": "."
|
||||
}, {
|
||||
"uid": "client",
|
||||
"append": true,
|
||||
"watch": true,
|
||||
"script": "server.js",
|
||||
"sourceDir": "./services/client/server",
|
||||
"workingDir": "."
|
||||
}
|
||||
]
|
|
@ -9,7 +9,7 @@
|
|||
<vn-app id="app"></vn-app>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/static/salix.routes.js">
|
||||
src="/salix/config.js">
|
||||
</script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
|
|
|
@ -1,37 +1,41 @@
|
|||
module.exports = function (app) {
|
||||
var api_key = app.get('api key');
|
||||
var url_account = app.get('url account');
|
||||
|
||||
var api_key = app.get('api key');
|
||||
var url_account = app.get('url account');
|
||||
app.get('/', function (req, res) {
|
||||
if (req.cookies['salix-session']) {
|
||||
res.render('index.ejs');
|
||||
}
|
||||
else {
|
||||
res.redirect(url_account + "/?api_key=" + api_key);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
if (req.cookies['salix-session']) {
|
||||
res.render('index.ejs');
|
||||
}
|
||||
else {
|
||||
res.redirect(url_account + "/?api_key=" + api_key);
|
||||
}
|
||||
});
|
||||
app.get('/login', function (req, res) {
|
||||
var token = req.query.access_token;
|
||||
if (token) {
|
||||
res.cookie('salix-session', token, { httpOnly: true, path: '/salix' });
|
||||
res.redirect('/salix');
|
||||
}
|
||||
else {
|
||||
res.redirect(url_account);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/login', function (req, res) {
|
||||
var token = req.query.access_token;
|
||||
if (token) {
|
||||
res.cookie('salix-session', token, { httpOnly: true, path: '/salix' });
|
||||
res.redirect('/salix');
|
||||
}
|
||||
else {
|
||||
res.redirect(url_account);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/config.js', (req, res) => {
|
||||
if (req.cookies['salix-session']) {
|
||||
// TODO: construir js dinamico de las rutas
|
||||
res.set('Content-Type', 'application/javascript');
|
||||
res.send('var routes = {}');
|
||||
}
|
||||
else {
|
||||
res.status(401);
|
||||
res.send("No autorizado");
|
||||
}
|
||||
});
|
||||
app.get('/config.js', (req, res) => {
|
||||
if (true || req.cookies['salix-session']) {
|
||||
// TODO: construir js dinamico de las rutas
|
||||
//res.set('Content-Type', 'application/javascript');
|
||||
//res.send('var routes = {}');
|
||||
var options = {
|
||||
//root: '../nginx/static/'
|
||||
root: 'services/nginx/static/'
|
||||
};
|
||||
res.sendFile('salix.routes.js', options);
|
||||
}
|
||||
else {
|
||||
res.status(401);
|
||||
res.send("No autorizado");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue