OLTAdmin.php 6.0 KB

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