Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ugly ui mapping code to hunt down a null ref exception.
- Loading branch information
1 parent
0ff93aa
commit 2091f7a
Showing
9 changed files
with
155 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
DeployD/Deployd.Agent/WebUi/Converters/RunningTasksToPackageListViewModelConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Deployd.Agent.WebUi.Models; | ||
using Deployd.Core.Caching; | ||
using Deployd.Core.Installation; | ||
|
||
namespace Deployd.Agent.WebUi.Converters | ||
{ | ||
public static class RunningTasksToPackageListViewModelConverter | ||
{ | ||
public static PackageListViewModel Convert(INuGetPackageCache cache, RunningInstallationTaskList runningTasks, ICurrentInstalledCache installCache) | ||
{ | ||
var model = new PackageListViewModel(); | ||
|
||
foreach(var packageId in cache.AvailablePackages) | ||
{ | ||
var package = new LocalPackageInformation | ||
{ | ||
PackageId = packageId, | ||
LatestAvailableVersion = cache.GetLatestVersion(packageId).ToString() | ||
}; | ||
|
||
var installedPackage = installCache.GetCurrentInstalledVersion(packageId); | ||
package.InstalledVersion = installedPackage == null ? "" : installedPackage.ToString(); | ||
|
||
package.CurrentTask = runningTasks.Count > 0 ? runningTasks | ||
.Where(t => t.PackageId == packageId) | ||
.Select(t => | ||
{ | ||
var lastOrDefault = t.ProgressReports.LastOrDefault(); | ||
return lastOrDefault != null ? new InstallTaskViewModel | ||
{ | ||
Messages = t.ProgressReports.Select(pr => pr.Message).ToArray(), | ||
Status = Enum.GetName(typeof(TaskStatus), t.Task.Status), | ||
PackageId = t.PackageId, | ||
Version = t.Version, | ||
LastMessage = t.ProgressReports.Count > 0 ? lastOrDefault.Message : "" | ||
} : null; | ||
}).FirstOrDefault() | ||
: null; | ||
|
||
model.Packages.Add(package); | ||
} | ||
|
||
model.CurrentTasks = runningTasks | ||
.Select(t => | ||
{ | ||
var progressReport = t.ProgressReports.LastOrDefault(); | ||
return progressReport != null | ||
? new InstallTaskViewModel | ||
{ | ||
Messages = t.ProgressReports.Select(pr => pr.Message).ToArray(), | ||
Status = Enum.GetName(typeof (TaskStatus), t.Task.Status), | ||
PackageId = t.PackageId, | ||
Version = t.Version, | ||
LastMessage = | ||
t.ProgressReports.Count > 0 ? progressReport.Message : "" | ||
} | ||
: null; | ||
}).ToList(); | ||
|
||
|
||
model.AvailableVersions = | ||
cache.AllCachedPackages().Select(p => p.Version.ToString()).Distinct().OrderByDescending(s => s); | ||
|
||
return model; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Deployd.Agent</title> | ||
</head> | ||
<body> | ||
<h1>Deployd.Agent</h1> | ||
|
||
<a href="/packages">Packages</a> | ||
|
||
</body> | ||
</html> | ||
@{ | ||
Layout = "layout.cshtml"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Deployd.Agent</title> | ||
<meta http-equiv="refresh" content="3"> | ||
</head> | ||
<body> | ||
<h1>Deployd.Agent - @Environment.MachineName</h1> | ||
|
||
<ul> | ||
<li><a href="/packages">Packages</a></li> | ||
<li><a href="/installations">Installations</a></li> | ||
</ul> | ||
@{ | ||
Layout = "layout.cshtml"; | ||
} | ||
|
||
<h2>Task Queue</h2> | ||
|
||
@foreach (var task in Model.TaskQueue) | ||
{ | ||
<p>@task.PackageId @task.Version</p> | ||
} | ||
|
||
<h2>Running Tasks</h2> | ||
<h2>Task Queue</h2> | ||
|
||
@foreach (var task in Model.RunningTasks) | ||
{ | ||
<p>@task.PackageId @task.Version @task.LastMessage</p> | ||
} | ||
</body> | ||
</html> | ||
@foreach (var task in Model.TaskQueue) | ||
{ | ||
<p>@task.PackageId @task.Version</p> | ||
} | ||
|
||
<h2>Running Tasks</h2> | ||
|
||
@foreach (var task in Model.RunningTasks) | ||
{ | ||
<p>@task.PackageId @task.Version @task.LastMessage</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Deployd.Agent</title> | ||
</head> | ||
<body> | ||
<h1>Deployd.Agent</h1> | ||
|
||
<form action="/packages/@Model.PackageName/install" method="POST"> | ||
<input type="submit" value="Install Latest"></input> | ||
</form> | ||
@{ | ||
Layout = "layout.cshtml"; | ||
} | ||
|
||
<h2>Available Package Versions for @Model.PackageName</h2> | ||
<form method="post" action="/packages/@Model.PackageName/install"> | ||
<input type="submit" value="Update to:"/> <select name="specificVersion"> | ||
@foreach(string version in Model.CachedVersions) | ||
{ | ||
<option>@version</option> | ||
} | ||
</select> | ||
</form> | ||
<form action="/packages/@Model.PackageName/install" method="POST"> | ||
<input type="submit" value="Install Latest"></input> | ||
</form> | ||
|
||
</body> | ||
</html> | ||
<h2>Available Package Versions for @Model.PackageName</h2> | ||
<form method="post" action="/packages/@Model.PackageName/install"> | ||
<input type="submit" value="Update to:"/> <select name="specificVersion"> | ||
@foreach(string version in Model.CachedVersions) | ||
{ | ||
<option>@version</option> | ||
} | ||
</select> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,46 @@ | ||
@using Deployd.Agent.WebUi.Models | ||
@{ | ||
Layout = "layout.cshtml"; | ||
} | ||
|
||
<h2>Available Packages</h2> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Deployd.Agent</title> | ||
</head> | ||
<body> | ||
<h1>Deployd.Agent - @Environment.MachineName</h1> | ||
|
||
<ul> | ||
<li><a href="/packages">Packages</a></li> | ||
<li><a href="/installations">Installations</a></li> | ||
</ul> | ||
<form method="post" action="/packages/UpdateAllTo"> | ||
<input type="submit" value="Update all to:"/> <select name="specificVersion"> | ||
@foreach(string version in Model.AvailableVersions) | ||
{ | ||
<option>@version</option> | ||
} | ||
</select> | ||
</form> | ||
|
||
<h2>Available Packages</h2> | ||
|
||
<form method="post" action="/packages/UpdateAllTo"> | ||
<input type="submit" value="Update all to:"/> <select name="specificVersion"> | ||
@foreach(string version in Model.AvailableVersions) | ||
{ | ||
<option>@version</option> | ||
} | ||
</select> | ||
</form> | ||
@foreach(LocalPackageInformation package in Model.Packages) | ||
{ | ||
<div style="clear:both"> | ||
<a href="/packages/@package.PackageId">@package.PackageId</a><div style="float:right;margin-right:80px"><form style="display:inline" action="/packages/@package.PackageId/install" method="POST"><input type="submit" value="Install Latest"></input></form></div><br/> | ||
@if (package.CurrentTask != null) | ||
{ | ||
<text>@package.CurrentTask.Status: @package.CurrentTask.LastMessage<br/></text> | ||
} | ||
|
||
@foreach(LocalPackageInformation package in Model.Packages) | ||
{ | ||
<div style="clear:both"> | ||
<a href="/packages/@package.PackageId">@package.PackageId</a><div style="float:right;margin-right:80px"><form style="display:inline" action="/packages/@package.PackageId/install" method="POST"><input type="submit" value="Install Latest"></input></form></div><br/> | ||
@if (package.CurrentTask != null) | ||
{ | ||
<text>@package.CurrentTask.Status: @package.CurrentTask.LastMessage<br/></text> | ||
} | ||
@if(!string.IsNullOrWhiteSpace(package.LatestAvailableVersion)) | ||
{ | ||
<text>Latest: @package.LatestAvailableVersion<br/></text> | ||
} | ||
@if (!string.IsNullOrWhiteSpace(package.InstalledVersion)) | ||
{ | ||
<text>Installed: @package.InstalledVersion</text> | ||
} | ||
else | ||
{ | ||
<text>Not installed</text> | ||
} | ||
<br/> | ||
</div> | ||
|
||
} | ||
|
||
@if(!string.IsNullOrWhiteSpace(package.LatestAvailableVersion)) | ||
{ | ||
<text>Latest: @package.LatestAvailableVersion<br/></text> | ||
} | ||
@if (!string.IsNullOrWhiteSpace(package.InstalledVersion)) | ||
{ | ||
<text>Installed: @package.InstalledVersion</text> | ||
} | ||
else | ||
{ | ||
<text>Not installed</text> | ||
} | ||
<br/> | ||
</div> | ||
|
||
} | ||
|
||
@foreach (InstallTaskViewModel task in Model.CurrentTasks) | ||
{ | ||
<p>@task.PackageId @task.Version @task.Status @task.LastMessage</p> | ||
} | ||
</body> | ||
</html> | ||
@foreach (InstallTaskViewModel task in Model.CurrentTasks) | ||
{ | ||
<p>@task.PackageId @task.Version @task.Status @task.LastMessage</p> | ||
} |