OLTAdmin.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. namespace FTTHBundle\Admin;
  3. use FTTHBundle\Form\AnchorType;
  4. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  5. use Sonata\AdminBundle\Datagrid\ListMapper;
  6. use Sonata\AdminBundle\Form\FormMapper;
  7. use Sonata\AdminBundle\Show\ShowMapper;
  8. use WorkflowBundle\Admin\WorkflowBaseAdmin;
  9. class OLTAdmin extends WorkflowBaseAdmin
  10. {
  11. public function configure()
  12. {
  13. $this->setTemplate('create', 'FTTHBundle:OLT:form.html.twig');
  14. $this->setTemplate('edit', 'FTTHBundle:OLT:form.html.twig');
  15. }
  16. /**
  17. * @param DatagridMapper $datagridMapper
  18. */
  19. protected function configureDatagridFilters(DatagridMapper $datagridMapper)
  20. {
  21. $datagridMapper
  22. ->add('name')
  23. ->add('model')
  24. ->add('ip')
  25. ->add('snmpCommunity')
  26. ->add('sshUser')
  27. ->add('sshPass')
  28. ->add('enablePass')
  29. ->add('sshConnect')
  30. ->add('sshPort')
  31. ->add('backups')
  32. ;
  33. }
  34. /**
  35. * @param ListMapper $listMapper
  36. */
  37. protected function configureListFields(ListMapper $listMapper)
  38. {
  39. $listMapper
  40. ->add('name')
  41. ->add('model')
  42. ->add('ip')
  43. ->add('snmpCommunity')
  44. ->add('sshUser')
  45. ->add('sshPass')
  46. ->add('enablePass')
  47. ->add('sshConnect')
  48. ->add('sshPort')
  49. ->add('enable')
  50. ->add('oltTimeout')
  51. ->add('backups')
  52. ->add('currentState','string', array('template' => 'WorkflowBundle:Workflow:base_list_field_current_state.html.twig'))
  53. ->add('_action', 'with-workflow-action', array(
  54. 'actions' => array(
  55. 'show' => array(),
  56. 'edit' => array(),
  57. 'delete' => array(),
  58. 'state' => array('template' => 'WorkflowBundle:Workflow:show_transitions.html.twig')
  59. )
  60. ))
  61. ;
  62. }
  63. /**
  64. * @param FormMapper $formMapper
  65. */
  66. protected function configureFormFields(FormMapper $formMapper)
  67. {
  68. $formMapper
  69. ->tab('default')
  70. ->with('')
  71. ->add('name')
  72. ->add('model', null, [
  73. 'query_builder' => function($qb) {
  74. return $qb->createQueryBuilder('o')
  75. ->orderBy('o.name', 'ASC')
  76. ;
  77. },
  78. ])
  79. ->end()
  80. ->end()
  81. ->tab('configuration')
  82. ->with('OLT')
  83. ->add('ip')
  84. ->add('snmpCommunity')
  85. ->add('sshUser')
  86. ->add('sshPass')
  87. ->add('enablePass')
  88. ->add('sshConnect', null, [
  89. 'help' => 'form.help_ssh_connect',
  90. ])
  91. ->add('sshPort')
  92. ->add('oltTimeout','integer', array('attr' => array('min' => 10, 'max' => 50)))
  93. ->end()
  94. ->end()
  95. ->tab('autodiscovery')
  96. ->with('olt_discovery_configuration')
  97. ->add('timeDiscovery', 'integer', array('attr' => array('min' => 0), 'help' => 'Set 0 to disable autodiscovery or set a x number to scan each x minutes the ONUs connected but without configuration'))
  98. ->add('clientId')
  99. ->add('discoveryProfile', null, array('help' => 'Profile to set the ONUs by autodiscovery'))
  100. ->end()
  101. ->end()
  102. ->tab('stats')
  103. ->with('olt_execute_time')
  104. ->add('executeSnmp')
  105. ->add('timeScan', 'integer', array('attr' => array('min' => 0)))
  106. ->add('timeOltScan', 'integer', array('attr' => array('min' => 0)))
  107. ->end()
  108. ->end()
  109. ->tab('Backups')
  110. ->with('Backup OLT')
  111. ->add('backups')
  112. ->add('files', AnchorType::class, array(
  113. 'required' => false,
  114. 'data' => $this->getSubject()->obtainFiles($this->getParameter('backups'))
  115. ))
  116. ->end()
  117. ->end()
  118. ;
  119. }
  120. /**
  121. * @param ShowMapper $showMapper
  122. */
  123. protected function configureShowFields(ShowMapper $showMapper)
  124. {
  125. $showMapper
  126. ->tab('default')
  127. ->with('')
  128. ->add('name')
  129. ->add('model')
  130. ->add('ip')
  131. ->add('snmpCommunity')
  132. ->add('sshUser')
  133. ->add('sshPass')
  134. ->add('enablePass')
  135. ->add('sshConnect')
  136. ->add('sshPort')
  137. ->add('oltTimeout')
  138. ->add('enable')
  139. ->end()
  140. ->end()
  141. ->tab('Log')
  142. ->with('Log')
  143. ->add('deviceLog','string', array(
  144. 'template' => 'DeviceBundle::show_device_log.html.twig',
  145. 'translation_domain' => 'DeviceBundle',
  146. ))
  147. ->end()
  148. ->end()
  149. ->tab('Backups')
  150. ->with('Backup OLT')
  151. ->add('backups')
  152. ->add('files', 'string', array(
  153. 'template' => 'FTTHBundle::show_backup_log.html.twig',
  154. 'translation_domain' => 'FTTHBundle'
  155. ))
  156. ->end()
  157. ->end()
  158. ;
  159. }
  160. }