def __init__(self, report, text, color, background_color, border, width, height, htmlCode, encoding, dataSrc, helper, options, profile): tmpText = [] if not isinstance(text, list): content = [] for line in text.strip().split("\n"): content.append(line.strip()) text = [" ".join(content)] for t in text: cssStyles = re.search(" css\{(.*)\}", t) jsAttr = {} if cssStyles is not None: content = t.replace(cssStyles.group(0), '').decode(encoding) if hasattr(t, 'decode') else t.replace(cssStyles.group(0), '') tmpText.append(content) for cssAttr in cssStyles.group(1).split(","): cssKey, cssVal = cssAttr.split(":") jsAttr[cssKey.strip()] = cssVal.strip() else: if hasattr(t, 'decode'): tmpText.append(t.decode(encoding)) else: tmpText.append(t) options["classes"].append(jsAttr) super(Paragraph, self).__init__(report, tmpText, htmlCode=htmlCode, css_attrs={'color': color, "width": width, "height": height, "background-color": background_color}, profile=profile) self.add_helper(helper) self.__options = OptText.OptionsText(self, options) if border: self.css('border', '1px solid %s' % self._report.theme.greys[9]) self.css({'text-align': 'justify', 'margin-top': '3px', "text-justify": 'distribute'})
def __init__(self, report, text="", color=None, align=None, width=None, height=None, htmlCode=None, tooltip=None, options=None, profile=None): super(Span, self).__init__(report, text, css_attrs={"width": width, "height": height, "color": color, 'text-align': align}, htmlCode=htmlCode, profile=profile) self.css({'line-height': '%spx' % Default_html.LINE_HEIGHT, 'margin': '0 5px', 'display': 'inline-block', 'vertical-align': 'middle'}) self.__options = OptText.OptionsText(self, options) if tooltip is not None: self.tooltip(tooltip)
def __init__(self, report, text, color, align, width, height, htmlCode, tooltip, options, helper, profile): super(Text, self).__init__(report, text, css_attrs={"color": color, "width": width, "height": height}, htmlCode=htmlCode, profile=profile) self.add_helper(helper) self.__options = OptText.OptionsText(self, options) #self._jsStyles = {"reset": self.options.reset, "markdown": self.options.markdown, "maxlength": self.options.limit_char} self.css({'text-align': align}) if tooltip is not None: self.tooltip(tooltip)
def __init__(self, report, rec, color, label, options, helper, profile): if rec is None: rec = {'value': 0, 'previous': 0} if label is not None: rec["label"] = label super(UpDown, self).__init__(report, rec, profile=profile) self.add_helper(helper) self.val[ 'color'] = self._report.theme.colors[9] if color is None else color self.__options = OptText.OptionsNumber(self, options)
def __init__(self, report, number, title, label, icon, color, tooltip, htmlCode, options, helper, width, profile): super(Numeric, self).__init__(report, number, htmlCode=htmlCode, profile=profile, css_attrs={"width": width, "color": color}) # Add the components label and icon self.add_label(label, css={"float": None, "width": 'none'}, htmlCode=self.htmlCode) self.add_icon(icon, htmlCode=self.htmlCode, family=options.get("icon_family")) self.add_helper(helper, css={"line-height": '20px'}) self.add_title(title, level=4, css={"margin-bottom": 0}, options={'content_table': False}) # Update the CSS Style of the component self.css({'text-align': 'center', 'display': 'inline-block'}) self.tooltip(tooltip) self.__options = OptText.OptionsNumber(self, options)
def __init__(self, report, recordSet, color, border, width, height, helper, options, profile): super(BlockText, self).__init__(report, recordSet, css_attrs={ 'color': color, "width": width, "height": height }, profile=profile) self.add_helper(helper) self.__options = OptText.OptionsText(self, options) self.css({'padding': '5px'}) if border != 'auto': self.css('border', str(border))
def __init__(self, report, text=None, color=None, align=None, width=None, height=None, htmlCode=None, tooltip=None, profile=None, options=None): text = text or [] if not isinstance(text, list): text = [text] for obj in text: if hasattr(obj, 'options'): obj.options.managed = False super(Label, self).__init__(report, text, css_attrs={"width": width, "height": height, 'color': color, 'text-align': align}, htmlCode=htmlCode, profile=profile) self.__options = OptText.OptionsText(self, options or {}) self.css({'margin': '0 5px', 'float': 'left', 'display': 'inline-block', 'line-height': '23px', 'vertical-align': 'middle', 'text-align': 'left'}) if tooltip: self.set_attrs(name='title', value=tooltip)
def __init__(self, page: primitives.PageModel, text, author, color, width, height, html_code, helper, options, profile): super(BlockQuote, self).__init__(page, { 'text': text, 'author': author }, html_code=html_code, profile=profile, css_attrs={ "width": width, "height": height, 'color': color }) self.add_helper(helper) self.__options = OptText.OptionsText(self, options)
def __init__(self, report, schema, width, height, htmlCode, options, profile, helper): super(Composite, self).__init__(report, None, css_attrs={ "width": width, "height": height }) self.__builders, ref_map = set(), {} self.__options = OptText.OptionsComposite(self, options) self.add_helper(helper) self._set_comp(None, schema, self.__builders, ref_map) self.attr = self.val.attr self._js = self.val._js self._dom = self.val._dom self._styleObj = self.val._styleObj
def __init__(self, report, status, width, height, htmlCode, profile, options): super(Status, self).__init__(report, status, htmlCode=htmlCode, css_attrs={ "width": width, "height": height }, profile=profile) self.__options = OptText.OptionsStatus(self, options) self.style.css.text_align = 'center' self.style.css.line_height = 30 self.style.css.margin = 2 self.style.css.padding = '10px auto' self.context = self._report.ui.menus.contextual() self.contextMenu(self.context, jsFncs=[])
def __init__(self, report, data, width, height, htmlCode, helper, options, profile): super(Console, self).__init__(report, data, htmlCode=htmlCode, css_attrs={ "width": width, "height": height }, profile=profile) self.css({ "overflow": 'auto', 'box-sizing': 'border-box', 'color': self._report.theme.greys[-1], 'background': self._report.theme.colors[0] }) self.__options = OptText.OptionsConsole(self, options) self.add_helper(helper)
def __init__(self, report, records, width, height, options, helper, profile): super(Delta, self).__init__(report, records, css_attrs={ "width": width, "height": height }, profile=profile) self.add_helper(helper) if not 'color' in self.val: self.val['color'] = self._report.theme.colors[9] if not 'thresold1' in self.val: self.val['thresold1'] = 100 if not 'thresold2' in self.val: self.val['thresold2'] = 50 self.css({"color": self.val['color']}) self.__options = OptText.OptionsNumber(self, options)
def __init__(self, report, recordSet, width, height, align, helper, options, profile): super(TextWithBorder, self).__init__(report, recordSet, css_attrs={ "width": width, "height": height }, profile=profile) self.add_helper(helper) self.__options = OptText.OptionsText(self, options) self.align = align if not 'colorTitle' in self.val: self.val['colorTitle'] = self._report.theme.colors[9] if not 'color' in self.val: self.val['color'] = self._report.theme.colors[9] self.css({ "border-color": self.val['colorTitle'], 'margin-top': '20px' })
def __init__(self, report, text, url, icon, helper, height, decoration, htmlCode, options, profile): super(ExternalLink, self).__init__(report, { "text": text, "url": url }, htmlCode=htmlCode, css_attrs={'height': height}, profile=profile) # Add the internal components icon and helper self.add_icon(icon, htmlCode=self.htmlCode, family=options.get("icon_family")) self.add_helper(helper) self.decoration, self.__url = decoration, {} self.__options = OptText.OptionsLink(self, options) if not 'url' in self.val: self.options.url = self.val['text'] else: self.options.url = self.val['url']
def __init__(self, report, text, level, name, contents, color, picture, icon, marginTop, htmlCode, width, height, align, options, profile): cssStyles = re.search(" css\{(.*)\}", text) if cssStyles is not None: text = text.replace(cssStyles.group(0), '') for cssAttr in cssStyles.group(1).split(","): cssKey, cssVal = cssAttr.split(":") options[cssKey.strip()] = cssVal.strip() super(Title, self).__init__(report, text, htmlCode=htmlCode, css_attrs={"width": width, "height": height}, profile=profile) self.__options = OptText.OptionsTitle(self, options) self._name, self.level, self.picture = name, level, picture self.add_icon(icon, htmlCode=self.htmlCode, family=options.get("icon_family")) if contents is not None: self._name = contents.add(text, level or 1, name) if level is not None and level < 5: getattr(self.style.add_classes.text, "title_%s" % level)() self.css({'color': color, 'margin': '%spx 0 5px 0' % marginTop, 'font-size': Default_css.font({1: 15, 2: 10, 3: 6, 4: 3}[level])}) else: self.style.add_classes.text.title() self.css({'margin': '%spx 0 5px 0' % marginTop, 'font-size': Default_css.font(10)}) if align == 'center': self.css({'margin': '5px auto 10px auto', 'display': 'block', 'text-align': 'center'}) elif align is not None: self.css({'margin': '5px auto 10px auto', 'display': 'block', 'text-align': align}) else: self.css({'display': 'block', "margin-right": "10px"}) if hasattr(report, '_content_table') and self.__options.content_table: # Special attribute set in the base component interface div = self._report.ui.div(htmlCode="%s_anchor" % self.htmlCode) if self._report.body.css('padding-top') is None: div.style.css.margin_top = - 10 else: div.style.css.margin_top = - int(self._report.body.css('padding-top')[:-2]) - 10 div.style.css.position = "absolute" div.style.css.z_index = -1 report._content_table.anchor(text, level or 4, "#%s_anchor" % self.htmlCode) report._content_table[-1].click([ self.dom.transition(["color", "font-size"], ['red', '102%'], duration=[0.5, 0.5], reverse=True)])
def __init__(self, report, legend, width, height, helper, options, profile): super(Fieldset, self).__init__(report, legend, css_attrs={"width": width, "height": height}, profile=profile) self.add_helper(helper) self.css({'padding': '5px', 'border': '1px groove %s' % self._report.theme.greys[3], 'display': 'block', 'margin': '5px 0'}) self.__options = OptText.OptionsText(self, options)
def __init__(self, report, vals, color, width, height, htmlCode, dataSrc, options, helper, profile): super(Pre, self).__init__(report, vals, htmlCode=htmlCode, css_attrs={"width": width, 'height': height, 'color': color}, profile=profile) self.__options = OptText.OptionsText(self, options) self.css({"text-align": 'left'}) self.add_helper(helper)
def __init__(self, report, text, author, color, width, height, htmlCode, helper, options, profile): super(BlockQuote, self).__init__(report, {'text': text, 'author': author}, htmlCode=htmlCode, profile=profile, css_attrs={"width": width, "height": height, 'color': color, "white-space": 'nowrap'}) self.add_helper(helper) self.__options = OptText.OptionsText(self, options)
def __init__(self, report, start, width, height, options, profile): super(Slides, self).__init__(report, [], css_attrs={"width": width, 'height': height}, profile=profile) self.__options = OptText.OptionsText(self, options) self.attr['data-current_slide'] = start self.title = self._report.ui.title("") self.title.style.css.border_bottom = "1px solid %s" % report.theme.colors[7] self.title.style.css.color = report.theme.colors[7] self.title.style.css.margin = 0 self.title.options.managed = False if 'contents' in options: del report._content_table self._content_table = options['contents'] self._content_table.style.css.z_index = 100 if 'timer' in options: self._report.ui.calendars.timer(options['timer']).css({"position": 'fixed', "font-size": '15px', 'top': '8px', "padding": '8px', "right": '15px', 'width': 'none', 'color': report.theme.greys[5]}) self.next = self._report.ui.icon("fas fa-arrow-alt-circle-right").css({"position": 'fixed', "font-size": '35px', 'bottom': '0', "padding": '8px', "right": '10px', 'width': 'none'}) self.previous = self._report.ui.icon("fas fa-arrow-alt-circle-left").css({"position": 'fixed', "font-size": '35px', 'bottom': '0', "padding": '8px', "left": '10px', 'width': 'none'}) self.page_number = self._report.ui.text("").css({"position": 'fixed', 'z-index': 101, "font-size": '25px', 'bottom': '0', "padding": '8px', "left": '50%', 'width': 'none'}) self.next.click([ self._report.js.getElementsByName(self.htmlCode).all([data.loops.dom_list.hide()]), data.primitives.float(self.dom.attr("data-current_slide").toString().parseFloat().add(1), 'slide_index'), self.js.if_(report.js.object('slide_index') <= self.dom.attr('data-last_slide'), [ self.title.build(self._report.js.getElementsByName(self.htmlCode)[report.js.object('slide_index')].attr('data-slide_title')), self.dom.attr("data-current_slide", report.js.object('slide_index')), self._report.js.getElementsByName(self.htmlCode)[report.js.object('slide_index')].show(display_value='flex'), self._report.js.getElementById("%s_count" % self.htmlCode).innerHTML(report.js.object('slide_index').toString().parseFloat().add(1)), ]).else_([ self.title.build(self._report.js.getElementsByName(self.htmlCode)[report.js.object('slide_index').add(-1)].attr('data-slide_title')), self._report.js.getElementsByName(self.htmlCode)[report.js.object('slide_index').add(-1)].show(display_value='flex')]), self.js.if_(report.js.object('slide_index') > 0, [self.previous.dom.show()]), self.js.if_(report.js.object('slide_index') == self.dom.attr('data-last_slide'), [self.next.dom.hide()]) ]) self.previous.click([ self._report.js.getElementsByName(self.htmlCode).all([data.loops.dom_list.hide()]), data.primitives.float(self.dom.attr("data-current_slide").toString().parseFloat().add(-1), 'slide_index'), self.js.if_(report.js.object('slide_index') >= 0, [ self.title.build(self._report.js.getElementsByName(self.htmlCode)[report.js.object('slide_index')].attr('data-slide_title')), self.dom.attr("data-current_slide", report.js.object('slide_index')), self._report.js.getElementsByName(self.htmlCode)[report.js.object('slide_index')].show(display_value='flex'), self._report.js.getElementById("%s_count" % self.htmlCode).innerHTML(report.js.object('slide_index').toString().parseFloat().add(1)), ]).else_([ self.title.build(self._report.js.getElementsByName(self.htmlCode)[0].attr('data-slide_title')), self._report.js.getElementsByName(self.htmlCode)[0].show(display_value='flex')]), self.js.if_(report.js.object('slide_index') == 0, [self.previous.dom.hide()]), self.js.if_(report.js.object('slide_index') < self.dom.attr('data-last_slide'), [self.next.dom.show()]) ]) # Add the keyboard shortcut report.body.keydown.right([self.next.dom.events.trigger("click")]) report.body.keydown.left([self.previous.dom.events.trigger("click")]) self.style.css.padding = "0 20px 20px 20px"