<?php
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
?>
<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function() {

    new Jsw.Hint({
        renderTo: 'main',
        hint: <?php echo $this->jsLmsg('hint'); ?>
    });

    new Jsw.Panel({
        cls: 'list-box',
        renderTo: 'main',
        items: [
            new Jsw.List({
                id: 'web-users-list',
                searchOveral: 'name',
                searchFilters: <?php echo Zend_Json::encode($this->webUsersList->getSearchFilterConfig()); ?>,
                data: <?php echo Zend_Json::encode($this->webUsersList->fetchData()); ?>,
                dataUrl: '/web-user/list-data',
                columns: [
                    Jsw.list.COLUMN_SELECTION,
                    {
                        header: <?php echo $this->webUsersList->jsLmsg('name'); ?>,
                        sortable: true,
                        dataIndex: 'name',
                        renderer: function(item) {
                            return '<a href=' + Jsw.prepareUrl('/web-user/edit/id/' + item.id) + '>' + item.name + '</a>';
                        }
                    }, {
                        header: '',
                        sortable: false,
                        cls: 'min',
                        renderer: function(item) {
                            return '<span class="tooltipData">' + <?php echo $this->webUsersList->jsLmsg('buttonOpenHomepageHint');?> + '</span>' +
                                '<a target="_blank" href=' + item.url +' class="s-btn sb-open-in-browser"><span></span></a>';
                        }
                    }
                ],
                operations: [
                    {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonCreate',
                        title: <?php echo $this->webUsersList->jsLmsg('add');?>,
                        description: <?php echo $this->webUsersList->jsLmsg('hintAdd', array('resourceUsage' => $this->resourceUsage)); ?>,
                        addCls: 'sb-add-user btn-primary',
                        href: '/web-user/create'
                    }, {
                        componentType: 'Jsw.bar.Separator'
                    },
                    {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonSettings',
                        title: <?php echo $this->webUsersList->jsLmsg('settings');?>,
                        description: <?php echo $this->webUsersList->jsLmsg('hintSettings'); ?>,
                        addCls: 'sb-settings',
                        href: '/web-user/settings'
                    }, {
                        componentType: 'Jsw.bar.Separator'
                    },
                    {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonRemoveWebUser',
                        title: <?php echo $this->webUsersList->jsLmsg('remove');?>,
                        description: <?php echo $this->webUsersList->jsLmsg('hintRemove'); ?>,
                        addCls: 'sb-remove-selected',
                        handler: function(event) {
                            Jsw.getComponent('web-users-list').execGroupOperation({
                                url: '/web-user/delete',
                                subtype: 'delete',
                                mouseEvent: event,
                                locale: {
                                    confirmOnGroupOperation: <?php echo $this->webUsersList->jsLmsg('confirmOnDelete'); ?>
                                }
                            });
                        }
                    }
                ]
            })
        ]
    });

});
//]]>
</script>
