customer merge
This commit is contained in:
commit
e4808007b7
|
@ -35,7 +35,7 @@ export const graphRoutes = {
|
|||
],
|
||||
|
||||
graphDependendies: {
|
||||
compras:["crud"],
|
||||
crud:[]
|
||||
compras: ["crud"],
|
||||
crud: []
|
||||
}
|
||||
};
|
|
@ -1,25 +1,40 @@
|
|||
import * as core from '@salix/core';
|
||||
import * as spliting from './spliting';
|
||||
<<<<<<< HEAD
|
||||
|
||||
function config($stateProvider, $urlRouterProvider) {
|
||||
function loader($ocLazyLoad, $q) {
|
||||
return $q(resolve => {
|
||||
spliting.crud(() => {
|
||||
resolve($ocLazyLoad.load({name: 'crud'}));
|
||||
=======
|
||||
import * as routes from './fake';
|
||||
|
||||
core.module.config(function ($stateProvider, $urlRouterProvider) {
|
||||
core.splitingRegister.registerGraph(routes.graphRoutes.graphDependendies);
|
||||
|
||||
function loader(route) {
|
||||
return function loader($ocLazyLoad, $q) {
|
||||
return $q((resolve) => {
|
||||
core.splitingRegister.execute(route.module).then(function(dependencies){
|
||||
var array = dependencies.map((item) => { return { name: item } });
|
||||
resolve($ocLazyLoad.load(array));
|
||||
});
|
||||
>>>>>>> 0bfbc5e0642bb669d8568ea1ce1782fde1702aa6
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$urlRouterProvider.otherwise("/");
|
||||
|
||||
routes.forEach(function(route) {
|
||||
routes.graphRoutes.routes.forEach(function (route) {
|
||||
$stateProvider.state(route.state, {
|
||||
url: route.url,
|
||||
template :route.template,
|
||||
template: route.template,
|
||||
resolve: {
|
||||
loader: xxx(route)
|
||||
loader: loader(route)
|
||||
}
|
||||
})
|
||||
}, this);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,30 +1,28 @@
|
|||
//import * as core from '@salix/core';
|
||||
import * as core from '@salix/core';
|
||||
|
||||
|
||||
|
||||
//TODO:quitar
|
||||
export const crud = (cb) => {
|
||||
require.ensure([], () => {
|
||||
require('@salix/crud');
|
||||
cb();
|
||||
}, "salix.crud");
|
||||
export const compras = () => {
|
||||
return new Promise(resolve => {
|
||||
require.ensure([], () => {
|
||||
require('@salix/compras');
|
||||
resolve('compras');
|
||||
}, "salix.compras");
|
||||
});
|
||||
};
|
||||
//END TODO
|
||||
|
||||
export const compras = (cb) => {
|
||||
require.ensure([], () => {
|
||||
require('@salix/compras')
|
||||
cb();
|
||||
}, "salix.compras");
|
||||
};
|
||||
core.splitingRegister.register('compras', compras);
|
||||
|
||||
export const ventas = () => {
|
||||
require.ensure([], () => {
|
||||
require('@salix/ventas')
|
||||
}, "salix.ventas");
|
||||
};
|
||||
|
||||
core.splitingRegister.register('ventas', ventas);
|
||||
|
||||
export const pagos = () => {
|
||||
require.ensure([], () => {
|
||||
require('@salix/pagos')
|
||||
}, "salix.pagos");
|
||||
};
|
||||
|
||||
core.splitingRegister.register('pagos', pagos);
|
|
@ -1,4 +1,2 @@
|
|||
import * as core from '@salix/core'
|
||||
import * as vendors from '@salix/vendor'
|
||||
import * as crud from '@salix/crud'
|
||||
console.log('compras');
|
||||
export * from './src/compras';
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './spliting';
|
|
@ -0,0 +1,12 @@
|
|||
import * as core from '@salix/core';
|
||||
|
||||
export const crud = () => {
|
||||
return new Promise(resolve => {
|
||||
require.ensure([], () => {
|
||||
require('@salix/crud');
|
||||
resolve('crud');
|
||||
}, "salix.crud");
|
||||
});
|
||||
};
|
||||
|
||||
core.splitingRegister.register('crud', crud);
|
|
@ -1,32 +1,59 @@
|
|||
const _SplitingRegister = ()=>{
|
||||
const _SplitingRegister = () => {
|
||||
|
||||
var _graph;
|
||||
var dependencies = {};
|
||||
|
||||
function getDependencies(dependency) {
|
||||
var array = [];
|
||||
array.push(dependency);
|
||||
var first = _graph[dependency];
|
||||
|
||||
while (first && first.length > 0) {
|
||||
dependency = first.shift();
|
||||
array = array.concat(getDependencies(dependency));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
return {
|
||||
registerGraph: function(graph){
|
||||
registerGraph: function (graph) {
|
||||
_graph = graph;
|
||||
},
|
||||
register: function(dependency,loader){
|
||||
dependencies[dependecy]=loader;
|
||||
register: function (dependency, loader) {
|
||||
dependencies[dependency] = loader;
|
||||
},
|
||||
execute: function(dependency){
|
||||
execute: function (dependency) {
|
||||
return new Promise(resolve => {
|
||||
|
||||
var _array=[];
|
||||
_array.push(dependency);
|
||||
var fist =graph[dependency];
|
||||
var array = getDependencies(dependency);
|
||||
var arrayClone = array.concat([]);
|
||||
|
||||
//TODO:create dependy graph
|
||||
function getDependency() {
|
||||
var key = array.shift();
|
||||
return dependencies[key];
|
||||
}
|
||||
|
||||
(function loadDependency(dependency) {
|
||||
|
||||
if(!dependency){
|
||||
resolve(arrayClone);
|
||||
return;
|
||||
}
|
||||
dependency().then(function (data) {
|
||||
var _dependency = getDependency();
|
||||
loadDependency(_dependency);
|
||||
});
|
||||
} (getDependency()))
|
||||
|
||||
});
|
||||
|
||||
while(key=array.pop()){
|
||||
dependencies[key]();
|
||||
}
|
||||
|
||||
},
|
||||
write:function(){
|
||||
|
||||
write: function () {
|
||||
console.log(_graph);
|
||||
}
|
||||
}
|
||||
};
|
||||
export const SplitingRegister = _SplitingRegister();
|
||||
window.dependencies = _SplitingRegister();
|
||||
export const SplitingRegister = window.dependencies;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
export * from './module';
|
||||
export * from './customer/routes';
|
||||
|
||||
export {NAME as CUSTOMER_INDEX,
|
||||
COMPONENT as CUSTOMER_INDEX_COMPONENT} from './customer/index';
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
import * as core from '@salix/core';
|
||||
import * as index from './index';
|
||||
|
||||
core.module.config(function($stateProvider, $urlRouterProvider) {
|
||||
$urlRouterProvider.otherwise("/");
|
||||
|
||||
$stateProvider
|
||||
.state('index', {
|
||||
url: "/index",
|
||||
component: index.CUSTOMER_INDEX,
|
||||
resolve: {
|
||||
load: function() {
|
||||
console.log('hello');
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('add', {
|
||||
url: "/add",
|
||||
template: "<div>add</div>"
|
||||
})
|
||||
.state('edit', {
|
||||
url: "/edit",
|
||||
template: "<div>edit</div>"
|
||||
})
|
||||
.state('delete', {
|
||||
url: "/delete",
|
||||
template: "<div>delete</div>"
|
||||
});
|
||||
});
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
|
||||
export const crud = (cb) => {
|
||||
require.ensure([], () => {
|
||||
require('@salix/crud');
|
||||
cb();
|
||||
}, "salix.crud");
|
||||
};
|
15
gulpfile.js
15
gulpfile.js
|
@ -1,16 +1,13 @@
|
|||
|
||||
var gulp = require ('gulp');
|
||||
var jsoncombine = require ('gulp-jsoncombine');
|
||||
|
||||
function combineFunc (data)
|
||||
{
|
||||
return new Buffer (JSON.stringify (data));
|
||||
}
|
||||
var concat = require ('gulp-concat');
|
||||
var babel = require ('gulp-babel');
|
||||
|
||||
gulp.task ('default', function ()
|
||||
{
|
||||
var json = gulp.src ('./@salix/**/routes.json')
|
||||
.pipe (jsoncombine ('salix.routes.json', combineFunc))
|
||||
.pipe (gulp.dest ('./build'));
|
||||
var js = gulp.src ('./@salix/crud/**/routes.js')
|
||||
.pipe (concat ('salix.routes.js'))
|
||||
.pipe (babel ({presets: ['es2015']}))
|
||||
.pipe (gulp.dest ('./build/private'));
|
||||
});
|
||||
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
</div>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="build/salix.app.js"
|
||||
selector="#app"
|
||||
routes-cdn="http://localhost:8080/routes">
|
||||
</script>
|
||||
src="build/public/salix.app.js"
|
||||
selector="#app">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
10
package.json
10
package.json
|
@ -11,7 +11,6 @@
|
|||
"dependencies": {
|
||||
"angular": "^1.5.8",
|
||||
"angular-ui-router": "^1.0.0-beta.3",
|
||||
"cors": "^2.8.1",
|
||||
"express": "^4.14.0",
|
||||
"material-design-lite": "^1.2.1",
|
||||
"oclazyload": "^0.6.3"
|
||||
|
@ -26,8 +25,10 @@
|
|||
"eslint-config-google": "^0.6.0",
|
||||
"eslint-plugin-angular": "^1.4.1",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-jsoncombine": "^1.0.3",
|
||||
"pre-commit": "^1.1.3",
|
||||
"cors": "^2.8.1",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-concat": "^2.6.0",
|
||||
"raw-loader": "*",
|
||||
"style-loader": "^0.13.1",
|
||||
"webpack": "*",
|
||||
|
@ -35,7 +36,10 @@
|
|||
},
|
||||
"scripts": {
|
||||
"build": "webpack --progress --colors --watch",
|
||||
"lint": "eslint ./ --cache --ignore-pattern .gitignore"
|
||||
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
|
||||
"dev": "webpack-dev-server --progress --colors --inline --hot",
|
||||
"gulp": "gulp",
|
||||
"express": "node server.js"
|
||||
},
|
||||
"pre-commit": [ "lint" ]
|
||||
}
|
||||
|
|
13
server.js
13
server.js
|
@ -2,11 +2,8 @@
|
|||
var express = require ('express');
|
||||
var cors = require ('cors');
|
||||
|
||||
function getRoutes (req, res)
|
||||
{
|
||||
var routes = require ('./build/salix.routes.json');
|
||||
res.send (JSON.stringify (routes));
|
||||
}
|
||||
var port = 3000;
|
||||
var routesUrl = '/private/salix.routes.js';
|
||||
|
||||
function getDefault (res, res)
|
||||
{
|
||||
|
@ -15,11 +12,11 @@ function getDefault (res, res)
|
|||
|
||||
function onListen ()
|
||||
{
|
||||
console.log ('HTTP server started.');
|
||||
console.log ('HTTP server started on port '+ port);
|
||||
}
|
||||
|
||||
var app = express ();
|
||||
app.get ('/routes', cors (), getRoutes);
|
||||
app.use ('/private', cors (), express.static (__dirname +'/build/private'));
|
||||
app.all (/.*/, cors (), getDefault);
|
||||
app.listen (8080, onListen);
|
||||
app.listen (port, onListen);
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ module.exports =
|
|||
'salix.app': ['@salix/app']
|
||||
},
|
||||
output: {
|
||||
path: path.join(__dirname, 'build'),
|
||||
path: path.join(__dirname, 'build', 'public'),
|
||||
filename: '[name].js',
|
||||
publicPath: 'build/',
|
||||
publicPath: 'build/public/',
|
||||
chunkFilename: "[name].js"
|
||||
},
|
||||
module: {
|
||||
|
@ -39,5 +39,6 @@ module.exports =
|
|||
__dirname,
|
||||
'node_modules'
|
||||
]
|
||||
}
|
||||
},
|
||||
devtool: 'cheap-module-eval-source-map' // 'source-map'
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue