@name
";
break;
case 'cluster': return "
@name #@name
@icon_remove
@icon_edit
@icon_type
@_classtext (@nb_members)
@icon_group
@members
+
";
break;
default: return "
@clusterlist";
break;
}
}
public static function view($params){
$view = '';
/* [1] On récupère la liste des utilisateurs
=========================================================*/
$request = new ModuleRequest('clusterDefault/getAll'); // On utilise la methode 'getAll' du module 'clusterDefault'
$answer = $request->dispatch(); // On recupere la reponse
// si erreur, on affiche l'explicitation
if( $answer->error != ManagerError::Success )
return View::$htmlError;
$CLUSTERLIST = $answer->get('clusters');
foreach($CLUSTERLIST as $u=>$cluster){
$membersReq = new ModuleRequest('clusterDefault/getMembers', [ 'id_cluster' => $cluster['id_cluster'] ]);
$membersRes = $membersReq->dispatch();
/* (2) Gestion si erreur */
if( $membersRes->error == ManagerError::Success ) $members = $membersRes->get('members');
else $members = [];
$CLUSTERLIST[$u]['members'] = View::replaceMultiple(
self::template('member'),
$members,
[ 'id_cluster' => $cluster['id_cluster'] ]
);
$CLUSTERLIST[$u]['_classtext'] = ($cluster['class']==0) ? 'utilisateurs' : 'machines';
$CLUSTERLIST[$u]['nb_members'] = (count($members)<2) ? count($members).' membre' : count($members).'membres';
$CLUSTERLIST[$u]['icon_type'] = ($cluster['class']==0) ? file_get_contents( __ROOT__.'/src/static/menu-side/users.svg' ) : file_get_contents( __ROOT__.'/src/static/menu-side/device.svg' );
}
$view_cluster = View::replaceMultiple(
self::template('cluster'),
$CLUSTERLIST, [
'icon_remove' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' ),
'icon_group' => file_get_contents( __ROOT__.'/src/static/container/group.svg' ),
'icon_edit' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' )
]);
return View::replaceSingle(self::template(), [ 'clusterlist' => $view_cluster ]);
}
}
?>