PHP Classes

File: assets/js/components/screen/Admin.js

Recommend this page to a friend!
  Classes of Rodrigo Faustino   Web App Multi-Perfil   assets/js/components/screen/Admin.js   Download  
File: assets/js/components/screen/Admin.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Web App Multi-Perfil
App that uses CRUD to manage multiple users
Author: By
Last change:
Date: 8 months ago
Size: 3,248 bytes
 

Contents

Class file image Download
import BuscaApi from '../lib/BuscaApiG.js'; export default class Admin { constructor(navigateCallback,lang) { this.navigateCallback = navigateCallback; this.buscaApi = new BuscaApi(sessionStorage.getItem('token')); this.menuItems = [ { href: "permissoes", icon: "assets/img/permiss.png", text: "PERFIL", id: "1-0" }, { href: "usuarios", icon: "assets/img/users.png", text: "USERS", id: "1-1" }, { href: "gerirsaloes", icon: "assets/img/cad.png", text: "SALOES", id: "0-2" }, { href: "experiencia", icon: "assets/img/combina.png", text: "EXPERIENCIA", id: "0-2" }, ]; this.userLanguage = lang; this.loadLanguage(); this.init(); } loadLanguage() { this.userLanguage = this.userLanguage.split('-')[0]; fetch(`assets/js/lang/${this.userLanguage}.json`) .then(response => response.json()) .then(translations => { document.querySelectorAll("[data-i18n]").forEach(elem => { const key = elem.getAttribute("data-i18n"); elem.textContent = translations[key]; }); }); } init() { this.atualizaEstiloCabecalho(); } atualizaEstiloCabecalho() { const cabecalho = document.querySelector('.app-header'); if (cabecalho) { cabecalho.style.background = 'linear-gradient(to bottom, rgb(0 0 0), #c44bbc, rgb(194 71 187))'; cabecalho.style.boxShadow = '0 36px 36px 56px rgb(199 86 194)'; } } render() { document.getElementById('titulo').innerHTML='Admin'; const menuContainer = document.createElement('div'); menuContainer.className = 'main'; menuContainer.classList.add = 'container'; this.menuItems.forEach(item => { const link = document.createElement('a'); link.href = '#'; link.onclick = () => this.navigateCallback(item.href); const menuItem = document.createElement('div'); menuItem.className = 'menu__item'; menuItem.id = item.id; const icon = document.createElement('img'); icon.className = 'menu__icon'; icon.src = item.icon; const menuContent = document.createElement('div'); menuContent.className = 'menu__content'; for (let i = 0; i < 2; i++) { const span = document.createElement('span'); span.className = 'menu__span'; menuContent.appendChild(span); } menuItem.appendChild(icon); menuItem.appendChild(menuContent); link.appendChild(menuItem); const textSpan = document.createElement('span'); textSpan.setAttribute('data-i18n', item.text); link.appendChild(textSpan); menuContainer.appendChild(link); }); const currentDiv = document.createElement('div'); currentDiv.className = 'is-active'; currentDiv.id = 'current'; menuContainer.appendChild(currentDiv); return { element: menuContainer, init: () => {} }; } }