﻿@{
    Layout = null;
}

@inherits System.Web.Mvc.WebViewPage<Frontend.Models.ResultModel>

<!DOCTYPE html>

<html>
<head>
    <link rel="stylesheet" type="text/css" href="css/Form.css" />  
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="refresh" content="5">
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />
    <title>FetchClimate2 Request results</title>
</head>
<body>
    @for(int i = 0, index = 0;i<Model.Regions.Length;i++) 
    {
        <p>Request
            @Html.Raw(String.Concat("for ", Model.Regions[i].IsPointSet ? "scattered points" : String.Format("grid #{0}", ++index)))
            @switch(Model.Regions[i].Status) 
            {
                case Frontend.Models.RegionResultStatus.Pending:
                    @Html.Raw(String.Format("is in queue with {0} before", Model.Regions[i].Parameter));
                    break;
                case Frontend.Models.RegionResultStatus.InProgress:
                    @Html.Raw(String.Format("is {0}% complete", Model.Regions[i].Parameter));
                    break;
                case Frontend.Models.RegionResultStatus.Succeeded:
                    @Html.Raw("completed. Download the data");
                    <a href="merge?r=@Model.Regions[i].Parameter&file=@(Model.Regions[i].IsPointSet ? "points.csv" : String.Format("grid{0}.csv", index))">here</a>
                    break;
                case Frontend.Models.RegionResultStatus.PartiallySucceeded:
                    @Html.Raw("completed with errors. Download part of the data");
                    <a href="merge?r=@Model.Regions[i].Parameter&file=@(Model.Regions[i].IsPointSet ? "points.csv" : String.Format("grid{0}.csv", index))">here</a>
                    break;
                case Frontend.Models.RegionResultStatus.Failed:
                    @Html.Raw("failed");
                    break;                    
            }
        </p>
    }
    @if (!Model.IsFinished) { 
        <p>Please wait... Page will refresh automatically</p>
    }
</body>
</html>
