...
This commit is contained in:
153
Presentation/HushianWebApp/Pages/Manage/GroupManagement.razor
Normal file
153
Presentation/HushianWebApp/Pages/Manage/GroupManagement.razor
Normal file
@@ -0,0 +1,153 @@
|
||||
@page "/GroupManagement"
|
||||
<Modal @ref="modal" />
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
@using Hushian.Application.Dtos
|
||||
@using HushianWebApp.Components
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject ILocalStorageService localStorageService;
|
||||
@inject NavigationManager navigationManager;
|
||||
@inject GroupService groupService;
|
||||
<Button Color="ButtonColor.Success" Style="margin-bottom:10px"
|
||||
@onclick="async()=>{
|
||||
await modal.ShowAsync<ADDGroupComponent>(title,parameters:parameters);
|
||||
}">
|
||||
گروه جدید
|
||||
</Button>
|
||||
|
||||
<Grid @ref="grid" TItem="GroupDto"
|
||||
AllowSorting="true"
|
||||
Class="table table-hover"
|
||||
DataProvider="DataProvider"
|
||||
HeaderRowCssClass="bg-primary text-white bg-opacity-75 border-bottom-0"
|
||||
Responsive="true"
|
||||
AllowPaging="true"
|
||||
OnRowDoubleClick="OnRowClick"
|
||||
AllowRowClick=true>
|
||||
|
||||
<GridColumns>
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="تصویر گروه" >
|
||||
@if (context.img?.Length!=0)
|
||||
{
|
||||
<Image Class="rounded-circle mx-auto d-block" src="@GetImageSource(context.img)" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<Icon Name="IconName.People" Size="IconSize.x5" />
|
||||
}
|
||||
</GridColumn>
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="شناسه گروه" SortKeySelector="item => item.ID">
|
||||
@context.ID
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="نام گروه" SortKeySelector="item => item.Name">
|
||||
@context.Name
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="توضیحات" >
|
||||
@context.Info
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="وضعیت">
|
||||
<Switch Value="@context.Available" ValueExpression="() => context.Available" ValueChanged="async(v)=>await SwitchChanged(context,v)" />
|
||||
|
||||
</GridColumn>
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="GroupDto" HeaderText="عملیات">
|
||||
<Button Color="ButtonColor.Danger" Size="ButtonSize.ExtraSmall" @onclick="async()=>await DeleteGroup(context.ID,context.Name)"> حذف </Button>
|
||||
<Button Color="ButtonColor.Warning" Size="ButtonSize.ExtraSmall" @onclick="async()=>await showGroupsComponent(context.ID,context.Name)"> کاربران </Button>
|
||||
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
|
||||
</Grid>
|
||||
|
||||
@code {
|
||||
private ConfirmDialog dialog = default!;
|
||||
|
||||
Dictionary<string, object> parameters = new Dictionary<string, object>();
|
||||
Grid<GroupDto> grid = default!;
|
||||
private Modal modal = default!;
|
||||
string title = "گروه جدید";
|
||||
public List<GroupDto> list = new();
|
||||
private async Task<GridDataProviderResult<GroupDto>> DataProvider(GridDataProviderRequest<GroupDto> request)
|
||||
{
|
||||
if(list.Count <= 0)
|
||||
list = await groupService.GetGroupsCompany();
|
||||
|
||||
int skip = (request.PageNumber - 1) * request.PageSize;
|
||||
|
||||
return await Task.FromResult(request.ApplyTo(list != null ? list.Skip(skip).Take(request.PageSize).ToList() : new()));
|
||||
}
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
|
||||
|
||||
if (!(await localStorageService.GetItem<List<string>>("Role")).Any(a => a == "HushianManagerCompany"))
|
||||
navigationManager.NavigateTo("/NotFound");
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
private async Task OnRowClick(GridRowEventArgs<GroupDto> args)
|
||||
{
|
||||
Dictionary<string, object> eparameters = new Dictionary<string, object>();
|
||||
eparameters.Add("model", args.Item);
|
||||
eparameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
|
||||
|
||||
|
||||
await modal.ShowAsync<UpdateGroupComponent>($"ویرایش گروه {args.Item.Name}", parameters: eparameters);
|
||||
|
||||
|
||||
}
|
||||
private async Task SwitchChanged(GroupDto model, bool value)
|
||||
{
|
||||
if (model.Available != value)
|
||||
{
|
||||
if (await groupService.ChangeAvailableGroupFromManager(model.ID, value))
|
||||
model.Available = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private async Task DeleteGroup(int GroupID, string name)
|
||||
{
|
||||
var confirmation = await dialog.ShowAsync(
|
||||
title: $"مطمئنی میخوای {name} حذف کنی؟",
|
||||
message1: "پس از حذف، نمیتوان آن را به حالت اولیه برگرداند.",
|
||||
message2: "میخوای ادامه بدی؟", new ConfirmDialogOptions()
|
||||
{
|
||||
YesButtonColor = ButtonColor.Danger,
|
||||
YesButtonText = "بله",
|
||||
NoButtonText = "نه !"
|
||||
});
|
||||
|
||||
if (!confirmation) return;
|
||||
|
||||
|
||||
if (await groupService.DeleteGroupFromManager(GroupID))
|
||||
{
|
||||
list = await groupService.GetGroupsCompany();
|
||||
await grid.RefreshDataAsync();
|
||||
}
|
||||
}
|
||||
async Task CallBack()
|
||||
{
|
||||
await modal.HideAsync();
|
||||
list = await groupService.GetGroupsCompany();
|
||||
await grid.RefreshDataAsync();
|
||||
}
|
||||
private string GetImageSource(byte[]? img)
|
||||
{
|
||||
if (img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
async Task showGroupsComponent(int GroupID, string name)
|
||||
{
|
||||
Dictionary<string, object> eparameters = new Dictionary<string, object>();
|
||||
eparameters.Add("GroupID", GroupID);
|
||||
|
||||
modal.Size = ModalSize.Small;
|
||||
await modal.ShowAsync<GroupUsersComponent>($"کارشناسان گروه {name}", parameters: eparameters);
|
||||
}
|
||||
}
|
166
Presentation/HushianWebApp/Pages/Manage/Settings.razor
Normal file
166
Presentation/HushianWebApp/Pages/Manage/Settings.razor
Normal file
@@ -0,0 +1,166 @@
|
||||
@page "/Settings"
|
||||
@using Hushian.Application.Dtos.Company
|
||||
@using HushianWebApp.Components
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject ILocalStorageService localStorageService;
|
||||
@inject NavigationManager navigationManager;
|
||||
@inject CompanyService companyService;
|
||||
<style>
|
||||
.section-box {
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: #343a40;
|
||||
margin-bottom: 1rem;
|
||||
border-right: 4px solid #ffc107;
|
||||
padding-right: 0.75rem;
|
||||
}
|
||||
|
||||
.section-title i {
|
||||
margin-left: 0.5rem;
|
||||
color: #ffc107;
|
||||
}
|
||||
|
||||
.row-fullheight {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row row-fullheight">
|
||||
|
||||
<!-- تغییر کلمه عبور -->
|
||||
<div class="col-md-6 d-flex flex-column" style="height: fit-content;">
|
||||
<div class="section-box w-100">
|
||||
<div class="section-title">
|
||||
<i class="bi bi-layout-text-window-reverse"></i> تغییر کلمه عبور
|
||||
</div>
|
||||
<ChangePassWordComponent/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (ALLOWcompanyinfo)
|
||||
{
|
||||
<!-- اطلاعات شرکت -->
|
||||
<div class="col-md-6 d-flex flex-column" style="height: fit-content;">
|
||||
<div class="section-box w-100">
|
||||
<div class="section-title">
|
||||
<i class="bi bi-gear-fill"></i> اطلاعات شرکت
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-3" style="padding-left: 10em;">
|
||||
<div class="col-md-6">
|
||||
<Switch @bind-Value="dto.Available" Label="در دسترس" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<Switch @bind-Value="dto.allowBot" Label="پاسخگوی هوشمند" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12" style="margin-top:15px">
|
||||
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Fullname" type="text" placeholder="نام کامل" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Email" type="text" placeholder="پست الکترونیک" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.WebSite" type="text" placeholder="وب سایت" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Phone" type="text" placeholder="تلفن" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Info" type="text" placeholder="توضیحات" />
|
||||
</div>
|
||||
<div class="col-md-12 d-flex align-items-center mb-2">
|
||||
<InputFile type="file" OnChange="OnFileChange" accept=".png" />
|
||||
@if (dto.img != null && dto.img.Length > 0)
|
||||
{
|
||||
<Image src="@GetImageSource()" class="rounded mx-2" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
</div>
|
||||
<div class="d-grid gap-2">
|
||||
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning"
|
||||
@onclick="updateItem">
|
||||
ویرایش
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
<!-- پایین چپ -->
|
||||
<div class="col-md-6 d-flex flex-column">
|
||||
<div class="section-box w-100">
|
||||
<div class="section-title">
|
||||
<i class="bi bi-graph-up"></i> بخش پایین چپ
|
||||
</div>
|
||||
<!-- محتوای دلخواه -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- پایین راست -->
|
||||
<div class="col-md-6 d-flex flex-column">
|
||||
<div class="section-box w-100">
|
||||
<div class="section-title">
|
||||
<i class="bi bi-chat-dots-fill"></i> بخش پایین راست
|
||||
</div>
|
||||
<!-- محتوای دلخواه -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||||
|
||||
bool ALLOWcompanyinfo = true;
|
||||
public bool loading { get; set; } = false;
|
||||
public CompanyDto dto { get; set; }
|
||||
= new();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!(await localStorageService.GetItem<List<string>>("Role")).Any(a => a == "HushianManagerCompany"))
|
||||
navigationManager.NavigateTo("/NotFound");
|
||||
|
||||
dto=await companyService.GetCompany();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
private async Task OnFileChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
var file = e.File;
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.OpenReadStream().CopyToAsync(memoryStream);
|
||||
dto.img = memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
private string GetImageSource()
|
||||
{
|
||||
if (dto.img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(dto.img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
async Task updateItem()
|
||||
{
|
||||
if (await companyService.UpdateCompany(dto))
|
||||
ToastService.Notify(new ToastMessage(ToastType.Success, "تغییر اطلاعات شرکت با موفقیت انجام شد"));
|
||||
}
|
||||
}
|
155
Presentation/HushianWebApp/Pages/Manage/UserManagment.razor
Normal file
155
Presentation/HushianWebApp/Pages/Manage/UserManagment.razor
Normal file
@@ -0,0 +1,155 @@
|
||||
@page "/UserManagement"
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
@using Common.Dtos.User
|
||||
@using Hushian.Application.Dtos
|
||||
@using HushianWebApp.Components
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject ILocalStorageService localStorageService;
|
||||
@inject NavigationManager navigationManager;
|
||||
@inject UserService userService;
|
||||
<Modal @ref="modal" />
|
||||
|
||||
<Button Color="ButtonColor.Success" Style="margin-bottom:10px"
|
||||
@onclick="async()=>{
|
||||
await modal.ShowAsync<ADDExperComponent>(title,parameters:parameters);
|
||||
}">
|
||||
کارشناس جدید
|
||||
</Button>
|
||||
|
||||
<Grid @ref="grid" TItem="HushianUserDto"
|
||||
AllowSorting="true"
|
||||
Class="table table-hover"
|
||||
DataProvider="DataProvider"
|
||||
HeaderRowCssClass="bg-primary text-white bg-opacity-75 border-bottom-0"
|
||||
Responsive="true"
|
||||
AllowPaging="true"
|
||||
OnRowDoubleClick="OnRowClick"
|
||||
AllowRowClick=true>
|
||||
|
||||
<GridColumns>
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="تصویر کاربر" >
|
||||
@if (context.img?.Length != 0)
|
||||
{
|
||||
<Image Class="rounded-circle mx-auto d-block" src="@GetImageSource(context.img)" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<Icon Name="IconName.Person" Size="IconSize.x5" />
|
||||
}
|
||||
</GridColumn>
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="نام کاریری" SortKeySelector="item => item.UserName">
|
||||
@context.UserName
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="نام کامل" SortKeySelector="item => item.FullName">
|
||||
@context.FullName
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="پست اکترونیک" SortKeySelector="item => item.Email">
|
||||
@context.Email
|
||||
</GridColumn>
|
||||
|
||||
@* <GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="موبابل" SortKeySelector="item => item.PhoneNumber">
|
||||
@context.PhoneNumber
|
||||
</GridColumn> *@
|
||||
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="وضعیت">
|
||||
<Switch Value="@context.Available" ValueExpression="() => context.Available" ValueChanged="async(v)=>await SwitchChanged(context,v)" />
|
||||
|
||||
</GridColumn>
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="HushianUserDto" HeaderText="عملیات">
|
||||
<Button Color="ButtonColor.Danger" Size="ButtonSize.ExtraSmall" @onclick="async()=>await DeleteExper(context.UserID,context.FullName)"> حذف </Button>
|
||||
<Button Color="ButtonColor.Warning" Size="ButtonSize.ExtraSmall" @onclick="async()=>await showGroupsComponent(context.UserID,context.FullName)"> گروه ها </Button>
|
||||
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
|
||||
</Grid>
|
||||
|
||||
@code {
|
||||
private ConfirmDialog dialog = default!;
|
||||
|
||||
Dictionary<string, object> parameters = new Dictionary<string, object>();
|
||||
Grid<HushianUserDto> grid = default!;
|
||||
private Modal modal = default!;
|
||||
string title = "کارشناس جدید";
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
|
||||
|
||||
if (!(await localStorageService.GetItem<List<string>>("Role")).Any(a =>a== "HushianManagerCompany") )
|
||||
navigationManager.NavigateTo("/NotFound");
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
private async Task<GridDataProviderResult<HushianUserDto>> DataProvider(GridDataProviderRequest<HushianUserDto> request)
|
||||
{
|
||||
var employees = await userService.GetExpersCompany(0, request.PageNumber, request.PageSize);
|
||||
return await Task.FromResult(request.ApplyTo(employees != null ? employees.list : new()));
|
||||
}
|
||||
async Task CallBack()
|
||||
{
|
||||
await modal.HideAsync();
|
||||
await grid.RefreshDataAsync();
|
||||
}
|
||||
private async Task OnRowClick(GridRowEventArgs<HushianUserDto> args)
|
||||
{
|
||||
var editmodel = new EditUserFromUserDto()
|
||||
{
|
||||
Email = args.Item.Email,
|
||||
FullName = args.Item.FullName,
|
||||
UserName = args.Item.UserName,
|
||||
img = args.Item.img
|
||||
};
|
||||
Dictionary<string, object> eparameters = new Dictionary<string, object>();
|
||||
eparameters.Add("model", editmodel);
|
||||
eparameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
|
||||
|
||||
await modal.ShowAsync<UpdateExperComponent>($"ویرایش کارشناس {args.Item.FullName}", parameters: eparameters);
|
||||
|
||||
}
|
||||
private async Task SwitchChanged(HushianUserDto model,bool value)
|
||||
{
|
||||
if (model.Available != value)
|
||||
{
|
||||
if (await userService.ChangeAvailableExperFromManager(model.UserID, value))
|
||||
model.Available = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private async Task DeleteExper(string ExperID,string name)
|
||||
{
|
||||
var confirmation = await dialog.ShowAsync(
|
||||
title: $"مطمئنی میخوای {name} حذف کنی؟",
|
||||
message1: "پس از حذف، نمیتوان آن را به حالت اولیه برگرداند.",
|
||||
message2: "میخوای ادامه بدی؟",new ConfirmDialogOptions()
|
||||
{
|
||||
YesButtonColor=ButtonColor.Danger,
|
||||
YesButtonText="بله",
|
||||
NoButtonText="نه !"
|
||||
});
|
||||
|
||||
if (!confirmation) return;
|
||||
|
||||
|
||||
if (await userService.DeleteExperFromManager(ExperID))
|
||||
await grid.RefreshDataAsync();
|
||||
}
|
||||
private string GetImageSource(byte[]? img)
|
||||
{
|
||||
if (img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
async Task showGroupsComponent(string ExperID, string name)
|
||||
{
|
||||
Dictionary<string, object> eparameters = new Dictionary<string, object>();
|
||||
eparameters.Add("ExperID", ExperID);
|
||||
|
||||
modal.Size = ModalSize.Small;
|
||||
await modal.ShowAsync<UserGroupsComponent>($"گروه های کارشناس {name}", parameters: eparameters);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user