This commit is contained in:
2025-09-09 00:10:53 +03:00
parent 38f2a05107
commit 204fc092d7
239 changed files with 22447 additions and 9536 deletions

View File

@@ -1,9 +1,17 @@
<div class="page-home">
<details id="details-personal-territory" open>
<details id="details-personal-territory" open style="display: none;">
<summary>
<span>Території для опрацювання</span>
</summary>
<div id="home-personal-territory-list"></div>
</details>
<details id="details-group-territory" open style="display: none;">
<summary>
<span>Групові території</span>
</summary>
<div id="home-group-territory-list"></div>
</details>
</div>

View File

@@ -3,93 +3,142 @@ const Home = {
let html = await fetch('/lib/pages/home/index.html').then((response) => response.text());
app.innerHTML = html;
Home.house.setHTML();
Home.homestead.setHTML();
if (USER.possibilities.can_view_territory) {
Home.personal.house.setHTML();
Home.personal.homestead.setHTML();
Home.group.house.setHTML();
Home.group.homestead.setHTML();
}
},
house: {
loadAPI: async function () {
let uuid = localStorage.getItem("uuid");
personal: {
house: {
list: [],
loadAPI: async () => {
const uuid = localStorage.getItem("uuid");
const URL = `${CONFIG.api}houses/list?mode=sheep`;
const res = await fetch(URL, {
headers: {
"Content-Type": "application/json",
"Authorization": uuid
}
});
Home.personal.house.list = await res.json();
return Home.personal.house.list;
},
setHTML: async () => {
const list = Home.personal.house.list.length > 0
? Home.personal.house.list
: await Home.personal.house.loadAPI();
const URL = `${CONFIG.api}houses/list?mode=sheep`;
return await fetch(URL, {
method: 'GET',
headers: {
"Content-Type": "application/json",
"Authorization": uuid
}
}).then((response) => response.json());
},
setHTML: async function () {
let list = await Home.house.loadAPI();
if (USER.possibilities.can_view_territory && list.length)
document.getElementById('details-personal-territory').style.display = "";
list.sort((a, b) => b.id - a.id);
list.sort((a, b) => b.id - a.id);
Home.renderCards(list, "house", "personal");
}
},
homestead: {
list: [],
loadAPI: async () => {
const uuid = localStorage.getItem("uuid");
const URL = `${CONFIG.api}homestead/list?mode=sheep`;
const res = await fetch(URL, {
headers: {
"Content-Type": "application/json",
"Authorization": uuid
}
});
Home.personal.homestead.list = await res.json();
return Home.personal.homestead.list;
},
setHTML: async () => {
const list = Home.personal.homestead.list.length > 0
? Home.personal.homestead.list
: await Home.personal.homestead.loadAPI();
console.log(list);
let block_house = document.getElementById('home-personal-territory-list')
if (USER.possibilities.can_view_territory && list.length)
document.getElementById('details-personal-territory').style.display = "";
for (let i = 0; i < list.length; i++) {
const element = list[i];
block_house.innerHTML += `
<div class="card">
<i style="background-image: url(https://sheep-service.com/cards/house/T${element.id}.webp);"></i>
<div class="contents">
<div class="group" style="background: ${colorGroup(element.group_id)}">
<span>Група №${element.group_id}</span>
</div>
<div class="info">
<div>
<p>${element.title} ${element.number}</p>
</div>
</div>
</div>
<a href="/territory/card/house/${element.id}" data-route></a>
</div>
`;
list.sort((a, b) => b.id - a.id);
Home.renderCards(list, "homestead", "personal");
}
}
},
homestead: {
loadAPI: async function () {
let uuid = localStorage.getItem("uuid");
group: {
house: {
list: [],
loadAPI: async () => {
const uuid = localStorage.getItem("uuid");
const URL = `${CONFIG.api}house/list?mode=group`;
const res = await fetch(URL, {
headers: {
"Content-Type": "application/json",
"Authorization": uuid
}
});
Home.group.house.list = await res.json();
return Home.group.house.list;
},
setHTML: async () => {
const list = Home.group.house.list.length > 0
? Home.group.house.list
: await Home.group.house.loadAPI();
const URL = `${CONFIG.api}homestead/list?mode=sheep`;
return await fetch(URL, {
method: 'GET',
headers: {
"Content-Type": "application/json",
"Authorization": uuid
}
}).then((response) => response.json());
},
setHTML: async function () {
let list = await Home.homestead.loadAPI();
if (USER.possibilities.can_view_territory && list.length)
document.getElementById('details-group-territory').style.display = "";
list.sort((a, b) => b.id - a.id);
list.sort((a, b) => b.id - a.id);
Home.renderCards(list, "house", "group");
}
},
homestead: {
list: [],
loadAPI: async () => {
const uuid = localStorage.getItem("uuid");
const URL = `${CONFIG.api}homestead/list?mode=group`;
const res = await fetch(URL, {
headers: {
"Content-Type": "application/json",
"Authorization": uuid
}
});
Home.group.homestead.list = await res.json();
return Home.group.homestead.list;
},
setHTML: async () => {
const list = Home.group.homestead.list.length > 0
? Home.group.homestead.list
: await Home.group.homestead.loadAPI();
console.log(list);
let block_homestead = document.getElementById('home-personal-territory-list')
if (USER.possibilities.can_view_territory && list.length)
document.getElementById('details-group-territory').style.display = "";
for (let i = 0; i < list.length; i++) {
const element = list[i];
block_homestead.innerHTML += `
<div class="card">
<i style="background-image: url(https://sheep-service.com/cards/homestead/H${element.id}.webp);"></i>
<div class="contents">
<div class="group" style="background: ${colorGroup(element.group_id)}">
<span>Група №${element.group_id}</span>
</div>
<div class="info">
<div>
<p>${element.title} ${element.number}</p>
</div>
</div>
</div>
<a href="/territory/card/homestead/${element.id}" data-route></a>
</div>
`;
list.sort((a, b) => b.id - a.id);
Home.renderCards(list, "homestead", "group");
}
}
},
renderCards: (list, type, block) => {
const container = document.getElementById(`home-${block}-territory-list`);
const fragment = document.createDocumentFragment();
for (const el of list) {
const card = document.createElement("div");
card.className = "card";
card.innerHTML = `
<i style="background-image: url(https://sheep-service.com/cards/${type}/${type === "house" ? "T" : "H"}${el.id}.webp);"></i>
<div class="contents">
<div class="info">
<div><p>${el.title} ${el.number}</p></div>
</div>
</div>
<a href="/territory/card/${type}/${el.id}" data-route></a>
`;
fragment.appendChild(card);
}
container.appendChild(fragment);
}
}

View File

@@ -36,7 +36,7 @@
cursor: pointer;
color: var(--ColorThemes3);
border-radius: var(--border-radius);
font-size: 16px;
font-size: var(--FontSize5);
font-weight: 300;
padding: 20px;
position: relative;
@@ -47,7 +47,8 @@
}
.page-home #home-personal-territory-list {
.page-home #home-personal-territory-list,
.page-home #home-group-territory-list {
width: 100%;
margin: 0;
display: flex;
@@ -112,7 +113,7 @@
/* background-repeat: round; */
background-size: cover;
background-position: center;
background-image: url(https://tm.rozenrod.com/web/img/bg.webp);
background-color: var(--PrimaryColor);
}
.page-home .card>a {
position: absolute;
@@ -132,60 +133,41 @@
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
align-items: stretch;
justify-content: space-between;
}
.page-home .group {
width: calc(100% - 20px);
max-height: 50px;
border-radius: 7px;
padding: 10px 0;
margin-top: 10px;
display: flex;
background: var(--PrimaryColor);
align-items: center;
flex-direction: column;
justify-content: space-around;
}
.page-home .group>span {
color: #fff;
font-size: 14px;
font-weight: 400;
}
.page-home .info {
width: calc(100% - 20px);
margin-bottom: 10px;
margin: 10px;
}
.page-home .info>div {
width: 100%;
height: 35px;
margin-top: 5px;
display: flex;
background: var(--ColorThemes0);
align-items: center;
justify-content: center;
font-size: 12px;
font-size: var(--FontSize1);
color: var(--ColorThemes3);
border-radius: 7px;
border-radius: calc(var(--border-radius) - 5px - 4px);
position: relative;
overflow: hidden;
}
.page-home .info>div>span {
color: var(--ColorThemes3);
font-size: 14px;
font-size: var(--FontSize3);
font-weight: 300;
z-index: 2;
}
.page-home .info>div>p {
color: var(--ColorThemes3);
font-size: 14px;
font-size: var(--FontSize3);
font-weight: 400;
padding: 10px;
z-index: 2;
width: 100%;
text-align: center;
}