<?php
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
?>
<p><?php echo $this->lmsg('hint'); ?></p>

<script type="text/javascript">
//<![CDATA[
    new Jsw.Panel({
        cls: 'list-box',
        renderTo: 'main',
        items: [
            new Jsw.List({
                id: 'admin-service-nodes-list',
                data: <?php echo Zend_Json::encode($this->serviceNodesList->fetchData()); ?>,
                dataUrl: '/service-node/list-data',
                disabledSelectHint: <?php echo $this->serviceNodesList->jsLmsg('disabledSelectHint');?>,
                searchFilters: <?php echo Zend_Json::encode($this->serviceNodesList->getSearchFilterConfig()); ?>,
                searchOveral: 'ipAddress',
                operations: [
                    {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonAddServiceNode',
                        title: <?php echo $this->serviceNodesList->jsLmsg('buttonAddServiceNode');?>,
                        description: <?php echo $this->serviceNodesList->jsLmsg('buttonAddServiceNodeDescription'); ?>,
                        addCls: 'sb-add-new-service-node btn-primary',
                        href: '/service-node/add'
                    }, {
                        componentType: 'Jsw.bar.Separator'
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonRemoveServiceNode',
                        title: <?php echo $this->serviceNodesList->jsLmsg('buttonRemoveServiceNode');?>,
                        description: <?php echo $this->serviceNodesList->jsLmsg('buttonRemoveServiceNodeDescription'); ?>,
                        addCls: 'sb-remove-selected',
                        handler: function(event) {
                            Jsw.getComponent('admin-service-nodes-list').execGroupOperation({
                                url: '/service-node/delete/',
                                subtype: 'delete',
                                mouseEvent: event,
                                locale: {
                                    confirmOnGroupOperation: <?php echo $this->serviceNodesList->jsLmsg('confirmOnDelete'); ?>
                                }
                            });
                        }
                    }
                ],
                columns: [
                    Jsw.list.COLUMN_SELECTION,
                    {
                        header: <?php echo $this->serviceNodesList->jsLmsg('ipAddress');?>,
                        sortable: true,
                        dataIndex: 'ipAddress',
                        renderer: function (item, isDisabled) {
                            return (
                                '<a href="' + Jsw.prepareUrl('/service-node/edit/id/' + item.id) + '">' +
                                    Jsw.escapeHtml(item.ipAddress) +
                                '</a>'
                            );
                        }
                    },
                    {
                        header: <?php echo $this->serviceNodesList->jsLmsg('description');?>,
                        sortable: true,
                        dataIndex: 'description',
                        renderer: function (item, isDisabled) {
                            return item.description ? Jsw.escapeHtml(item.description) : '';
                        }
                    }
                ],
                isDisabledItem: function (item) {
                    return (item.registeredIpAddresses > 0);
                }
            })
        ]
    });
//]]>
</script>
