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,13 +52,19 @@ 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 (charts != null) if (user != null)
{ {
return View("ViewCharts", charts); ViewChartModel charts = new ViewChartModel(user.CurrentCharts, chart);
if (charts != null)
{
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)]

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"> <br />
<button class="btn btn-primary dropdown-toggle bg-dark" type="button" data-toggle="dropdown">Dropdown Example <h4>Charts for: @Model.Charts.ICAO</h4>
<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>
} <form asp-action="ViewCharts" method="post">
} <div class="form-group">
</ul> <label>Select Charts</label><br />
</div> <select name="chart" class="form-control">
@if (Model.Charts != null) {
<option value=""></option>
foreach(var item in Model.Charts.GroundLayout) {
var itemString = JsonConvert.SerializeObject(item);
<option value="@itemString">@item.Name</option>
}
<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>
}
</div> </div>
</div> </div>
<div class="card-body col-md-8"> <div class="card-body col-md-8 vh-80">
<div class="container jumbotron"> <div class="container jumbotron vh-100">
<h3>Chart Lookup</h3> @{
if (Model.Selected != null)
{
<h3>@Model.Selected.Name</h3>
<br /> <br />
<br /> <br />
<form asp-controller="Charts" asp-action="Index"> <iframe src="@Model.Selected.URL" width="100%" height="90%"></iframe>
<div class="form-group">
<input type="text" class="form-control" placeholder="ICAO Code" name="ICAO" value="@TempData["ICAO"]">
</div>
<button type="submit" class="btn btn-secondary">Search</button>
@{
if (TempData["Error"] != null)
{//If an error has been flagged, information will be displayed to the user
<br />
<br />
<div class="alert alert-danger">
<strong>Warning!</strong> @TempData["Error"] <button type='button' class='close' data-dismiss='alert' aria-hidden='true' />&times;
</div>
}
} }
</form> }
</div> </div>
</div> </div>
</div> </div>