Skip to content

Commit 67b03a7

Browse files
author
Prabath Perera
committed
Backup log view added
1 parent 6937520 commit 67b03a7

4 files changed

Lines changed: 220 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace app\controllers;
4+
5+
use Yii;
6+
use app\models\BackupLog;
7+
use app\models\BackupLogSearch;
8+
use yii\web\Controller;
9+
use yii\web\NotFoundHttpException;
10+
use yii\filters\VerbFilter;
11+
12+
/**
13+
* BackupLogController implements the CRUD actions for BackupLog model.
14+
*/
15+
class BackupLogController extends Controller
16+
{
17+
/**
18+
* @inheritdoc
19+
*/
20+
public function behaviors()
21+
{
22+
return [
23+
'verbs' => [
24+
'class' => VerbFilter::className(),
25+
'actions' => [
26+
'delete' => ['POST'],
27+
],
28+
],
29+
];
30+
}
31+
32+
/**
33+
* Lists all BackupLog models.
34+
* @return mixed
35+
*/
36+
public function actionIndex()
37+
{
38+
$searchModel = new BackupLogSearch();
39+
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
40+
41+
return $this->render('index', [
42+
'searchModel' => $searchModel,
43+
'dataProvider' => $dataProvider,
44+
]);
45+
}
46+
47+
/**
48+
* Displays a single BackupLog model.
49+
* @param integer $id
50+
* @return mixed
51+
*/
52+
public function actionView($id)
53+
{
54+
return $this->render('view', [
55+
'model' => $this->findModel($id),
56+
]);
57+
}
58+
59+
/**
60+
* Finds the BackupLog model based on its primary key value.
61+
* If the model is not found, a 404 HTTP exception will be thrown.
62+
* @param integer $id
63+
* @return BackupLog the loaded model
64+
* @throws NotFoundHttpException if the model cannot be found
65+
*/
66+
protected function findModel($id)
67+
{
68+
if (($model = BackupLog::findOne($id)) !== null) {
69+
return $model;
70+
} else {
71+
throw new NotFoundHttpException('The requested page does not exist.');
72+
}
73+
}
74+
}

models/BackupLogSearch.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace app\models;
4+
5+
use Yii;
6+
use yii\base\Model;
7+
use yii\data\ActiveDataProvider;
8+
use app\models\BackupLog;
9+
10+
/**
11+
* BackupLogSearch represents the model behind the search form about `app\models\BackupLog`.
12+
*/
13+
class BackupLogSearch extends BackupLog
14+
{
15+
/**
16+
* @inheritdoc
17+
*/
18+
public function rules()
19+
{
20+
return [
21+
[['id', 'schedule'], 'integer'],
22+
[['schema', 'artifact', 'hash', 'status', 'created_at'], 'safe'],
23+
];
24+
}
25+
26+
/**
27+
* @inheritdoc
28+
*/
29+
public function scenarios()
30+
{
31+
// bypass scenarios() implementation in the parent class
32+
return Model::scenarios();
33+
}
34+
35+
/**
36+
* Creates data provider instance with search query applied
37+
*
38+
* @param array $params
39+
*
40+
* @return ActiveDataProvider
41+
*/
42+
public function search($params)
43+
{
44+
$query = BackupLog::find();
45+
46+
// add conditions that should always apply here
47+
48+
$dataProvider = new ActiveDataProvider([
49+
'query' => $query,
50+
]);
51+
52+
$this->load($params);
53+
54+
if (!$this->validate()) {
55+
// uncomment the following line if you do not want to return any records when validation fails
56+
// $query->where('0=1');
57+
return $dataProvider;
58+
}
59+
60+
// grid filtering conditions
61+
$query->andFilterWhere([
62+
'id' => $this->id,
63+
'schedule' => $this->schedule,
64+
'created_at' => $this->created_at,
65+
]);
66+
67+
$query->andFilterWhere(['like', 'schema', $this->schema])
68+
->andFilterWhere(['like', 'artifact', $this->artifact])
69+
->andFilterWhere(['like', 'hash', $this->hash])
70+
->andFilterWhere(['like', 'status', $this->status]);
71+
72+
return $dataProvider;
73+
}
74+
}

views/backup-log/index.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use yii\helpers\Html;
4+
use yii\grid\GridView;
5+
6+
/* @var $this yii\web\View */
7+
/* @var $searchModel app\models\BackupLogSearch */
8+
/* @var $dataProvider yii\data\ActiveDataProvider */
9+
10+
$this->title = 'Backup Logs';
11+
$this->params['breadcrumbs'][] = $this->title;
12+
?>
13+
<div class="backup-log-index">
14+
15+
<h1><?= Html::encode($this->title) ?></h1>
16+
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17+
18+
<?= GridView::widget([
19+
'dataProvider' => $dataProvider,
20+
'filterModel' => $searchModel,
21+
'columns' => [
22+
'id',
23+
'schedule',
24+
'schema',
25+
'artifact',
26+
'hash',
27+
'status',
28+
'created_at',
29+
],
30+
]); ?>
31+
</div>

views/backup-log/view.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
use yii\helpers\Html;
4+
use yii\widgets\DetailView;
5+
6+
/* @var $this yii\web\View */
7+
/* @var $model app\models\BackupLog */
8+
9+
$this->title = $model->id;
10+
$this->params['breadcrumbs'][] = ['label' => 'Backup Logs', 'url' => ['index']];
11+
$this->params['breadcrumbs'][] = $this->title;
12+
?>
13+
<div class="backup-log-view">
14+
15+
<h1><?= Html::encode($this->title) ?></h1>
16+
17+
<p>
18+
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
19+
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
20+
'class' => 'btn btn-danger',
21+
'data' => [
22+
'confirm' => 'Are you sure you want to delete this item?',
23+
'method' => 'post',
24+
],
25+
]) ?>
26+
</p>
27+
28+
<?= DetailView::widget([
29+
'model' => $model,
30+
'attributes' => [
31+
'id',
32+
'schedule',
33+
'schema',
34+
'artifact',
35+
'hash',
36+
'status',
37+
'created_at',
38+
],
39+
]) ?>
40+
41+
</div>

0 commit comments

Comments
 (0)