Merge items from Stefan-5422/feature-Dashboard

This commit is contained in:
Stefan
2023-06-01 15:24:29 +02:00
parent 560c4aefca
commit 0364016766
3 changed files with 328 additions and 97 deletions
@@ -7,12 +7,12 @@
@inherits LayoutComponentBase
<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">
<Column ColumnSize="ColumnSize.Is6.OnDesktop.Is12.Is3.WithOffset">
<Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle">
<TextEdit @bind-Text="username" Placeholder="Username" />
<Column ColumnSize="ColumnSize.Is6.OnDesktop.Is3.WithOffset.OnDesktop.Is12.OnMobile">
<Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle" Width="Width.Auto">
<TextEdit @bind-Text="username" Placeholder="Username" Size="Size.Small"/>
</Field>
<Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle">
<TextEdit @bind-Text="password" Role="TextRole.Password" Placeholder="Password" />
<Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle" Width="Width.Auto">
<TextEdit @bind-Text="password" Role="TextRole.Password" Placeholder="Password" Size="Size.Small" />
</Field>
<Button Width="Width.Is25" Disabled="disabled" Color="color" Clicked="Clicked" Position="Position.Relative.Bottom.Is50.Start.Is50.Translate.MiddleX">Login</Button>
</Column>
@@ -1,28 +1,224 @@
@page "/admin"
@using Blazorise.Components
@page "/Admin"
@using Blazorise.Components;
@using Elektrifikatsiya.Models;
@using System.Net
@using Elektrifikatsiya.Services;
@inject IAuthenticationService AuthenthicationService;
<Div>
<Row Padding="Padding.Is3">
<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">
<Column ColumnSize="ColumnSize.Is6.OnDesktop.Is12">
<Column ColumnSize="ColumnSize.Is5.OnDesktop.Is12.OnMobile">
<Bar Breakpoint="Breakpoint.Desktop"
Background="Background.White"
ThemeContrast="ThemeContrast.None"
Shadow="Shadow.Remove"
Border="Border.Is1.RoundedTop">
<BarBrand>
<Column ColumnSize="ColumnSize.Is12">
Users
</BarBrand>
<Button Position="Position.Absolute.End" Padding="Padding.Is3" Outline>
<BarIcon IconName="IconName.Add" ></BarIcon>
</Column>
<Column ColumnSize="ColumnSize.Is12.Is11.WithOffset.OnDesktop.IsAuto.OnMobile">
<Button Clicked="@ShowModalAddUser" TextAlignment="TextAlignment.End" Shadow="Shadow.Remove">
<BarIcon IconName="IconName.Add"></BarIcon>
</Button>
</Column>
</BarBrand>
</Bar>
<ListView TItem="User"
Data="@users"
TextField="@((_)=>(""))"
ValueField="@((_)=>(""))"
Style="border-radius: 0px 0px"
Height="100%"
MaxHeight="90%">
<ItemTemplate>
<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>Name: @context.Item.Name</Small>
<br />
<Small>Rolle: @context.Item.Role</Small>
</Column>
</Row>
</Column>
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is7.OnMobile">
<Button Clicked="@ShowModalDelete" class="btn1" Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Color="Color.Dark" Outline>
<BarIcon IconName="IconName.Delete" />
</Button>
<style>
.btn1:hover {
background: #E50000;
}
</style>
<Modal @ref="modalRefAddUser">
<ModalContent Centered>
<ModalHeader>
<ModalTitle>Add User</ModalTitle>
<CloseButton />
</ModalHeader>
<ModalBody>
<Field>
<FieldLabel>User Name</FieldLabel>
<TextEdit Placeholder="Enter user name..." />
</Field>
<Field>
<FieldLabel>User Password</FieldLabel>
<TextEdit Placeholder="Enter user password..." />
</Field>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px" Clicked="@HideModalAddUser">Close</Button>
<Button Color="Color.Primary" style="border-bottom-left-radius: 0px; border-bottom-right-radius: 0" Clicked="@HideModalAddUser">Add</Button>
</ModalFooter>
</ModalContent>
</Modal>
<Modal @ref="modalRefDelete">
<ModalContent Centered>
<ModalHeader>
<ModalTitle>Delete User</ModalTitle>
<CloseButton />
</ModalHeader>
<ModalBody>
<Field>
<FieldLabel>Admin Password</FieldLabel>
<TextEdit Placeholder="Enter admin password..." />
</Field>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px" Clicked="@HideModalDelete">Close</Button>
<Button Color="Color.Primary" style="border-bottom-left-radius: 0px; border-bottom-right-radius: 0px" Clicked="@HideModalDelete">Delete</Button>
</ModalFooter>
</ModalContent>
</Modal>
</Column>
<br />
<br />
<Row>
<Column ColumnSize="ColumnSize.Is1.OnDesktop">
<Button Position="Position.Absolute.Top.Is50.Start.Is100.Translate.Middle" Color="Color.Dark" Outline>
<BarIcon IconName="IconName.Pen" />
</Button>
</Column>
</Row>
</Row>
</ListGroupItem>
</ItemTemplate>
</ListView>
</Column>
<Column ColumnSize="ColumnSize.Is6.OnDesktop.Is12.OnMobile" Margin="Margin.Is3.FromTop.OnMobile" Padding="Padding.Is4.FromStart.OnMobile">
<Div>
<Field>
<FieldLabel>
<h2>
User Settings
</h2>
</FieldLabel>
</Field>
<Field>
<FieldLabel>
<h5>
User Name
</h5>
<Paragraph>
Here you can change the name of the User
</Paragraph>
</FieldLabel>
<TextEdit Placeholder="Enter User Name" />
</Field>
<br />
<br />
<Field>
<FieldLabel>
<h5>
Password
</h5>
<Paragraph>
Here you can change the password of a User
</Paragraph>
</FieldLabel>
<TextEdit Placeholder="Enter old password" />
<br />
<TextEdit Placeholder="Enter new password" />
</Field>
<br />
<br />
<Field>
<FieldLabel>
<h5>
Select Role
</h5>
<Paragraph>
Here you select or change the role of to User or Admin
</Paragraph>
</FieldLabel>
<br />
<Dropdown Display="Display.InlineBlock">
<DropdownToggle Color="Color.Primary" Width="Width.Is100">Roles</DropdownToggle>
<DropdownMenu>
<DropdownItem>Admin</DropdownItem>
<DropdownDivider />
<DropdownItem>User</DropdownItem>
</DropdownMenu>
</Dropdown>
</Field>
</Div>
<Column ColumnSize="ColumnSize.IsFull" TextAlignment="TextAlignment.End">
<Button Color="Color.Primary">Save</Button>
</Column>
</Column>
</Div>
</Row>
</Div>
@code {
List<User> users = new List<User>() { new User("Silas", "aldjlfasd", Role.Admin), new User("Joe", "qiowruioewjfopa", Role.Admin), new User("Stefan", "adfadsdf", Role.Admin), new User("Manu", "öhöfldaösldf", Role.User) };
private Modal? modalRefDelete;
public Admin()
{
}
private Task ShowModalDelete()
{
return modalRefDelete!.Show();
}
private Task HideModalDelete() => modalRefDelete!.Hide();
private Modal? modalRefAddUser;
private Task ShowModalAddUser()
{
return modalRefAddUser!.Show();
}
private Task HideModalAddUser() => modalRefAddUser!.Hide();
private async Task AddModalAddUser(string name, string passwort)
{
await AuthenthicationService.RegisterUserAsync(name, passwort, Role.User);
await HideModalAddUser();
}
}
@@ -87,6 +87,41 @@
</Column>
</Div>
</Row>
<Row>
<Column ColumnSize="ColumnSize.Is3.OnDesktop.Is11.OnMobile" Margin="Margin.Is1.Is3.OnMobile.FromStart">
<Bar Breakpoint="Breakpoint.Desktop"
Background="Background.White"
ThemeContrast="ThemeContrast.None"
Shadow="Shadow.Remove"
Border="Border.Is1.RoundedTop">
<BarBrand>
Electricity Cost
</BarBrand>
</Bar>
<ListGroup Flush Border="Border.Is1.Is1.Is1.Is1">
<ListGroupItem>
<Div Flex="Flex.JustifyContent.Between" Width="Width.Is100">
<Heading Size="HeadingSize.Is6">Daily Cost</Heading>
</Div>
<Paragraph Margin="Margin.Is1.FromBottom">2€</Paragraph>
</ListGroupItem>
<ListGroupItem>
<Div Flex="Flex.JustifyContent.Between" Width="Width.Is100">
<Heading Size="HeadingSize.Is6">Monthly Cost</Heading>
</Div>
<Paragraph Margin="Margin.Is1.FromBottom">60€</Paragraph>
</ListGroupItem>
<ListGroupItem>
<Div Flex="Flex.JustifyContent.Between" Width="Width.Is100">
<Heading Size="HeadingSize.Is6">Yearly Cost</Heading>
</Div>
<Paragraph Margin="Margin.Is1.FromBottom">720€</Paragraph>
</ListGroupItem>
</ListGroup>
</Column>
</Row>
<Row Padding="Padding.Is3">
<Column>
<Button Color="Color.Primary" Style="border-radius: 0px" Clicked="@(async () => await HandleRedraw())">Aktualisieren</Button>