@model IEnumerable<Alpha.Coordinador.Interfaces.Models.VmFile>
@using System.Text;
@using Alpha.UtilidadesMariano.GeneralLIb.Util;
@{
    ViewBag.Title = "Archivos";
    Layout = "";
}
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/bootstrap")
<style>
    body {
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        text-align: center;
        padding-left: 50px;
        padding-right: 50px;
        padding-top: 0px;
    }

    #files {
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        border-collapse: collapse;
        width: 100%;
    }

    #files td, #files th {
        border: 1px solid #808080;
        padding: 8px;
    }

    #files tr:nth-child(even) {
        background-color: #f2f2f2;
    }

    #files tr:hover {
        background-color: #ddd;
    }

    #files th {
        padding-top: 12px;
        padding-bottom: 12px;
        text-align: left;
        background: linear-gradient(to bottom, #eae0c2 5%, #ccc2a6 100%);
        background-color: #4CAF50;
        color: black;
    }

    .table {
        border-radius: 10px;
    }

    br {
        outline: 1px solid black;
    }
</style>
<h2 id="title">Subir/bajar archivos.</h2>

<h3 id="uploadTitle">
    @Html.ActionLink("Agregar archivo", "UploadFiles", new { Ip = ViewBag.Ip, Inner = ViewBag.Inner, Token = ViewBag.Token })
</h3>
<br />
@{ 

}
<table class="table" id="files">
    <tr>
        <th>
            Nombre
        </th>
        <th style="text-align:right; padding-right:35px;">Acciones</th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.FileName)
            </td>
            <td style="text-align:right">
                @Html.ActionLink("Descargar", "Download", new { Ip = ViewBag.Ip, FileName = item.FileName, Inner = ViewBag.Inner, Token = ViewBag.Token }, new { @onclick = "delayedReload();" }) |
                @Html.ActionLink("Borrar", "Delete", new { Ip = ViewBag.Ip, FileName = item.FileName, Inner = ViewBag.Inner, Token = ViewBag.Token })
            </td>
        </tr>
    }
</table>
<script>
    function delayedReload(delay = 5000) {
        setTimeout(() => location.reload(), delay);
    }
    document.addEventListener('contextmenu', event => event.preventDefault());
    var domReady = function (callback) {
        document.readyState === "interactive" || document.readyState === "complete" ? callback() : document.addEventListener("DOMContentLoaded", callback);
    };
    domReady(() => {
            @if(ViewBag.Ip == null)
            {
                @:document.getElementById('uploadTitle').style.display = 'none';
                @:document.getElementById('files').style.display = 'none';
                @:document.getElementById('title').innerText = 'Error';
            }
    });
</script>