Merge branch 'feature-Dashboard' of https://github.com/Stefan-5422/-T5-Elektrifikatsiya into feature-Dashboard

This commit is contained in:
Silence
2023-04-19 09:50:03 +02:00
4 changed files with 218 additions and 213 deletions
@@ -23,18 +23,18 @@
Admin Admin
</BarLink> </BarLink>
</BarItem> </BarItem>
<BarItem>
<BarLink To="/addplug" TextColor="TextColor.White">
<BarIcon Style="color:white" IconName="IconName.Plug" />
Add Plug
</BarLink>
</BarItem>
<BarItem> <BarItem>
<BarLink To="/settings" TextColor="TextColor.White"> <BarLink To="/settings" TextColor="TextColor.White">
<BarIcon Style="color:white" IconName="IconName.Wrench" /> <BarIcon Style="color:white" IconName="IconName.Wrench" />
Settings Settings
</BarLink> </BarLink>
</BarItem> </BarItem>
<BarItem>
<BarLink To="/addplug" TextColor="TextColor.White">
<BarIcon Style="color:white" IconName="IconName.Plug" />
Add Plug
</BarLink>
</BarItem>
</BarStart> </BarStart>
<BarEnd> <BarEnd>
<BarItem> <BarItem>
@@ -2,17 +2,16 @@
@inherits LayoutComponentBase @inherits LayoutComponentBase
<Image Source="logo.png" Width="Width.Is50" Height="Height.Is50"> </Image> <Image Source="logo.png" Width="Width.Is50" Height="Height.Is50"> </Image>
<Card Width="Width.Is50" Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Padding="Padding.Is5"> <Card Width="Width.Is50" Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Padding="Padding.Is5">
<Field Width="Width.Is25" Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle"> <Column ColumnSize="ColumnSize.Is6.OnDesktop.Is12.Is3.WithOffset">
<TextEdit Placeholder="Username" /> <Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle">
</Field> <TextEdit Placeholder="Username" />
<Field Width="Width.Is25" Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle"> </Field>
<TextEdit Role="TextRole.Password" Placeholder="Password" /> <Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle">
</Field> <TextEdit Role="TextRole.Password" Placeholder="Password" />
<Button Width="Width.Is25" Color="Color.Primary" Clicked="Clicked" Position="Position.Relative.Bottom.Is50.Start.Is50.Translate.MiddleX" >Login</Button> </Field>
<Button Color="Color.Primary" Position="Position.Relative.Bottom.Is50.Start.Is50.Translate.MiddleX">Login</Button>
</Column>
</Card> </Card>
@code { @code {
private void Clicked()
{
Debug.WriteLine("Button was clicked!");
}
} }
@@ -9,88 +9,88 @@
@inject IDeviceManagmentService DeviceManagmentService @inject IDeviceManagmentService DeviceManagmentService
@inject IAuthenticationService AuthenticationService @inject IAuthenticationService AuthenticationService
<Row Style="height:50%; width:100%" Padding="Padding.Is3.OnDesktop.Is5.FromStart.OnMobile"> <Row Style="height:50%; width:100%" Padding="Padding.Is3.OnDesktop.Is5.FromStart.OnMobile">
<Row Style="height:90%; width:100%"> <Row Style="height:90%; width:100%">
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is1"></Column>
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is12">
<Bar Breakpoint="Breakpoint.Desktop"
Background="Background.White"
ThemeContrast="ThemeContrast.None"
Shadow="Shadow.Remove"
Border="Border.Is1.RoundedTop">
<BarBrand>
<Column ColumnSize="ColumnSize.Is9">
Add a plug via wifi
</Column>
<Column ColumnSize="ColumnSize.Is3.Is1.WithOffset">
<LoadingIndicator @bind-Visible="@visible">
</LoadingIndicator>
</Column>
</BarBrand>
</Bar>
<ListView Class="w-100"
TItem="IPAddress"
Data="@ipAddresses"
TextField="@((_)=>(""))"
ValueField="@((_)=>(""))"
Mode="ListGroupMode.Static"
Style="border-radius: 0px 0px">
<ItemTemplate>
<ListGroupItem>
<Row>
<Column ColumnSize="ColumnSize.Is6">
<Row>
</Row>
<Row Width="Width.Is100">
<Column>
<Small>IP: @context.Item</Small>
</Column>
</Row>
</Column>
<Column ColumnSize="ColumnSize.Is4.Is2.WithOffset">
<Button Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Color="Color.Dark" Clicked="@(async () => await DeviceManagmentService.RegisterDevice(context.Item,(await AuthenticationService.GetUserAsync()).ValueOrDefault))" Outline>
<BarIcon IconName="IconName.Add" />
</Button>
</Column>
</Row>
</ListGroupItem>
</ItemTemplate>
</ListView>
</Column>
</Row>
</Row>
<Row Style="height:50%; width:100%; border-top-style:solid; border-top-color:#1a237e" Padding="Padding.Is3.OnDesktop.Is5.FromStart.OnMobile">
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is1"></Column> <Column ColumnSize="ColumnSize.Is4.OnDesktop.Is1"></Column>
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is12"> <Column ColumnSize="ColumnSize.Is4.OnDesktop.Is12">
<Row Style="height:15%; width:100%"></Row> <Bar Breakpoint="Breakpoint.Desktop"
<Row Style="height:10%; width:100%"> Background="Background.White"
<Bar Breakpoint="Breakpoint.Desktop" ThemeContrast="ThemeContrast.None"
Background="Background.White" Shadow="Shadow.Remove"
ThemeContrast="ThemeContrast.None" Border="Border.Is1.RoundedTop">
Shadow="Shadow.Remove" <BarBrand>
Border="Border.Is1.RoundedTop" <Column ColumnSize="ColumnSize.Is9">
Style="width:100%"> Add a plug via wifi
<BarBrand> </Column>
Add a plug via IP <Column ColumnSize="ColumnSize.Is3.Is6.WithOffset">
</BarBrand> <LoadingIndicator @bind-Visible="@visible">
</Bar> </LoadingIndicator>
<ListGroup Style="width:100%; border-radius: 0px 0px"> </Column>
<ListGroupItem Color="Color.Default"> </BarBrand>
<Form> </Bar>
<Field Horizontal> <ListView Class="w-100"
<FieldBody ColumnSize="ColumnSize.Is12"> TItem="IPAddress"
<TextEdit Placeholder="Enter the Device IP here" /> Data="@ipAddresses"
<br> TextField="@((_)=>(""))"
<Button style="background-color:#1a237e; color:white" Type="ButtonType.Submit" PreventDefaultOnSubmit>CONNECT</Button> ValueField="@((_)=>(""))"
</FieldBody> Mode="ListGroupMode.Static"
</Field> Style="border-radius: 0px 0px">
</Form> <ItemTemplate>
</ListGroupItem> <ListGroupItem>
</ListGroup> <Row>
</Row> <Column ColumnSize="ColumnSize.Is8">
<Row Style="height:75%; width:100%"></Row> <Row>
</Row>
<Row Width="Width.Is100">
<Column>
<Small>IP: @context.Item</Small>
</Column>
</Row>
</Column>
<Column ColumnSize="ColumnSize.Is4">
<Button Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Color="Color.Dark" Clicked="@(async () => await DeviceManagmentService.RegisterDevice(context.Item,(await AuthenticationService.GetUserAsync()).ValueOrDefault))" Outline>
<BarIcon IconName="IconName.Add" />
</Button>
</Column>
</Row>
</ListGroupItem>
</ItemTemplate>
</ListView>
</Column> </Column>
</Row> </Row>
</Row>
<Row Style="height:50%; width:100%; border-top-style:solid; border-top-color:#1a237e" Padding="Padding.Is3.OnDesktop.Is5.FromStart.OnMobile">
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is1"></Column>
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is12">
<Row Style="height:15%; width:100%"></Row>
<Row Style="height:10%; width:100%">
<Bar Breakpoint="Breakpoint.Desktop"
Background="Background.White"
ThemeContrast="ThemeContrast.None"
Shadow="Shadow.Remove"
Border="Border.Is1.RoundedTop"
Style="width:100%">
<BarBrand>
Add a plug via IP
</BarBrand>
</Bar>
<ListGroup Style="width:100%; border-radius: 0px 0px">
<ListGroupItem Color="Color.Default">
<Form>
<Field Horizontal>
<FieldBody ColumnSize="ColumnSize.Is12">
<TextEdit Placeholder="Enter the Device IP here" />
<br>
<Button style="background-color:#1a237e; color:white" Type="ButtonType.Submit" PreventDefaultOnSubmit>CONNECT</Button>
</FieldBody>
</Field>
</Form>
</ListGroupItem>
</ListGroup>
</Row>
<Row Style="height:75%; width:100%"></Row>
</Column>
</Row>
@code { @code {
List<IPAddress> ipAddresses = new List<IPAddress>(); List<IPAddress> ipAddresses = new List<IPAddress>();
@@ -106,7 +106,7 @@
System.Timers.Timer aTimer = new System.Timers.Timer(1000); System.Timers.Timer aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed += (_, _) => { aTimer.Elapsed += (_, _) => {
DateTime dateTime = DateTime.UtcNow; DateTime dateTime = DateTime.UtcNow;
if(dateTime >= time.AddSeconds(5)) if(dateTime >= time.AddSeconds(3))
{ {
visible = false; visible = false;
InvokeAsync(StateHasChanged); InvokeAsync(StateHasChanged);
@@ -3,129 +3,131 @@
@using Elektrifikatsiya.Models; @using Elektrifikatsiya.Models;
@using System.Net @using System.Net
<Div> <Div>
<Row Style="width: 100%; height: 100%"> <Row Style="width: 100%; height: 100%" Margin="Margin.Is3.FromTop.OnMobile" Padding="Padding.Is4.FromStart.OnMobile">
<Div Display="Display.Flex.Row.OnDesktop" Margin=" Margin.Is3.FromBottom" Width="Width.Is100"> <Div Display="Display.Flex.Row.OnDesktop" Margin=" Margin.Is3.FromBottom" Width="Width.Is100">
<Column ColumnSize="ColumnSize.Is5.OnDesktop.Is12.OnMobile"> <Column ColumnSize="ColumnSize.Is5.OnDesktop.Is12.OnMobile">
<Bar Breakpoint="Breakpoint.Desktop" <Bar Breakpoint="Breakpoint.Desktop"
Background="Background.White" Background="Background.White"
ThemeContrast="ThemeContrast.None" ThemeContrast="ThemeContrast.None"
Shadow="Shadow.Remove" Shadow="Shadow.Remove"
Border="Border.Is1.RoundedTop"> Border="Border.Is1.RoundedTop">
<BarBrand> <BarBrand>
Plugs Plugs
</BarBrand> </BarBrand>
</Bar> </Bar>
<ListView TItem="Device" <ListView TItem="Device"
Data="@plugs" Data="@plugs"
TextField="@((_)=>(""))" TextField="@((_)=>(""))"
ValueField="@((_)=>(""))" ValueField="@((_)=>(""))"
Style="border-radius: 0px 0px" Style="border-radius: 0px 0px"
Height="100%" Height="100%"
MaxHeight="90%"> MaxHeight="90%">
<ItemTemplate> <ItemTemplate>
<ListGroupItem Border="Border.OnBottom"> <ListGroupItem Border="Border.OnBottom">
<Row>
<Column ColumnSize="ColumnSize.Is6">
<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>
</Row>
</Column>
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is7.OnMobile">
<Button Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Color="Color.Dark" Outline>
<BarIcon IconName="IconName.Bolt" />
</Button>
</Column>
<br />
<br />
<Row> <Row>
<Column ColumnSize="ColumnSize.Is6">
<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>
</Row>
</Column>
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is7.OnMobile">
<Button Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Color="Color.Dark" Outline>
<BarIcon IconName="IconName.Delete" />
</Button>
</Column>
<br />
<br />
<Row>
<Column ColumnSize="ColumnSize.Is1.OnDesktop"> <Column ColumnSize="ColumnSize.Is1.OnDesktop">
<Button Position="Position.Absolute.Top.Is50.Start.Is100.Translate.Middle" Color="Color.Dark" Outline> <Button @onclick="Toggle" Position="Position.Absolute.Top.Is50.Start.Is100.Translate.Middle" Color="Color.Dark" Outline>
<BarIcon IconName="IconName.Pen" /> <BarIcon IconName="IconName.Pen" />
</Button> </Button>
</Column> </Column>
</Row> </Row>
</Row> </Row>
</ListGroupItem> </ListGroupItem>
</ItemTemplate> </ItemTemplate>
</ListView> </ListView>
</Column> </Column>
<Column ColumnSize="ColumnSize.Is6.OnDesktop.Is12.OnMobile" Margin="Margin.Is3.OnMobile"> <Column ColumnSize="ColumnSize.Is6.OnDesktop.Is12.OnMobile" Margin="Margin.Is3.FromTop.OnMobile" Padding="Padding.Is4.FromStart.OnMobile">
<Field> <Div hidden="@hideButtonSettings">
<FieldLabel> <Field>
<h5> <FieldLabel>
Plug Name <h5>
</h5> Plug Name
<Paragraph> </h5>
Here you can change the Name of your Plug <Paragraph>
</Paragraph> Here you can change the name of your plug
</FieldLabel> </Paragraph>
<TextEdit Placeholder="Enter Name" /> </FieldLabel>
</Field> <TextEdit Placeholder="Enter Name" />
<br /> </Field>
<br /> <br />
<Field> <br />
<FieldLabel> <Field>
<h5> <FieldLabel>
Change Max Output <h5>
</h5> Change Max Output
<Paragraph> </h5>
Here you can limit how much Power your Plug uses <Paragraph>
</Paragraph> Here you can limit how much power your plug uses
</FieldLabel> </Paragraph>
<TextEdit Placeholder="Enter Max Output" /> </FieldLabel>
</Field> <TextEdit Placeholder="Enter Max Output" />
<br /> </Field>
<br /> <br />
<Field> <br />
<FieldLabel> <Field>
<h5> <FieldLabel>
Electricity Price <h5>
</h5> Select Room
<Paragraph> </h5>
Here you enter your electricity price. This is gonna calculate the overall Price of your System <Paragraph>
</Paragraph> Here you select or change the room the plug belongs to.
</FieldLabel> </Paragraph>
<TextEdit Placeholder="Enter Electricity Price" /> </FieldLabel>
</Field> <br />
<br /> <Dropdown Display="Display.InlineBlock">
<br /> <DropdownToggle Color="Color.Primary" Width="Width.Is100">Rooms</DropdownToggle>
<Field> <DropdownMenu>
<FieldLabel> <DropdownItem>Room 1</DropdownItem>
<h5> <DropdownDivider />
Select Room <DropdownItem>Room 2</DropdownItem>
</h5> <DropdownDivider />
<Paragraph> <DropdownItem>Room 3</DropdownItem>
Here you select or change the Room where you use your Plug. </DropdownMenu>
</Paragraph> </Dropdown>
</FieldLabel> </Field>
<br /> </Div>
<Dropdown Display="Display.InlineBlock"> <Div hidden="@(!hideButtonSettings)">
<DropdownToggle Color="Color.Primary" Width="Width.Is100">Rooms</DropdownToggle> <Field>
<DropdownMenu> <FieldLabel>
<DropdownItem>Room 1</DropdownItem> <h5>
<DropdownDivider /> Electricity Price
<DropdownItem>Room 2</DropdownItem> </h5>
<DropdownDivider /> <Paragraph>
<DropdownItem>Room 3</DropdownItem> Here you enter your electricity price. This is gonna calculate the overall Price of your System
</DropdownMenu> </Paragraph>
</Dropdown> </FieldLabel>
</Field> <TextEdit Placeholder="Enter Electricity Price" />
<Column ColumnSize="ColumnSize.IsFull" TextAlignment="TextAlignment.End"> </Field>
<Button Color="Color.Primary">Save</Button> </Div>
<Column ColumnSize="ColumnSize.IsFull" TextAlignment="TextAlignment.End">
<Button Color="Color.Primary">Save</Button>
</Column>
</Column> </Column>
</Column>
</Div> </Div>
</Row> </Row>
</Div> </Div>
@@ -133,8 +135,12 @@
@code { @code {
List<Device> plugs = new List<Device>() { new Device("ffff:ffff:ffff:ffff", "Josne", IPAddress.Broadcast, new User("Joe", "qiowruioewjfopa", Role.Admin), "Raum"), new Device("ffff:ffff:ffff:ffff", "Josne", IPAddress.Broadcast, new User("Joe", "Josne", Role.Admin), "Raum"), new Device("ffff:ffff:ffff:ffff", "Josne", IPAddress.Broadcast, new User("Joe", "qiowruioewjfopa", Role.Admin), "Raum"), }; List<Device> plugs = new List<Device>() { new Device("ffff:ffff:ffff:ffff", "Josne", IPAddress.Broadcast, new User("Joe", "qiowruioewjfopa", Role.Admin), "Raum"), new Device("ffff:ffff:ffff:ffff", "Josne", IPAddress.Broadcast, new User("Joe", "Josne", Role.Admin), "Raum"), new Device("ffff:ffff:ffff:ffff", "Josne", IPAddress.Broadcast, new User("Joe", "qiowruioewjfopa", Role.Admin), "Raum"), };
private bool hideButtonSettings = true;
private void Toggle()
{
hideButtonSettings = !hideButtonSettings;
}
} }