Skip to content

Commit

Permalink
Merge pull request #2 from erossini/feature/widgets
Browse files Browse the repository at this point in the history
New widgets
  • Loading branch information
erossini authored Mar 4, 2021
2 parents 996255c + 603504d commit d3abaa7
Show file tree
Hide file tree
Showing 472 changed files with 104,046 additions and 24 deletions.
119 changes: 118 additions & 1 deletion AdminLTEWithASPNETCore/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AdminLTEWithASPNETCore.Attributes;
using AdminLTEWithASPNETCore.Models;
using AdminLTEWithASPNETCore.Models.Controllers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand All @@ -19,7 +20,123 @@ public HomeController(ILogger<HomeController> logger)

public IActionResult Index()
{
return View();
HomeModel model = new HomeModel();
model.Card = new Models.Components.Cards.CardModel()
{
Body = "This is an example of card",
Links = new System.Collections.Generic.List<Models.Components.LinkModel>()
{
new Models.Components.LinkModel() {
Target = "_blank",
Text = "PureSourceCode",
Url = "https://www.puresourcecode.com"
},
new Models.Components.LinkModel() {
Target = "",
Text = "Click here",
Url = "#"
}
},
Title = "Card test"
};
model.VisitorChart = new Models.Components.Charts.ChartModel()
{
ChartId = "visitor-chart",
Height = 250,
Labels = { "18th", "20th", "22nd", "24th", "26th", "28th", "30th" },
ShowLegend = true,
Datasets = new System.Collections.Generic.List<Models.Components.Charts.Dataset>()
{
new Models.Components.Charts.Dataset()
{
BackgroundColors = new System.Collections.Generic.List<string>() { "transparent" },
BorderColor = "#007bff",
Label = "This week",
PointBackgroundColor = "#007bff",
PointBorderColor = "#007bff",
Fill = false,
Data = new System.Collections.Generic.List<decimal>() {
100, 120, 170, 167, 180, 177, 160
}
},
new Models.Components.Charts.Dataset()
{
BackgroundColors = new System.Collections.Generic.List<string>() { "transparent" },
BorderColor = "#ced4da",
Label = "Last week",
PointBackgroundColor = "#ced4da",
PointBorderColor = "#ced4da",
Fill = false,
Data = new System.Collections.Generic.List<decimal>() {
60, 80, 70, 67, 80, 77, 100
}
}
}
};
model.SalesChart = new Models.Components.Charts.ChartModel()
{
ChartId = "salesChart",
Height = 250,
Labels = { "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" },
ShowLegend = true,
XAxes = new Models.Components.Charts.Axes()
{
ShowAxes = true,
ShowGridLines = true
},
YAxes = new Models.Components.Charts.Axes()
{
ShowAxes = true,
ShowGridLines = true
},
Datasets = new System.Collections.Generic.List<Models.Components.Charts.Dataset>()
{
new Models.Components.Charts.Dataset()
{
BackgroundColors = new System.Collections.Generic.List<string>() { "#007bff" },
BorderColor = "#007bff",
Label = "This year",
Data = new System.Collections.Generic.List<decimal>()
{
1000, 2000, 3000, 2500, 2700, 2500, 3000
}
},
new Models.Components.Charts.Dataset()
{
BackgroundColors = new System.Collections.Generic.List<string>() { "#ced4da" },
BorderColor = "#ced4da",
Label = "Last year",
Data = new System.Collections.Generic.List<decimal>()
{
700, 1700, 2700, 2000, 1800, 1500, 2000
}
}
}
};
model.SalesPie = new Models.Components.Charts.ChartModel()
{
ChartId = "pieSales",
Labels = new System.Collections.Generic.List<string>() {
"Instore Sales", "Download Sales", "Mail-Order Sales"
},
ShowLegend = true,
Datasets = new System.Collections.Generic.List<Models.Components.Charts.Dataset>()
{
new Models.Components.Charts.Dataset()
{
BackgroundColors = new System.Collections.Generic.List<string>()
{
"#f56954", "#00a65a", "#f39c12"
},
Data = new System.Collections.Generic.List<decimal>()
{
30, 20, 10
}
}
}
};

return View("Index", model);
}

[Breadcrumb("Privacy")]
Expand Down
47 changes: 47 additions & 0 deletions AdminLTEWithASPNETCore/Controllers/ServicePageController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AdminLTEWithASPNETCore.Controllers
{
public class ServicePageController : Controller
{
private readonly SignInManager<IdentityUser> _signInManager;

public ServicePageController(SignInManager<IdentityUser> signInManager)
{
_signInManager = signInManager;
}

public IActionResult Lockscreen()
{
ViewBag.Reason = "lockscreen";
return View();
}

public async Task<IActionResult> LockscreenCheck(string password)
{
if (ModelState.IsValid && !string.IsNullOrEmpty(password))
{
var result = await _signInManager.PasswordSignInAsync(User.Identity?.Name, password, false, lockoutOnFailure: true);
if (result.Succeeded)
{
return LocalRedirectPermanent("/Home");
}
if (result.RequiresTwoFactor)
{
return RedirectToPage("./LoginWith2fa", new { ReturnUrl = "/Home" });
}
else
{
return LocalRedirectPermanent("/ServicePage/Lockscreen");
}
}

return LocalRedirectPermanent("/ServicePage/Lockscreen");
}
}
}
35 changes: 35 additions & 0 deletions AdminLTEWithASPNETCore/Enums/Components/PositionType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

namespace AdminLTEWithASPNETCore.Enums.Components
{
/// <summary>
/// Enum PositionType
/// </summary>
public enum PositionType
{
/// <summary>
/// The bottom
/// </summary>
[Description("bottom")]
Bottom,
/// <summary>
/// The left
/// </summary>
[Description("left")]
Left,
/// <summary>
/// The right
/// </summary>
[Description("right")]
Right,
/// <summary>
/// The top
/// </summary>
[Description("top")]
Top
}
}
35 changes: 35 additions & 0 deletions AdminLTEWithASPNETCore/Enums/Components/ShadowType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

namespace AdminLTEWithASPNETCore.Enums.Components
{
/// <summary>
/// Enum ShadowType
/// </summary>
public enum ShadowType
{
/// <summary>
/// The none
/// </summary>
[Description("")]
None,
/// <summary>
/// The small
/// </summary>
[Description("shadow-sm")]
Small,
/// <summary>
/// The regular
/// </summary>
[Description("shadow")]
Regular,
/// <summary>
/// The large
/// </summary>
[Description("shadow-lg")]
Large
}
}
41 changes: 41 additions & 0 deletions AdminLTEWithASPNETCore/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

namespace AdminLTEWithASPNETCore.Extensions
{
/// <summary>
/// Class EnumExtensions.
/// </summary>
public static class EnumExtensions
{
/// <summary>
/// Gets the description.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerationValue">The enumeration value.</param>
/// <returns>System.String.</returns>
/// <exception cref="ArgumentException">enumerationValue</exception>
public static string GetDescription<T>(this T enumerationValue) where T : struct
{
var type = enumerationValue.GetType();
if (!type.IsEnum)
{
throw new ArgumentException($"{nameof(enumerationValue)} must be of Enum type", nameof(enumerationValue));
}
var memberInfo = type.GetMember(enumerationValue.ToString());
if (memberInfo.Length > 0)
{
var attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);

if (attrs.Length > 0)
{
return ((DescriptionAttribute)attrs[0]).Description;
}
}
return enumerationValue.ToString();
}
}
}
39 changes: 39 additions & 0 deletions AdminLTEWithASPNETCore/Helpers/ScriptTagHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Razor.TagHelpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdminLTEWithASPNETCore.Helpers
{
[HtmlTargetElement("script", Attributes = "on-content-loaded")]
public class ScriptTagHelper : TagHelper
{
/// <summary>
/// Execute script only once document is loaded.
/// </summary>
public bool OnContentLoaded { get; set; } = false;

public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (!OnContentLoaded)
{
base.Process(context, output);
}
else
{
var content = output.GetChildContentAsync().Result;
var javascript = content.GetContent();

var sb = new StringBuilder();
sb.Append("document.addEventListener('DOMContentLoaded',");
sb.Append("function() {");
sb.Append(javascript);
sb.Append("});");

output.Content.SetHtmlContent(sb.ToString());
}
}
}
}
49 changes: 49 additions & 0 deletions AdminLTEWithASPNETCore/Models/Components/Boxes/BoxModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using AdminLTEWithASPNETCore.Enums.Components;
using AdminLTEWithASPNETCore.Extensions;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace AdminLTEWithASPNETCore.Models.Components.Boxes
{
/// <summary>
/// Class BoxModel.
/// </summary>
public class BoxModel
{
/// <summary>
/// Gets or sets the color of the background.
/// </summary>
/// <value>The color of the background.</value>
public string BackgroundColor { get; set; } = "bg-blue";
/// <summary>
/// Gets or sets the icon.
/// </summary>
/// <value>The icon.</value>
public string Icon { get; set; } = "fa-info";
/// <summary>
/// Gets or sets the text.
/// </summary>
/// <value>The text.</value>
public string Text { get; set; }
/// <summary>
/// Gets or sets the shadow.
/// </summary>
/// <value>The shadow.</value>
public ShadowType Shadow { get; set; } = ShadowType.None;
/// <summary>
/// Gets or sets the sub text.
/// </summary>
/// <value>The sub text.</value>
public string SubText { get; set; }

/// <summary>
/// Gets the CSS for the shadow
/// </summary>
/// <returns>Returns the CSS for the requested shadow</returns>
public string ShadowText => Shadow.GetDescription();
}
}
13 changes: 13 additions & 0 deletions AdminLTEWithASPNETCore/Models/Components/Boxes/ProgressBoxModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AdminLTEWithASPNETCore.Models.Components.Boxes
{
public class ProgressBoxModel : BoxModel
{
public int Percent { get; set; }
public string PercentDescription { get; set; }
}
}
Loading

0 comments on commit d3abaa7

Please sign in to comment.