<?php
// Copyright 1999-2026. WebPros International GmbH. All rights reserved.
?>
<?= $this->partial('partials/tabs.phtml', ['tabs' => $this->tabs, 'renderTo' => 'main', 'renderMode' => 'top']); ?>

<p><?= $this->trustedIpsList->lmsg('pageHint'); ?></p>

<script type="text/javascript">
    //<![CDATA[
        new Jsw.Panel({
            cls: 'list-box',
            renderTo: 'main',
            items: [
                new Jsw.List({
                    id: 'trusted-ips-list',
                    data: <?= Zend_Json::encode($this->trustedIpsList->fetchData()); ?>,
                    dataUrl: '/server-protection/trusted-list-data',
                    searchFilters: <?= Zend_Json::encode($this->trustedIpsList->getSearchFilterConfig()); ?>,
                    operations: [{
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonAddTrustedIp',
                        title: <?= $this->trustedIpsList->jsLmsg('buttonAddTrustedIp') ?>,
                        description: <?= $this->trustedIpsList->jsLmsg('hintAddTrustedIp') ?>,
                        addCls: 'sb-item-add',
                        href: '/server-protection/add-trusted-ip'
                    }, {
                        componentType: 'Jsw.bar.Separator'
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonRemoveIp',
                        title: <?= $this->trustedIpsList->jsLmsg('buttonRemoveIp') ?>,
                        description: <?= $this->trustedIpsList->jsLmsg('hintRemoveIp') ?>,
                        addCls: 'sb-remove-selected',
                        handler: function(event) {
                            Jsw.getComponent('trusted-ips-list').execGroupOperation({
                                url: '/server-protection/delete-trusted-ips',
                                subtype: 'delete',
                                skipConfirmation: true
                            });
                        }
                    }],
                    columns: [
                        Jsw.list.COLUMN_SELECTION,
                        {
                            header: <?= $this->trustedIpsList->jsLmsg('ip');?>,
                            sortable: true,
                            dataIndex: 'ip'
                        },
                        {
                            header: <?= $this->trustedIpsList->jsLmsg('ipDesc');?>,
                            cls: 'max',
                            sortable: false,
                            dataIndex: 'description'
                        },
                        {
                            cls: 'min',
                            renderer: function (item) {
                                return '<span class="tooltipData">' + <?= $this->trustedIpsList->jsLmsg('buttonEditHint');?> + '</span>' +
                                    '<a href="' + Jsw.prepareUrl('/server-protection/edit-trusted-ip/?ip=' + Jsw.escapeHtml(item.ip)) +'" class="s-btn sb-edit"><span>'+<?= $this->trustedIpsList->jsLmsg('buttonEditTrustedIp');?>+'</span></a>';
                            }
                        }
                    ]
                })
            ]
        });
    //]]>
</script>
