mirror of
https://github.com/Stefan-5422/-T5-Elektrifikatsiya.git
synced 2026-09-04 00:45:58 +02:00
Merge pull request #20 from Stefan-5422/feature-Dashboard
Feature dashboard
This commit is contained in:
@@ -16,11 +16,21 @@
|
|||||||
{
|
{
|
||||||
BarOptions = new()
|
BarOptions = new()
|
||||||
{
|
{
|
||||||
HorizontalHeight = "72px"
|
HorizontalHeight = "72px",
|
||||||
|
DarkColors = new()
|
||||||
|
{
|
||||||
|
ItemColorOptions = new()
|
||||||
|
{
|
||||||
|
ActiveBackgroundColor = "#1a237e",
|
||||||
|
ActiveColor = "#1a237e",
|
||||||
|
HoverColor = "#1a237e",
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
ColorOptions = new()
|
ColorOptions = new()
|
||||||
{
|
{
|
||||||
Primary = "#0288D1",
|
Primary = "#1a237e",
|
||||||
Secondary = "#A65529",
|
Secondary = "#A65529",
|
||||||
Success = "#23C02E",
|
Success = "#23C02E",
|
||||||
Info = "#9BD8FE",
|
Info = "#9BD8FE",
|
||||||
@@ -31,7 +41,7 @@
|
|||||||
},
|
},
|
||||||
BackgroundOptions = new()
|
BackgroundOptions = new()
|
||||||
{
|
{
|
||||||
Primary = "#0288D1",
|
Primary = "#1a237e",
|
||||||
Secondary = "#A65529",
|
Secondary = "#A65529",
|
||||||
Success = "#23C02E",
|
Success = "#23C02E",
|
||||||
Info = "#9BD8FE",
|
Info = "#9BD8FE",
|
||||||
@@ -42,7 +52,12 @@
|
|||||||
},
|
},
|
||||||
InputOptions = new()
|
InputOptions = new()
|
||||||
{
|
{
|
||||||
CheckColor = "#0288D1",
|
CheckColor = "#1a237e",
|
||||||
|
},
|
||||||
|
TextColorOptions = new()
|
||||||
|
{
|
||||||
|
Dark = "#000000",
|
||||||
|
Primary = "#1a237e"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<Bar Breakpoint="Breakpoint.Desktop" NavigationBreakpoint="Breakpoint.Tablet" ThemeContrast="ThemeContrast.Dark"
|
<Bar Breakpoint="Breakpoint.Desktop" NavigationBreakpoint="Breakpoint.Tablet" ThemeContrast="ThemeContrast.Dark"
|
||||||
Mode="BarMode.VerticalInline" CollapseMode="BarCollapseMode.Small">
|
Mode="BarMode.VerticalInline" CollapseMode="BarCollapseMode.Small">
|
||||||
<BarToggler />
|
<BarToggler TextColor="TextColor.Primary" />
|
||||||
<BarBrand>
|
<BarBrand>
|
||||||
<BarItem>
|
<BarItem>
|
||||||
<BarLink To="">
|
<BarLink To="">
|
||||||
@@ -12,36 +12,30 @@
|
|||||||
<BarMenu>
|
<BarMenu>
|
||||||
<BarStart>
|
<BarStart>
|
||||||
<BarItem>
|
<BarItem>
|
||||||
<BarLink To="/">
|
<BarLink To="/" TextColor="TextColor.White">
|
||||||
<BarIcon IconName="IconName.Dashboard" />
|
<BarIcon Style="color:white" IconName="IconName.Dashboard" />
|
||||||
Dashboard
|
Dashboard
|
||||||
</BarLink>
|
</BarLink>
|
||||||
</BarItem>
|
</BarItem>
|
||||||
<BarItem>
|
<BarItem>
|
||||||
<BarDropdown @bind-Visible="pagesBarVisible">
|
<BarLink To="/" TextColor="TextColor.White">
|
||||||
<BarDropdownToggle>
|
<BarIcon Style="color:white" IconName="IconName.ShieldAlt" />
|
||||||
<BarIcon IconName="IconName.Edit" />
|
Admin
|
||||||
Pages
|
</BarLink>
|
||||||
</BarDropdownToggle>
|
</BarItem>
|
||||||
<BarDropdownMenu>
|
<BarItem>
|
||||||
<BarDropdownItem To="/simple-form">Simple Form</BarDropdownItem>
|
<BarLink To="/" TextColor="TextColor.White">
|
||||||
</BarDropdownMenu>
|
<BarIcon Style="color:white" IconName="IconName.Plug" />
|
||||||
</BarDropdown>
|
Add Plug
|
||||||
|
</BarLink>
|
||||||
</BarItem>
|
</BarItem>
|
||||||
</BarStart>
|
</BarStart>
|
||||||
<BarEnd>
|
<BarEnd>
|
||||||
<BarItem>
|
<BarItem>
|
||||||
<BarDropdown>
|
<BarLink To="/" TextColor="TextColor.White">
|
||||||
<BarDropdownToggle>
|
<BarIcon Style="color:white" IconName="IconName.Wrench" />
|
||||||
<BarIcon IconName="IconName.Smartphone" />
|
Settings
|
||||||
Apps
|
</BarLink>
|
||||||
</BarDropdownToggle>
|
|
||||||
<BarDropdownMenu>
|
|
||||||
<BarDropdownItem To="/apps/todo">
|
|
||||||
Todo
|
|
||||||
</BarDropdownItem>
|
|
||||||
</BarDropdownMenu>
|
|
||||||
</BarDropdown>
|
|
||||||
</BarItem>
|
</BarItem>
|
||||||
</BarEnd>
|
</BarEnd>
|
||||||
</BarMenu>
|
</BarMenu>
|
||||||
@@ -49,5 +43,6 @@
|
|||||||
@code {
|
@code {
|
||||||
private bool pagesBarVisible = true;
|
private bool pagesBarVisible = true;
|
||||||
|
|
||||||
RenderFragment customIcon =@<img src="/brand-logo.png" style="width:32px; height: 32px" />;
|
//TODO: replace logo png with transparent background one
|
||||||
|
RenderFragment customIcon =@<img src="/logo.png" style="width:32px; height: 32px" />;
|
||||||
}
|
}
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
@using Blazorise.Localization
|
|
||||||
|
|
||||||
<Bar @bind-Visible="@topbarVisible" Breakpoint="Breakpoint.Desktop" Background="Background.Primary" ThemeContrast="ThemeContrast.Light">
|
|
||||||
<BarBrand>
|
|
||||||
<BarItem>
|
|
||||||
<BarLink To="">
|
|
||||||
<BarIcon Margin="Margin.Is2.FromEnd" IconName="IconName.Dashboard" />
|
|
||||||
Elektrifikatsiya
|
|
||||||
</BarLink>
|
|
||||||
</BarItem>
|
|
||||||
</BarBrand>
|
|
||||||
<BarToggler />
|
|
||||||
<BarMenu>
|
|
||||||
<BarStart>
|
|
||||||
<BarItem>
|
|
||||||
<BarLink To="/">Home</BarLink>
|
|
||||||
</BarItem>
|
|
||||||
<BarItem>
|
|
||||||
<BarLink To="https://blazorise.com/docs/">Documentation</BarLink>
|
|
||||||
</BarItem>
|
|
||||||
<BarItem>
|
|
||||||
<BarDropdown>
|
|
||||||
<BarDropdownToggle>More</BarDropdownToggle>
|
|
||||||
<BarDropdownMenu>
|
|
||||||
<BarDropdownItem To="https://blazorise.com/docs/start/">
|
|
||||||
Quick-Start Guide
|
|
||||||
</BarDropdownItem>
|
|
||||||
<BarDropdownDivider />
|
|
||||||
<BarDropdownItem To="https://blazorise.com/docs/usage/">
|
|
||||||
Usage
|
|
||||||
</BarDropdownItem>
|
|
||||||
</BarDropdownMenu>
|
|
||||||
</BarDropdown>
|
|
||||||
</BarItem>
|
|
||||||
<BarItem>
|
|
||||||
<BarDropdown>
|
|
||||||
<BarDropdownToggle>Layout</BarDropdownToggle>
|
|
||||||
<BarDropdownMenu>
|
|
||||||
<BarDropdownItem Clicked="@(()=>OnLayoutTypeChecked("fixed-header"))">
|
|
||||||
@if ( LayoutType == "fixed-header" )
|
|
||||||
{
|
|
||||||
<Icon Name="IconName.CheckCircle" TextColor="TextColor.Success" />
|
|
||||||
}
|
|
||||||
Fixed Header
|
|
||||||
</BarDropdownItem>
|
|
||||||
<BarDropdownItem Clicked="@(()=>OnLayoutTypeChecked("fixed-header-footer-only"))">
|
|
||||||
@if ( LayoutType == "fixed-header-footer-only" )
|
|
||||||
{
|
|
||||||
<Icon Name="IconName.CheckCircle" TextColor="TextColor.Success" />
|
|
||||||
}
|
|
||||||
Fixed Header and Footer only
|
|
||||||
</BarDropdownItem>
|
|
||||||
<BarDropdownItem Clicked="@(()=>OnLayoutTypeChecked("sider-with-header-on-top"))">
|
|
||||||
@if ( LayoutType == "sider-with-header-on-top" )
|
|
||||||
{
|
|
||||||
<Icon Name="IconName.CheckCircle" TextColor="TextColor.Success" />
|
|
||||||
}
|
|
||||||
Sider with Header on top
|
|
||||||
</BarDropdownItem>
|
|
||||||
</BarDropdownMenu>
|
|
||||||
</BarDropdown>
|
|
||||||
</BarItem>
|
|
||||||
|
|
||||||
|
|
||||||
</BarStart>
|
|
||||||
<BarEnd>
|
|
||||||
<BarItem>
|
|
||||||
<BarDropdown RightAligned>
|
|
||||||
<BarDropdownToggle><Icon Name="IconName.Language" /></BarDropdownToggle>
|
|
||||||
<BarDropdownMenu>
|
|
||||||
@foreach ( var cultureInfo in LocalizationService.AvailableCultures )
|
|
||||||
{
|
|
||||||
<BarDropdownItem @key="@cultureInfo.Name" Clicked="@(()=>SelectCulture(cultureInfo.Name))">
|
|
||||||
@if ( cultureInfo.IsNeutralCulture )
|
|
||||||
{
|
|
||||||
@cultureInfo.EnglishName
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
@cultureInfo.Parent.EnglishName
|
|
||||||
}
|
|
||||||
</BarDropdownItem>
|
|
||||||
}
|
|
||||||
</BarDropdownMenu>
|
|
||||||
</BarDropdown>
|
|
||||||
</BarItem>
|
|
||||||
<BarItem>
|
|
||||||
<BarDropdown RightAligned>
|
|
||||||
<BarDropdownToggle><Icon Name="IconName.Tint" /> Theme</BarDropdownToggle>
|
|
||||||
<BarDropdownMenu Style="padding: 15px; min-width:550px;">
|
|
||||||
<Row>
|
|
||||||
<Column Margin="Margin.Is2.FromBottom">
|
|
||||||
<Field>
|
|
||||||
<Switch TValue="bool" Checked="@(Theme?.Enabled == true)" CheckedChanged="@ThemeEnabledChanged">Theme enabled</Switch>
|
|
||||||
</Field>
|
|
||||||
</Column>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
|
||||||
<Column Margin="Margin.Is2.FromBottom">
|
|
||||||
<Field>
|
|
||||||
<Check TValue="bool" Checked="@(Theme?.IsGradient == true)" CheckedChanged="@ThemeGradientChanged">Gradient colors</Check>
|
|
||||||
</Field>
|
|
||||||
<Field>
|
|
||||||
<Check TValue="bool" Checked="@(Theme?.IsRounded == true)" CheckedChanged="@ThemeRoundedChanged">Rounded elements</Check>
|
|
||||||
</Field>
|
|
||||||
</Column>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
|
||||||
<Column>
|
|
||||||
<Container Fluid>
|
|
||||||
<ThemeColorSelector Value="@(Theme?.ColorOptions?.Primary)" ValueChanged="@ThemeColorChanged"></ThemeColorSelector>
|
|
||||||
</Container>
|
|
||||||
</Column>
|
|
||||||
</Row>
|
|
||||||
</BarDropdownMenu>
|
|
||||||
</BarDropdown>
|
|
||||||
</BarItem>
|
|
||||||
<BarItem>
|
|
||||||
<BarLink To="https://github.com/Megabit/Blazorise">GitHub</BarLink>
|
|
||||||
</BarItem>
|
|
||||||
</BarEnd>
|
|
||||||
</BarMenu>
|
|
||||||
</Bar>
|
|
||||||
@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<bool> ThemeEnabledChanged { get; set; }
|
|
||||||
|
|
||||||
[Parameter] public EventCallback<bool> ThemeGradientChanged { get; set; }
|
|
||||||
|
|
||||||
[Parameter] public EventCallback<bool> ThemeRoundedChanged { get; set; }
|
|
||||||
|
|
||||||
[Parameter] public EventCallback<string> ThemeColorChanged { get; set; }
|
|
||||||
|
|
||||||
[Parameter] public string LayoutType { get; set; }
|
|
||||||
|
|
||||||
[Parameter] public EventCallback<string> LayoutTypeChanged { get; set; }
|
|
||||||
|
|
||||||
[Inject] protected ITextLocalizerService LocalizationService { get; set; }
|
|
||||||
|
|
||||||
[CascadingParameter] protected Theme Theme { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Elektrifikatsiya.Model;
|
using Elektrifikatsiya.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace Elektrifikatsiya.Database
|
namespace Elektrifikatsiya.Database
|
||||||
|
|||||||
@@ -18,10 +18,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Blazorise" Version="1.2.0" />
|
||||||
|
<PackageReference Include="Blazorise.Charts" Version="1.2.0" />
|
||||||
|
<PackageReference Include="Blazorise.Components" Version="1.2.0" />
|
||||||
|
<PackageReference Include="Blazorise.Material" Version="1.2.0" />
|
||||||
|
<PackageReference Include="Blazorise.Icons.Material" Version="1.2.0" />
|
||||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||||
<PackageReference Include="Blazorise" Version="1.1.*" />
|
|
||||||
<PackageReference Include="Blazorise.Material" Version="1.1.*" />
|
|
||||||
<PackageReference Include="Blazorise.Icons.Material" Version="1.1.*" />
|
|
||||||
<PackageReference Include="FluentResults" Version="3.15.1" />
|
<PackageReference Include="FluentResults" Version="3.15.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
|
||||||
|
|||||||
@@ -2,56 +2,7 @@
|
|||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
|
|
||||||
@if ( layoutType == "fixed-header" )
|
|
||||||
{
|
|
||||||
<Layout Sider>
|
|
||||||
<LayoutSider>
|
|
||||||
<LayoutSiderContent>
|
|
||||||
<SideMenu />
|
|
||||||
</LayoutSiderContent>
|
|
||||||
</LayoutSider>
|
|
||||||
<Layout>
|
|
||||||
<LayoutHeader Fixed>
|
|
||||||
<TopMenu ThemeEnabledChanged="@OnThemeEnabledChanged"
|
|
||||||
ThemeGradientChanged="@OnThemeGradientChanged"
|
|
||||||
ThemeRoundedChanged="@OnThemeRoundedChanged"
|
|
||||||
ThemeColorChanged="@OnThemeColorChanged"
|
|
||||||
@bind-LayoutType="@layoutType" />
|
|
||||||
</LayoutHeader>
|
|
||||||
<LayoutContent Padding="Padding.Is4.OnX.Is4.FromTop">
|
|
||||||
@Body
|
|
||||||
</LayoutContent>
|
|
||||||
</Layout>
|
|
||||||
</Layout>
|
|
||||||
}
|
|
||||||
else if ( layoutType == "fixed-header-footer-only" )
|
|
||||||
{
|
|
||||||
<Layout>
|
|
||||||
<LayoutHeader Fixed>
|
|
||||||
<TopMenu ThemeEnabledChanged="@OnThemeEnabledChanged"
|
|
||||||
ThemeGradientChanged="@OnThemeGradientChanged"
|
|
||||||
ThemeRoundedChanged="@OnThemeRoundedChanged"
|
|
||||||
ThemeColorChanged="@OnThemeColorChanged"
|
|
||||||
@bind-LayoutType="@layoutType" />
|
|
||||||
</LayoutHeader>
|
|
||||||
<LayoutContent Padding="Padding.Is4.OnX.Is4.FromTop">
|
|
||||||
@Body
|
|
||||||
</LayoutContent>
|
|
||||||
<LayoutFooter Fixed>
|
|
||||||
<FooterMenu></FooterMenu>
|
|
||||||
</LayoutFooter>
|
|
||||||
</Layout>
|
|
||||||
}
|
|
||||||
else if ( layoutType == "sider-with-header-on-top" )
|
|
||||||
{
|
|
||||||
<Layout>
|
|
||||||
<LayoutHeader Fixed>
|
|
||||||
<TopMenu ThemeEnabledChanged="@OnThemeEnabledChanged"
|
|
||||||
ThemeGradientChanged="@OnThemeGradientChanged"
|
|
||||||
ThemeRoundedChanged="@OnThemeRoundedChanged"
|
|
||||||
ThemeColorChanged="@OnThemeColorChanged"
|
|
||||||
@bind-LayoutType="@layoutType" />
|
|
||||||
</LayoutHeader>
|
|
||||||
<Layout Sider>
|
<Layout Sider>
|
||||||
<LayoutSider>
|
<LayoutSider>
|
||||||
<LayoutSiderContent>
|
<LayoutSiderContent>
|
||||||
@@ -64,5 +15,3 @@ else if ( layoutType == "sider-with-header-on-top" )
|
|||||||
</LayoutContent>
|
</LayoutContent>
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,122 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
|
@using Blazorise.Components;
|
||||||
|
@using Elektrifikatsiya.Models;
|
||||||
@inject IVersionProvider VersionProvider
|
@inject IVersionProvider VersionProvider
|
||||||
<Heading Size="HeadingSize.Is1" Margin="Margin.Is3.FromBottom">Blazorise</Heading>
|
|
||||||
|
|
||||||
<Paragraph>
|
<Row Padding="Padding.Is3">
|
||||||
Blazorise is a component library built on top of Blazor and CSS frameworks like <Anchor To="https://getbootstrap.com/" Target="Target.Blank">Bootstrap</Anchor>, <Anchor To="https://bulma.io/" Target="Target.Blank">Bulma</Anchor>, <Anchor To="https://ant.design/" Target="Target.Blank">Ant Design</Anchor>, and <Anchor To="http://daemonite.github.io/material/" Target="Target.Blank">Material</Anchor>. It can be used to build responsive, single-page web applications.
|
<Column ColumnSize="ColumnSize.Is6">
|
||||||
</Paragraph>
|
<ListView TItem="Device"
|
||||||
|
Data="@plugs"
|
||||||
|
TextField="@((_)=>(""))"
|
||||||
|
ValueField="@((_)=>(""))"
|
||||||
|
Mode="ListGroupMode.Static">
|
||||||
|
<ItemTemplate>
|
||||||
|
<ListGroupItem>
|
||||||
|
<Row>
|
||||||
|
<Column ColumnSize="ColumnSize.Is8">
|
||||||
|
<Row>
|
||||||
|
<Column ColumnSize="ColumnSize.Is7">
|
||||||
|
<Heading Size="HeadingSize.Is6" Margin="Margin.Is1.FromBottom">@context.Item.Name</Heading>
|
||||||
|
</Column>
|
||||||
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<Column>
|
||||||
|
<Small>User: @context.Item.User</Small>
|
||||||
|
<br />
|
||||||
|
<Small>Room: @context.Item.Room</Small>
|
||||||
|
</Column>
|
||||||
|
<Column ColumnSize="ColumnSize.Is5">
|
||||||
|
<Paragraph Margin="Margin.Is1.OnY">@context.Item.PowerUsage W</Paragraph>
|
||||||
|
</Column>
|
||||||
|
</Row>
|
||||||
|
</Column>
|
||||||
|
<Column ColumnSize="ColumnSize.Is4">
|
||||||
|
<Button Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Color="Color.Dark" Outline>
|
||||||
|
<BarIcon IconName="IconName.Bolt" />
|
||||||
|
</Button>
|
||||||
|
</Column>
|
||||||
|
</Row>
|
||||||
|
</ListGroupItem>
|
||||||
|
</ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</Column>
|
||||||
|
<Column ColumnSize="ColumnSize.Is6">
|
||||||
|
<ListView TItem="Event"
|
||||||
|
Data="@events"
|
||||||
|
TextField="@((_)=>(""))"
|
||||||
|
ValueField="@((_)=>(""))"
|
||||||
|
Mode="ListGroupMode.Static">
|
||||||
|
<ItemTemplate>
|
||||||
|
<Div Flex="Flex.InlineFlex.JustifyContent.Between" Width="Width.Is100">
|
||||||
|
<Heading Size="HeadingSize.Is6" Margin="Margin.Is2.FromBottom">@context.Item.EventName</Heading>
|
||||||
|
<Small>@context.Item.Date</Small>
|
||||||
|
</Div>
|
||||||
|
<Paragraph Margin="Margin.Is2.FromBottom">@context.Item.Description</Paragraph>
|
||||||
|
</ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</Column>
|
||||||
|
</Row>
|
||||||
|
<Row Padding="Padding.Is3">
|
||||||
|
<Column>
|
||||||
|
<Button Color="Color.Primary" Clicked="@(async () => await HandleRedraw())">Aktualisieren</Button>
|
||||||
|
<LineChart @ref="lineChart" TItem="double" />
|
||||||
|
</Column>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<Alert Color="Color.Info" Visible>
|
@code {
|
||||||
<Paragraph>
|
//TODO: insert new event here if plug produces one
|
||||||
This is a Blazorise Starting Template allowing you to quickly get started building your project!
|
List<Event> events = new List<Event>() { new Event("Placeholder", "Placeholder", DateTime.Now), new Event("Placeholder", "Placeholder", DateTime.Now), new Event("Placeholder", "Placeholder", DateTime.Now) };
|
||||||
</Paragraph>
|
//TODO: insert new Device here if user adds one
|
||||||
|
List<Device> plugs = new List<Device>() { 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") };
|
||||||
|
|
||||||
<Paragraph>
|
//code for graph
|
||||||
The bare minimum has been installed for you:
|
LineChart<double> lineChart;
|
||||||
<ul>
|
|
||||||
<li>Blazorise @($"v{VersionProvider.MilestoneVersion}")</li>
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
<li>The Blazorise Provider you have selected</li>
|
{
|
||||||
<li>The corresponding icon provider</li>
|
if (firstRender)
|
||||||
</ul>
|
{
|
||||||
However Blazorise has many more extensions at your disposal.
|
await HandleRedraw();
|
||||||
You can find them <Anchor To="https://blazorise.com/docs/extensions" Target="Target.Blank">here</Anchor>.
|
}
|
||||||
</Paragraph>
|
}
|
||||||
|
|
||||||
|
async Task HandleRedraw()
|
||||||
|
{
|
||||||
|
await lineChart.Clear();
|
||||||
|
|
||||||
|
await lineChart.AddLabelsDatasetsAndUpdate(Labels, GetLineChartDataset());
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: insert dataset of current and last voltage usages
|
||||||
|
LineChartDataset<double> GetLineChartDataset()
|
||||||
|
{
|
||||||
|
return new LineChartDataset<double>
|
||||||
|
{
|
||||||
|
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<string> backgroundColors = new List<string> { 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<string> borderColors = new List<string> { 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<double> RandomizeData()
|
||||||
|
{
|
||||||
|
var r = new Random(DateTime.Now.Millisecond);
|
||||||
|
|
||||||
|
return new List<double> {
|
||||||
|
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() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<Paragraph>
|
|
||||||
Please visit the official <Anchor To="https://bootstrapdemo.blazorise.com/" Target="Target.Blank">Blazorise Demo</Anchor> for component examples.
|
|
||||||
</Paragraph>
|
|
||||||
<Paragraph>
|
|
||||||
Please visit the official <Anchor To="https://blazorise.com/docs/" Target="Target.Blank">Blazorise Documentation</Anchor> to learn more about the available components.
|
|
||||||
</Paragraph>
|
|
||||||
</Alert>
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
<script src="js/material/material.min.js"></script>
|
<script src="js/material/material.min.js"></script>
|
||||||
<script src="_framework/blazor.server.js"></script>
|
<script src="_framework/blazor.server.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.1/chart.min.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.blazorExtensions = {
|
window.blazorExtensions = {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Blazorise;
|
using Blazorise;
|
||||||
|
using Blazorise.Bootstrap;
|
||||||
using Blazorise.Icons.Material;
|
using Blazorise.Icons.Material;
|
||||||
using Blazorise.Material;
|
using Blazorise.Material;
|
||||||
|
|
||||||
@@ -46,3 +47,9 @@ void AddBlazorise(IServiceCollection services)
|
|||||||
.AddMaterialProviders()
|
.AddMaterialProviders()
|
||||||
.AddMaterialIcons();
|
.AddMaterialIcons();
|
||||||
}
|
}
|
||||||
|
builder.Services
|
||||||
|
.AddBlazorise(options =>
|
||||||
|
{
|
||||||
|
options.Immediate = true;
|
||||||
|
})
|
||||||
|
.AddBootstrapProviders();
|
||||||
@@ -9,3 +9,4 @@
|
|||||||
|
|
||||||
@using Elektrifikatsiya
|
@using Elektrifikatsiya
|
||||||
@using Blazorise
|
@using Blazorise
|
||||||
|
@using Blazorise.Charts
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 264 KiB |
Reference in New Issue
Block a user