From 86cd8ec8d2cdc6e2b910d5ce02b268f11b33370d Mon Sep 17 00:00:00 2001 From: David Moreau Date: Thu, 21 Dec 2017 08:49:02 -0500 Subject: [PATCH] router works better now --- README.md | 2 +- client/Editor/Cell/OperationDirectionCell.js | 8 ++--- client/Hud/Navbar.js | 34 +++++++++++--------- client/Routes.js | 14 +++++--- client/main.js | 4 +-- public/index.php | 3 ++ server/Base/Configuration.php | 8 ++++- server/Base/Provider/IndexProvider.php | 13 +++----- server/Silo.php | 24 ++++++++------ 9 files changed, 65 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index fb07963..4df8a52 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![Logo](./silo.png) [![Build Status](https://travis-ci.org/frankandoak/silo.svg?branch=master)](https://travis-ci.org/frankandoak/silo) # Silo -Simple yet powerful Warehouse Managment System. Daily used by Frank + Oak. +Simple yet powerful Warehouse Managment System. Daily used by Frank And Oak. Proudly built in MontrĂ©al with: - React diff --git a/client/Editor/Cell/OperationDirectionCell.js b/client/Editor/Cell/OperationDirectionCell.js index 566dada..bf247b4 100644 --- a/client/Editor/Cell/OperationDirectionCell.js +++ b/client/Editor/Cell/OperationDirectionCell.js @@ -1,13 +1,13 @@ const React = require('react'); -const Link = require('../../Factory').Link; +const Link = require('react-router-dom').Link; const {Cell} = require('fixed-data-table'); module.exports = ({rowIndex, data, ...props}) => { const {source, target, location} = data.getObjectAt(rowIndex); return - {source ? : CREATE} + {source ? {source} : CREATE}  →  - {target ? : DELETE} -  ({location ? : 'skus'}) + {target ? {target} : DELETE} +  ({location ? {location} : 'skus'}) }; diff --git a/client/Hud/Navbar.js b/client/Hud/Navbar.js index ddef0df..ff22326 100644 --- a/client/Hud/Navbar.js +++ b/client/Hud/Navbar.js @@ -9,6 +9,24 @@ module.exports = React.createClass({ return {title} }, + /* + + + */ + render: function(){ return ( @@ -17,22 +35,6 @@ module.exports = React.createClass({ Silo - - - ); } diff --git a/client/Routes.js b/client/Routes.js index fe129d5..397e9ff 100644 --- a/client/Routes.js +++ b/client/Routes.js @@ -7,14 +7,20 @@ import Location from './View/Location' import Product from './View/Product' import OperationSet from './View/OperationSet' +const withId = (WrappedComponent) => ({match, ...props}) => (); + +export {withId}; + // match.params.id let key = 0; const routes = (RouteCp = Route) => [ , - , - , - , - + , + , + , + ]; export default routes + + diff --git a/client/main.js b/client/main.js index e803b1a..8c363e1 100644 --- a/client/main.js +++ b/client/main.js @@ -33,7 +33,7 @@ const App = React.createClass({
- {Routes} + {Routes()} (
Not found
)} />
@@ -44,4 +44,4 @@ const App = React.createClass({ } }); -ReactDOM.render(, document.getElementById('ReactMount')); +ReactDOM.render(, document.getElementById('container')); diff --git a/public/index.php b/public/index.php index f2f6b21..9cbec2f 100644 --- a/public/index.php +++ b/public/index.php @@ -14,4 +14,7 @@ 'config.cache' => new \Silo\Base\SinglePhpFileCache($configFile, \Silo\Base\Configuration::CACHE_KEY), 'defaultErrorHandler' => true ]); +$indexProvider = new \Silo\Base\Provider\IndexProvider(); +$app->register($indexProvider)->mount('/', $indexProvider); + $app->run(); diff --git a/server/Base/Configuration.php b/server/Base/Configuration.php index 8835b22..6d892bd 100644 --- a/server/Base/Configuration.php +++ b/server/Base/Configuration.php @@ -69,6 +69,8 @@ public function has($name, $defaultValue, $validation = null) $this->validate($defaultValue, $validation); $this->app[$name] = $defaultValue; } + + return $this; } public function set($name, $value) @@ -79,11 +81,15 @@ public function set($name, $value) } $this->validate($value, $configKey->getValidation()); $this->app[$name] = $value; + + return $this; } public function save() { $this->cache->save($this->key, $this->getAll()); + + return $this; } private function getConfigurationKeyByName($name) @@ -111,6 +117,7 @@ public function getAll() $name = $config->getName(); $result[$name] = $app[$name]; }); + return $result; } @@ -125,6 +132,5 @@ public function injectFromCache() } } } - } } diff --git a/server/Base/Provider/IndexProvider.php b/server/Base/Provider/IndexProvider.php index dc73c1e..51d1ea3 100644 --- a/server/Base/Provider/IndexProvider.php +++ b/server/Base/Provider/IndexProvider.php @@ -15,18 +15,15 @@ class IndexProvider implements \Pimple\ServiceProviderInterface, ControllerProvi { public function register(Container $app) { - $app['index.css'] = [ - '/master.css', - '/static/default/default/css/chosen.css', - '/static/default/default/css/jquery.switchButton.css' - ]; + $app['index.css'] = []; $app['index.js'] = [ - '/legacy.js', '/vendors.js', '/app.js' ]; + $app['title'] = 'silo'; + $app['index.response'] = $app->factory(function()use($app){ $metas = ""; @@ -44,7 +41,7 @@ public function register(Container $app) - silo + {$app['title']} @@ -67,7 +64,7 @@ public function connect(Application $app) { $c = $app['controllers_factory']; - $c->get('/', $app['index.response']); + $c->get('/', function()use($app){return $app['index.response'];}); return $c; } diff --git a/server/Silo.php b/server/Silo.php index a64e5d4..460caf9 100644 --- a/server/Silo.php +++ b/server/Silo.php @@ -19,7 +19,8 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Validator\Validation; - +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Main Silo entry point, exposed as a Container. */ @@ -38,8 +39,14 @@ public function __construct(array $values = []) parent::__construct($values); $this->register(new ConfigurationProvider); - $this['config']->has('configured', true); // @todo should be false in a not so distant future + $this['config'] + ->has('configured', false) // @todo should be false in a not so distant future + ->has('route.base', '/silo/inventory') + ->has('em.dsn', null); + + //$this['config']->save(); + $this['debug'] = true; if ($this['configured']) { $this->register(new MetricProvider); $this->register(new DoctrineProvider, [ @@ -105,12 +112,12 @@ public function __construct(array $values = []) return $s; }; - $app->mount('/silo/inventory/location', new \Silo\Inventory\LocationController); - $app->mount('/silo/inventory/operation', new \Silo\Inventory\OperationController); - $app->mount('/silo/inventory/product', new \Silo\Inventory\ProductController); - $app->mount('/silo/inventory/batch', new \Silo\Inventory\BatchController); - $app->mount('/silo/inventory/user', new \Silo\Inventory\UserController); - $app->mount('/silo/inventory/export', new \Silo\Inventory\ExportController); + $app->mount($app['route.base'].'/location', new \Silo\Inventory\LocationController); + $app->mount($app['route.base'].'/operation', new \Silo\Inventory\OperationController); + $app->mount($app['route.base'].'/product', new \Silo\Inventory\ProductController); + $app->mount($app['route.base'].'/batch', new \Silo\Inventory\BatchController); + $app->mount($app['route.base'].'/user', new \Silo\Inventory\UserController); + $app->mount($app['route.base'].'/export', new \Silo\Inventory\ExportController); $app['version'] = function(){ $filename = __DIR__.'/../../VERSION'; @@ -129,7 +136,6 @@ public function __construct(array $values = []) // Deal with exceptions ErrorHandler::register(); - if (isset($app['defaultErrorHandler']) && $app['defaultErrorHandler']) { $app->error(function (\Exception $e, $request) use ($app) { if ($e instanceof NotFoundHttpException) {