diff --git a/.gitignore b/.gitignore index 7c19e99..7ae447d 100755 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ *.lock /vendor/ /phpunit/coverage -.vscode \ No newline at end of file +.vscode +TODO \ No newline at end of file diff --git a/build/api/module/clusterDefault.php b/build/api/module/clusterDefault.php index 3d1a200..039463a 100755 --- a/build/api/module/clusterDefault.php +++ b/build/api/module/clusterDefault.php @@ -426,7 +426,7 @@ /* RETOURNE LA LISTE DES MODULE D'UN GROUPE DE MACHINES * - * @id_cluster UID du groupe de machine + * @id_machine_cluster UID du groupe de machine * * @return modules Liste des modules autorisés pour le groupe de machines * @@ -438,9 +438,9 @@ /* [1] On récupère les modules =========================================================*/ /* (1) Récupération */ - $mod_req = new Repo('module/getByMachineCluster', [ + $mod_req = new Repo('module/getForMachineCluster', [ $_SESSION['WAREHOUSE']['id'], - $id_cluster + $id_machine_cluster ]); $answer = $mod_req->answer(); @@ -457,6 +457,44 @@ + + + + + + /* RETOURNE LES E-TREES D'UN GROUPE DE MACHINES + * + * @id_machine_cluster UID du groupe de machine + * + * @return etrees E-trees du groupe de machines + * + */ + public static function getEtrees($params){ + extract($params); + + + /* [1] On récupère les modules + =========================================================*/ + /* (1) Récupération */ + $mod_req = new Repo('etree/getForMachineCluster', [ + $_SESSION['WAREHOUSE']['id'], + $id_machine_cluster + ]); + + $answer = $mod_req->answer(); + + /* (2) Gestion erreur */ + if( $answer === false ) + return ['error' => new Error(Err::NoMatchFound)]; // no error + + + /* [3] On retourne la liste + =========================================================*/ + return [ 'etrees' => $answer ]; + } + + + } diff --git a/build/api/module/machineDefault.php b/build/api/module/machineDefault.php index 487893c..99bd2ff 100755 --- a/build/api/module/machineDefault.php +++ b/build/api/module/machineDefault.php @@ -481,7 +481,7 @@ $sorted_actions[$action['timeout']][] = [ 'id_action' => intval($action['id_action']), 'name' => strtolower($action['name']), - 'previous' => $action['previous'], + 'required' => $action['required'], 'action' => $action['action'] ]; } @@ -495,20 +495,17 @@ /* [4] On récupère la liste des MODULES (puces) =========================================================*/ - $chipsReq = new Repo('chip/getAll', [$_SESSION['WAREHOUSE']['id']]); + $chipsReq = new Repo('chip/getForMachine', [$_SESSION['WAREHOUSE']['id'], $id_machine]); $chips = ($chipsReq->error->get()==Err::Success) ? $chipsReq->answer() : []; foreach($chips as $c=>$chip){ /* [5] On récupére la liste des PINS de chaque PUCE =========================================================*/ - $pinsReq = new Repo('pin_merge/getByIdChip', [$chip['id_chip']]); - $pins = ($pinsReq->error->get()==Err::Success) ? $pinsReq->answer() : []; - - $chips[$c]['pins'] = []; - foreach($pins as $p=>$pin) - $chips[$c]['pins'][$p] = intval($pin['pin']); + $chips[$c]['pins'] = explode(',', $chip['pins']); + if( !is_array($chip['pins']) ) + $chips[$c]['pins'] = []; /* [6] On récupère valeurs pour chaque état de chaque PUCE =========================================================*/ @@ -520,7 +517,7 @@ // On met en forme les données : "val1,val2,val3" -> [val1, val2, val3] foreach($states as $s=>$state){ - $chips[$c]['states'][$state['state']] = explode(',', $state['pin_values']); + $chips[$c]['states'][$state['state']] = explode(',', $state['values']); foreach($chips[$c]['states'][$state['state']] as $s2=>$state2) $chips[$c]['states'][$state['state']][$s2] = intval($state2); } @@ -543,6 +540,7 @@ foreach($permissions as $p=>$permission){ $actionList = explode(',', $permission['id_action']); + foreach($actionList as $a=>$action) $actionList[$a] = intval($action); @@ -555,6 +553,49 @@ } + /* [6] On envoie les e-tree de la machine + =========================================================*/ + $etrees = []; + + /* (1) On essaie de récupérer les etree de la machine*/ + $mc_req = new Request('machineDefault/getClusters', ['id_machine' => $id_machine]); + + $mc_res = $mc_req->dispatch(); + + /* (2) Si on arrive à récupérer les clusters */ + if( $mc_res->error->get() == Err::Success ){ + + /* (3) Pour chaque cluster, on récupère les e-trees */ + foreach($mc_res->get('clusters') as $cluster){ + + /* (4) On les e-trees du cluster */ + $etree_req = new Request('clusterDefault/getEtrees', [ + 'id_machine_cluster' => $cluster['id_machine_cluster'] + ]); + + $etree_res = $etree_req->dispatch(); + + /* (5) Si erreur, on passe */ + if( $etree_res->error->get() != Err::Success ) + continue; + + /* (6) Sinon -> On entregistre les e-trees */ + foreach($etree_res->get('etrees') as $etree){ + $etree_value = $etree['name'].'-'.$etree['daemon']; + + /* (7) Si pas déja entregistré -> on l'ajoute */ + if( !in_array($etrees, $etree_name) ) + $etrees[] = $etree_name; + } + + + } + + } + + + + /* [N] Retourne les données @@ -563,7 +604,8 @@ 'actions' => $sorted_actions, 'states' => $globalStates, 'chips' => $chips, - 'permissions' => $indexed_permissions + 'permissions' => $indexed_permissions, + 'etrees' => $etrees ]; } diff --git a/build/database/repo/chip.php b/build/database/repo/chip.php index b7654a1..228ab18 100755 --- a/build/database/repo/chip.php +++ b/build/database/repo/chip.php @@ -11,16 +11,59 @@ protected static function table_name(){ static $table_name = 'chip'; return $table_name; } - /* RENVOIE LA LISTE DES CARTES/PUCES DISPONIBLES EN FONCTION DES MODULES DE L'ENTREPOT + /* RENVOIE LA LISTE DES CARTES/PUCES DISPONIBLES EN FONCTION DES MODULES DU GROUPE DE MACHINE + * + * @id_warehouse UID de l'entrepot + * @id_machine UID de la machine * * @return chips Liste des puces/cartes disponibles * */ - public static function getAll($id_warehouse){ - /* [1] On récupère les modules de l'entrepot courant - =========================================================*/ - $module_merge = Table::get('module_merge') - ->whereIdWarehouse(7); + public static function getForMachine($id_warehouse, $id_machine){ + + /* (1) On récupère les groupes de la machine + ---------------------------------------------------------*/ + $get_clus = new Repo('machine/getClusters', [$id_warehouse, $id_machine]); + + $clusters = $get_clus->answer(); + + if( $clusters === false ) + return []; + + + /* (2) On récupère les modules associés aux clusters + ---------------------------------------------------------*/ + $module_ids = []; + + foreach($clusters as $cluster){ + + $get_mods = new Repo('module/getForMachineCluster', [$id_warehouse, $cluster['id_machine_cluster']]); + + $mods = $get_mods->answer(); + + // si pas déja -> on ajoute l'id module à la liste + if( is_array($mods) && !in_array($mods['id_module'], $module_ids) ) + $module_ids[] = $mods['id_module']; + + } + + + /* (3) On récupère la liste des CHIPS + ---------------------------------------------------------*/ + $chips = []; + foreach($module_ids as $module_id){ + + $chip_req = Table::get('chip') + ->select('*') + ->whereIdModule($module_id); + + $fetched = $chip_req->fetch(); + + // only one by ids + $chips[$fetched['id_chip']] = $fetched; + + } + $chip = Table::get('chip') diff --git a/build/database/repo/etree.php b/build/database/repo/etree.php new file mode 100644 index 0000000..459843c --- /dev/null +++ b/build/database/repo/etree.php @@ -0,0 +1,202 @@ + UID of the given warehouse + * @id_machine_cluster UID of the given machine_cluster + * + * @return etrees The list of etrees + * FALSE on error + * + =========================================================*/ + public static function getForMachineCluster($id_warehouse, $id_machine_cluster){ + + /* (1) On récupère le ETREE de la machine + ---------------------------------------------------------*/ + $module = Table::get('module') + ->select('id_module') + ->select('name'); + + $etree = Table::get('etree') + ->select('id_etree') + ->select('daemon') + ->join('id_module', $module); + + $merge = Table::get('module_merge') + ->join('id_etree', $etree) + ->whereIdWarehouse($id_warehouse) + ->whereIdMachineCluster($id_machine_cluster); + + return $merge->fetch(); + + } + + + + + + + + + + + + /* [4] Adds a module to machine cluster of a warehouse + * + * @id_warehouse UID of the given warehouse + * @id_machine_cluster UID of the given machine_cluster + * @id_module UID of the given module + * + * @return status TRUE on success + * + =========================================================*/ + public static function link($id_warehouse, $id_machine_cluster, $id_module){ + + /* (1) Check module + ---------------------------------------------------------*/ + /* (1) Check if module exists (by its id) */ + $module = Table::get('module') + ->select('*') + ->unique() + ->whereId($id_module); + + if( !$module->fetch() ) + return false; + + /* (2) Check if the module is allowed in the warehouse */ + $module_m = Table::get('module_availability') + ->select('*') + ->unique() + ->whereIdWarehouse($id_warehouse) + ->whereIdModule($id_module); + + // if not allowed in the warehouse -> error + if( !$module->fetch() ) + return false; + + + /* (2) Check machine_cluster + ---------------------------------------------------------*/ + /* (1) Check if machine_cluster exists (by its id) */ + $machine_cluster = Table::get('machine_cluster') + ->select('*') + ->unique() + ->whereIdWarehouse($id_warehouse) + ->whereId($id_machine_cluster); + + if( !$machine_cluster->fetch() ) + return false; + + /* (2) Check link does not already exists */ + $exists = Table::get('module_merge') + ->select('*') + ->unique() + ->whereIdWarehouse($id_warehouse) + ->whereIdMachineCluster($id_machine_cluster) + ->whereIdModule($id_module); + + if( !!$exists->fetch() ) + return true; // returns all right (even if nothing done) + + + + /* (3) Create link + ---------------------------------------------------------*/ + $inserted = Table::get('module_merge')->insert([ + 'id_warehouse' => $id_warehouse, + 'id_module' => $id_module, + 'id_machine_cluster' => $id_machine_cluster + ]); + + // return TRUE only if PDO insert successful + return $inserted; + + } + + + + + + + + /* [5] Removes a module from machine cluster of a warehouse + * + * @id_warehouse UID of the given warehouse + * @id_machine_cluster UID of the given machine_cluster + * @id_module UID of the given module + * + * @return status TRUE on success + * + =========================================================*/ + public static function unlink($id_warehouse, $id_machine_cluster, $id_module){ + + /* (1) Check module + ---------------------------------------------------------*/ + /* (1) Check if module exists (by its id) */ + $module = Table::get('module') + ->select('*') + ->unique() + ->whereId($id_module); + + if( !$module->fetch() ) + return false; + + + + /* (2) Check machine_cluster + ---------------------------------------------------------*/ + /* (1) Check if machine_cluster exists (by its id) */ + $machine_cluster = Table::get('machine_cluster') + ->select('*') + ->unique() + ->whereIdWarehouse($id_warehouse) + ->whereId($id_machine_cluster); + + if( !$machine_cluster->fetch() ) + return false; + + /* (2) Check if link already exists */ + $exists = Table::get('module_merge') + ->select('*') + ->unique() + ->whereIdWarehouse($id_warehouse) + ->whereIdMachineCluster($id_machine_cluster) + ->whereIdModule($id_module); + + if( !$exists->fetch() ) + return false; // returns all right (even if nothing done) + + + + /* (3) Remove link + ---------------------------------------------------------*/ + $deleted = Table::get('module_merge') + ->whereIdWarehouse($id_warehouse) + ->whereIdModule($id_module) + ->whereIdMachineCluster($id_machine_cluster) + ->delete(); + + // return TRUE only if PDO delete successful + return $deleted; + + } + + + + + + } + + +?> diff --git a/build/database/repo/module.php b/build/database/repo/module.php index 79d2f0b..1fb697e 100644 --- a/build/database/repo/module.php +++ b/build/database/repo/module.php @@ -37,7 +37,7 @@ * FALSE on error * =========================================================*/ - public static function getByWarehouse($id_warehouse){ + public static function getForWarehouse($id_warehouse){ /* (1) Build request */ $modules = Table::get('module')->select('*'); @@ -63,14 +63,21 @@ * FALSE on error * =========================================================*/ - public static function getByMachineCluster($id_warehouse, $id_machine_cluster){ + public static function getForMachineCluster($id_warehouse, $id_machine_cluster){ - /* (1) Build request */ - $modules = Table::get('module')->select('*'); - $merge = Table::get('module_merge') + /* (1) On récupère le ETREE de la machine + ---------------------------------------------------------*/ + $module = Table::get('module') + ->select('id_module') + ->select('name'); + + $etree = Table::get('etree') + ->join('id_module', $module); + + $merge = Table::get('module_merge') + ->join('id_etree', $etree) ->whereIdWarehouse($id_warehouse) ->whereIdMachineCluster($id_machine_cluster); - $merge->join('id_module', $modules); return $merge->fetch(); diff --git a/build/database/repo/pin_merge.php b/build/database/repo/pin_merge.php deleted file mode 100755 index 13b3a27..0000000 --- a/build/database/repo/pin_merge.php +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/build/database/repo/state.php b/build/database/repo/state.php index 2b1ff71..ae9160d 100755 --- a/build/database/repo/state.php +++ b/build/database/repo/state.php @@ -14,22 +14,21 @@ * * @id_chip UID de la puce * - * @return states Retourne les données sous forme de tableau de la forme (state, chip, pin, value) + * @return states Retourne les données sous forme de tableau de la forme (state, chip, pin, value) * */ public static function getForChip($id_chip){ - $req = DatabaseDriver::getPDO()->prepare("SELECT s.state, pm.id_chip, GROUP_CONCAT(s.value ORDER BY pm.pin ASC) as pin_values - FROM state as s, pin_merge as pm - WHERE s.id_pin_merge = pm.id_pin_merge - AND pm.id_chip = :id_chip - GROUP BY s.state, pm.id_chip"); - $req->execute([ - ':id_chip' => $id_chip - ]); + $chip = Table::get('chip') + ->select('id_chip') + ->whereId($id_chip); + $req = Table::get('state') + ->select('state') + ->select('value') + ->join('id_chip', $chip); - return $req->fetchAll(); + return $req->fetch(); } } diff --git a/build/database/repo/warehouse.php b/build/database/repo/warehouse.php index e0d640f..2c84a08 100755 --- a/build/database/repo/warehouse.php +++ b/build/database/repo/warehouse.php @@ -99,7 +99,7 @@ /* [1] On récupère les modules =========================================================*/ /* (1) Récupération */ - $mod_req = new Repo('module/getByWarehouse', [$id_warehouse]); + $mod_req = new Repo('module/getForWarehouse', [$id_warehouse]); $answer = $mod_req->answer(); diff --git a/build/viewer/view/group/view.php b/build/viewer/view/group/view.php index 304c6cf..6959476 100755 --- a/build/viewer/view/group/view.php +++ b/build/viewer/view/group/view.php @@ -61,16 +61,17 @@ })); $twig->addFunction(new \Twig_Function('f_options', function($id_cluster){ - $modReq = new Request('clusterDefault/getModules', [ - 'id_cluster' => (int) $id_cluster + $modReq = new Request('clusterDefault/getEtrees', [ + 'id_machine_cluster' => (int) $id_cluster ]); $modRes = $modReq->dispatch(); + // si erreur, on affiche rien par défaut if( $modRes->error->get() != Err::Success ) return []; - return $modRes->get('modules'); + return $modRes->get('etrees'); })); diff --git a/build/viewer/view/group/view.twig b/build/viewer/view/group/view.twig index 7887d17..4a84a3d 100755 --- a/build/viewer/view/group/view.twig +++ b/build/viewer/view/group/view.twig @@ -62,9 +62,9 @@ {{ p_icon.option | raw }} - {% for option in f_options(id_machine_cluster) %} + {% for option in f_options(machine_cluster.id_machine_cluster) %} - {{ option.name }} + {{ option.name }}:{{ option.daemon }} {% else %} Aucune option diff --git a/build/viewer/view/machine/groups.php b/build/viewer/view/machine/groups.php index 99fd598..774d82a 100755 --- a/build/viewer/view/machine/groups.php +++ b/build/viewer/view/machine/groups.php @@ -62,16 +62,17 @@ })); $twig->addFunction(new \Twig_Function('f_options', function($id_cluster){ - $modReq = new Request('clusterDefault/getModules', [ - 'id_cluster' => (int) $id_cluster + $modReq = new Request('clusterDefault/getEtrees', [ + 'id_machine_cluster' => (int) $id_cluster ]); $modRes = $modReq->dispatch(); + // si erreur, on affiche rien par défaut if( $modRes->error->get() != Err::Success ) return []; - return $modRes->get('modules'); + return $modRes->get('etrees'); })); diff --git a/build/viewer/view/machine/groups.twig b/build/viewer/view/machine/groups.twig index 28011d1..1fc09e8 100755 --- a/build/viewer/view/machine/groups.twig +++ b/build/viewer/view/machine/groups.twig @@ -20,7 +20,7 @@ {{ p_icon.option | raw }} {% for option in f_options(cluster.id_machine_cluster) %} - {{ option.name }} + {{ option.name }}:{{ option.daemon }} {% else %} Aucune option diff --git a/config/modules.json b/config/modules.json index e168521..9e91599 100755 --- a/config/modules.json +++ b/config/modules.json @@ -1,18 +1,6 @@ { "module": { - "POST::method": { - "description": "Test de l'API", - "permissions": [["warehouse"]], - "parameters": {} - }, - - "POST::markdown": { - "description": "Retourne une description en markdown des différents modules de l'API", - "permissions": [["admin"]], - "options": { "download": true }, - "parameters": {} - }, "POST::apiBlueprint": { "description": "Retourne une documentation de l'API au format API Blueprint.", @@ -20,40 +8,7 @@ "options": { "download": true }, "parameters": {} } - }, - - "upload": { - - "POST::call_log": { - "description": "Upload d'un journal d'appel au format .xml. Retour des données de call_log/unserialize", - "permissions": [["admin"]], - "parameters": { - "file": { "description": "Fichier du journal d'appel.", "type": "FILE" } - }, - "output": { - "tmp_id": { "description": "Identifiant temporaire du journal d'appel", "type": "varchar(40,40)" }, - "directory": { "description": "Annuaire des contacts trouvés", "type": "array>" }, - "call": { "description": "Liste des identifiants des contacts triés par nombre d'appels", "type": "array" }, - "sms": { "description": "Liste des identifiants des contacts triés par nombre de sms", "type": "array" } - } - } - }, - - "download": { - - "POST::multiple": { - "description": "Download des données relatives aux sujets donnés.", - "permissions": [["admin"]], - "options": { "download": true }, - "parameters": { - "subjects": { "description": "Identifiants des sujets d'enquêtes à intégrer.", "type": "array", "optional": true }, - "phone": { "description": "Si vaut TRUE, renvoie les sujets cellulaires.", "type": "boolean", "optional": true }, - "facebook": { "description": "Si vaut TRUE, renvoie les sujet facebook.", "type": "boolean", "optional": true }, - "survey": { "description": "Si vaut TRUE, renvoie les sujets ResTIC.", "type": "boolean", "optional": true }, - "all": { "description": "Si vaut TRUE, renvoie tous les sujets enregistrés.", "type": "boolean", "optional": true } - } - } }, @@ -509,11 +464,22 @@ "description": "Retourne les modules d'un groupe de machines", "permissions": [["admin"]], "parameters": { - "id_cluster": { "description": "UID du groupe de machines", "type": "id" } + "id_machine_cluster": { "description": "UID du groupe de machines", "type": "id" } }, "output": { "modules": { "description": "Modules du groupe", "type": "array" } } + }, + + "POST::getEtrees": { + "description": "Retourne les e-trees d'un groupe de machines", + "permissions": [["admin"]], + "parameters": { + "id_machine_cluster": { "description": "UID du groupe de machines", "type": "id" } + }, + "output": { + "etrees": { "description": "E-trees du groupe", "type": "array" } + } } }, diff --git a/config/repositories.json b/config/repositories.json index 4ac7bd0..c7f483d 100755 --- a/config/repositories.json +++ b/config/repositories.json @@ -2,12 +2,16 @@ "module": [ "getAll", - "getByWarehouse", - "getByMachineCluster", + "getForWarehouse", + "getForMachineCluster", "link", "unlink" ], + "etree": [ + "getForMachineCluster" + ], + "history": [ "create", "delete", @@ -131,8 +135,7 @@ "action": [ "getAll", "getById" ], "global_state": [ "getAll" ], - "chip": [ "getAll" ], - "pin_merge": [ "getAll", "getByIdChip" ], + "chip": [ "getForMachine" ], "state": [ "getForChip" ], "warehouse": [ diff --git a/logauth.sql b/logauth.sql index 4d09902..3c58abc 100644 --- a/logauth.sql +++ b/logauth.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Host: localhost --- Generation Time: Sep 23, 2017 at 07:46 PM +-- Generation Time: Sep 25, 2017 at 04:37 PM -- Server version: 5.7.19-0ubuntu0.16.04.1 -- PHP Version: 7.0.22-0ubuntu0.16.04.1 @@ -28,11 +28,12 @@ USE `logauth`; -- Table structure for table `action` -- +DROP TABLE IF EXISTS `action`; CREATE TABLE `action` ( `id_action` int(11) NOT NULL, `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `timeout` int(11) NOT NULL, - `previous` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'started | signaled | locked', + `required` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'started | signaled | locked', `action` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'start | signal | lock' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -40,10 +41,10 @@ CREATE TABLE `action` ( -- Dumping data for table `action` -- -INSERT INTO `action` (`id_action`, `name`, `timeout`, `previous`, `action`) VALUES +INSERT INTO `action` (`id_action`, `name`, `timeout`, `required`, `action`) VALUES (1, 'Start', 0, '0X0', '1XX'), -(2, 'Signal', 1, 'XX0', '11X'), -(3, 'Lock', 2, 'XX0', '001'), +(2, 'Signal', 3, 'XX0', '11X'), +(3, 'Lock', 5, 'XX0', '001'), (4, 'Unlock', 0, 'XX1', '000'), (5, 'Stop', 0, '1X0', '0XX'), (6, 'Unsignal', 0, 'X10', 'X00'); @@ -54,6 +55,7 @@ INSERT INTO `action` (`id_action`, `name`, `timeout`, `previous`, `action`) VALU -- Table structure for table `action_merge` -- +DROP TABLE IF EXISTS `action_merge`; CREATE TABLE `action_merge` ( `id_action_merge` int(11) NOT NULL, `id_target` int(11) NOT NULL, @@ -97,6 +99,7 @@ INSERT INTO `action_merge` (`id_action_merge`, `id_target`, `id_source`, `id_act -- Table structure for table `admin` -- +DROP TABLE IF EXISTS `admin`; CREATE TABLE `admin` ( `id_admin` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -120,21 +123,45 @@ INSERT INTO `admin` (`id_admin`, `id_warehouse`, `username`, `mail`, `password`, -- Table structure for table `chip` -- +DROP TABLE IF EXISTS `chip`; CREATE TABLE `chip` ( `id_chip` int(11) NOT NULL, - `id_module` int(11) DEFAULT NULL, + `id_module` int(11) DEFAULT NULL COMMENT 'in global_state', `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `position` int(11) NOT NULL, - `type` varchar(10) COLLATE utf8_unicode_ci NOT NULL + `type` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `pins` text COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `chip` -- -INSERT INTO `chip` (`id_chip`, `id_module`, `name`, `position`, `type`) VALUES -(1, 1, 'led1', 0, 'SERIAL'), -(2, 1, 'relay1', 1, 'SERIAL'); +INSERT INTO `chip` (`id_chip`, `id_module`, `name`, `position`, `type`, `pins`) VALUES +(1, 1, 'led1', 0, 'digital', '4,17,27'), +(2, 1, 'relay1', 1, 'digital', '21'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `etree` +-- + +DROP TABLE IF EXISTS `etree`; +CREATE TABLE `etree` ( + `id_etree` int(11) NOT NULL, + `id_module` int(11) NOT NULL, + `daemon` varchar(30) COLLATE latin1_bin NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + +-- +-- Dumping data for table `etree` +-- + +INSERT INTO `etree` (`id_etree`, `id_module`, `daemon`) VALUES +(1, 1, 'read'), +(2, 3, 'emitter'), +(3, 3, 'receiver'); -- -------------------------------------------------------- @@ -142,6 +169,7 @@ INSERT INTO `chip` (`id_chip`, `id_module`, `name`, `position`, `type`) VALUES -- Table structure for table `global_state` -- +DROP TABLE IF EXISTS `global_state`; CREATE TABLE `global_state` ( `id_global_state` int(11) NOT NULL, `global_state` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'started | signaled | locked', @@ -164,6 +192,7 @@ INSERT INTO `global_state` (`id_global_state`, `global_state`, `chips`) VALUES -- Table structure for table `history` -- +DROP TABLE IF EXISTS `history`; CREATE TABLE `history` ( `id_history` int(11) NOT NULL, `timestamp` int(11) NOT NULL, @@ -202,6 +231,7 @@ INSERT INTO `history` (`id_history`, `timestamp`, `id_user`, `id_machine`, `id_a -- Table structure for table `log` -- +DROP TABLE IF EXISTS `log`; CREATE TABLE `log` ( `id_log` int(11) NOT NULL, `id_feature` int(11) NOT NULL, @@ -216,6 +246,7 @@ CREATE TABLE `log` ( -- Table structure for table `machine` -- +DROP TABLE IF EXISTS `machine`; CREATE TABLE `machine` ( `id_machine` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -355,6 +386,7 @@ INSERT INTO `machine` (`id_machine`, `id_warehouse`, `name`, `token`, `unlock_co -- Table structure for table `machine_cluster` -- +DROP TABLE IF EXISTS `machine_cluster`; CREATE TABLE `machine_cluster` ( `id_machine_cluster` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -378,6 +410,7 @@ INSERT INTO `machine_cluster` (`id_machine_cluster`, `id_warehouse`, `name`) VAL -- Table structure for table `machine_cluster_merge` -- +DROP TABLE IF EXISTS `machine_cluster_merge`; CREATE TABLE `machine_cluster_merge` ( `id_machine_cluster_merge` int(11) NOT NULL, `id_machine_cluster` int(11) NOT NULL, @@ -392,7 +425,15 @@ INSERT INTO `machine_cluster_merge` (`id_machine_cluster_merge`, `id_machine_clu (3, 1, 58), (4, 2, 75), (5, 3, 6), -(6, 2, 58); +(6, 2, 58), +(9, 4, 122), +(10, 4, 123), +(11, 4, 124), +(12, 4, 125), +(13, 5, 126), +(14, 5, 127), +(15, 5, 128), +(16, 5, 129); -- -------------------------------------------------------- @@ -400,6 +441,7 @@ INSERT INTO `machine_cluster_merge` (`id_machine_cluster_merge`, `id_machine_clu -- Table structure for table `module` -- +DROP TABLE IF EXISTS `module`; CREATE TABLE `module` ( `id_module` int(11) NOT NULL, `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL @@ -410,9 +452,10 @@ CREATE TABLE `module` ( -- INSERT INTO `module` (`id_module`, `name`) VALUES -(1, 'motheure'), -(2, 'portail'), -(3, 'upload'); +(1, 'rfid'), +(2, 'motheure'), +(3, 'portail'), +(4, 'autostop'); -- -------------------------------------------------------- @@ -420,6 +463,7 @@ INSERT INTO `module` (`id_module`, `name`) VALUES -- Table structure for table `module_availability` -- +DROP TABLE IF EXISTS `module_availability`; CREATE TABLE `module_availability` ( `id_warehouse` int(11) NOT NULL, `id_module` int(11) NOT NULL @@ -433,7 +477,8 @@ INSERT INTO `module_availability` (`id_warehouse`, `id_module`) VALUES (7, 1), (8, 1), (7, 2), -(8, 2); +(8, 2), +(8, 3); -- -------------------------------------------------------- @@ -441,35 +486,23 @@ INSERT INTO `module_availability` (`id_warehouse`, `id_module`) VALUES -- Table structure for table `module_merge` -- +DROP TABLE IF EXISTS `module_merge`; CREATE TABLE `module_merge` ( `id_module_merge` int(11) NOT NULL, `id_machine_cluster` int(11) NOT NULL, - `id_module` int(11) NOT NULL, + `id_etree` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; --- -------------------------------------------------------- - -- --- Table structure for table `pin_merge` +-- Dumping data for table `module_merge` -- -CREATE TABLE `pin_merge` ( - `id_pin_merge` int(11) NOT NULL, - `id_chip` int(11) NOT NULL, - `pin` int(11) NOT NULL, - `type` varchar(20) COLLATE utf8_unicode_ci NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - --- --- Dumping data for table `pin_merge` --- - -INSERT INTO `pin_merge` (`id_pin_merge`, `id_chip`, `pin`, `type`) VALUES -(1, 1, 4, 'SERIAL'), -(2, 1, 17, 'SERIAL'), -(3, 1, 27, 'SERIAL'), -(4, 2, 21, 'SERIAL'); +INSERT INTO `module_merge` (`id_module_merge`, `id_machine_cluster`, `id_etree`, `id_warehouse`) VALUES +(1, 4, 1, 8), +(2, 5, 1, 8), +(3, 4, 2, 8), +(4, 5, 2, 8); -- -------------------------------------------------------- @@ -477,32 +510,25 @@ INSERT INTO `pin_merge` (`id_pin_merge`, `id_chip`, `pin`, `type`) VALUES -- Table structure for table `state` -- +DROP TABLE IF EXISTS `state`; CREATE TABLE `state` ( `id_state` int(11) NOT NULL, - `id_pin_merge` int(11) NOT NULL, + `id_chip` int(11) NOT NULL, `state` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `value` smallint(4) NOT NULL + `value` text COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `state` -- -INSERT INTO `state` (`id_state`, `id_pin_merge`, `state`, `value`) VALUES -(1, 1, '0', 1), -(2, 2, '0', 1), -(3, 3, '0', 1), -(4, 1, 'G', 1), -(5, 2, 'G', 0), -(6, 3, 'G', 1), -(7, 1, 'B', 1), -(8, 2, 'B', 1), -(9, 3, 'B', 0), -(10, 1, 'R', 0), -(11, 2, 'R', 1), -(12, 3, 'R', 1), -(13, 4, '0', 0), -(14, 4, '1', 1); +INSERT INTO `state` (`id_state`, `id_chip`, `state`, `value`) VALUES +(15, 1, '0', '1,1,1'), +(16, 1, 'R', '0,1,1'), +(17, 1, 'G', '1,0,1'), +(18, 1, 'B', '1,1,0'), +(19, 2, '0', '0'), +(20, 2, '1', '1'); -- -------------------------------------------------------- @@ -510,6 +536,7 @@ INSERT INTO `state` (`id_state`, `id_pin_merge`, `state`, `value`) VALUES -- Table structure for table `user` -- +DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id_user` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -623,6 +650,7 @@ INSERT INTO `user` (`id_user`, `id_warehouse`, `code`, `username`, `firstname`, -- Table structure for table `user_cluster` -- +DROP TABLE IF EXISTS `user_cluster`; CREATE TABLE `user_cluster` ( `id_user_cluster` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -646,6 +674,7 @@ INSERT INTO `user_cluster` (`id_user_cluster`, `id_warehouse`, `name`) VALUES -- Table structure for table `user_cluster_merge` -- +DROP TABLE IF EXISTS `user_cluster_merge`; CREATE TABLE `user_cluster_merge` ( `id_user_cluster_merge` int(11) NOT NULL, `id_user_cluster` int(11) NOT NULL, @@ -677,6 +706,7 @@ INSERT INTO `user_cluster_merge` (`id_user_cluster_merge`, `id_user_cluster`, `i -- Table structure for table `warehouse` -- +DROP TABLE IF EXISTS `warehouse`; CREATE TABLE `warehouse` ( `id_warehouse` int(11) NOT NULL, `name` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, @@ -726,6 +756,13 @@ ALTER TABLE `chip` ADD PRIMARY KEY (`id_chip`), ADD KEY `id_module` (`id_module`); +-- +-- Indexes for table `etree` +-- +ALTER TABLE `etree` + ADD PRIMARY KEY (`id_etree`), + ADD KEY `id_module` (`id_module`); + -- -- Indexes for table `global_state` -- @@ -791,22 +828,15 @@ ALTER TABLE `module_availability` ALTER TABLE `module_merge` ADD PRIMARY KEY (`id_module_merge`), ADD KEY `id_machine_cluster` (`id_machine_cluster`), - ADD KEY `id_machine` (`id_module`), + ADD KEY `id_machine` (`id_etree`), ADD KEY `id_warehouse` (`id_warehouse`); --- --- Indexes for table `pin_merge` --- -ALTER TABLE `pin_merge` - ADD PRIMARY KEY (`id_pin_merge`), - ADD KEY `id_chip` (`id_chip`); - -- -- Indexes for table `state` -- ALTER TABLE `state` ADD PRIMARY KEY (`id_state`), - ADD KEY `id_pin_merge` (`id_pin_merge`); + ADD KEY `id_pin_merge` (`id_chip`); -- -- Indexes for table `user` @@ -861,6 +891,11 @@ ALTER TABLE `admin` ALTER TABLE `chip` MODIFY `id_chip` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- +-- AUTO_INCREMENT for table `etree` +-- +ALTER TABLE `etree` + MODIFY `id_etree` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; +-- -- AUTO_INCREMENT for table `global_state` -- ALTER TABLE `global_state` @@ -889,27 +924,22 @@ ALTER TABLE `machine_cluster` -- AUTO_INCREMENT for table `machine_cluster_merge` -- ALTER TABLE `machine_cluster_merge` - MODIFY `id_machine_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; + MODIFY `id_machine_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; -- -- AUTO_INCREMENT for table `module` -- ALTER TABLE `module` - MODIFY `id_module` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; + MODIFY `id_module` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `module_merge` -- ALTER TABLE `module_merge` - MODIFY `id_module_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=59; --- --- AUTO_INCREMENT for table `pin_merge` --- -ALTER TABLE `pin_merge` - MODIFY `id_pin_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; + MODIFY `id_module_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `state` -- ALTER TABLE `state` - MODIFY `id_state` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; + MODIFY `id_state` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21; -- -- AUTO_INCREMENT for table `user` -- @@ -924,7 +954,7 @@ ALTER TABLE `user_cluster` -- AUTO_INCREMENT for table `user_cluster_merge` -- ALTER TABLE `user_cluster_merge` - MODIFY `id_user_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=89; + MODIFY `id_user_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=88; -- -- AUTO_INCREMENT for table `warehouse` -- @@ -954,6 +984,12 @@ ALTER TABLE `admin` ALTER TABLE `chip` ADD CONSTRAINT `chip_id_module` FOREIGN KEY (`id_module`) REFERENCES `module` (`id_module`) ON DELETE CASCADE ON UPDATE CASCADE; +-- +-- Constraints for table `etree` +-- +ALTER TABLE `etree` + ADD CONSTRAINT `fk_etree_id_module` FOREIGN KEY (`id_module`) REFERENCES `module` (`id_module`) ON DELETE CASCADE ON UPDATE CASCADE; + -- -- Constraints for table `history` -- @@ -999,21 +1035,15 @@ ALTER TABLE `module_availability` -- Constraints for table `module_merge` -- ALTER TABLE `module_merge` + ADD CONSTRAINT `fk_module_merge_id_etree` FOREIGN KEY (`id_etree`) REFERENCES `etree` (`id_etree`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `fk_module_merge_id_machine_cluster` FOREIGN KEY (`id_machine_cluster`) REFERENCES `machine_cluster` (`id_machine_cluster`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `fk_module_merge_id_module` FOREIGN KEY (`id_module`) REFERENCES `module` (`id_module`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `fk_module_merge_id_warehouse` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`id_warehouse`) ON DELETE CASCADE ON UPDATE CASCADE; --- --- Constraints for table `pin_merge` --- -ALTER TABLE `pin_merge` - ADD CONSTRAINT `pin_id_chip` FOREIGN KEY (`id_chip`) REFERENCES `chip` (`id_chip`) ON DELETE CASCADE ON UPDATE CASCADE; - -- -- Constraints for table `state` -- ALTER TABLE `state` - ADD CONSTRAINT `state_id_pin_merge` FOREIGN KEY (`id_pin_merge`) REFERENCES `pin_merge` (`id_pin_merge`); + ADD CONSTRAINT `fk_state_id_chip` FOREIGN KEY (`id_chip`) REFERENCES `chip` (`id_chip`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `user` diff --git a/public_html/css/container.scss b/public_html/css/container.scss index 4938ed6..a415cab 100755 --- a/public_html/css/container.scss +++ b/public_html/css/container.scss @@ -337,6 +337,7 @@ .option > span.ignore > span{ border-radius: 3px; + margin-right: .4em; } /* (5) Lien vers la modification */ diff --git a/public_html/css/min/container.css b/public_html/css/min/container.css index 85eb9fc..a1da2cf 100644 --- a/public_html/css/min/container.css +++ b/public_html/css/min/container.css @@ -539,6 +539,7 @@ #WRAPPER > #CONTAINER > section > .inline-box .option > span.ignore > span, #WRAPPER > #CONTAINER > section > .inline-row .option > span.ignore > span { border-radius: 3px; + margin-right: .4em; } #WRAPPER > #CONTAINER > section > .inline-box .link_edit,