Hangfire icon indicating copy to clipboard operation
Hangfire copied to clipboard

How to add more page in Dashboard?

Open stevenluoxiaohua opened this issue 10 years ago • 7 comments

How to add more page in Dashboard?

stevenluoxiaohua avatar Jun 13 '16 08:06 stevenluoxiaohua

following

gandarez avatar Jun 13 '16 12:06 gandarez

In short, you should do the following steps:

  • Install the RazorGenerator extension for Visual Studio (here is GitHub repo).
  • Create a .cshtml file with the following content. You can see more examples in the Hangfire repository.
@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: true *@
@inherits RazorPage

@* The rest of a page *@
  • Set the CustomTool property of a .cshtml file to RazorGenerator. After this step, a new class will appear in your project.
  • Register page for a route for a new class:
using Hangfire.Dashboard;
RouteCollection.Routes.AddRazorPage("/batches/started", x => new StartedBatchesPage());
  • Add a new navigation menu item:
NavigationMenu.Items.Add(page => new MenuItem("Batches", page.Url.To("/batches/started")));

odinserj avatar Jun 16 '16 11:06 odinserj

Register page for a route

any class is ok? when call this class?

stevenluoxiaohua avatar Jun 16 '16 12:06 stevenluoxiaohua

Set the CustomTool property of a .cshtml file to RazorGenerator. After this step, a new class will appear in your project.

You should use class created by RazorGenerator.

odinserj avatar Jun 16 '16 12:06 odinserj

You may also need to override its namespace.

@* Generator: Template
    TypeVisibility: Internal
    GeneratePrettyNames: true
    Namespace: Hangfire.Dashboard.Pages
*@

gandarez avatar Jun 16 '16 18:06 gandarez

@odinserj I couldn't find any extension or way to add a route

RouteCollection.Routes.AddRazorPage("/batches/started", x => new StartedBatchesPage());

Should it be DashboardRoutes.Routes ?

gandarez avatar Jun 16 '16 19:06 gandarez

@odinserj the razor template generator isn't available for VS2022, is that the only way to extend or replace pages?

weirdyang avatar Nov 04 '24 03:11 weirdyang