1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-16 06:15:24 +00:00

Feature: Only show selected mounts in status display

This commit is contained in:
Philipp Schafft 2020-10-01 17:34:31 +00:00
parent c423b36ae4
commit 47dd475f12
6 changed files with 23 additions and 6 deletions

View File

@ -5,6 +5,8 @@
<xsl:include href="includes/mountnav.xsl"/>
<xsl:include href="includes/player.xsl"/>
<xsl:param name="param-showall" />
<xsl:param name="param-has-mount" />
<xsl:variable name="title">Server status</xsl:variable>
<!-- Auth template -->
@ -42,6 +44,7 @@
<div class="stats">
<ul class="boxnav">
<li><a href="reloadconfig.xsl">Reload Configuration</a></li>
<li><a href="?showall=true">Show all mounts</a></li>
</ul>
</div>
@ -72,6 +75,7 @@
</section>
<!-- Mount stats -->
<xsl:if test="$param-showall or $param-has-mount">
<xsl:for-each select="source">
<section class="box">
<h3 class="box_title">Mountpoint <code><xsl:value-of select="@mount" /></code></h3>
@ -142,5 +146,6 @@
</section>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@ -462,6 +462,8 @@ void admin_send_response(xmlDocPtr doc,
char *fullpath_xslt_template;
size_t fullpath_xslt_template_len;
ice_config_t *config = config_get_config();
const char *showall;
const char *mount;
fullpath_xslt_template_len = strlen(config->adminroot_dir) + strlen(xslt_template) + strlen(PATH_SEPARATOR) + 1;
fullpath_xslt_template = malloc(fullpath_xslt_template_len);
@ -470,7 +472,17 @@ void admin_send_response(xmlDocPtr doc,
config_release_config();
ICECAST_LOG_DEBUG("Sending XSLT (%s)", fullpath_xslt_template);
xslt_transform(doc, fullpath_xslt_template, client, 200, NULL);
COMMAND_OPTIONAL(client, "showall", showall);
COMMAND_OPTIONAL(client, "mount", mount);
if (showall && util_str_to_bool(showall)) {
const char *params[] = {"param-has-mount", mount ? "'true'" : NULL, "param-showall", "'true'", NULL};
xslt_transform(doc, fullpath_xslt_template, client, 200, NULL, params);
} else {
const char *params[] = {"param-has-mount", mount ? "'true'" : NULL, "param-showall", NULL, NULL};
xslt_transform(doc, fullpath_xslt_template, client, 200, NULL, params);
}
free(fullpath_xslt_template);
}
}

View File

@ -642,7 +642,7 @@ void client_send_reportxml(client_t *client, reportxml_t *report, document_domai
ICECAST_LOG_DEBUG("Sending XSLT (%s)", fullpath_xslt_template);
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
xslt_transform(doc, fullpath_xslt_template, client, status, location);
xslt_transform(doc, fullpath_xslt_template, client, status, location, NULL);
free(fullpath_xslt_template);
}

View File

@ -1053,7 +1053,7 @@ void stats_transform_xslt(client_t *client)
doc = stats_get_xml(0, mount, client);
xslt_transform(doc, xslpath, client, 200, NULL);
xslt_transform(doc, xslpath, client, 200, NULL, NULL);
xmlFreeDoc(doc);
free(xslpath);

View File

@ -320,7 +320,7 @@ static inline void _send_error(client_t *client, icecast_error_id_t id, int old_
client_send_error_by_id(client, id);
}
void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, int status, const char *location)
void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, int status, const char *location, const char **params)
{
xmlDocPtr res;
xsltStylesheetPtr cur;
@ -344,7 +344,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, in
return;
}
res = xsltApplyStylesheet(cur, doc, NULL);
res = xsltApplyStylesheet(cur, doc, params);
if (res != NULL) {
if (xsltSaveResultToString(&string, &len, res, cur) < 0)
problem = 1;

View File

@ -17,7 +17,7 @@
#include "icecasttypes.h"
void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, int status, const char *location);
void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, int status, const char *location, const char **params);
void xslt_initialize(void);
void xslt_shutdown(void);
void xslt_clear_cache(void);