Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edcf6af
commit 52081e1
Showing
10 changed files
with
1,168 additions
and
899 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
var React = require('react'); | ||
|
||
|
||
var MessageRow = React.createClass({ | ||
render: function(){ | ||
var url = '#fubumvc/chain-details/' + this.props.message.chain; | ||
|
||
|
||
return ( | ||
<tr> | ||
<td><a href={url} title="View the chain visualization for this message type">{this.props.message.type}</a></td> | ||
<td>{this.props.message.query}</td> | ||
<td>{this.props.message.resource}</td> | ||
</tr> | ||
); | ||
} | ||
}); | ||
|
||
var MessageTable = React.createClass({ | ||
getInitialState: function(){ | ||
return { | ||
loading: true | ||
} | ||
}, | ||
|
||
componentDidMount: function(){ | ||
FubuDiagnostics.get('ClientMessages:clientmessages', {}, data => { | ||
_.assign(data, {loading: false}); | ||
|
||
this.setState(data); | ||
}); | ||
}, | ||
|
||
render: function(){ | ||
if (this.state.loading){ | ||
return (<p>Loading...</p>); | ||
} | ||
|
||
if (this.state.messages.length == 0){ | ||
return ( | ||
<h1>No client messages in this application!</h1> | ||
); | ||
} | ||
|
||
var rows = this.state.messages.map(function(r, i){ | ||
return ( | ||
<MessageRow message={r} /> | ||
); | ||
}); | ||
|
||
return ( | ||
<table className="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Client Side Name</th> | ||
<th>Query Model</th> | ||
<th>Resource Model</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{rows} | ||
</tbody> | ||
</table> | ||
); | ||
} | ||
}); | ||
|
||
|
||
FubuDiagnostics.section('fubumvc').add({ | ||
title: 'Client Message Types', | ||
description: 'A list of all the message types available for aggregated querying', | ||
key: 'client-messages', | ||
component: MessageTable | ||
}); |
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
58 changes: 58 additions & 0 deletions
58
src/FubuMVC.Core/Diagnostics/ClientMessagesFubuDiagnostics.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,58 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FubuMVC.Core.Runtime.Aggregation; | ||
|
||
namespace FubuMVC.Core.Diagnostics | ||
{ | ||
public class ClientMessagesFubuDiagnostics | ||
{ | ||
private readonly IClientMessageCache _messages; | ||
|
||
public ClientMessagesFubuDiagnostics(IClientMessageCache messages) | ||
{ | ||
_messages = messages; | ||
} | ||
|
||
public ClientMessageReport get_clientmessages() | ||
{ | ||
return new ClientMessageReport | ||
{ | ||
messages = _messages.AllClientMessages().OrderBy(x => x.Message).Select(x => | ||
{ | ||
var description1 = new ClientMessageDescription(x); | ||
return description1; | ||
}).ToArray() | ||
}; | ||
} | ||
} | ||
|
||
public class ClientMessageReport | ||
{ | ||
public ClientMessageDescription[] messages; | ||
} | ||
|
||
public class ClientMessageDescription | ||
{ | ||
public ClientMessageDescription() | ||
{ | ||
} | ||
|
||
public ClientMessageDescription(ClientMessagePath path) | ||
{ | ||
type = path.Message; | ||
query = path.InputType == null ? "N/A" : path.InputType.FullName; | ||
resource = path.ResourceType.FullName; | ||
chain = path.Chain.GetHashCode(); | ||
} | ||
|
||
public int chain { get; set; } | ||
|
||
public string resource { get; set; } | ||
|
||
public string query { get; set; } | ||
|
||
public string type { get; set; } | ||
} | ||
} |
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
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,121 @@ | ||
using System.Linq; | ||
using FubuMVC.Core; | ||
using FubuMVC.Core.Runtime.Aggregation; | ||
|
||
namespace TestHarnessApp | ||
{ | ||
public class AggregationEndpoint | ||
{ | ||
private readonly IAggregator _aggregator; | ||
|
||
public AggregationEndpoint(IAggregator aggregator) | ||
{ | ||
_aggregator = aggregator; | ||
} | ||
|
||
public Resource1 get_query1_Name(Query1 query) | ||
{ | ||
return new Resource1 { Name = query.Name }; | ||
} | ||
|
||
public Resource2 get_second_resource() | ||
{ | ||
return new Resource2(); | ||
} | ||
|
||
public Resource3 get_third_resource(Input2 input) | ||
{ | ||
return new Resource3(); | ||
} | ||
|
||
public Resource4 get_fourth_resource() | ||
{ | ||
return new Resource4(); | ||
} | ||
|
||
public AggregationResponse post_aggregated_query(AggregatedQuery query) | ||
{ | ||
return _aggregator.QueryAggregate(query); | ||
} | ||
|
||
public string[] get_aggregation() | ||
{ | ||
// The call to IAggregator.Fetch() will return an array | ||
// of objects. My assumption now is that you'd do this in | ||
// the main endpoint method, tack the data store data on | ||
// to the view model sent to the main spark view, and | ||
// render it to the view with a page helper there. | ||
// This is so common now that I think we put a json variable | ||
// helper into FubuMVC.Core. | ||
return _aggregator.Fetch(_ => | ||
{ | ||
// By an input query | ||
_.Query(new Query1 { Name = "Jeremy Maclin" }); | ||
// By the resource type | ||
_.Resource<Resource2>(); | ||
// By the input type as a marker | ||
_.Input<Input2>(); | ||
// By action method | ||
_.Action<AggregationEndpoint>(x => x.get_fourth_resource()); | ||
}) | ||
.Select(x => x.ToString()) | ||
.ToArray(); | ||
} | ||
|
||
[ClientMessage] | ||
public class Input1 | ||
{ | ||
|
||
} | ||
|
||
[ClientMessage] | ||
public class Resource2 | ||
{ | ||
public override string ToString() | ||
{ | ||
return "I am Resource2"; | ||
} | ||
} | ||
|
||
[ClientMessage] | ||
public class Input2 { } | ||
|
||
[ClientMessage] | ||
public class Resource3 | ||
{ | ||
public override string ToString() | ||
{ | ||
return "Resource3 from input type 2"; | ||
} | ||
} | ||
|
||
[ClientMessage] | ||
public class Resource4 | ||
{ | ||
public override string ToString() | ||
{ | ||
return "Resource4 from an action identified by expression"; | ||
} | ||
} | ||
|
||
[ClientMessage] | ||
public class Query1 | ||
{ | ||
public string Name { get; set; } | ||
} | ||
|
||
[ClientMessage] | ||
public class Resource1 | ||
{ | ||
public string Name { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return "Resource1: " + Name; | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.