Beispiel #1
0
 def _render_options(cls):
     return [
         (
             "metric_render_options",
             Transform(
                 Dictionary(
                     elements=[
                         ("font_size",
                          CascadingDropdown(
                              title=_("Metric value font size"),
                              orientation="horizontal",
                              choices=[
                                  ("fix", _("Set the metric value font size to:"),
                                   Fontsize(default_value="22.5")),
                                  ("dynamic",
                                   _("Dynamically adapt the metric font size to the dashlet size"
                                    ))
                              ],
                              default_value="dynamic")),
                         ("link_to_svc_detail",
                          DropdownChoice(
                              title=_("Link to service detail page"),
                              choices=[
                                  ("true",
                                   _("Open service detail page when clicking on the metric value"
                                    )), ("false", _("Do not add a link to the metric value"))
                              ],
                              default_value="true")),
                         ("show_site",
                          CascadingDropdown(
                              title=_("Show the site name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the site name"))],
                              default_value="false")),
                         ("show_host",
                          CascadingDropdown(
                              title=_("Show the host name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the host name"))],
                              default_value="false")),
                         ("show_service",
                          CascadingDropdown(
                              title=_("Show the service name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the service name"))],
                              default_value="tooltip")),
                         ("show_metric",
                          CascadingDropdown(
                              title=_("Show the metric name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the metric name"))],
                              default_value="above")),
                         ("show_state_color",
                          DropdownChoice(title=_("Show the service state color"),
                                         choices=[
                                             ("background", _("... as background color")),
                                             ("font", _("... as font color")),
                                             ("false", _("Do not show the service state color")),
                                         ],
                                         default_value="background")),
                         ("show_unit",
                          DropdownChoice(title=_("Show the metric's unit"),
                                         choices=[
                                             ("true", _("Show the metric's unit")),
                                             ("false", _("Do not show the metric's unit")),
                                         ],
                                         default_value="true")),
                     ],
                     optional_keys=[],
                     title=_("Metric rendering options"),
                 ),),
         ),
     ]
Beispiel #2
0
def vs_graph_render_option_elements(default_values=None, exclude=None):
    # Allow custom default values to be specified by the caller. This is, for example,
    # needed by the dashlets which should add the host/service by default.
    if default_values is None:
        default_values = artwork.get_default_graph_render_options()
    else:
        default_values = default_values.copy()
        for k, v in artwork.get_default_graph_render_options().items():
            default_values.setdefault(k, v)

    elements = [
        ("font_size", Fontsize(default_value=default_values["font_size"], )),
        ("show_title",
         DropdownChoice(
             title=_("Title"),
             choices=[
                 (False, _("Don't show graph title")),
                 (True, _("Show graph title")),
                 ("inline", _("Show graph title on graph area")),
             ],
             default_value=default_values["show_title"],
         )),
        ("title_format",
         Transform(
             vs_title_infos(),
             forth=transform_graph_render_options_title_format,
         )),
        ("show_graph_time",
         Checkbox(
             title=_("Show graph time range"),
             label=_("Show the graph time range on top of the graph"),
             default_value=default_values["show_graph_time"],
         )),
        ("show_margin",
         Checkbox(
             title=_("Show margin round the graph"),
             label=_("Show a margin round the graph"),
             default_value=default_values["show_margin"],
         )),
        ("show_legend",
         Checkbox(
             title=_("Show legend"),
             label=_("Show the graph legend"),
             default_value=default_values["show_legend"],
         )),
        ("show_vertical_axis",
         Checkbox(
             title=_("Show vertical axis"),
             label=_("Show the graph vertical axis"),
             default_value=default_values["show_vertical_axis"],
         )),
        ("vertical_axis_width",
         CascadingDropdown(
             title=_("Vertical axis width"),
             orientation="horizontal",
             choices=[
                 ("fixed", _("Use fixed width (relative to font size)")),
                 ("explicit", _("Use absolute width:"),
                  Float(title="", default_value=40.0, unit=_("pt"))),
             ],
         )),
        ("show_time_axis",
         Checkbox(
             title=_("Show time axis"),
             label=_("Show the graph time axis"),
             default_value=default_values["show_time_axis"],
         )),
        ("show_controls",
         Checkbox(
             title=_("Show controls"),
             label=_("Show the graph controls"),
             default_value=default_values["show_controls"],
         )),
        ("show_pin",
         Checkbox(
             title=_("Show pin"),
             label=_("Show the pin"),
             default_value=default_values["show_pin"],
         )),
        ("show_time_range_previews",
         Checkbox(
             title=_("Show time range previews"),
             label="Show previews",
             default_value=default_values["show_time_range_previews"],
         )),
        ("foreground_color",
         GraphColor(
             title=_("Foreground color"),
             default_value=default_values["foreground_color"],
         )),
        ("background_color",
         GraphColor(
             title=_("Background color"),
             default_value=default_values["background_color"],
         )),
        ("canvas_color",
         GraphColor(
             title=_("Canvas color"),
             default_value=default_values["canvas_color"],
         )),
    ]

    if exclude:
        elements = [x for x in elements if x[0] not in exclude]

    return elements