<%@ page title="" language="VB" masterpagefile="~/Template/Master.master" autoeventwireup="false" inherits="PCC_System_Servers, MachSol.MachPanel.Web" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="Ajax" %>

<%@ Register Src="~/Template/GVPager.ascx" TagName="Pager" TagPrefix="UC" %>

<%@ Register TagPrefix="cc1" Namespace="System.Web.UI" Assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CPH_Content" runat="Server">
    <div class="col-xs-12">
        <div class="card">
            <div class="header">
                <h3>Manage Servers
                </h3>
            </div>
            <div class="body">

                <ajax:TabContainer ID="TbCntr_Servers" runat="server" OnClientActiveTabChanged="loadTabPanel">
                    <ajax:TabPanel ID="Tab_ControlServers" runat="server" HeaderText="<%$ Resources:Content,ControlPanelServers %>">
                        <ContentTemplate>
                            <asp:Button ID="Btn_Tab0" runat="server" Style="display: none;" />
                            <asp:Panel ID="Pnl_TabContent0" runat="server">
                                <div class="row">
                                    <div class="col-xs-12">
                                        <asp:GridView ID="GV_Servers" CssClass="table table-bordered table-striped table-hover" AllowSorting="true" AllowPaging="true"
                                            EmptyDataText='<%$ Resources:Content, GN00001375 %>' runat="server" AutoGenerateColumns="False"
                                            DataKeyNames="IsPrimary, AdminLogin, AdminPassword, ServerIP, MPServerId">
                                            <Columns>
                                                <asp:TemplateField HeaderText='<%$Resources:content,strStatus%>' HeaderStyle-CssClass="col-xs-2" ItemStyle-CssClass="col-xs-2">
                                                    <ItemTemplate>
                                                        <asp:Label ID="Lbl_Enable" runat="server"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText='<%$Resources:content,strName%>' HeaderStyle-CssClass="col-xs-3" ItemStyle-CssClass="col-xs-3">
                                                    <ItemTemplate>
                                                        <asp:Label ID="Lbl_Name" runat="server"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText='<%$Resources:content,USM0063%>' HeaderStyle-CssClass="col-xs-2" ItemStyle-CssClass="col-xs-2">
                                                    <ItemTemplate>
                                                        <asp:Label ID="Lbl_Server" runat="server"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText='<%$Resources:content,GN000174%>' HeaderStyle-CssClass="col-xs-2" ItemStyle-CssClass="col-xs-2">
                                                    <ItemTemplate>
                                                        <asp:Label ID="Lbl_ServerIP" runat="server"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText='<%$Resources:content,USM0061%>' HeaderStyle-CssClass="col-xs-3" ItemStyle-CssClass="col-xs-3">
                                                    <ItemTemplate>
                                                        <asp:Label ID="Lbl_UserName" runat="server"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="<%$Resources:Content,GN0000368 %>" HeaderStyle-CssClass="col-xs-5" ItemStyle-CssClass="col-xs-5">
                                                    <ItemTemplate>
                                                        <asp:LinkButton ID="Lbtn_Details" runat="server" Text="<%$Resources:Content,strDetails %>"
                                                            CausesValidation="false" CommandName="health" class="btn btn-primary waves-effect"></asp:LinkButton>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                    </div>
                                </div>
                            </asp:Panel>
                        </ContentTemplate>
                    </ajax:TabPanel>
                    <ajax:TabPanel ID="Tab_RemoteServers" runat="server" HeaderText="<%$ Resources:Content,L00242%>">
                        <ContentTemplate>
                            <asp:Button ID="Btn_Tab1" runat="server" Style="display: none;" />
                            <asp:Panel ID="Pnl_TabContent1" runat="server" Visible="false">
                                <div class="row Div_OpsRow" id="Div_OpsRow2" runat="server">
                                    <div class="col-xs-12">
                                        <div class="card">
                                            <div class="header">
                                                <h3>
                                                    <%= Resources.Content.GN00001320%>                                                                                                                                 
                                                </h3>
                                            </div>
                                            <div class="body">
                                                <asp:Button ID="btnEnable" runat="server" Text="<%$ Resources:Content,strEnable%>" class="btn btn-primary waves-effect btnAction" Custom1="Custom" Style="display: none" />
                                                <asp:Button ID="btnDisable" runat="server" Text="<%$ Resources:Content,strDisable%>" class="btn btn-primary waves-effect btnAction" Custom1="Custom" Style="display: none" />

                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">

                                    <div class="col-xs-12">

                                        <asp:Panel ID="Pnl_Filter" runat="server" DefaultButton="Btn_Filter">
                                            <div class="row">
                                                <div class="panel-group search-panel" id="AS_RemoteServers" role="tablist" aria-multiselectable="true">
                                                    <div class="col-xs-12" role="tab" id="SH_RemoteServers">
                                                        <div class="card">
                                                            <div class="header" role="button" data-toggle="collapse" data-parent="#AS_RemoteServers" href="#<%= CSB_RemoteServers.ClientID%>" aria-expanded="true" aria-controls="SH_RemoteServers">
                                                                <h3>
                                                                    <%= Resources.Content.GN0000395%>
                                                                </h3>
                                                            </div>
                                                            <div id="CSB_RemoteServers" runat="server" class="body panel-collapse collapse" role="tabpanel" aria-labelledby="SH_RemoteServers" aria-expanded="false">
                                                                <div class="row">
                                                                    <div class="col-md-3 col-sm-6 col-xs-12">
                                                                        <div class="form-group form-float">
                                                                            <asp:DropDownList ID="DDL_ADDomains" runat="server" />
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-md-3 col-sm-6 col-xs-12">
                                                                        <div class="form-group form-float">
                                                                            <asp:DropDownList ID="DDL_ServiceTypes" runat="server"></asp:DropDownList>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-md-3 col-sm-6 col-xs-12">
                                                                        <div class="form-group form-float">
                                                                            <asp:DropDownList ID="DDL_Status" MaxLength="255" runat="server">
                                                                                <asp:ListItem Text="<%$ Resources:Content,SelectStatus %>" Value="-1" Selected="True" />
                                                                                <asp:ListItem Text="<%$ Resources:Content,GN000195 %>" Value="1" />
                                                                                <asp:ListItem Text="<%$ Resources:Content,GN0000860 %>" Value="0" />
                                                                            </asp:DropDownList>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-md-3 col-sm-6 col-xs-12">
                                                                        <div class="form-group form-float">
                                                                            <div class="form-line">
                                                                                <asp:TextBox ID="TxBx_ReferenceID" runat="server"></asp:TextBox>
                                                                                <asp:Label ID="Label2" runat="server" EnableViewState="false" Text="<%$ Resources:Content,DGN1110019%>" class="form-label"></asp:Label>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-md-3 col-sm-6 col-xs-12">
                                                                        <div class="form-group form-float">
                                                                            <div class="form-line">
                                                                                <asp:TextBox ID="TxBx_IP" runat="server" MaxLength="255"></asp:TextBox>
                                                                                <asp:Label ID="Label7" runat="server" EnableViewState="false" Text="<%$ Resources:Content,GN000174%>" class="form-label"></asp:Label>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-xs-12">
                                                                        <div class="form-group form-float">
                                                                            <asp:Button ID="Btn_Filter" runat="server" class="btn btn-primary waves-effect" Text="<%$ Resources:Content,GN0000391%>" />
                                                                            <asp:Button ID="Btn_Clear" Visible="false" class="btn btn-primary waves-effect" runat="server"
                                                                                Text="<%$ Resources:Content,String289 %>" />
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </asp:Panel>

                                        <div class="clearfix">
                                            <div class="double-scroll-wrapper1">
                                                <div>
                                                </div>
                                            </div>
                                            <div class="double-scroll-wrapper2">
                                                <asp:GridView ID="GV_RemoteServers" CssClass="table table-bordered table-striped table-hover table-layout-fixed" AllowSorting="true"
                                                    AllowPaging="true" EmptyDataText='<%$ Resources:Content, GN00001375 %>' runat="server" Style="min-width: 1650px; max-width: 4020px;"
                                                    AutoGenerateColumns="False">

                                                    <Columns>
                                                        <asp:TemplateField HeaderStyle-Width="50px" HeaderText='<%$ Resources:Content,GN0000370 %>'>
                                                            <HeaderTemplate>
                                                                <asp:CheckBox class="option-menu" ID="ChkBx_All" runat="server" Text=" " onclick="SetCheckedHeader(this.checked, this,'All');" />
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <asp:CheckBox class="option-menu" ID="ChkBx_Item" runat="server" Text=" " onclick="SetCheckedHeader(this.checked, this,'1');" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText='<%$ Resources:Content, GN0000368 %>' HeaderStyle-Width="165px">

                                                            <ItemTemplate>
                                                                <asp:LinkButton class="btn btn-primary waves-effect" ID="LB_TestService" CommandName="TestService"
                                                                    runat="server" Text='<%$Resources:Content,String318%>' />
                                                                <asp:LinkButton ID="Lbtn_Details" runat="server" Text="<%$Resources:Content,strDetails %>"
                                                                    CausesValidation="false" CommandName="health" class="btn btn-primary waves-effect"></asp:LinkButton>
                                                                <asp:LinkButton class="btn btn-primary waves-effect btnAction" ID="Lbtn_Update" CommandName="updateremote"
                                                                    runat="server" Text='<%$Resources:Content,Update%>' />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField SortExpression="Status" HeaderText='<%$ Resources:Content, String385 %>' HeaderStyle-Width="65px">
                                                            <ItemTemplate>
                                                                <asp:Literal ID="Ltl_Status" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText='<%$Resources:content,strName%>' HeaderStyle-Width="130px">
                                                            <ItemTemplate>
                                                                <asp:Label ID="Lbl_Name" runat="server"></asp:Label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField SortExpression="IP" HeaderText='<%$ Resources:Content,GN000174%>' HeaderStyle-Width="120px">
                                                            <ItemTemplate>
                                                                <div id="Div_IP" runat="server" />
                                                                <asp:HiddenField ID="HF_ServerId" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField SortExpression="ReferenceId" HeaderText='<%$ Resources:Content,DGN1110019%>' HeaderStyle-Width="200px">
                                                            <ItemTemplate>
                                                                <asp:HyperLink ID="LB_ServerName" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.ReferenceId")%>' />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField SortExpression="ServerGroupName" HeaderText='<%$ Resources:Content,GN0000971%>' HeaderStyle-Width="200px">
                                                            <ItemTemplate>
                                                                <asp:HyperLink ID="LB_ServerGroupName" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.ServerGroupName")%>' />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText='<%$ Resources:Content, GN00001101 %>' HeaderStyle-Width="80px">
                                                            <ItemTemplate>
                                                                <asp:Label ID="Lbl_RemoteVersion" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.RemoteVersion")%>' />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>

                                                        <asp:TemplateField SortExpression="ADDomain" HeaderText='<%$ Resources:Content, DGN1110433 %>' HeaderStyle-Width="150px">
                                                            <ItemTemplate>
                                                                <asp:HyperLink ID="LB_ADDomain" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.ADDomain")%>' />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText='<%$ Resources:Content,DGN1110261%>' HeaderStyle-Width="150px">
                                                            <ItemTemplate>
                                                                <asp:Literal ID="Ltl_LoginName" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText='Additional Servers' HeaderStyle-Width="150px" Visible="false">
                                                            <ItemTemplate>
                                                                <div id="Div_DAGIPs" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField SortExpression="ServiceTypeName" HeaderText='<%$ Resources:Content,GN000135%>' HeaderStyle-Width="120px">
                                                            <ItemTemplate>
                                                                <%#DataBinder.Eval(Container, "DataItem.ServiceTypeName")%>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>

                                                    </Columns>
                                                    <%--PagerTemplate Start--%>
                                                    <PagerTemplate>
                                                        <UC:Pager ID="Pager1" runat="server" />
                                                    </PagerTemplate>
                                                    <%--PagerTemplate End--%>
                                                </asp:GridView>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <asp:Panel ID="Pnl_ServiceTest" runat="server" CssClass="width-modal-popup-auto" Style="display: none">
                                    <div class="col-xs-12">
                                        <div class="card">
                                            <div class="header">
                                                <h3><%= Resources.Content.L0096%></h3>
                                            </div>
                                            <div class="body">
                                                <div class="row">
                                                    <div id="Td_Message" class="col-xs-12" runat="server">
                                                        <asp:Label ID="Lbl_ServicesStaus" runat="server" Font-Bold="true" EnableViewState="false"></asp:Label>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-xs-12">
                                                        <asp:Button ID="Btn_OK" runat="server" Text="<%$ Resources:Content,GN0000858%>" class="btn btn-primary waves-effect" />
                                                        <asp:Button ID="Btn_Display" runat="server" Style="display: none;" CssClass="btn btn-primary waves-effect" />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </asp:Panel>

                                <ajax:ModalPopupExtender runat="server" ID="MPE_ServicesTest" BackgroundCssClass="modalBackground"
                                    DropShadow="false" PopupControlID="Pnl_ServiceTest" TargetControlID="Btn_Display"
                                    OkControlID="Btn_OK">
                                </ajax:ModalPopupExtender>
                                </div>
                            </asp:Panel>
                        </ContentTemplate>
                    </ajax:TabPanel>
                </ajax:TabContainer>

            </div>
        </div>
    </div>

    <asp:Button ID="Button2" runat="server" CssClass="btn-dummy" />
    <asp:Button ID="Button1" runat="server" CssClass="btn-dummy" />
    <ajax:ModalPopupExtender runat="server" ID="MPE_ServerStats" BackgroundCssClass="modalBackground"
        DropShadow="false" PopupControlID="Pnl_ServerStats" TargetControlID="Button1" OkControlID="Button2">
    </ajax:ModalPopupExtender>
    <%----%>
    <asp:Panel ID="Pnl_ServerStats" runat="server" CssClass="width-modal-popup-auto" Style="display: none; position: fixed;">
        <div class="col-xs-12">
            <div class="card">
                <div class="header container-fluid">
                    <h3 class="pull-left">
                        <span id="server-name"></span>
                    </h3>
                    <span>
                        <button type="button" class="close" onclick="$find('<%=MPE_ServerStats.ClientID%>').hide();">&times;</button>
                    </span>
                </div>
                <div class="body">
                    <div class="row">
                        <div class="col-md-4 col-sm-6 col-xs-12" id="div-general-info">
                            <h3><%= Resources.Content.GeneralInformation %></h3>
                            <hr />
                            <div class="row">
                                <span class="col-xs-5 row-label">
                                    <asp:Literal ID="Ltrl123" runat="server" Text="<% $Resources:Content,GN00001560 %>"></asp:Literal>:</span>
                                <span id="general-info-os" class="col-xs-6"></span>
                            </div>
                            <div class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl124" runat="server" Text="<% $Resources:Content,GN00001101 %>"></asp:Literal>:</span>
                                <span id="general-info-os-version" class="col-xs-6"></span>
                            </div>
                            <div class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl125" runat="server" Text="<% $Resources:Content,WorkGroup %>"></asp:Literal>:</span>
                                <span id="general-info-workgroup" class="col-xs-6"></span>
                            </div>
                            <div class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl126" runat="server" Text="<% $Resources:Content,strDomain %>"></asp:Literal>:</span>
                                <span id="general-info-domain" class="col-xs-6"></span>
                            </div>
                            <div class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl127" runat="server" Text="<% $Resources:Content,InstallPath %>"></asp:Literal>:</span>
                                <span id="general-info-install-path" class="col-xs-6"></span>
                            </div>
                            <div id="div-install-url" class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl128" runat="server" Text="<% $Resources:Content,Installurl %>"></asp:Literal>:</span>
                                <span id="general-info-install-url" class="col-xs-6"></span>
                            </div>
                        </div>

                        <div class="col-md-4 col-sm-6 col-xs-12" id="div-db-info">
                            <h3><%= Resources.Content.String18 %></h3>
                            <hr />
                            <div class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl129" runat="server" Text="<% $Resources:Content,SPT002274 %>"></asp:Literal>:</span>
                                <span id="db-info-server" class="col-xs-6"></span>
                            </div>
                            <div class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl130" runat="server" Text="<% $Resources:Content,SPT002073 %>"></asp:Literal>:</span>
                                <span id="db-info-name" class="col-xs-6"></span>
                            </div>
                            <div class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl131" runat="server" Text="<% $Resources:Content,SPT002074 %>"></asp:Literal>:</span>
                                <span id="db-info-user" class="col-xs-6"></span>
                            </div>
                            <div class="row">
                                <span class="row-label col-xs-5">
                                    <asp:Literal ID="Ltrl132" runat="server" Text="<% $Resources:Content,FailoverPartner %>"></asp:Literal>:</span>
                                <span id="db-info-partner" class="col-xs-6"></span>
                            </div>
                        </div>

                        <div class="col-md-4 col-sm-6 col-xs-12" id="div-svc-info">
                            <h3><%= Resources.Content.String57 %></h3>
                            <hr />
                            <div id="panel-svc-wrapper" class="col-xs-8">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-6 col-xs-12">
                            <h3><%= Resources.Content.CPUUsage %></h3>
                            <hr />
                            <div id="cpu-stats"></div>
                        </div>

                        <div class="col-sm-6 col-xs-12">
                            <h3><%= Resources.Content.MemoryUsageInPercentage%></h3>
                            <hr />
                            <div id="memory-stats"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12">
                            <h3><%= Resources.Content.DiskUsageInGB %></h3>
                            <hr />
                            <div id="disk-stats-wrapper" class="row">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </asp:Panel>

    <script type="text/javascript">
        //$(document).ready(function () {
        //    setTimeout(function () {
        //        $("table[id$='GV_RemoteServers'] tr td input[id$='HF_ServerId']").each(function () {
        //            $this = $(this);
        //            setTimeout(function ($source) {
        //                let hostUrl = $(location).attr('protocol') + '//' + $(location).attr('host');

        //                let param;

        //                param = "{ip:'" + $source.val() + "'}";

        //                let $Lbtn_Update = $source.parent('td').parent('tr').find("a[id$='Lbtn_Update']").first();
        //                if ($Lbtn_Update) {
        //                    $Lbtn_Update.addClass('hide');
        //                    $.ajax({
        //                        type: "POST",
        //                        url: hostUrl + "/WebServices/MachPanelService.asmx/isUpdateRequiredOnRemote",
        //                        data: param,
        //                        contentType: "application/json; charset=utf-8",
        //                        dataType: "json",
        //                        success: function (response) {
        //                            let result = JSON.parse(response.d);
        //                            if (result.Status == "success" && result.required == true) {

        //                                $Lbtn_Update.removeClass('hide');

        //                            }
        //                            //else
        //                            //    console.error(result.ErrorMessage);

        //                        },
        //                        error: function () { console.error("Remote server update required get failed: " + param); }
        //                    });
        //                }
        //            }, 50, $this);

        //        });
        //    }, 100);

        //});

        //Server Heath Info
        function ShowServerInfo(event, IP) {

            var params = "{'IP': '" + IP + "'}";

            $.ajax({
                type: "POST",
                url: "/PCC/System/Servers.aspx/GetServerStatsAsync",
                async: true,
                data: params,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    if (msg.d.indexOf('Error') < 0) {

                        $find('<%=MPE_ServerStats.ClientID%>').show();
                        setTimeout(function () {
                            try {
                                $('.width-modal-popup-auto').css('width', 85 / 100 * $(window).width() + 'px');
                                $(window).on('resize', function () { $('.width-modal-popup-auto').css('width', 85 / 100 * $(window).width() + 'px'); });
                            } catch{ }
                        }, 100);

                        let data = JSON.parse(msg.d);
                        try {

                            $("#cpu-stats").empty();
                            $("#memory-stats").empty();

                            let config = {
                                data: data.cpu.data,
                                parseTime: false,
                                xkey: 'x',
                                ykeys: ['y'],
                                labels: [data.cpu.label],
                                fillOpacity: 0.6,
                                hideHover: 'auto',
                                behaveLikeLine: true,
                                resize: true,
                                pointFillColors: ['#ffffff'],
                                pointStrokeColors: ['black'],
                                lineColors: ['#44c1b9', 'red'],
                                hoverCallback: function (index, options, content, row) {
                                    return "<div class='morris-hover-row-label'>" + row.x + "</div><div class='morris-hover-point' style='color: b'>" +
                                        "<%=Resources.Content.CPUUsage%>: " + row.y + "</div>";
                                }
                            };

                            config.element = 'cpu-stats';
                            let cpuGraph = Morris.Area(config);
                            $("#cpu-stats > svg:nth-child(1)").css("min-width", $("#cpu-stats").width());
                            cpuGraph.redraw();

                            config = {
                                data: data.memory.data,
                                parseTime: false,
                                xkey: 'x',
                                ykeys: ['y'],
                                labels: [data.memory.label],
                                fillOpacity: 0.6,
                                hideHover: 'auto',
                                behaveLikeLine: true,
                                resize: true,
                                pointFillColors: ['#ffffff'],
                                pointStrokeColors: ['black'],
                                lineColors: ['#b444c1', 'red'],
                                hoverCallback: function (index, options, content, row) {
                                    return "<div class='morris-hover-row-label'>" + row.x + "</div><div class='morris-hover-point' style='color: b'>" +
                                        "<%=Resources.Content.MemoryUsageInPercentage%>: " + row.y + "</div>";
                                }
                            };

                            config.element = 'memory-stats';
                            let memoryGraph = Morris.Area(config);
                            $("#memory-stats > svg:nth-child(1)").css("min-width", $("#memory-stats").width());
                            memoryGraph.redraw();

                            let diskStatsWrapper = document.getElementById('disk-stats-wrapper');
                            diskStatsWrapper.innerHTML = "";//reset;

                            x = 0;
                            for (let x = 0; x < data.disk.volumes.length; x++) {
                                let v = data.disk.volumes[x];
                                let diskStatsCol = document.createElement("div");
                                $(diskStatsCol).addClass('col-md-4 col-sm-6 col-xs-12');

                                let diskStats = document.createElement('div');
                                diskStats.id = 'vol-stats-' + x.toString();
                                $(diskStats).css('position', 'relative');

                                diskStatsCol.append(diskStats);
                                diskStatsWrapper.append(diskStatsCol);

                                let donut = Morris.Donut({
                                    element: 'vol-stats-' + x.toString(),
                                    data: v.data
                                });

                                $("#disk-stats-wrapper #vol-stats-" + x + " > svg:nth-child(1)").css("max-height", "170px");
                                $("#disk-stats-wrapper #vol-stats-" + x + " > svg:nth-child(1)").css("max-width", "78%");
                                donut.redraw();
                            }

                            x = 0;
                            for (let x = 0; x < data.disk.volumes.length; x++) {
                                let v = data.disk.volumes[x];
                                let diskStats = document.getElementById('vol-stats-' + x.toString());
                                let diskLabel = document.createElement('span');
                                $(diskLabel).css('position', 'absolute');
                                $(diskLabel).css('top', '55%');

                                $(diskLabel).html("Drive: " + v.label);
                                diskStats.insertBefore(diskLabel, diskStats.firstChild);
                            }
                        }
                        catch (e) { console.error(e); }

                        $('#server-name').html("");//reset;
                        $('#server-name').html(data.serverName);

                        //general info
                        $('#general-info-os').html(data.general.windowsProductName);
                        $('#general-info-os-version').html(data.general.windowsVersion);
                        $('#general-info-workgroup').html(data.general.workGroup);
                        $('#general-info-domain').html(data.general.domain);
                        $('#general-info-install-path').html(data.general.installPath);
                        if (data.general.installUrl && data.general.installUrl != '') {
                            $('#general-info-install-url').html(data.general.installUrl);
                        }
                        else
                            $('#div-install-url').hide();

                        //database info
                        if (data.database) {
                            $('#db-info-server').html(data.database.dataSource);
                            $('#db-info-name').html(data.database.initialCatalog);
                            $('#db-info-user').html(data.database.userId);
                            $('#db-info-partner').html(data.database.failoverPartner);
                        }
                        else {
                            $('#div-general-info, #div-svc-info').removeClass('col-md-4');
                            $('#div-db-info').hide().addClass('hide');
                        }

                        let svcWrapper = document.getElementById('panel-svc-wrapper');
                        svcWrapper.innerHTML = "";//reset;

                        x = 0;
                        for (x = 0; x < data.services.length; x++) {
                            let svc = data.services[x];
                            let svcNode = document.createElement('div');
                            $(svcNode).css('padding', '0.50rem 0rem');
                            $(svcNode).css('border-bottom', 'solid 1px #999');
                            $(svcNode).addClass('row');

                            let svcName = document.createElement('span');
                            $(svcName).css('font-size', '14px');
                            $(svcName).css('font-weight', 500);
                            $(svcName).css('padding', '7px 15px 2px 0px');
                            $(svcName).addClass('col-xs-9');

                            //$(svcName).addClass('svc-name');
                            $(svcName).html(svc.displayName);
                            svcNode.append(svcName);

                            let svcStatus = document.createElement('span');
                            $(svcStatus).css('font-size', '14px');
                            $(svcStatus).css('font-weight', 500);
                            $(svcStatus).css('padding', '7px 15px 2px 0px');
                            $(svcStatus).addClass('col-xs-3')
                            switch (svc.status.toLowerCase()) {
                                case 'running':
                                    $(svcStatus).css('color', 'green');
                                    break;
                                case 'stopped':
                                case 'disabled':
                                    $(svcStatus).css('color', 'red');
                                    break;
                                default:
                                    $(svcStatus).css('color', '#f8c30a');
                            }
                            $(svcStatus).html(svc.status);
                            svcNode.append(svcStatus);

                            svcWrapper.append(svcNode);
                        }
                    }
                    else {
                        alert(msg.d);
                    }
                },
                error: function (errorMessage) {
                    alert(errorMessage);
                },
                complete: function (jqXHR, textStatus) {
                    setTimeout(function () { $('.page-loader-wrapper').hide(); }, 30);
                }
            });

            event.preventDefault();

        }

    </script>
</asp:Content>

