neue Kategorien [GELÖST]
neue Kategorien
man hat ja im Adminbereich die Dienst/port Überwachungsübersicht. Kann man solch eine Box auch für Systemdienste machen und entsprechende Kategorien anlegen damit man sofort sieht das die Dienste laufen und manuel neu starten kann (ähnlich Serverdienstverwaltung)?
Ich habe einige eigene Dienste am laufen und da in der Serverdienstverwaltung alles streng nach Alphabet geordnet wird (Trotz Kategorie) ist natürlich alles unter Benutzerdefinierte Dienste "gequetscht". Der Übersicht halber und auch des Komforts hätte ich es gern als eigene Box in der Adminübersicht, zB wenn man unter Benutzerdefinierte Dienste eine Kategorie angibt, erscheint auf der Hauptseite über Dienst/Portüberwachung eine Box mit der Kategorie und allen diensten die in dieser Kategorie sind (mit start, stop, restart). Wärenatürlich noch toll, wenn man es Optional auch bei dem Kunden im Dashboard (Übersichtsseite) anzeigen lassen kann.
Liebe Grüße
_____________________________
Meine Erweiterungen für Keyhelp:
Keyhelp Kernel-Ipset Firewall
KeyHelp Dashboard Layout Customizer
KeyHelp GitHub Release Downloads Widget
▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽
https://github.com/NicoMSH-plugins
Re: neue Kategorien [GELÖST]
EDIT: Einzutragen im Adminpanel unter Konfiguration -> White-Label -> Zusätzliches JavaScript
Code: Select all
// benutzerdefinierte Service Boxen im Dashboard
// custom service boxes in the dashboard
if ('admin_dashboard' === getUrlQueryParameterValue('page')) {
$(function() {
// hier die Kategorien der benutzerdefinierten Services eintragen (mit Komma getrennt)
// enter the categories for the custom services here (separated by commas)
const categories = ['Owncast', 'Musicbot'];
// Einrückung der Boxen über System-/Portüberwachung
// Indentation of the boxes via system/port monitoring
let $portTable = $('table').filter(function() {
let htmlText = $(this).text();
return htmlText.includes('FTP') && htmlText.includes('SSH');
}).first();
// Fallback über die bekannten Icons der Portüberwachungs-Box
// Fallback using the known icons from the port monitoring box
if (!$portTable.length) {
$portTable = $('table').filter(function() {
return $(this).find('.fa-network-wired, .fa-server, .fa-desktop').length > 0;
}).first();
}
let $portCard = $portTable.closest('.card, .box');
let txtLoading = '...';
let $nativeLoadingText = $('.has-text-grey, .loading, .is-loading, .loading-indicator').first();
if ($nativeLoadingText.length) {
txtLoading = $nativeLoadingText.text().trim();
}
// Erstellt für jede Kategorie eine eigene Box
// Creates a separate box for each category
categories.forEach(function(catName, index) {
let safeId = 'custom-service-box-' + index;
let $customBox = $(`
<div class="card mt-5 mb-5" id="${safeId}-card" style="margin-top: 1.5rem !important; margin-bottom: 1.5rem !important;">
<header class="card-header">
<span class="card-header-icon">
<i class="fas fa-cogs"></i>
</span>
<p class="card-header-title">${catName}</p>
</header>
<div class="card-content">
<div class="table-container" id="${safeId}-content">
<p class="has-text-grey">${txtLoading}</p>
</div>
</div>
</div>
`);
if ($portCard.length) {
$portCard.before($customBox);
}
});
function extractAndRenderTables($parsedHtml, rawHtml, servicePageUrl) {
let $masterTable = null;
let firstInputCategory = (categories.length > 0) ? categories[0] : 'Owncast';
$parsedHtml.find('table').each(function() {
let cleanedText = $(this).text().replace(/\s+/g, ' ').trim().toLowerCase();
if (cleanedText.includes(firstInputCategory.toLowerCase())) {
$masterTable = $(this);
return false;
}
});
if ($masterTable) {
// Neutraler Name für den serverübergreifenden Verteil-Einsatz
// Neutral name for the cross-server distribution operation
localStorage.setItem('kh_custom_services_url', servicePageUrl);
categories.forEach(function(catName, index) {
let safeId = 'custom-service-box-' + index;
let $catTable = $masterTable.clone();
let keptRows = 0;
$catTable.find('thead th, thead td').each(function(cellIndex) {
if (cellIndex === 1) {
$(this).hide();
} else if (cellIndex === 0) {
$(this).css({ 'width': '42%', 'white-space': 'nowrap' });
} else if (cellIndex === 2 || cellIndex === 3) {
$(this).css({ 'width': '20%', 'white-space': 'nowrap' });
}
});
$catTable.find('tbody tr').each(function() {
let $row = $(this);
if ($row.closest('tfoot').length || $row.hasClass('is-footer') || $row.find('td[colspan], th[colspan]').length > 0) {
return;
}
let isMatch = false;
$row.find('td, th').each(function() {
if ($(this).text().replace(/\s+/g, ' ').trim().toLowerCase() === catName.toLowerCase()) {
isMatch = true;
}
});
if (isMatch) {
keptRows++;
let $visibleCells = $row.children('th, td').filter(function() {
return $(this).css('display') !== 'none' && !$(this).hasClass('is-hidden');
});
if ($visibleCells.length >= 1) {
$visibleCells.eq(0).css({
'white-space': 'nowrap',
'width': '42%',
'padding-right': '1.5rem'
});
}
if ($visibleCells.length >= 5) {
$visibleCells.eq(1).hide();
}
} else {
$row.remove();
}
});
$catTable.find('tfoot td, tfoot th, tbody tr.is-footer td').each(function() {
let cellText = $(this).text().trim();
let numMatch = cellText.match(/[0-9]+/);
if (numMatch) {
$(this).text(cellText.replace(numMatch[0], keptRows));
}
});
$('#' + safeId + '-content').empty().append($catTable);
});
// Einmalig AJAX-Umleitung und KeyHelp-Status-Abfrage für alle Boxen starten
// Initiate a one-time AJAX redirect and KeyHelp status query for all boxes
$.ajaxPrefilter(function(options) {
let isServiceCall = (
options.url.includes('admin_dashboard') ||
options.url === '' ||
options.url === window.location.href ||
options.url === window.location.search
);
if (isServiceCall && !options.url.includes('page=admin_service_management')) {
options.url = servicePageUrl;
}
});
let originalUrl = window.location.href;
try {
window.history.replaceState(null, '', servicePageUrl);
} catch (e) {}
let scriptMatches = rawHtml.match(/<script\b[^>]*>([\s\S]*?)<\/script>/gi) || [];
scriptMatches.forEach(function(scriptTag) {
let srcMatch = scriptTag.match(/src=["']([^"']+)["']/i);
if (srcMatch && srcMatch) {
let jsFile = srcMatch[1];
if (!jsFile.includes('jquery') && !jsFile.includes('vendor') && !jsFile.includes('app.js')) {
$.getScript(jsFile);
}
} else {
let inlineCode = scriptTag.replace(/<\/?script[^>]*>/gi, '');
if (inlineCode.includes('service') || inlineCode.includes('status') || inlineCode.includes('ajax')) {
try {
window.eval(inlineCode);
} catch (e) {}
}
}
});
setTimeout(function() {
try {
window.history.replaceState(null, '', originalUrl);
} catch (e) {}
}, 400);
return true;
}
return false;
}
let cachedUrl = localStorage.getItem('kh_custom_services_url') || 'index.php?page=admin_service_management';
$.get(cachedUrl, function(htmlData) {
let $parsed = $('<div>').append($.parseHTML(htmlData));
if (extractAndRenderTables($parsed, htmlData, cachedUrl)) {
return;
}
let subPageUrl = null;
$parsed.find('a, option').each(function() {
let target = $(this).attr('href') || $(this).attr('value') || '';
if (target.includes('page=admin_service_management') || target.includes('service')) {
if (target && !target.includes('admin_dashboard')) {
subPageUrl = target.startsWith('?') ? 'index.php' + target : target;
return false;
}
}
});
if (subPageUrl) {
$.get(subPageUrl, function(subHtml) {
let $subParsed = $('<div>').append($.parseHTML(subHtml));
extractAndRenderTables($subParsed, subHtml, subPageUrl);
});
}
});
});
}_____________________________
Meine Erweiterungen für Keyhelp:
Keyhelp Kernel-Ipset Firewall
KeyHelp Dashboard Layout Customizer
KeyHelp GitHub Release Downloads Widget
▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽
https://github.com/NicoMSH-plugins