@using Zap.BI.Portal.Helpers
@using Zap.BI.Portal.Pages.Diagnostics
@using Zap.Text
@model Zap.BI.Portal.Models.TroubleshootViewModel

@{
    Layout = null;
}

@helper HeadingText()
{
    if (@Model.Heading.IsNotEmpty())
    {
        <span>@Model.Heading</span>
    }
    else if (@Model.HttpErrorCode > 0 && @Model.HttpErrorCode != 500)
    {
        <span>@Model.HttpErrorCode</span>
    }
    else
    {
        <span>Oops</span>
    }
}

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=100" />
        <meta charset="utf-8" />
        <title>@DiagnosticText.Troubleshoot_aspx_Label_Heading</title>
        <script src="@Url.Action("Script", "JavaScript", new { id = "Zap.Web.Core.Scripts.jquery.js" })" type="text/javascript"></script>
        <style type="text/css">
            html, body
            {
                margin: 0px;
                padding: 0px;
            }

            .LoadingSplashContainer
            {
                padding: 0;
                margin: 0;
                position: absolute;
                z-index: 65535;
                width: 100%;
            }

            .LoadingSplashContent
            {
                margin: 0 auto;
                font-family: "Segoe UI", Verdana, Helvetica, Arial, sans-serif;
                font-size: 14px;
            }

            .headingTable
            {
                text-align: center;
                font-size: 13pt;
                font-weight: bold;
                color: black;
            }

            .messageText
            {
                font-size: 14pt;
                color: #666666;
                padding-top: 20px;
            }

            .light
            {
                color: #777777
            }

            .button
            {
                display: inline-block;
                height: 40px;
                width: 140px;
                cursor: default;
                font-family: "Segoe UI", Verdana, Helvetica, Arial, sans-serif;
                font-size: 16px;
                color: #FFFFFF;
                background: #5585b4;
                border: 1px solid hsl(209.7, 38.8%, 56%);
            }

            .button:hover
            {
                background: hsl(209.7, 38.8%, 60%);
            }

            .imageSize
            {
                width: 150px;
                height: 150px;
            }

            .details
            {
                padding-left: 70px;
            }

            svg path{ fill: #444444 !important}

            a {
                font-weight: bold;
                color: #444444;
            }

            a:hover, a:visited, a:link, a:active
            {
                text-decoration: none;
            }

        </style>
        <script>
            window.addEventListener('load', function () {
                var retryForm = document.getElementById('retryForm');
                var retryButton = document.getElementById('retryButton');

                if (retryForm != null && retryButton != null) {
                    retryForm.addEventListener('submit', function () {
                        retryButton.disabled = true;
                    });
                }
            });
        </script>
    </head>
    <body>
        <div class="LoadingSplashContainer">
            <div class="LoadingSplashContent">
                <div style="text-align: center; margin-top: 100px">
                    <div style="padding-bottom: 50px;">
                        <img id="TitleIcon" class="imageSize" src="@Model.HeadingImage">
                    </div>
                    <div style="font-size: 3em">
                         @HeadingText()
                    </div>
                    <div class="messageText light">
                        @if (@Model.Message.IsNotEmpty())
                        {
                            <span>@HtmlSanitizer.Sanitize(Model.Message)</span>
                        }
                    </div>
                    <div class="messageText">
                        <span>
                            @if (!@Model.HideInvestigationMessage)
                            {
                                @DiagnosticText.Troubleshoot_aspx_Label_Message<br/>
                            }
                            @if (!Model.HideGoBackMessage)
                            {
                                <a href="javascript:history.back()">@DiagnosticText.Troubleshoot_aspx_Label_GoBackMessage</a>
                            }
                        </span>
                    </div>
                    
                    @if (@Model.ShowRetryButton)
                    {
                        <div style="text-align: center; padding: 20px;">
                            <form id="retryForm" method="post" action="@Url.Action("Retry", "Error")">
                                <input type="hidden" name="originalUrl" value="@(Model.RetryUrl ?? Request.RawUrl)" />
                                <input id="retryButton" type="submit" class="button" value="@DiagnosticText.Troubleshoot_aspx_ButtonLabel_Retry" />
                            </form>
                        </div>
                    }
                    
                </div>
            </div>
        </div>
    </body>
</html>