<?php
// Copyright 1999-2021. Plesk International GmbH. All rights reserved.
?>

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

            new Jsw.List({
                id: 'admin-control-panel-access-list',
                data: <?php echo Zend_Json::encode($this->accessList->fetchData()); ?>,
                dataUrl: '/control-panel-access/list-data',
                searchFilters: <?php echo Zend_Json::encode($this->accessList->getSearchFilterConfig()); ?>,
                searchOveral: 'netaddr',
                operations: [
                    {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonAddNetwork',
                        title: <?php echo $this->accessList->jsLmsg('buttonAddNewNetwork');?>,
                        description: <?php echo $this->accessList->jsLmsg('buttonAddNewNetworkDescription'); ?>,
                        addCls: 'sb-add-new btn-primary',
                        href: '/control-panel-access/add-network'
                    }, {
                        componentType: 'Jsw.bar.Separator'
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonRemove',
                        title: <?php echo $this->accessList->jsLmsg('buttonRemove');?>,
                        description: <?php echo $this->accessList->jsLmsg('buttonRemoveDescription'); ?>,
                        addCls: 'sb-remove-selected',
                        handler: function (event) {
                            Jsw.getComponent('admin-control-panel-access-list').execGroupOperation({
                                url: '/control-panel-access/delete-network/',
                                subtype: 'delete',
                                mouseEvent: event,
                                locale: {
                                    confirmOnGroupOperation: <?php echo $this->accessList->jsLmsg('confirmOnDelete'); ?>
                                }
                            });
                        }
                    }, {
                        componentType: 'Jsw.bar.Separator'
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonSettings',
                        title: <?php echo $this->accessList->jsLmsg('buttonSettings');?>,
                        description: <?php echo $this->accessList->jsLmsg('buttonSettingsDescription'); ?>,
                        addCls: 'sb-settings',
                        handler: function () {
                            new Jsw.AjaxPopupForm({
                                cls: 'popup-panel',
                                title: <?php echo $this->jsLmsg('admin.controllers.control-panel-access.settings.title') ?>,
                                url: '/control-panel-access/settings',
                                locale: {
                                    waitMsg: <?php echo $this->jsLmsg('components.list.loadingTitle') ?>
                                }
                            });
                        }
                    }
                ],
                columns: [
                    Jsw.list.COLUMN_SELECTION,
                    {
                        header: <?php echo $this->accessList->jsLmsg('ipAddress');?>,
                        sortable: true,
                        dataIndex: 'netaddr',
                        renderer: function (item) {
                            return (
                                '<a href="' + Jsw.prepareUrl('/control-panel-access/edit-network/id/' + item.id) + '">' +
                                    Jsw.escapeHtml(item.netaddr) +
                                '</a>'
                            );
                        }
                    }, {
                        header: <?php echo $this->accessList->jsLmsg('subnetMask');?>,
                        sortable: true,
                        dataIndex: 'netmask'
                    }
                ]
            })
        ]
    });
//]]>
</script>
