コード例 #1
0
ファイル: JobSearchModel.php プロジェクト: cychenyin/postmill
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = JobModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'host_strategy' => $this->host_strategy, 'restore_strategy' => $this->restore_strategy, 'retry_strategy' => $this->retry_strategy, 'error_strategy' => $this->error_strategy, 'exist_strategy' => $this->exist_strategy, 'running_timeout_s' => $this->running_timeout_s, 'status' => $this->status, 'modify_time' => $this->modify_time, 'create_time' => $this->create_time, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'next_run_time' => $this->next_run_time]);
     $query->andFilterWhere(['like', 'cmd', $this->cmd])->andFilterWhere(['like', 'cron_str', $this->cron_str])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'mails', $this->mails])->andFilterWhere(['like', 'phones', $this->phones])->andFilterWhere(['like', 'team', $this->team])->andFilterWhere(['like', 'owner', $this->owner])->andFilterWhere(['like', 'hosts', $this->hosts])->andFilterWhere(['like', 'modify_user', $this->modify_user])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'oupput_match_reg', $this->oupput_match_reg]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: indexBAK.php プロジェクト: cychenyin/postmill
    <?php 
echo $form->field($queryModel, 'stop')->radioList(['1' => '运行或系统暂停', '0' => '新建或终止']);
?>
    <div class="form-group">
        <?php 
echo Html::submitButton('query', ['class' => 'btn btn-primary']);
?>
    </div>
<?php 
ActiveForm::end();
?>
</div>

<div id="job-grid" class="grid-view">
<?php 
$dataProvider = new ActiveDataProvider(['query' => JobModel::find(), 'pagination' => ['pageSize' => 20]]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', 'name', 'cmd', 'cron_str', 'owner', 'hosts', ['class' => 'yii\\grid\\DataColumn', 'label' => 'Next_run_time', 'enableSorting' => 'True', 'value' => function ($data) {
    $dt = new DateTime();
    return $dt->setTimestamp($data->next_run_time)->format('Y-m-d H:i');
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {edit} {stop}', 'buttons' => ['view' => function ($url, $data, $key) {
    // return $data->status === 'editable' ? Html::a('view', $url) : '';
    return Html::a('view', '/index.php?r=job/view&job_id=' . $data->id);
}, 'edit' => function ($url, $model, $key) {
    return empty(Yii::$app->session['user']['name']) || $data->owner == Yii::$app->session['user']['name'] ? Html::a('edit', $url) : '';
}, 'stop' => function ($url, $model, $key) {
    return in_array($data->status, [1, 2]) ? Html::a('stop', $url) : Html::a('start', $url);
}], 'urlCreator' => function ($action, $model, $key, $index) {
    return '/index.php?r=job/' . $action . '&job_id=' . $model->id;
}]]]);
?>
</div>
コード例 #3
0
ファイル: JobController.php プロジェクト: cychenyin/postmill
 /**
  * Finds the JobModel model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return JobModel the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = JobModel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }