public function actionDeleteRule()
 {
     if (true) {
         if (isset($_POST['delete'])) {
             foreach ($_POST['delete'] as $id) {
                 $rule = DiscoveryRule::findOne($id);
                 if ($rule->delete()) {
                     Yii::$app->getSession()->addFlash('success', Yii::t('topology', 'Rule {name} deleted', ['name' => $rule->name]));
                 } else {
                     Yii::$app->getSession()->setFlash('error', Yii::t('topology', 'Error deleting rule {name}', ['name' => $rule->name]));
                 }
             }
         }
     } else {
         Yii::$app->getSession()->addFlash('warning', Yii::t('topology', 'You are not allowed to delete rules'));
     }
     return $this->redirect('index');
 }
 static function loadFromDB($id)
 {
     $rule = parent::findOne($id);
     if (!isset($rule)) {
         return null;
     }
     $task = ScheduledTask::findOne(['obj_data' => $id, 'obj_class' => 'meican\\topology\\models\\DiscoveryTask']);
     if ($task) {
         $rule->freq = $task->freq;
         $rule->freq_enabled = true;
     }
     if ($rule->subscription_id) {
         $rule->subscribe_enabled = true;
     }
     return $rule;
 }
Exemple #3
0
 public function execute($ruleId)
 {
     $rule = DiscoveryRule::findOne($ruleId);
     $ds = new DiscoveryService();
     $ds->execute($this, $rule);
 }
Exemple #4
0
        <div class="box box-default">
            <div class="box-header with-border">
                <h3 class="box-title">Details</h3>
            </div>
            <div class="box-body">
                <?php 
echo $form->field($model, 'name')->textInput(['size' => 50]);
?>
                <?php 
echo $form->field($model, 'type')->dropDownList(ArrayHelper::map(DiscoveryRule::getTypes(), 'id', 'name'));
?>
                <?php 
echo $form->field($model, 'auto_apply')->dropDownList(ArrayHelper::map([['id' => false, 'name' => Yii::t("topology", 'Manually')], ['id' => true, 'name' => Yii::t("topology", 'Automatically')]], 'id', 'name'));
?>
                <?php 
echo $form->field($model, 'protocol')->dropDownList(ArrayHelper::map(DiscoveryRule::getProtocols(), 'id', 'name'));
?>
                <?php 
echo $form->field($model, 'url')->textInput(['size' => 50]);
?>
                <?php 
echo $form->field($model, 'freq')->hiddenInput()->label("");
?>
            </div>
            <div class="box-footer">
                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-6">
                        <button type="submit" class="btn btn-primary"><?php 
echo Yii::t("topology", 'Save');
?>
</button>