 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Project.Master" Inherits="System.Web.Mvc.ViewPage<AdministratorConsole.Models.ProjectController.FileFiltersAdvancedViewModel>" %>

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
	<script language="javascript" type="text/javascript">
	    function displayNewFilterForm()
        {
	        var newFormContainer = document.getElementById("NewFormContainer");

	        if (newFormContainer != null) {
	            if (newFormContainer.style.display.trim().toLowerCase() == "none") newFormContainer.style.display = "block";
	            else newFormContainer.style.display = "none";
	        }
	    }

	    function showTestContainer() {
	        $("#FileFilterTestResults").css("display", "block");

	        i = 0; 
	        setInterval(function() { 
	            i = ++i % 6; 
	            $("#LoadingContainer").html("Loading" + Array(i + 1).join("."));
	        }, 500); 
	    }
	</script>
    <div id="banner-space">
        <div id="banner-detail-container">
            <div class="left-floating-panel">
	            <div id="project-title"><span><%= Html.Encode(Model.CurrentProject.Name) %></span><span id="project-number"><%= Html.Encode(Model.CurrentProject.Number) %></span></div>
                <div id="project-database-export"><b>Last Database Export:</b> <% if (Model.CurrentProject.LastDatabaseExport.HasValue)
                                                                                  { %><%= DateTimeHelper.ToString(Model.CurrentProject.LastDatabaseExport.Value) %><% } else { %>No Exports<% } %></div>
	        </div>
            <% if (Model.LicenseType != LicenseType.ODP)
               { %>
                <div class="right-floating-panel total-time-container-outer">
                    <div id="total-time-container">
				        <div class="header">Total Time Saved</div>
			            <div class="value"><%= (Math.Ceiling(Model.CurrentProject.CompletedTasksTime.TotalHours)).ToString("000") %> hrs</div>
                    </div>
                </div> 
            <% } %>
            <% Html.RenderPartial("Partials/LaunchableTasks", new LaunchableTasksModel(Model.CurrentProject, Model.TaskSchedules, Model.CurrentUser)); %>
            <div class="clear"></div>
        </div>
    </div>
    <div id="content-wrap">
        <% Html.RenderPartial("Navigation/_SideNavigation", Model.MenuNavigationModel); %>
	    <div id="content">
	        <h1>Manage File Filters</h1>
            <h2>File Filters</h2>
            <div id="tab-container">
                <ul class="tabs">
                    <li><a href="<%= Url.Action("FileFilters/" + Model.CurrentProject.ExternalId, "Project") %>">Browse</a></li>
                    <li><a href="<%= Url.Action("FileFiltersAdvanced/" + Model.CurrentProject.ExternalId, "Project") %>" class="active">Advanced</a></li>
                </ul>
            </div>
            <br />
            <div><%= Html.Encode("File Filters are rules used to specifically include or exclude files that Clarity will monitor and process with tasks. By default, all files are included, however, if you add Filters below, it will use them to decide which files will be visible and processed.  This is often used to exclude temporary working files and other \"non-official\" files from processing.") %></div>
            <br />
            <% if (Model.FileFilter != null) { %><% Html.RenderPartial("Partials/FileFilterAction", Model.GetFileFilterActionViewModel()); %><% } %>
            <div id="FileFilterGridViewContainer" class="reportPanel-scrollingbody">
                <table class="standard-list full" cellspacing="" cellpadding="">
                    <tr>
                        <th style="width:120px">&nbsp;</th>
                        <th>Filter</th>
                        <th style="text-align:right;padding-right:8px;"><%= Ajax.ActionLink("Add", "NewFileFilter", new { id = Model.CurrentProject.ExternalId }, new AjaxOptions { UpdateTargetId = "content", InsertionMode = InsertionMode.InsertBefore }) %></th>
                    </tr>
                    <% bool evenEntry = false; %>
                    <% foreach (FileFilter fileFilter in Model.CurrentProject.FileFilters)
                       { %>
                        <tr <% if (evenEntry) { %>class="even"<% evenEntry = false; %><% } else { %>class="odd"<% evenEntry = true; %><% } %>>
                            <td>
                                <table>
                                    <tr>
                                        <td style="padding-right:3px;"><%= Ajax.ActionLink("Edit", "EditFileFilter", new { projectId = Model.CurrentProject.ExternalId, filterId = fileFilter.ExternalId }, new AjaxOptions { UpdateTargetId = "content", InsertionMode = InsertionMode.InsertBefore }) %></td>
                                        <td><%= Html.ActionLink("Delete", "DeleteFileFilter/" + Model.CurrentProject.ExternalId + "/" + fileFilter.ExternalId, "Project") %></td>
                                    </tr>
                                </table>
                            </td>
                            <td colspan="2"><%= Html.Encode(fileFilter.FilterReadable) %></td>
                        </tr>
                    <% } %>
                </table>
            </div>
            <br />
            <table width="100%">
                <tr>
                    <td><% using (Ajax.BeginForm("LoadFileFilterTestResults", new { projectId = Model.CurrentProject.ExternalId }, new AjaxOptions { UpdateTargetId = "FileFilterTestResults", InsertionMode = InsertionMode.Replace, OnBegin = "showTestContainer()" }))
                                                        { %><input type="submit" value="Test Filters" class="button" /><% } %></td>
                </tr>
            </table>
            <br />
            <div id="FileFilterTestResults" style="display:none"><div id="LoadingContainer" class="loadingContainer">Loading</div></div>
	    </div>
    </div>
</asp:Content>
