...
This commit is contained in:
29
Presentation/HushianWebApp/Layout/BeforeLayout.razor
Normal file
29
Presentation/HushianWebApp/Layout/BeforeLayout.razor
Normal file
@@ -0,0 +1,29 @@
|
||||
@inherits LayoutComponentBase
|
||||
<main class="main w-full lg:h-screen min-[500px]:py-6 bg-main-500 overflow-auto">
|
||||
<Toasts class="p-3" AutoHide="true" Delay="4000" Placement="ToastsPlacement.TopRight" />
|
||||
|
||||
<div class="container">
|
||||
<div class="right-side">
|
||||
@Body
|
||||
</div>
|
||||
<div class="left-side" style="align-self: center;">
|
||||
<div>
|
||||
<img src="/before/assets/images/Hushian-logo.svg" alt="Hushian" class="hidden lg:block">
|
||||
</div>
|
||||
|
||||
<div class="text-right py-5">
|
||||
<p class="font-bold text-slate-700 mb-2">نکات امنیتی</p>
|
||||
<ul class=" text-slate-500 text-xs space-y-3 list-disc">
|
||||
<li class="mr-4">
|
||||
هرگز اطلاعات حساب کاربری (نام کاربری و کلمه عبور) خود را در اختیار دیگران قرار ندهید.
|
||||
</li>
|
||||
<li class="mr-4">
|
||||
پس از اتمام کار با سامانه، حتما بر روی دکمه خروج از سامانه کلیک نمایید.
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</main>
|
11
Presentation/HushianWebApp/Layout/EmpLayout.razor
Normal file
11
Presentation/HushianWebApp/Layout/EmpLayout.razor
Normal file
@@ -0,0 +1,11 @@
|
||||
@inherits LayoutComponentBase
|
||||
<main class="main w-full lg:h-screen min-[500px]:py-6 bg-main-500 overflow-auto">
|
||||
|
||||
|
||||
<div class="container">
|
||||
@Body
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
243
Presentation/HushianWebApp/Layout/MainLayout.razor
Normal file
243
Presentation/HushianWebApp/Layout/MainLayout.razor
Normal file
@@ -0,0 +1,243 @@
|
||||
@inherits LayoutComponentBase
|
||||
@using Common.Dtos.User
|
||||
@using HushianWebApp.Components
|
||||
@using HushianWebApp.Pages
|
||||
@using HushianWebApp.Pages.Manage
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ILocalStorageService localStorageService;
|
||||
@inject AuthService authService;
|
||||
@inject BaseController baseController;
|
||||
@inject UserService userService;
|
||||
<Modal @ref="modal" />
|
||||
<Toasts class="p-3" AutoHide="true" Delay="4000" Placement="ToastsPlacement.TopRight" />
|
||||
<div class="bb-page">
|
||||
<Sidebar @ref="sidebar"
|
||||
Href="/"
|
||||
IconName="IconName.BootstrapFill"
|
||||
Title="هوشــیان"
|
||||
BadgeText="v1.3.1"
|
||||
ImageSrc="/before/assets/images/hushian-logo.svg"
|
||||
DataProvider="SidebarDataProvider"
|
||||
Width="230"
|
||||
WidthUnit="Unit.Px" />
|
||||
<main>
|
||||
<div class="d-flex align-items-center justify-content-end">
|
||||
<div class="text-white text-end d-flex flex-column justify-content-center align-items-end mx-2">
|
||||
<div style="color: black;" class="fw-bold">@Fullname</div>
|
||||
<h6 style="color: black;">@TitleRole</h6>
|
||||
</div>
|
||||
@if (img != null && img.Length > 0)
|
||||
{
|
||||
<Image Src=@GetImageSource() Class="rounded" Alt="placeholder" @onclick="EditCurrentUser"
|
||||
Style="height: 30px;cursor:pointer;margin-left:10px" />
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<Icon Name="IconName.People" Size="IconSize.x3" Style="height: 30px;cursor:pointer;margin-left:10px" @onclick="EditCurrentUser" />
|
||||
}
|
||||
|
||||
|
||||
<Button Color="ButtonColor.Danger" Size="ButtonSize.Small"
|
||||
@onclick=OnCliclLogout Style="margin-left:10px">
|
||||
<Icon Name="IconName.DoorOpen" /> خروج
|
||||
</Button>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<article class="content px-4">
|
||||
<div class="py-2">
|
||||
@if (isonline)
|
||||
{
|
||||
@if (isAuthorizedCompanyUser)
|
||||
{
|
||||
@Body
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>دسترسی به شرکت برای شما یافت نشد</p>
|
||||
}
|
||||
}
|
||||
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private Modal modal = default!;
|
||||
public string Info { get; set; } = "";
|
||||
private string SelectedMenu = "page2";
|
||||
public string Username { get; set; }
|
||||
public string Fullname { get; set; }
|
||||
public byte[]? img { get; set; }
|
||||
public List<string> Roles { get; set; } = new();
|
||||
bool isonline = false;
|
||||
bool isAuthorizedCompanyUser = false;
|
||||
public string TitleRole { get; set; } = "";
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await CheckOnline();
|
||||
if (isonline)
|
||||
{
|
||||
//Roles = await localStorageService.GetItem<List<string>>("Role");
|
||||
Username = await localStorageService.GetItem<string>("Username");
|
||||
Fullname = await localStorageService.GetItem<string>("Fullname");
|
||||
string UserID = await localStorageService.GetItem<string>("UserID");
|
||||
img = await localStorageService.GetItem<byte[]?>("img");
|
||||
}
|
||||
|
||||
|
||||
TitleRole = Roles.Any(a => a == "HushianManagerCompany") ? "مدیر" : "کارشناس";
|
||||
|
||||
isAuthorizedCompanyUser = Roles.Contains("HushianManagerCompany") || (Roles.Contains("HushianExperCompany") && await userService.CheckAvailableExperInCompany());
|
||||
|
||||
string route = NavigationManager.Uri.Replace(NavigationManager.BaseUri, "").ToLower();
|
||||
if (route.Length > 0)
|
||||
{
|
||||
SelectedMenu = route switch
|
||||
{
|
||||
"conversation" => "page2",
|
||||
"usermanagement" => "page3",
|
||||
"groupmanagement" => "page4",
|
||||
"settings" => "page5",
|
||||
_ => "page1"
|
||||
};
|
||||
|
||||
}
|
||||
else SelectedMenu = "page1";
|
||||
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
async Task OnCliclLogout()
|
||||
{
|
||||
await authService.Logout();
|
||||
NavigationManager.NavigateTo("/login");
|
||||
}
|
||||
private async Task ChangePasword()
|
||||
{
|
||||
var parameters = new Dictionary<string, object>();
|
||||
parameters.Add("Username", Username);
|
||||
await modal.ShowAsync<ChangePassWordComponent>(title: "تغییر رمز عبور", parameters: parameters);
|
||||
|
||||
}
|
||||
private async Task Settings()
|
||||
{
|
||||
var parameters = new Dictionary<string, object>();
|
||||
await modal.ShowAsync<Settings>(title: "تنظیمات شرکت", parameters: parameters);
|
||||
|
||||
}
|
||||
private async Task EditCurrentUser()
|
||||
{
|
||||
var parameters = new Dictionary<string, object>();
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<EditUserFromUserDto>(this, CallBack));
|
||||
|
||||
await modal.ShowAsync<EditUserYourselfComponent>(title: $"ویرایش کاربر {Username}", parameters: parameters);
|
||||
|
||||
}
|
||||
async Task CallBack(EditUserFromUserDto edit)
|
||||
{
|
||||
await modal.HideAsync();
|
||||
img = edit.img;
|
||||
await localStorageService.RemoveItem("img");
|
||||
await localStorageService.SetItem("img", img);
|
||||
|
||||
Fullname = edit.FullName;
|
||||
await localStorageService.RemoveItem("Fullname");
|
||||
await localStorageService.SetItem("Fullname", Fullname);
|
||||
|
||||
}
|
||||
private void SetActiveMenu(string menu)
|
||||
{
|
||||
SelectedMenu = menu;
|
||||
|
||||
if (menu == "page1") NavigationManager.NavigateTo("/");
|
||||
|
||||
else if (menu == "page2") NavigationManager.NavigateTo("/Conversation");
|
||||
|
||||
else if (menu == "page3") NavigationManager.NavigateTo("/UserManagement");
|
||||
|
||||
else if (menu == "page4") NavigationManager.NavigateTo("/GroupManagement");
|
||||
|
||||
else if (menu == "page5") NavigationManager.NavigateTo("/Settings");
|
||||
|
||||
}
|
||||
|
||||
async Task CheckOnline()
|
||||
{
|
||||
var token = await localStorageService.GetItem<string>("key");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
isonline = false;
|
||||
NavigationManager.NavigateTo("/login");
|
||||
}
|
||||
else
|
||||
{
|
||||
await baseController.RemoveToken();
|
||||
await baseController.SetToken(token);
|
||||
if (!await authService.IsOnline())
|
||||
{
|
||||
await baseController.RemoveToken();
|
||||
isonline = false;
|
||||
NavigationManager.NavigateTo("/login");
|
||||
}
|
||||
else
|
||||
{
|
||||
Roles = await localStorageService.GetItem<List<string>>("Role");
|
||||
if (Roles.Count == 1 && Roles.Contains("HushianUserCompany"))
|
||||
{
|
||||
isonline = false;
|
||||
NavigationManager.NavigateTo("/NotFound");
|
||||
}
|
||||
else
|
||||
isonline = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private string GetImageSource()
|
||||
{
|
||||
if (img != null && img.Length > 0)
|
||||
{
|
||||
return $"data:image/jpeg;base64,{Convert.ToBase64String(img)}";
|
||||
}
|
||||
return "/defprofile.jpg";
|
||||
}
|
||||
}
|
||||
|
||||
@code {
|
||||
Sidebar sidebar = default!;
|
||||
IEnumerable<NavItem>? navItems;
|
||||
|
||||
private async Task<SidebarDataProviderResult> SidebarDataProvider(SidebarDataProviderRequest request)
|
||||
{
|
||||
if (navItems is null)
|
||||
navItems = GetNavItems();
|
||||
|
||||
return await Task.FromResult(request.ApplyTo(navItems));
|
||||
}
|
||||
|
||||
private IEnumerable<NavItem> GetNavItems()
|
||||
{
|
||||
navItems = new List<NavItem>
|
||||
{
|
||||
// new NavItem { Href = "/", IconName = IconName.HouseDoorFill, Text = "خانه"},
|
||||
// new NavItem { Href = "/Conversation", IconName = IconName.ChatText, Text = " گفتگو ها"},
|
||||
new NavItem { Href = "/", IconName = IconName.ChatText, Text = " گفتگو ها"},
|
||||
new NavItem { Href = "/UserManagement", IconName = IconName.PersonBoundingBox, Text = " مدیریت کاربران"},
|
||||
new NavItem { Href = "/GroupManagement", IconName = IconName.Grid1X2, Text = " مدیریت گروه ها"},
|
||||
new NavItem { Href = "/Settings", IconName = IconName.Hammer, Text = " تنظیمات"},
|
||||
};
|
||||
|
||||
return navItems;
|
||||
}
|
||||
|
||||
private void ToggleSidebar() => sidebar.ToggleSidebar();
|
||||
}
|
77
Presentation/HushianWebApp/Layout/MainLayout.razor.css
Normal file
77
Presentation/HushianWebApp/Layout/MainLayout.razor.css
Normal file
@@ -0,0 +1,77 @@
|
||||
.page {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
|
||||
}
|
||||
|
||||
.top-row {
|
||||
background-color: #f7f7f7;
|
||||
border-bottom: 1px solid #d6d5d5;
|
||||
justify-content: flex-end;
|
||||
height: 3.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
white-space: nowrap;
|
||||
margin-left: 1.5rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.top-row ::deep a:first-child {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media (max-width: 640.98px) {
|
||||
.top-row {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 641px) {
|
||||
.page {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.top-row.auth ::deep a:first-child {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.top-row, article {
|
||||
padding-left: 2rem !important;
|
||||
padding-right: 1.5rem !important;
|
||||
}
|
||||
}
|
55
Presentation/HushianWebApp/Layout/NavMenu.razor
Normal file
55
Presentation/HushianWebApp/Layout/NavMenu.razor
Normal file
@@ -0,0 +1,55 @@
|
||||
<div class="bb-page">
|
||||
|
||||
|
||||
|
||||
<main>
|
||||
<div class="bb-top-row px-4 d-flex justify-content-between">
|
||||
<Icon Name="IconName.List" role="button" @onclick="ToggleSidebar" />
|
||||
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
|
||||
</div>
|
||||
|
||||
<article class="content px-4">
|
||||
<div class="py-2">Page content goes here</div>
|
||||
</article>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
Sidebar sidebar = default!;
|
||||
IEnumerable<NavItem>? navItems;
|
||||
|
||||
private async Task<SidebarDataProviderResult> SidebarDataProvider(SidebarDataProviderRequest request)
|
||||
{
|
||||
if (navItems is null)
|
||||
navItems = GetNavItems();
|
||||
|
||||
return await Task.FromResult(request.ApplyTo(navItems));
|
||||
}
|
||||
|
||||
private IEnumerable<NavItem> GetNavItems()
|
||||
{
|
||||
navItems = new List<NavItem>
|
||||
{
|
||||
new NavItem { Id = "1", Href = "/getting-started", IconName = IconName.HouseDoorFill, Text = "Getting Started"},
|
||||
|
||||
new NavItem { Id = "2", IconName = IconName.LayoutSidebarInset, Text = "Content", IconColor = IconColor.Primary },
|
||||
new NavItem { Id = "3", Href = "/icons", IconName = IconName.PersonSquare, Text = "Icons", ParentId="2"},
|
||||
|
||||
new NavItem { Id = "4", IconName = IconName.ExclamationTriangleFill, Text = "Components", IconColor = IconColor.Success },
|
||||
new NavItem { Id = "5", Href = "/alerts", IconName = IconName.CheckCircleFill, Text = "Alerts", ParentId="4"},
|
||||
new NavItem { Id = "6", Href = "/breadcrumb", IconName = IconName.SegmentedNav, Text = "Breadcrumb", ParentId="4"},
|
||||
new NavItem { Id = "7", Href = "/sidebar", IconName = IconName.LayoutSidebarInset, Text = "Sidebar", ParentId="4"},
|
||||
|
||||
new NavItem { Id = "8", IconName = IconName.WindowPlus, Text = "Forms", IconColor = IconColor.Danger },
|
||||
new NavItem { Id = "9", Href = "/autocomplete", IconName = IconName.InputCursorText, Text = "Auto Complete", ParentId="8"},
|
||||
new NavItem { Id = "10", Href = "/currency-input", IconName = IconName.CurrencyDollar, Text = "Currency Input", ParentId="8"},
|
||||
new NavItem { Id = "11", Href = "/number-input", IconName = IconName.InputCursor, Text = "Number Input", ParentId="8"},
|
||||
new NavItem { Id = "12", Href = "/switch", IconName = IconName.ToggleOn, Text = "Switch", ParentId="8"},
|
||||
};
|
||||
|
||||
return navItems;
|
||||
}
|
||||
|
||||
private void ToggleSidebar() => sidebar.ToggleSidebar();
|
||||
}
|
4
Presentation/HushianWebApp/Layout/UserPanelLayout.razor
Normal file
4
Presentation/HushianWebApp/Layout/UserPanelLayout.razor
Normal file
@@ -0,0 +1,4 @@
|
||||
@inherits LayoutComponentBase
|
||||
<Toasts class="p-3" AutoHide="true" Delay="4000" Placement="ToastsPlacement.TopRight" />
|
||||
@Body
|
||||
|
Reference in New Issue
Block a user