Exemplo n.º 1
0
        <h3 class="box-title"><?php 
echo Yii::t("topology", "Discovered changes");
?>
</h3>
        <div class="box-tools">
            <button class="btn btn-sm btn-default" id="apply-all">Apply all changes</button>
        </div>
    </div>
    <div class="box-body">
        <?php 
Pjax::begin(['id' => 'change-pjax']);
echo Grid::widget(['id' => 'change-grid', 'filterModel' => $searchChange, 'dataProvider' => $changeProvider, 'columns' => array(['class' => 'yii\\grid\\ActionColumn', 'template' => '{apply}', 'buttons' => ['apply' => function ($url, $model) {
    return $model->status == Change::STATUS_APPLIED ? "" : Html::a('<span class="fa fa-check apply-btn"></span>', '#');
}], 'headerOptions' => ['style' => 'width: 2%;']], ['attribute' => 'domain', 'filter' => Html::activeDropDownList($searchChange, 'domain', ArrayHelper::map(Change::find()->where(['status' => Change::STATUS_PENDING])->asArray()->select("domain")->distinct(true)->orderBy("domain ASC")->all(), 'domain', 'domain'), ['class' => 'form-control', 'prompt' => 'any']), 'headerOptions' => ['style' => 'width: 16%;']], ['header' => Yii::t('topology', 'Type'), 'value' => function ($model) {
    return $model->getType();
}, 'filter' => Html::activeDropDownList($searchChange, 'type', ArrayHelper::map(Change::getTypes(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'any']), 'headerOptions' => ['style' => 'width: 7%;']], ['attribute' => 'item_type', 'filter' => Html::activeDropDownList($searchChange, 'item_type', ArrayHelper::map(Change::getItemTypes(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'any']), 'value' => function ($model) {
    return $model->getItemType();
}, 'headerOptions' => ['style' => 'width: 12%;']], ['attribute' => 'data', 'filter' => false, 'format' => 'raw', 'value' => function ($model) {
    return $model->getDetails();
}, 'headerOptions' => ['style' => 'width: 30%;']], ['header' => 'Status', 'filter' => false, 'format' => 'raw', 'value' => function ($model) {
    switch ($model->status) {
        case Change::STATUS_FAILED:
            return '<a href="#" title="' . $model->error . '"><span class="label label-danger">Failed</span></a>';
        case Change::STATUS_APPLIED:
            return '<span class="label label-success">Applied</span>';
        case Change::STATUS_PENDING:
            return '<span class="label label-primary">Pending</span>';
        default:
            return "";
    }
}, 'headerOptions' => ['style' => 'width: 5%;']])]);