<%@ Page Language="C#" MasterPageFile="~/UGCCNG.Master" AutoEventWireup="true" CodeBehind="adminsrvdef.aspx.cs" Inherits="UGCC_Sharp.WebForm1" Title="Server Definitions" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="alert alert-info">
        Server definitions are the various nodes the panel manages.&nbsp; ID #1 is always reserved for the node of your first install of the web panel.
    </div>
    <div id="divSqliteWarn" runat="server"></div>
    <div class="form-horizontal">
        <div class="form-group">
            <label class="col-sm-2 control-label">
                Defined servers
            </label>
            <div class="col-sm-10">
                <asp:DropDownList ID="DropDownList1" runat="server" CssClass="form-control" AutoPostBack="True"
                    OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                </asp:DropDownList>
                <span class="help-block">Select a already setup server definition.&nbsp; To create a new server definition use the section at the bottom of the page.</span>
            </div>
        </div>
    </div>
    <div class="row">

        <ul class="nav nav-tabs nav-justified">
            <li id="liGeneral" runat="server" class="active">
                <asp:LinkButton ID="lnkGeneral" runat="server" OnClick="lnkGeneral_Click">General</asp:LinkButton></li>
            <li id="liRemote" runat="server">
                <asp:LinkButton ID="lnkRemote" runat="server" OnClick="lnkRemote_Click">Remote Settings</asp:LinkButton></li>
            <li id="liInstaller" runat="server">
                <asp:LinkButton ID="lnkInstaller" runat="server" OnClick="lnkInstaller_Click">Installer settings</asp:LinkButton></li>
        </ul>
    </div>
    <br />
    <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
        <asp:View ID="View1" runat="server">
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Server definition ID
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtID" runat="server" CssClass="form-control" ReadOnly="True" ToolTip="Server definitions ID needed for remote monitor"
                        BorderStyle="None"></asp:TextBox>
                    <span class="help-block">Server definition ID number for the selected server; this is needed for the remote monitor.&nbsp; Autogenerated and cannot be changed.&nbsp; This ID is used in the remote monitor&#39;s ugccmon.cfg.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Name/Description
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtName" runat="server" CssClass="form-control" ToolTip="This is what the server definition will be displayed as"></asp:TextBox>
                    <span class="help-block">This is what the server definition will be displayed as/referred
                    to as throughout the panel</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Locations
                </label>
                <div class="col-sm-10">
                    <asp:ListBox runat="server" ID="lstSdef" CssClass="form-control" SelectionMode="Multiple"></asp:ListBox>
                    <span class="help-block">Locations this server def is a member of (ctrl+click to multi-select)</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Platform
                </label>
                <div class="col-sm-10">
                    <asp:DropDownList ID="ddlPlatform" runat="server" CssClass="form-control" OnSelectedIndexChanged="ddlPlatform_SelectedIndexChanged">
                        <asp:ListItem Value="win">Windows</asp:ListItem>
                        <asp:ListItem Value="lin">Linux</asp:ListItem>
                    </asp:DropDownList>
                    <span class="help-block">Platform type of selected remote system.&nbsp; Ensure it&#39;s accurate.</span>
                </div>
            </div>
        </asp:View>
        <asp:View runat="server" ID="MultiViewRemote">
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Address
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtAddress" runat="server" CssClass="form-control" ToolTip="IP address or fully qualified domain name of remote monitor"></asp:TextBox>
                    <span class="help-block">IP address or FQDN of remote monitor.&nbsp; We recommend using
                    an IP address if feasible.&nbsp; Not needed for ID #1, unless multiple remote panels are in use.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Port
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtPort" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">Port the remote monitor is listening on.&nbsp; Not needed for ID #1, unless multiple remote panels are in use.</span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Shared secret
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtSecret" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">The password needed to communicate
                with the remote monitor.&nbsp; Not needed for ID #1, unless multiple remote panels are in use.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Timeout
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtTimeOut" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">Specify the maximum amount of time, in milliseconds, that the panel will wait for a connection acknowledgment from the remote monitor.&nbsp; If you see frequent timeouts in the main status menu or in the logs, increase this value.&nbsp; A sane value is 1000-2000.&nbsp; If it&#39;s a fast and physically close host you could go as low as 60.&nbsp; Not needed for ID #1, unless multiple remote panels are in use.&nbsp; This value will have a significant impact if panel is unable to connect to the monitor due to an outage as the remote command has to timeout before proceeding to the next, it&#39;s important to not set it to too high of a value.&nbsp; Use the test feture below to get an estimate of what to begin with.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Off line
                </label>
                <div class="col-sm-10">
                    <div class="checkbox-inline">
                        <asp:CheckBox ID="chkOffline" runat="server" />&nbsp;
                    </div>
                    <span class="help-block">If the defined server is off line, check this box to prevent
                the panel from querying this server.&nbsp; Otherwise it may take a while for any
                operations to complete on this server depending on the timeout value.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Test settings
                </label>
                <div class="col-sm-10">
                    <div class="input-group">
                        <span class="input-group-btn">
                            <asp:Button ID="btnTest" runat="server" CssClass="btn btn-default" OnClick="btnTest_Click"
                                Text="Test" />
                        </span>
                        <asp:Label ID="lblTest" runat="server" CssClass="form-control"></asp:Label>
                    </div>
                    <!-- /input-group -->

                    <span class="help-block">After saving your settings, you can check connectivity with
                the remote monitor here.  It will also report the Round Trip Time  (RTT).  This is the amount of time it took to complete a request.  This can be used to estimate a timeout value.  Make note of the highest RTT reported and set your timeout to a factor or 2-4 times the highest RTT observed</span>
                </div>
            </div>
        </asp:View>
        <asp:View runat="server" ID="MultiViewInstaller">
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Installer Settings
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtInstallLoc" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">Location where misc Installer Settings files are stored.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    File cache
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtFCache" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">Location where a copy of the game server install files, mods,
                etc are saved/located.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    New game server path
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtNewGSPath" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">For automated server installs; where should the panel create
                them?&nbsp; The installer will append &lt;user id&gt;/&lt;server id&gt; to this path for new servers.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    New game server path (Alt)
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtNewGSPathAlt" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">For automated server installs; an alternate location for creating servers.  Could be an SSD, separate drive, whatever.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Addresses
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtAddresses" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">For automated server installs; what are the usable IP addresses the panel can use.  If multiple IP addresses are available, separate them with commas.&nbsp; Never use FQDN, only IP addresses.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Allow new servers
                </label>
                <div class="col-sm-10">
                    <div class="checkbox-inline">
                        <asp:CheckBox ID="chkAllowNewGS" runat="server" />&nbsp;
                    </div>
                    <span class="help-block">This controls whether or not the automated installer will install
                new game servers on this server.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    Max servers
                </label>
                <div class="col-sm-10">
                    <asp:TextBox ID="txtMaxSrvrs" runat="server" CssClass="form-control"></asp:TextBox>
                    <span class="help-block">Don't use this definition for auto installs once this amount of servers are deployed on this definition.  0 is unlimited. </span>
                </div>
            </div>
        </asp:View>
    </asp:MultiView>
    </div>
    <br />
    <div id="lblError" runat="server"></div>

    <asp:Button ID="btnUpdate" runat="server" CssClass="btn btn-primary"
        OnClick="btnUpdate_Click" Text="Update" />
    &nbsp;<asp:Button ID="btnDel" runat="server" CssClass="btn btn-primary" OnClick="btnDel_Click"
        Text="Delete" />

    <hr />

    To create a new entry, enter the desired Name/Description below and click add.<br />
    <div class="input-group">
        <asp:TextBox ID="txtNew" runat="server" CssClass="form-control" placeholder="New definition's name"></asp:TextBox>
        <span class="input-group-btn">
            <asp:Button ID="btnNew" runat="server" CssClass="btn btn-default" Text="Add" OnClick="btnNew_Click" />
        </span>
    </div>
    <!-- /input-group -->

</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="head">
</asp:Content>

