Skip to content

Commit 441c9ad

Browse files
committed
Switched index to razor view
1 parent deabfb8 commit 441c9ad

5 files changed

Lines changed: 54 additions & 34 deletions

File tree

src/IdentityManager2/Api/Controllers/PageController.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using System;
22
using System.Threading.Tasks;
3-
using IdentityManager2.Assets;
3+
using IdentityManager2.Api.Models;
44
using IdentityManager2.Configuration;
55
using Microsoft.AspNetCore.Authentication;
66
using Microsoft.AspNetCore.Authorization;
77
using Microsoft.AspNetCore.Mvc;
8+
using Newtonsoft.Json;
89

910
namespace IdentityManager2.Api.Controllers
1011
{
@@ -23,10 +24,20 @@ public PageController(IdentityManagerOptions config)
2324
[Route("", Name = IdentityManagerConstants.RouteNames.Home)]
2425
public IActionResult Index()
2526
{
26-
return new EmbeddedHtmlResult(
27-
Request.PathBase,
28-
"IdentityManager2.Assets.Templates.index.html",
29-
config.SecurityConfiguration);
27+
return View("/Areas/IdentityManager/Pages/Index.cshtml", new PageModel
28+
{
29+
PathBase = Request.PathBase,
30+
Model = JsonConvert.SerializeObject(new
31+
{
32+
PathBase = Request.PathBase,
33+
ShowLoginButton = config.SecurityConfiguration.ShowLoginButton,
34+
oauthSettings = new
35+
{
36+
authorization_endpoint = Request.PathBase + Constants.AuthorizePath,
37+
client_id = Constants.IdMgrClientId
38+
}
39+
})
40+
});
3041
}
3142

3243
[HttpGet]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace IdentityManager2.Api.Models
2+
{
3+
public class PageModel
4+
{
5+
public string PathBase { get; set; }
6+
public string Model { get; set; }
7+
}
8+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@model IdentityManager2.Api.Models.PageModel
2+
3+
<!DOCTYPE html>
4+
<html>
5+
<head>
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7+
<meta charset="utf-8" />
8+
<title>IdentityManager 2</title>
9+
<link href="@Model.PathBase/assets/Content.bootstrap.min.css" rel="stylesheet" />
10+
<link href="@Model.PathBase/assets/Content.Style.min.css" rel="stylesheet" />
11+
<link rel="icon" type="image/x-icon" href="@Model.PathBase/assets/Content.favicon.ico" />
12+
<link rel="shortcut icon" type="image/x-icon" href="@Model.PathBase/assets/Content.favicon.ico" />
13+
</head>
14+
<body lang="en" ng-app="ttIdmApp" ng-csp ng-controller="LayoutCtrl" ng-cloak>
15+
16+
<div ng-include="'@Model.PathBase/assets/Templates.navbar.html'"></div>
17+
18+
<div class="container" ng-cloak>
19+
<ng-view tt-focus></ng-view>
20+
</div>
21+
22+
<div ng-include="'@Model.PathBase/assets/Templates.footer.html'"></div>
23+
24+
<script id="model" type="application/json">
25+
@Html.Raw(Model.Model)
26+
</script>
27+
<script src="@Model.PathBase/assets/Scripts.Bundle.js"></script>
28+
</body>
29+
</html>

src/IdentityManager2/Assets/Templates/index.html

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/IdentityManager2/IdentityManager2.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
@@ -23,7 +23,6 @@
2323

2424
<EmbeddedResource Include="Assets\Scripts\Bundle.js" />
2525

26-
<EmbeddedResource Include="Assets\Templates\index.html" />
2726
<EmbeddedResource Include="Assets\Templates\home.html" />
2827
<EmbeddedResource Include="Assets\Templates\users\edit.html" />
2928
<EmbeddedResource Include="Assets\Templates\users\list.html" />

0 commit comments

Comments
 (0)