From c1ebd2894d8d52d981d4b14705eeb90e9b1f08af Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 3 Feb 2016 23:22:18 +0100 Subject: [PATCH] Conception BDD (attributs statique) + Modifications mineures --- conception.sql | 12 +++ config/database.json | 6 ++ config/dispatcher-extensions.json | 11 +-- config/dispatcher-tree.json | 16 ++-- config/managers.json | 5 ++ css/constants.css | 0 css/constants.scss | 0 css/header.css | 2 +- css/header.scss | 4 +- css/menu-side.css | 0 css/submenu-side.css | 0 css/submenu-side.scss | 0 index.php | 24 +++--- js/lib/page-manager.js | 4 +- js/lib/reset.js | 0 manager/Database.php | 104 +++++++++++++++++++++++++ manager/ResourcesDispatcher.php | 4 +- manager/autoloader.php | 4 +- router/Route.php | 0 router/Router.php | 0 src/dynamic/create.svg | 0 src/dynamic/edit.svg | 0 src/dynamic/filter.svg | 0 src/dynamic/remove.svg | 0 src/dynamic/search.svg | 0 src/static/loader.svg | 0 src/static/menu-side/users2.svg | 0 src/static/sub-menu-side/analytics.svg | 0 src/static/sub-menu-side/create.svg | 0 src/static/sub-menu-side/edit.svg | 0 src/static/sub-menu-side/filter.svg | 0 src/static/sub-menu-side/password.svg | 50 ++++++++++++ src/static/sub-menu-side/remove.svg | 0 src/static/sub-menu-side/search.svg | 0 src/static/sub-menu-side/sync.svg | 0 src/static/sub-menu-side/view.svg | 0 todo.md | 13 +++- view.php | 24 +++--- view/analytics.php | 6 ++ view/dashboard.php | 4 + view/js/analytics.js | 0 view/machines.php | 4 + view/profile.php | 67 ++++++++++++++++ view/settings.php | 4 + view/users.php | 4 + 45 files changed, 328 insertions(+), 44 deletions(-) create mode 100644 conception.sql create mode 100755 config/database.json mode change 100644 => 100755 config/dispatcher-extensions.json mode change 100644 => 100755 config/dispatcher-tree.json create mode 100644 config/managers.json mode change 100644 => 100755 css/constants.css mode change 100644 => 100755 css/constants.scss mode change 100644 => 100755 css/menu-side.css mode change 100644 => 100755 css/submenu-side.css mode change 100644 => 100755 css/submenu-side.scss mode change 100644 => 100755 index.php mode change 100644 => 100755 js/lib/page-manager.js mode change 100644 => 100755 js/lib/reset.js create mode 100755 manager/Database.php mode change 100644 => 100755 manager/autoloader.php mode change 100644 => 100755 router/Route.php mode change 100644 => 100755 router/Router.php mode change 100644 => 100755 src/dynamic/create.svg mode change 100644 => 100755 src/dynamic/edit.svg mode change 100644 => 100755 src/dynamic/filter.svg mode change 100644 => 100755 src/dynamic/remove.svg mode change 100644 => 100755 src/dynamic/search.svg mode change 100644 => 100755 src/static/loader.svg mode change 100644 => 100755 src/static/menu-side/users2.svg mode change 100644 => 100755 src/static/sub-menu-side/analytics.svg mode change 100644 => 100755 src/static/sub-menu-side/create.svg mode change 100644 => 100755 src/static/sub-menu-side/edit.svg mode change 100644 => 100755 src/static/sub-menu-side/filter.svg create mode 100644 src/static/sub-menu-side/password.svg mode change 100644 => 100755 src/static/sub-menu-side/remove.svg mode change 100644 => 100755 src/static/sub-menu-side/search.svg mode change 100644 => 100755 src/static/sub-menu-side/sync.svg mode change 100644 => 100755 src/static/sub-menu-side/view.svg mode change 100644 => 100755 todo.md mode change 100644 => 100755 view/analytics.php mode change 100644 => 100755 view/dashboard.php create mode 100755 view/js/analytics.js mode change 100644 => 100755 view/machines.php create mode 100644 view/profile.php mode change 100644 => 100755 view/settings.php mode change 100644 => 100755 view/users.php diff --git a/conception.sql b/conception.sql new file mode 100644 index 0000000..04cd530 --- /dev/null +++ b/conception.sql @@ -0,0 +1,12 @@ +STATIQUES + - un utilisateur + - une machine + - un evenement -> journal + + +DYNAMIQUES + - options (utilisation des STATIQUES par cle etrangere) + + +MODELE + \ No newline at end of file diff --git a/config/database.json b/config/database.json new file mode 100755 index 0000000..d11c9a0 --- /dev/null +++ b/config/database.json @@ -0,0 +1,6 @@ +{ + "host" : "localhost", + "dbname" : "stefproject", + "user" : "php", + "password" : "Qt358nUdyeTxLDM8" +} \ No newline at end of file diff --git a/config/dispatcher-extensions.json b/config/dispatcher-extensions.json old mode 100644 new mode 100755 index 58ba435..a7b5c39 --- a/config/dispatcher-extensions.json +++ b/config/dispatcher-extensions.json @@ -1,7 +1,8 @@ { - "extensions": { - "svg": "image/svg+xml", - "css": "text/css", - "js": "text/js" - } + "svg": "image/svg+xml", + + "css": "text/css", + "js": "text/js", + + "json": "application/json" } \ No newline at end of file diff --git a/config/dispatcher-tree.json b/config/dispatcher-tree.json old mode 100644 new mode 100755 index b4469a1..f72aee7 --- a/config/dispatcher-tree.json +++ b/config/dispatcher-tree.json @@ -1,8 +1,12 @@ { - "parents": { - "st" : "/src/static", - "dy" : "/src/dynamic", - "css" : "/css", - "js" : "/js" - } + "st" : "/src/static", + "dy" : "/src/dynamic", + + "conf" : "/config", + + "css" : "/css", + "js" : "/js", + + "cssview" : "/view/css", + "jsview" : "/view/js" } \ No newline at end of file diff --git a/config/managers.json b/config/managers.json new file mode 100644 index 0000000..0954b60 --- /dev/null +++ b/config/managers.json @@ -0,0 +1,5 @@ +{ + "a" : "/firstManager", + "b" : "/secondManager", + "c" : "/thirdManager" +} \ No newline at end of file diff --git a/css/constants.css b/css/constants.css old mode 100644 new mode 100755 diff --git a/css/constants.scss b/css/constants.scss old mode 100644 new mode 100755 diff --git a/css/header.css b/css/header.css index 36e8b68..2c632fd 100755 --- a/css/header.css +++ b/css/header.css @@ -1,2 +1,2 @@ -#WRAPPER>#HEADER>.icon{display:block;position:absolute;top:0;left:0;width:4em;height:4em;background-color:#0082b8;background-image:url("../src/static/icon.svg");background-position:center center;background-repeat:no-repeat;background-size:50% 50%;cursor:pointer;transition:all .3s}#WRAPPER>#HEADER>.icon:hover{background-color:#00709f}#WRAPPER>#HEADER.loading>.icon{background-image:url("../src/static/loader.svg");background-size:70% 70%} +#WRAPPER>#HEADER>.icon{display:block;position:absolute;top:0;left:0;width:4em;height:4em;background-color:#0082b8;background-image:url("/f/svg/icon/st");background-position:center center;background-repeat:no-repeat;background-size:50% 50%;cursor:pointer;transition:all .3s}#WRAPPER>#HEADER>.icon:hover{background-color:#00709f}#WRAPPER>#HEADER.loading>.icon{background-image:url("/f/svg/loader/st");background-size:70% 70%} /*# sourceMappingURL=header.css.map */ diff --git a/css/header.scss b/css/header.scss index 6b7f148..7b93cc9 100755 --- a/css/header.scss +++ b/css/header.scss @@ -12,7 +12,7 @@ height: 4em; background-color: darken($theme-color, 10); - background-image: url('../src/static/icon.svg'); + background-image: url('/f/svg/icon/st'); background-position: center center; background-repeat: no-repeat; background-size: 50% 50%; @@ -30,7 +30,7 @@ /* Animation de chargement qudnd chargement ajax */ &.loading > .icon{ - background-image: url('../src/static/loader.svg'); + background-image: url('/f/svg/loader/st'); background-size: 70% 70%; } diff --git a/css/menu-side.css b/css/menu-side.css old mode 100644 new mode 100755 diff --git a/css/submenu-side.css b/css/submenu-side.css old mode 100644 new mode 100755 diff --git a/css/submenu-side.scss b/css/submenu-side.scss old mode 100644 new mode 100755 diff --git a/index.php b/index.php old mode 100644 new mode 100755 index df33010..1bfd0f8 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ inclusion de la page $R->get('dashboard(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; }); + $R->get('profile(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; }); $R->get('machines(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; }); $R->get('users(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; }); $R->get('analytics(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; }); $R->get('settings(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; }); // nomPage -> nomPage/ - $R->get('dashboard', function(){ header('Location: /dashboard/'); }); - $R->get('machines', function(){ header('Location: /machines/'); }); - $R->get('users', function(){ header('Location: /users/'); }); - $R->get('analytics', function(){ header('Location: /analytics/'); }); - $R->get('settings', function(){ header('Location: /settings/'); }); + $R->get('dashboard', function(){ header('Location: /dashboard/'); }); + $R->get('profile', function(){ header('Location: /profile/'); }); + $R->get('machines', function(){ header('Location: /machines/'); }); + $R->get('users', function(){ header('Location: /users/'); }); + $R->get('analytics', function(){ header('Location: /analytics/'); }); + $R->get('settings', function(){ header('Location: /settings/'); }); - $R->get('dashboard/', function(){ include __ROOT__.'/view.php'; }); - $R->get('machines/', function(){ include __ROOT__.'/view.php'; }); - $R->get('users/', function(){ include __ROOT__.'/view.php'; }); - $R->get('analytics/', function(){ include __ROOT__.'/view.php'; }); - $R->get('settings/', function(){ include __ROOT__.'/view.php'; }); + // $R->get('dashboard/', function(){ include __ROOT__.'/view.php'; }); + // $R->get('machines/', function(){ include __ROOT__.'/view.php'; }); + // $R->get('users/', function(){ include __ROOT__.'/view.php'; }); + // $R->get('analytics/', function(){ include __ROOT__.'/view.php'; }); + // $R->get('settings/', function(){ include __ROOT__.'/view.php'; }); // Dispatcher $R->get('f(?:/([\w-]+))*/?', function(){ new manager\ResourcesDispatcher($_GET['url']); }); diff --git a/js/lib/page-manager.js b/js/lib/page-manager.js old mode 100644 new mode 100755 index a7f2bb1..d513b15 --- a/js/lib/page-manager.js +++ b/js/lib/page-manager.js @@ -22,8 +22,8 @@ pageManagerClass.prototype = { page: null, // l'indice de la page courante dans pagelist vars: [], // les variables suivant le nom de la page dans l'URL path: '', // le chemin du dossier contenant les pages (.php) - jsPath: 'js', // le chemin du dossier contenant les scripts (.js) - cssPath: 'css', // le chemin du dossier contenant les feuilles de style (.css) + jsPath: '/f/jsview/', // le chemin du dossier contenant les scripts (.js) + cssPath: '/f/cssview/', // le chemin du dossier contenant les feuilles de style (.css) pagelist: null, // la liste des pages pouvant être chargées container: null, // élément DOM qui contiendra le contenu des pages à charger /* ======================================================================= diff --git a/js/lib/reset.js b/js/lib/reset.js old mode 100644 new mode 100755 diff --git a/manager/Database.php b/manager/Database.php new file mode 100755 index 0000000..cf79f62 --- /dev/null +++ b/manager/Database.php @@ -0,0 +1,104 @@ +host = $host; + $this->dbname = $dbname; + $this->username = $username; + $this->password = $password; + + // password: Qt358nUdyeTxLDM8 + self::$pdo = new \PDO('mysql:host='.$host.';dbname='.$dbname, $username, $password); + } + + + /* retourne une instance de la classe */ + public static function getInstance(){ + if( self::$instance == null ){ + + // chargement de la configuration du server SQL + $conf = json_decode(file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/f/json/database/conf'), true); + self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']); + + } + + return self::$instance; + } + + /* retourne la connection statique */ + public static function getPDO(){ + $instance = self::getInstance(); + return self::$pdo; + } + + + /*************************************************************/ + /* _____ ______ _ _ ______ _____ _ */ + /* / ____| ____| \ | | ____| __ \ /\ | | */ + /* | | __| |__ | \| | |__ | |__) | / \ | | */ + /* | | |_ | __| | . ` | __| | _ / / /\ \ | | */ + /* | |__| | |____| |\ | |____| | \ \ / ____ \| |____ */ + /* \_____|______|_| \_|______|_| \_\/_/ \_\______| */ + /* */ + /*************************************************************/ + + /* SUPPRIME LES VALEURS À CLÉS NUMÉRIQUES DANS UN FETCH D'UNE TABLE DE LA BDD + * + * @fetchData le résultat d'une $requeteSQL->fetchAll() + * + * @return newFetchData retourne le tableau donné en paramètre mais sans les valeurs à clés numériques + * + */ + public static function delNumeric($fetchData, $oneDimension=false){ + + /* [1] 2 dimensions + ===============================================*/ + if( !$oneDimension ){ + + // on supprime les doublons des entrées (indice numérique) + for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs + foreach($fetchData[$i] as $col => $val){ // pour toutes les entrées + + if( !mb_detect_encoding($val, 'UTF-8') ) + $fetchData[$i][$col] = utf8_encode($val); + + if( is_int($col) ) // si l'indice est un entier + unset( $fetchData[$i][$col] ); // on le supprime + } + + /* [2] 1 dimensions + ===============================================*/ + }else{ + + // on supprime les doublons des entrées (indice numérique) + foreach($fetchData as $i=>$val){ // pour toutes les entrées + + if( !mb_detect_encoding($val, 'UTF-8') ) + $fetchData[$i] = utf8_encode($val); + + if( is_int($i) ) // si l'indice est un entier + unset( $fetchData[$i] ); // on le supprime + } + + } + + return $fetchData; + } + + } + +?> diff --git a/manager/ResourcesDispatcher.php b/manager/ResourcesDispatcher.php index 5c2dac8..497a4d4 100755 --- a/manager/ResourcesDispatcher.php +++ b/manager/ResourcesDispatcher.php @@ -31,11 +31,11 @@ /* [0] On met a jour la configuration =====================================================*/ // Extensions supportees - $extensions_conf = json_decode( file_get_contents('http://'.$_SERVER['HTTP_HOST'].self::$extension_config_path), true )['extensions']; + $extensions_conf = json_decode( file_get_contents('http://'.$_SERVER['HTTP_HOST'].self::$extension_config_path), true ); self::$supported_extensions = $extensions_conf; // Dossiers supportes - $parents_conf = json_decode( file_get_contents('http://'.$_SERVER['HTTP_HOST'].self::$parents_config_path), true )['parents']; + $parents_conf = json_decode( file_get_contents('http://'.$_SERVER['HTTP_HOST'].self::$parents_config_path), true ); self::$supported_parents = $parents_conf; diff --git a/manager/autoloader.php b/manager/autoloader.php old mode 100644 new mode 100755 index a3838c1..eb5d9af --- a/manager/autoloader.php +++ b/manager/autoloader.php @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/router/Route.php b/router/Route.php old mode 100644 new mode 100755 diff --git a/router/Router.php b/router/Router.php old mode 100644 new mode 100755 diff --git a/src/dynamic/create.svg b/src/dynamic/create.svg old mode 100644 new mode 100755 diff --git a/src/dynamic/edit.svg b/src/dynamic/edit.svg old mode 100644 new mode 100755 diff --git a/src/dynamic/filter.svg b/src/dynamic/filter.svg old mode 100644 new mode 100755 diff --git a/src/dynamic/remove.svg b/src/dynamic/remove.svg old mode 100644 new mode 100755 diff --git a/src/dynamic/search.svg b/src/dynamic/search.svg old mode 100644 new mode 100755 diff --git a/src/static/loader.svg b/src/static/loader.svg old mode 100644 new mode 100755 diff --git a/src/static/menu-side/users2.svg b/src/static/menu-side/users2.svg old mode 100644 new mode 100755 diff --git a/src/static/sub-menu-side/analytics.svg b/src/static/sub-menu-side/analytics.svg old mode 100644 new mode 100755 diff --git a/src/static/sub-menu-side/create.svg b/src/static/sub-menu-side/create.svg old mode 100644 new mode 100755 diff --git a/src/static/sub-menu-side/edit.svg b/src/static/sub-menu-side/edit.svg old mode 100644 new mode 100755 diff --git a/src/static/sub-menu-side/filter.svg b/src/static/sub-menu-side/filter.svg old mode 100644 new mode 100755 diff --git a/src/static/sub-menu-side/password.svg b/src/static/sub-menu-side/password.svg new file mode 100644 index 0000000..b9a1676 --- /dev/null +++ b/src/static/sub-menu-side/password.svg @@ -0,0 +1,50 @@ + +image/svg+xml \ No newline at end of file diff --git a/src/static/sub-menu-side/remove.svg b/src/static/sub-menu-side/remove.svg old mode 100644 new mode 100755 diff --git a/src/static/sub-menu-side/search.svg b/src/static/sub-menu-side/search.svg old mode 100644 new mode 100755 diff --git a/src/static/sub-menu-side/sync.svg b/src/static/sub-menu-side/sync.svg old mode 100644 new mode 100755 diff --git a/src/static/sub-menu-side/view.svg b/src/static/sub-menu-side/view.svg old mode 100644 new mode 100755 diff --git a/todo.md b/todo.md old mode 100644 new mode 100755 index 29e8708..96f4ee4 --- a/todo.md +++ b/todo.md @@ -4,16 +4,27 @@ - [ ] Dev des managers et de l'API et liste des acces - [ ] Creation de la base des managers et de l'API - [ ] Conception des managers et de l'API -- [ ] Conception BDD + ameliorations - [ ] Definir graphiquement le #CONTAINER - [ ] Structure - [ ] Elements - [ ] Affichages - [ ] Styles globaux + ############ # EN COURS # ############ +- [x] Conception BDD + ameliorations + - [x] Liste des tables + - [x] Liste de attributs + - [ ] Attributs statiques + - utilisateur (id, ) + - machine + - journal + - [ ] Attributs dynamiques + - les options + - les addons des attributs statiques + - [ ] Ameliorations et genericite possibles ######## diff --git a/view.php b/view.php index cb73e5a..4589d5a 100755 --- a/view.php +++ b/view.php @@ -10,20 +10,20 @@ - - - - - - - - + + + + + + + + - + - + @@ -42,7 +42,7 @@