Skip to content

Commit d3abaa7

Browse files
authored
Merge pull request #2 from erossini/feature/widgets
New widgets
2 parents 996255c + 603504d commit d3abaa7

File tree

472 files changed

+104046
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

472 files changed

+104046
-24
lines changed

AdminLTEWithASPNETCore/Controllers/HomeController.cs

+118-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using AdminLTEWithASPNETCore.Attributes;
22
using AdminLTEWithASPNETCore.Models;
3+
using AdminLTEWithASPNETCore.Models.Controllers;
34
using Microsoft.AspNetCore.Authorization;
45
using Microsoft.AspNetCore.Mvc;
56
using Microsoft.Extensions.Logging;
@@ -19,7 +20,123 @@ public HomeController(ILogger<HomeController> logger)
1920

2021
public IActionResult Index()
2122
{
22-
return View();
23+
HomeModel model = new HomeModel();
24+
model.Card = new Models.Components.Cards.CardModel()
25+
{
26+
Body = "This is an example of card",
27+
Links = new System.Collections.Generic.List<Models.Components.LinkModel>()
28+
{
29+
new Models.Components.LinkModel() {
30+
Target = "_blank",
31+
Text = "PureSourceCode",
32+
Url = "https://www.puresourcecode.com"
33+
},
34+
new Models.Components.LinkModel() {
35+
Target = "",
36+
Text = "Click here",
37+
Url = "#"
38+
}
39+
},
40+
Title = "Card test"
41+
};
42+
model.VisitorChart = new Models.Components.Charts.ChartModel()
43+
{
44+
ChartId = "visitor-chart",
45+
Height = 250,
46+
Labels = { "18th", "20th", "22nd", "24th", "26th", "28th", "30th" },
47+
ShowLegend = true,
48+
Datasets = new System.Collections.Generic.List<Models.Components.Charts.Dataset>()
49+
{
50+
new Models.Components.Charts.Dataset()
51+
{
52+
BackgroundColors = new System.Collections.Generic.List<string>() { "transparent" },
53+
BorderColor = "#007bff",
54+
Label = "This week",
55+
PointBackgroundColor = "#007bff",
56+
PointBorderColor = "#007bff",
57+
Fill = false,
58+
Data = new System.Collections.Generic.List<decimal>() {
59+
100, 120, 170, 167, 180, 177, 160
60+
}
61+
},
62+
new Models.Components.Charts.Dataset()
63+
{
64+
BackgroundColors = new System.Collections.Generic.List<string>() { "transparent" },
65+
BorderColor = "#ced4da",
66+
Label = "Last week",
67+
PointBackgroundColor = "#ced4da",
68+
PointBorderColor = "#ced4da",
69+
Fill = false,
70+
Data = new System.Collections.Generic.List<decimal>() {
71+
60, 80, 70, 67, 80, 77, 100
72+
}
73+
}
74+
}
75+
};
76+
model.SalesChart = new Models.Components.Charts.ChartModel()
77+
{
78+
ChartId = "salesChart",
79+
Height = 250,
80+
Labels = { "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" },
81+
ShowLegend = true,
82+
XAxes = new Models.Components.Charts.Axes()
83+
{
84+
ShowAxes = true,
85+
ShowGridLines = true
86+
},
87+
YAxes = new Models.Components.Charts.Axes()
88+
{
89+
ShowAxes = true,
90+
ShowGridLines = true
91+
},
92+
Datasets = new System.Collections.Generic.List<Models.Components.Charts.Dataset>()
93+
{
94+
new Models.Components.Charts.Dataset()
95+
{
96+
BackgroundColors = new System.Collections.Generic.List<string>() { "#007bff" },
97+
BorderColor = "#007bff",
98+
Label = "This year",
99+
Data = new System.Collections.Generic.List<decimal>()
100+
{
101+
1000, 2000, 3000, 2500, 2700, 2500, 3000
102+
}
103+
},
104+
new Models.Components.Charts.Dataset()
105+
{
106+
BackgroundColors = new System.Collections.Generic.List<string>() { "#ced4da" },
107+
BorderColor = "#ced4da",
108+
Label = "Last year",
109+
Data = new System.Collections.Generic.List<decimal>()
110+
{
111+
700, 1700, 2700, 2000, 1800, 1500, 2000
112+
}
113+
}
114+
}
115+
};
116+
model.SalesPie = new Models.Components.Charts.ChartModel()
117+
{
118+
ChartId = "pieSales",
119+
Labels = new System.Collections.Generic.List<string>() {
120+
"Instore Sales", "Download Sales", "Mail-Order Sales"
121+
},
122+
ShowLegend = true,
123+
Datasets = new System.Collections.Generic.List<Models.Components.Charts.Dataset>()
124+
{
125+
new Models.Components.Charts.Dataset()
126+
{
127+
BackgroundColors = new System.Collections.Generic.List<string>()
128+
{
129+
"#f56954", "#00a65a", "#f39c12"
130+
},
131+
Data = new System.Collections.Generic.List<decimal>()
132+
{
133+
30, 20, 10
134+
}
135+
}
136+
}
137+
};
138+
139+
return View("Index", model);
23140
}
24141

25142
[Breadcrumb("Privacy")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Microsoft.AspNetCore.Identity;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
8+
namespace AdminLTEWithASPNETCore.Controllers
9+
{
10+
public class ServicePageController : Controller
11+
{
12+
private readonly SignInManager<IdentityUser> _signInManager;
13+
14+
public ServicePageController(SignInManager<IdentityUser> signInManager)
15+
{
16+
_signInManager = signInManager;
17+
}
18+
19+
public IActionResult Lockscreen()
20+
{
21+
ViewBag.Reason = "lockscreen";
22+
return View();
23+
}
24+
25+
public async Task<IActionResult> LockscreenCheck(string password)
26+
{
27+
if (ModelState.IsValid && !string.IsNullOrEmpty(password))
28+
{
29+
var result = await _signInManager.PasswordSignInAsync(User.Identity?.Name, password, false, lockoutOnFailure: true);
30+
if (result.Succeeded)
31+
{
32+
return LocalRedirectPermanent("/Home");
33+
}
34+
if (result.RequiresTwoFactor)
35+
{
36+
return RedirectToPage("./LoginWith2fa", new { ReturnUrl = "/Home" });
37+
}
38+
else
39+
{
40+
return LocalRedirectPermanent("/ServicePage/Lockscreen");
41+
}
42+
}
43+
44+
return LocalRedirectPermanent("/ServicePage/Lockscreen");
45+
}
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace AdminLTEWithASPNETCore.Enums.Components
8+
{
9+
/// <summary>
10+
/// Enum PositionType
11+
/// </summary>
12+
public enum PositionType
13+
{
14+
/// <summary>
15+
/// The bottom
16+
/// </summary>
17+
[Description("bottom")]
18+
Bottom,
19+
/// <summary>
20+
/// The left
21+
/// </summary>
22+
[Description("left")]
23+
Left,
24+
/// <summary>
25+
/// The right
26+
/// </summary>
27+
[Description("right")]
28+
Right,
29+
/// <summary>
30+
/// The top
31+
/// </summary>
32+
[Description("top")]
33+
Top
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace AdminLTEWithASPNETCore.Enums.Components
8+
{
9+
/// <summary>
10+
/// Enum ShadowType
11+
/// </summary>
12+
public enum ShadowType
13+
{
14+
/// <summary>
15+
/// The none
16+
/// </summary>
17+
[Description("")]
18+
None,
19+
/// <summary>
20+
/// The small
21+
/// </summary>
22+
[Description("shadow-sm")]
23+
Small,
24+
/// <summary>
25+
/// The regular
26+
/// </summary>
27+
[Description("shadow")]
28+
Regular,
29+
/// <summary>
30+
/// The large
31+
/// </summary>
32+
[Description("shadow-lg")]
33+
Large
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace AdminLTEWithASPNETCore.Extensions
8+
{
9+
/// <summary>
10+
/// Class EnumExtensions.
11+
/// </summary>
12+
public static class EnumExtensions
13+
{
14+
/// <summary>
15+
/// Gets the description.
16+
/// </summary>
17+
/// <typeparam name="T"></typeparam>
18+
/// <param name="enumerationValue">The enumeration value.</param>
19+
/// <returns>System.String.</returns>
20+
/// <exception cref="ArgumentException">enumerationValue</exception>
21+
public static string GetDescription<T>(this T enumerationValue) where T : struct
22+
{
23+
var type = enumerationValue.GetType();
24+
if (!type.IsEnum)
25+
{
26+
throw new ArgumentException($"{nameof(enumerationValue)} must be of Enum type", nameof(enumerationValue));
27+
}
28+
var memberInfo = type.GetMember(enumerationValue.ToString());
29+
if (memberInfo.Length > 0)
30+
{
31+
var attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
32+
33+
if (attrs.Length > 0)
34+
{
35+
return ((DescriptionAttribute)attrs[0]).Description;
36+
}
37+
}
38+
return enumerationValue.ToString();
39+
}
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Microsoft.AspNetCore.Razor.TagHelpers;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace AdminLTEWithASPNETCore.Helpers
9+
{
10+
[HtmlTargetElement("script", Attributes = "on-content-loaded")]
11+
public class ScriptTagHelper : TagHelper
12+
{
13+
/// <summary>
14+
/// Execute script only once document is loaded.
15+
/// </summary>
16+
public bool OnContentLoaded { get; set; } = false;
17+
18+
public override void Process(TagHelperContext context, TagHelperOutput output)
19+
{
20+
if (!OnContentLoaded)
21+
{
22+
base.Process(context, output);
23+
}
24+
else
25+
{
26+
var content = output.GetChildContentAsync().Result;
27+
var javascript = content.GetContent();
28+
29+
var sb = new StringBuilder();
30+
sb.Append("document.addEventListener('DOMContentLoaded',");
31+
sb.Append("function() {");
32+
sb.Append(javascript);
33+
sb.Append("});");
34+
35+
output.Content.SetHtmlContent(sb.ToString());
36+
}
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using AdminLTEWithASPNETCore.Enums.Components;
2+
using AdminLTEWithASPNETCore.Extensions;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.ComponentModel.DataAnnotations;
6+
using System.Linq;
7+
using System.Reflection;
8+
using System.Threading.Tasks;
9+
10+
namespace AdminLTEWithASPNETCore.Models.Components.Boxes
11+
{
12+
/// <summary>
13+
/// Class BoxModel.
14+
/// </summary>
15+
public class BoxModel
16+
{
17+
/// <summary>
18+
/// Gets or sets the color of the background.
19+
/// </summary>
20+
/// <value>The color of the background.</value>
21+
public string BackgroundColor { get; set; } = "bg-blue";
22+
/// <summary>
23+
/// Gets or sets the icon.
24+
/// </summary>
25+
/// <value>The icon.</value>
26+
public string Icon { get; set; } = "fa-info";
27+
/// <summary>
28+
/// Gets or sets the text.
29+
/// </summary>
30+
/// <value>The text.</value>
31+
public string Text { get; set; }
32+
/// <summary>
33+
/// Gets or sets the shadow.
34+
/// </summary>
35+
/// <value>The shadow.</value>
36+
public ShadowType Shadow { get; set; } = ShadowType.None;
37+
/// <summary>
38+
/// Gets or sets the sub text.
39+
/// </summary>
40+
/// <value>The sub text.</value>
41+
public string SubText { get; set; }
42+
43+
/// <summary>
44+
/// Gets the CSS for the shadow
45+
/// </summary>
46+
/// <returns>Returns the CSS for the requested shadow</returns>
47+
public string ShadowText => Shadow.GetDescription();
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace AdminLTEWithASPNETCore.Models.Components.Boxes
7+
{
8+
public class ProgressBoxModel : BoxModel
9+
{
10+
public int Percent { get; set; }
11+
public string PercentDescription { get; set; }
12+
}
13+
}

0 commit comments

Comments
 (0)