fix frontend and update user

This commit is contained in:
Николай 2023-05-19 14:06:33 +04:00
parent 38f53ae91e
commit b426a6373d
12 changed files with 103 additions and 79 deletions

View File

@ -24,8 +24,8 @@
</tbody> </tbody>
</table> </table>
<div class="col d-flex justify-content-evenly align-items-baseline"> <div class="col d-flex justify-content-evenly align-items-baseline">
<button type="button" class="btn btn-primary btn-lg m-2" id="savedoc">Сохранить в doc-формате</button> <button type="button" class="btn btn-primary m-2" id="savedoc">Сохранить в doc-формате</button>
<button type="button" class="btn btn-primary btn-lg m-2" id="saveexcel">Сохранить в xls-формате</button> <button type="button" class="btn btn-primary m-2" id="saveexcel">Сохранить в xls-формате</button>
</div> </div>
</div> </div>

View File

@ -1,4 +1,5 @@
using HardwareShopContracts.BindingModels; using DocumentFormat.OpenXml.Spreadsheet;
using HardwareShopContracts.BindingModels;
using HardwareShopContracts.SearchModels; using HardwareShopContracts.SearchModels;
using HardwareShopContracts.ViewModels; using HardwareShopContracts.ViewModels;
using HardwareShopDatabaseImplement.Models; using HardwareShopDatabaseImplement.Models;
@ -56,9 +57,39 @@ namespace HardwareShopWorkerApp.Controllers
return View(); return View();
} }
[HttpGet]
public IActionResult Privacy() public IActionResult Privacy()
{ {
return View(); if (APIClient.User == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.User);
}
[HttpPost]
public void Privacy(string login, string email, string password)
{
if (APIClient.User == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/user/updatedata", new UserBindingModel
{
Id = APIClient.User.Id,
Login = login,
Email = email,
Password = password
});
APIClient.User.Login = login;
APIClient.User.Email = email;
APIClient.User.Password = password;
Response.Redirect("MainWorker");
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]

View File

@ -15,7 +15,7 @@
<div class=" col-sm-8"> <div class=" col-sm-8">
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Сборки</h2> <h2 class="display-4">Сборки</h2>
<button type="button" class="btn btn-primary btn-lg" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
</div> </div>
<div class="text-center" name="id"> <div class="text-center" name="id">
<table class="table"> <table class="table">
@ -49,13 +49,13 @@
@Html.DisplayFor(modelItem => item.BuildName) @Html.DisplayFor(modelItem => item.BuildName)
</td> </td>
<td> <td>
<button onclick="getBuild(@item.Id)" type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#updateModal"> <button onclick="getBuild(@item.Id)" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateModal">
Обновить Обновить
</button> </button>
<a class="btn btn-primary btn-lg mb-5" asp-controller="Home" asp-action="LinkPurchase" asp-route-buildId="@item.Id"> <a class="btn btn-primary" asp-controller="Home" asp-action="LinkPurchase" asp-route-buildId="@item.Id">
Привязать Привязать
</a> </a>
<button onclick="getBuild(@item.Id)" type="button" class="btn btn-danger btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#deleteModal"> <button onclick="getBuild(@item.Id)" type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
Удалить Удалить
</button> </button>
</td> </td>

View File

@ -17,7 +17,7 @@
<div class=" col-sm-8"> <div class=" col-sm-8">
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Комментарии</h2> <h2 class="display-4">Комментарии</h2>
<button type="button" class="btn btn-primary btn-lg" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button> <button type="button" class="btn btn-primary " data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
</div> </div>
<div class="text-center" name="id"> <div class="text-center" name="id">
<table class="table"> <table class="table">

View File

@ -16,7 +16,6 @@
<h1 class="display-6">Товары</h1> <h1 class="display-6">Товары</h1>
<div class="d-flex justify-content-center"> <div class="d-flex justify-content-center">
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button> <button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary mx-2 mt-3">Удалить</button>
</div> </div>
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>

View File

@ -13,7 +13,7 @@
<div class="text-center"> <div class="text-center">
@{ @{
<p> <p>
<button type="button" onclick="getBuild()" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button> <button type="button" onclick="getBuild()" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
</p> </p>
<table class="table"> <table class="table">
<thead> <thead>
@ -224,11 +224,11 @@
</div> </div>
</div> </div>
<div class="text-center d-flex flex-column mt-5"> <div class="text-center d-flex flex-column mt-5">
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить</button> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Удалить</button> <button type="button" class="btn btn-primary">Удалить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Обновить</button> <button type="button" class="btn btn-primary">Обновить</button>
<button type="submit" class="btn btn-primary btn-lg mb-5">Сохранить</button> <button type="submit" class="btn btn-primary">Сохранить</button>
</div> </div>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">

View File

@ -0,0 +1,29 @@
@using HardwareShopContracts.ViewModels;
@model UserViewModel
@{
ViewData["Title"] = "Privacy Policy";
Layout = "~/Views/Shared/_LayoutWorker.cshtml";
}
<div class="text-center">
<h2 class="display-4">Личные данные</h2>
</div>
<form method="post" class="d-flex flex-column align-items-center">
<div class="col-sm-3">
<label class="form-label">Почта:</label>
<input type="text" class="form-control" name="email" value="@Model.Email">
</div>
<div class="col-sm-3">
<label class="form-label">Пароль:</label>
<input type="text" class="form-control" name="password" value="@Model.Password">
</div>
<div class="col-sm-3">
<label class="form-label">Логин:</label>
<input type="text" class="form-control" name="login" value="@Model.Login">
</div>
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
<button type="submit" class="btn btn-primary mt-3 px-4">Подтвердить</button>
</div>
</form>

View File

@ -19,7 +19,7 @@
<a asp-controller="Home" asp-action="CreatePurchase" class="btn btn-primary mx-2">Добавить</a> <a asp-controller="Home" asp-action="CreatePurchase" class="btn btn-primary mx-2">Добавить</a>
<button type="button" class="btn btn-primary mx-2" id="delete">Удалить покупку</button> <button type="button" class="btn btn-primary mx-2" id="delete">Удалить покупку</button>
<button type="button" class="btn btn-primary mx-2" id="done">Выдан</button> <button type="button" class="btn btn-primary mx-2" id="done">Выдан</button>
<button type="button" class="btn btn-primary mx-2" id="update">Обновить</button> <button type="button" class="btn btn-primary mx-2" id="update">Изменить</button>
</p> </p>
</div> </div>
<div class="text-center"> <div class="text-center">

View File

@ -17,7 +17,6 @@
<h1 class="display-6">Товары</h1> <h1 class="display-6">Товары</h1>
<div class="d-flex justify-content-center"> <div class="d-flex justify-content-center">
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button> <button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary mx-2 mt-3">Удалить</button>
</div> </div>
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>

View File

@ -3,29 +3,15 @@
Layout = "~/Views/Shared/_LayoutWorker.cshtml"; Layout = "~/Views/Shared/_LayoutWorker.cshtml";
} }
<h4 class="fw-bold">Отчет по покупкам</h4> <div class="d-flex flex-column align-items-center">
<div class="col-sm-3">
<div id="error-div-shell" class="error-div-shell"> <label class="form-label">С</label>
<div> <input type="date" class="form-control" name="dateFrom" id="date-from-input">
<p id="error-p" class="error-p mb-2"></p> <label class="form-label">По</label>
<input type="date" class="form-control" name="dateTo" id="date-to-input">
</div> </div>
</div> <button type="submit" class="btn btn-primary mt-3 px-4" id="generate-button">Вывод на страницу</button>
<button type="submit" class="btn btn-primary mt-3 px-4" id="send-by-mail-button">Отправить на почту</button>
<div class="d-flex flex-wrap gap-1 align-items-end mb-2">
<div class="mb-2">
<p class="mb-0">Дата начала:</p>
<input id="date-from-input" class="form-control" type="date" />
</div>
<div class="mb-2">
<p class="mb-0">Дата конца:</p>
<input id="date-to-input" class="form-control" type="date" />
</div>
<button id="generate-button" class="btn btn-primary mb-2">
Показать
</button>
<button id="send-by-mail-button" class="btn btn-primary mb-2">
На почту
</button>
</div> </div>
<p class="mb-0"> <p class="mb-0">
@ -34,21 +20,20 @@
<span>&nbsp;по&nbsp;</span> <span>&nbsp;по&nbsp;</span>
<span id="date-to-span" class="fw-bold">...</span> <span id="date-to-span" class="fw-bold">...</span>
</p> </p>
<div class="mb-2 border">
<table class="table mb-0"> <table class="table">
<thead class="table-head"> <thead>
<tr> <tr>
<th>Номер покупки</th> <th scope="col">Номер покупки</th>
<th>Дата покупки</th> <th scope="col">Дата покупки</th>
<th>Сумма покупки</th> <th scope="col">Сумма покупки</th>
<th>Комментарии</th> <th scope="col">Комментарии</th>
<th>Комплектующие</th> <th scope="col">Комплектующие</th>
</tr> </tr>
</thead> </thead>
<tbody id="tbody"> <tbody id="tbody">
</tbody> </tbody>
</table> </table>
</div>
@section Scripts @section Scripts
{ {
@ -72,9 +57,6 @@
"DateFrom": dateFrom, "DateFrom": dateFrom,
"DateTo": dateTo "DateTo": dateTo
}; };
if (!validate(reportModel)) {
return;
}
$.ajax({ $.ajax({
url: "/home/WorkerReport", url: "/home/WorkerReport",
type: "POST", type: "POST",
@ -94,9 +76,6 @@
"DateFrom": dateFrom, "DateFrom": dateFrom,
"DateTo": dateTo "DateTo": dateTo
}; };
if (!validate(reportModel)) {
return;
}
$.ajax({ $.ajax({
url: "/home/SendByMailPurchaseReport", url: "/home/SendByMailPurchaseReport",
type: "POST", type: "POST",
@ -159,22 +138,6 @@
// [Other] // [Other]
const validate = function (reportModel) {
if (isNaN(reportModel["DateFrom"])) {
errorP.innerHTML = "Выберите начальную дату";
return false;
}
if (isNaN(reportModel["DateTo"])) {
errorP.innerHTML = "Выберите конечную дату";
return false;
}
if (reportModel["DateFrom"] >= reportModel["DateTo"]) {
errorP.innerHTML = "Начальная дата должна быть меньше конечной";
return false;
}
return true;
}
const getDate = function (iso) { const getDate = function (iso) {
const year = iso.substring(0, 4); const year = iso.substring(0, 4);
const month = iso.substring(5, 7); const month = iso.substring(5, 7);

View File

@ -24,8 +24,8 @@
</tbody> </tbody>
</table> </table>
<div class="col d-flex justify-content-evenly align-items-baseline"> <div class="col d-flex justify-content-evenly align-items-baseline">
<button type="button" class="btn btn-primary btn-lg m-2" id="savedoc">Сохранить в doc-формате</button> <button type="button" class="btn btn-primary m-2" id="savedoc">Сохранить в doc-формате</button>
<button type="button" class="btn btn-primary btn-lg m-2" id="saveexcel">Сохранить в xls-формате</button> <button type="button" class="btn btn-primary m-2" id="saveexcel">Сохранить в xls-формате</button>
</div> </div>
</div> </div>

View File

@ -36,6 +36,9 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="WorkerReport">Отчёт</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="WorkerReport">Отчёт</a>
</li> </li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
</ul> </ul>
</div> </div>
</div> </div>