...
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
@using Common.Dtos.User
|
||||
@using Hushian.Application.Dtos
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject UserService userService;
|
||||
|
||||
<div class="row" style="height: fit-content; padding: 1rem;">
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.FullName" type="text" class="form-control" placeholder="نام و نام خانوادگی" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.PhoneNumber" type="text" class="form-control" placeholder="موبایل" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Email" type="text" class="form-control" placeholder="پست الکترونیک" />
|
||||
</div>
|
||||
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
|
||||
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
|
||||
|
||||
|
||||
@if (model.img != null && model.img.Length > 0)
|
||||
{
|
||||
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
|
||||
</div>
|
||||
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> جدید </Button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
public AddUserDto model { get; set; } = new();
|
||||
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
|
||||
public bool loading { get; set; } = false;
|
||||
}
|
||||
@functions{
|
||||
async Task NewItem()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.FullName) && !string.IsNullOrEmpty(model.PhoneNumber))
|
||||
{
|
||||
model.PassWord =model.UserName= model.PhoneNumber;
|
||||
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir";
|
||||
|
||||
loading = true;
|
||||
if (await userService.AddExper(model))
|
||||
{
|
||||
loading = false;
|
||||
await OnMultipleOfThree.InvokeAsync();
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
model = new();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
private async Task OnFileChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
var file = e.File;
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.OpenReadStream().CopyToAsync(memoryStream);
|
||||
model.img = memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
private string GetImageSource()
|
||||
{
|
||||
if (model.img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
@using Hushian.Application.Dtos
|
||||
@using HushianWebApp.Service
|
||||
@inject GroupService groupService;
|
||||
<div class="row" style="height: fit-content; padding: 1rem;">
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Name" type="text" class="form-control" placeholder="نام گروه" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Info" type="text" class="form-control" placeholder="توضیحات" />
|
||||
</div>
|
||||
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
|
||||
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
|
||||
|
||||
@if (model.img != null && model.img.Length >0)
|
||||
{
|
||||
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
|
||||
</div>
|
||||
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> جدید </Button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public ADDGroupDto model { get; set; } = new();
|
||||
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
|
||||
public bool loading { get; set; } = false;
|
||||
}
|
||||
@functions {
|
||||
async Task NewItem()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
loading = true;
|
||||
if (await groupService.AddGroup(model))
|
||||
{
|
||||
loading = false;
|
||||
await OnMultipleOfThree.InvokeAsync();
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnFileChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
var file = e.File;
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.OpenReadStream().CopyToAsync(memoryStream);
|
||||
model.img = memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
private string GetImageSource()
|
||||
{
|
||||
if (model.img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
101
Presentation/HushianWebApp/Components/Base/ChatBubble.razor
Normal file
101
Presentation/HushianWebApp/Components/Base/ChatBubble.razor
Normal file
@@ -0,0 +1,101 @@
|
||||
@using Hushian.Application.Dtos
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<div class="chat-container p-3">
|
||||
|
||||
@foreach (var msg in Messages)
|
||||
{
|
||||
@if (!target && ((!msg.IsRead && msg.Type == Hushian.Enums.ConversationType.UE) || Messages.Last() == msg))
|
||||
{
|
||||
target = true;
|
||||
<div id="target" style="text-align: center;">
|
||||
@if (!msg.IsRead && msg.Type == Hushian.Enums.ConversationType.UE)
|
||||
{
|
||||
<p>ـــــــــــــــــــــــــ</p>
|
||||
}
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
|
||||
<div class="d-flex mb-2 @(msg.Type==Hushian.Enums.ConversationType.UE ? "justify-content-end" : "justify-content-start")" >
|
||||
<div class="chat-bubble @(msg.Type==Hushian.Enums.ConversationType.UE ? "chat-mine"
|
||||
: msg.Type==Hushian.Enums.ConversationType.UE && msg.ExperID=="bot" ? "chat-ai" : "chat-other")" data-id="@msg.ID">
|
||||
@msg.text
|
||||
</div>
|
||||
@if (msg.Type == Hushian.Enums.ConversationType.EU)
|
||||
{
|
||||
if (msg.IsRead)
|
||||
{
|
||||
<Icon Style="align-self: self-end;" Name="IconName.CheckAll" Size="IconSize.x5" Color="IconColor.Success" />
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<Icon Style="align-self: self-end;" Name="IconName.CheckLg" Size="IconSize.x5" />
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.chat-bubble {
|
||||
padding: 0.5rem 0.75rem;
|
||||
border-radius: 1rem;
|
||||
max-width: 75%;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.chat-mine {
|
||||
background: linear-gradient(to right, #005eff, #267fff);
|
||||
color: white;
|
||||
border-top-left-radius: 0;
|
||||
}
|
||||
|
||||
.chat-other {
|
||||
background-color: #f1f1f1;
|
||||
color: #333;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
.chat-ai {
|
||||
background-color: #f1f1f1;
|
||||
color: #353;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
bool target = false;
|
||||
[Parameter]
|
||||
public List<ConversationItemDto> Messages { get; set; } = new();
|
||||
[Parameter] public EventCallback<int> EventCallIsRead { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync("observeVisibility", DotNetObjectReference.Create(this));
|
||||
await JSRuntime.InvokeVoidAsync("scrollToTarget");
|
||||
|
||||
}
|
||||
}
|
||||
[JSInvokable]
|
||||
public async Task MarkAsRead(int id)
|
||||
{
|
||||
var msg = Messages.FirstOrDefault(m => m.ID == id);
|
||||
if (msg != null && !msg.IsRead && msg.Type==Hushian.Enums.ConversationType.UE)
|
||||
{
|
||||
msg.IsRead = true;
|
||||
await EventCallIsRead.InvokeAsync(id);
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
@using Common.Dtos.User
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject UserService userService;
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject AuthService authService;
|
||||
@inject ILocalStorageService localStorageService;
|
||||
<form style="background-color: #ffffff; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column;">
|
||||
|
||||
<label style="margin-bottom: 8px; font-size: 14px; color: #333;" for="oldpass">رمز عبور قبلی:</label>
|
||||
<input dir="ltr" style="text-align:center" @bind="@dto.OldPassword" type="password" class="form-control" placeholder="رمز عبور قبلی" />
|
||||
|
||||
|
||||
<label style="margin-bottom: 8px; font-size: 14px; color: #333; margin-top:15px" for="newpass">رمز عبور جدید:</label>
|
||||
<input dir="ltr" style="text-align:center" @bind="@dto.NewPassword" type="password" class="form-control" placeholder="رمز عبور جدید" />
|
||||
|
||||
<label style="margin-bottom: 8px; font-size: 14px; color: #333; margin-top:15px" for="newpass2">تکرار رمز عبور جدید:</label>
|
||||
<input dir="ltr" style="text-align:center" @bind="RePassword" type="password" class="form-control" placeholder="تکرار رمز عبور جدید" />
|
||||
<ul style="padding-right:10px; padding-top:10px">
|
||||
<li style="color:red">رمز عبور باید حداقل دارای یک کاراکتر باشد</li>
|
||||
<li style="color:red">رمز عبور باید حداقل دارای یک کاراکتر انگلیسی بزرگ باشد</li>
|
||||
<li style="color:red">رمز عبور باید حداقل دارای یک کاراکتر انگلیسی کوچک باشد</li>
|
||||
<li style="color:red">رمز عبور باید حداقل دارای یک عدد باشد</li>
|
||||
</ul>
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<Button style="margin-top:15px" Loading="SpinnerVisible" onclick="@Click" Color="ButtonColor.Primary"> تغییر کلمه عبور </Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||||
public bool SpinnerVisible { get; set; }
|
||||
public ChangePasswordFromUserDto dto { get; set; } = new();
|
||||
public string RePassword { get; set; } = "";
|
||||
public string Username { get; set; } = "";
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Username = await localStorageService.GetItem<string>("Username");
|
||||
dto = new() { UserName = Username };
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
async Task Click()
|
||||
{
|
||||
if (string.IsNullOrEmpty(dto.OldPassword) || string.IsNullOrEmpty(dto.NewPassword))
|
||||
return;
|
||||
|
||||
if (dto.NewPassword != RePassword)
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Danger, "کلمه عبور با تکرار متفاوت است"));
|
||||
return;
|
||||
}
|
||||
SpinnerVisible = true;
|
||||
var result = await userService.ChangePasswordYourself(dto);
|
||||
if (result)
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Success, "تغییر کلمه عبور با موفقیت انجام شد"));
|
||||
|
||||
await authService.Logout();
|
||||
NavigationManager.NavigateTo("/login");
|
||||
}
|
||||
else ToastService.Notify(new ToastMessage(ToastType.Danger, "خطا در تغییر کلمه عبور"));
|
||||
|
||||
SpinnerVisible = false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
@using Common.Dtos.User
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject UserService userService;
|
||||
@inject ILocalStorageService localStorageService;
|
||||
<div class="row" style="height: fit-content; padding: 1rem;">
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.FullName" type="text" class="form-control" placeholder="نام کامل" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Email" type="text" class="form-control" placeholder="پست الکترونیک" />
|
||||
</div>
|
||||
|
||||
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
|
||||
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
|
||||
|
||||
|
||||
@if (model.img != null && model.img.Length > 0)
|
||||
{
|
||||
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
|
||||
</div>
|
||||
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
|
||||
@if (isAuthorizedCompanyUser)
|
||||
{
|
||||
<Button Loading=loading LoadingText="در حال آزادسازی..." Color="ButtonColor.Danger" @onclick="FreeExper"> آزادسازی کارشناس </Button>
|
||||
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
bool isAuthorizedCompanyUser = false;
|
||||
[Parameter] public EventCallback<EditUserFromUserDto> OnMultipleOfThree { get; set; }
|
||||
public List<string> Roles { get; set; } = new();
|
||||
public bool loading { get; set; } = false;
|
||||
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||||
public EditUserFromUserDto model { get; set; } = new();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var user=await userService.GetCurrentUser();
|
||||
if (user!=null)
|
||||
{
|
||||
model.UserName=user.UserName;
|
||||
model.img = user.img;
|
||||
model.FullName = user.FullName;
|
||||
model.Email = user.Email;
|
||||
|
||||
Roles = await localStorageService.GetItem<List<string>>("Role");
|
||||
isAuthorizedCompanyUser = Roles.Contains("HushianExperCompany") && await userService.CheckAvailableExperInCompany();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Danger,"خطا در فراخوانی اطلاعات کاربر"));
|
||||
}
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
private async Task OnFileChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
var file = e.File;
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.OpenReadStream().CopyToAsync(memoryStream);
|
||||
model.img = memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
private string GetImageSource()
|
||||
{
|
||||
if (model.img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
async Task NewItem()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.FullName))
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir";
|
||||
|
||||
loading = true;
|
||||
if (await userService.EditUserYourself(model))
|
||||
{
|
||||
loading = false;
|
||||
await OnMultipleOfThree.InvokeAsync(model);
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
async Task FreeExper()
|
||||
{
|
||||
loading = true;
|
||||
if (await userService.FreeExper())
|
||||
{
|
||||
loading = false;
|
||||
await OnMultipleOfThree.InvokeAsync(model);
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
@using Hushian.Application.Dtos
|
||||
@using HushianWebApp.Service
|
||||
@inject GroupService groupService;
|
||||
@inject UserService userService;
|
||||
@if (!Spinnervisible)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12" style="margin-bottom:15px">
|
||||
<AutoComplete @bind-Value="ExperName"
|
||||
TItem="HushianUserDto"
|
||||
DataProvider="DataProvider"
|
||||
PropertyName="FullName"
|
||||
Placeholder="جستجو در کاربران..."
|
||||
OnChanged="(HushianUserDto exper) => OnAutoCompleteChanged(exper)" />
|
||||
</div>
|
||||
</div>
|
||||
<SortableList TItem="HushianUserDto"
|
||||
Data="Expers"
|
||||
Context="item"
|
||||
AllowSorting="false">
|
||||
<ItemTemplate>
|
||||
@item.FullName
|
||||
<Tooltip Title="گرفتن دسترسی" role="button">
|
||||
<Icon Name="IconName.Trash3" @onclick="async()=>{await UnJoin(item);}"></Icon>
|
||||
</Tooltip>
|
||||
</ItemTemplate>
|
||||
</SortableList>
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-center">
|
||||
<Spinner Type="SpinnerType.Dots" Class="me-3" Color="SpinnerColor.Success" Visible="@Spinnervisible" />
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
private string? ExperName;
|
||||
private bool Spinnervisible = false;
|
||||
|
||||
[Parameter] public int GroupID { get; set; }
|
||||
public List<HushianUserDto> Expers { get; set; }
|
||||
= new();
|
||||
public List<HushianUserDto> CoExpers { get; set; }
|
||||
= new();
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Spinnervisible = true;
|
||||
Expers = await groupService.GetExpersFromGroupID(GroupID);
|
||||
Spinnervisible = false;
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions {
|
||||
private async Task<AutoCompleteDataProviderResult<HushianUserDto>> DataProvider(AutoCompleteDataProviderRequest<HushianUserDto> request)
|
||||
{
|
||||
CoExpers = (await userService.GetExpersCompany(0, 0, 0)).list;
|
||||
return await Task.FromResult(new AutoCompleteDataProviderResult<HushianUserDto> { Data = CoExpers.Where(w => w.FullName.Contains(request.Filter.Value)), TotalCount = CoExpers.Count() });
|
||||
}
|
||||
|
||||
private async Task OnAutoCompleteChanged(HushianUserDto exper)
|
||||
{
|
||||
Spinnervisible = true;
|
||||
if (exper != null
|
||||
&& !Expers.Any(a => a.UserID == exper.UserID)
|
||||
&& await groupService.JoinExperToGroup(GroupID, exper.UserID) )
|
||||
Expers.Add(exper);
|
||||
Spinnervisible = false;
|
||||
}
|
||||
async Task UnJoin(HushianUserDto exper)
|
||||
{
|
||||
Spinnervisible = true;
|
||||
if (exper != null && await groupService.UnJoinExperToGroup(GroupID, exper.UserID))
|
||||
Expers.Remove(exper);
|
||||
Spinnervisible = false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
@using Common.Dtos.User
|
||||
@using Hushian.Application.Dtos
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject UserService userService;
|
||||
|
||||
<div class="row" style="height: fit-content; padding: 1rem;">
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.FullName" type="text" class="form-control" placeholder="نام و نام خانوادگی" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Email" type="text" class="form-control" placeholder="پست الکترونیک" />
|
||||
</div>
|
||||
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
|
||||
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
|
||||
|
||||
|
||||
@if (model.img != null && model.img.Length > 0)
|
||||
{
|
||||
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
|
||||
</div>
|
||||
<Button Loading=loading LoadingText="در حال ویرایش اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter] public EditUserFromUserDto model { get; set; }
|
||||
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
|
||||
public bool loading { get; set; } = false;
|
||||
}
|
||||
@functions{
|
||||
async Task NewItem()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.FullName))
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir";
|
||||
|
||||
loading = true;
|
||||
if (await userService.ExperEditingFromManager(model))
|
||||
{
|
||||
loading = false;
|
||||
await OnMultipleOfThree.InvokeAsync();
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnFileChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
var file = e.File;
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.OpenReadStream().CopyToAsync(memoryStream);
|
||||
model.img = memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
private string GetImageSource()
|
||||
{
|
||||
if (model.img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
@using Hushian.Application.Dtos
|
||||
@using HushianWebApp.Service
|
||||
@inject GroupService groupService;
|
||||
<div class="row" style="height: fit-content; padding: 1rem;">
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Name" type="text" class="form-control" placeholder="نام گروه" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.Info" type="text" class="form-control" placeholder="توضیحات" />
|
||||
</div>
|
||||
<div class="col-md-12" style="display: flex;flex-wrap: nowrap;align-items: baseline;">
|
||||
<InputFile type="file" OnChange="OnFileChange" accept=".png" style="margin-bottom:10px" />
|
||||
|
||||
|
||||
@if (model.img != null && model.img.Length > 0)
|
||||
{
|
||||
<Image src="@GetImageSource()" Class="rounded mx-auto d-block" height="25" width="25" alt="Uploaded Image" />
|
||||
}
|
||||
|
||||
</div>
|
||||
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public GroupDto model { get; set; }
|
||||
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
|
||||
public bool loading { get; set; } = false;
|
||||
}
|
||||
@functions {
|
||||
async Task NewItem()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
loading = true;
|
||||
if (await groupService.UpdateGroup(model))
|
||||
{
|
||||
loading = false;
|
||||
await OnMultipleOfThree.InvokeAsync();
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
private async Task OnFileChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
var file = e.File;
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.OpenReadStream().CopyToAsync(memoryStream);
|
||||
model.img = memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
private string GetImageSource()
|
||||
{
|
||||
if (model.img != null)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
@using Hushian.Application.Dtos
|
||||
@using HushianWebApp.Service
|
||||
@inject GroupService groupService;
|
||||
|
||||
@if (!Spinnervisible)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12" style="margin-bottom:15px">
|
||||
<AutoComplete @bind-Value="GroupName"
|
||||
TItem="GroupDto"
|
||||
DataProvider="DataProvider"
|
||||
PropertyName="Name"
|
||||
Placeholder="جستجو در گروه ها..."
|
||||
OnChanged="(GroupDto group) => OnAutoCompleteChanged(group)" />
|
||||
</div>
|
||||
</div>
|
||||
<SortableList TItem="GroupDto"
|
||||
Data="Groups"
|
||||
Context="item"
|
||||
AllowSorting="false">
|
||||
<ItemTemplate>
|
||||
@item.Name
|
||||
<Tooltip Title="گرفتن دسترسی" role="button">
|
||||
<Icon Name="IconName.Trash3" @onclick="async()=>{await UnJoin(item);}"></Icon>
|
||||
</Tooltip>
|
||||
</ItemTemplate>
|
||||
</SortableList>
|
||||
}
|
||||
|
||||
|
||||
<div class="d-flex justify-content-center">
|
||||
<Spinner Type="SpinnerType.Dots" Class="me-3" Color="SpinnerColor.Success" Visible="@Spinnervisible" />
|
||||
</div>
|
||||
@code {
|
||||
private string? GroupName;
|
||||
private bool Spinnervisible = false;
|
||||
|
||||
[Parameter] public string ExperID { get; set; }
|
||||
public List<GroupDto> Groups { get; set; }
|
||||
= new();
|
||||
public List<GroupDto> CoGroups { get; set; }
|
||||
= new();
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Spinnervisible = true;
|
||||
Groups = await groupService.GetGroupsFromExperID(ExperID);
|
||||
Spinnervisible = false;
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions {
|
||||
private async Task<AutoCompleteDataProviderResult<GroupDto>> DataProvider(AutoCompleteDataProviderRequest<GroupDto> request)
|
||||
{
|
||||
CoGroups = await groupService.GetGroupsCompany();
|
||||
return await Task.FromResult(new AutoCompleteDataProviderResult<GroupDto> { Data = CoGroups.Where(w=>w.Name.Contains(request.Filter.Value)), TotalCount = CoGroups.Count() });
|
||||
}
|
||||
|
||||
private async Task OnAutoCompleteChanged(GroupDto group)
|
||||
{
|
||||
Spinnervisible = true;
|
||||
if (group != null
|
||||
&& !Groups.Any(a => a.ID == group.ID)
|
||||
&& await groupService.JoinExperToGroup(group.ID, ExperID))
|
||||
Groups.Add(group);
|
||||
Spinnervisible = false;
|
||||
}
|
||||
async Task UnJoin(GroupDto group)
|
||||
{
|
||||
Spinnervisible = true;
|
||||
if (group != null && await groupService.UnJoinExperToGroup(group.ID, ExperID))
|
||||
Groups.Remove(group);
|
||||
Spinnervisible = false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
@using Hushian.Application.Dtos
|
||||
<small>پیام های اخیر شما ...</small>
|
||||
<div class="row">
|
||||
@foreach (var item in Conversations)
|
||||
{
|
||||
<div class="col-sm-3">
|
||||
<Card>
|
||||
<CardBody>
|
||||
<CardText>@GetTitleCon(item.Title)</CardText>
|
||||
<Button Color="ButtonColor.Primary" @onclick="async()=>await OnMultipleOfThree.InvokeAsync(item.ID)" Type="ButtonType.Link">Go somewhere</Button>
|
||||
</CardBody>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">@item.ExperFullName (@item.Cdate item.Ctime)</li>
|
||||
</ul>
|
||||
@if (item.status == Hushian.Enums.ConversationStatus.InProgress && item.NoReadCount > 0)
|
||||
{
|
||||
<Badge Color="BadgeColor.Danger"
|
||||
Position="Position.Absolute"
|
||||
Placement="BadgePlacement.TopLeft"
|
||||
IndicatorType="BadgeIndicatorType.RoundedPill"
|
||||
VisuallyHiddenText="unread messages">@item.NoReadCount </Badge>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</Card>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public EventCallback<int> OnMultipleOfThree { get; set; }
|
||||
[Parameter] public List<ConversationDto> Conversations { get; set; }
|
||||
string GetTitleCon(string str)
|
||||
{
|
||||
if (str.Length > 15) return str.Substring(0, 15) + "...";
|
||||
return str;
|
||||
|
||||
}
|
||||
}
|
128
Presentation/HushianWebApp/Components/Verification.razor
Normal file
128
Presentation/HushianWebApp/Components/Verification.razor
Normal file
@@ -0,0 +1,128 @@
|
||||
@using Common.Dtos.User
|
||||
@using Common.Enums
|
||||
@using HushianWebApp.Service
|
||||
@inject VerificationService verificationService;
|
||||
@inject NavigationManager navigation;
|
||||
|
||||
<div class="header-form">
|
||||
<img src="/before/assets/images/Hushian-logo.svg" width="133" alt="Hushian" class="lg:hidden mb-3">
|
||||
|
||||
<span>@Title</span>
|
||||
</div>
|
||||
<p></p>
|
||||
@if (type == VerificationCodeType.ForgetPassword)
|
||||
{
|
||||
<div style="display: flex; justify-content: space-between">
|
||||
<TextInput @bind-value=code type="text" name="code" style="text-align:center;margin-left: 10px;" placeholder="کد ارسال شده" required="required" />
|
||||
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: space-between">
|
||||
<TextInput @bind-value=Value type="password" name="Value" style="text-align:center;margin-top: 10px;;margin-left: 10px" placeholder="کلمه عبور جدید" required="required" />
|
||||
<TextInput @bind-value=ReValue type="password" name="ReValue" style="text-align:center;margin-top: 10px;;margin-left: 10px" placeholder="تکرار کلمه عبور جدید" required="required" />
|
||||
|
||||
<Button Loading=loading LoadingText="ارسال درخواست" @onclick=onClick Color="ButtonColor.Success" style="margin-top: 10px;;margin-left: 10px"> احراز </Button>
|
||||
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div style="display: flex; justify-content: space-between">
|
||||
<TextInput @bind-value=code type="text" name="code" style="text-align:center;margin-left: 10px;" placeholder="کد ارسال شده" required="required" />
|
||||
|
||||
<Button Loading=loading LoadingText="ارسال درخواست" @onclick=onClick Color="ButtonColor.Success"> احراز </Button>
|
||||
|
||||
</div>
|
||||
}
|
||||
<div style="display: flex; justify-content: space-between">
|
||||
|
||||
<Button Disabled=Disabledresendmsg @onclick=onClickresend Color="ButtonColor.Link" style="font-size: small;font-weight: normal;text-decoration: none;"> @resendmsg </Button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
// PhoneNumberConfirmed
|
||||
public VerificationCodeType type { get; set; }
|
||||
[Parameter]
|
||||
public string sendValue { get; set; }
|
||||
[Parameter]
|
||||
public int? ID { get; set; }
|
||||
public string? code { get; set; }
|
||||
[Parameter] public string? Title { get; set; }
|
||||
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||||
[Parameter] public EventCallback<VerificationCodeType> OnMultipleOfThree { get; set; }
|
||||
public string? Value { get; set; }
|
||||
public string? ReValue { get; set; }
|
||||
bool loading = false;
|
||||
string resendmsg = "ارسال مجدد";
|
||||
bool Disabledresendmsg = false;
|
||||
}
|
||||
@functions {
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
resendmsg = "در حال ارسال کد احراز ...";
|
||||
Disabledresendmsg = true;
|
||||
if (ID == 0)
|
||||
ID = await verificationService.FromUserName(sendValue, type);
|
||||
ToastService.Notify(new(ToastType.Info, $"کد احراز به کاربری '{sendValue}' ارسال شد"));
|
||||
|
||||
resendmsg = "ارسال مجدد";
|
||||
Disabledresendmsg = false;
|
||||
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
async Task onClickresend()
|
||||
{
|
||||
resendmsg = "در حال ارسال مجدد کد احراز ...";
|
||||
Disabledresendmsg = true;
|
||||
if (ID == 0)
|
||||
ID = await verificationService.FromUserName(sendValue, type);
|
||||
else
|
||||
{
|
||||
await verificationService.ReSendCode(ID.Value);
|
||||
}
|
||||
|
||||
ToastService.Notify(new(ToastType.Info, $"کد احراز به کاربری '{sendValue}' ارسال شد"));
|
||||
|
||||
resendmsg = "ارسال مجدد";
|
||||
Disabledresendmsg = false;
|
||||
}
|
||||
async Task onClick()
|
||||
{
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
ToastService.Notify(new(ToastType.Warning, $"کد ارسالی را وارد کنید"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == VerificationCodeType.ForgetPassword)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Value) || string.IsNullOrEmpty(ReValue))
|
||||
{
|
||||
ToastService.Notify(new(ToastType.Warning, $"کلمه عبور جدید را مشخص کنید"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Value != ReValue)
|
||||
{ ToastService.Notify(new(ToastType.Warning, $"کلمه عبور جدید و تکرار متفاوت هستند"));
|
||||
return;}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
loading = true;
|
||||
if (await verificationService.ConfirmedCode(new ConfirmedCodeDto()
|
||||
{ code = code, codeType = type, Id = ID.Value, value = Value }))
|
||||
{
|
||||
ToastService.Notify(new(ToastType.Success, $"احراز با موفقیت انجام شد برای ادامه ورود کنید"));
|
||||
await OnMultipleOfThree.InvokeAsync(type);
|
||||
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user