Dashboard.class.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. @nom: Dashboard
  4. @auteur: Valentin CARRUESCO (valentin.carruesco@sys1.fr)
  5. @description: Classe de gestion des dashboard de widgets
  6. */
  7. class Dashboard extends SQLiteEntity{
  8. public $id,$user,$label;
  9. protected $TABLE_NAME = 'plugin_dashboard_view';
  10. protected $CLASS_NAME = 'Dashboard';
  11. protected $object_fields =
  12. array(
  13. 'id'=>'key',
  14. 'user'=>'id',
  15. 'label'=>'longstring',
  16. 'default' => 'int'
  17. );
  18. function __construct(){
  19. parent::__construct();
  20. }
  21. public static function initForUser($id){
  22. foreach(array('Salon','Cuisine','Chambre','Garage','Système') as $room){
  23. $entity = new Dashboard();
  24. $entity->create();
  25. $entity->user = $id;
  26. $entity->label = $room;
  27. $entity->default = 0;
  28. $entity->save();
  29. }
  30. $entity = new Dashboard();
  31. $entity->create();
  32. $entity->user = $id;
  33. $entity->label = "Général";
  34. $entity->default = 1;
  35. $entity->save();
  36. $dashboard = $entity->id;
  37. $entity = new Widget();
  38. $entity->create();
  39. $widgets = array(
  40. 'dash_profil'=>array('cell'=>0,'column'=>0),
  41. 'dash_monitoring_ram'=>array('cell'=>0,'column'=>1),
  42. 'dash_monitoring_clock'=>array('cell'=>1,'column'=>1),
  43. 'dash_monitoring_system'=>array('cell'=>1,'column'=>1),
  44. 'dash_monitoring_network'=>array('cell'=>2,'column'=>1),
  45. 'dash_monitoring_services'=>array('cell'=>3,'column'=>1),
  46. 'dash_monitoring_hdd'=>array('cell'=>4,'column'=>1),
  47. 'dash_monitoring_disk'=>array('cell'=>5,'column'=>1),
  48. 'dash_monitoring_gpio'=>array('cell'=>1,'column'=>0),
  49. 'dash_monitoring_users'=>array('cell'=>0,'column'=>0),
  50. 'dash_monitoring_vocal'=>array('cell'=>5,'column'=>2),
  51. 'dash_monitoring_logs'=>array('cell'=>6,'column'=>2)
  52. );
  53. foreach($widgets as $widget=>$position):
  54. $entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\''.$widget.'\', \'null\', \''.$position['cell'].'\', \''.$position['column'].'\', \'\',\''.$dashboard.'\');');
  55. endforeach;
  56. return $dashboard;
  57. }
  58. }
  59. ?>