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

<script type="text/javascript">
//<![CDATA[
    new Jsw.Panel({
        cls: 'list-box',
        renderTo: 'main',
        items: [
            new Jsw.Hint({
                hint: <?php echo $this->hint ?>
            }),

            new Jsw.List({
                id: 'banned-ips-list',
                data: <?php echo Zend_Json::encode($this->bannedIpsList->fetchData()); ?>,
                dataUrl: <?php echo $this->jsEscape($this->dataUrl); ?>,
                searchFilters: <?php echo Zend_Json::encode($this->bannedIpsList->getSearchFilterConfig()); ?>,
                operations: [{
                    componentType: 'Jsw.SmallButton',
                    id: 'buttonMoveToTrustedIp',
                    title: <?php echo $this->bannedIpsList->jsLmsg('buttonMoveToTrustedIp') ?>,
                    description: <?php echo $this->bannedIpsList->jsLmsg('hintMoveToTrustedIp') ?>,
                    addCls: 'sb-move',
                    handler: function(event) {
                        Jsw.getComponent('banned-ips-list').execGroupOperation({
                            url: '/server-protection/move-to-trusted',
                            subtype: 'move',
                            skipConfirmation: true
                        });
                    }
                }, {
                    componentType: 'Jsw.bar.Separator'
                }, {
                    componentType: 'Jsw.SmallButton',
                    id: 'buttonRemoveIp',
                    title: <?php echo $this->bannedIpsList->jsLmsg('buttonRemoveIp') ?>,
                    description: <?php echo $this->bannedIpsList->jsLmsg('hintRemoveIp') ?>,
                    addCls: 'sb-remove-selected',
                    handler: function(event) {
                        Jsw.getComponent('banned-ips-list').execGroupOperation({
                            url: '/server-protection/delete-banned-ips',
                            subtype: 'delete',
                            skipConfirmation: true
                        });
                    }
                }
                <?php if (isset($this->banActive)): ?>
                , {
                    componentType: 'Jsw.bar.Separator'
                }, {
                    componentType: 'Jsw.SmallButton',
                    <?php if ($this->banActive): ?>
                    id: 'buttonDisable',
                    attrs: { 'data-method': 'post' },
                    title: <?php echo $this->bannedIpsList->jsLmsg('buttonDisable') ?>,
                    description: <?php echo $this->bannedIpsList->jsLmsg('hintDisable') ?>,
                    addCls: 'sb-turn-off',
                    href: '/server-protection/disable'
                    <?php else: ?>
                    id: 'buttonEnable',
                    attrs: { 'data-method': 'post' },
                    title: <?php echo $this->bannedIpsList->jsLmsg('buttonEnable') ?>,
                    description: <?php echo $this->bannedIpsList->jsLmsg('hintEnable') ?>,
                    addCls: 'sb-turn-on',
                    href: '/server-protection/enable'
                    <?php endif; ?>
                }
                <?php endif; ?>
                ],
                columns: [
                    Jsw.list.COLUMN_SELECTION,
                    {
                        header: <?php echo $this->bannedIpsList->jsLmsg('ip');?>,
                        sortable: true,
                        dataIndex: 'ip'
                    <?php if ($this->showJailColumn): ?>
                    }, {
                        header: <?php echo $this->bannedIpsList->jsLmsg('jail');?>,
                        sortable: true,
                        dataIndex: 'jail',
                        renderer: function (item) {
                            var link = Jsw.prepareUrl('/server-protection/overview-jail/id/' +  encodeURIComponent(item.jail));
                            return '<a href="' + link + '">' + Jsw.escapeHtml(item.jail) + '</a>';
                        }
                    <?php endif; ?>
                    }
                ]
            })
        ]
    });
//]]>
</script>
