Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP typescript support #386

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [16.x]

steps:
- uses: actions/checkout@v1
Expand All @@ -19,10 +19,9 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
cd App
cd ui
npm ci
npm run lint
npm run test
npm run browserify
npm run build
env:
CI: true
48 changes: 48 additions & 0 deletions App/grains/grainState.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const React = require('react')
const Chart = require('../components/time-series-chart.jsx')
const CounterWidget = require('../components/counter-widget.jsx')
const SiloBreakdown = require('./silo-table.jsx')
const Panel = require('../components/panel.jsx')
const Page = require('../components/page.jsx')

module.exports = class GrainState extends React.Component {
renderEmpty() {
return <span>No state retrieved</span>
}

renderState() {

return (
<Page
title={getName(this.props.grainType)}
subTitle={this.props.grainId}
>
<div>
<div className="row">
<div className="col-md-12">
<p>
{JSON.stringify(this.props.state, null, "\t")}
</p>
</div>

</div>
</div>
</Page>
)
}

render() {
if (Object.keys(this.props.state).length === 0)
return this.renderEmpty()
return this.renderState()
}
}

function getName(value) {
try {
var parts = value.split(',')[0].split('.')
return parts[parts.length - 1]
} catch (error) {
return value;
}
}
27 changes: 27 additions & 0 deletions App/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,28 +349,51 @@ routie('/grain/:grainType', function (grainType) {
})


<<<<<<< HEAD
routie('/grainDetails', function () {
=======
routie('/grainState/:grainType/:grainId', function(grainType, grainId) {
>>>>>>> add initial support for grain state output
var thisRouteIndex = ++routeIndex
events.clearAll()
scroll()
renderLoading()

<<<<<<< HEAD
var grainTypes = {}
var loadDataIsPending = false;
var loadData = function (cb) {
if (!loadDataIsPending) {
http.get('GrainTypes', function (err, data) {
grainTypes = data
=======
var grainState = {}
var loadDataIsPending = false;
var loadData = function(cb) {
if (!loadDataIsPending) {
http.get('GrainState?grainId=' + grainId + '&grainType='+ grainType, function(err, data) {
grainState = data
>>>>>>> add initial support for grain state output
render()
}).finally(() => loadDataIsPending = false);
}
}

<<<<<<< HEAD
render = function () {
if (routeIndex != thisRouteIndex) return
renderPage(
<GrainDetails
grainTypes={grainTypes}
=======
render = function() {
if (routeIndex != thisRouteIndex) return
renderPage(
<GrainState
grainType={grainType}
grainId={grainId}
state={grainState}
>>>>>>> add initial support for grain state output
/>,
'#/grainState'
)
Expand All @@ -379,7 +402,11 @@ routie('/grainDetails', function () {
loadData()
})

<<<<<<< HEAD
routie('/reminders/:page?', function (page) {
=======
routie('/reminders/:page?', function(page) {
>>>>>>> add initial support for grain state output
var thisRouteIndex = ++routeIndex
events.clearAll()
scroll()
Expand Down
41 changes: 0 additions & 41 deletions App/lib/http.js

This file was deleted.

7 changes: 5 additions & 2 deletions OrleansDashboard.Core/DashboardClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Threading.Tasks;
using Orleans;
using Orleans.Concurrency;
Expand Down Expand Up @@ -76,7 +79,7 @@ public async Task<Immutable<string>> GetGrainState(string id, string grainType)
return await dashboardGrain.GetGrainState(id, grainType);
}

public async Task<Immutable<string[]>> GetGrainTypes()
public async Task<Immutable<CallableGrainMethod[]>> GetGrainTypes()
{
return await dashboardGrain.GetGrainTypes();
}
Expand Down
3 changes: 2 additions & 1 deletion OrleansDashboard.Core/IDashboardClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Dynamic;
using System.Threading.Tasks;
using Orleans.Concurrency;
using Orleans.Runtime;
Expand Down Expand Up @@ -29,6 +30,6 @@ public interface IDashboardClient

Task<Immutable<string>> GetGrainState(string id,string grainType);

Task<Immutable<string[]>> GetGrainTypes();
Task<Immutable<CallableGrainMethod[]>> GetGrainTypes();
}
}
9 changes: 8 additions & 1 deletion OrleansDashboard.Core/IDashboardGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

namespace OrleansDashboard
{
public class CallableGrainMethod
{
public string Namespace { get; set; }
public string Class { get; set; }
public string Method { get; set; }
}

public interface IDashboardGrain : IGrainWithIntegerKey
{
[OneWay]
Expand All @@ -28,6 +35,6 @@ public interface IDashboardGrain : IGrainWithIntegerKey

Task<Immutable<string>> GetGrainState(string id, string grainType);

Task<Immutable<string[]>> GetGrainTypes();
Task<Immutable<CallableGrainMethod[]>> GetGrainTypes();
}
}
14 changes: 13 additions & 1 deletion OrleansDashboard/Dashboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OpenTelemetry;
Expand Down Expand Up @@ -49,17 +50,28 @@ public async Task Execute(CancellationToken cancellationToken)
.ConfigureServices(services =>
{
services.AddServicesForHostedDashboard(grainFactory, dashboardOptions);
services.AddCors(options => {
options.AddDefaultPolicy(policy => policy
.WithOrigins("http://localhost:3000")
.AllowAnyHeader()
.WithMethods("GET")
.Build());
});

})
.Configure(app =>
{
app.UseCors();

if (dashboardOptions.HasUsernameAndPassword())
{
// only when username and password are configured
// do we inject basicauth middleware in the pipeline
app.UseMiddleware<BasicAuthMiddleware>();
}

app.UseOrleansDashboard(dashboardOptions);

})
.UseKestrel()
.UseUrls($"http://{dashboardOptions.Host}:{dashboardOptions.Port}")
Expand Down
13 changes: 13 additions & 0 deletions OrleansDashboard/DashboardMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ await WriteJson(context,
return;
}

if (request.Path == "/GrainState")
{
request.Query.TryGetValue("grainId", out var grainId);

request.Query.TryGetValue("grainType", out var grainType);

var result = await Client.GetGrainState(grainId, grainType);

await WriteJson(context, result);

return;
}

if (request.Path == "/Trace")
{
await TraceAsync(context);
Expand Down
Loading