<?php
// Copyright 1999-2022. 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: 'failed-request-files-list',
                    searchOveral: 'name',
                    data: <?php echo Zend_Json::encode($this->failedRequestFilesList->fetchData()); ?>,
                    dataUrl: '/failed-request/list-data/id/<?php echo $this->domainId ?>',
                    isDisabledItem: function(item) {
                        return item.readOnly;
                    },
                    columns: [
                        Jsw.list.COLUMN_SELECTION,
                        {
                            header: <?php echo $this->failedRequestFilesList->jsLmsg('modificationDate'); ?>,
                            sortable: true,
                            dataIndex: 'modificationDate',
                            cls: 't-r number'
                        },
                        {
                            header: <?php echo $this->failedRequestFilesList->jsLmsg('name'); ?>,
                            sortable: true,
                            dataIndex: 'name',
                            renderer: function(item) {
                                return '<span class="tooltipData">' + <?php echo $this->failedRequestFilesList->jsLmsg('viewHint');?> + '</span>' +
                                    '<a href="' +
                                    Jsw.prepareUrl('/failed-request/view/id/<?php echo $this->domainId ?>/filename/' + encodeURIComponent(item.id)) +
                                    '" class="failed-request-file-name ext" target="_blank">' + Jsw.escapeHtml(item.name) + '</a>';
                            }
                        }
                    ],
                    operations: [{
                    <?php if ($this->tracingEnabled): ?>
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonDisableTracing',
                        title: <?php echo $this->failedRequestFilesList->jsLmsg('buttonDisableTracing');?>,
                        description: <?php echo $this->failedRequestFilesList->jsLmsg('buttonDisableTracingHint'); ?>,
                        addCls: 'sb-service-stop',
                        handler: function(event) {
                            Jsw.redirectPost('/failed-request/disable-tracing/id/<?php echo $this->domainId ?>');
                        }
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonChangeTracing',
                        title: <?php echo $this->failedRequestFilesList->jsLmsg('buttonChangeTracing');?>,
                        description: <?php echo $this->failedRequestFilesList->jsLmsg('buttonChangeTracingHint'); ?>,
                        addCls: 'sb-settings',
                        handler: function(event) {
                            Jsw.redirect('/failed-request/enable-tracing/id/<?php echo $this->domainId ?>');
                        }
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonRefresh',
                        title: <?php echo $this->failedRequestFilesList->jsLmsg('buttonRefresh') ?>,
                        description: <?php echo $this->failedRequestFilesList->jsLmsg('buttonRefreshHint') ?>,
                        addCls: 'sb-refresh',
                        handler: function () {
                            Jsw.getComponent('failed-request-files-list').reload();
                        }
                    }, {
                    <?php else: ?>
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonEnableTracing',
                        title: <?php echo $this->failedRequestFilesList->jsLmsg('buttonEnableTracing');?>,
                        description: <?php echo $this->failedRequestFilesList->jsLmsg('buttonEnableTracingHint'); ?>,
                        addCls: 'sb-service-start',
                        handler: function(event) {
                            new Jsw.AjaxPopupForm({
                                cls: 'popup-panel',
                                title: <?php echo $this->jsLmsg('smb.controllers.failed-request.enable-tracing.title') ?>,
                                url: '/failed-request/enable-tracing/id/<?php echo $this->domainId ?>',
                                locale: {
                                    waitMsg: <?php echo $this->jsLmsg('components.list.loadingTitle') ?>
                                }
                            });
                        }
                    }, {
                    <?php endif; ?>
                        componentType: 'Jsw.bar.Separator'
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonDownloadZip',
                        title: <?php echo $this->failedRequestFilesList->jsLmsg('downloadZip');?>,
                        description: <?php echo $this->failedRequestFilesList->jsLmsg('downloadZipHint'); ?>,
                        addCls: 'sb-download',
                        handler: function(event) {
                            Jsw.getComponent('failed-request-files-list').execGroupOperation({
                                submitHandler: Jsw.redirectPost,
                                url: '/failed-request/download/id/<?php echo $this->domainId ?>',
                                skipConfirmation: true
                            });
                        }
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonRemoveFailedRequestFiles',
                        title: <?php echo $this->failedRequestFilesList->jsLmsg('remove');?>,
                        description: <?php echo $this->failedRequestFilesList->jsLmsg('hintRemove'); ?>,
                        addCls: 'sb-remove-selected',
                        handler: function(event) {
                            Jsw.getComponent('failed-request-files-list').execGroupOperation({
                                url: '/failed-request/delete/id/<?php echo $this->domainId ?>',
                                subtype: 'delete',
                                mouseEvent: event,
                                locale: {
                                    confirmOnGroupOperation: <?php echo $this->failedRequestFilesList->jsLmsg('confirmOnDelete'); ?>
                                }
                            });
                        }
                    }]
                })
            ]
        });
    });
    //]]>
</script>
