Egorka
6 years ago
18 changed files with 827 additions and 55 deletions
@ -0,0 +1,87 @@
|
||||
<?php |
||||
/** |
||||
* Created by Error202 |
||||
* Date: 19.12.2017 |
||||
*/ |
||||
|
||||
namespace backend\helpers; |
||||
|
||||
use Yii; |
||||
use yii\helpers\Html; |
||||
|
||||
class DashboardHelper |
||||
{ |
||||
public static function getAllWidgets() |
||||
{ |
||||
$widgetsCounter = ''; // Counters Widgets |
||||
$widgetsInfo = ''; // Information Widgets |
||||
|
||||
// Get all items in widgets/items folder |
||||
$path = Yii::getAlias('@backend/widgets/dashboard'); |
||||
$files = scandir($path, 0); |
||||
|
||||
//foreach ($files as $file) { |
||||
foreach (Yii::$app->params['dashboard_widgets'] as $idx => $item) { |
||||
//if (!is_file($path . '/' . $file)) { |
||||
// continue; |
||||
//} |
||||
|
||||
//$itemFile = $path . '/' . $file; |
||||
//$item = require($itemFile); |
||||
|
||||
if (isset($item['rule']) && (Yii::$app->user->can($item['rule']) || Yii::$app->user->can('admin'))) { |
||||
} elseif (!isset($item['rule'])) { |
||||
} else { |
||||
continue; |
||||
} |
||||
|
||||
if ($item['category'] == 'counter') { |
||||
$line = Html::a($item['name'], '#', [ |
||||
'onclick' => 'addWidget(' . $idx . ", 'colorCounter')", |
||||
]) . '<br>'; |
||||
$widgetsCounter .= $line; |
||||
} else { |
||||
$line = Html::a($item['name'], '#', [ |
||||
'onclick' => 'addWidget(' . $idx . ", 'colorInfo')", |
||||
]) . '<br>'; |
||||
$widgetsInfo .= $line; |
||||
} |
||||
} |
||||
|
||||
return [$widgetsCounter, $widgetsInfo]; |
||||
} |
||||
|
||||
public static function getExtColors() |
||||
{ |
||||
return [ |
||||
'gray' => Yii::t('main', 'Gray'), |
||||
'gray-light' => Yii::t('main', 'Light gray'), |
||||
'black' => Yii::t('main', 'Black'), |
||||
'red' => Yii::t('main', 'Red'), |
||||
'yellow' => Yii::t('main', 'Yellow'), |
||||
'aqua' => Yii::t('main', 'Aqua'), |
||||
'navy' => Yii::t('main', 'Navy'), |
||||
'blue' => Yii::t('main', 'Blue'), |
||||
'light-blue' => Yii::t('main', 'Light Blue'), |
||||
'green' => Yii::t('main', 'Green'), |
||||
'teal' => Yii::t('main', 'Teal'), |
||||
'olive' => Yii::t('main', 'Olive'), |
||||
'lime' => Yii::t('main', 'Lime'), |
||||
'orange' => Yii::t('main', 'Orange'), |
||||
'fuchsia' => Yii::t('main', 'Fuchsia'), |
||||
'purple' => Yii::t('main', 'Purple'), |
||||
'maroon' => Yii::t('main', 'Maroon'), |
||||
]; |
||||
} |
||||
|
||||
public static function getColors() |
||||
{ |
||||
return [ |
||||
'default' => Yii::t('main', 'Gray'), |
||||
'danger' => Yii::t('main', 'Red'), |
||||
'primary' => Yii::t('main', 'Blue'), |
||||
'success' => Yii::t('main', 'Green'), |
||||
'warning' => Yii::t('main', 'Orange'), |
||||
]; |
||||
} |
||||
} |
@ -1,50 +1,73 @@
|
||||
<?php |
||||
return [ |
||||
'Menu' => 'Меню', |
||||
'Title' => 'Заголовок', |
||||
'Description' => 'Описание', |
||||
'Keywords' => 'Ключевые слова', |
||||
'Sign out' => 'Выход', |
||||
'Sign in' => 'Вход', |
||||
'Profile' => 'Профиль', |
||||
'Error' => 'Ошибка', |
||||
'Return to back or login page please.' => 'Вернитесь назад или авторизуйтесь снова.', |
||||
'{attribute} "{value}" already exists for this section.' => '{attribute} "{value}" уже есть в этом разделе.', |
||||
'"{attribute}" must be a valid JSON object' => '"{attribute}" должен быть в формате Json', |
||||
'Please select correct type' => 'Укажите правильный тип', |
||||
'Settings' => 'Настройки', |
||||
'Type' => 'Тип', |
||||
'Section' => 'Раздел', |
||||
'Key' => 'Ключ', |
||||
'Value' => 'Значение', |
||||
'Active' => 'Активная', |
||||
'Created At' => 'Создано', |
||||
'Updated At' => 'Обновлено', |
||||
'On' => 'Включить', |
||||
'Off' => 'Выключить', |
||||
'Updating Setting' => 'Редактирование параметра', |
||||
'Editing' => 'Редактирование', |
||||
'Change at your own risk' => 'Редактируйте на свой страх и риск', |
||||
'Online' => 'В сети', |
||||
'Search results' => 'Поиск', |
||||
'Search...' => 'Поиск...', |
||||
'Name' => 'Название', |
||||
'Title attribute' => 'Атрибут тега Title', |
||||
'Url' => 'Ссылка', |
||||
'Sign in to start your session' => 'Вход в панель управления', |
||||
'You have {count} notifications' => 'Новых уведомлений: {count}', |
||||
'Modules' => 'Модули', |
||||
'Find modules' => 'Поиск модулей', |
||||
'Enable' => 'Включить', |
||||
'Disable' => 'Отключить', |
||||
'Settings List' => 'Все настройки', |
||||
'Create Setting' => 'Новый параметр', |
||||
'Interface Language' => 'Язык интерфейса', |
||||
'design' => 'Оформление', |
||||
'site' => 'Сайт', |
||||
'Change Favicon' => 'Изменить иконку сайта', |
||||
'Set Favicon' => 'Новая иконка сайта', |
||||
'Image' => 'Изображение', |
||||
'Menu' => 'Меню', |
||||
'Title' => 'Заголовок', |
||||
'Description' => 'Описание', |
||||
'Keywords' => 'Ключевые слова', |
||||
'Sign out' => 'Выход', |
||||
'Sign in' => 'Вход', |
||||
'Profile' => 'Профиль', |
||||
'Error' => 'Ошибка', |
||||
'Return to back or login page please.' => 'Вернитесь назад или авторизуйтесь снова.', |
||||
'{attribute} "{value}" already exists for this section.' => '{attribute} "{value}" уже есть в этом разделе.', |
||||
'"{attribute}" must be a valid JSON object' => '"{attribute}" должен быть в формате Json', |
||||
'Please select correct type' => 'Укажите правильный тип', |
||||
'Settings' => 'Настройки', |
||||
'Type' => 'Тип', |
||||
'Section' => 'Раздел', |
||||
'Key' => 'Ключ', |
||||
'Value' => 'Значение', |
||||
'Active' => 'Активная', |
||||
'Created At' => 'Создано', |
||||
'Updated At' => 'Обновлено', |
||||
'On' => 'Включить', |
||||
'Off' => 'Выключить', |
||||
'Updating Setting' => 'Редактирование параметра', |
||||
'Editing' => 'Редактирование', |
||||
'Change at your own risk' => 'Редактируйте на свой страх и риск', |
||||
'Online' => 'В сети', |
||||
'Search results' => 'Поиск', |
||||
'Search...' => 'Поиск...', |
||||
'Name' => 'Название', |
||||
'Title attribute' => 'Атрибут тега Title', |
||||
'Url' => 'Ссылка', |
||||
'Sign in to start your session' => 'Вход в панель управления', |
||||
'You have {count} notifications' => 'Новых уведомлений: {count}', |
||||
'Modules' => 'Модули', |
||||
'Find modules' => 'Поиск модулей', |
||||
'Enable' => 'Включить', |
||||
'Disable' => 'Отключить', |
||||
'Settings List' => 'Все настройки', |
||||
'Create Setting' => 'Новый параметр', |
||||
'Interface Language' => 'Язык интерфейса', |
||||
'design' => 'Оформление', |
||||
'site' => 'Сайт', |
||||
'Change Favicon' => 'Изменить иконку сайта', |
||||
'Set Favicon' => 'Новая иконка сайта', |
||||
'Image' => 'Изображение', |
||||
'Only png files allowed. Minimum size: 200x200. Form: square' => 'Разрешены только png файлы минимального размера 200х200. Форма: квадрат', |
||||
'Favicon generation complete' => 'Иконка для сайта обновлена', |
||||
'Favicon generation complete' => 'Иконка для сайта обновлена', |
||||
'Counters widgets' => 'Счетчики', |
||||
'Info widgets' => 'Информационные', |
||||
'Cancel' => 'Отмена', |
||||
'Ok' => 'Готово', |
||||
'Add widget' => 'Добавление виджета', |
||||
'Remove widget' => 'Удаление виджета', |
||||
'Gray' => 'Серый', |
||||
'Light gray' => 'Серый светлый', |
||||
'Black' => 'Чёрный', |
||||
'Red' => 'Красный', |
||||
'Yellow' => 'Жёлтый', |
||||
'Aqua' => 'Аква', |
||||
'Navy' => 'Синий тёмный', |
||||
'Blue' => 'Синий', |
||||
'Light Blue' => 'Голубой', |
||||
'Green' => 'Зелёный', |
||||
'Teal' => 'Изумрудный', |
||||
'Olive' => 'Оливковый', |
||||
'Lime' => 'Лаймовый', |
||||
'Orange' => 'Оранжевый', |
||||
'Fuchsia' => 'Фуксия', |
||||
'Purple' => 'Пурпурный', |
||||
'Maroon' => 'Вишнёвый', |
||||
]; |
||||
|
@ -1,10 +1,276 @@
|
||||
<?php |
||||
|
||||
use zertex\gridstack\Gridstack; |
||||
use kartik\dialog\Dialog; |
||||
use yii\web\JsExpression; |
||||
use yii\helpers\Url; |
||||
|
||||
/* @var $this yii\web\View */ |
||||
|
||||
$this->title = Yii::t('dashboard', 'Dashboard'); |
||||
|
||||
$css = ' |
||||
.grid-stack { |
||||
margin: 0 !important; |
||||
padding: 0 !important; |
||||
/*border: solid 1px red;*/ |
||||
} |
||||
.grid-stack-item { |
||||
margin: 0 !important; |
||||
padding: 0 !important; |
||||
/*border: solid 1px green;*/ |
||||
overflow: hidden; |
||||
} |
||||
.grid-stack-item-content { |
||||
margin: 0 !important; |
||||
padding: 0 !important; |
||||
overflow: hidden !important; |
||||
left: 0 !important; |
||||
right: 15px !important; |
||||
/*bottom: 40px !important;*/ |
||||
/*bottom: auto !important;*/ |
||||
} |
||||
|
||||
.moveButton { |
||||
font-size:12px; |
||||
color:#999; |
||||
cursor: pointer; |
||||
margin-right:5px; |
||||
display: inline-block; |
||||
} |
||||
.moveButton:hover { |
||||
color:#333; |
||||
} |
||||
|
||||
.user128 { |
||||
width: 128px; |
||||
height: 128px; |
||||
} |
||||
|
||||
.big_drop .select2-results ul { |
||||
max-height: 500px !important; |
||||
min-height: 500px !important; |
||||
height: 500px !important; |
||||
} |
||||
'; |
||||
$this->registerCss($css); |
||||
|
||||
$addWidgetUrl = Url::toRoute('/site/add-widget'); |
||||
$removeWidgetUrl = Url::toRoute('/site/remove-widget'); |
||||
$js = <<<JS |
||||
var AddWidgetDialog; |
||||
var RemoveWidgetDialog; |
||||
|
||||
function addWidget(itemIdx, colorId) |
||||
{ |
||||
var color = $("#"+colorId).val(); |
||||
$.ajax({ |
||||
method: "GET", |
||||
data: {itemIdx: itemIdx, color: color}, |
||||
url: "{$addWidgetUrl}" |
||||
}) |
||||
.done(function(data){ |
||||
AddWidgetDialog.close(); |
||||
document.location.reload(); |
||||
}); |
||||
return false; |
||||
} |
||||
|
||||
function removeWidget(idx) |
||||
{ |
||||
$.ajax({ |
||||
method: "GET", |
||||
data: {idx: idx}, |
||||
url: "{$removeWidgetUrl}" |
||||
}) |
||||
.done(function(data){ |
||||
RemoveWidgetDialog.close(); |
||||
document.location.reload(); |
||||
}); |
||||
return false; |
||||
} |
||||
JS; |
||||
|
||||
$this->registerJs($js, $this::POS_HEAD); |
||||
|
||||
$saveWidgetsUrl = Url::toRoute('/site/save-widgets'); |
||||
$js2 = ' |
||||
$("#addWidgetButton").on("click", function() { |
||||
krajeeDialog.dialog( |
||||
"", |
||||
function (result) {alert(result);} |
||||
); |
||||
}); |
||||
|
||||
$("#removeWidgetButton").on("click", function() { |
||||
krajeeDialogRemove.dialog( |
||||
"", |
||||
function (result) {alert(result);} |
||||
); |
||||
}); |
||||
|
||||
$(".grid-stack").on("change", function(event, items) { |
||||
var widgets = []; |
||||
|
||||
$(".grid-stack-item.ui-draggable").each(function () { |
||||
var $this = $(this); |
||||
widgets.push({ |
||||
x: $this.attr("data-gs-x"), |
||||
y: $this.attr("data-gs-y"), |
||||
w: $this.attr("data-gs-width"), |
||||
h: $this.attr("data-gs-height"), |
||||
c: $this.attr("data-color"), |
||||
title: $this.attr("data-title"), |
||||
name: $this.attr("data-name"), |
||||
method: $this.attr("data-method"), |
||||
resize: $this.attr("data-resize"), |
||||
widget: $this.attr("data-widget"), |
||||
icon: $this.attr("data-icon"), |
||||
}); |
||||
}); |
||||
var widgetsJson = JSON.stringify(widgets); |
||||
$.ajax({ |
||||
method: "POST", |
||||
data: {widgets: widgetsJson}, |
||||
url: "' . $saveWidgetsUrl . '", |
||||
}) |
||||
.done(function(data){ |
||||
}); |
||||
}); |
||||
'; |
||||
|
||||
$this->registerJs($js2, $this::POS_READY); |
||||
|
||||
$formatJs = <<<JS |
||||
var formatRepo = function (repo) { |
||||
if (repo.loading) { |
||||
return repo.text; |
||||
} |
||||
var markup = |
||||
'<div class="row">' + |
||||
'<div class="col-sm-12">' + |
||||
'<b style="margin-left:5px">' + repo.text + '</b>' + |
||||
'</div>' + |
||||
'</div>'; |
||||
if (repo.description) { |
||||
markup += '<h5>' + repo.description + '</h5>'; |
||||
} |
||||
return '<div style="overflow:hidden;">' + markup + '</div>'; |
||||
}; |
||||
var formatRepoSelection = function (repo) { |
||||
return repo.full_name || repo.text; |
||||
} |
||||
JS; |
||||
$this->registerJs($formatJs, $this::POS_HEAD); |
||||
?> |
||||
|
||||
<div class="site-index"> |
||||
|
||||
<?= Dialog::widget([ |
||||
'options' => [ |
||||
'title' => Yii::t('main', 'Add widget'), |
||||
'buttons' => [ |
||||
[ |
||||
'id' => 'cancel-1', |
||||
'label' => Yii::t('main', 'Cancel'), |
||||
'action' => new JsExpression('function(dialog) { |
||||
dialog.close(); |
||||
}') |
||||
], |
||||
], |
||||
'onshown' => new JsExpression("function(dialog){ |
||||
var url = '" . Url::toRoute('/site/get-widgets-list') . "'; |
||||
$.ajax({ |
||||
method: 'POST', |
||||
url: url, |
||||
}) |
||||
.done(function(data){ |
||||
dialog.getModalBody().html(data); |
||||
AddWidgetDialog = dialog; |
||||
}); |
||||
}"), |
||||
], |
||||
]); ?> |
||||
|
||||
<?= Dialog::widget([ |
||||
'libName' => 'krajeeDialogRemove', |
||||
'options' => [ |
||||
'title' => Yii::t('main', 'Remove widget'), |
||||
'type' => Dialog::TYPE_DANGER, |
||||
'buttons' => [ |
||||
[ |
||||
'id' => 'cancel-1', |
||||
'label' => Yii::t('main', 'Cancel'), |
||||
'action' => new JsExpression('function(dialog) { |
||||
dialog.close(); |
||||
}') |
||||
], |
||||
], |
||||
'onshown' => new JsExpression("function(dialog){ |
||||
var url = '" . Url::toRoute('/site/get-selected-widgets-list') . "'; |
||||
$.ajax({ |
||||
method: 'POST', |
||||
url: url, |
||||
}) |
||||
.done(function(data){ |
||||
dialog.getModalBody().html(data); |
||||
RemoveWidgetDialog = dialog; |
||||
}); |
||||
}"), |
||||
], |
||||
]); ?> |
||||
|
||||
<?php |
||||
$gridStack = Gridstack::begin([ |
||||
'options' => ['class' => 'grid-stack'], |
||||
'clientOptions' => [ |
||||
'cellHeight' => 22, |
||||
'verticalMargin' => 15, |
||||
'handle' => '.moveHandle', |
||||
], |
||||
]); |
||||
$widgets = \core\helpers\UserHelper::getSetting('widgetsLayout', []); |
||||
foreach ($widgets as $widget) { |
||||
$widgetData = [ |
||||
'class'=>'grid-stack-item', |
||||
'data-gs-width'=>$widget['w'], |
||||
'data-gs-height'=>$widget['h'], |
||||
'data-gs-x'=>$widget['x'], |
||||
'data-gs-y'=>$widget['y'], |
||||
'data-method' => $widget['method'], |
||||
'data-title' => $widget['title'], |
||||
'data-color' => $widget['c'], |
||||
'data-resize' => $widget['resize'], |
||||
'data-widget' => $widget['widget'], |
||||
'data-icon' => $widget['icon'], |
||||
'data-name' => $widget['name'], |
||||
]; |
||||
// Disable resize if need |
||||
if ($widget['resize'] == 0) { |
||||
$widgetData['data-gs-no-resize'] = 'y'; |
||||
} |
||||
|
||||
if (isset($widget['auto']) && $widget['auto'] == 1) { |
||||
$widgetData['data-gs-auto-position'] = 'y'; |
||||
} |
||||
|
||||
// Remove (), if exists |
||||
$widget['method'] = str_replace('()', '', $widget['method']); |
||||
// Echo widget data |
||||
echo $gridStack->beginWidget($widgetData); |
||||
echo call_user_func($widget['widget'] . '::' . $widget['method'], $widget['c']); |
||||
echo $gridStack->endWidget(); |
||||
} |
||||
?> |
||||
|
||||
<?php Gridstack::end(); ?> |
||||
|
||||
<div class="clearfix"></div> |
||||
<hr> |
||||
|
||||
<div class="row" style="text-align: right; padding-right:15px;"> |
||||
<button class="btn btn-default" id="addWidgetButton"><i class="fa fa-plus"></i></button> |
||||
<button class="btn btn-default" id="removeWidgetButton"><i class="fa fa-minus"></i></button> |
||||
</div> |
||||
|
||||
</div> |
||||
|
@ -0,0 +1,37 @@
|
||||
<?php |
||||
|
||||
use yii\helpers\Html; |
||||
use backend\helpers\DashboardHelper; |
||||
|
||||
/** |
||||
* @var $this \yii\web\View |
||||
* @var $wl array |
||||
*/ |
||||
|
||||
list($widgetsCounter, $widgetsInfo) = DashboardHelper::getAllWidgets(); |
||||
?> |
||||
|
||||
<div class="row"> |
||||
<div class="col-md-6"> |
||||
<h4><?= Yii::t('main', 'Counters widgets') ?></h4>
|
||||
|
||||
<div style="margin-bottom:15px;"> |
||||
<?= Html::dropDownList('colorCounter', 'blue', DashboardHelper::getExtColors(), [ |
||||
'id' => 'colorCounter', |
||||
'class' => 'form-control', |
||||
]) ?> |
||||
</div> |
||||
<?= $widgetsCounter ?> |
||||
</div> |
||||
<div class="col-md-6"> |
||||
<h4><?= Yii::t('main', 'Info widgets') ?></h4>
|
||||
<div style="margin-bottom:15px;"> |
||||
<?= Html::dropDownList('colorInfo', 'primary', DashboardHelper::getColors(), [ |
||||
'id' => 'colorInfo', |
||||
'class' => 'form-control', |
||||
]) ?> |
||||
</div> |
||||
<?= $widgetsInfo ?> |
||||
</div> |
||||
</div> |
||||
|
@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @var $this \yii\web\View |
||||
*/ |
||||
|
||||
$widgets = \core\helpers\UserHelper::getSetting('widgetsLayout', []); |
||||
$i = 0; |
||||
?> |
||||
|
||||
<?php foreach ($widgets as $widget) : ?> |
||||
|
||||
<a href="#" onClick="removeWidget(<?= $i ?>)"><?= $widget['name'] ?></a><br>
|
||||
|
||||
<?php |
||||
$i++; |
||||
endforeach; |
||||
?> |
@ -0,0 +1,33 @@
|
||||
<?php |
||||
/** |
||||
* Created by Error202 |
||||
* Date: 19.12.2017 |
||||
*/ |
||||
|
||||
namespace backend\widgets\dashboard\helpers; |
||||
|
||||
use core\entities\user\User; |
||||
use Yii; |
||||
use yii\web\View; |
||||
use backend\widgets\dashboard\templates\AdminLteBox2; |
||||
use yii\helpers\Url; |
||||
|
||||
class UsersLastInfo |
||||
{ |
||||
public static function widgetLastUsers($color = 'green') |
||||
{ |
||||
$users = User::find()->orderBy(['id' => SORT_DESC])->limit(8)->all(); |
||||
$body = (new View())->render('@backend/widgets/dashboard/views/usersLastInfo-body', [ |
||||
'users' => $users, |
||||
]); |
||||
|
||||
return AdminLteBox2::widget([ |
||||
'color' => $color, |
||||
'cssclass' => 'grid-stack-item-content', |
||||
'title' => Yii::t('user', 'Users'), |
||||
'bottomtext' => Yii::t('user', 'All users'), |
||||
'bottomlink' => Url::toRoute(['/user-manage/index']), |
||||
'body' => $body, |
||||
]); |
||||
} |
||||
} |
@ -0,0 +1,58 @@
|
||||
<?php |
||||
|
||||
namespace backend\widgets\dashboard\templates; |
||||
|
||||
use yii\bootstrap\Widget; |
||||
|
||||
class AdminLteBox2 extends Widget |
||||
{ |
||||
public $title; |
||||
public $cssclass; |
||||
public $color; |
||||
public $bottomtext; |
||||
public $bottomlink; |
||||
public $body; |
||||
|
||||
|
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
if ($this->cssclass === null) { |
||||
$this->cssclass = 'col-md-6 col-sm-12 col-xs-12'; |
||||
} |
||||
|
||||
if ($this->color === null) { |
||||
$this->color = 'box-info'; |
||||
} |
||||
$this->color = $this->color === null ? 'box-info' : 'box-' . $this->color; |
||||
|
||||
if ($this->title === null) { |
||||
$this->title = 'Box Title'; |
||||
} |
||||
} |
||||
|
||||
public function run() |
||||
{ |
||||
$header = '<div class="box-header with-border"> |
||||
<h3 class="box-title">' . $this->title . '</h3> |
||||
<div class="box-tools pull-right"> |
||||
<i class="fa fa-arrows moveHandle moveButton"></i> |
||||
</div> |
||||
</div>'; |
||||
|
||||
$body = $this->body; |
||||
|
||||
|
||||
$footer = ' |
||||
<div class="box-footer text-center"> |
||||
<a href="' . $this->bottomlink . '" class="uppercase">' . $this->bottomtext . '</a> |
||||
</div>'; |
||||
|
||||
return '<div class="box ' . $this->color . ' ' . $this->cssclass . '">' . |
||||
$header . |
||||
$body . |
||||
$footer . |
||||
'</div>'; |
||||
} |
||||
} |
@ -0,0 +1,49 @@
|
||||
<?php |
||||
|
||||
namespace backend\widgets\dashboard\templates; |
||||
|
||||
use yii\bootstrap\Widget; |
||||
|
||||
class AdminLteBox3 extends Widget |
||||
{ |
||||
public $title; |
||||
public $cssclass; |
||||
public $color; |
||||
public $body; |
||||
|
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
if ($this->cssclass === null) { |
||||
$this->cssclass = 'col-md-6 col-sm-12 col-xs-12'; |
||||
} |
||||
|
||||
if ($this->color === null) { |
||||
$this->color = 'box-info'; |
||||
} |
||||
$this->color = $this->color === null ? 'box-info' : 'box-' . $this->color; |
||||
|
||||
if ($this->title === null) { |
||||
$this->title = 'Box Title'; |
||||
} |
||||
} |
||||
|
||||
public function run() |
||||
{ |
||||
$header = '<div class="box-header with-border"> |
||||
<h3 class="box-title">' . $this->title . '</h3> |
||||
<div class="box-tools pull-right"> |
||||
<i class="fa fa-arrows moveHandle moveButton"></i> |
||||
</div> |
||||
</div>'; |
||||
|
||||
$body = $this->body; |
||||
|
||||
|
||||
return '<div class="box ' . $this->color . ' ' . $this->cssclass . '">' . |
||||
$header . |
||||
$body . |
||||
'</div>'; |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
<?php |
||||
|
||||
namespace backend\widgets\dashboard\templates; |
||||
|
||||
use yii\bootstrap\Widget; |
||||
|
||||
class AdminLteSimpleBox1 extends Widget |
||||
{ |
||||
public $bgclass; |
||||
public $cssclass; |
||||
public $icon; |
||||
public $title; |
||||
public $subtitle; |
||||
|
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->bgclass = $this->bgclass === null ? 'bg-aqua' : $this->bgclass; |
||||
$this->cssclass = $this->cssclass === null ? 'col-md-3 col-sm-6 col-xs-12' : $this->cssclass; |
||||
$this->icon = $this->icon === null ? 'fa fa-envelope-o' : $this->icon; |
||||
$this->title = $this->title === null ? 'Messages' : $this->title; |
||||
$this->subtitle = $this->subtitle === null ? '0' : $this->subtitle; |
||||
} |
||||
|
||||
public function run() |
||||
{ |
||||
return '<div class="' . $this->cssclass . '"> |
||||
<div class="info-box"> |
||||
<span class="info-box-icon ' . $this->bgclass . '"> |
||||
<i class="' . $this->icon . '"></i> |
||||
</span> |
||||
<div class="info-box-content"> |
||||
<span class="info-box-text">' . $this->title . '</span> |
||||
<span class="info-box-number">' . $this->subtitle . '</span> |
||||
</div> |
||||
</div> |
||||
</div>'; |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
<?php |
||||
|
||||
use yii\helpers\Url; |
||||
|
||||
/** |
||||
* @var $this \yii\web\View; |
||||
* @var $users \core\entities\user\User[] |
||||
*/ |
||||
?> |
||||
|
||||
<div class="box-body no-padding"> |
||||
<ul class="users-list clearfix"> |
||||
|
||||
<?php foreach ($users as $user) : ?> |
||||
|
||||
<li> |
||||
<img class="user128" src="<?= Yii::$app->avatar->show($user->username) ?>" alt="<?= $user->username ?>">
|
||||
<a class="users-list-name" |
||||
href="<?= Url::toRoute(['user-manage/view', 'id' => $user->id]) ?>"><?= $user->username ?></a>
|
||||
<span class="users-list-date"><?= date('d.m.y', $user->created_at) ?></span>
|
||||
</li> |
||||
|
||||
<?php endforeach; ?> |
||||
|
||||
</ul> |
||||
</div> |
@ -0,0 +1,25 @@
|
||||
<?php |
||||
|
||||
use yii\db\Migration; |
||||
|
||||
/** |
||||
* Class m180912_213557_add_users_settings_field |
||||
*/ |
||||
class m180912_213557_add_users_settings_field extends Migration |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeUp() |
||||
{ |
||||
$this->addColumn('{{%users}}', 'settings', $this->text()); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeDown() |
||||
{ |
||||
$this->dropColumn('{{%users}}', 'settings'); |
||||
} |
||||
} |
Loading…
Reference in new issue