Skip to content

Commit

Permalink
feat(IpfsServer): show node ID on home page
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed May 17, 2019
1 parent 7ccc7e4 commit 1528a2a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion IpfsServer/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
}
<div class="jumbotron">
<h1>IPFS</h1>
<p class="lead">Join the <a href="https://ipfs.io/">InterPlanetary File System</a> - the permanent distributed web.</p>
<p class="lead">Welcome to the <a href="https://ipfs.io/">InterPlanetary File System</a> - the permanent distributed web.</p>
<p>You are talking to node <span class="hex">@Model.NodeId</span>.</p>
</div>
<div class="row">
<div class="col-md-4">
Expand Down
18 changes: 16 additions & 2 deletions IpfsServer/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Ipfs.CoreApi;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

Expand All @@ -12,12 +13,25 @@ namespace Ipfs.Server.Pages
/// </summary>
public class IndexModel : PageModel
{
ICoreApi ipfs;

/// <summary>
/// Build the model.
/// Creates a new instance of the controller.
/// </summary>
public void OnGet()
public IndexModel(ICoreApi ipfs)
{
this.ipfs = ipfs;
}

public string NodeId = "foo-bar";

/// <summary>
/// Build the model.
/// </summary>
public async Task OnGetAsync()
{
var peer = await ipfs.Generic.IdAsync();
NodeId = peer.Id.ToString();
}
}
}
4 changes: 4 additions & 0 deletions IpfsServer/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ body {
display: none;
}
}

.hex {
font-size: 80%;
}

0 comments on commit 1528a2a

Please sign in to comment.