user settings, users management, project settings, bug fixes
This commit is contained in:
97
static/scripts/notifications.js
Normal file
97
static/scripts/notifications.js
Normal file
@@ -0,0 +1,97 @@
|
||||
if (location.pathname.match(/fullcpgrid/i) ? true : false) {
|
||||
document.documentElement.style.fontSize = "32px";
|
||||
document.querySelector(".notifications").style.transform =
|
||||
"translate(0.5rem, calc(-50% + 3rem))";
|
||||
}
|
||||
|
||||
class Notifications {
|
||||
constructor(el) {
|
||||
this.el = el;
|
||||
}
|
||||
|
||||
createDiv(className = "") {
|
||||
const el = document.createElement("div");
|
||||
el.classList.add(className);
|
||||
return el;
|
||||
}
|
||||
addText(el, text) {
|
||||
el.appendChild(document.createTextNode(text));
|
||||
}
|
||||
|
||||
create(
|
||||
title = "Untitled notification",
|
||||
description = "",
|
||||
duration = 2,
|
||||
destroyOnClick = false,
|
||||
clickFunction = undefined
|
||||
) {
|
||||
function destroy(animate) {
|
||||
if (animate) {
|
||||
notiEl.classList.add("out");
|
||||
notiEl.addEventListener("animationend", () => {
|
||||
notiEl.remove();
|
||||
});
|
||||
} else {
|
||||
notiEl.remove();
|
||||
}
|
||||
}
|
||||
|
||||
const notiEl = this.createDiv("noti");
|
||||
const notiCardEl = this.createDiv("noticard");
|
||||
const glowEl = this.createDiv("notiglow");
|
||||
const borderEl = this.createDiv("notiborderglow");
|
||||
|
||||
const titleEl = this.createDiv("notititle");
|
||||
this.addText(titleEl, title);
|
||||
|
||||
const descriptionEl = this.createDiv("notidesc");
|
||||
this.addText(descriptionEl, description);
|
||||
|
||||
notiEl.appendChild(notiCardEl);
|
||||
notiCardEl.appendChild(glowEl);
|
||||
notiCardEl.appendChild(borderEl);
|
||||
notiCardEl.appendChild(titleEl);
|
||||
notiCardEl.appendChild(descriptionEl);
|
||||
|
||||
this.el.appendChild(notiEl);
|
||||
|
||||
console.log("height", notiCardEl.scrollHeight);
|
||||
requestAnimationFrame(function () {
|
||||
notiEl.style.height =
|
||||
"calc(0.25rem + " + notiCardEl.getBoundingClientRect().height + "px)";
|
||||
});
|
||||
|
||||
notiEl.addEventListener("mousemove", (event) => {
|
||||
const rect = notiCardEl.getBoundingClientRect();
|
||||
const localX = (event.clientX - rect.left) / rect.width;
|
||||
const localY = (event.clientY - rect.top) / rect.height;
|
||||
|
||||
console.log(localX, localY);
|
||||
glowEl.style.left = localX * 100 + "%";
|
||||
glowEl.style.top = localY * 100 + "%";
|
||||
|
||||
borderEl.style.left = localX * 100 + "%";
|
||||
borderEl.style.top = localY * 100 + "%";
|
||||
});
|
||||
|
||||
if (clickFunction != undefined) {
|
||||
notiEl.addEventListener("click", clickFunction);
|
||||
}
|
||||
|
||||
if (destroyOnClick) {
|
||||
notiEl.addEventListener("click", () => destroy(true));
|
||||
}
|
||||
|
||||
if (duration != 0) {
|
||||
setTimeout(() => {
|
||||
notiEl.classList.add("out");
|
||||
notiEl.addEventListener("animationend", () => {
|
||||
notiEl.remove();
|
||||
});
|
||||
}, duration * 1000);
|
||||
}
|
||||
return notiEl;
|
||||
}
|
||||
}
|
||||
|
||||
notis = new Notifications(document.querySelector(".notifications"));
|
||||
36
static/scripts/users-table.js
Normal file
36
static/scripts/users-table.js
Normal file
@@ -0,0 +1,36 @@
|
||||
$(document).ready(function () {
|
||||
const createTable = () => {
|
||||
const table = document.getElementById("usersTable");
|
||||
const tbody = table.querySelector("tbody");
|
||||
// Очищаем таблицу
|
||||
tbody.innerHTML = "";
|
||||
|
||||
users.forEach((user) => {
|
||||
const row = document.createElement("tr");
|
||||
row.setAttribute(
|
||||
"onclick",
|
||||
`location.href = '/admin/user/` + user.id + `'`
|
||||
);
|
||||
|
||||
const email = document.createElement("td");
|
||||
email.textContent = user.email;
|
||||
row.appendChild(email);
|
||||
|
||||
const name = document.createElement("td");
|
||||
name.textContent = user.name;
|
||||
row.appendChild(name);
|
||||
|
||||
const phone = document.createElement("td");
|
||||
phone.textContent = user.phone;
|
||||
row.appendChild(phone);
|
||||
|
||||
const projects = document.createElement("td");
|
||||
projects.textContent = user.projects;
|
||||
row.appendChild(projects);
|
||||
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
};
|
||||
|
||||
createTable();
|
||||
});
|
||||
Reference in New Issue
Block a user