Clean up and TS client

This commit is contained in:
BrennanConroy 2016-11-02 18:32:55 -07:00
parent 5434d437e9
commit 019bb460ec
17 changed files with 39 additions and 7434 deletions

3
.gitignore vendored
View File

@ -33,4 +33,5 @@ launchSettings.json
*.tmp
*.nuget.props
*.nuget.targets
autobahnreports/
autobahnreports/
signalr-client.js

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,187 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Welcome to ASP.NET Core</title>
<style>
html {
background: #f1f1f1;
height: 100%;
}
body {
background: #fff;
color: #505050;
font: 14px 'Segoe UI', tahoma, arial, helvetica, sans-serif;
margin: 1%;
min-height: 95.5%;
border: 1px solid silver;
position: relative;
}
#header {
padding: 0;
}
#header h1 {
font-size: 44px;
font-weight: normal;
margin: 0;
padding: 10px 30px 10px 30px;
}
#header span {
margin: 0;
padding: 0 30px;
display: block;
}
#header p {
font-size: 20px;
color: #fff;
background: #007acc;
padding: 0 30px;
line-height: 50px;
margin-top: 25px;
}
#header p a {
color: #fff;
text-decoration: underline;
font-weight: bold;
padding-right: 35px;
background: no-repeat right bottom url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAWCAMAAAAcqPc3AAAANlBMVEUAAAAAeswfitI9mthXp91us+KCvuaTx+mjz+2x1u+83PLH4vTR5/ba7Pjj8Pns9fv1+v3////wy3dWAAAAAXRSTlMAQObYZgAAAHxJREFUeNp9kVcSwCAIRMHUYoH7XzaxOxJ9P8oyQ1uIqNPwh3s2aLmIM2YtqrLcQIeQEylhuCeUOlhgve5yoBCfWmlnlgkN4H8ykbpaE7gR03AbUHiwoOxUH9Xp+ubd41p1HF3mBPrfC87BHeTdaB3ceeKL9HGpcvX9zu6+DdMWT9KQPvYAAAAASUVORK5CYII=);
}
#main {
padding: 5px 30px;
clear: both;
}
.section {
width: 21.7%;
float: left;
margin: 0 0 0 4%;
}
.section h2 {
font-size: 13px;
text-transform: uppercase;
margin: 0;
border-bottom: 1px solid silver;
padding-bottom: 12px;
margin-bottom: 8px;
}
.section.first {
margin-left: 0;
}
.section.first h2 {
font-size: 24px;
text-transform: none;
margin-bottom: 25px;
border: none;
}
.section.first li {
border-top: 1px solid silver;
padding: 8px 0;
}
.section.last {
margin-right: 0;
}
ul {
list-style: none;
padding: 0;
margin: 0;
line-height: 20px;
}
li {
padding: 4px 0;
}
a {
color: #267cb2;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
#footer {
clear: both;
padding-top: 50px;
}
#footer p {
position: absolute;
bottom: 10px;
}
</style>
</head>
<body>
<div id="header">
<h1>Welcome to ASP.NET Core</h1>
<span>
We've made some big updates in this release, so its <b>important</b> that you spend
a few minutes to learn whats new.
</span>
<p>You've created a new ASP.NET Core project. <a href="http://go.microsoft.com/fwlink/?LinkId=518016">Learn what's new</a></p>
</div>
<div id="main">
<div class="section first">
<h2>This application consists of:</h2>
<ul>
<li>Sample pages using ASP.NET Core MVC</li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518004">Bower</a> for managing client-side libraries</li>
<li>Theming using <a href="http://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li>
</ul>
</div>
<div class="section">
<h2>How to</h2>
<ul>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699562">Add an appsetting in config and access it in app.</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699318">Add client packages using Bower.</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li>
</ul>
</div>
<div class="section">
<h2>Overview</h2>
<ul>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li>
</ul>
</div>
<div class="section last">
<h2>Run & Deploy</h2>
<ul>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li>
</ul>
</div>
<div id="footer">
<p>We would love to hear your <a href="http://go.microsoft.com/fwlink/?LinkId=518015">feedback</a></p>
</div>
</div>
</body>
</html>

View File

@ -1,113 +0,0 @@
@*
For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
*@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
function hubConnection(url) {
var ws = new WebSocket(url);
var id = 0;
var calls = {};
var methods = {};
ws.onopen = function () {
console.log('Opened!');
};
ws.onmessage = function (event) {
let response = {};
response = JSON.parse(event.data);
// Response
if (response.Id) {
var cb = calls[response.Id];
delete calls[response.Id];
if (response.Error) {
cb.error(response.Error);
}
else {
cb.success(response.Result);
}
}
else {
// Reverse JSON RPC
methods[response.Method](response.Arguments);
}
};
ws.onclose = function (event) {
console.log('Closed!');
};
this.invoke = function (method, args, formatType) {
return new Promise((resolve, reject) => {
calls[id] = { success: resolve, error: reject };
//if (formatType == 'line') {
// ws.send(`CI${id},M${method},${args.join()}\n`);
//}
//else {
ws.send(JSON.stringify({ method: method, arguments: args, id: id }));
//}
id++;
});
};
this.on = function (method, fn) {
methods[method] = fn;
};
}
document.addEventListener('DOMContentLoaded', () => {
//let connectButton = document.getElementById('connect');
//connectButton.addEventListener('click', () => {
run(document.getElementById('formatType').value);
//connectButton.disabled = true;
});
//});
function run(formatType) {
var conn = new hubConnection(`ws://${document.location.host}/hubs/ws?formatType=${formatType}`);
conn.on('Send', function (message) {
var child = document.createElement('li');
child.innerText = message;
document.getElementById('messages').appendChild(child);
});
document.getElementById('sendmessage').addEventListener('submit', event => {
let data = document.getElementById('data').value;
conn.invoke('ChatSample.Hubs.Chat.Send', [data], formatType).catch(err => {
var child = document.createElement('li');
child.style.color = 'red';
child.innerText = err;
document.getElementById('messages').appendChild(child);
});
event.preventDefault();
});
};
</script>
</head>
<body>
<h1>WebSockets</h1>
<form id="sendmessage">
<input type="text" id="data" />
<input type="submit" value="Send" />
</form>
<ul id="messages"></ul>
</body>
</html>

View File

@ -1,7 +0,0 @@
@{
ViewData["Title"] = "About";
}
<h2>@ViewData["Title"].</h2>
<h3>@ViewData["Message"]</h3>
<p>Use this area to provide additional information.</p>

View File

@ -1,17 +0,0 @@
@{
ViewData["Title"] = "Contact";
}
<h2>@ViewData["Title"].</h2>
<h3>@ViewData["Message"]</h3>
<address>
One Microsoft Way<br />
Redmond, WA 98052-6399<br />
<abbr title="Phone">P:</abbr>
425.555.0100
</address>
<address>
<strong>Support:</strong> <a href="mailto:Support@example.com">Support@example.com</a><br />
<strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a>
</address>

View File

@ -4,6 +4,8 @@
@*<link rel="stylesheet" href="~/css/chat.css" />*@
<script src="~/js/signalr-client.js"></script>
<script>
function hubConnection(url) {
var ws = new WebSocket(url);
@ -80,22 +82,20 @@
document.addEventListener('DOMContentLoaded', () => {
run('json');
});
let connection = new RpcConnection(`http://${document.location.host}/hubs`, 'formatType=json&format=text');
function run(formatType) {
var conn = new hubConnection(`ws://${document.location.host}/hubs/ws?formatType=${formatType}`);
conn.on('Send', function (message) {
connection.on('Send', function (message) {
var child = document.createElement('li');
child.innerText = message;
document.getElementById('messages').appendChild(child);
});
connection.start();
document.getElementById('sendmessage').addEventListener('submit', event => {
let data = document.getElementById('new-message').value;
conn.invoke('ChatSample.Hubs.Chat.Send', [data], formatType).catch(err => {
connection.invoke('ChatSample.Hubs.Chat.Send', data, 'json').catch(err => {
var child = document.createElement('li');
child.style.color = 'red';
child.innerText = err;
@ -104,8 +104,7 @@
event.preventDefault();
});
};
});
</script>
<div id="chat-area">

View File

@ -1,132 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
function hubConnection(url) {
var ws = new WebSocket(url);
var id = 0;
var calls = {};
var methods = {};
ws.onopen = function () {
console.log('Opened!');
};
ws.onmessage = function (event) {
let response = {};
if (document.getElementById('formatType').value == 'line') {
let parts = event.data.split(',');
if (event.data[0] == 'R') {
response.Id = parts[0].slice(2);
response.Result = parts[1].slice(1);
}
else if (event.data[0] == 'C') {
response.Method = parts[1].slice(1);
response.Arguments = parts.slice(2).join();
}
else {
response.error = parts[0].slice(1);
}
}
else {
response = JSON.parse(event.data);
}
// Response
if (response.Id) {
var cb = calls[response.Id];
delete calls[response.Id];
if (response.Error) {
cb.error(response.Error);
}
else {
cb.success(response.Result);
}
}
else {
// Reverse JSON RPC
methods[response.Method](response.Arguments);
}
};
ws.onclose = function (event) {
console.log('Closed!');
};
this.invoke = function (method, args, formatType) {
return new Promise((resolve, reject) => {
calls[id] = { success: resolve, error: reject };
if (formatType == 'line') {
ws.send(`CI${id},M${method},${args.join()}\n`);
}
else {
ws.send(JSON.stringify({ method: method, arguments: args, id: id }));
}
id++;
});
};
this.on = function (method, fn) {
methods[method] = fn;
};
}
document.addEventListener('DOMContentLoaded', () => {
//let connectButton = document.getElementById('connect');
//connectButton.addEventListener('click', () => {
run(document.getElementById('formatType').value);
// connectButton.disabled = true;
//});
});
function run(formatType) {
var conn = new hubConnection(`ws://${document.location.host}/hubs/ws?formatType=${formatType}`);
conn.on('Send', function (message) {
var child = document.createElement('li');
child.innerText = message;
document.getElementById('messages').appendChild(child);
});
document.getElementById('sendmessage').addEventListener('submit', event => {
let data = document.getElementById('data').value;
conn.invoke('ChatSample.Hubs.Chat.Send', [data], formatType).catch(err => {
var child = document.createElement('li');
child.style.color = 'red';
child.innerText = err;
document.getElementById('messages').appendChild(child);
});
event.preventDefault();
});
};
</script>
</head>
<body>
<h1>WebSockets</h1>
<div>
<select id="formatType">
<option value="json">json</option>
<option value="line">line</option>
</select>
<input type="button" id="connect" value="Connect" />
</div>
<form id="sendmessage">
<input type="text" id="data" />
<input type="submit" value="Send" />
</form>
<ul id="messages"></ul>
</body>
</html>

View File

@ -1,6 +1,6 @@
[
{
"outputFile": "wwwroot/css/site.css",
"inputFile": "Content/site.less"
"inputFile": "wwwroot/css/site.less"
}
]

View File

@ -3,37 +3,37 @@
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"version": "1.1.0-preview1-001100-00",
"type": "platform"
},
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*",
"Microsoft.AspNetCore.Diagnostics": "1.1.0-*",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0-*",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0-*",
"Microsoft.AspNetCore.Mvc": "1.1.0-*",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*",
"Microsoft.AspNetCore.StaticFiles": "1.1.0-*",
"Microsoft.EntityFrameworkCore.Design": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0-*",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
"version": "1.0.0",
"version": "1.1.0-*",
"type": "build"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*",
"Microsoft.Extensions.Configuration.Json": "1.1.0-*",
"Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*",
"Microsoft.Extensions.Logging": "1.1.0-*",
"Microsoft.Extensions.Logging.Console": "1.1.0-*",
"Microsoft.Extensions.Logging.Debug": "1.1.0-*",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0-*",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
@ -42,7 +42,9 @@
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.SignalR": "1.0.0-*"
"Microsoft.AspNetCore.SignalR": {
"target": "project"
}
},
"tools": {
@ -60,7 +62,7 @@
},
"frameworks": {
"netcoreapp1.0": {
"netcoreapp1.1": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
@ -90,7 +92,7 @@
},
"scripts": {
"precompile": [ "dotnet bundle" ],
"precompile": [ "dotnet bundle", "tsc --project ../../src/Microsoft.AspNetCore.SignalR.Client.TS/ --out wwwroot/js/signalr-client.js" ],
"prepublish": [ "bower install" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}

View File

@ -1,132 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
function hubConnection(url) {
var ws = new WebSocket(url);
var id = 0;
var calls = {};
var methods = {};
ws.onopen = function () {
console.log('Opened!');
};
ws.onmessage = function (event) {
let response = {};
if (document.getElementById('formatType').value == 'line') {
let parts = event.data.split(',');
if (event.data[0] == 'R') {
response.Id = parts[0].slice(2);
response.Result = parts[1].slice(1);
}
else if (event.data[0] == 'C') {
response.Method = parts[1].slice(1);
response.Arguments = parts.slice(2).join();
}
else {
response.error = parts[0].slice(1);
}
}
else {
response = JSON.parse(event.data);
}
// Response
if (response.Id) {
var cb = calls[response.Id];
delete calls[response.Id];
if (response.Error) {
cb.error(response.Error);
}
else {
cb.success(response.Result);
}
}
else {
// Reverse JSON RPC
methods[response.Method](response.Arguments);
}
};
ws.onclose = function (event) {
console.log('Closed!');
};
this.invoke = function (method, args, formatType) {
return new Promise((resolve, reject) => {
calls[id] = { success: resolve, error: reject };
if (formatType == 'line') {
ws.send(`CI${id},M${method},${args.join()}\n`);
}
else {
ws.send(JSON.stringify({ method: method, arguments: args, id: id }));
}
id++;
});
};
this.on = function (method, fn) {
methods[method] = fn;
};
}
document.addEventListener('DOMContentLoaded', () => {
//let connectButton = document.getElementById('connect');
//connectButton.addEventListener('click', () => {
run(document.getElementById('formatType').value);
// connectButton.disabled = true;
//});
});
function run(formatType) {
var conn = new hubConnection(`ws://${document.location.host}/hubs/ws?formatType=${formatType}`);
conn.on('Send', function (message) {
var child = document.createElement('li');
child.innerText = message;
document.getElementById('messages').appendChild(child);
});
document.getElementById('sendmessage').addEventListener('submit', event => {
let data = document.getElementById('data').value;
conn.invoke('ChatSample.Hubs.Chat.Send', [data], formatType).catch(err => {
var child = document.createElement('li');
child.style.color = 'red';
child.innerText = err;
document.getElementById('messages').appendChild(child);
});
event.preventDefault();
});
};
</script>
</head>
<body>
<h1>WebSockets</h1>
<div>
<select id="formatType">
<option value="json">json</option>
<option value="line">line</option>
</select>
<input type="button" id="connect" value="Connect" />
</div>
<form id="sendmessage">
<input type="text" id="data" />
<input type="submit" value="Send" />
</form>
<ul id="messages"></ul>
</body>
</html>

View File

@ -1,4 +1,5 @@
/// <autosync enabled="true" />
/// <reference path="js/signalr-client.js" />
/// <reference path="js/site.js" />
/// <reference path="lib/bootstrap/dist/js/bootstrap.js" />
/// <reference path="lib/jquery/dist/jquery.js" />

View File

@ -1,75 +0,0 @@
body
{
font-family: Trebuchet MS;
font-size: 13px;
}
#messages
{
width: 70%;
border: 1px solid #ccc;
height: 500px;
float: left;
overflow: auto;
margin-left: 0px;
padding-left: 0px;
}
#messages li
{
list-style-type: none;
padding: 3px;
}
#users
{
width: 17%;
height: 500px;
border-right: 1px solid #ccc;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
float: left;
margin-left: 0px;
padding-left: 0px;
overflow: auto;
font-size: small;
white-space: nowrap;
}
#users li
{
padding: 4px;
}
.clear
{
clear: both;
}
#new-message
{
font-family: Trebuchet MS;
width: 70%;
padding: 5px;
border: 1px solid #ccc;
}
.error
{
color:Red;
}
.pm
{
color:Red;
}
.notification
{
color:#bbb;
}
.message
{
}

View File

@ -6731,9 +6731,9 @@ body {
border: 1px solid #ccc;
height: 500px;
float: left;
overflow: auto;
margin-left: 0px;
padding-left: 0px;
overflow-y: auto;
}
#messages li {
list-style-type: none;

View File

@ -1,4 +1,4 @@
@import "../wwwroot/lib/bootstrap/less/bootstrap.less";
@import "../lib/bootstrap/less/bootstrap.less";
body {
padding-top: @navbar-height + 10px;
@ -12,9 +12,9 @@ body {
border: 1px solid #ccc;
height: 500px;
float: left;
overflow: auto;
margin-left: 0px;
padding-left: 0px;
overflow-y: auto;
}
#messages li

File diff suppressed because one or more lines are too long