2016-07-18 14:49:00 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace manager\view\machine;
|
|
|
|
|
use \manager\View;
|
|
|
|
|
use \manager\ModuleRequest;
|
|
|
|
|
use \manager\Authentification;
|
|
|
|
|
use \manager\ManagerError;
|
|
|
|
|
|
|
|
|
|
class groups{
|
|
|
|
|
|
|
|
|
|
public static function template($type=null){
|
|
|
|
|
|
|
|
|
|
switch($type){
|
|
|
|
|
case 'machine': return "
|
|
|
|
|
<span>
|
|
|
|
|
@name
|
2016-07-21 00:06:55 +00:00
|
|
|
|
<span class='rem-member' data-member='@id_machine' data-cluster='@id_cluster'></span>
|
2016-07-18 14:49:00 +00:00
|
|
|
|
</span>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'machine_cluster': return "
|
|
|
|
|
<article class='inline-box' id='@id_machine_cluster'>
|
2016-07-20 23:19:19 +00:00
|
|
|
|
|
2016-07-20 15:33:38 +00:00
|
|
|
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name</span>
|
2016-07-18 14:49:00 +00:00
|
|
|
|
<span class='link_remove' data-cluster='@id_machine_cluster'>@icon_remove</span>
|
|
|
|
|
|
2016-07-20 23:19:19 +00:00
|
|
|
|
<span class='link_edit' data-cluster='@id_machine_cluster'>@icon_edit</span>
|
|
|
|
|
|
2016-07-18 14:49:00 +00:00
|
|
|
|
<span class='code'>
|
|
|
|
|
@icon_type
|
2016-07-20 09:47:32 +00:00
|
|
|
|
<span>@count machines</span>
|
2016-07-18 14:49:00 +00:00
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span class='groups'>
|
|
|
|
|
@icon_group
|
|
|
|
|
@machines
|
|
|
|
|
<span class='add-member' data-cluster='@id_machine_cluster'>+</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
</article>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: return "
|
|
|
|
|
<input type='text' class='searchbar' placeholder='Recherche'>
|
|
|
|
|
@clusterlist";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function view($params){
|
|
|
|
|
$view = '';
|
|
|
|
|
|
|
|
|
|
/* [1] On récupère la liste des utilisateurs
|
|
|
|
|
=========================================================*/
|
|
|
|
|
$request = new ModuleRequest('clusterDefault/getAll', [
|
|
|
|
|
'class' => 1
|
|
|
|
|
]);
|
|
|
|
|
$answer = $request->dispatch();
|
|
|
|
|
|
|
|
|
|
// si erreur, on affiche l'explicitation
|
|
|
|
|
if( $answer->error != ManagerError::Success )
|
|
|
|
|
return View::$htmlError;
|
|
|
|
|
|
|
|
|
|
$CLUSTERLIST = $answer->get('clusters');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($CLUSTERLIST as $c=>$cluster){
|
|
|
|
|
$machinesReq = new ModuleRequest('clusterDefault/getMembers', [
|
|
|
|
|
'id_cluster' => $cluster['id_machine_cluster'],
|
|
|
|
|
'class' => 1
|
|
|
|
|
]);
|
|
|
|
|
$machinesRes = $machinesReq->dispatch();
|
|
|
|
|
|
|
|
|
|
/* (2) Gestion si erreur */
|
|
|
|
|
if( $machinesRes->error == ManagerError::Success ) $machines = $machinesRes->get('members');
|
|
|
|
|
else $machines = [];
|
|
|
|
|
|
|
|
|
|
$CLUSTERLIST[$c]['count'] = count($machines);
|
|
|
|
|
|
|
|
|
|
$CLUSTERLIST[$c]['machines'] = View::replaceMultiple(
|
|
|
|
|
self::template('machine'),
|
|
|
|
|
$machines,
|
2016-07-21 00:06:55 +00:00
|
|
|
|
[ 'id_cluster' => $cluster['id_machine_cluster'] ]
|
2016-07-18 14:49:00 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$view_cluster = View::replaceMultiple(
|
|
|
|
|
self::template('machine_cluster'),
|
|
|
|
|
$CLUSTERLIST, [
|
|
|
|
|
'icon_remove' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' ),
|
|
|
|
|
'icon_edit' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' ),
|
2016-07-18 14:53:01 +00:00
|
|
|
|
'icon_type' => file_get_contents( __ROOT__.'/src/static/menu-side/device.svg' ),
|
2016-07-18 14:49:00 +00:00
|
|
|
|
'icon_group' => file_get_contents( __ROOT__.'/src/static/container/group.svg' ),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return View::replaceSingle(self::template(), [ 'clusterlist' => $view_cluster ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|