2016-07-12 10:06:46 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
|
namespace viewer\view\machine;
|
|
|
|
|
use \viewer\core\Viewer;
|
|
|
|
|
use \api\core\ModuleRequest;
|
|
|
|
|
use \api\core\Authentification;
|
2016-07-12 10:06:46 +00:00
|
|
|
|
use \manager\ManagerError;
|
|
|
|
|
|
2016-08-06 09:32:50 +00:00
|
|
|
|
class machine_view{
|
2016-07-12 10:06:46 +00:00
|
|
|
|
|
|
|
|
|
public static function template($type=null){
|
|
|
|
|
|
|
|
|
|
switch($type){
|
|
|
|
|
case 'cluster': return "
|
|
|
|
|
<span>
|
|
|
|
|
@name
|
2016-07-24 13:35:00 +00:00
|
|
|
|
<span class='rem-group' data-group='@id_machine_cluster' data-machine='@id_machine'></span>
|
2016-07-12 10:06:46 +00:00
|
|
|
|
</span>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'machine': return "
|
|
|
|
|
<article class='inline-box' id='@id_machine'>
|
|
|
|
|
|
|
|
|
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
|
|
|
|
<span class='link_remove' data-machine='@id_machine'>@icon_remove</span>
|
|
|
|
|
|
|
|
|
|
<span class='link_edit' data-machine='@id_machine'>@icon_edit</span>
|
|
|
|
|
|
|
|
|
|
<span class='groups'>
|
|
|
|
|
@icon_group
|
|
|
|
|
@grouplist
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
</article>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: return "
|
|
|
|
|
<input type='text' class='searchbar' placeholder='Recherche'>
|
|
|
|
|
@machinelist";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function view($params){
|
|
|
|
|
$view = '';
|
|
|
|
|
|
|
|
|
|
/* [1] On récupère la liste des machines
|
|
|
|
|
=========================================================*/
|
|
|
|
|
$request = new ModuleRequest('machineDefault/getAll'); // On utilise la methode 'getAll' du module 'machineDefault'
|
|
|
|
|
$answer = $request->dispatch(); // On recupere la reponse
|
|
|
|
|
|
|
|
|
|
// si erreur, on affiche l'explicitation
|
|
|
|
|
if( $answer->error != ManagerError::Success )
|
2016-10-18 14:03:03 +00:00
|
|
|
|
return Viewer::$htmlError;
|
2016-07-12 10:06:46 +00:00
|
|
|
|
|
|
|
|
|
$MACHINELIST = $answer->get('machines');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($MACHINELIST as $u=>$machine){
|
|
|
|
|
$clustersReq = new ModuleRequest('machineDefault/getClusters', [ 'id_machine' => $machine['id_machine'] ]);
|
|
|
|
|
$clustersRes = $clustersReq->dispatch();
|
|
|
|
|
|
|
|
|
|
/* (2) Gestion si erreur */
|
|
|
|
|
if( $clustersRes->error == ManagerError::Success ) $clusters = $clustersRes->get('clusters');
|
|
|
|
|
else $clusters = [];
|
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
|
$MACHINELIST[$u]['grouplist'] = Viewer::replaceMultiple(
|
2016-07-12 10:06:46 +00:00
|
|
|
|
self::template('cluster'),
|
|
|
|
|
$clusters,
|
|
|
|
|
[ 'id_machine' => $machine['id_machine'] ]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
|
$view_machine = Viewer::replaceMultiple(
|
2016-07-12 10:06:46 +00:00
|
|
|
|
self::template('machine'),
|
|
|
|
|
$MACHINELIST, [
|
2016-10-18 14:03:03 +00:00
|
|
|
|
'icon_remove' => file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/remove.svg' ),
|
|
|
|
|
'icon_edit' => file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/edit.svg' ),
|
|
|
|
|
'icon_group' => file_get_contents( __PUBLIC__.'/src/static/container/group.svg' ),
|
2016-07-12 10:06:46 +00:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
|
return Viewer::replaceSingle(self::template(), [ 'machinelist' => $view_machine ]);
|
2016-07-12 10:06:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|