def __init__(self, report, title, width, height, htmlCode, options, profile): self.indices, self.first_level, self.entries_count, self.ext_links = [], None, 0, {} super(ContentsTable, self).__init__(report, [], htmlCode=htmlCode, css_attrs={ "width": width, "height": height }, profile=profile) self.style.css.position = "fixed" self.title = self._report.ui.div() self.title += self._report.ui.text(title).css({ "width": 'auto', 'display': 'inline-block' }) self.title += self._report.ui.text("[hide]").css({ "width": '30px', 'display': 'inline-block', 'margin-left': '5px', 'font-size': Defaults_css.font(-5) }) self.title[0].style.css.font_size = Defaults_css.font(6) self.title[0].style.css.font_weight = "bold" self.title.options.managed = False self.menu = self._report.ui.div(htmlCode="content_page")
def divisor(self, data, divider=None, width=(100, '%'), height=(None, 'px'), options=None, profile=False): """ Description: ------------ Add list of items separated by a symbol (default BLACK_RIGHT_POINTING_TRIANGLE). The components will be based on Links Usage:: record = [] rptObj.ui.menus.divisor(record) Underlying HTML Objects: - :class:`epyk.core.html.HtmlContainer.Div` - :class:`epyk.core.html.HtmlText.link` Attributes: ---------- :param divider: symbols.shape or String. The symbol between the links :param width: Tuple. Optional. A tuple with the integer for the component width and its unit :param height: Tuple. Optional. A tuple with the integer for the component height and its unit :param options: Dictionary. Optional. Specific Python options available for this component :param profile: Boolean or Dictionary. Optional. A flag to set the component performance storage """ if divider is None: divider = self.context.rptObj.symbols.shapes.BLACK_RIGHT_POINTING_TRIANGLE div = self.context.rptObj.ui.div(width=width, height=height, options=options, profile=profile) div.texts = [] for rec in data[:-1]: if not isinstance(rec, dict): rec = {"text": rec} div.texts.append( self.context.rptObj.ui.link(*rec).css( {"display": 'inline-block'})) div += div.texts[-1] div += self.context.rptObj.ui.text(divider).css({ "display": 'inline-block', 'margin': '0 5px', 'font-size': Defaults_css.font(-2) }) rec = { "text": data[-1] } if not isinstance(data[-1], dict) else data[-1] div += self.context.rptObj.ui.link(*rec).css( {"display": 'inline-block'}) return div
def text(self, text, width=('auto', ""), tooltip=None, height=(None, "px"), profile=None, options=None): """ Description: ----------- Attributes: ---------- :param text: :param width: Tuple. Optional. A tuple with the integer for the component width and its unit :param tooltip: :param height: :param profile: :param options: """ c = self.context.rptObj.ui.text(text, tooltip=tooltip, width=width, height=height, profile=profile, options=options) c.style.add_classes.div.background_hover() c.style.css.border_radius = 5 c.style.css.font_size = Defaults_css.font(-2) c.style.css.padding = '1px 2px' return c
def __init__(self, report, position, icon, text, tooltip, width, height, htmlCode, options, profile): super(IconEdit, self).__init__(report, '', htmlCode=htmlCode, profile=profile, css_attrs={ "width": width, 'height': height, 'float': 'left' if position is None else position }) if tooltip is not None: self.tooltip(tooltip) # Add the internal components icons and helper self.add_span(text) #, css={"float": 'right'}) if width[0] is not None and width[1] == 'px': self.add_icon(icon, { "margin": "2px", 'font-size': "%s%s" % (width[0], width[1]) }, htmlCode=self.htmlCode, family=options.get("icon_family")) else: self.add_icon(icon, { "margin": "2px", 'font-size': Defaults_css.font() }, htmlCode=self.htmlCode, family=options.get("icon_family")) self.css({"margin": "5px 0", 'cursor': 'pointer'})
def __init__(self, rptObj): super(AttrIcon, self).__init__(rptObj) self.font_size = Defaults_css.font() self.vertical_align = "middle" self.display = "inline-block" self.margin = "auto 0" self.padding = "auto 0"
def absolute(self, text, size_notch=None, top=(50, "%"), left=(50, "%"), bottom=None, align='left', width=('auto', ""), height=(None, "px"), htmlCode=None, options=None, profile=None): """ Description: ------------ Attributes: ---------- :param text: :param size_notch: :param top: :param left: :param bottom: :param align: :param width: :param height: :param htmlCode: :param options: :param profile: """ left = Arguments.size(left, unit="%") top = Arguments.size(top, unit="%") width = Arguments.size(width, unit="%") height = Arguments.size(height, unit="px") dfl_options = {"reset": False, "markdown": False, "maxlength": None} if options is not None: dfl_options.update(options) text = self.context.rptObj.py.encode_html(text) text_comp = html.HtmlText.Text(self.context.rptObj, text, None, align, width, height, htmlCode, None, dfl_options, None, profile) text_comp.style.position = "absolute" text_comp.style.display = "block" if bottom is not None: text_comp.style.bottom = "%s%s" % (bottom[0], bottom[1]) else: text_comp.style.top = "%s%s" % (top[0], top[1]) text_comp.style.left = "%s%s" % (left[0], left[1]) text_comp.style.transform = "translate(-%s, -%s)" % ( text_comp.style.left, text_comp.style.top) if size_notch is not None: text_comp.style.font_size = Defaults_css.font(size_notch) if width[0] == 'auto': text_comp.style.css.display = "inline-block" return text_comp
def subtitle(self, text=None, name=None, contents=None, color=None, picture=None, icon=None, marginTop=5, htmlCode=None, width=("auto", ""), height=(None, "px"), align=None, options=None, profile=None): """ Description: ------------ Attributes: ---------- :param text: :param name: :param contents: :param color: :param picture: :param icon: :param marginTop: :param htmlCode: :param width: :param height: :param align: :param options: :param profile: """ width = Arguments.size(width, unit="px") height = Arguments.size(height, unit="px") title = self.context.rptObj.ui.title(text=text, name=name, contents=contents, color=color, picture=picture, icon=icon, marginTop=marginTop, htmlCode=htmlCode, width=width, height=height, align=align, options=options, profile=profile) title.style.css.font_size = Defaults_css.font(3) title.style.css.bold() return title
def __init__(self, htmlObj): super(NavBar, self).__init__(htmlObj) self.font_size = Defaults_css.font(8) self.display = 'block' self.margin = 0 self.vertical_align = 'top' self.left = 0 self.box_sizing = "border-box" self.padding = "0 5px 0 2px" self.position = "fixed" self.background_color = htmlObj._report.theme.greys[0] self.border_bottom = "1px solid %s" % htmlObj._report.theme.greys[4] self.top = 0 self.z_index = 310
def __str__(self): item = [ '<fieldset %s>' % self.get_attrs(pyClassNames=self.style.get_classes()) ] if 'icon' in self.val: self.val['align'] = self.align item.append( '<i class="%(icon)s fa-5x" style="width:100%%;text-align:%(align)s;margin:2px 0 10px 0;color:%(color)s"></i>' % self.val) if 'url' in self.val: item.append( '<legend style="font-size:%spx;color:%s"></legend><span></span><br><a style="float:right" href="%s">+ more details</a></fieldset>' % (Defaults_css.font(10), self.val['colorTitle'], self.val['url'])) else: item.append( '<legend style="font-size:%spx;color:%s"></legend><span></span></fieldset>' % (Defaults_css.font(10), self.val['colorTitle'])) item.append(self.helper) self._report._props.setdefault('js', {}).setdefault( "builders", []).append(self.refresh()) return "".join(item)
def up_down(self, rec=None, color=None, label=None, options=None, helper=None, profile=None): """ Description: ------------ Up and down Text component Usage:: rptObj.ui.texts.up_down({'previous': 240885, 'value': 240985}) Underlying HTML Objects: - :class:`epyk.core.html.HtmlText.UpDown` Related Pages: https://fontawesome.com/ Attributes: ---------- :param rec: :param color: :param label: :param options: :param helper: :param profile: """ dflt_options = { "digits": 0, 'thousand_sep': ",", 'decimal_sep': ".", 'font_size': Defaults_css.font(), 'red': self.context.rptObj.theme.danger[1], 'green': self.context.rptObj.theme.success[1], 'orange': self.context.rptObj.theme.warning[1] } if options is not None: dflt_options.update(options) html_up_down = html.HtmlTextComp.UpDown(self.context.rptObj, rec, color, label, dflt_options, helper, profile) return html_up_down
def __str__(self): self._report._props.setdefault('js', {}).setdefault( "builders", []).append(self.refresh()) return '''<div %(strAttr)s> <div style="width:100%%;text-align:right;font-size:%(size)s"></div> <div id="progress" style="height:10px;color:%(color)s;border:1px solid %(greyColor)s"></div> <div style="font-size:10px;font-style:italic;color:%(greyColor)s;padding-bottom:5px;text-align:left"></div> %(helper)s </div>''' % { "strAttr": self.get_attrs(pyClassNames=self.style.get_classes()), "size": Defaults_css.font(12), 'htmlCode': self.htmlCode, "color": self.val['color'], "greyColor": self._report.theme.greys[6], "helper": self.helper }
def __str__(self): items = [ '<div %s>' % self.get_attrs(pyClassNames=self.style.get_classes()) ] items.append( '<div id="%s_title" style="font-size:%spx;text-align:left"><a></a></div>' % (self.htmlCode, Defaults_css.font(3))) items.append( '<div id="%s_p" style="width:100%%;text-justify:inter-word;text-align:justify;"></div>' % self.htmlCode) #if self.val.get('button') is not None: # items.append('<a href="#" %s><i></i></a>' % (self._report.style.getClsTag(['CssHrefNoDecoration', 'CssButtonBasic']))) items.append('</div>') self._report._props.setdefault('js', {}).setdefault( "builders", []).append(self.refresh()) return ''.join(items)
def upper(self, text=None, options=None, tooltip="", align="left", width=(None, "px"), height=('auto', ""), htmlCode=None, profile=False): """ Description: ------------ Templates: https://github.com/epykure/epyk-templates/blob/master/locals/components/list.py https://github.com/epykure/epyk-templates/blob/master/locals/components/paragraph.py Attributes: ---------- :param text: :param options: :param tooltip: :param align: :param width: :param height: :param htmlCode: :param profile: """ width = Arguments.size(width, unit="px") height = Arguments.size(height, unit="px") dflt_options = {'markdown': False} if options is not None: dflt_options.update(options) html_title = html.HtmlTags.HtmlGeneric(self.context.rptObj, "div", text, width, height, htmlCode, tooltip, dflt_options, profile) html_title.style.css.font_size = Defaults_css.font(12) html_title.style.css.text_align = align html_title.style.css.margin_top = 10 html_title.style.css.padding_bottom = 5 html_title.style.css.margin_bottom = 20 html_title.style.css.bold() html_title.style.css.text_transform = "uppercase" html_title.style.css.border_bottom = "3px solid %s" % self.context.rptObj.theme.colors[ -1] return html_title
def __init__(self, report, position, icon, text, tooltip, width, height, htmlCode, options, profile): self._options = options super(Tick, self).__init__(report, '', htmlCode=htmlCode, profile=profile, css_attrs={ "width": width, 'height': height, 'float': 'left' if position is None else position }) if tooltip is not None: self.tooltip(tooltip) # Add the internal components icons and helper self.add_span(text, css={"float": 'right'}) self.add_icon(icon, { "color": self._report.theme.success[1], "margin": "2px", 'font-size': Defaults_css.font() }, htmlCode=self.htmlCode, family=options.get("icon_family")) self.icon.style.add_classes.div.background_hover() self.css({"margin": "5px 0", 'cursor': 'pointer'}) self.style.css.float = position self.style.css.display = "inline-block" self.css({"text-align": "center"}) if text is not None: self.span.css({ "line-height": '%spx' % 25, 'vertical-align': 'middle' }) self.icon.css({ "border-radius": "%spx" % 25, "width": "%spx" % 25, "margin-right": "auto", "margin": "auto", "color": 'blue', "line-height": '%s%s' % (25, width[1]) })
def headline(self, text=None, options=None, tooltip="", align="left", width=(None, "px"), height=('auto', ""), htmlCode=None, profile=False): """ Description: ------------ Templates: https://github.com/epykure/epyk-templates/blob/master/locals/components/calendar.py https://github.com/epykure/epyk-templates/blob/master/locals/components/list.py Attributes: ---------- :param text: :param options: :param tooltip: :param align: :param width: :param height: :param htmlCode: :param profile: """ width = Arguments.size(width, unit="px") height = Arguments.size(height, unit="px") dflt_options = {'markdown': False} if options is not None: dflt_options.update(options) html_title = html.HtmlTags.HtmlGeneric(self.context.rptObj, "div", text, width, height, htmlCode, tooltip, dflt_options, profile) html_title.style.css.font_size = Defaults_css.font(8) html_title.style.css.text_align = align html_title.style.css.margin_top = 5 html_title.style.css.color = self.context.rptObj.theme.colors[-1] html_title.style.css.font_style = 'italic' return html_title
def bold(self, text=None, options=None, tooltip="", width=(None, "px"), height=('auto', ""), htmlCode=None, profile=False): """ Description: ------------ Templates: https://github.com/epykure/epyk-templates/blob/master/locals/components/list.py http://192.168.0.34:8081/script/home Attributes: ---------- :param text: :param options: :param tooltip: :param width: :param height: :param htmlCode: :param profile: """ width = Arguments.size(width, unit="px") height = Arguments.size(height, unit="px") dflt_options = {'markdown': False} if options is not None: dflt_options.update(options) html_title = html.HtmlTags.HtmlGeneric(self.context.rptObj, "div", text, width, height, htmlCode, tooltip, dflt_options, profile) html_title.style.css.font_size = Defaults_css.font(6) html_title.style.css.font_weight = "bold" html_title.style.css.color = self.context.rptObj.theme.colors[-1] return html_title
def rubric(self, text=None, options=None, tooltip="", width=(None, "px"), height=('auto', ""), htmlCode=None, profile=False): """ Description: ------------ Templates: https://github.com/epykure/epyk-templates/blob/master/locals/components/list.py Attributes: ---------- :param text: :param options: :param tooltip: :param width: :param height: :param htmlCode: :param profile: """ width = Arguments.size(width, unit="px") height = Arguments.size(height, unit="px") dflt_options = {'markdown': False} if options is not None: dflt_options.update(options) html_title = html.HtmlTags.HtmlGeneric(self.context.rptObj, "div", text, width, height, htmlCode, tooltip, dflt_options, profile) html_title.style.css.border_left = '3px solid %s' % self.context.rptObj.theme.colors[ 2] html_title.style.css.padding_left = 5 html_title.style.css.font_size = Defaults_css.font(4) return html_title
def anchor(self, text, level=0, anchor='#'): """ Description: ------------ Add link to the content table Attributes: ---------- :param text: :param level: :param anchor: """ href = self._report.ui.link(text, url=anchor) href.options.managed = False href.style.css.font_size = Defaults_css.font(2) href.style.add_classes.link.no_decoration() self.val.append(href) href.style.css.display = 'block' href.style.css.width = '100%' if level is not None: href.style.css.padding_left = (level - 1) * 5 return self
def section(self, text=None, options=None, tooltip="", align="left", width=(None, "px"), height=('auto', ""), htmlCode=None, profile=False): """ Description: ------------ Attributes: ---------- :param text: :param options: Dictionary. Optional. Specific Python options available for this component :param tooltip: String. Optional. A string with the value of the tooltip :param align: String. Optional. A string with the horizontal position of the component :param width: Tuple. Optional. A tuple with the integer for the component width and its unit :param height: Tuple. Optional. A tuple with the integer for the component height and its unit :param htmlCode: String. Optional. An identifier for this component (on both Python and Javascript side) :param profile: Boolean or Dictionary. Optional. A flag to set the component performance storage """ width = Arguments.size(width, unit="px") height = Arguments.size(height, unit="px") dflt_options = {'markdown': False} if options is not None: dflt_options.update(options) html_title = html.HtmlTags.HtmlGeneric(self.context.rptObj, "div", text, width, height, htmlCode, tooltip, dflt_options, profile) html_title.style.css.font_size = Defaults_css.font(8) html_title.style.css.text_align = align html_title.style.css.margin_top = 20 html_title.style.css.margin_bottom = 10 return html_title
def customize(self): self.css({ "background": self.rptObj.theme.colors[0], "font-size": Defaults_css.font(), 'width': 'auto' })
def __init__(self, rptObj): super(AttrInput, self).__init__(rptObj) self.font_size = Defaults_css.font() self.font_family = Defaults_css.Font.family self.box_sizing = 'border-box'
def absolute(self, text, size_notch=None, icon="", top=(50, "%"), left=(50, "%"), bottom=None, width=('auto', ""), height=(None, "px"), htmlCode=None, options=None, profile=None): """ Description: ------------ Display a button on the page regardless the current layoyt of components By default the button will be center on the page. Usage:: rptObj.ui.buttons.absolute("Test") Templates: https://github.com/epykure/epyk-templates/blob/master/locals/components/button.py Attributes: ---------- :param text: String. Optional. The value to be displayed to the button :param size_notch: :param bottom: Integer. Optional. The position of the component :param icon: String. Optional. A string with the value of the icon to display from font-awesome :param top: Tuple. Optional. A tuple with the integer for the component's distance to the top of the page :param left: Tuple. Optional. A tuple with the integer for the component's distance to the left of the page :param width: Optional. A tuple with the integer for the component width and its unit :param height: Optional. A tuple with the integer for the component height and its unit :param htmlCode: String. Optional. An identifier for this component (on both Python and Javascript side) :param options: Dictionary. Optional. Specific Python options available for this component :param profile: Optional. A flag to set the component performance storage """ left = Arguments.size(left, unit="%") top = Arguments.size(top, unit="%") width = Arguments.size(width, unit="%") height = Arguments.size(height, unit="px") html_button = html.HtmlButton.Button(self.context.rptObj, text, icon, width, height, htmlCode=htmlCode, tooltip=None, profile=profile, options=options) html_button.style.position = "absolute" html_button.style.display = "block" if bottom is not None: html_button.style.bottom = "%s%s" % (bottom[0], bottom[1]) else: html_button.style.top = "%s%s" % (top[0], top[1]) html_button.style.left = "%s%s" % (left[0], left[1]) html_button.style.transform = "translate(-%s, -%s)" % ( html_button.style.left, html_button.style.top) if size_notch is not None: html_button.style.font_size = Defaults_css.font(size_notch) if width[0] == 'auto': html_button.style.css.display = "inline-block" return html_button
def customize(self): self.css({ 'color': self.rptObj.theme.greys[-1], "background-color": self.rptObj.theme.colors[0], "font-size": Defaults_css.font() })
def __init__(self, rptObj): super(AttrSkarkline, self).__init__(rptObj) self.display = "inline-block" self.font_size = Defaults_css.font() self.margin = "1px 4px"
def __init__(self, rptObj): super(AttrButton, self).__init__(rptObj) self.font_size = Defaults_css.font()
def __init__(self, rptObj): super(AttrBadge, self).__init__(rptObj) self.padding = "1px 3px" self.margin = "1px 1px 1px 2px" self.vertical_align = "bottom" self.font_size = Defaults_css.font(-3)
def __init__(self, rptObj): super(AttrHelp, self).__init__(rptObj) self.font_size = Defaults_css.font() self.cursor = "pointer" self.float = "right" self.margin = "1px 4px"