<?php
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
?>

<script type="text/javascript">
//<![CDATA[
    const operations = [];
    <?php if ($this->showEditButton): ?>
    operations.push({
        componentType: 'Jsw.SmallButton',
        id: 'buttonEditJail',
        title: <?php echo $this->jsLmsg('buttonEditJail') ?>,
        description: <?php echo $this->jsLmsg('hintEditJail') ?>,
        addCls: 'sb-edit-jail',
        href: '/server-protection/edit-jail/id/' + <?php echo $this->jsHtml(rawurlencode($this->jail->getName())); ?>
    });
    <?php endif; ?>
    <?php if ($this->jail->isEnabled()): ?>
    operations.push({
        componentType: 'Jsw.SmallButton',
        id: 'buttonDisableJails',
        title: <?php echo $this->jsLmsg('buttonDisableJail');?>,
        description: <?php echo $this->jsLmsg('hintDisableJail'); ?>,
        addCls: 'sb-turn-off',
        handler: function () {
            Jsw.redirectPost(Jsw.prepareUrl('/server-protection/toggle-jail/id/' + <?php echo $this->jsHtml(rawurlencode($this->jail->getName())); ?>));
        },
    });
    <?php elseif ($this->showActivateJailsButton): ?>
    operations.push({
        componentType: 'Jsw.SmallButton',
        id: 'buttonActivateJails',
        title: <?php echo $this->jsLmsg('buttonActivateJail');?>,
        description: <?php echo $this->jsLmsg('hintActivateJail'); ?>,
        addCls: 'sb-activate',
        handler: function () {
            Jsw.redirectPost(Jsw.prepareUrl('/server-protection/toggle-jail/id/' + <?php echo $this->jsHtml(rawurlencode($this->jail->getName())); ?>));
        },
    });
    <?php endif; ?>
    <?php if ($this->showRemoveButton): ?>
    operations.push({
        componentType: 'Jsw.SmallButton',
        id: 'buttonRemoveJail',
        title: <?php echo $this->jsLmsg('buttonRemoveJail') ?>,
        description: <?php echo $this->jsLmsg('hintRemoveJail') ?>,
        addCls: 'sb-remove-selected',
        handler: function () {
            Jsw.redirectPost(Jsw.prepareUrl('/server-protection/delete-jail/id/' + <?php echo $this->jsHtml(rawurlencode($this->jail->getName())); ?>));
        },
    });
    <?php endif; ?>
    const separator = {
        componentType: 'Jsw.bar.Separator'
    };
    new Jsw.Container({
        renderTo: 'main',
        items: [
            new Jsw.Hint({
                hint: <?php echo $this->jsLmsg('pageHint'); ?>
            }),

            new Jsw.SmallTools({
                operations: operations.flatMap((operation) => [separator, operation]).slice(1)
            }),

            {
                componentType: 'Jsw.Panel',
                cls: 'form-box',
                items: [
                    {
                        componentType: 'Jsw.form.DisplayField',
                        fieldLabel: <?php echo $this->jsLmsg('fieldSatatus'); ?>,
                        value: <?php echo $this->jsHtml($this->jail->isEnabled() ?
                            ('<img src="' . $this->skinUrl('/icons/16/plesk/on.png') . '" alt="' . $this->lmsg('enabled') . '" /> ' .
                                $this->lmsg('enabled')) :
                            ('<img src="' . $this->skinUrl('/icons/16/plesk/att.png') . '" alt="' . $this->lmsg('disabled') . '" /> ' .
                                $this->lmsg('disabled'))); ?>
                    }, {
                        componentType: 'Jsw.form.DisplayField',
                        fieldLabel: <?php echo $this->jsLmsg('fieldParameters'); ?>,
                        value: <?php echo $this->jsHtml('<pre class="code">' . $this->escape($this->jail->getText()) . '</pre>'); ?>
                    }
                ]
            }
        ]
    });
//]]>
</script>


<?php echo $this->partial('server-protection/_ban-list.phtml', [
    'bannedIpsList' => $this->bannedIpsList,
    'hint' => $this->jsLmsg('banListHint'),
    'dataUrl' => '/server-protection/ban-list-data/jail/' . $this->jail->getName(),
    'showJailColumn' => false,
    'showBanSwitchOnOffButton' => false,
    'banActive' => $this->banActive,
]); ?>
