@using GreenTree.Nachtragsmanagement.Web.Models.Global;

@{
    Layout = "~/Views/Shared/_FunctionLayout.cshtml";
}

@{ 
	var userContext = GreenTree.Nachtragsmanagement.Core.CommonHelper.UserContext();
}

@model GreenTree.Nachtragsmanagement.Web.Models.Admin.AppInfo.AppInfoDataModel

<script>

	function checkUpdate() {
		devLoadingPanelUpdate.Show();
		$.ajax({
			url: '@Url.Action("PartialCheckUpdate", "Admin")',
			success: function (response) {
				if (!response) return;
				setTimeout(function () {
					devLoadingPanelUpdate.Hide();
					$(".updateContainer").remove();
					$("body").append(response);
				}, 200);
			},
			error: function () {
				devLoadingPanelUpdate.Hide();
				alert("error occured");
			}
		});
	}

</script>

<img src="@Url.Content("~/Content/Images/appInfo.png")" style="width: 90%; margin: 38px 5%" />

<table style="margin: 0 5%; width: 90%">
	<tbody>
		<tr>
			<td style="width: 49%">
				<div style="margin-bottom: 6px; vertical-align: top">
					<b>Verwendete Bibliotheken</b>
				</div>
				@Html.DevExpress().ListBox(t =>
				{
					t.Name = "devListBoxAssemblies";
					t.Width = new Unit(100, UnitType.Percentage);
					t.Height = new Unit(260, UnitType.Pixel);
					t.Properties.Columns.Add("Manufacturer", "Hersteller", new Unit(75, UnitType.Percentage));
					t.Properties.Columns.Add("Name", "Bibliothek", new Unit(75, UnitType.Percentage));
					t.Properties.Columns.Add("Version", "Version", new Unit(25, UnitType.Percentage));
				}).BindList(Model.Assemblies).GetHtml()
			</td>
			<td style="width: 51%; padding-left: 18px; vertical-align: top">
				<div style="padding-bottom: 3px; margin-bottom: 3px; vertical-align: top; border-bottom: 1px solid #009688">
					<b>Sonstige Informationen</b>
				</div>
				<ul>
					<li>
						Basisverzeichnis: <i>@Model.BaseDirectory</i>
					</li>
					<li>
						ASP.NET Info: <i>v<span>@Model.AspNetVersion</span></i>
					</li>
					<li>
						Betriebssystem: <i>@Model.OperatingSystem (@(Model.Is64BitOs ? "64Bit" : "32Bit"))</i>
					</li>
				</ul>
				<div style="width: 90%; margin: 0 5%; text-align: center">
					<h3 style="color: #009688">
						Aktuelle Programmpaketversion
					</h3>
					<div style="font-size: 40px; margin: 12px 0">
						v<span>@GreenTree.Nachtragsmanagement.Core.AppendixVersion.CurrentVersion</span>
					</div>
					@if (userContext.CurrentUser.HasFunction("Administration-AppInfo-Update"))
					{
						Html.DevExpress().Button(t =>
						{
							t.Name = "devButtonUpdate";
							t.Text = "Auf Update prüfen";
							t.ClientSideEvents.Click = "function (s, e) { checkUpdate(); }";
						}).GetHtml();
					}
					@if (Model.IsUpdate)
					{
						<div style="margin-top: 12px; color: green; font-size: 28px">
							Update erfolgreich!
						</div>
					}
				</div>
			</td>
		</tr>
	</tbody>
</table>

@Html.DevExpress().LoadingPanel(t =>
{
	t.Name = "devLoadingPanelUpdate";
	t.Text = "Es wird nach Updates geprüft... bitte warten!";
	t.Modal = true;
	t.Styles.LoadingDiv.Opacity = 0;
}).GetHtml()