You are here

public function SensorDisappearedSensors::settingsForm in Monitoring 7

Adds UI to clear the missing sensor status.

Overrides SensorConfigurable::settingsForm

File

lib/Drupal/monitoring/Sensor/Sensors/SensorDisappearedSensors.php, line 35
Contains \Drupal\monitoring\Sensor\Sensors\SensorDisappearedSensors.

Class

SensorDisappearedSensors
Monitors if sensors disappeared without prior being disabled.

Namespace

Drupal\monitoring\Sensor\Sensors

Code

public function settingsForm($form, &$form_state) {
  $result = monitoring_sensor_run($this->info
    ->getName());
  $form = parent::settingsForm($form, $form_state);
  if ($result
    ->isCritical()) {
    $form['clear_missing_sensors_wrapper'] = array(
      '#type' => 'fieldset',
      '#title' => t('Missing sensors'),
      '#description' => t('This action will clear the missing sensors and the critical sensor status will go away.'),
      '#weight' => -10,
    );
    $form['clear_missing_sensors_wrapper']['info'] = array(
      '#type' => 'item',
      '#title' => t('Sensor message'),
      '#markup' => $result
        ->getMessage(),
    );
    $form['clear_missing_sensors_wrapper']['clear_missing_sensor'] = array(
      '#type' => 'submit',
      '#submit' => array(
        'monitoring_clear_missing_sensor_submit',
      ),
      '#value' => t('Clear missing sensors'),
    );
  }
  return $form;
}