diff --git a/@salix/app/index.js b/@salix/app/index.js index 4d375b31f..cb9a3f178 100644 --- a/@salix/app/index.js +++ b/@salix/app/index.js @@ -1 +1 @@ -export * from './src/app' \ No newline at end of file +export * from './src/app' diff --git a/@salix/app/src/app.js b/@salix/app/src/app.js index 6f2c434cc..b3ac02fdd 100644 --- a/@salix/app/src/app.js +++ b/@salix/app/src/app.js @@ -2,5 +2,4 @@ import {bootstrap} from './bootstrap'; import * as spliting from './spliting'; import * as routes from './routes'; - bootstrap(); diff --git a/@salix/app/src/routes.js b/@salix/app/src/routes.js index 2e174fa18..563a6de20 100644 --- a/@salix/app/src/routes.js +++ b/@salix/app/src/routes.js @@ -1,11 +1,8 @@ import * as core from '@salix/core'; - import * as spliting from './spliting'; import * as routes from './fake'; - core.module.config(function ($stateProvider, $urlRouterProvider) { - core.splitingRegister.registerGraph(routes.graphRoutes.graphDependendies); function loader(route) { @@ -29,5 +26,5 @@ core.module.config(function ($stateProvider, $urlRouterProvider) { loader: loader(route) } }) - }, this); + }); }); diff --git a/@salix/compras/index.js b/@salix/compras/index.js index 283db8c3b..deb604b56 100644 --- a/@salix/compras/index.js +++ b/@salix/compras/index.js @@ -1 +1,2 @@ -export * from './src/compras'; \ No newline at end of file +export * from './src/compras'; + diff --git a/@salix/compras/routing.json b/@salix/compras/routing.json deleted file mode 100644 index ac6307544..000000000 --- a/@salix/compras/routing.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "route": "buys", - "template": "buys.template" -} diff --git a/@salix/core/src/core.js b/@salix/core/src/core.js index 34075fc61..f0e8af9e1 100644 --- a/@salix/core/src/core.js +++ b/@salix/core/src/core.js @@ -1,11 +1,15 @@ /** * export public module */ + export * from './module' export * from './util' + export {SplitingRegister as splitingRegister} from './splitingregister' export {NAME as RESOLVEDEFAULTCOMPONENT, ResolveDefaultComponent} from './resolveDefaultComponents' export {NAME as INTERPOLATE,Interpolate} from './interpolate' +export {NAME as ROUTESLOADER, RoutesLoader} from './routesLoader' + export {NAME as BUTTON,directive as ButtonDirective} from './button/button' export {NAME as BUTTONMT,factory as buttonmt} from './button/button.mt' export {NAME as BUTTONBT,factory as buttonbt} from './button/button.bt' @@ -20,4 +24,4 @@ export {NAME as TEXTFIELDMT,factory as textfieldmt} from './textfield/textfield. export {NAME as TEXTFIELDBT,factory as textfieldbt} from './textfield/textfield.bt' export {NAME as LABEL,directive as LabelDirective} from './label/label' export {NAME as LABELMT,factory as labelmt} from './label/label.mt' -export {NAME as LABELBT,factory as labelbt} from './label/label.bt' \ No newline at end of file +export {NAME as LABELBT,factory as labelbt} from './label/label.bt' diff --git a/@salix/core/src/routesLoader.js b/@salix/core/src/routesLoader.js new file mode 100644 index 000000000..9fb665721 --- /dev/null +++ b/@salix/core/src/routesLoader.js @@ -0,0 +1,29 @@ + +import {module as _module} from './module' +import * as util from './util' + +export const NAME = util.getProviderName ('RoutesLoader') + +export class RoutesLoader +{ + constructor () {} + + $get ($http) + { + let script = document.currentScript || (() => { + let scripts = document.getElementsByTagName ('script'); + return scripts[scripts.length - 1]; + }) (); + + let routesCdn = script.getAttribute ('routes-cdn'); + + return $http + ({ + method: 'GET', + url: routesCdn + }) + } +} + +_module.provider (NAME, () => new RoutesLoader ()) + diff --git a/@salix/crud/src/crud.js b/@salix/crud/src/crud.js index 58323041f..14f65f6df 100644 --- a/@salix/crud/src/crud.js +++ b/@salix/crud/src/crud.js @@ -1,2 +1,4 @@ export * from './module'; -export {NAME as CUSTOMER_INDEX, COMPONENT as CUSTOMER_INDEX_COMPONENT} from './customer/index' \ No newline at end of file +export {NAME as CUSTOMER_INDEX, COMPONENT as CUSTOMER_INDEX_COMPONENT} from './customer/index' +export {NAME as CUSTOMER_ADD, COMPONENT as CUSTOMER_ADD_COMPONENT} from './customer/index/add' + diff --git a/@salix/crud/src/customer/index/add.html b/@salix/crud/src/customer/index/add.html new file mode 100644 index 000000000..308197934 --- /dev/null +++ b/@salix/crud/src/customer/index/add.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/@salix/crud/src/customer/index/add.js b/@salix/crud/src/customer/index/add.js new file mode 100644 index 000000000..903b4606f --- /dev/null +++ b/@salix/crud/src/customer/index/add.js @@ -0,0 +1,16 @@ +import template from './add.html'; +import {module} from '../../module'; + +export const NAME = 'customerAdd'; + +export const COMPONENT = { + template: template, + bindings :{ + users: '<' + }, + controller :function($scope, $element, $attrs){ + console.log(this.users); + } +}; + +module.component(NAME, COMPONENT); \ No newline at end of file diff --git a/@salix/crud/src/customer/index/index.html b/@salix/crud/src/customer/index/index.html index bf833f5d0..1f45f7a81 100644 --- a/@salix/crud/src/customer/index/index.html +++ b/@salix/crud/src/customer/index/index.html @@ -1 +1 @@ -
index from component
\ No newline at end of file + \ No newline at end of file diff --git a/@salix/crud/src/customer/index/index.js b/@salix/crud/src/customer/index/index.js index 4a195604a..31b48466b 100644 --- a/@salix/crud/src/customer/index/index.js +++ b/@salix/crud/src/customer/index/index.js @@ -4,11 +4,10 @@ import {module} from '../../module'; export const NAME = 'customerIndex'; export const COMPONENT = { template: template, - controller: function() { - this.user = {name: 'world'}; + controller :function(){ + this.users = {id:10,name:"xxxx"}; } }; - module.component(NAME, COMPONENT); diff --git a/@salix/ventas/routing.json b/@salix/ventas/routing.json deleted file mode 100644 index ef776755e..000000000 --- a/@salix/ventas/routing.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "route": "sales", - "template": "sales.template" -} diff --git a/gulpfile.js b/gulpfile.js index 6fbf8aebc..e17bbfd1e 100644 --- a/gulpfile.js +++ b/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/**/routing.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')); }); diff --git a/index.html b/index.html index b506e8e60..e093cae62 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,10 @@ edit delete - + diff --git a/package.json b/package.json index df20f4e4b..d1fb87045 100644 --- a/package.json +++ b/package.json @@ -16,18 +16,23 @@ "oclazyload": "^0.6.3" }, "devDependencies": { - "gulp": "^3.9.1", - "gulp-jsoncombine": "^1.0.3", - "webpack": "*", - "webpack-dev-server": "*", - "raw-loader": "*", - "css-loader": "^0.25.0", - "style-loader": "^0.13.1", - "babel-loader": "*", "babel-core": "*", - "babel-preset-es2015": "*" + "babel-loader": "*", + "babel-preset-es2015": "*", + "cors": "^2.8.1", + "css-loader": "^0.25.0", + "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", + "gulp-concat": "^2.6.0", + "raw-loader": "*", + "style-loader": "^0.13.1", + "webpack": "*", + "webpack-dev-server": "*" }, "scripts": { - "build": "webpack --progress --colors --watch" + "build": "webpack --progress --colors --watch", + "dev": "webpack-dev-server --progress --colors --inline --hot", + "gulp": "gulp", + "express": "node server.js" } } diff --git a/server.js b/server.js index cee4df2ea..04801bb91 100644 --- a/server.js +++ b/server.js @@ -1,11 +1,9 @@ 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) { @@ -14,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.json', getRoutes); -app.all (/.*/, getDefault); -app.listen (8080, onListen); +app.use ('/private', cors (), express.static (__dirname +'/build/private')); +app.all (/.*/, cors (), getDefault); +app.listen (port, onListen); diff --git a/webpack.config.js b/webpack.config.js index 6ff905c05..f6de35fb7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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' };