<?php
// Copyright 1999-2021. Plesk International GmbH. All rights reserved.
?>
<script type="text/javascript">
//<![CDATA[
    Jsw.addStatusMessage('warning', <?php echo $this->jsLmsg('legacyModeHint', [
        'link' => $this->htmlLink('', $this->lmsg('legacyModeHintLinkText'), ['href' => '/smb/database/list']),
    ]) ?>);

    new Jsw.Panel({
        cls: 'list-box',
        renderTo: 'main',
        items: [
            new Jsw.List({
                id: 'dumps-list',
                searchFilters: <?php echo Zend_Json::encode($this->dumpsList->getSearchFilterConfig()); ?>,
                searchOveral: 'name',
                data: <?php echo Zend_Json::encode($this->dumpsList->fetchData()); ?>,
                dataUrl: <?php echo $this->jsEscape($this->url(['action' => 'backup-database-data'])) ?>,
                columns: [
                    Jsw.list.COLUMN_SELECTION,
                    {
                        header: <?php echo $this->dumpsList->jsLmsg('name');?>,
                        sortable: true,
                        cls: 'name',
                        dataIndex: 'name'
                    },
                    {
                        header: <?php echo $this->dumpsList->jsLmsg('database');?>,
                        sortable: true,
                        cls: 'name',
                        dataIndex: 'db'
                    },
                    {
                        header: <?php echo $this->dumpsList->jsLmsg('size');?>,
                        sortable: true,
                        cls: 'number',
                        dataIndex: 'size',
                        renderer: function (item, isDisabled) {
                            return Jsw.escapeHtml(item.sizeString);
                        }
                    },
                    {
                        header: <?php echo $this->dumpsList->jsLmsg('createdDate');?>,
                        sortable: true,
                        cls: 'number',
                        dataIndex: 'timestamp',
                        renderer: function (item, isDisabled) {
                            return Jsw.escapeHtml(item.timestampString);
                        }
                    },
                    {
                        header: '',
                        sortable: false,
                        cls: 'min',
                        renderer: function (item, isDisabled) {
                            var url = <?= $this->jsEscape($this->url(['action' => 'backup-database-download'])) ?>;
                            var urlParams = {
                                databaseId: item.dbid,
                                name: item.name
                            };
                            return (
                                '<span>' +
                                    '<span class="tooltipData"><?php echo $this->dumpsList->lmsg('downloadHint'); ?></span>' +
                                    '<a href="' + Jsw.escapeHtml(Jsw.addUrlParams(url, urlParams)) + '">' +
                                        '<img src="<?php echo $this->skinUrl('/icons/16/plesk/download.png') ?>"/>' +
                                    '</a>' +
                                '</span>'
                            );
                        }
                    }
                ],
                operations: [{
                    componentType: 'Jsw.SmallButton',
                    id: 'buttonRemove',
                    title: <?php echo $this->dumpsList->jsLmsg('removeButton'); ?>,
                    description: <?php echo $this->dumpsList->jsLmsg('removeButtonHint'); ?>,
                    cls: 's-btn sb-remove-selected',
                    handler: function (event) {
                        Jsw.getComponent('dumps-list').execGroupOperation({
                            url: '<?php echo $this->url(['action' => 'backup-database-remove']); ?>',
                            subtype: 'delete',
                            mouseEvent: event,
                            locale: {
                                confirmOnGroupOperation: <?php echo $this->dumpsList->jsLmsg('removeConfirmation'); ?>
                            }
                        });
                    }
                }]
            })
        ]
    });
//]]>
</script>
