Chart Viewer now complete

This commit is contained in:
Luke Else 2022-02-15 16:03:46 +00:00
parent 39cc7caef7
commit 8ac4a3d693
3 changed files with 103 additions and 46 deletions

View File

@ -52,14 +52,20 @@ namespace EFB.Controllers
return View(); return View();
} }
public IActionResult ViewCharts(Chart chart){ public IActionResult ViewCharts(string chart){
ChartModel charts = HttpContext.Session.GetObject<UserModel>("User").CurrentCharts; UserModel user = HttpContext.Session.GetObject<UserModel>("User");
if (user != null)
{
ViewChartModel charts = new ViewChartModel(user.CurrentCharts, chart);
if (charts != null) if (charts != null)
{ {
return View("ViewCharts", charts); return View("ViewCharts", charts);
} }
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return RedirectToAction("Index", "Home");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() public IActionResult Error()

28
Models/ViewChartModel.cs Normal file
View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Razor;
using Newtonsoft.Json;
using EFB.Models.JSON;
using Microsoft.AspNetCore;
using EFB.Sessions;
namespace EFB.Models
{
public class ViewChartModel
{
public ChartModel Charts { get; set; }
public Chart Selected { get; set; }
public ViewChartModel(ChartModel current, string selected){
Charts = current;
if (selected != null)
{
Selected = JsonConvert.DeserializeObject<Chart>(selected);
}
}
}
}

View File

@ -1,4 +1,5 @@
@model EFB.Models.ChartModel; @using Newtonsoft.Json;
@model EFB.Models.ViewChartModel;
@{ @{
ViewData["Title"] = "Welcome"; ViewData["Title"] = "Welcome";
} }
@ -27,53 +28,75 @@
} }
</form> </form>
<h4>Charts for: @Model.ICAO</h4>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle bg-dark" type="button" data-toggle="dropdown">Dropdown Example
<span class="caret"></span></button>
<ul class="dropdown-menu">
@{ @{
foreach (var item in Model.Approach)
{
<li><button class="bg-dark" runat="server" onclick=""></button></li>
}
}
</ul>
</div>
</div>
</div>
<div class="card-body col-md-8">
<div class="container jumbotron">
<h3>Chart Lookup</h3>
<br /> <br />
<br /> <h4>Charts for: @Model.Charts.ICAO</h4>
<form asp-controller="Charts" asp-action="Index"> <form asp-action="ViewCharts" method="post">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" placeholder="ICAO Code" name="ICAO" value="@TempData["ICAO"]"> <label>Select Charts</label><br />
</div> <select name="chart" class="form-control">
<button type="submit" class="btn btn-secondary">Search</button>
@{ @if (Model.Charts != null) {
if (TempData["Error"] != null) <option value=""></option>
{//If an error has been flagged, information will be displayed to the user foreach(var item in Model.Charts.GroundLayout) {
var itemString = JsonConvert.SerializeObject(item);
<br /> <option value="@itemString">@item.Name</option>
<br />
<div class="alert alert-danger">
<strong>Warning!</strong> @TempData["Error"] <button type='button' class='close' data-dismiss='alert' aria-hidden='true' />&times;
</div>
} }
<option value=""></option>
foreach(var item in Model.Charts.SID) {
var itemString = JsonConvert.SerializeObject(item);
<option value="@itemString">@item.Name</option>
} }
<option value=""></option>
foreach(var item in Model.Charts.STAR) {
var itemString = JsonConvert.SerializeObject(item);
<option value="@itemString">@item.Name</option>
}
<option value=""></option>
foreach(var item in Model.Charts.Approach) {
var itemString = JsonConvert.SerializeObject(item);
<option value="@itemString">@item.Name</option>
}
<option value=""></option>
foreach(var item in Model.Charts.TextualData) {
var itemString = JsonConvert.SerializeObject(item);
<option value="@itemString">@item.Name</option>
}
}
</select>
<button type="submit" class="btn btn-primary">View</button>
</div>
</form> </form>
</div> }
</div> </div>
</div> </div>
<div class="card-body col-md-8 vh-80">
<div class="container jumbotron vh-100">
@{
if (Model.Selected != null)
{
<h3>@Model.Selected.Name</h3>
<br />
<br />
<iframe src="@Model.Selected.URL" width="100%" height="90%"></iframe>
}
}
</div>
</div>
</div>