Пример #1
0
    def page(self) -> None:
        html.h3(_("Upload Icon"))
        html.p(
            _("Allowed are single PNG image files with a maximum size of 80x80 px."
              ))

        html.begin_form('upload_form', method='POST')
        self._vs_upload().render_input('_upload_icon', None)
        html.hidden_fields()
        html.end_form()

        icons = sorted(self._load_custom_icons().items())
        with table_element("icons", _("Custom Icons")) as table:
            for icon_name, category_name in icons:
                table.row()

                table.cell(_("Actions"), css="buttons")
                delete_url = make_action_link([("mode", "icons"),
                                               ("_delete", icon_name)])
                html.icon_button(delete_url, _("Delete this Icon"), "delete")

                table.cell(_("Icon"),
                           html.render_icon(icon_name),
                           css="buttons")
                table.text_cell(_("Name"), icon_name)
                table.text_cell(_("Category"),
                                IconSelector.category_alias(category_name))
Пример #2
0
    def page(self) -> None:
        html.p(
            _("Here you can add icons, for example to use them in bookmarks or "
              "in custom actions of views. Allowed are single PNG image files "
              "with a maximum size of 80x80 px. Custom actions have to be defined "
              "in the global settings and can be used in the custom icons rules "
              "of hosts and services."))

        html.begin_form('upload_form', method='POST')
        self._vs_upload().render_input('_upload_icon', None)
        html.hidden_fields()
        html.end_form()

        icons = sorted(self._load_custom_icons().items())
        with table_element("icons", _("Custom Icons")) as table:
            for icon_name, category_name in icons:
                table.row()

                table.cell(_("Actions"), css="buttons")
                delete_url = make_confirm_link(
                    url=make_action_link([("mode", "icons"),
                                          ("_delete", icon_name)]),
                    message=_(
                        "Do you really want to delete the icon <b>%s</b>?") %
                    icon_name,
                )
                html.icon_button(delete_url, _("Delete this Icon"), "delete")

                table.cell(_("Icon"),
                           html.render_icon(icon_name),
                           css="buttons")
                table.cell(_("Name"), icon_name)
                table.cell(_("Category"),
                           IconSelector.category_alias(category_name))
Пример #3
0
    def parameters(cls, mode):
        def bookmark_config_to_vs(v):
            if v:
                return (v["title"], v["url"], v["icon"], v["topic"])
            return v

        def bookmark_vs_to_config(v):
            return {
                "title": v[0],
                "url": v[1],
                "icon": v[2],
                "topic": v[3],
            }

        parameters = super(BookmarkList, cls).parameters(mode)

        parameters += [(
            _("Bookmarks"),
            [
                # sort-index, key, valuespec
                (2.5, "default_topic",
                 TextUnicode(
                     title=_("Default Topic") + "<sup>*</sup>",
                     size=50,
                     allow_empty=False,
                 )),
                (
                    3.0,
                    "bookmarks",
                    ListOf(
                        # For the editor we want a compact dialog. The tuple horizontal editin mechanism
                        # is exactly the thing we want. But we want to store the data as dict. This is a
                        # nasty hack to use the transform by default. Better would be to make Dict render
                        # the same way the tuple is rendered.
                        Transform(
                            Tuple(
                                elements=[
                                    (TextUnicode(
                                        title=_("Title") + "<sup>*</sup>",
                                        size=30,
                                        allow_empty=False,
                                    )),
                                    (TextUnicode(
                                        title=_("URL"),
                                        size=50,
                                        allow_empty=False,
                                        validate=cls.validate_url,
                                    )),
                                    (IconSelector(title=_("Icon"), )),
                                    (cls._vs_topic()),
                                ],
                                orientation="horizontal",
                                title=_("Bookmarks"),
                            ),
                            forth=bookmark_config_to_vs,
                            back=bookmark_vs_to_config,
                        )))
            ])]

        return parameters
Пример #4
0
 def _load_custom_icons(self):
     s = IconSelector()
     return s.available_icons(only_local=True)
Пример #5
0
 def _load_custom_icons(self):
     s = IconSelector(show_builtin_icons=False, with_emblem=False)
     return s.available_icons(only_local=True)