Skip to content

Commit

Permalink
View/Actions redone with ModalButton widget
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Aug 7, 2015
1 parent e6ca06d commit befcb6c
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 204 deletions.
46 changes: 25 additions & 21 deletions src/views/server/_boot-live.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php
use yii\bootstrap\Modal;
use hipanel\widgets\ModalButton;
use yii\helpers\Html;

if ($model->isLiveCDSupported()) {
echo Html::beginForm(['boot-live'], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']);
echo Html::hiddenInput('id', $model->id);

$os_items = [];
foreach ($osimageslivecd as $item) {
$js = "$(this).closest('form').find('.livecd-osimage').val({$item['osimage']}).end().submit(); $(this).closest('button').button('loading');";
Expand All @@ -16,27 +13,34 @@
];

}
Modal::begin([
'toggleButton' => [

ModalButton::begin([
'model' => $model,
'scenario' => 'boot-live',
'button' => [
'label' => Yii::t('app', 'Boot LiveCD'),
'class' => 'btn btn-default',
'disabled' => !$model->isOperable(),
'position' => ModalButton::BUTTON_IN_MODAL,
],
'header' => Html::tag('h4', Yii::t('app', 'Confirm boot from Live CD')),
'footer' => \yii\bootstrap\ButtonDropdown::widget([
'label' => 'Boot LiveCD',
'dropdown' => [
'items' => $os_items
],
'options' => [
'class' => 'btn btn-info',
'data-loading-text' => Yii::t('app', 'Resetting password...'),
]
])
'modal' => [
'header' => Html::tag('h4', Yii::t('app', 'Confirm booting from Live CD')),
'headerOptions' => ['class' => 'label-info'],
'footer' => \yii\bootstrap\ButtonDropdown::widget([
'label' => Yii::t('app', 'Boot LiveCD'),
'dropdown' => [
'items' => $os_items
],
'options' => [
'class' => 'btn btn-info',
'data-loading-text' => Yii::t('app', '...'),
]
])
]

]);
echo Html::hiddenInput('osimage', null, ['class' => 'livecd-osimage']);
?>
Это приведет к отключению сервера и загрузке образа Live CD.
<?php Modal::end();
echo Html::endForm();
echo Yii::t('app', 'This action will shutdown the server and boot live cd image');

ModalButton::end();
}
73 changes: 16 additions & 57 deletions src/views/server/_delete.php
Original file line number Diff line number Diff line change
@@ -1,60 +1,19 @@
<?php
use yii\bootstrap\Modal;
use hipanel\widgets\ModalButton;
use yii\helpers\Html;








echo Html::a('<i class="fa fa-trash-o"></i>' . Yii::t('app', 'Delete'), '#', [
'data-toggle' => 'modal',
'data-target' => "#modal_{$model->id}_delete",
]);

echo Html::beginForm(['delete'], "POST", ['data' => ['pjax' => 1, 'pjax-push' => 0], 'class' => 'inline']);
echo Html::activeHiddenInput($model, 'id');
Modal::begin([
'id' => "modal_{$model->id}_delete",
'toggleButton' => false,
'header' => Html::tag('h4', Yii::t('app', 'Confirm server deleting')),
'headerOptions' => ['class' => 'label-danger'],
'footer' => Html::button(Yii::t('app', 'Delete server'), [
'class' => 'btn btn-danger',
'data-loading-text' => Yii::t('app', 'Deleting server...'),
'onClick' => new \yii\web\JsExpression("
$(this).closest('form').trigger('submit');
$(this).button('loading');
")
])
]);
echo Yii::t('app', 'Are you sure you want to delete server {name}? You will loose everything!', ['name' => $model->name]);
Modal::end();
echo Html::endForm();


//$modal = ModalButton::widget([
// 'model' => $model,
// // false - не делать форму
// 'formOptions' => [
// 'action' => 'delete',
// 'type' => 'POST',
// ],
// 'button' => [ // callback
// 'tag' => 'a',
// 'label' => 'DELETE',
// ],
// 'buttonPosition' => ModalButton::BUTTON_OUTSIDE, // BUTTON_INSIDE, BUTTON_IN_MODAL
// 'body' => 'Text',
// 'header' => Html::tag('h4', Yii::t('app', 'Confirm server deleting')),
// 'footer' => Html::button(Yii::t('app', 'Delete server'), [
// 'class' => 'btn btn-danger',
// 'data-loading-text' => Yii::t('app', 'Deleting server...'),
// 'onClick' => new \yii\web\JsExpression("
// $(this).closest('form').trigger('submit');
// $(this).button('loading');
// "),
// ])
//]);
echo ModalButton::widget([
'model' => $model,
'scenario' => 'delete',
'button' => ['label' => '<i class="fa fa-trash-o"></i>' . Yii::t('app', 'Delete')],
'body' => Yii::t('app', 'Are you sure you want to delete server {name}? You will loose everything!', ['name' => $model->name]),
'modal' => [
'header' => Html::tag('h4', Yii::t('app', 'Confirm server deleting')),
'headerOptions' => ['class' => 'label-danger'],
'footer' => [
'label' => Yii::t('app', 'Delete server'),
'data-loading-text' => Yii::t('app', 'Deleting server...'),
'class' => 'btn btn-danger',
]
]
]);
32 changes: 17 additions & 15 deletions src/views/server/_power-off.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
<?php
use yii\bootstrap\Modal;
use hipanel\widgets\ModalButton;
use yii\helpers\Html;

echo Html::beginForm(['power-off'], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']);
echo Html::hiddenInput('id', $model->id);
Modal::begin([
'toggleButton' => [
ModalButton::begin([
'model' => $model,
'scenario' => 'power-off',
'button' => [
'label' => Yii::t('app', 'Power off'),
'class' => 'btn btn-default',
'disabled' => !$model->isOperable(),
],
'header' => Html::tag('h4', Yii::t('app', 'Confirm server power off')),
'headerOptions' => ['class' => 'label-warning'],
'footer' => Html::button(Yii::t('app', 'Power OFF'), [
'class' => 'btn btn-warning',
'data-loading-text' => Yii::t('app', 'Turning power OFF...'),
'onClick' => new \yii\web\JsExpression("$(this).closest('form').submit(); $(this).button('loading')")
])
'modal' => [
'header' => Html::tag('h4', Yii::t('app', 'Confirm server power off')),
'headerOptions' => ['class' => 'label-warning'],
'footer' => [
'label' => Yii::t('app', 'Power OFF'),
'data-loading-text' => Yii::t('app', 'Turning power OFF...'),
'class' => 'btn btn-warning',
]
]
]);
?>
<div class="callout callout-warning">
<h4><?= Yii::t('app', 'This may cause data loose!') ?></h4>

<p><?= Yii::t('app',
'Power off will immediately interrupt all processes on the server in a dangerous way. Always try to shoudown it, before turning off the power. Are you sure you want to power off the server?') ?></p>
'Power off will immediately interrupt all processes on the server in a dangerous way. Always try to shutdown it, before turning off the power. Are you sure you want to power off the server?') ?></p>
</div>
<?php Modal::end();
echo Html::endForm();

<?php ModalButton::end();
31 changes: 16 additions & 15 deletions src/views/server/_power-on.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?php
use yii\bootstrap\Modal;
use hipanel\widgets\ModalButton;
use yii\helpers\Html;

echo Html::beginForm(['power-on'], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']);
echo Html::hiddenInput('id', $model->id);
Modal::begin([
'toggleButton' => [
echo ModalButton::widget([
'model' => $model,
'scenario' => 'power-on',
'button' => [
'label' => Yii::t('app', 'Power on'),
'class' => 'btn btn-default',
'disabled' => !$model->isOperable(),
],
'header' => Html::tag('h4', Yii::t('app', 'Confirm server power ON')),
'footer' => Html::button(Yii::t('app', 'Power ON'), [
'class' => 'btn btn-info',
'data-loading-text' => Yii::t('app', 'Turning power ON...'),
'onClick' => new \yii\web\JsExpression("$(this).closest('form').submit(); $(this).button('loading')")
])
]);
echo Yii::t('app', 'Turn ON server power?');
Modal::end();
echo Html::endForm();
'body' => Yii::t('app', 'Turn ON server power?'),
'modal' => [
'header' => Html::tag('h4', Yii::t('app', 'Confirm server power ON')),
'headerOptions' => ['class' => 'label-info'],
'footer' => [
'label' => Yii::t('app', 'Power ON'),
'data-loading-text' => Yii::t('app', 'Turning power ON...'),
'class' => 'btn btn-info',
]
]
]);
30 changes: 16 additions & 14 deletions src/views/server/_reboot.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
<?php
use yii\bootstrap\Modal;
use hipanel\widgets\ModalButton;
use yii\helpers\Html;

echo Html::beginForm(['reboot'], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']);
echo Html::hiddenInput('id', $model->id);
Modal::begin([
'toggleButton' => [
ModalButton::begin([
'model' => $model,
'scenario' => 'reboot',
'button' => [
'label' => Yii::t('app', 'Reboot'),
'class' => 'btn btn-default',
'disabled' => !$model->isOperable(),
],
'header' => Html::tag('h4', Yii::t('app', 'Confirm server reboot')),
'headerOptions' => ['class' => 'label-warning'],
'footer' => Html::button(Yii::t('app', 'Reboot'), [
'class' => 'btn btn-warning',
'data-loading-text' => Yii::t('app', 'Rebooting...'),
'onClick' => new \yii\web\JsExpression("$(this).closest('form').submit();")
])
'modal' => [
'header' => Html::tag('h4', Yii::t('app', 'Confirm server reboot')),
'headerOptions' => ['class' => 'label-warning'],
'footer' => [
'label' => Yii::t('app', 'Reboot'),
'data-loading-text' => Yii::t('app', 'Rebooting...'),
'class' => 'btn btn-warning',
]
]
]);
?>
<div class="callout callout-warning">
<h4><?= Yii::t('app', 'This may cause data loose!') ?></h4>

<p><?= Yii::t('app', 'Reboot will interrupt all processes on the server. Are you sure you want to reset the server?') ?></p>
</div>
<?php Modal::end();
echo Html::endForm();

<?php ModalButton::end();
42 changes: 20 additions & 22 deletions src/views/server/_reinstall.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<?php
use hipanel\modules\server\assets\OsSelectionAsset;
use yii\bootstrap\Modal;
use hipanel\widgets\ModalButton;

use yii\helpers\Html;
use yii\helpers\Json;

echo Html::a('<i class="ion-ios-cog-outline"></i>' . Yii::t('app', 'Reinstall OS'), '#', [
'data-toggle' => 'modal',
'data-target' => "#modal_{$model->id}_reinstall",
]);

echo Html::beginForm(['reinstall'], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']);
echo Html::hiddenInput('id', $model->id);
Modal::begin([
'id' => "modal_{$model->id}_reinstall",
'toggleButton' => false,
'header' => Html::tag('h4', Yii::t('app', 'Please, select the operating system you want to install')),
'headerOptions' => ['class' => 'label-warning'],
'footer' => Html::button(Yii::t('app', 'Reinstall'), [
'class' => 'btn btn-warning',
'data-loading-text' => Yii::t('app', 'Reinstalling started...'),
'onClick' => new \yii\web\JsExpression("$(this).closest('form').submit(); $(this).button('loading');")
])
ModalButton::begin([
'model' => $model,
'scenario' => 'reinstall',
'button' => ['label' => '<i class="ion-ios-cog-outline"></i>' . Yii::t('app', 'Reinstall OS')],
'modal' => [
'header' => Html::tag('h4', Yii::t('app', 'Please, select the operating system you want to install')),
'headerOptions' => ['class' => 'label-info'],
'footer' => [
'label' => Yii::t('app', 'Reinstall'),
'data-loading-text' => Yii::t('app', 'Resinstalling started...'),
'class' => 'btn btn-warning',
]
]
]);
?>
<div class="callout callout-warning">
Expand Down Expand Up @@ -76,6 +74,7 @@
<strong><?= $softpack['name'] ?></strong>
<small style="font-weight: normal"><?= $softpack['description'] ?></small>
<a class="softinfo-bttn glyphicon glyphicon-info-sign" href="#"></a>

<div class="soft-desc" style="display: none;"></div>
</label>
</div>
Expand All @@ -87,13 +86,12 @@
</div>
</div>
</div>
<?php Modal::end();
echo Html::endForm();

OsSelectionAsset::register($this);
<?php OsSelectionAsset::register($this);
$this->registerJs("
var osparams = " . Json::encode($grouped_osimages['oses']) . ";
$('.os-selector').osSelector({
osparams: osparams
});
", \yii\web\View::POS_READY, 'os-selector-init'); ?>
", \yii\web\View::POS_READY, 'os-selector-init');

ModalButton::end();
41 changes: 17 additions & 24 deletions src/views/server/_reset-password.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
<?php
use yii\bootstrap\Modal;
use yii\helpers\Html;
use hipanel\widgets\ModalButton;

echo Html::a('<i class="fa fa-refresh"></i>' . Yii::t('app', 'Reset root password'), '#', [
'data-toggle' => 'modal',
'data-target' => "#modal_{$model->id}_reset-password",
echo ModalButton::widget([
'model' => $model,
'scenario' => 'reset-password',
'button' => ['label' => '<i class="fa fa-refresh"></i>' . Yii::t('app', 'Reset root password')],
'body' => Yii::t('app',
'Are you sure you want to reset the root password on {name} server? You will get your new root password on the e-mail.',
['name' => $model->name]),
'modal' => [
'header' => Html::tag('h4', Yii::t('app', 'Confirm root password resetting')),
'headerOptions' => ['class' => 'label-danger'],
'footer' => [
'label' => Yii::t('app', 'Reset root password'),
'data-loading-text' => Yii::t('app', 'Resetting...'),
'class' => 'btn btn-danger',
]
]
]);

echo Html::beginForm(['reset-password'], "POST", ['data' => ['pjax' => 1, 'pjax-push' => 0], 'class' => 'inline']);
echo Html::activeHiddenInput($model, 'id');
Modal::begin([
'id' => "modal_{$model->id}_reset-password",
'toggleButton' => false,
'header' => Html::tag('h4', Yii::t('app', 'Confirm root password resetting')),
'headerOptions' => ['class' => 'label-warning'],
'footer' => Html::button(Yii::t('app', 'Reset root password'), [
'class' => 'btn btn-warning',
'data-loading-text' => Yii::t('app', 'Resetting...'),
'onClick' => new \yii\web\JsExpression("
$(this).closest('form').trigger('submit');
$(this).button('loading');
")
])
]);
echo Yii::t('app', 'Are you sure you want to reset the root password on {name} server? You will get your new root password on the e-mail.',
['name' => $model->name]);
Modal::end();
echo Html::endForm();
Loading

0 comments on commit befcb6c

Please sign in to comment.