Permalink
Browse files

Updated the Hub Auth sample style

  • Loading branch information...
1 parent dc326e4 commit 49ef78c1daad57c110aaa2cd308836f98cd00b36 @DamianEdwards DamianEdwards committed Oct 30, 2012
@@ -11,30 +11,30 @@ $(function () {
};
$.each(hubs, function (title, hub) {
- var list = $('<ul>').appendTo($('body').append('<h2>' + title + '</h2>'));
- var addMessage = function (value, color) {
- list.append('<li style="background-color:' + color + ';color:white">' + value + '</li>');
- };
+ var list = $('<ul>').appendTo($('#messages').append('<h4>' + title + '</h4>')),
+ addMessage = function (value, className) {
+ list.append('<li class="' + className + '">' + value + '</li>');
+ };
$.extend(hub.client, {
joined: function (id, when, authInfo) {
+ var info = [];
if ($.connection.hub.id === id) {
addMessage(id, 'blue');
}
- var info = [];
$.each(authInfo, function (k, v) {
- info.push("<b>" + k + ":</b> " + v);
+ info.push("<strong>" + k + ":</strong> " + v);
});
- addMessage(id + ' joined at ' + when + '<br />' + info.join('; '), 'green');
+ addMessage(id + ' joined at ' + when + '<br />' + info.join('; '), 'text-success');
},
rejoined: function (id, when) {
- addMessage(id + ' reconnected at ' + when, 'purple');
+ addMessage(id + ' reconnected at ' + when, 'text-warning');
},
left: function (id, when) {
- addMessage(id + ' left at ' + when, 'red');
+ addMessage(id + ' left at ' + when, 'text-error');
},
invoked: function (id, when) {
- addMessage(id + ' invoked hub method at' + when, 'orange');
+ addMessage(id + ' invoked hub method at' + when, 'text-info');
}
});
});
@@ -1,24 +1,31 @@
-<%@ Page Title="SignalR Auth Sample" Language="C#" AutoEventWireup="true"
- CodeBehind="Default.aspx.cs" Inherits="Microsoft.AspNet.SignalR.Samples.Hubs.Auth._Default" %>
-<!DOCTYPE html>
-<html>
-<head>
- <title>Auth Sample</title>
- <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
- <script src="../../Scripts/signalr.samples.js" type="text/javascript"></script>
- <script src="../../Scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
- <script src="../../Scripts/json2.min.js" type="text/javascript"></script>
- <script src="../../Scripts/jquery.signalR.js" type="text/javascript"></script>
- <script src="../../signalr/hubs" type="text/javascript"></script>
- <script src="Auth.js" type="text/javascript"></script>
-</head>
-<body>
- <form runat="server">
- <asp:Label ID="userNameLabel" AssociatedControlID="userName" Text="User Name: " runat="server" />
- <asp:TextBox ID="userName" runat="server" />
- <asp:Label ID="rolesLabel" AssociatedControlID="roles" Text="Roles: " runat="server" />
- <asp:TextBox ID ="roles" runat="server" />
- <asp:Button ID="login" runat="server" Text="login" OnClick="Login" />
+<%@ Page Title="SignalR Auth Sample" Language="C#" MasterPageFile="~/SignalR.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Microsoft.AspNet.SignalR.Samples.Hubs.Auth._Default" %>
+
+<asp:Content ContentPlaceHolderID="MainContent" runat="server">
+ <ul class="breadcrumb">
+ <li><a href="<%: ResolveUrl("~/") %>">SignalR Samples</a> <span class="divider">/</span></li>
+ <li class="active">Hub Authorization</li>
+ </ul>
+
+ <div class="page-header">
+ <h2>Hub Authorization <small>Protect hubs and hub methods</small></h2>
+ <p>Demonstrates how to use the authorization features of the Hub API to restrict certain Hubs and methods to specific users.</p>
+ </div>
+
+ <form runat="server" class="form-inline">
+ <asp:Label runat="server" AssociatedControlID="userName" Text="User Name:" />
+ <asp:TextBox ID="userName" runat="server" placeholder="Enter 'User'" />
+
+ <asp:Label runat="server" AssociatedControlID="roles" Text="Roles:" />
+ <asp:TextBox ID ="roles" runat="server" placeholder="Enter 'Invoker' or 'Admin'" />
+
+ <asp:Button runat="server" ID="login" CssClass="btn" Text="Log in" OnClick="Login" />
</form>
-</body>
-</html>
+
+ <div id="messages">
+ </div>
+</asp:Content>
+
+<asp:Content ContentPlaceHolderID="Scripts" runat="server">
+ <script src="<%: ResolveUrl("~/signalr/hubs") %>"></script>
+ <script src="Auth.js"></script>
+</asp:Content>
@@ -4,7 +4,7 @@
using System.Web.Security;
using System.Web.UI;
-namespace Microsoft.AspNet.SignalR.Hosting.AspNet.Samples.Hubs.Auth
+namespace Microsoft.AspNet.SignalR.Samples.Hubs.Auth
{
public partial class _Default : Page
{
@@ -29,6 +29,7 @@ private static string[] SplitString(string original)
let trimmed = piece.Trim()
where !String.IsNullOrEmpty(trimmed)
select trimmed;
+
return split.ToArray();
}
}
Oops, something went wrong.

0 comments on commit 49ef78c

Please sign in to comment.