/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
backend/widgets/server/HealthCheckWidget.php
125 строк
3 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace backend\widgets\server; use common\assets\SwitcheryAsset; use common\grid\BooleanColumn; use common\models\SystemTool; use yii\helpers\Html; use yii\helpers\Url; use Yii; /** * Список проектов * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2020 */ class HealthCheckWidget extends BaseServerWidget { /** * @inheritdoc */ public $icon = 'icon-stack'; /** * @inheritdoc */ public $title = 'Health Check'; /** * @inheritdoc */ public $sub_title = 'Integration statuses. Are they active, and do we receive a response from them.'; /** * @inheritdoc */ protected function getCols() { return [ [ 'title' => 'Active', 'slug' => 'active', 'is_center' => true, 'width' => '1' ], [ 'title' => 'Service', 'slug' => 'service', 'width' => '30' ], [ 'title' => 'Status', 'slug' => 'status', 'is_center' => true, 'width' => '20' ], [ 'title' => 'Last execute', 'slug' => 'last_check', 'width' => '20' ], // [ // 'title' => 'Description', // 'slug' => 'description', // 'width' => '30' // ], ]; } /** * @inheritdoc */ protected function getRows() { SwitcheryAsset::register(Yii::$app->view); $a = SystemTool::getAlias(); $data = SystemTool::find() ->select([ 'id', 'title', 'is_active', 'last_check' ]) ->alias($a) ->indexBy('id') ->asArray() ->all(); $rows = []; foreach ($data as $row) { if ($row) { $status = BooleanColumn::ICON_ACTIVE; } else { $status = BooleanColumn::ICON_INACTIVE; } $rows[] = [ 'service' => ['value' => $row['title']], 'status' => ['value' => $status], 'last_check' => ['value' => $row['last_check']], 'active' => [ 'value' => Html::tag('div', Html::label( Html::input('checkbox', 'service', $row['id'], [ 'class' => 'switchery small', 'id' => 'tool_id_' . $row['id'], 'checked' => ($row['is_active'] == 1) ? 'checked' : null, 'data-url' => Url::to([ 'data/server/action/service', ]), 'name' => 'service' ])), ['class' => 'checkbox switchery-xs checkbox-switchery']) ] ]; } return $rows; } }