HM-56. Добавлена страница для просмотра логов с фильтрацией, пагинацией (#20)

This commit is contained in:
Nikolay
2020-07-19 16:19:39 +03:00
committed by GitHub
parent d01ee79202
commit 47fe69bc65
20 changed files with 520 additions and 10 deletions

34
src/utils/elementUtils.js Normal file
View File

@ -0,0 +1,34 @@
/**
* @interface CreateElementProps
* @type {Object}
* @property {string} tagName - имя создаваемого тега
* @property {Node} parentNode - родительский Node в который поместить элемент
* @property {Object<string, string>} options - опции, которые можно присвоить объекту
* @property {Object<string, string>} args - аргументы, которые нужно прикрепить к Node
*/
/**
* Функция создания элементов
* @function createElement
* @param {CreateElementProps} createElementProps - параметры для функции
* @returns {Node}
*/
export const createElement = (createElementProps) => {
const {tagName, parentNode, options, args} = createElementProps;
const element = document.createElement(tagName);
if (options) {
Object.entries(options)
.forEach(([key, value]) => {
element[key] = value;
});
}
if (args) {
Object.entries(args)
.forEach(([attr, value]) => {
element.setAttribute(attr, value);
});
}
parentNode.appendChild(element);
return element;
};