<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Main.aspx.cs" Inherits="GigaTech.CMS.Web.Apps.DeviceSystem.VDPLog.Main" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
            <script src="/Scripts/jquery-1.6.4.min.js"></script>
</head>
<script language="javascript">
    var forPortlet = '<%=forPortlet%>';
    var hubConnected = false;

    Ext.onReady(function () {
        Ext.QuickTips.init();

        var gridStore = Ext.create('Ext.data.Store', {
            pageSize: 20,
            remoteSort: true,
            autoLoad: true,
            fields: ['Ident', 'CallerMAC', 'CallerModel', 'CallerIDs', 'CallerIP', 'CallerLocation', 'TargetMAC', 'TargetModel', 'TargetIDs', 'TargetIP', 'TargetLocation', 'ActionDateTime', 'Result'],
            proxy: {
                type: 'ajax',
                url: 'Handler.ashx?action=GetAllGridData',
                reader: {
                    type: 'json',
                    root: 'items',
                    totalProperty: 'totalCount'
                },
                simpleSortMode: true
            },
            sorters: [{
                property: "ActionDateTime",
                direction: "DESC"
            }]
        });

        var grid = Ext.create('Ext.grid.Panel', {
            id: 'VDPGrid',
            title: forPortlet == 'Y' ? '' : '<%=GetGlobalResourceObject("CMSResource", "AllCallRecords")%>',
            region: 'center',
            store: gridStore,
            //jmadd
            tbar: [
                    {
                        text: 'Export to CSV',
                        cls: 'x-btn-default-small',
                        border: 1,
                        style: {
                            borderColor: 'gray',
                            borderStyle: 'solid'
                        },
                        handler: function () {
                            try {  
                                parent.CMSClientDownload("/Apps/DeviceSystem/VDPLog/ImportExport.ashx?action=ExportCSV&tableName=system_device_vdp_log");
                            } catch (e) {
                                window.open("ImportExport.ashx?action=ExportCSV&tableName=system_device_vdp_log", "CMSDownloadIFrame");
                            }
                            //window.open("ImportExport.ashx?action=ExportCSV&tableName=system_device_reboot_log", "CMSDownloadIFrame");
                        }
                    }
            ],
            //finish
            columns: [
                { text: '<%=GetGlobalResourceObject("CMSResource", "CallerMAC")%>', dataIndex: 'CallerMAC', hidden: true },
                { text: '<%=GetGlobalResourceObject("CMSResource", "CallerLocation")%>', dataIndex: 'CallerLocation', flex: 1, sortable: false },
                { text: '<%=GetGlobalResourceObject("CMSResource", "CallerType")%>', dataIndex: 'CallerModel', width: 110 },
                { text: '<%=GetGlobalResourceObject("CMSResource", "CallerID")%>', dataIndex: 'CallerIDs', hidden: true },
                { text: '<%=GetGlobalResourceObject("CMSResource", "CallerIP")%>', dataIndex: 'CallerIP', width: 110 },
                { text: '<%=GetGlobalResourceObject("CMSResource", "CallTime")%>', dataIndex: 'ActionDateTime', width: 150 },
                {
                    text: '<%=GetGlobalResourceObject("CMSResource", "CallResult")%>', dataIndex: 'Result', width: 60,
                    renderer: function (value) {
                        return value == "1" ? "<font color=green><%=GetGlobalResourceObject("CMSResource", "Connected")%></font>" : "<font color=red><%=GetGlobalResourceObject("CMSResource", "Miss")%></font>";
                    }
                },
                 { text: '<%=GetGlobalResourceObject("CMSResource", "CalleeMAC")%>', dataIndex: 'TargetMAC', hidden: true },
                 { text: '<%=GetGlobalResourceObject("CMSResource", "CalleeLocation")%>', dataIndex: 'TargetLocation', flex: 1, sortable: false },
                { text: '<%=GetGlobalResourceObject("CMSResource", "CalleeType")%>', dataIndex: 'TargetModel', width: 110 },
                { text: '<%=GetGlobalResourceObject("CMSResource", "CalleeID")%>', dataIndex: 'TargetIDs', hidden: true },
                { text: '<%=GetGlobalResourceObject("CMSResource", "CalleeIP")%>', dataIndex: 'TargetIP', width: 110 }

            ],
            dockedItems: [{
                xtype: 'pagingtoolbar',
                hidden: forPortlet == 'Y',
                store: gridStore,
                dock: 'bottom',
                displayInfo: true
            }]
        });

        Ext.create('Ext.container.Viewport', {
            layout: {
                type: 'border'
            },
            items: [grid]
        });
    });
</script>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>
