diff --git a/cron/cron.js b/cron/cron.js index 8acfc3a..7f382f7 100644 --- a/cron/cron.js +++ b/cron/cron.js @@ -11,7 +11,7 @@ cron.schedule("30 22 * * *", () => { }); // 2. Перевірка стендів без графіку щосуботи о 18:00 -cron.schedule("0 18 * * 6", async () => { +cron.schedule("0 8 * * 6", async () => { console.log(`[${new Date().toLocaleString()}] Запуск перевірки стендів без графіку...`); try { await Stand.check_add(); diff --git a/cron/tasks/stands.js b/cron/tasks/stands.js index d4ac68c..776652a 100644 --- a/cron/tasks/stands.js +++ b/cron/tasks/stands.js @@ -33,7 +33,8 @@ class Stands { return; } - const dateNow = Date.now(); + const ONE_DAY = 24 * 60 * 60 * 1000; + const dateNow = Date.now() + 7 * ONE_DAY; const sqlSchedule = ` SELECT 1 @@ -75,24 +76,28 @@ class Stands { async check_entries() { try { - const today = new Date(); - today.setHours(0, 0, 0, 0); - // 1. Отримуємо вісників і одразу робимо Map для швидкого пошуку const sheeps = await dbAll(`SELECT id, name FROM sheeps`); if (!sheeps.length) return console.log('There are no sheeps'); const sheepMap = new Map(sheeps.map(s => [s.id, s.name])); - const startTomorrow = today.getTime() + 86400000; - const startDayAfterTomorrow = today.getTime() + 86400000 * 2; + + // 2. Отримуємо всі записи на завтра + const now = new Date(); + const tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1); + const startTomorrow = tomorrow.getTime(); + const dayAfterTomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 2); + const startDayAfterTomorrow = dayAfterTomorrow.getTime(); const sqlStands = ` SELECT stand_schedule.*, - (SELECT stand_list.title FROM stand_list WHERE stand_list.id = stand_schedule.stand_id) AS title + stand_list.title FROM stand_schedule + LEFT JOIN + stand_list ON stand_schedule.stand_id = stand_list.id WHERE stand_schedule.date >= ? AND stand_schedule.date < ? ORDER BY @@ -102,7 +107,7 @@ class Stands { const schedule = await dbAll(sqlStands, [startTomorrow, startDayAfterTomorrow]); if (!schedule.length) return console.log('No active schedule'); - // 2. Угруповання даних (Transform) + // 3. Угруповання даних (Transform) const standsData = schedule.reduce((acc, item) => { if (!acc[item.stand_id]) { acc[item.stand_id] = { id: item.stand_id, title: item.title || `Стенд ${sId}`, hours: {}, maxSheepIdx: 0, date: item.date }; @@ -115,7 +120,7 @@ class Stands { return acc; }, {}); - // 3. Генерація + // 4. Генерація for (const standId in standsData) { const data = standsData[standId]; const title = data.title; diff --git a/web/index.html b/web/index.html index 0fee8d9..9a4b833 100644 --- a/web/index.html +++ b/web/index.html @@ -1,5 +1,5 @@ - + diff --git a/web/lib/pages/sheeps/script.js b/web/lib/pages/sheeps/script.js index ceb58e7..fde0e2b 100644 --- a/web/lib/pages/sheeps/script.js +++ b/web/lib/pages/sheeps/script.js @@ -243,7 +243,7 @@ const Sheeps = { for (const element of list) { if (search_value && !element.name.toLowerCase().includes(search_value)) { - continue; // пропустить, если имя не содержит строку поиска + continue; // пропустити, якщо ім'я не містить рядок пошуку } html += ` diff --git a/web/lib/pages/territory/card/script.js b/web/lib/pages/territory/card/script.js index 742f8bb..c3c20b9 100644 --- a/web/lib/pages/territory/card/script.js +++ b/web/lib/pages/territory/card/script.js @@ -507,7 +507,7 @@ const Territory_card = { joint: { async setHTML(homestead_id){ - let lest = await this.getJoint(homestead_id); + let list = await this.getJoint(homestead_id); let block_info = document.getElementById('page-card-info'); @@ -516,7 +516,7 @@ const Territory_card = {

Надати спільний доступ:

${Sheeps.sheeps_list.list.map(p => { - const isSelected = lest.some(item => item.sheep_id === p.id); + const isSelected = list.some(item => item.sheep_id === p.id); if(USER.id === Number(p.id) && USER.mode != 2) return return `
-
- + - -
-
- - - - + + + + + Карта території +
- -
+
+
+ + + + +
-
- - Багатоквартирні будинки -
- - -
-
+ +
-
- +
+ + Багатоквартирні будинки +
+ -
- - Житлові райони - + +
+
-
-
+
+ + +
+ + Житлові райони + + +
+
diff --git a/web/lib/pages/territory/list/script.js b/web/lib/pages/territory/list/script.js index 052ec4e..2a81e8c 100644 --- a/web/lib/pages/territory/list/script.js +++ b/web/lib/pages/territory/list/script.js @@ -39,6 +39,24 @@ const Territory_list = { Territory_list.homestead.setHTML(); }, + // Пошук + search: { + open: () => { + const sheepSearchForm = document.getElementById("page-territory-search"); + const current = sheepSearchForm.dataset.state; + sheepSearchForm.dataset.state = current === 'open' ? 'closed' : 'open'; + }, + input: (value) => { + console.log(value); + + search_value = value?.trim()?.toLowerCase() || ""; + // Sheeps.sheeps_list.setHTML(search_value); + + Territory_list.house.setHTML(search_value); + Territory_list.homestead.setHTML(search_value); + } + }, + house: { url: null, list: [], @@ -54,7 +72,7 @@ const Territory_list = { Territory_list.house.list = await response.json(); return Territory_list.house.list; }, - setHTML: async function () { + setHTML: async function (search_value = null) { const block = document.getElementById('list-house'); const territory_entrances = localStorage.getItem('territory_list_entrances') === 'true'; const sort_mode = localStorage.getItem('territory_list_sort') ?? "1"; @@ -88,6 +106,11 @@ const Territory_list = { (territory_list_filter === 2 && qty !== work && !territory_entrances) || (territory_list_filter === 2 && element.working === false); + + if (search_value && !element.house.title.toLowerCase().includes(search_value)) { + continue; // пропустити, якщо ім'я не містить рядок пошуку + } + if (statusMatch) { const card = document.createElement('app-territory-card'); @@ -161,7 +184,7 @@ const Territory_list = { Territory_list.homestead.list = await response.json(); return Territory_list.homestead.list; }, - setHTML: async function () { + setHTML: async function (search_value = null) { const block = document.getElementById('list-homestead'); const sortMode = localStorage.getItem('territory_list_sort') ?? "1"; const territory_list_filter = Number(localStorage.getItem("territory_list_filter") ?? 0); @@ -184,6 +207,10 @@ const Territory_list = { (territory_list_filter === 1 && element.working) || (territory_list_filter === 2 && !element.working); + if (search_value && !element.title.toLowerCase().includes(search_value)) { + continue; // пропустити, якщо ім'я не містить рядок пошуку + } + if (statusMatch) { const working = element.working; diff --git a/web/lib/pages/territory/list/style.css b/web/lib/pages/territory/list/style.css index 08576dc..d74485c 100644 --- a/web/lib/pages/territory/list/style.css +++ b/web/lib/pages/territory/list/style.css @@ -57,6 +57,7 @@ border-radius: var(--border-radius); overflow: auto; display: flex; + flex-wrap: wrap; } .page-territory>.list-controls select { @@ -73,6 +74,58 @@ border-radius: calc(var(--border-radius) - 5px - 2px); } +.page-territory>.list-controls>button { + display: flex; + position: relative; + background: var(--ColorThemes3); + font-size: 18px; + cursor: pointer; + min-width: 30px; + height: 30px; + padding: 0; + margin-left: calc(100% - 220px); + align-items: center; + justify-content: center; + border-radius: calc(var(--border-radius) - 5px - 2px); + border: 1px solid var(--ColorThemes0); +} + +.page-territory>.list-controls>button>svg { + width: 25px; + height: 25px; + fill: var(--ColorThemes0); +} + +#page-territory-search { + width: 100%; + display: flex; + flex-direction: row; + align-items: center; + cursor: pointer; + position: relative; + z-index: 5; + max-height: 0; + overflow: hidden; + opacity: 0; + transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease; +} + +#page-territory-search[data-state="open"] { + max-height: 60px; + padding: 15px 0 0 0; + opacity: 1; +} + +#page-territory-search input { + width: 100%; + padding: 0 5px; + border-radius: calc(var(--border-radius) - 5px - 4px); + height: 30px; + background: var(--ColorThemes3); + color: var(--ColorThemes0); + font-size: var(--FontSize2); +} + #page-territory-sort { display: flex; diff --git a/web/lib/pages/territory/manager/index.html b/web/lib/pages/territory/manager/index.html index c1cf0a5..3afa22f 100644 --- a/web/lib/pages/territory/manager/index.html +++ b/web/lib/pages/territory/manager/index.html @@ -95,12 +95,8 @@ - +
+