Skip to content

Commit

Permalink
Account, DB, Hdomain - index, view pages
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Aug 4, 2015
1 parent 68cbb4d commit 7b0d23a
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 222 deletions.
2 changes: 1 addition & 1 deletion src/controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function actions()
'error' => Yii::t('app', 'An error occurred when trying to create account')
],
'create-ftponly' => [
'class' => 'hipanel\actions\SmartCreateAction',
'class' => 'hipanel\actions\SmartCreateAction',
'success' => Yii::t('app', 'Account creating task has been added to queue'),
'error' => Yii::t('app', 'An error occurred when trying to create account')
],
Expand Down
26 changes: 18 additions & 8 deletions src/grid/AccountGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,43 @@
use hipanel\grid\RefColumn;
use hipanel\modules\hosting\widgets\account\State;
use hipanel\modules\server\grid\ServerColumn;
use hipanel\widgets\ArraySpoiler;

class AccountGridView extends \hipanel\grid\BoxedGridView
{
static public function defaultColumns()
{
return [
'account' => [
'class' => MainColumn::className(),
'attribute' => 'login',
'filterAttribute' => 'login_like',
'account' => [
'class' => MainColumn::className(),
'attribute' => 'login',
'filterAttribute' => 'login_like',
],
'state' => [
'state' => [
'class' => RefColumn::className(),
'format' => 'raw',
'value' => function ($model) {
return State::widget(compact('model'));
},
'gtype' => 'state,db',
],
'server' => [
'server' => [
'class' => ServerColumn::className()
],
'actions' => [
'sshftp_ips' => [
'attribute' => 'sshftp_ips',
'format' => 'raw',
'value' => function ($model) {
return ArraySpoiler::widget([
'data' => $model->sshftp_ips,
'visibleCount' => 3
]);
}
],
'actions' => [
'class' => ActionColumn::className(),
'template' => '{view} {update} {delete}'
],

];
}
}
1 change: 1 addition & 0 deletions src/models/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function goodStates()
*/
public function isOperable()
{
return false;
/// TODO: all is operable for admin
if (!in_array($this->state, $this->goodStates())) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/views/account/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
'filterModel' => $searchModel,
'columns' => [
'checkbox',
'seller_id',
'account',
'client_id',
'seller_id',
'server',
'account',
'state',
'actions',
],
Expand Down
251 changes: 130 additions & 121 deletions src/views/account/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,154 +7,163 @@

use hipanel\modules\hosting\grid\AccountGridView;
use hipanel\widgets\ArraySpoiler;
use hipanel\widgets\Box;
use hipanel\widgets\PasswordInput;
use hipanel\widgets\Pjax;
use hipanel\widgets\RequestState;
use hiqdev\assets\flagiconcss\FlagIconCssAsset;
use yii\bootstrap\Modal;
use yii\helpers\Html;
use yii\helpers\Inflector;
use yii\helpers\Url;
use yii\web\JsExpression;

$this->title = $model->login;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Accounts'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$this->title = $model->login;
$this->subtitle = Yii::t('app', 'account detailed information') . ' #' . $model->id;
$this->breadcrumbs->setItems([
['label' => 'Accounts', 'url' => ['index']],
$this->title,
]);

?>

<? Pjax::begin(Yii::$app->params['pjax']) ?>

<div class="box box-danger">
<div class="box-header">
<?php
$model->scenario = 'set-password';
$form = \yii\bootstrap\ActiveForm::begin([
'action' => Url::toRoute(['set-password']),
'options' => [
'data' => ['pjax' => 1],
'class' => 'inline',
]
]);
print Html::activeHiddenInput($model, 'id');
$this->registerJs("$('#{$form->id}').on('beforeSubmit', function (event) {
<div class="row">
<div class="col-md-3">
<?php Box::begin(); ?>
<div class="profile-user-img text-center">
<i class="fa fa-user fa-5x"></i>
</div>
<p class="text-center">
<span class="profile-user-role"><?= $model->login ?></span>
<br>
<span class="profile-user-name"><?= $model->client . ' / ' . $model->seller; ?></span>
</p>

<div class="profile-usermenu">
<ul class="nav">
<li>
<?= Html::a('<i class="fa fa-lock"></i>' . Yii::t('app', 'Change password'), '#', [
'data-toggle' => 'modal',
'data-target' => '#modal_' . $model->id . '_password',
'disabled' => !$model->isOperable()
]); ?>

<?php
$model->scenario = 'set-password';
$form = \yii\bootstrap\ActiveForm::begin([
'action' => Url::toRoute(['set-password']),
'options' => [
'data' => ['pjax' => 1],
'class' => 'inline',
]
]);
echo Html::activeHiddenInput($model, 'id');
$this->registerJs("$('#{$form->id}').on('beforeSubmit', function (event) {
if ($(this).data('yiiActiveForm').validated) {
return $(this).find('[type=\"submit\"]').button('loading');
}
});");
Modal::begin([
'toggleButton' => [
'label' => '<i class="fa fa-lock"></i>&nbsp;&nbsp;' . Yii::t('app', 'Change password'),
'class' => 'btn btn-default',
'disabled' => !$model->isOperable(),
],
'header' => Html::tag('h4', Yii::t('app', 'Enter a new password')),
'headerOptions' => ['class' => 'label-info'],
'footer' => Html::submitButton(Yii::t('app', 'Change'), [
'class' => 'btn btn-warning',
'data-loading-text' => Yii::t('app', 'Changing...'),
])
]);
?>
<div class="callout callout-warning">
<h4><?= Yii::t('app', 'This will immediately terminate all sessions of the user!') ?></h4>
</div>
Modal::begin([
'id' => 'modal_' . $model->id . '_password',
'toggleButton' => false,
'header' => Html::tag('h4', Yii::t('app', 'Enter a new password')),
'headerOptions' => ['class' => 'label-info'],
'footer' => Html::submitButton(Yii::t('app', 'Change'), [
'class' => 'btn btn-warning',
'data-loading-text' => Yii::t('app', 'Changing...'),
])
]);
?>
<div class="callout callout-warning">
<h4><?= Yii::t('app', 'This will immediately terminate all sessions of the user!') ?></h4>
</div>

<?php echo $form->field($model, 'password')->widget(PasswordInput::className())->label(false);
echo $form->field($model, 'login')->hiddenInput()->label(false);
Modal::end();
$form->end();
?>
<?php echo $form->field($model, 'password')->widget(PasswordInput::className())->label(false);
echo $form->field($model, 'login')->hiddenInput()->label(false);
Modal::end();
$form->end();
?>
</li>
<li>
<?php
echo Html::a('<i class="fa fa-globe"></i>' . Yii::t('app', 'Manage IP restrictions'), '#', [
'data-toggle' => 'modal',
'data-target' => '#modal_' . $model->id . '_sshftp_ips',
'disabled' => !$model->isOperable() /// TODO: check whether works
]);

<?php
$model->scenario = 'update';
$form = \yii\bootstrap\ActiveForm::begin([
'action' => Url::toRoute(['set-allowed-ips']),
'options' => [
'data' => ['pjax' => 1],
'class' => 'inline',
],
]);
print Html::activeHiddenInput($model, 'id');
$this->registerJs("$('#{$form->id}').on('beforeSubmit', function (event) {
$model->scenario = 'set-allowed-ips';
$form = \yii\bootstrap\ActiveForm::begin([
'action' => Url::toRoute(['set-allowed-ips']),
'options' => [
'data' => ['pjax' => 1],
'class' => 'inline',
],
]);
echo Html::activeHiddenInput($model, 'id');
$this->registerJs("$('#{$form->id}').on('beforeSubmit', function (event) {
if ($(this).data('yiiActiveForm').validated) {
return $(this).find('[type=\"submit\"]').button('loading');
}
});");
Modal::begin([
'toggleButton' => [
'label' => '<i class="fa fa-globe"></i>&nbsp;&nbsp;' . Yii::t('app', 'Change SSH/FTP IPs'),
'class' => 'btn btn-default',
'disabled' => !$model->isOperable(),
],
'header' => Html::tag('h4', Yii::t('app', 'Enter new restrictions')),
'headerOptions' => ['class' => 'label-info'],
'footer' => Html::submitButton(Yii::t('app', 'Change'), [
'class' => 'btn btn-warning',
'data-loading-text' => Yii::t('app', 'Changing...'),
])
]);
?>
<div class="callout callout-warning">
<h4><?= Yii::t('app', 'This will immediately terminate all sessions of the user!') ?></h4>
</div>
Modal::begin([
'id' => 'modal_' . $model->id . '_sshftp_ips',
'toggleButton' => false,
'header' => Html::tag('h4', Yii::t('app', 'Enter new restrictions')),
'headerOptions' => ['class' => 'label-info'],
'footer' => Html::submitButton(Yii::t('app', 'Change'), [
'class' => 'btn btn-warning',
'data-loading-text' => Yii::t('app', 'Changing...'),
])
]);
?>
<div class="callout callout-warning">
<h4><?= Yii::t('app', 'This will immediately terminate all sessions of the user!') ?></h4>
</div>

<?php echo $form->field($model, 'sshftp_ips');
Modal::end();
$form->end();
?>

<?= Html::a('<i class="fa fa-close"></i>&nbsp;&nbsp;' . Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger pull-right',
'data' => [
'confirm' => Yii::t('app', 'Are you sure you want to delete this account?'),
'method' => 'post',
],
]) ?>
<?php echo $form->field($model, 'sshftp_ips');
Modal::end();
$form->end();
?>
</li>
<li>
<?= Html::a('<i class="fa fa-trash-o"></i>' . Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
'data' => [
'confirm' => Yii::t('app', 'Are you sure you want to delete this account?'),
'method' => 'post',
],
]) ?>
</li>
</ul>
</div>
<?php Box::end(); ?>
</div>
</div>
<div class="row" xmlns="http://www.w3.org/1999/html">
<div class="col-md-5">
<div class="box box-info">
<div class="box-body">
<div class="event-view">
<?= AccountGridView::detailView([

<div class="col-md-9">
<div class="row">
<div class="col-md-6">
<?php
$box = Box::begin(['renderBody' => false]);
$box->beginHeader();
echo $box->renderTitle(Yii::t('app', 'Account information'));
$box->endHeader();
$box->beginBody();
echo AccountGridView::detailView([
'boxed' => false,
'model' => $model,
'columns' => [
'seller_id',
'client_id',
'server',
'account',
[
'attribute' => 'state',
'format' => 'raw',
'value' => function ($model) {
return RequestState::widget([
'model' => $model,
'clientOptions' => [
'afterChange' => new JsExpression("function () { $.pjax.reload('#content-pjax', {'timeout': 0});}")
]
]);
}
],
[
'attribute' => 'password',
'format' => 'raw',
'value' => function () { return Yii::t('app', 'Only able to change'); }
],
[
'attribute' => 'sshftp_ips',
'format' => 'raw',
'value' => function ($model) {
return ArraySpoiler::widget([
'data' => $model->sshftp_ips,
'visibleCount' => 3
]);
}
]
]
]) ?>
</div>
['attribute' => 'login'],
'state',
'sshftp_ips'
],
]);
$box->endBody();
$box::end();
?>
</div>
</div>
</div>
</div>

<?php Pjax::end() ?>
</div>
4 changes: 2 additions & 2 deletions src/views/db/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
'filterModel' => $searchModel,
'columns' => [
'checkbox',
'seller_id',
'client_id',
'name',
'client_id',
'seller_id',
'service_ip',
'description',
'state',
Expand Down
Loading

0 comments on commit 7b0d23a

Please sign in to comment.