Skip to content

Commit bf5a89e

Browse files
added template viewer
1 parent 2bf507f commit bf5a89e

File tree

6 files changed

+69
-125
lines changed

6 files changed

+69
-125
lines changed

DeveloperTools/Controllers/TemplatesController.cs

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

tests/temp/Templates/Index.cshtml renamed to DeveloperTools/EPiServer.DeveloperTools.Views/Views/Templates/Index.cshtml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
@using DeveloperTools.Models
2-
@using EPiServer.Shell
3-
@inherits System.Web.Mvc.WebViewPage<IEnumerable<EPiServer.DataAbstraction.TemplateModel>>
4-
5-
@{
6-
Layout = Paths.ToResource("EPiServer.DeveloperTools", "Views/Shared/DevToolsMaster.cshtml");
7-
}
1+
@model EPiServer.DeveloperTools.Features.Templates.TemplatesModel
82

93
<div class="epi-contentArea">
104
<h1 class="EP-prefix">Templates</h1>
@@ -14,35 +8,44 @@
148
<table cellpadding="0" cellspacing="0" border="0" class="display" id="theList">
159
<thead>
1610
<tr>
11+
<th align="left">ContentModelType</th>
1712
<th align="left">Name</th>
1813
<th align="left">Category</th>
19-
<th align="left">Default</th>
2014
<th align="left">Inherit</th>
2115
<th align="left">Tags</th>
2216
<th align="left">AvailableWithoutTag</th>
2317
<th align="left">Path</th>
24-
<th align="left">Type</th>
18+
<th align="left">ModelType</th>
19+
<th align="left">TemplateType</th>
2520
</tr>
2621
</thead>
2722
<tbody>
28-
@foreach (var t in Model)
23+
@foreach (var a in Model.Templates)
2924
{
30-
<tr>
31-
<td>@t.Name</td>
32-
<td>@t.TemplateTypeCategory</td>
33-
<td>@(t.Default ? "yes" : "no")</td>
34-
<td>@(t.Inherit ? "yes" : "no")</td>
35-
<td>@(t.Tags == null ? "" : string.Join(",", t.Tags))</td>
36-
<td>@(t.AvailableWithoutTag ? "Yes" : "No")</td>
37-
<td>@t.Path</td>
38-
<td>@t.TemplateType</td>
39-
</tr>
25+
var i = 0;
26+
27+
@foreach (var t in a.Value)
28+
{
29+
<tr>
30+
<td>@(i == 0 ? a.Key.ModelType.FullName : string.Empty)</td>
31+
<td>@t.DisplayName (@t.Name)</td>
32+
<td>@t.TemplateTypeCategory</td>
33+
<td>@(t.Inherit ? "yes" : "no")</td>
34+
<td>@(t.Tags == null ? "" : string.Join(",", t.Tags))</td>
35+
<td>@(t.AvailableWithoutTag ? "Yes" : "No")</td>
36+
<td>@t.Path</td>
37+
<td>@t.ModelType</td>
38+
<td>@t.TemplateType</td>
39+
</tr>
40+
41+
i++;
42+
}
4043
}
4144
</tbody>
4245
</table>
4346
</div>
4447

45-
@section Scripts {
48+
@section AdditionalScripts {
4649
<script>
4750
$(document).ready(function () {
4851
$('#theList').dataTable(
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Linq;
2+
using DeveloperTools.Controllers;
3+
using EPiServer.DataAbstraction;
4+
using Microsoft.AspNetCore.Mvc;
5+
6+
namespace EPiServer.DeveloperTools.Features.Templates;
7+
8+
public class TemplatesController : DeveloperToolsController
9+
{
10+
private readonly ContentTypeModelRepository _contentTypeModelRepository;
11+
private readonly ITemplateRepository _templateRepository;
12+
13+
public TemplatesController(ITemplateRepository templateRepository, ContentTypeModelRepository contentTypeModelRepository)
14+
{
15+
_templateRepository = templateRepository;
16+
_contentTypeModelRepository = contentTypeModelRepository;
17+
}
18+
19+
public ActionResult Index()
20+
{
21+
var model = new TemplatesModel
22+
{
23+
Templates = _contentTypeModelRepository
24+
.List()
25+
.Where(ct => ct != null)
26+
.Select(ct => new { ContentType = ct, Templates = _templateRepository.List(ct.ModelType) })
27+
.ToDictionary(arg => arg.ContentType, arg => arg.Templates)
28+
};
29+
30+
return View(model);
31+
}
32+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Collections.Generic;
2+
using EPiServer.DataAbstraction;
3+
using EPiServer.DataAbstraction.RuntimeModel;
4+
5+
namespace EPiServer.DeveloperTools.Features.Templates;
6+
7+
public class TemplatesModel
8+
{
9+
public Dictionary<ContentTypeModel, IEnumerable<TemplateModel>> Templates { get; set; } = new();
10+
}

DeveloperTools/Infrastructure/MenuProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public IEnumerable<MenuItem> GetMenuItems()
2828
CreateUrlMenuItem("Startup Perf", "StartupPerf", 20),
2929
CreateUrlMenuItem("IoC", "IOC", 30),
3030
CreateUrlMenuItem("App Environment", "AppEnvironment", 40),
31-
CreateUrlMenuItem("Revert Content Types", "RevertToDefault", 50),
32-
CreateUrlMenuItem("Content Type Analyzer", "ContentTypeAnalyzer", 60),
33-
CreateUrlMenuItem("Templates", "Templates", 70),
31+
CreateUrlMenuItem("Templates", "Templates", 50),
32+
CreateUrlMenuItem("Revert Content Types", "RevertToDefault", 60),
33+
CreateUrlMenuItem("Content Type Analyzer", "ContentTypeAnalyzer", 70),
3434
CreateUrlMenuItem("Log Viewer", "LogViewer", 80),
3535
CreateUrlMenuItem("Memory Dump", "MemoryDump", 90),
3636
CreateUrlMenuItem("Remote Events", "RemoteEvent", 100),

tests/temp/TimeMeters/Index.cshtml

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

0 commit comments

Comments
 (0)