diff --git a/APP_WEB/Controllers/HomeController.cs b/APP_WEB/Controllers/HomeController.cs index 799bebb..c737bce 100644 --- a/APP_WEB/Controllers/HomeController.cs +++ b/APP_WEB/Controllers/HomeController.cs @@ -4,20 +4,47 @@ using AppWeb.Models; namespace AppWeb.Controllers { + /// + /// + /// public class HomeController : Controller { private readonly ILogger _logger; + /// + /// + /// + /// MVC public HomeController(ILogger logger) { _logger = logger; } + /// + /// + /// + [HttpGet] + [Route("/")] public IActionResult Index() { return View(); } + /// + /// + /// + [HttpGet] + [Route("/contacts")] + public IActionResult Contacts() + { + return View(); + } + + /// + /// + /// + [HttpGet] + [Route("/error")] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/APP_WEB/ScriptsAndCss/CssFiles/styles.css b/APP_WEB/ScriptsAndCss/CssFiles/styles.css index 6760198..ea72644 100644 --- a/APP_WEB/ScriptsAndCss/CssFiles/styles.css +++ b/APP_WEB/ScriptsAndCss/CssFiles/styles.css @@ -20,3 +20,125 @@ html { body { margin-bottom: 60px; } + +/* + ************************** + START ALERT + ************************** +*/ + +/* Основные стили для контейнера уведомлений */ +#notification-container { + position: fixed; + bottom: 20px; + left: 20px; + z-index: 9999; +} + +.error_alert_animate { + border: 1px solid #AC0B00; +} + +.ok_alert_animate { + border: 1px solid #007126; +} + +.warning_alert_animate { + border: 1px solid #A33E00; +} + +/* Стили для уведомлений */ +.notification { + background-color: #333; + color: white; + border-radius: 8px; + padding: 10px 20px; + margin-bottom: 10px; + font-size: 16px; + max-width: 300px; + opacity: 1; + animation: slideUpAndFade 5s ease-in-out forwards; +} + +/* Анимация для подъема уведомления вверх и его исчезновения */ +@keyframes slideUpAndFade { + 0% { + transform: translateY(0); + opacity: 1; + } + + 50% { + transform: translateY(-50%); /* Поднимаем уведомление до середины экрана */ + opacity: 0.7; + } + + 100% { + transform: translateY(-100%); /* Двигаем уведомление еще выше */ + opacity: 0; + } +} + +/* + ************************** + END ALERT + ************************** +*/ + +/* + ************************** + START ANIMS + ************************** +*/ + + +.puff-in-center { + -webkit-animation: puff-in-center 0.1s cubic-bezier(0.470, 0.000, 0.745, 0.715) both; + animation: puff-in-center 0.1s cubic-bezier(0.470, 0.000, 0.745, 0.715) both; +} + +/** + * ---------------------------------------- + * animation puff-in-center + * ---------------------------------------- + */ +@-webkit-keyframes puff-in-center { + 0% { + -webkit-transform: scale(2); + transform: scale(2); + -webkit-filter: blur(4px); + filter: blur(4px); + opacity: 0; + } + + 100% { + -webkit-transform: scale(1); + transform: scale(1); + -webkit-filter: blur(0px); + filter: blur(0px); + opacity: 1; + } +} + +@keyframes puff-in-center { + 0% { + -webkit-transform: scale(2); + transform: scale(2); + -webkit-filter: blur(4px); + filter: blur(4px); + opacity: 0; + } + + 100% { + -webkit-transform: scale(1); + transform: scale(1); + -webkit-filter: blur(0px); + filter: blur(0px); + opacity: 1; + } +} + +/* + ************************** + END ANIMS + ************************** +*/ \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Base/Components/BaseEvents.js b/APP_WEB/ScriptsAndCss/JsScripts/Base/Components/BaseEvents.js new file mode 100644 index 0000000..b27f20a --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Base/Components/BaseEvents.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=BaseEvents.js.map \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Base/Components/BaseEvents.js.map b/APP_WEB/ScriptsAndCss/JsScripts/Base/Components/BaseEvents.js.map new file mode 100644 index 0000000..30ba2c4 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Base/Components/BaseEvents.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BaseEvents.js","sourceRoot":"","sources":["../../../TypeScripts/Base/Components/BaseEvents.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Alerts/Alerts.js b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Alerts/Alerts.js new file mode 100644 index 0000000..66ce63f --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Alerts/Alerts.js @@ -0,0 +1,33 @@ +export class Alerts { + AlertShow(notification) { + const container = document.getElementById('notification-container'); + if (!container) + return; + const newNotification = document.createElement('div'); + newNotification.classList.add('notification'); + switch (notification.type) { + case TypeAlert.Error: + newNotification.classList.add('error_alert_animate'); + break; + case TypeAlert.Ok: + newNotification.classList.add('ok_alert_animate'); + break; + case TypeAlert.Warning: + newNotification.classList.add('warning_alert_animate'); + break; + } + newNotification.textContent = notification.text; + container.appendChild(newNotification); + newNotification.classList.add('puff-in-center'); + setTimeout(() => { + newNotification.remove(); + }, notification.duration * 1000); + } +} +export var TypeAlert; +(function (TypeAlert) { + TypeAlert["Error"] = "error"; + TypeAlert["Warning"] = "warning"; + TypeAlert["Ok"] = "ok"; +})(TypeAlert || (TypeAlert = {})); +//# sourceMappingURL=Alerts.js.map \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Alerts/Alerts.js.map b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Alerts/Alerts.js.map new file mode 100644 index 0000000..7abe51c --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Alerts/Alerts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Alerts.js","sourceRoot":"","sources":["../../../../TypeScripts/Base/Services/Alerts/Alerts.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,MAAM;IAIR,SAAS,CAAC,YAA+B;QAC5C,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAC;QACpE,IAAI,CAAC,SAAS;YAAE,OAAO;QAGvB,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACtD,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAE9C,QAAQ,YAAY,CAAC,IAAI,EAAE,CAAC;YACxB,KAAK,SAAS,CAAC,KAAK;gBAChB,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;gBACrD,MAAM;YACV,KAAK,SAAS,CAAC,EAAE;gBACb,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;gBAClD,MAAM;YACV,KAAK,SAAS,CAAC,OAAO;gBAClB,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;gBACvD,MAAM;QACd,CAAC;QAED,eAAe,CAAC,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC;QAGhD,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;QACvC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAGhD,UAAU,CAAC,GAAG,EAAE;YACZ,eAAe,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC,EAAE,YAAY,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACrC,CAAC;CACJ;AAiBD,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACjB,4BAAe,CAAA;IACf,gCAAmB,CAAA;IACnB,sBAAS,CAAA;AACb,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB"} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Cookies.js b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Cookies.js new file mode 100644 index 0000000..5a2424e --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Cookies.js @@ -0,0 +1,26 @@ +export class Cookies { + getCookie(cookieName) { + const name = cookieName + "="; + const decodedCookie = decodeURIComponent(document.cookie); + const ca = decodedCookie.split(";"); + for (let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === " ") { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } + } + return ""; + } + setCookie(name, value, days) { + const date = new Date(); + date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); + document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + date.toUTCString() + ";path=/;secure"; + } + removeCookie(name) { + document.cookie = name + "=;Max-Age=-99999999;"; + } +} +//# sourceMappingURL=Cookies.js.map \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Cookies.js.map b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Cookies.js.map new file mode 100644 index 0000000..c80f9c9 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Cookies.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Cookies.js","sourceRoot":"","sources":["../../../TypeScripts/Base/Services/Cookies.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,OAAO;IAOhB,SAAS,CAAC,UAAkB;QAExB,MAAM,IAAI,GAAQ,UAAU,GAAG,GAAG,CAAC;QAEnC,MAAM,aAAa,GAAG,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAE1D,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAEjC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YAEd,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBAEzB,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACvB,CAAC;YAED,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAExB,OAAO,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC;QACL,CAAC;QAED,OAAO,EAAE,CAAC;IACd,CAAC;IAOD,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,IAAY;QAG/C,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAGxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAG1D,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC;IACnH,CAAC;IAMD,YAAY,CAAC,IAAY;QACrB,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,sBAAsB,CAAC;IACpD,CAAC;CACJ"} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Utilities.js b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Utilities.js new file mode 100644 index 0000000..88b988a --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Utilities.js @@ -0,0 +1,143 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { Alerts } from "./Alerts/Alerts"; +export class Utilities { + constructor() { + this.Alerts = new Alerts(); + } + isEmpty(value) { + if (value == null) + return true; + if (value === "") + return true; + return false; + } + setInputWarning(input) { + input.classList.add("warning_input"); + const timeout = setTimeout(() => { + input.classList.remove("warning_input"); + clearTimeout(timeout); + }, 3000); + } + setAreaWarning(input) { + input.classList.add("warning_area"); + const timeout = setTimeout(() => { + input.classList.remove("warning_area"); + clearTimeout(timeout); + }, 3000); + } + isValidEmail(email) { + if (this.isEmpty(email)) + return false; + const pattern = /^([a-z0-9_.-])+@[a-z0-9-]+\.([a-z]{2,4}\.)?[a-z]{2,4}$/i; + return pattern.test(email); + } + doDelay(mlsec) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise(resolve => { + setTimeout(() => { + resolve(null); + }, mlsec); + }); + }); + } + get getWidh() { + return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; + } + get getHeight() { + return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; + } + getRandomInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; + } + copyValueToBuffer(value, element) { + try { + const coord = element.getBoundingClientRect(); + const scrolled = window.pageYOffset || document.documentElement.scrollTop; + const iOsDevice = navigator.userAgent.match(/ipad|iphone/i); + const textArea = document.createElement("textarea"); + textArea.readOnly = true; + textArea.style.top = `${Math.round(scrolled + coord.top)}px`; + textArea.classList.add("text_copy"); + textArea.value = value; + document.body.appendChild(textArea); + textArea.focus(); + if (iOsDevice) { + const editable = textArea.contentEditable; + const readOnly = textArea.readOnly; + textArea.contentEditable = "true"; + textArea.readOnly = false; + const range = document.createRange(); + range.selectNodeContents(textArea); + const selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + textArea.setSelectionRange(0, 999999); + textArea.contentEditable = editable; + textArea.readOnly = readOnly; + } + else { + textArea.select(); + } + const resultCopy = document.execCommand("copy"); + document.body.removeChild(textArea); + return resultCopy; + } + catch (e) { + console.error("Error: ", e); + return false; + } + } + getCurrentDate() { + const date = new Date(); + const nowDay = date.getDate(); + const nowMonth = date.getMonth() + 1; + let forFullDay = ""; + if (nowDay < 10) { + forFullDay = "0"; + } + let forFullMonth = ""; + if (nowMonth < 10) { + forFullMonth = "0"; + } + return `${forFullDay}${nowDay}.${forFullMonth}${nowMonth}.${date.getFullYear()}`; + } + stringToBoolean(str) { + const lowerStr = str.toLowerCase(); + if (lowerStr === "true") { + return true; + } + else if (lowerStr === "false") { + return false; + } + else { + return null; + } + } + generateUuid() { + var d = new Date().getTime(); + var d2 = ((typeof performance !== "undefined") && performance.now && (performance.now() * 1000)) || 0; + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => { + var r = Math.random() * 16; + if (d > 0) { + r = (d + r) % 16 | 0; + d = Math.floor(d / 16); + } + else { + r = (d2 + r) % 16 | 0; + d2 = Math.floor(d2 / 16); + } + return (c === "x" ? r : (r & 0x3 | 0x8)).toString(16); + }); + } +} +//# sourceMappingURL=Utilities.js.map \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Utilities.js.map b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Utilities.js.map new file mode 100644 index 0000000..313f168 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Base/Services/Utilities.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Utilities.js","sourceRoot":"","sources":["../../../TypeScripts/Base/Services/Utilities.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC,MAAM,OAAO,SAAS;IAGlB;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;IAOD,OAAO,CAAC,KAAa;QAGjB,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QAG/B,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;QAG9B,OAAO,KAAK,CAAC;IACjB,CAAC;IAMD,eAAe,CAAC,KAAuB;QAGnC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAGrC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAG5B,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC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AAC;QAC1D,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Pages/Base/BasePage.js b/APP_WEB/ScriptsAndCss/JsScripts/Pages/Base/BasePage.js new file mode 100644 index 0000000..ba8213a --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Pages/Base/BasePage.js @@ -0,0 +1,61 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { TypeAlert } from "../../Base/Services/Alerts/Alerts"; +export class BasePage { + constructor(utilities, cookies, alerts) { + this.Utilities = utilities; + this.Cookies = cookies; + this.Alerts = alerts; + } + set PageReadyState(state) { + if (this.readyState !== state) { + this.readyState = state; + const event = new CustomEvent('pageStateChanged', { + detail: { + stateName: 'ReadyState', + stateValue: state + } + }); + window.dispatchEvent(event); + } + } + get PageReadyState() { + return this.readyState; + } + WaitForReadyState(conditions, actions) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => { + const intervalId = setInterval(() => { + const allConditionsMet = conditions.every(condition => condition === true); + if (allConditionsMet) { + clearInterval(intervalId); + if (allConditionsMet) { + this.PageReadyState = true; + actions.forEach(action => { + action(); + }); + const alert = { + text: "Страница успешно запущена", + type: TypeAlert.Ok, + duration: 2 + }; + this.Alerts.AlertShow(alert); + resolve({ states: conditions }); + } + else { + console.log("Состояния еще не доступны или не достигнута готовность..."); + } + } + }, 100); + }); + }); + } +} +//# sourceMappingURL=BasePage.js.map \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Pages/Base/BasePage.js.map b/APP_WEB/ScriptsAndCss/JsScripts/Pages/Base/BasePage.js.map new file mode 100644 index 0000000..da69c48 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Pages/Base/BasePage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BasePage.js","sourceRoot":"","sources":["../../../TypeScripts/Pages/Base/BasePage.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAKtE,MAAM,OAAO,QAAQ;IA0BjB,YAAY,SAAoB,EAAE,OAAgB,EAAE,MAAc;QAE9D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAG3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAGvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAKD,IAAW,cAAc,CAAC,KAAK;QAC3B,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;YAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YAExB,MAAM,KAAK,GAAG,IAAI,WAAW,CAA6B,kBAAkB,EAAE;gBAC1E,MAAM,EAAE;oBACJ,SAAS,EAAE,YAAY;oBACvB,UAAU,EAAE,KAAK;iBACpB;aACJ,CAAC,CAAC;YAEH,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACL,CAAC;IAKD,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAQY,iBAAiB,CAAC,UAAqB,EAAE,OAAuB;;YACzE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3B,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;oBAEhC,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;oBAE3E,IAAI,gBAAgB,EAAE,CAAC;wBACnB,aAAa,CAAC,UAAU,CAAC,CAAC;wBAE1B,IAAI,gBAAgB,EAAE,CAAC;4BACnB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;4BAK3B,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gCACrB,MAAM,EAAE,CAAC;4BACb,CAAC,CAAC,CAAC;4BAGH,MAAM,KAAK,GAAsB;gCAC7B,IAAI,EAAE,2BAA2B;gCACjC,IAAI,EAAE,SAAS,CAAC,EAAE;gCAClB,QAAQ,EAAE,CAAC;6BACd,CAAC;4BAEF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;4BAE5B,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,EAAC,CAAC,CAAC;wBACnC,CAAC;6BAAM,CAAC;4BACJ,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;wBAC7E,CAAC;oBACL,CAAC;gBACL,CAAC,EAAE,GAAG,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ"} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Pages/Contacts.js b/APP_WEB/ScriptsAndCss/JsScripts/Pages/Contacts.js new file mode 100644 index 0000000..24e0983 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Pages/Contacts.js @@ -0,0 +1,18 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { BasePage } from "./Base/BasePage"; +export class ContactPage extends BasePage { + StartPage() { + return __awaiter(this, void 0, void 0, function* () { + yield this.WaitForReadyState([true], []); + }); + } +} +//# sourceMappingURL=Contacts.js.map \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Pages/Contacts.js.map b/APP_WEB/ScriptsAndCss/JsScripts/Pages/Contacts.js.map new file mode 100644 index 0000000..3a94b51 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Pages/Contacts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Contacts.js","sourceRoot":"","sources":["../../TypeScripts/Pages/Contacts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,OAAO,WAAY,SAAQ,QAAQ;IAIxB,SAAS;;YAClB,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7C,CAAC;KAAA;CACJ"} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Pages/IndexPage.js b/APP_WEB/ScriptsAndCss/JsScripts/Pages/IndexPage.js new file mode 100644 index 0000000..3b8aeb6 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Pages/IndexPage.js @@ -0,0 +1,18 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { BasePage } from "./Base/BasePage"; +export class IndexPage extends BasePage { + StartPage() { + return __awaiter(this, void 0, void 0, function* () { + yield this.WaitForReadyState([true], []); + }); + } +} +//# sourceMappingURL=IndexPage.js.map \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/Pages/IndexPage.js.map b/APP_WEB/ScriptsAndCss/JsScripts/Pages/IndexPage.js.map new file mode 100644 index 0000000..7e9638f --- /dev/null +++ b/APP_WEB/ScriptsAndCss/JsScripts/Pages/IndexPage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexPage.js","sourceRoot":"","sources":["../../TypeScripts/Pages/IndexPage.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,OAAO,SAAU,SAAQ,QAAQ;IAItB,SAAS;;YAClB,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7C,CAAC;KAAA;CACJ"} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/main_api.js b/APP_WEB/ScriptsAndCss/JsScripts/main_api.js index 533d128..f904160 100644 --- a/APP_WEB/ScriptsAndCss/JsScripts/main_api.js +++ b/APP_WEB/ScriptsAndCss/JsScripts/main_api.js @@ -7,23 +7,56 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -import { Cookies } from "./cookies"; -import { Utilities } from "./utilities"; +import { Alerts } from "./Base/Services/Alerts/Alerts"; +import { Cookies } from "./Base/Services/Cookies"; +import { Utilities } from "./Base/Services/Utilities"; +import { ContactPage } from "./Pages/Contacts"; +import { IndexPage } from "./Pages/IndexPage"; (() => { window.addEventListener("load", () => __awaiter(void 0, void 0, void 0, function* () { const utilities = new Utilities(); const cookies = new Cookies(); + const alerts = new Alerts(); const currentUrl = new URL(document.location.href); const pathname = currentUrl.pathname.toLowerCase(); const partsPath = pathname.split("/"); + let indexPageState = { + ReadyState: undefined + }; + window.addEventListener('pageStateChanged', function (event) { + const stateName = event.detail.stateName; + const stateValue = event.detail.stateValue; + if (stateName === 'ReadyState') { + indexPageState.ReadyState = stateValue; + } + CheckStatesAndProceed(); + }); switch (partsPath[1]) { case "": { + const page = new IndexPage(utilities, cookies, alerts); + yield page.StartPage(); + } + break; + case "": + { + const page = new ContactPage(utilities, cookies, alerts); + yield page.StartPage(); } break; default: break; } + function CheckStatesAndProceed() { + if (indexPageState.ReadyState !== undefined) { + if (indexPageState.ReadyState) { + console.log("Success Start Page"); + } + else { + console.log("Wait Load Page"); + } + } + } })); })(); //# sourceMappingURL=main_api.js.map \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/JsScripts/main_api.js.map b/APP_WEB/ScriptsAndCss/JsScripts/main_api.js.map index 7fbcc35..0b222d8 100644 --- a/APP_WEB/ScriptsAndCss/JsScripts/main_api.js.map +++ b/APP_WEB/ScriptsAndCss/JsScripts/main_api.js.map @@ -1 +1 @@ -{"version":3,"file":"main_api.js","sourceRoot":"","sources":["../TypeScripts/main_api.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,CAAC,GAAG,EAAE;IAEF,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAS,EAAE;QAEvC,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAGlC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;QAG9B,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAGnD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAGnD,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAGtC,QAAQ,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;YACnB,KAAK,EAAE;gBACH,CAAC;gBAKD,CAAC;gBACD,MAAM;YACV;gBACI,MAAM;QACd,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACP,CAA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AC,CAAC,CAAC,EAAE,CAAC;YACnB,KAAK,EAAE;gBACH,CAAC;oBAEG,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;oBAEvD,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC3B,CAAC;gBACD,MAAM;YAEV,KAAK,EAAE;gBACH,CAAC;oBAEG,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;oBAEzD,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC3B,CAAC;gBACD,MAAM;YACV;gBACI,MAAM;QACd,CAAC;QAED,SAAS,qBAAqB;YAC1B,IAAI,cAAc,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBAE1C,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC;oBAC5B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;gBACtC,CAAC;qBAAM,CAAC;oBACJ,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;gBAClC,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/TypeScripts/Base/Components/BaseEvents.ts b/APP_WEB/ScriptsAndCss/TypeScripts/Base/Components/BaseEvents.ts new file mode 100644 index 0000000..5c9174a --- /dev/null +++ b/APP_WEB/ScriptsAndCss/TypeScripts/Base/Components/BaseEvents.ts @@ -0,0 +1,4 @@ +export interface PageReadyStateChangedEvent { + stateName: string; + stateValue: any; +} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/TypeScripts/alerts.ts b/APP_WEB/ScriptsAndCss/TypeScripts/Base/Services/Alerts/Alerts.ts similarity index 73% rename from APP_WEB/ScriptsAndCss/TypeScripts/alerts.ts rename to APP_WEB/ScriptsAndCss/TypeScripts/Base/Services/Alerts/Alerts.ts index 29e116b..340ce73 100644 --- a/APP_WEB/ScriptsAndCss/TypeScripts/alerts.ts +++ b/APP_WEB/ScriptsAndCss/TypeScripts/Base/Services/Alerts/Alerts.ts @@ -1,10 +1,8 @@ export class Alerts { /** * Функция для отображения уведомления - * - * TODO: Сделать синхронизацию уведомления для всех - если она касается размещения задач на сервере */ - public AlertShow(notification: Notification): void { + public AlertShow(notification: NotificationAlert): void { const container = document.getElementById('notification-container'); if (!container) return; @@ -37,15 +35,23 @@ } } -// Тип для уведомлений -interface Notification { - text: string; - duration: number; // продолжительность отображения в секундах - type: TypeAlert; +declare global { + /** + * Уведомление + */ + interface NotificationAlert { + text: string; // текст сообщения уведомления + duration: number; // продолжительность отображения в секундах + type: TypeAlert; // тип уведомления (расцветка) + } } + +/** + * Тип оповещения +*/ export enum TypeAlert { Error = 'error', Warning = 'warning', - Ok = 'ok', + Ok = 'ok' } \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/TypeScripts/cookies.ts b/APP_WEB/ScriptsAndCss/TypeScripts/Base/Services/Cookies.ts similarity index 100% rename from APP_WEB/ScriptsAndCss/TypeScripts/cookies.ts rename to APP_WEB/ScriptsAndCss/TypeScripts/Base/Services/Cookies.ts diff --git a/APP_WEB/ScriptsAndCss/TypeScripts/utilities.ts b/APP_WEB/ScriptsAndCss/TypeScripts/Base/Services/Utilities.ts similarity index 99% rename from APP_WEB/ScriptsAndCss/TypeScripts/utilities.ts rename to APP_WEB/ScriptsAndCss/TypeScripts/Base/Services/Utilities.ts index 8ce6aa3..d3d6bc8 100644 --- a/APP_WEB/ScriptsAndCss/TypeScripts/utilities.ts +++ b/APP_WEB/ScriptsAndCss/TypeScripts/Base/Services/Utilities.ts @@ -1,4 +1,4 @@ -import { Alerts } from "./alerts"; +import { Alerts } from "./Alerts/Alerts"; /** * Класс вспомогательных методов diff --git a/APP_WEB/ScriptsAndCss/TypeScripts/Pages/Base/BasePage.ts b/APP_WEB/ScriptsAndCss/TypeScripts/Pages/Base/BasePage.ts new file mode 100644 index 0000000..788e46f --- /dev/null +++ b/APP_WEB/ScriptsAndCss/TypeScripts/Pages/Base/BasePage.ts @@ -0,0 +1,110 @@ +import { Alerts, TypeAlert } from "../../Base/Services/Alerts/Alerts"; +import { PageReadyStateChangedEvent } from "../../Base/Components/BaseEvents"; +import { Utilities } from "../../Base/Services/Utilities"; +import { Cookies } from "../../Base/Services/Cookies"; + +export class BasePage { + /** + * Экземпляр класса утилит + */ + public readonly Utilities: Utilities; + + /** + * Экземпляр класса кук + */ + public readonly Cookies: Cookies; + + /** + * Экземпляр класса системы уведомлений + */ + public readonly Alerts: Alerts; + + /** + * Состояние готовности страницы + */ + private readyState: boolean; + + /** + * Конструктор + * @param utilities - экземпляр класса утилит + * @param cookies - экземпляр класса кук + */ + constructor(utilities: Utilities, cookies: Cookies, alerts: Alerts) { + //присваиваем экземпляр класса утилит + this.Utilities = utilities; + + //присваиваем экземпляр класса кук + this.Cookies = cookies; + + //присваиваем экземпляр класса кук + this.Alerts = alerts; + } + + /** + * Метод изменяет состояние готовности страницы + */ + public set PageReadyState(state) { + if (this.readyState !== state) { + this.readyState = state; + // Создаем и отправляем CustomEvent + const event = new CustomEvent('pageStateChanged', { + detail: { + stateName: 'ReadyState', + stateValue: state + } + }); + + window.dispatchEvent(event); + } + } + + /** + * Метод получает состояние готовности страницы + */ + public get PageReadyState() { + return this.readyState; + } + + /** + * Метод ждёт состояния готовности страницы к показу пользователю + * P.s на ней могут работать разные сервисы или запускаться перед началом работы со страницей + * @param conditions - массив булевых условий, которые должны быть истинными + * @param actions - массив отложенных функций, которые будут выполнены по очереди после выполнения всех условий + */ + public async WaitForReadyState(conditions: boolean[], actions: (() => void)[]) { + return new Promise((resolve) => { + const intervalId = setInterval(() => { + // Проверяем все условия готовности + const allConditionsMet = conditions.every(condition => condition === true); + + if (allConditionsMet) { + clearInterval(intervalId); // Останавливаем интервал + + if (allConditionsMet) { + this.PageReadyState = true; + + /* + После того как все условия выполнены, выполняем отложенные функции по очереди + */ + actions.forEach(action => { + action(); // Выполняем каждую отложенную функцию + }); + + // Пример использования NotificationAlert и TypeAlert + const alert: NotificationAlert = { + text: "Страница успешно запущена", + type: TypeAlert.Ok, + duration: 2 + }; + + this.Alerts.AlertShow(alert) + + resolve({ states: conditions}); + } else { + console.log("Состояния еще не доступны или не достигнута готовность..."); + } + } + }, 100); // Проверяем каждые 100 мс + }); + } +} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/TypeScripts/Pages/Contacts.ts b/APP_WEB/ScriptsAndCss/TypeScripts/Pages/Contacts.ts new file mode 100644 index 0000000..9e8f2d0 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/TypeScripts/Pages/Contacts.ts @@ -0,0 +1,14 @@ +import { BasePage } from "./Base/BasePage"; + +export class ContactPage extends BasePage { + /** + * Метод запускает страницу + */ + public async StartPage(): Promise { + await this.WaitForReadyState([true], [this.PostEventLoad]); + } + + private PostEventLoad(): void { + console.log("Contact post event...") + } +} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/TypeScripts/Pages/IndexPage.ts b/APP_WEB/ScriptsAndCss/TypeScripts/Pages/IndexPage.ts new file mode 100644 index 0000000..032ae13 --- /dev/null +++ b/APP_WEB/ScriptsAndCss/TypeScripts/Pages/IndexPage.ts @@ -0,0 +1,14 @@ +import { BasePage } from "./Base/BasePage"; + +export class IndexPage extends BasePage { + /** + * Метод запускает страницу + */ + public async StartPage(): Promise { + await this.WaitForReadyState([true], [ this.PostEventLoad ]); + } + + private PostEventLoad(): void { + console.log("Index post event...") + } +} \ No newline at end of file diff --git a/APP_WEB/ScriptsAndCss/TypeScripts/main_api.ts b/APP_WEB/ScriptsAndCss/TypeScripts/main_api.ts index da2a805..369b0df 100644 --- a/APP_WEB/ScriptsAndCss/TypeScripts/main_api.ts +++ b/APP_WEB/ScriptsAndCss/TypeScripts/main_api.ts @@ -1,5 +1,9 @@ -import { Cookies } from "./cookies"; -import { Utilities } from "./utilities"; +import { PageReadyStateChangedEvent } from "./Base/Components/BaseEvents"; +import { Alerts } from "./Base/Services/Alerts/Alerts"; +import { Cookies } from "./Base/Services/Cookies"; +import { Utilities } from "./Base/Services/Utilities"; +import { ContactPage } from "./Pages/Contacts"; +import { IndexPage } from "./Pages/IndexPage"; (() => { //по загрузке окна @@ -10,6 +14,9 @@ import { Utilities } from "./utilities"; //создаем экземпляр класса кук const cookies = new Cookies(); + //создаем экземпляр класса уведомлений + const alerts = new Alerts(); + //получаем текущий URL const currentUrl = new URL(document.location.href); @@ -19,18 +26,54 @@ import { Utilities } from "./utilities"; //разбиваем пути URL на части const partsPath = pathname.split("/"); + // Состояние IndexPage, изначально неопределенное + let indexPageState = { + ReadyState: undefined + }; + + window.addEventListener('pageStateChanged', function (event: + CustomEvent) { + const stateName = event.detail.stateName; + const stateValue = event.detail.stateValue; + + if (stateName === 'ReadyState') { + indexPageState.ReadyState = stateValue; + } + + CheckStatesAndProceed(); + }); + //смотрим путь switch (partsPath[1]) { - case "": //страница авторизации + case "": { - //создаем экземпляр класса авторизации - //const auth = new IndexPage(utilities, cookies); - ////запускаем авторизацию - //await auth.startPage(); + // создаем экземпляр страницы + const page = new IndexPage(utilities, cookies, alerts); + // запускаем + await page.StartPage(); + } + break; + case "contacts": + { + // создаем экземпляр страницы + const page = new ContactPage(utilities, cookies, alerts); + // запускаем + await page.StartPage(); } break; default: break; } + + function CheckStatesAndProceed() { + if (indexPageState.ReadyState !== undefined) { + // Все необходимые состояния получены + if (indexPageState.ReadyState) { + console.log("Success Start Page"); + } else { + console.log("Wait Load Page"); + } + } + } }); })(); \ No newline at end of file diff --git a/APP_WEB/Views/Home/Contacts.cshtml b/APP_WEB/Views/Home/Contacts.cshtml new file mode 100644 index 0000000..2259a9f --- /dev/null +++ b/APP_WEB/Views/Home/Contacts.cshtml @@ -0,0 +1,4 @@ +@{ + ViewData["Title"] = "Контакты"; +} + diff --git a/APP_WEB/Views/Home/Index.cshtml b/APP_WEB/Views/Home/Index.cshtml index bcfd79a..52381a0 100644 --- a/APP_WEB/Views/Home/Index.cshtml +++ b/APP_WEB/Views/Home/Index.cshtml @@ -1,8 +1,4 @@ @{ - ViewData["Title"] = "Home Page"; + ViewData["Title"] = "Главная"; } - - Welcome - Learn about building Web apps with ASP.NET Core. - diff --git a/APP_WEB/Views/Shared/_Layout.cshtml b/APP_WEB/Views/Shared/_Layout.cshtml index 79f5bea..6c46a1b 100644 --- a/APP_WEB/Views/Shared/_Layout.cshtml +++ b/APP_WEB/Views/Shared/_Layout.cshtml @@ -3,20 +3,29 @@ - @ViewData["Title"] - AppWeb + @ViewData["Title"] + - - - @RenderBody() - - + @RenderBody() + + + + +@* + + + + + + *@ + + - @await RenderSectionAsync("Scripts", required: false)
Learn about building Web apps with ASP.NET Core.