diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/App.razor b/src/Elektrifikatsiya/Elektrifikatsiya/App.razor index 9c0ed48..cf7da0a 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/App.razor +++ b/src/Elektrifikatsiya/Elektrifikatsiya/App.razor @@ -1,48 +1,63 @@  - - - - - -

Sorry, there's nothing at this address.

-
-
- - - + + + + + +

Sorry, there's nothing at this address.

+
+
+ + +
@code { - private Theme theme = new() - { - BarOptions = new() - { - HorizontalHeight = "72px" - }, - ColorOptions = new() - { - Primary = "#0288D1", - Secondary = "#A65529", - Success = "#23C02E", - Info = "#9BD8FE", - Warning = "#F8B86C", - Danger = "#F95741", - Light = "#F0F0F0", - Dark = "#535353", - }, - BackgroundOptions = new() - { - Primary = "#0288D1", - Secondary = "#A65529", - Success = "#23C02E", - Info = "#9BD8FE", - Warning = "#F8B86C", - Danger = "#F95741", - Light = "#F0F0F0", - Dark = "#535353", - }, - InputOptions = new() - { - CheckColor = "#0288D1", - } - }; + private Theme theme = new() + { + BarOptions = new() + { + HorizontalHeight = "72px", + DarkColors = new() + { + ItemColorOptions = new() + { + ActiveBackgroundColor = "#1a237e", + ActiveColor = "#1a237e", + HoverColor = "#1a237e", + } + + } + }, + ColorOptions = new() + { + Primary = "#1a237e", + Secondary = "#A65529", + Success = "#23C02E", + Info = "#9BD8FE", + Warning = "#F8B86C", + Danger = "#F95741", + Light = "#F0F0F0", + Dark = "#535353", + }, + BackgroundOptions = new() + { + Primary = "#1a237e", + Secondary = "#A65529", + Success = "#23C02E", + Info = "#9BD8FE", + Warning = "#F8B86C", + Danger = "#F95741", + Light = "#F0F0F0", + Dark = "#535353", + }, + InputOptions = new() + { + CheckColor = "#1a237e", + }, + TextColorOptions = new() + { + Dark = "#000000", + Primary = "#1a237e" + } + }; } \ No newline at end of file diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Components/Layout/SideMenu.razor b/src/Elektrifikatsiya/Elektrifikatsiya/Components/Layout/SideMenu.razor index 7450e71..3691e03 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Components/Layout/SideMenu.razor +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Components/Layout/SideMenu.razor @@ -1,6 +1,6 @@  - + @@ -12,36 +12,30 @@ - - + + Dashboard + + + + + + Admin - - - - Pages - - - Simple Form - - + + + Add Plug + - - - - Apps - - - - Todo - - - + + + Settings + @@ -49,5 +43,6 @@ @code { private bool pagesBarVisible = true; - RenderFragment customIcon =@; + //TODO: replace logo png with transparent background one + RenderFragment customIcon =@; } \ No newline at end of file diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Components/Layout/TopMenu.razor b/src/Elektrifikatsiya/Elektrifikatsiya/Components/Layout/TopMenu.razor deleted file mode 100644 index 2fd68fd..0000000 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Components/Layout/TopMenu.razor +++ /dev/null @@ -1,163 +0,0 @@ -@using Blazorise.Localization - - - - - - - Elektrifikatsiya - - - - - - - - Home - - - Documentation - - - - More - - - Quick-Start Guide - - - - Usage - - - - - - - Layout - - - @if ( LayoutType == "fixed-header" ) - { - - } - Fixed Header - - - @if ( LayoutType == "fixed-header-footer-only" ) - { - - } - Fixed Header and Footer only - - - @if ( LayoutType == "sider-with-header-on-top" ) - { - - } - Sider with Header on top - - - - - - - - - - - - - @foreach ( var cultureInfo in LocalizationService.AvailableCultures ) - { - - @if ( cultureInfo.IsNeutralCulture ) - { - @cultureInfo.EnglishName - } - else - { - @cultureInfo.Parent.EnglishName - } - - } - - - - - - Theme - - - - - Theme enabled - - - - - - - Gradient colors - - - Rounded elements - - - - - - - - - - - - - - - GitHub - - - - -@code { - protected override async Task OnInitializedAsync() - { - await SelectCulture( "en-US" ); - - await base.OnInitializedAsync(); - } - - Task SelectCulture( string name ) - { - LocalizationService.ChangeLanguage( name ); - - return Task.CompletedTask; - } - - private bool topbarVisible = false; - - Task OnLayoutTypeChecked( string layoutType ) - { - LayoutType = layoutType; - - return LayoutTypeChanged.InvokeAsync( layoutType ); - } - - [Parameter] public EventCallback ThemeEnabledChanged { get; set; } - - [Parameter] public EventCallback ThemeGradientChanged { get; set; } - - [Parameter] public EventCallback ThemeRoundedChanged { get; set; } - - [Parameter] public EventCallback ThemeColorChanged { get; set; } - - [Parameter] public string LayoutType { get; set; } - - [Parameter] public EventCallback LayoutTypeChanged { get; set; } - - [Inject] protected ITextLocalizerService LocalizationService { get; set; } - - [CascadingParameter] protected Theme Theme { get; set; } -} \ No newline at end of file diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Database/DeviceManagementDatabaseContext.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Database/DeviceManagementDatabaseContext.cs index f182b24..693b9e5 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Database/DeviceManagementDatabaseContext.cs +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Database/DeviceManagementDatabaseContext.cs @@ -1,4 +1,4 @@ -using Elektrifikatsiya.Model; +using Elektrifikatsiya.Models; using Microsoft.EntityFrameworkCore; namespace Elektrifikatsiya.Database diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Elektrifikatsiya.csproj b/src/Elektrifikatsiya/Elektrifikatsiya/Elektrifikatsiya.csproj index 526f375..2912297 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Elektrifikatsiya.csproj +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Elektrifikatsiya.csproj @@ -18,10 +18,12 @@ + + + + + - - - diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Layouts/MainLayout.razor b/src/Elektrifikatsiya/Elektrifikatsiya/Layouts/MainLayout.razor index 7d66732..362810d 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Layouts/MainLayout.razor +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Layouts/MainLayout.razor @@ -2,67 +2,16 @@ @inherits LayoutComponentBase -@if ( layoutType == "fixed-header" ) -{ - - - - - - - - - - - - @Body - - - -} -else if ( layoutType == "fixed-header-footer-only" ) -{ - - - - - - @Body - - - - - -} -else if ( layoutType == "sider-with-header-on-top" ) -{ - - - - - - - - - - - - - @Body - - - - -} \ No newline at end of file + + + + + + + + + + @Body + + + \ No newline at end of file diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Model/Device.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Model/Device.cs deleted file mode 100644 index 65cdf34..0000000 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Model/Device.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Net; - -namespace Elektrifikatsiya.Model; - -public class Device -{ - [Key] - public string Key { get; private set; } - [Required] - public string Name { get; private set; } = string.Empty; - [Required] - public IPAddress Address { get; private set; } - - public Device(string key, IPAddress address) - { - Key = key; - Address = address; - } -} \ No newline at end of file diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Models/Device.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Models/Device.cs new file mode 100644 index 0000000..0176b78 --- /dev/null +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Models/Device.cs @@ -0,0 +1,27 @@ +using System.ComponentModel.DataAnnotations; +using System.Net; + +namespace Elektrifikatsiya.Models; + +public class Device +{ + [Key] + public string Key { get; private set; } + [Required] + public string Name { get; private set; } = string.Empty; + [Required] + public IPAddress Address { get; private set; } + public int PowerUsage { get; set; } + public string User { get; set; } + public string Room { get; set; } + + public Device(string key, string name, IPAddress address, int powerUsage, string user, string room) + { + Key = key; + Name = name; + Address = address; + PowerUsage = powerUsage; + User = user; + Room = room; + } +} \ No newline at end of file diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Models/Event.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Models/Event.cs new file mode 100644 index 0000000..5c76207 --- /dev/null +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Models/Event.cs @@ -0,0 +1,18 @@ +namespace Elektrifikatsiya.Models +{ + public class Event + { + public string EventName { get; set; } + public string Description { get; set; } + public DateTime Date { get; set; } + + //if Plug Class implemented -> Property for which plug this event is from + + public Event(string eventName, string description, DateTime date) + { + EventName = eventName; + Description = description; + Date = date; + } + } +} diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Dashboard.razor b/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Dashboard.razor index d918c4b..3cd8102 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Dashboard.razor +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Dashboard.razor @@ -1,31 +1,122 @@ @page "/" +@using Blazorise.Components; +@using Elektrifikatsiya.Models; @inject IVersionProvider VersionProvider -Blazorise - - Blazorise is a component library built on top of Blazor and CSS frameworks like Bootstrap, Bulma, Ant Design, and Material. It can be used to build responsive, single-page web applications. - + + + + + + + + + + @context.Item.Name + + + + + User: @context.Item.User +
+ Room: @context.Item.Room +
+ + @context.Item.PowerUsage W + +
+
+ + + +
+
+
+
+
+ + + +
+ @context.Item.EventName + @context.Item.Date +
+ @context.Item.Description +
+
+
+
+ + + + + + - - - This is a Blazorise Starting Template allowing you to quickly get started building your project! - +@code { + //TODO: insert new event here if plug produces one + List events = new List() { new Event("Placeholder", "Placeholder", DateTime.Now), new Event("Placeholder", "Placeholder", DateTime.Now), new Event("Placeholder", "Placeholder", DateTime.Now) }; + //TODO: insert new Device here if user adds one + List plugs = new List() { new Device("Placeholder", "Plug", System.Net.IPAddress.Broadcast, 60, "Oldin", "4AHINF"), new Device("Placeholder", "Plug", System.Net.IPAddress.Broadcast, 60, "Oldin", "4AHINF"), new Device("Placeholder", "Plug", System.Net.IPAddress.Broadcast, 60, "Oldin", "4AHINF") }; - - The bare minimum has been installed for you: -
    -
  • Blazorise @($"v{VersionProvider.MilestoneVersion}")
  • -
  • The Blazorise Provider you have selected
  • -
  • The corresponding icon provider
  • -
- However Blazorise has many more extensions at your disposal. - You can find them here. -
+ //code for graph + LineChart lineChart; + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await HandleRedraw(); + } + } + + async Task HandleRedraw() + { + await lineChart.Clear(); + + await lineChart.AddLabelsDatasetsAndUpdate(Labels, GetLineChartDataset()); + } + + //TODO: insert dataset of current and last voltage usages + LineChartDataset GetLineChartDataset() + { + return new LineChartDataset + { + Label = "# of random number in thousands", + Data = RandomizeData(), + BackgroundColor = backgroundColors, + BorderColor = borderColors, + Fill = true, + PointRadius = 3, + CubicInterpolationMode = "monotone", + }; + } + + string[] Labels = { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" }; + List backgroundColors = new List { ChartColor.FromRgba(255, 99, 132, 0.2f), ChartColor.FromRgba(54, 162, 235, 0.2f), ChartColor.FromRgba(255, 206, 86, 0.2f), ChartColor.FromRgba(75, 192, 192, 0.2f), ChartColor.FromRgba(153, 102, 255, 0.2f), ChartColor.FromRgba(255, 159, 64, 0.2f) }; + List borderColors = new List { ChartColor.FromRgba(255, 99, 132, 1f), ChartColor.FromRgba(54, 162, 235, 1f), ChartColor.FromRgba(255, 206, 86, 1f), ChartColor.FromRgba(75, 192, 192, 1f), ChartColor.FromRgba(153, 102, 255, 1f), ChartColor.FromRgba(255, 159, 64, 1f) }; + + List RandomizeData() + { + var r = new Random(DateTime.Now.Millisecond); + + return new List { + r.Next( 3, 50 ) * r.NextDouble(), + r.Next( 3, 50 ) * r.NextDouble(), + r.Next( 3, 50 ) * r.NextDouble(), + r.Next( 3, 50 ) * r.NextDouble(), + r.Next( 3, 50 ) * r.NextDouble(), + r.Next( 3, 50 ) * r.NextDouble() }; + } +} - - Please visit the official Blazorise Demo for component examples. - - - Please visit the official Blazorise Documentation to learn more about the available components. - -
diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Dashboard.razor.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Dashboard.razor.cs new file mode 100644 index 0000000..ed25e93 --- /dev/null +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Dashboard.razor.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using System.Net.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.Web.Virtualization; +using Microsoft.JSInterop; +using Elektrifikatsiya; +using Blazorise; + +namespace Elektrifikatsiya.Pages +{ + public partial class Dashboard + { + string bgcolor { get; set; } = "00f"; // (starting value) + void SetColor() + { + bgcolor = "#fd7"; + StateHasChanged(); // may not be required, but I'm at work right now, so can't check + } + } +} \ No newline at end of file diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Pages/_Layout.cshtml b/src/Elektrifikatsiya/Elektrifikatsiya/Pages/_Layout.cshtml index d698356..45c56e9 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Pages/_Layout.cshtml +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Pages/_Layout.cshtml @@ -40,6 +40,7 @@ +