|
| 1 | +using Code311.Host.Models; |
| 2 | +using Code311.Tabler.Mvc.Assets; |
| 3 | +using Code311.Tabler.Widgets.Calendar.Options; |
| 4 | +using Code311.Tabler.Widgets.Calendar.Widgets; |
| 5 | +using Code311.Tabler.Widgets.Charts.Options; |
| 6 | +using Code311.Tabler.Widgets.Charts.Widgets; |
| 7 | +using Code311.Tabler.Widgets.DataTables.Options; |
| 8 | +using Code311.Tabler.Widgets.DataTables.Widgets; |
| 9 | +using Microsoft.AspNetCore.Mvc; |
| 10 | + |
| 11 | +namespace Code311.Host.Controllers; |
| 12 | + |
| 13 | +public sealed class WidgetsController(ICode311AssetRequestStore assets) : Controller |
| 14 | +{ |
| 15 | + public IActionResult DataTables() |
| 16 | + { |
| 17 | + var widget = new DataTableWidgetSlot( |
| 18 | + "widget.datatables.incidents", |
| 19 | + "panel-body", |
| 20 | + new DataTableWidgetOptionsBuilder().WithPageLength(25).EnableSearch(true).Build()); |
| 21 | + |
| 22 | + assets.AddWidgetAssets(widget); |
| 23 | + var init = widget.CreateInitialization("datatable-demo"); |
| 24 | + return View(new WidgetDemoViewModel("DataTables", init.ElementId, init.OptionsJson)); |
| 25 | + } |
| 26 | + |
| 27 | + public IActionResult Calendar() |
| 28 | + { |
| 29 | + var widget = new CalendarWidgetSlot( |
| 30 | + "widget.calendar.operations", |
| 31 | + "panel-body", |
| 32 | + new CalendarWidgetOptionsBuilder().WithInitialView("dayGridMonth").ShowWeekends(true).Build()); |
| 33 | + |
| 34 | + assets.AddWidgetAssets(widget); |
| 35 | + var init = widget.CreateInitialization("calendar-demo"); |
| 36 | + return View("WidgetPage", new WidgetDemoViewModel("Calendar", init.ElementId, init.OptionsJson)); |
| 37 | + } |
| 38 | + |
| 39 | + public IActionResult Charts() |
| 40 | + { |
| 41 | + var widget = new ChartWidgetSlot( |
| 42 | + "widget.charts.kpi", |
| 43 | + "panel-body", |
| 44 | + new ChartWidgetOptionsBuilder().WithType("line").ShowLegend(true).Build()); |
| 45 | + |
| 46 | + assets.AddWidgetAssets(widget); |
| 47 | + var init = widget.CreateInitialization("charts-demo"); |
| 48 | + return View("WidgetPage", new WidgetDemoViewModel("Charts", init.ElementId, init.OptionsJson)); |
| 49 | + } |
| 50 | +} |
0 commit comments