From 6b71adab4dfd31608a209a9b78d4c2e1bcebbab0 Mon Sep 17 00:00:00 2001 From: Thomas Hounsell Date: Sun, 4 Jan 2015 17:31:27 +0000 Subject: [PATCH] Minor display changes, more meta groundwork Also page size increased from 15 to 20. --- BuildFeed.csproj | 3 +- Controllers/buildController.cs | 2 +- Models/{LabMeta.cs => MetaItem.cs} | 52 ++++++----- Views/build/info.cshtml | 25 ++++-- Views/build/lab.cshtml | 140 ----------------------------- content/style.css | 24 ++++- 6 files changed, 76 insertions(+), 170 deletions(-) rename Models/{LabMeta.cs => MetaItem.cs} (69%) delete mode 100644 Views/build/lab.cshtml diff --git a/BuildFeed.csproj b/BuildFeed.csproj index be5e5df..854d424 100644 --- a/BuildFeed.csproj +++ b/BuildFeed.csproj @@ -196,7 +196,7 @@ - + @@ -293,7 +293,6 @@ - diff --git a/Controllers/buildController.cs b/Controllers/buildController.cs index 4ab368c..5b533c4 100644 --- a/Controllers/buildController.cs +++ b/Controllers/buildController.cs @@ -7,7 +7,7 @@ namespace BuildFeed.Controllers { public class buildController : Controller { - public static int pageSize { get { return 15; } } + public static int pageSize { get { return 20; } } // // GET: /build/ diff --git a/Models/LabMeta.cs b/Models/MetaItem.cs similarity index 69% rename from Models/LabMeta.cs rename to Models/MetaItem.cs index 7e290ad..98bf835 100644 --- a/Models/LabMeta.cs +++ b/Models/MetaItem.cs @@ -1,25 +1,22 @@ -using BuildFeed; -using NServiceKit.DataAnnotations; +using NServiceKit.DataAnnotations; using NServiceKit.DesignPatterns.Model; using NServiceKit.Redis; -using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; -using System.Web; using System.Web.Mvc; using Required = System.ComponentModel.DataAnnotations.RequiredAttribute; namespace BuildFeed.Models { [DataObject] - public class LabMeta : IHasId + public class MetaItem : IHasId { [Key] [Index] [@Required] - public string Id { get; set; } + public MetaItemKey Id { get; set; } [DisplayName("Page Content")] [AllowHtml] @@ -31,21 +28,21 @@ public class LabMeta : IHasId [DataObjectMethod(DataObjectMethodType.Select, true)] - public static IEnumerable Select() + public static IEnumerable Select() { using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database)) { - var client = rClient.As(); + var client = rClient.As(); return client.GetAll(); } } [DataObjectMethod(DataObjectMethodType.Select, false)] - public static LabMeta SelectById(string id) + public static MetaItem SelectById(MetaItemKey id) { using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database)) { - var client = rClient.As(); + var client = rClient.As(); return client.GetById(id); } } @@ -56,43 +53,45 @@ public static IEnumerable SelectUnusedLabs() using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database)) { - var client = rClient.As(); + var client = rClient.As(); var labs = Build.SelectBuildLabs(); - var usedLabs = client.GetAll(); + var usedLabs = from u in client.GetAll() + where u.Id.Type == MetaType.Lab + select u; return from l in labs - where !usedLabs.Any(ul => ul.Id == l) + where !usedLabs.Any(ul => ul.Id.Value as string == l) select l; } } [DataObjectMethod(DataObjectMethodType.Insert, true)] - public static void Insert(LabMeta item) + public static void Insert(MetaItem item) { using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database)) { - var client = rClient.As(); + var client = rClient.As(); client.Store(item); } } [DataObjectMethod(DataObjectMethodType.Update, true)] - public static void Update(LabMeta item) + public static void Update(MetaItem item) { using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database)) { - var client = rClient.As(); + var client = rClient.As(); client.Store(item); } } [DataObjectMethod(DataObjectMethodType.Insert, false)] - public static void InsertAll(IEnumerable items) + public static void InsertAll(IEnumerable items) { using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database)) { - var client = rClient.As(); + var client = rClient.As(); client.StoreAll(items); } } @@ -102,9 +101,22 @@ public static void DeleteById(long id) { using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database)) { - var client = rClient.As(); + var client = rClient.As(); client.DeleteById(id); } } } + + public struct MetaItemKey + { + public object Value { get; set; } + public MetaType Type { get; set; } + } + + public enum MetaType + { + Lab, + Version, + Source + } } \ No newline at end of file diff --git a/Views/build/info.cshtml b/Views/build/info.cshtml index 96d10a9..378518f 100644 --- a/Views/build/info.cshtml +++ b/Views/build/info.cshtml @@ -6,12 +6,12 @@ @section head { - + - + } @@ -65,21 +65,34 @@
@Html.LabelFor(model => model.Lab, new { @class = "control-label col-sm-2" })
-

@Html.ActionLink(Model.Lab, "lab", new { lab = Model.Lab })

+

+ @Model.Lab
+ Find more builds from @Model.Lab +

@Html.LabelFor(model => model.BuildTime, new { @class = "control-label col-sm-2" })
-

@Html.DisplayFor(model => model.BuildTime, "{0:yyMMdd-HHmm}")

+

+ @Html.DisplayFor(model => model.BuildTime, "{0:yyMMdd-HHmm}") + @if (Model.BuildTime.HasValue) + { +
+ Find more builds compiled in @Model.BuildTime.Value.Year + } +

@Html.LabelFor(model => model.SourceType, new { @class = "control-label col-sm-2" })
-

@Html.DisplayFor(model => model.SourceType, "Enumeration")

+

+ @Html.DisplayFor(model => model.SourceType, "Enumeration")
+ Find more builds sourced from @Html.DisplayFor(model => model.SourceType, "Enumeration") +

@@ -90,7 +103,7 @@ - @if ( (Model.MajorVersion == 6 && Model.MinorVersion == 4) || (Model.MajorVersion == 10 && Model.MinorVersion == 0) && Model.FlightLevel != BuildFeed.Models.LevelOfFlight.None) + @if ((Model.MajorVersion == 6 && Model.MinorVersion == 4) || (Model.MajorVersion == 10 && Model.MinorVersion == 0) && Model.FlightLevel != BuildFeed.Models.LevelOfFlight.None) {
@Html.LabelFor(model => model.FlightLevel, new { @class = "control-label col-sm-2" }) diff --git a/Views/build/lab.cshtml b/Views/build/lab.cshtml deleted file mode 100644 index b32fe3d..0000000 --- a/Views/build/lab.cshtml +++ /dev/null @@ -1,140 +0,0 @@ -@model IEnumerable - -@{ - ViewBag.Title = "BuildFeed"; - - - if (ViewBag.PageNumber > 1) - { - ViewBag.Title = string.Format("Page {1} | {0}", ViewBag.Title, ViewBag.PageNumber); - } - - ViewBag.ItemId = ViewContext.Controller.ValueProvider.GetValue("lab").RawValue; - ViewBag.Title = string.Format("Builds from {1} | {0}", ViewBag.Title, ViewBag.ItemId); -} - -@section head -{ - - -} - -
-
-
    - @foreach (var item in Model) - { -
  • -
    - @Html.ActionLink("Info", "info", new { id = item.Id }, new { @class = "btn btn-info btn-xs" }) - @if (User.Identity.IsAuthenticated) - { - @Html.ActionLink("Edit", "edit", new { id = item.Id }, new { @class = "btn btn-default btn-xs" }) - } - @if (Roles.IsUserInRole("Administrators")) - { - @Html.ActionLink("Delete", "delete", new { id = item.Id }, new { @class = "btn btn-danger btn-xs" }) - } -

    @Html.DisplayFor(modelItem => item.FullBuildString)

    -
    -
    - @Html.DisplayFor(TypeOfSource => item.SourceType, "Enumeration") - @if (item.FlightLevel != BuildFeed.Models.LevelOfFlight.None) - { - Flight Level: @Html.DisplayFor(TypeOfSource => item.FlightLevel, "Enumeration") - } - @if (item.BetaWikiUri != null) - { - BetaWiki (Client) - } - @if (item.BetaWikiServerUri != null) - { - BetaWiki (Server) - } - @if (item.WinWorldPCUri != null) - { - WinWorldPC - } - @if (item.BetaArchiveUri != null) - { - BetaArchive Wiki - } - @if (item.LonghornMsUri != null) - { - Longhorn.ms - } -
    -
  • - } -
-
-
- -
- @Html.ActionLink("Return to full listing", "index", new { controller = "build", area = "", page = 1 }, new { @class = "list-group-item" }) -
-
- @if (User.Identity.IsAuthenticated) - { - if (Roles.IsUserInRole("Administrators")) - { - @Html.ActionLink("Administration", "index", new { controller = "base", area = "admin" }, new { @class = "list-group-item" }) - } - @Html.ActionLink("Add a build", "create", new { controller = "build" }, new { @class = "list-group-item" }) - @Html.ActionLink("Change your password", "password", new { controller = "support" }, new { @class = "list-group-item" }) - @Html.ActionLink("Log out", "logout", new { controller = "support" }, new { @class = "list-group-item" }) - } - else - { - @Html.ActionLink("Log in", "login", new { controller = "support" }, new { @class = "list-group-item" }) - @Html.ActionLink("Register", "register", new { controller = "support" }, new { @class = "list-group-item" }) - } -
-
-
- -@if (ViewBag.PageCount > 1) -{ -
    - @if (ViewBag.PageNumber > 1) - { -
  • @Html.ActionLink(HttpUtility.HtmlDecode("«"), ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(), new { page = ViewBag.PageNumber - 1 })
  • - } - else - { -
  • «
  • - } - - - @for (int i = 1; i <= ViewBag.PageCount; i++) - { -
  • @Html.ActionLink(i.ToString(), ViewBag.Action as string, new { page = i })
  • - } - - - @if (ViewBag.PageNumber < ViewBag.PageCount) - { -
  • @Html.ActionLink(HttpUtility.HtmlDecode("»"), ViewBag.Action as string, new { page = ViewBag.PageNumber + 1 })
  • - } - else - { -
  • »
  • - } -
-} - -@section scripts -{ - @Scripts.Render("~/bundles/jsrender") - - -} \ No newline at end of file diff --git a/content/style.css b/content/style.css index fcac347..fe6c1b7 100644 --- a/content/style.css +++ b/content/style.css @@ -73,6 +73,28 @@ li:last-child .build-foot margin-right: 0.12em; } +.more-link +{ + display: inline-block; + font-size: 13px; + vertical-align: 1px; + border-bottom: 1px dashed #41c0e5; + color: #31b0d5; +} + + .more-link .fa-sm + { + font-size: 11px; + vertical-align: 0px; + } + + .more-link:hover + { + color: #30829e; + border-bottom-color: #50a2be; + text-decoration: none; + } + .field-validation-error { color: #ff4136; @@ -151,4 +173,4 @@ label, .control-label, .help-block, .checkbox, .radio { margin: 0; width: 100%; -} \ No newline at end of file +}