111 lines
8.9 KiB
JavaScript
111 lines
8.9 KiB
JavaScript
$(document).ready(function () {
|
|
const createTable = () => {
|
|
const table = document.getElementById("documentsTable");
|
|
const tbody = table.querySelector("tbody");
|
|
// Очищаем таблицу
|
|
tbody.innerHTML = "";
|
|
|
|
documents.forEach((doc) => {
|
|
const row = document.createElement("tr");
|
|
|
|
const data = document.createElement("td");
|
|
|
|
const rowContainer = document.createElement("div");
|
|
rowContainer.setAttribute("class", "row-container with-button");
|
|
|
|
rowContainer.setAttribute(
|
|
"onclick",
|
|
`window.open('` + API_SERVER + `/` + doc.path + `', '_blank')`
|
|
);
|
|
|
|
const rowIcon = document.createElement("div");
|
|
rowIcon.setAttribute("class", "row-icon");
|
|
|
|
let svgContent;
|
|
if (doc.type === "pdf") {
|
|
svgContent = `
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="17" height="22" viewBox="0 0 17 22" fill="none">
|
|
<g clip-path="url(#clip0_209_356)">
|
|
<path d="M3.13331 22H13.8656C15.9588 22 16.9989 20.922 16.9989 18.788V9.471H9.68256C8.38844 9.471 7.77219 8.8451 7.77219 7.5317V0H3.13438C1.05081 0 0 1.0879 0 3.223V18.788C0 20.933 1.04125 22 3.13331 22ZM8.53081 14.7103C8.8655 14.7103 9.13963 14.773 9.35319 14.8984C9.56781 15.0238 9.72506 15.2042 9.82812 15.4374C9.93119 15.6706 9.98325 15.95 9.98325 16.2734C9.98325 16.6012 9.93013 16.8839 9.826 17.1215C9.72762 17.3531 9.56003 17.5459 9.34788 17.6715C9.13431 17.7991 8.86125 17.8629 8.53081 17.8629H7.27069V14.7103H8.53081ZM12.6267 14.7103V15.3197H11.2604V16.082H12.5035V16.6727H11.2604V17.8629H10.4869V14.7103H12.6267ZM5.70244 14.7103C5.95 14.7103 6.15719 14.7598 6.32294 14.8599C6.48975 14.9589 6.61513 15.0909 6.70013 15.2559C6.78513 15.422 6.82763 15.6046 6.82763 15.8037C6.82763 16.0039 6.78406 16.1865 6.698 16.3493C6.61061 16.515 6.47842 16.6507 6.31763 16.7398C6.12503 16.8423 5.91037 16.8923 5.69394 16.885H5.11912V17.8629H4.34563V14.7103H5.70244ZM8.40756 15.312H8.04419V17.2601H8.40756C8.54569 17.2601 8.66256 17.2403 8.76138 17.2007C8.85628 17.1636 8.9399 17.1009 9.00362 17.0192C9.07059 16.9298 9.11841 16.8267 9.14387 16.7167C9.17362 16.5957 9.1885 16.4538 9.1885 16.2921C9.1885 16.0765 9.16194 15.8961 9.10775 15.7498C9.06155 15.6139 8.97247 15.498 8.85487 15.4209C8.71883 15.3422 8.56434 15.3041 8.40863 15.3109L8.40756 15.312ZM5.525 15.2933H5.117V16.3141H5.525C5.6204 16.3168 5.71506 16.296 5.80125 16.2536C5.8771 16.216 5.9401 16.1554 5.98188 16.0798C6.02508 15.9948 6.04631 15.8997 6.0435 15.8037C6.0435 15.6387 5.99781 15.5111 5.90538 15.4242C5.79946 15.3316 5.6634 15.2855 5.525 15.2933ZM9.15875 0.1133C9.58269 0.1848 9.99706 0.4818 10.472 0.9746L16.0406 6.7309C16.5261 7.2336 16.8194 7.6439 16.8799 8.0652H9.71125C9.33831 8.0652 9.15556 7.8804 9.15556 7.5108L9.15875 0.1133Z" fill="#FF3B30"/>
|
|
</g>
|
|
<defs>
|
|
<clipPath id="clip0_209_356">
|
|
<rect width="17" height="22" fill="white"/>
|
|
</clipPath>
|
|
</defs>
|
|
</svg>
|
|
`;
|
|
} else if (doc.type === "doc" || doc.type === "docx") {
|
|
svgContent = `
|
|
<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-label="Office Open XML word processing document" data-testid="word-icon"><path d="M16.795 0c1.115 0 1.519.116 1.926.334.407.218.727.538.945.945.218.407.334.811.334 1.926v13.59c0 1.115-.116 1.519-.334 1.926a2.272 2.272 0 01-.945.945c-.407.218-.811.334-1.926.334H3.205c-1.115 0-1.519-.116-1.926-.334a2.272 2.272 0 01-.945-.945C.116 18.314 0 17.91 0 16.795V3.205C0 2.09.116 1.686.334 1.279.552.872.872.552 1.279.334 1.686.116 2.09 0 3.205 0h13.59zM5.177 4.931H3.264L6.098 15.5h1.734L10 7.867h.105l2.179 7.633h1.727l2.834-10.569h-1.904l-1.83 7.99h-.105l-2.132-7.99H9.231l-2.11 7.99h-.106l-1.838-7.99z" fill="#205BC5" fill-rule="evenodd"></path></svg>
|
|
`;
|
|
} else {
|
|
svgContent = `
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="17" height="22" viewBox="0 0 17 22" fill="none">
|
|
<g clip-path="url(#clip0_209_356)">
|
|
<path d="M3.13331 22H13.8656C15.9588 22 16.9989 20.922 16.9989 18.788V9.471H9.68256C8.38844 9.471 7.77219 8.8451 7.77219 7.5317V0H3.13438C1.05081 0 0 1.0879 0 3.223V18.788C0 20.933 1.04125 22 3.13331 22ZM8.53081 14.7103C8.8655 14.7103 9.13963 14.773 9.35319 14.8984C9.56781 15.0238 9.72506 15.2042 9.82812 15.4374C9.93119 15.6706 9.98325 15.95 9.98325 16.2734C9.98325 16.6012 9.93013 16.8839 9.826 17.1215C9.72762 17.3531 9.56003 17.5459 9.34788 17.6715C9.13431 17.7991 8.86125 17.8629 8.53081 17.8629H7.27069V14.7103H8.53081ZM12.6267 14.7103V15.3197H11.2604V16.082H12.5035V16.6727H11.2604V17.8629H10.4869V14.7103H12.6267ZM5.70244 14.7103C5.95 14.7103 6.15719 14.7598 6.32294 14.8599C6.48975 14.9589 6.61513 15.0909 6.70013 15.2559C6.78513 15.422 6.82763 15.6046 6.82763 15.8037C6.82763 16.0039 6.78406 16.1865 6.698 16.3493C6.61061 16.515 6.47842 16.6507 6.31763 16.7398C6.12503 16.8423 5.91037 16.8923 5.69394 16.885H5.11912V17.8629H4.34563V14.7103H5.70244ZM8.40756 15.312H8.04419V17.2601H8.40756C8.54569 17.2601 8.66256 17.2403 8.76138 17.2007C8.85628 17.1636 8.9399 17.1009 9.00362 17.0192C9.07059 16.9298 9.11841 16.8267 9.14387 16.7167C9.17362 16.5957 9.1885 16.4538 9.1885 16.2921C9.1885 16.0765 9.16194 15.8961 9.10775 15.7498C9.06155 15.6139 8.97247 15.498 8.85487 15.4209C8.71883 15.3422 8.56434 15.3041 8.40863 15.3109L8.40756 15.312ZM5.525 15.2933H5.117V16.3141H5.525C5.6204 16.3168 5.71506 16.296 5.80125 16.2536C5.8771 16.216 5.9401 16.1554 5.98188 16.0798C6.02508 15.9948 6.04631 15.8997 6.0435 15.8037C6.0435 15.6387 5.99781 15.5111 5.90538 15.4242C5.79946 15.3316 5.6634 15.2855 5.525 15.2933ZM9.15875 0.1133C9.58269 0.1848 9.99706 0.4818 10.472 0.9746L16.0406 6.7309C16.5261 7.2336 16.8194 7.6439 16.8799 8.0652H9.71125C9.33831 8.0652 9.15556 7.8804 9.15556 7.5108L9.15875 0.1133Z" fill="#FF3B30"/>
|
|
</g>
|
|
<defs>
|
|
<clipPath id="clip0_209_356">
|
|
<rect width="17" height="22" fill="white"/>
|
|
</clipPath>
|
|
</defs>
|
|
</svg>
|
|
`;
|
|
}
|
|
|
|
rowIcon.innerHTML = svgContent;
|
|
|
|
rowContainer.appendChild(rowIcon);
|
|
|
|
const rowContent = document.createElement("div");
|
|
rowContent.setAttribute("class", "row-content");
|
|
|
|
const documentName = document.createElement("h1");
|
|
documentName.textContent = doc.name;
|
|
documentName.setAttribute("id", `doc-name-${doc.id}`);
|
|
rowContent.appendChild(documentName);
|
|
|
|
const documentType = document.createElement("h2");
|
|
documentType.textContent = doc.type;
|
|
rowContent.appendChild(documentType);
|
|
|
|
const date = document.createElement("span");
|
|
date.textContent = doc.date;
|
|
rowContent.appendChild(date);
|
|
|
|
rowContainer.appendChild(rowContent);
|
|
|
|
data.appendChild(rowContainer);
|
|
|
|
if (isAdmin && isFull) {
|
|
const deleteContainer = document.createElement("div");
|
|
deleteContainer.setAttribute("class", "row-delete-container");
|
|
deleteContainer.setAttribute("onclick", `deleteDoc(${doc.id});`);
|
|
|
|
let deleteContent = `
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="21" height="25" viewBox="0 0 21 25" fill="none">
|
|
<g clip-path="url(#clip0_369_11)">
|
|
<path d="M6.98543 19.8025C7.38047 19.8025 7.64032 19.553 7.62993 19.1892L7.3077 8.06653C7.29731 7.7027 7.03742 7.46362 6.6632 7.46362C6.2682 7.46362 6.00831 7.71309 6.0187 8.07692L6.33058 19.1892C6.34097 19.5634 6.60082 19.8025 6.98543 19.8025ZM10.0624 19.8025C10.4574 19.8025 10.738 19.553 10.738 19.1892V8.07692C10.738 7.71309 10.4574 7.46362 10.0624 7.46362C9.66737 7.46362 9.39709 7.71309 9.39709 8.07692V19.1892C9.39709 19.553 9.66737 19.8025 10.0624 19.8025ZM13.1497 19.8025C13.5239 19.8025 13.7838 19.5634 13.7942 19.1892L14.106 8.07692C14.1164 7.71309 13.8565 7.46362 13.4615 7.46362C13.0873 7.46362 12.8275 7.7027 12.817 8.07692L12.5052 19.1892C12.4948 19.553 12.7547 19.8025 13.1497 19.8025ZM5.49895 4.75051H7.15178V2.52599C7.15178 1.93347 7.56755 1.54886 8.19128 1.54886H11.9127C12.5364 1.54886 12.9522 1.93347 12.9522 2.52599V4.75051H14.605V2.42204C14.605 0.914762 13.6278 0 12.027 0H8.07692C6.47611 0 5.49895 0.914762 5.49895 2.42204V4.75051ZM0.779624 5.58214H19.3555C19.7817 5.58214 20.1247 5.21831 20.1247 4.79211C20.1247 4.3659 19.7817 4.01248 19.3555 4.01248H0.779624C0.363825 4.01248 0 4.3659 0 4.79211C0 5.2287 0.363825 5.58214 0.779624 5.58214ZM5.30147 23.1497H14.8337C16.3202 23.1497 17.3181 22.183 17.3908 20.6965L18.1185 5.38462H16.4449L15.7484 20.5198C15.7277 21.1435 15.2807 21.5801 14.6673 21.5801H5.447C4.85449 21.5801 4.4075 21.1331 4.37629 20.5198L3.63825 5.38462H2.00624L2.74428 20.7069C2.81705 22.1933 3.79418 23.1497 5.30147 23.1497Z" fill="#FF3B30" fill-opacity="0.85"/>
|
|
</g>
|
|
<defs>
|
|
<clipPath id="clip0_369_11">
|
|
<rect width="20.1247" height="25" fill="white"/>
|
|
</clipPath>
|
|
</defs>
|
|
</svg>
|
|
`;
|
|
|
|
deleteContainer.innerHTML = deleteContent;
|
|
|
|
data.appendChild(deleteContainer);
|
|
}
|
|
|
|
row.appendChild(data);
|
|
tbody.appendChild(row);
|
|
});
|
|
};
|
|
|
|
createTable();
|
|
});
|