From 302a9cc690387fb242c11865fae9eb2b8e2ed24d Mon Sep 17 00:00:00 2001 From: Thomas Hounsell Date: Tue, 22 Sep 2015 14:34:52 +0100 Subject: [PATCH] Language Override; RTL styling; Migration tooling --- BuildFeed/Scripts/bfs.js | 58 +++++++++++-------- BuildFeed/Views/shared/_default.cshtml | 35 ++++++++++-- BuildFeed/content/rtl.css | 39 ++++++++++++- RedisMongoMigration/Program.cs | 72 +++++++++++++++++------- RedisMongoMigration/Redis/RedisMember.cs | 54 +++++++++++------- RedisMongoMigration/Redis/RedisRole.cs | 13 ++++- 6 files changed, 199 insertions(+), 72 deletions(-) diff --git a/BuildFeed/Scripts/bfs.js b/BuildFeed/Scripts/bfs.js index 5d918c5..26965f4 100644 --- a/BuildFeed/Scripts/bfs.js +++ b/BuildFeed/Scripts/bfs.js @@ -2,36 +2,44 @@ var bfsTimeout; $(function () { - $("#page-navigation-search").click(function (event) { - event.preventDefault(); - $("#search-modal").modal('show'); - }); - $("#search-input").keyup(function () { - var search = $(this); - $(this).parent().find(".list-group").remove(); + $("#page-navigation-search").click(function (event) { + event.preventDefault(); + $("#search-modal").modal('show'); + }); + $("#search-input").keyup(function () { + var search = $(this); + $(this).parent().find(".list-group").remove(); - if (typeof bfsTimeout != 'undefined') { - clearTimeout(bfsTimeout); - } + if (typeof bfsTimeout != 'undefined') { + clearTimeout(bfsTimeout); + } - if (typeof bfsAjax != 'undefined' && bfsAjax.readyState != 4) { - bfsAjax.abort(); - } + if (typeof bfsAjax != 'undefined' && bfsAjax.readyState != 4) { + bfsAjax.abort(); + } - bfsTimeout = setTimeout(function (object) { - bfsAjax = $.ajax("/api/GetSearchResult/?query=" + $("#search-input").val()).done(function (data) { - var template = $.templates("#result-template"); - var content = $("
"); + bfsTimeout = setTimeout(function (object) { + bfsAjax = $.ajax("/api/GetSearchResult/?query=" + $("#search-input").val()).done(function (data) { + var template = $.templates("#result-template"); + var content = $("
"); - var item = template.render(data); - content.append(item); + var item = template.render(data); + content.append(item); - $("#search-results").html(content); + $("#search-results").html(content); - $("#search-results a.list-group-item").click(function () { - ga('send', 'pageview', '/api/GetSearchResult/?query=' + $("#search-input").val()); - }); + $("#search-results a.list-group-item").click(function () { + ga('send', 'pageview', '/api/GetSearchResult/?query=' + $("#search-input").val()); }); - }, 200); - }); + }); + }, 200); + }); + + $("#lang-switcher a").click(function (event) { + event.preventDefault(); + var lang = $(this).data("lang"); + document.cookie = "lang=" + lang + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/"; + + location.reload(true); + }); }); \ No newline at end of file diff --git a/BuildFeed/Views/shared/_default.cshtml b/BuildFeed/Views/shared/_default.cshtml index 3bf5174..f3f1705 100644 --- a/BuildFeed/Views/shared/_default.cshtml +++ b/BuildFeed/Views/shared/_default.cshtml @@ -1,4 +1,5 @@ -@{ +@using System.Globalization; +@{ bool IsRTL = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft; } @@ -16,9 +17,9 @@ @Styles.Render("~/content/css") - @if(IsRTL) + @if (IsRTL) { - Styles.Render("~/content/rtl"); + @Styles.Render("~/content/rtl") } @ViewBag.Title @RenderSection("head", false) @@ -78,10 +79,36 @@
  • @BuildFeed.Local.Common.AddBuild
  • @BuildFeed.Local.Common.LogOut
  • } -
  • @BuildFeed.Local.Common.Search
  • +
  • @BuildFeed.Local.Common.Search
  • @BuildFeed.Local.Common.Statistics
  • @BuildFeed.Local.Common.RssFeeds
  • @BuildFeed.Local.Common.Twitter
  • +
  • + + +
  • diff --git a/BuildFeed/content/rtl.css b/BuildFeed/content/rtl.css index bcda0d8..2f9816a 100644 --- a/BuildFeed/content/rtl.css +++ b/BuildFeed/content/rtl.css @@ -1,4 +1,41 @@ .form-horizontal .form-control-static { text-align: left; -} \ No newline at end of file +} + +.pagination > li > a, +.pagination > li > span +{ + float: right; +} + +h1[dir=ltr] +{ + text-align: right; +} + +@media (min-width: 768px) +{ + .navbar-header + { + float: right; + } + + .navbar-nav > li + { + float: right; + } + + .navbar-right + { + float: left !important; + margin-left: -15px; + margin-right: 0; + } + + .navbar-right .dropdown-menu + { + right: auto; + left: 0; + } +} diff --git a/RedisMongoMigration/Program.cs b/RedisMongoMigration/Program.cs index 56edd0f..251fc4b 100644 --- a/RedisMongoMigration/Program.cs +++ b/RedisMongoMigration/Program.cs @@ -9,6 +9,10 @@ using RBuild = RedisMongoMigration.Redis.Build; using MongoLevelOfFlight = RedisMongoMigration.Mongo.MongoLevelOfFlight; using RedisLevelOfFlight = RedisMongoMigration.Redis.RedisLevelOfFlight; +using MMember = RedisMongoMigration.Mongo.MongoMember; +using RMember = RedisMongoMigration.Redis.RedisMember; +using RRole = RedisMongoMigration.Redis.RedisRole; +using MRole = RedisMongoMigration.Mongo.MongoRole; namespace RedisMongoMigration { @@ -16,30 +20,58 @@ class Program { static void Main(string[] args) { - var builds = RBuild.Select(); - var newBuilds = from b in builds - select new MBuildModel() - { - Id = Guid.NewGuid(), - LegacyId = b.Id, + var builds = from b in RBuild.Select() + select new MBuildModel() + { + Id = Guid.NewGuid(), + LegacyId = b.Id, - MajorVersion = b.MajorVersion, - MinorVersion = b.MinorVersion, - Number = b.Number, - Revision = b.Revision, - Lab = b.Lab, - BuildTime = b.BuildTime, + MajorVersion = b.MajorVersion, + MinorVersion = b.MinorVersion, + Number = b.Number, + Revision = b.Revision, + Lab = b.Lab, + BuildTime = b.BuildTime, - Added = b.Added, - Modified = b.Modified, - SourceType = b.SourceType, - SourceDetails = b.SourceDetails, - LeakDate = b.LeakDate, - FlightLevel = ExchangeFlights(b.FlightLevel) - }; + Added = b.Added, + Modified = b.Modified, + SourceType = b.SourceType, + SourceDetails = b.SourceDetails, + LeakDate = b.LeakDate, + FlightLevel = ExchangeFlights(b.FlightLevel) + }; MBuild m = new MBuild(); - m.InsertAll(newBuilds); + m.InsertAll(builds); Console.WriteLine("Builds: Complete"); + + var members = from r in RMember.Select() + select new MMember() + { + CreationDate = r.CreationDate, + EmailAddress = r.EmailAddress, + Id = r.Id, + IsApproved = r.IsApproved, + IsLockedOut = r.IsLockedOut, + LastActivityDate = r.LastActivityDate, + LastLockoutDate = r.LastLockoutDate, + LastLoginDate = r.LastLoginDate, + LockoutWindowAttempts = r.LockoutWindowAttempts, + LockoutWindowStart = r.LockoutWindowStart, + PassHash = r.PassHash, + PassSalt = r.PassSalt, + UserName = r.UserName + }; + Console.WriteLine("Members: Complete"); + + var roles = from r in RRole.Select() + select new MRole() + { + Id = r.Id, + RoleName = r.RoleName, + Users = r.Users + }; + Console.WriteLine("Roles: Complete"); + Console.ReadKey(); } diff --git a/RedisMongoMigration/Redis/RedisMember.cs b/RedisMongoMigration/Redis/RedisMember.cs index ad82a61..6d848ba 100644 --- a/RedisMongoMigration/Redis/RedisMember.cs +++ b/RedisMongoMigration/Redis/RedisMember.cs @@ -1,36 +1,48 @@ using NServiceKit.DataAnnotations; using NServiceKit.DesignPatterns.Model; +using NServiceKit.Redis; using System; +using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace RedisMongoMigration.Redis { - [DataObject] - public class RedisMember : IHasId - { - [Key] - [Index] - public Guid Id { get; set; } + [DataObject] + public class RedisMember : IHasId + { + [Key] + [Index] + public Guid Id { get; set; } - [Key] - public string UserName { get; set; } - public byte[] PassHash { get; set; } - public byte[] PassSalt { get; set; } + [Key] + public string UserName { get; set; } + public byte[] PassHash { get; set; } + public byte[] PassSalt { get; set; } - [Key] - public string EmailAddress { get; set; } + [Key] + public string EmailAddress { get; set; } - public bool IsApproved { get; set; } - public bool IsLockedOut { get; set; } + public bool IsApproved { get; set; } + public bool IsLockedOut { get; set; } - public DateTime CreationDate { get; set; } - public DateTime LastActivityDate { get; set; } - public DateTime LastLockoutDate { get; set; } - public DateTime LastLoginDate { get; set; } + public DateTime CreationDate { get; set; } + public DateTime LastActivityDate { get; set; } + public DateTime LastLockoutDate { get; set; } + public DateTime LastLoginDate { get; set; } - public DateTime LockoutWindowStart { get; set; } - public int LockoutWindowAttempts { get; set; } - } + public DateTime LockoutWindowStart { get; set; } + public int LockoutWindowAttempts { get; set; } + + public static IEnumerable Select() + { + using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1)) + { + var client = rClient.As(); + return client.GetAll(); + } + } + } } diff --git a/RedisMongoMigration/Redis/RedisRole.cs b/RedisMongoMigration/Redis/RedisRole.cs index 3c33534..1f9b8a4 100644 --- a/RedisMongoMigration/Redis/RedisRole.cs +++ b/RedisMongoMigration/Redis/RedisRole.cs @@ -1,6 +1,8 @@ using NServiceKit.DataAnnotations; using NServiceKit.DesignPatterns.Model; +using NServiceKit.Redis; using System; +using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; @@ -17,5 +19,14 @@ public class RedisRole : IHasId public string RoleName { get; set; } public Guid[] Users { get; set; } - } + + public static IEnumerable Select() + { + using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1)) + { + var client = rClient.As(); + return client.GetAll(); + } + } + } }