Browse Source

Modules table system field migration

Modules view button delete/install change to info dialog
master
Egorka 6 years ago
parent
commit
c48826a7d6
  1. 2
      backend/messages/ru/main.php
  2. 105
      backend/views/module/list.php
  3. 28
      backend/views/module/remote-list.php
  4. 25
      console/migrations/m180914_163138_add_modules_system_field.php

2
backend/messages/ru/main.php

@ -79,4 +79,6 @@ return [
'Error module archive' => 'Ошибка архива модуля', 'Error module archive' => 'Ошибка архива модуля',
'Module installed successful' => 'Модуль успешно установлен', 'Module installed successful' => 'Модуль успешно установлен',
'Install' => 'Установить', 'Install' => 'Установить',
'To remove the module, use the following command in the SSH console:' => 'Для удаления модуля введите в SSH консоли сервера команду:',
'To install the module, use the following command in the SSH console:' => 'Для установки модуля введите в SSH консоли сервера команду:',
]; ];

105
backend/views/module/list.php

@ -4,69 +4,80 @@
* Date: 17.08.2018 * Date: 17.08.2018
*/ */
use core\entities\ModuleRecord;
use yii\helpers\Html; use yii\helpers\Html;
use core\helpers\ModuleHelper; use core\helpers\ModuleHelper;
use kartik\dialog\Dialog;
/** /**
* @var $this \yii\web\View * @var $this \yii\web\View
* @var $modules \core\entities\ModuleRecord[] * @var $modules \core\entities\ModuleRecord[]
*/ */
$this->title = Yii::t('main', 'Modules'); $this->title = Yii::t('main', 'Modules');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
$message = Yii::t('main', 'To remove the module, use the following command in the SSH console:');
$js = <<<JS
$(".delete-button").on('click', function () {
var name = $(this).data('name');
krajeeDialog.alert('{$message}' + "\\n" + '<pre><code>php yii module/remove ' + name + '</code></pre>');
});
JS;
$this->registerJs($js, $this::POS_READY);
?> ?>
<div class="row"> <?= Dialog::widget([
'options' => [],
]);
?>
<?php foreach ($modules as $module): ?> <div class="row">
<?php <?php foreach ($modules as $module) : ?>
$color = $module->isEnabled() ? '#00aced' : '#cccccc'; <?php
if ($module->isDisabled()) { $color = $module->isEnabled() ? '#00aced' : '#cccccc';
ModuleHelper::addModuleAdminTranslation($module->name); if ($module->isDisabled()) {
} ModuleHelper::addModuleAdminTranslation($module->name);
}
$module_name = in_array($module->name, array_keys(Yii::$app->getI18n()->translations)) ? Yii::t($module->name, $module->name) : $module->name; $module_name = in_array($module->name, array_keys(Yii::$app->getI18n()->translations)) ? Yii::t($module->name, $module->name) : $module->name;
$module_description = in_array($module->name, array_keys(Yii::$app->getI18n()->translations)) ? Yii::t($module->name, $module->description) : $module->description; $module_description = in_array($module->name, array_keys(Yii::$app->getI18n()->translations)) ? Yii::t($module->name, $module->description) : $module->description;
?> ?>
<div class="col-md-4"> <div class="col-md-4">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-power-off" aria-hidden="true" style="color: <?= $color ?>"></i> <?= $module_name ?></h3> <h3 class="box-title"><i class="fa fa-power-off" aria-hidden="true"
</div> style="color: <?= $color ?>"></i> <?= $module_name ?></h3>
<div class="box-body"> </div>
<?= $module_description ?> <div class="box-body">
</div> <?= $module_description ?>
<div class="box-footer" style="text-align: right"> </div>
<?php if ($module->isEnabled()): ?> <div class="box-footer" style="text-align: right">
<?= Html::a(Yii::t('main', 'Disable'), ['module/disable', 'id' => $module->id], [ <?php if ($module->isEnabled()) : ?>
'class' => 'btn btn-default btn-sm', <?= Html::a(Yii::t('main', 'Disable'), ['module/disable', 'id' => $module->id], [
'data' => [ 'class' => 'btn btn-default btn-sm',
'method' => 'post', 'data' => [
], 'method' => 'post',
]) ?> ],
<?php else: ?> ]) ?>
<?= Html::a(Yii::t('main', 'Enable'), ['module/enable', 'id' => $module->id], [ <?php else : ?>
'class' => 'btn btn-default btn-sm', <?= Html::a(Yii::t('main', 'Enable'), ['module/enable', 'id' => $module->id], [
'data' => [ 'class' => 'btn btn-default btn-sm',
'method' => 'post', 'data' => [
], 'method' => 'post',
]) ?> ],
<?php endif; ?> ]) ?>
<?php endif; ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['module/delete', 'id' => $module->id], [ <?= Html::button(Yii::t('buttons', 'Delete'), [
'class' => 'btn btn-danger btn-sm', 'class' => 'btn btn-danger btn-sm delete-button',
'data' => [ 'data-name' => $module->name,
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'), ]) ?>
'method' => 'post', </div>
], </div>
]) ?> </div>
</div> <?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div> </div>

28
backend/views/module/remote-list.php

@ -5,6 +5,7 @@
*/ */
use yii\helpers\Html; use yii\helpers\Html;
use kartik\dialog\Dialog;
/** /**
* @var $this \yii\web\View * @var $this \yii\web\View
@ -14,12 +15,25 @@ use yii\helpers\Html;
$this->title = Yii::t('main', 'Available Modules'); $this->title = Yii::t('main', 'Available Modules');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
$message = Yii::t('main', 'To install the module, use the following command in the SSH console:');
$js = <<<JS
$(".install-button").on('click', function () {
var name = $(this).data('name');
krajeeDialog.alert('{$message}' + "\\n" + '<pre><code>php yii module/install ' + name + '</code></pre>');
});
JS;
$this->registerJs($js, $this::POS_READY);
?> ?>
<?php if ($message) : ?> <?php if ($message) : ?>
<div><?= $message ?></div>
<?php endif; ?> <?php endif; ?>
<?= Dialog::widget([
'options' => [],
]);
?>
<div class="row"> <div class="row">
@ -43,18 +57,12 @@ $this->params['breadcrumbs'][] = $this->title;
</div> </div>
<div class="box-footer" style="text-align: right"> <div class="box-footer" style="text-align: right">
<?php if (Yii::$app->moduleManager->isExists($module['name'])) : ?> <?php if (Yii::$app->moduleManager->isExists($module['name'])) : ?>
<?= Html::a(Yii::t('main', 'Installed'), '#', [ <?= Html::button(Yii::t('main', 'Installed'), [
'class' => 'btn btn-default btn-sm disabled', 'class' => 'btn btn-default btn-sm disabled',
'data' => [
'method' => 'post',
],
]) ?> ]) ?>
<?php else : ?> <?php else : ?>
<?= Html::a(Yii::t('main', 'Install'), ['module/install', 'name' => $module['name']], [ <?= Html::button(Yii::t('main', 'Install'), [
'class' => 'btn btn-success btn-sm', 'class' => 'btn btn-success btn-sm install-button',
'data' => [
'method' => 'post',
],
]) ?> ]) ?>
<?php endif; ?> <?php endif; ?>
</div> </div>

25
console/migrations/m180914_163138_add_modules_system_field.php

@ -0,0 +1,25 @@
<?php
use yii\db\Migration;
/**
* Class m180914_163138_add_modules_system_field
*/
class m180914_163138_add_modules_system_field extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('{{%modules}}', 'system', $this->integer(1)->defaultValue(0));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('{{%modules}}', 'system');
}
}
Loading…
Cancel
Save