14 lines
3.2 KiB
JavaScript
14 lines
3.2 KiB
JavaScript
/*
|
|
* This file is part of the TYPO3 CMS project.
|
|
*
|
|
* It is free software; you can redistribute it and/or modify it under
|
|
* the terms of the GNU General Public License, either version 2
|
|
* of the License, or any later version.
|
|
*
|
|
* For the full copyright and license information, please read the
|
|
* LICENSE.txt file that was distributed with this source code.
|
|
*
|
|
* The TYPO3 project - inspiring people to share!
|
|
*/
|
|
import u from"@typo3/core/ajax/ajax-request.js";import g from"@typo3/core/event/regular-event.js";import d from"@typo3/backend/icons.js";import r from"@typo3/backend/storage/persistent.js";import c from"@typo3/backend/viewport.js";import"@typo3/backend/element/status-indicator-element.js";var a;(function(o){o.element="#typo3-cms-backend-backend-toolbaritems-systeminformationtoolbaritem",o.icon="#typo3-cms-backend-backend-toolbaritems-systeminformationtoolbaritem .toolbar-item-icon .t3js-icon",o.menu="#typo3-cms-backend-backend-toolbaritems-systeminformationtoolbaritem .dropdown-menu",o.data="[data-systeminformation-data]",o.badge="[data-systeminformation-badge]",o.message="[data-systeminformation-message-module]",o.messageLink="[data-systeminformation-message-module] a"})(a||(a={}));class n{constructor(){this.timer=null,this.updateMenu=()=>{const t=document.querySelector(a.icon),e=t.cloneNode(!0);this.timer!==null&&(clearTimeout(this.timer),this.timer=null),d.getIcon("spinner-circle",d.sizes.small).then(s=>{t.replaceWith(document.createRange().createContextualFragment(s))}),new u(TYPO3.settings.ajaxUrls.systeminformation_render).get().then(async s=>{document.querySelector(a.menu).innerHTML=await s.resolve(),n.updateBadge()}).finally(()=>{document.querySelector(a.icon).replaceWith(e),this.timer=setTimeout(this.updateMenu,1e3*300)})},new g("click",this.handleMessageLinkClick).delegateTo(document,a.messageLink),c.Topbar.Toolbar.registerEvent(this.updateMenu),document.addEventListener("typo3:system-information-menu:update",()=>this.updateMenu())}static getData(){const e=document.querySelector(a.data)?.dataset;return{count:e?.systeminformationDataCount?parseInt(e.systeminformationDataCount,10):0,severityBadgeClass:e?.systeminformationDataSeveritybadgeclass??""}}static getMessageDataFromElement(t){const e=t.dataset;return{count:e.systeminformationMessageCount?parseInt(e.systeminformationMessageCount,10):0,status:e.systeminformationMessageStatus??"",module:e.systeminformationMessageModule??"",params:e.systeminformationMessageParams??""}}static updateBadge(){const t=n.getData(),e=document.querySelector(a.badge);e.removeAttribute("class"),e.classList.add("toolbar-item-badge"),e.classList.add("badge"),e.classList.add("badge-pill"),t.severityBadgeClass!==""&&e.classList.add(t.severityBadgeClass),e.textContent=t.count.toString(),e.classList.toggle("hidden",!(t.count>0))}handleMessageLinkClick(t,e){const s=n.getMessageDataFromElement(e.closest(a.message));if(s.module==="")return;t.preventDefault(),t.stopPropagation();const m={},l=Math.floor(Date.now()/1e3);let i={};r.isset("systeminformation")&&(i=JSON.parse(r.get("systeminformation"))),m[s.module]={lastAccess:l},Object.assign(i,m),r.set("systeminformation",JSON.stringify(i)).then(()=>{TYPO3.ModuleMenu.App.showModule(s.module,s.params),c.Topbar.refresh()})}}var p=new n;export{p as default};
|