From 0fb71d4b9804bd587a023c450c2d049ee5e53aa3 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Tue, 13 Oct 2020 06:07:28 +0000 Subject: [PATCH] Update: Corrected dashboard generation, but still needs some more updates --- admin/dashboard.xsl | 46 ++++++++++++++++++++++----------------------- src/admin.c | 44 +++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/admin/dashboard.xsl b/admin/dashboard.xsl index 4cba3e59..5ffa1d8b 100644 --- a/admin/dashboard.xsl +++ b/admin/dashboard.xsl @@ -37,30 +37,28 @@ - -
-

Maintenance

- - -
    - -
  • -

    -
      - -
    • -
      -
    -
  • -
    -
-
- -

Nothing to do.

-
-
-
-
+
+

Maintenance

+ + +
    + +
  • +

    +
      + +
    • +
      +
    +
  • +
    +
+
+ +

Nothing to do.

+
+
+
diff --git a/src/admin.c b/src/admin.c index 64de6524..147bf46a 100644 --- a/src/admin.c +++ b/src/admin.c @@ -1349,26 +1349,35 @@ static void command_mark_log (client_t *client, source_t *source, adm static void __reportxml_add_maintenance(reportxml_node_t *parent, const char *type, const char *text, const char *docs) { - reportxml_node_t *maintenance = reportxml_node_new(REPORTXML_NODE_TYPE_VALUE, NULL, NULL, NULL); + reportxml_node_t *incident = reportxml_node_new(REPORTXML_NODE_TYPE_INCIDENT, NULL, NULL, NULL); + reportxml_node_t *state = reportxml_node_new(REPORTXML_NODE_TYPE_STATE, NULL, NULL, NULL); + reportxml_node_t *resource = reportxml_node_new(REPORTXML_NODE_TYPE_RESOURCE, NULL, NULL, NULL); - reportxml_node_set_attribute(maintenance, "type", "structure"); - reportxml_node_add_child(parent, maintenance); + reportxml_node_add_child(parent, incident); + reportxml_node_add_child(incident, state); + reportxml_node_add_child(incident, resource); - reportxml_helper_add_value_enum(maintenance, "type", type); + reportxml_node_set_attribute(resource, "type", "result"); + reportxml_node_set_attribute(resource, "name", "maintenance"); + + reportxml_helper_add_value_enum(resource, "type", type); if (text) - reportxml_helper_add_text(maintenance, NULL, text); + reportxml_helper_add_text(state, NULL, text); if (docs) - reportxml_helper_add_reference(maintenance, "documentation", docs); + reportxml_helper_add_reference(incident, "documentation", docs); - refobject_unref(maintenance); + refobject_unref(state); + refobject_unref(resource); + refobject_unref(incident); } static void command_dashboard (client_t *client, source_t *source, admin_format_t response) { ice_config_t *config = config_get_config(); reportxml_t *report = client_get_reportxml("0aa76ea1-bf42-49d1-887e-ca95fb307dc4", NULL, NULL); + reportxml_node_t *reportnode = reportxml_get_node_by_type(report, REPORTXML_NODE_TYPE_REPORT, 0); reportxml_node_t *incident = reportxml_get_node_by_type(report, REPORTXML_NODE_TYPE_INCIDENT, 0); reportxml_node_t *resource; reportxml_node_t *node; @@ -1414,31 +1423,22 @@ static void command_dashboard (client_t *client, source_t *source, adm reportxml_node_add_child(incident, resource); refobject_unref(resource); - - resource = reportxml_node_new(REPORTXML_NODE_TYPE_RESOURCE, NULL, NULL, NULL); - reportxml_node_set_attribute(resource, "type", "result"); - reportxml_node_set_attribute(resource, "name", "maintenance"); - if (config->config_problems & CONFIG_PROBLEM_HOSTNAME) - __reportxml_add_maintenance(resource, "warning", "Hostname is not set to anything useful in .", NULL); + __reportxml_add_maintenance(reportnode, "warning", "Hostname is not set to anything useful in .", NULL); if (config->config_problems & CONFIG_PROBLEM_LOCATION) - __reportxml_add_maintenance(resource, "warning", "No useful location is given in .", NULL); + __reportxml_add_maintenance(reportnode, "warning", "No useful location is given in .", NULL); if (config->config_problems & CONFIG_PROBLEM_ADMIN) - __reportxml_add_maintenance(resource, "warning", "No admin contact given in . YP directory support will is disabled.", NULL); + __reportxml_add_maintenance(reportnode, "warning", "No admin contact given in . YP directory support will is disabled.", NULL); if (!has_sources) - __reportxml_add_maintenance(resource, "info", "Currently no sources are connected to this server.", NULL); + __reportxml_add_maintenance(reportnode, "info", "Currently no sources are connected to this server.", NULL); if (has_too_many_clients) { - __reportxml_add_maintenance(resource, "warning", "More than 90% of the server's configured maximum clients are connected", NULL); + __reportxml_add_maintenance(reportnode, "warning", "More than 90% of the server's configured maximum clients are connected", NULL); } else if (has_many_clients) { - __reportxml_add_maintenance(resource, "info", "More than 75% of the server's configured maximum clients are connected", NULL); + __reportxml_add_maintenance(reportnode, "info", "More than 75% of the server's configured maximum clients are connected", NULL); } - reportxml_node_add_child(incident, resource); - refobject_unref(resource); - - refobject_unref(incident); config_release_config();