mirror of
https://github.com/Stefan-5422/-T5-Elektrifikatsiya.git
synced 2026-09-04 00:45:58 +02:00
Merge items from Stefan-5422/feature-Dashboard
This commit is contained in:
@@ -7,12 +7,12 @@
|
|||||||
@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">
|
||||||
<Column ColumnSize="ColumnSize.Is6.OnDesktop.Is12.Is3.WithOffset">
|
<Column ColumnSize="ColumnSize.Is6.OnDesktop.Is3.WithOffset.OnDesktop.Is12.OnMobile">
|
||||||
<Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle">
|
<Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle" Width="Width.Auto">
|
||||||
<TextEdit @bind-Text="username" Placeholder="Username" />
|
<TextEdit @bind-Text="username" Placeholder="Username" Size="Size.Small"/>
|
||||||
</Field>
|
</Field>
|
||||||
<Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle">
|
<Field Position="Position.Relative.Top.Is50.Start.Is50.Translate.Middle" Width="Width.Auto">
|
||||||
<TextEdit @bind-Text="password" Role="TextRole.Password" Placeholder="Password" />
|
<TextEdit @bind-Text="password" Role="TextRole.Password" Placeholder="Password" Size="Size.Small" />
|
||||||
</Field>
|
</Field>
|
||||||
<Button Width="Width.Is25" Disabled="disabled" Color="color" Clicked="Clicked" Position="Position.Relative.Bottom.Is50.Start.Is50.Translate.MiddleX">Login</Button>
|
<Button Width="Width.Is25" Disabled="disabled" Color="color" Clicked="Clicked" Position="Position.Relative.Bottom.Is50.Start.Is50.Translate.MiddleX">Login</Button>
|
||||||
</Column>
|
</Column>
|
||||||
|
|||||||
@@ -1,28 +1,224 @@
|
|||||||
@page "/admin"
|
@page "/Admin"
|
||||||
@using Blazorise.Components
|
@using Blazorise.Components;
|
||||||
@using Elektrifikatsiya.Models;
|
@using Elektrifikatsiya.Models;
|
||||||
@using System.Net
|
@using System.Net
|
||||||
|
@using Elektrifikatsiya.Services;
|
||||||
|
|
||||||
|
@inject IAuthenticationService AuthenthicationService;
|
||||||
<Div>
|
<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">
|
<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"
|
<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>
|
||||||
|
<Column ColumnSize="ColumnSize.Is12">
|
||||||
Users
|
Users
|
||||||
</BarBrand>
|
</Column>
|
||||||
<Button Position="Position.Absolute.End" Padding="Padding.Is3" Outline>
|
<Column ColumnSize="ColumnSize.Is12.Is11.WithOffset.OnDesktop.IsAuto.OnMobile">
|
||||||
|
<Button Clicked="@ShowModalAddUser" TextAlignment="TextAlignment.End" Shadow="Shadow.Remove">
|
||||||
<BarIcon IconName="IconName.Add"></BarIcon>
|
<BarIcon IconName="IconName.Add"></BarIcon>
|
||||||
</Button>
|
</Button>
|
||||||
|
</Column>
|
||||||
|
</BarBrand>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Bar>
|
</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>
|
</Column>
|
||||||
</Div>
|
</Div>
|
||||||
</Row>
|
</Row>
|
||||||
</Div>
|
</Div>
|
||||||
|
|
||||||
@code {
|
@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>
|
</Column>
|
||||||
</Div>
|
</Div>
|
||||||
</Row>
|
</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">
|
<Row Padding="Padding.Is3">
|
||||||
<Column>
|
<Column>
|
||||||
<Button Color="Color.Primary" Style="border-radius: 0px" Clicked="@(async () => await HandleRedraw())">Aktualisieren</Button>
|
<Button Color="Color.Primary" Style="border-radius: 0px" Clicked="@(async () => await HandleRedraw())">Aktualisieren</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user