diff --git a/assets/AppAsset.php b/assets/AppAsset.php index e8cc9ba..5911a90 100644 --- a/assets/AppAsset.php +++ b/assets/AppAsset.php @@ -19,5 +19,6 @@ class AppAsset extends AssetBundle 'yii\web\YiiAsset', 'yii\bootstrap\BootstrapAsset', 'rmrevin\yii\fontawesome\AssetBundle', + 'dmstr\web\AdminLteAsset', ]; } diff --git a/config/main.php b/config/main.php index 7b51e0e..0f7fbec 100644 --- a/config/main.php +++ b/config/main.php @@ -15,6 +15,7 @@ return [ 'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => true, + 'loginUrl' => ['/auth/login'], ], 'errorHandler' => [ 'errorAction' => 'site/error', @@ -38,7 +39,7 @@ return [ 'showScriptName' => false, 'rules' => [ '' => 'panel/index', - 'login' => 'site/login', + 'login' => 'auth/login', '//' => '/', '/' => '/view', '' => '/index', diff --git a/config/params.php b/config/params.php index 473c41b..318e93d 100644 --- a/config/params.php +++ b/config/params.php @@ -4,7 +4,7 @@ use yii\helpers\ArrayHelper; $params = [ 'adminEmail' => 'admin@example.com', - 'wsURL' => 'ws://192.168.1.102:8081', + 'wsURL' => 'ws://192.168.1.103:8081', ]; return ArrayHelper::merge($params, require 'params-local.php'); diff --git a/controllers/AuthController.php b/controllers/AuthController.php index 3ab70c0..5dde7e7 100644 --- a/controllers/AuthController.php +++ b/controllers/AuthController.php @@ -10,6 +10,8 @@ use app\models\LoginForm; class AuthController extends Controller { + public $layout = 'base'; + public function behaviors() { return [ diff --git a/models/Item.php b/models/Item.php index ef496fb..1ed0320 100644 --- a/models/Item.php +++ b/models/Item.php @@ -62,6 +62,7 @@ class Item extends ActiveRecord [['url', 'name', 'icon', 'bg', 'class'], 'string', 'max' => 255], [['room_id'], 'exist', 'skipOnError' => true, 'targetClass' => Room::className(), 'targetAttribute' => ['room_id' => 'id']], [['board_id'], 'exist', 'skipOnError' => true, 'targetClass' => Board::className(), 'targetAttribute' => ['board_id' => 'id']], + [['sort_order'], 'default', 'value' => 0], ]; } @@ -78,6 +79,7 @@ class Item extends ActiveRecord 'room_id' => Yii::t('app', 'Комната'), 'board_id' => Yii::t('app', 'Плата'), 'url' => Yii::t('app', 'Url'), + 'pin' => Yii::t('app', 'Pin'), 'name' => Yii::t('app', 'Название'), 'icon' => Yii::t('app', 'Иконка'), 'bg' => Yii::t('app', 'Фон'), diff --git a/models/RoomSearch.php b/models/RoomSearch.php index f8af211..f002262 100644 --- a/models/RoomSearch.php +++ b/models/RoomSearch.php @@ -19,7 +19,7 @@ class RoomSearch extends Room { return [ [['id'], 'integer'], - [['name'], 'safe'], + [['name', 'bg'], 'safe'], ]; } @@ -62,7 +62,8 @@ class RoomSearch extends Room 'id' => $this->id, ]); - $query->andFilterWhere(['like', 'name', $this->name]); + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'bg', $this->bg]); return $dataProvider; } diff --git a/modules/settings/Module.php b/modules/settings/Module.php new file mode 100644 index 0000000..d62c8ff --- /dev/null +++ b/modules/settings/Module.php @@ -0,0 +1,24 @@ +render('index'); + } +} diff --git a/modules/settings/views/default/index.php b/modules/settings/views/default/index.php new file mode 100644 index 0000000..22b5d4b --- /dev/null +++ b/modules/settings/views/default/index.php @@ -0,0 +1,12 @@ +
+

context->action->uniqueId ?>

+

+ This is the view content for action "context->action->id ?>". + The action belongs to the controller "context) ?>" + in the "context->module->id ?>" module. +

+

+ You may customize this page by editing the following file:
+ +

+
diff --git a/servers/Panel.php b/servers/Panel.php index f67c9c9..35338cf 100644 --- a/servers/Panel.php +++ b/servers/Panel.php @@ -41,9 +41,9 @@ class Panel implements MessageComponentInterface protected $board_clients; /** - * @var Item[] + * @var array */ - protected $items; + protected $item_values; /** * Class constructor. @@ -58,6 +58,7 @@ class Panel implements MessageComponentInterface $this->loop = $loop; $this->user_clients = []; $this->board_clients = []; + $this->item_values = []; // Database driver hack: Prevent MySQL for disconnecting by timeout Yii::$app->db->createCommand('SET SESSION wait_timeout = 2147483;')->execute(); @@ -65,18 +66,18 @@ class Panel implements MessageComponentInterface Yii::$app->db->createCommand('SHOW TABLES;')->execute(); }); - /** @var Item[] $items */ - $items = Item::find()->all(); - - foreach ($items as $item) { - $this->items[$item->id] = $item; - +// /** @var Item[] $items */ +// $items = Item::find()->all(); +// +// foreach ($items as $item) { +// $this->item_values[$item->id] = $item; +// // if ($item->save_history_interval > 0) { // $this->loop->addPeriodicTimer($item->save_history_interval, function () use ($item) { // $this->saveHistory($item); // }); // } - } +// } $this->log('Server started'); } @@ -117,7 +118,7 @@ class Panel implements MessageComponentInterface $conn->send(Json::encode([ 'type' => 'init', - 'items' => $this->items, + 'items' => $this->item_values, ])); return $this->log("Connected user [{$user->id}] {$user->username}"); @@ -254,7 +255,7 @@ class Panel implements MessageComponentInterface return false; } - $this->items[$item->id]->value = $data['value']; + $this->item_values[$item->id] = $data['value']; $this->sendUsers([ 'type' => 'value', diff --git a/views/site/login.php b/views/auth/login.php similarity index 96% rename from views/site/login.php rename to views/auth/login.php index 9e96fd2..87e4155 100644 --- a/views/site/login.php +++ b/views/auth/login.php @@ -8,6 +8,7 @@ use yii\helpers\Html; use yii\bootstrap\ActiveForm; $this->title = 'Авторизация'; +$this->params['body-class'] = 'login-page'; $fieldOptions1 = [ 'options' => ['class' => 'form-group has-feedback'], @@ -28,7 +29,7 @@ $fieldOptions2 = [ Solomaha Home -
+ 'login-form', 'enableClientValidation' => false]); ?> diff --git a/views/board/create.php b/views/board/create.php index 42e8758..bd1d6a7 100644 --- a/views/board/create.php +++ b/views/board/create.php @@ -5,8 +5,8 @@ use yii\helpers\Html; -$this->title = 'Добавить Board'; -$this->params['breadcrumbs'][] = ['label' => 'Boards', 'url' => ['index']]; +$this->title = 'Добавить Устройство'; +$this->params['breadcrumbs'][] = ['label' => 'Устройства', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/views/board/index.php b/views/board/index.php index dc73aa2..149a237 100644 --- a/views/board/index.php +++ b/views/board/index.php @@ -7,7 +7,8 @@ use yii\helpers\Html; use yii\grid\GridView; use yii\widgets\Pjax; -$this->title = 'Boards'; + +$this->title = 'Устройства'; $this->params['breadcrumbs'][] = $this->title; ?>
@@ -26,7 +27,12 @@ $this->params['breadcrumbs'][] = $this->title; 'columns' => [ 'id', 'name', - 'baseUrl', + [ + 'attribute' => 'type', + 'value' => function (\app\models\Board $model) { + return $model->getTypeLabel(); + } + ], ['class' => 'yii\grid\ActionColumn'], ], diff --git a/views/board/update.php b/views/board/update.php index b054830..57fdb8e 100644 --- a/views/board/update.php +++ b/views/board/update.php @@ -5,8 +5,8 @@ use yii\helpers\Html; -$this->title = 'Изменить Board: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Boards', 'url' => ['index']]; +$this->title = 'Изменить Устройство: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Устройства', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Редактирование'; ?> diff --git a/views/board/view.php b/views/board/view.php index 6a4a40c..77f50c8 100644 --- a/views/board/view.php +++ b/views/board/view.php @@ -7,7 +7,7 @@ use yii\helpers\Html; use yii\widgets\DetailView; $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Boards', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => 'Устройства', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/views/layouts/_header.php b/views/layouts/_header.php index ca8cd4e..169894f 100644 --- a/views/layouts/_header.php +++ b/views/layouts/_header.php @@ -7,7 +7,8 @@ use yii\helpers\Html;
- SHSmart Home', Yii::$app->homeUrl, ['class' => 'logo']) ?> + SHSmart Home', + Yii::$app->homeUrl, ['class' => 'logo']) ?>
diff --git a/views/layouts/_left.php b/views/layouts/_left.php index e6cb965..cb89e99 100644 --- a/views/layouts/_left.php +++ b/views/layouts/_left.php @@ -24,7 +24,7 @@ ['label' => 'Настройки', 'options' => ['class' => 'header']], ['label' => 'Элементы', 'icon' => 'fa fa-cubes', 'url' => ['/item/index']], ['label' => 'Комнаты', 'icon' => 'fa fa-folder-open', 'url' => ['/room/index']], - ['label' => 'История', 'icon' => 'fa fa-bar-chart', 'url' => ['/history/index']], +// ['label' => 'История', 'icon' => 'fa fa-bar-chart', 'url' => ['/history/index']], ['label' => 'Платы', 'icon' => 'fa fa-bolt', 'url' => ['/board/index']], ['label' => 'Пользователи', 'icon' => 'fa fa-users', 'url' => ['/user/index']], diff --git a/views/panel/index.php b/views/panel/index.php index 0427cd6..51aeb05 100644 --- a/views/panel/index.php +++ b/views/panel/index.php @@ -23,14 +23,14 @@ WSClientAsset::register($this);
getItems()->variables()->all() as $item): ?> -
name ?> - + НЕИЗВЕСТНО
@@ -39,7 +39,7 @@ WSClientAsset::register($this);
getItems()->switches()->all() as $item): ?> -
diff --git a/views/room/_form.php b/views/room/_form.php index 6a7b4d2..607e9ee 100644 --- a/views/room/_form.php +++ b/views/room/_form.php @@ -14,7 +14,12 @@ use yii\widgets\ActiveForm; field($model, 'name')->textInput(['maxlength' => true]) ?> - field($model, 'bg')->textInput(['maxlength' => true]) ?> + field($model, 'bg')->dropDownList([ + 'success' => 'Зеленый', + 'danger' => 'Красный', + 'warning' => 'Оранжевый', + 'info' => 'Синий', + ]) ?>
isNewRecord ? 'Добавить' : 'Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> diff --git a/views/room/create.php b/views/room/create.php index 561e6fe..0a94583 100644 --- a/views/room/create.php +++ b/views/room/create.php @@ -6,7 +6,7 @@ use yii\helpers\Html; $this->title = 'Добавить Room'; -$this->params['breadcrumbs'][] = ['label' => 'Rooms', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => 'Комнаты', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/views/room/index.php b/views/room/index.php index 3e1382a..8b8d5dc 100644 --- a/views/room/index.php +++ b/views/room/index.php @@ -7,7 +7,7 @@ use yii\helpers\Html; use yii\grid\GridView; use yii\widgets\Pjax; -$this->title = 'Rooms'; +$this->title = 'Комнаты'; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/views/room/update.php b/views/room/update.php index c6e2ee2..e9111de 100644 --- a/views/room/update.php +++ b/views/room/update.php @@ -6,7 +6,7 @@ use yii\helpers\Html; $this->title = 'Изменить Room: ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Rooms', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => 'Комнаты', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Редактирование'; ?> diff --git a/views/room/view.php b/views/room/view.php index cc3c942..9a6a0a1 100644 --- a/views/room/view.php +++ b/views/room/view.php @@ -7,7 +7,7 @@ use yii\helpers\Html; use yii\widgets\DetailView; $this->title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Rooms', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => 'Комнаты', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/web/css/site.css b/web/css/site.css index 14237e5..a727ec0 100644 --- a/web/css/site.css +++ b/web/css/site.css @@ -24,3 +24,11 @@ text-align: center; line-height: 80px; } + +.login-page { + background: url("../img/login-bg.png") no-repeat center center fixed; + -webkit-background-size: cover; + -moz-background-size: cover; + -o-background-size: cover; + background-size: cover; +} diff --git a/web/img/login-bg.png b/web/img/login-bg.png new file mode 100644 index 0000000..e1e11fb Binary files /dev/null and b/web/img/login-bg.png differ diff --git a/web/js/wsclient.js b/web/js/wsclient.js index 84ec67b..482de34 100644 --- a/web/js/wsclient.js +++ b/web/js/wsclient.js @@ -10,6 +10,9 @@ function initWebSocket() { WS = new WebSocket(wsURL); WS.onmessage = onMessage; + WS.close(function () { + showErrorMessage('Невозможно подключиться к серверу'); + }); } function onMessage(e) {