def __str__(self):
        """ Return the svg container """
        self.processData()
        categories = AresHtmlRadio.Radio(
            self.aresObj, [key for key, _, _ in self.chartKeys],
            cssAttr={'display': 'None'} if len(self.chartKeys) == 2 else {},
            internalRef='key_%s' % self.htmlId)
        categories.select(self.selectedChartKey)
        self.dynKeySelection = categories.val  # The javascript representation of the radio
        values = AresHtmlRadio.Radio(
            self.aresObj, [val for val, _, _ in self.chartVals],
            cssAttr={'display': 'None'} if len(self.chartVals) == 1 else {},
            internalRef='val_%s' % self.htmlId)
        values.select(self.selectedChartVal)
        self.dynValSelection = values.val  # The javascript representation of the radio

        categories.click([self])
        values.click([self])

        self.htmlContent.append(str(categories))
        self.htmlContent.append(str(values))
        self.htmlContent.append('<div %s></div>' % self.strAttr())
        return str(
            AresHtmlContainer.AresBox(self.htmlId,
                                      "\n".join(self.htmlContent),
                                      self.headerBox,
                                      properties=self.references))
示例#2
0
    def __str__(self):
        """ Return the svg container """
        self.processData()
        self.categories = AresHtmlRadio.Radio(
            self.aresObj, [key for key, _, _ in self.chartKeys],
            cssAttr={'display': 'None'} if len(self.chartKeys) == 1 else {},
            checked=self.selectedChartKey)
        self.values = AresHtmlRadio.Radio(
            self.aresObj, [val for val, _, _ in self.chartVals],
            cssAttr={'display': 'None'} if len(self.chartVals) == 1 else {},
            checked=self.selectedChartVal)
        self.categories.click([self])
        self.values.click([self])

        self.htmlContent.append(str(self.categories))
        self.htmlContent.append(str(self.values))
        self.htmlContent.append(
            '<div %s style="height:%spx;"><svg style="width:100%%;height:%spx;"></svg></div>'
            % (self.strAttr(), self.height, self.height))
        if self.headerBox:
            return str(
                AresHtmlContainer.AresBox(self.htmlId,
                                          "\n".join(self.htmlContent),
                                          self.headerBox,
                                          properties=self.references))

        return "\n".join(self.htmlContent)
 def __str__(self):
     item = AresItem.Item(None, self.incIndent)
     item.add(0, '<div %s></div>' % self.strAttr())
     if self.headerBox is not None:
         item = AresHtmlContainer.AresBox(self.htmlId,
                                          item,
                                          self.headerBox,
                                          properties=self.references)
     return str(item)
示例#4
0
  def __str__(self):
    """ Return a header HTML Tag """
    items = AresItem.Item('<H%s>' % self.dim)
    items.add(1, '<a class="anchorjs-link" %s style="color:inherit">%s</a>' % (self.strAttr(), self.vals))
    items.add(0, '</H%s>' % self.dim)
    if self.aresObj.withContainer:
      return str(AresHtmlContainer.TextContainer(self.aresObj, str(items)))

    return str(items)
示例#5
0
  def __str__(self):
    """ Return the String representation of a Code HTML tag """
    item = AresItem.Item(None)
    if self.htmlComp is not None:
      self.vals = self.vals.format(*self.htmlComp)
    for val in self.vals.split("\n"):
      item.add(1, "<p class='text-justify'>%s</p>" % val.strip())
    if self.aresObj.withContainer:
      return str(AresHtmlContainer.TextContainer(self.aresObj, str(item)))

    return str(item)
示例#6
0
    def __str__(self):
        """ Return the svg container """
        for seriesGrp in self.seriesGrps:
            for filter in seriesGrp.filters:
                for chart in seriesGrp.xFilter.charts:
                    # Update all the charts linked to a given recordSet
                    filter.change(chart.jsUpdate())

        items = []
        if self.chartDesc is not None:
            self.chartDesc.attr.setdefault('css', {}).update(
                {'margin-bottom': '10px'})
            items.append(str(self.chartDesc))

        if not self.multiSeries and len(self.seriesGrps) > 1:
            # The type of chart cannot handle multiple series so the different other groups will be display in a
            # list with all the group names
            items.append(
                '<div class="list-group" style="float:left;height:%spx;width:25%%;margin-top:5px">'
                % self.height)
            for i, seriesGrp in enumerate(self.seriesGrps):
                if i == 0:
                    items.append(
                        '<button  type="button" class="list-group-item list-group-item-action list-group-item-success">%s</button>'
                        % seriesGrp.jsVar['grpName'])
                else:
                    items.append(
                        '<button  type="button" class="list-group-item list-group-item-action">%s</button>'
                        % seriesGrp.jsVar['grpName'])
            items.append('</div>')
            self.attr.setdefault('css', {}).update({
                'float': 'right',
                'width': '74%'
            })
        items.append(
            '<div %s><svg style="width:100%%;height:%spx;"></svg></div>' %
            (self.strAttr(), self.height))

        if self.headerBox:
            return str(
                AresHtmlContainer.AresBox(self.htmlId,
                                          "\n".join(items),
                                          self.headerBox,
                                          properties=self.references))

        return "\n".join(items)
示例#7
0
  def __str__(self):
    """ Return the svg container """
    self.processData()
    self.categories = AresHtmlRadio.Radio(self.aresObj, [key for key, _, _ in self.chartKeys], cssAttr={'display': 'None'}, internalRef='key_%s' % self.htmlId,
                                     checked=self.selectedChartKey)
    self.values = AresHtmlRadio.Radio(self.aresObj, [val for val, _, _ in self.chartVals], cssAttr={'display': 'None'}, internalRef='val_%s' % self.htmlId,
                                 checked=self.selectedChartVal)

    self.categories.click([self])
    self.values.click([self])

    self.htmlContent.append(str(self.categories))
    self.htmlContent.append(str(self.values))
    self.htmlContent.append('<div %s></div>' % self.strAttr())
    if self.headerBox:
      return str(AresHtmlContainer.AresBox(self.htmlId, "\n".join(self.htmlContent), self.headerBox, properties=self.references))

    return "\n".join(self.htmlContent)
示例#8
0
    def __str__(self):
        """  Returns the string representation of a HTML Table """
        self.mouveHover('#BFFCA6', 'black')
        trAttr = []
        if 'css' in self.__rows_attr['ALL']:
            trAttr.append('style="%s"' % ";".join([
                "%s:%s" % (key, val)
                for key, val in self.__rows_attr['ALL']["css"].items()
            ]))
        for attrCod in ['onmouseover', 'onMouseOut', 'class']:
            if attrCod in self.__rows_attr['ALL']:
                trAttr.append(
                    '%s="%s"' %
                    (attrCod, " ".join(self.__rows_attr['ALL'][attrCod])))
        for attrCod in ['name', 'id', 'data-index']:
            if attrCod in self.__rows_attr['ALL']:
                trAttr.append('%s="%s"' %
                              (attrCod, self.__rows_attr['ALL'][attrCod]))
        strTrAttr = " ".join(trAttr)
        self.aresObj.jsFnc.add(
            '$("#%s > thead > tr > th").tooltip(); $("#%s > tbody > tr > td").tooltip() ;'
            % (self.htmlId, self.htmlId))

        # Special extra part of some line in the table
        trSpecialAttr = {}
        for row in self.__rows_attr['rows']:
            attr = self.__rows_attr['rows'][row]
            trRes = []
            if 'css' in attr:
                trRes.append('style="%s"' % ";".join(
                    ["%s:%s" % (key, val)
                     for key, val in attr["css"].items()]))
            for attrCod in ['onmouseover', 'onMouseOut', 'class']:
                # Here we consider those properties as ones that could be propagated to the extra defintiion
                # This will allow in the case of the pivot table to keep the onmouseover event for example
                if attrCod in self.__rows_attr:
                    if attrCod in attr:
                        attr[attrCod].extend(self.__rows_attr[attrCod])
                    else:
                        attr[attrCod] = self.__rows_attr[attrCod]
                if attrCod in attr:
                    trRes.append('%s="%s"' %
                                 (attrCod, " ".join(set(attr[attrCod]))))
            for attrCod in ['data-index', 'name', 'id', 'title']:
                if attrCod in attr:
                    if attrCod == 'data-index':
                        trRes.append('%s=%s' % (attrCod, attr[attrCod]))
                    else:
                        trRes.append('%s="%s"' % (attrCod, attr[attrCod]))
            trSpecialAttr[row] = " ".join(trRes)

        # Build the table
        htmlButtons = []
        if self.buttons:
            for button in self.buttons:
                htmlButtons.append(button)
        html = ["<thead>"]
        for i in range(self.hdrLines):
            if i == (self.hdrLines - 1):
                html.append(
                    "<tr class='thead-inverse' %s>%s</tr>" %
                    (strTrAttr, "".join([str(th) for th in self.__data[i]])))
            else:
                html.append(
                    "<tr %s>%s</tr>" %
                    (strTrAttr, "".join([str(th) for th in self.__data[i]])))
        html.append("</thead>")
        html.append(self.tbody)
        for i, row in enumerate(self.__data[self.hdrLines:]):
            cells = []
            for j, td in enumerate(row):
                if self.header[-1][j].get(
                        'aresType') == 'input' and td.vals != '':
                    styleVals = "style='%s'" % self.header[-1][j].get(
                        'aresCssAttr') if self.header[-1][j].get(
                            'aresCssAttr') is not None else ''
                    td.vals = "<input class='form-control' value='%s' %s>" % (
                        td.vals, styleVals)
                elif self.header[-1][j].get(
                        'aresType') == 'internalLink' and td.vals != '':
                    styleVals = "style='%s'" % self.header[-1][j].get(
                        'aresCssAttr') if self.header[-1][j].get(
                            'aresCssAttr') is not None else ''
                    url = render_template_string(
                        '''{{ url_for(\'ares.run_report\', report_name=\'%s\', script_name=\'%s\') }}'''
                        % (self.aresObj.reportName,
                           self.header[-1][j]['script_name']))
                    url = "%s?%s=%s" % (url, self.recKey(
                        self.header[-1][j]), td.vals)
                    td.vals = "<a href='%s' %s target='_blank'>%s</a>" % (
                        url, styleVals, td.vals)
                cells.append(str(td))
            if i in trSpecialAttr:
                html.append("<tr %s %s>%s</tr>" %
                            (strTrAttr, trSpecialAttr[i], "".join(cells)))
            else:
                html.append("<tr %s>%s</tr>" % (strTrAttr, "".join(cells)))
        html.append("</tbody>")
        item = "%s<table %s>%s</table>" % ("".join(htmlButtons),
                                           self.strAttr(), "".join(html))
        if self.headerBox is not None:
            height = int(
                self.attr.get('css', {
                    'height': '300px'
                }).get('height', '300px').replace("px", ""))
            container = AresHtmlContainer.AresBox(self.htmlId,
                                                  item,
                                                  self.headerBox,
                                                  properties=self.references)
            container.cssAttr['height'] = "%spx" % (height + 100)
            return str(container)

        return item
示例#9
0
    def __str__(self):
        """  Returns the string representation of a HTML Table """
        trAttr, trSpecialAttr = [], {}
        if 'css' in self.__rows_attr:
            trAttr.append('style="%s"' % ";".join([
                "%s:%s" % (key, val)
                for key, val in self.__rows_attr["css"].items()
            ]))
        for attrCod in ['onmouseover', 'onMouseOut', 'class']:
            if attrCod in self.__rows_attr:
                trAttr.append('%s="%s"' %
                              (attrCod, " ".join(self.__rows_attr[attrCod])))
        for attrCod in ['name', 'id', 'data-index']:
            if attrCod in self.__rows_attr:
                trAttr.append('%s="%s"' % (attrCod, self.__rows_attr[attrCod]))
        strTrAttr = " ".join(trAttr)

        # Special extra part of some line in the table
        for row in self.__rows_attr['rows']:
            attr = self.__rows_attr['rows'][row]
            trRes = []
            if 'css' in attr:
                trRes.append('style="%s"' % ";".join(
                    ["%s:%s" % (key, val)
                     for key, val in attr["css"].items()]))
            for attrCod in ['onmouseover', 'onMouseOut', 'class']:
                # Here we consider those properties as ones that could be propagated to the extra defintiion
                # This will allow in the case of the pivot table to keep the onmouseover event for example
                if attrCod in self.__rows_attr:
                    if attrCod in attr:
                        attr[attrCod].extend(self.__rows_attr[attrCod])
                    else:
                        attr[attrCod] = self.__rows_attr[attrCod]
                if attrCod in attr:
                    trRes.append('%s="%s"' %
                                 (attrCod, " ".join(set(attr[attrCod]))))
            for attrCod in ['data-index', 'name', 'id']:
                if attrCod in attr:
                    if attrCod == 'data-index':
                        trRes.append('%s=%s' % (attrCod, attr[attrCod]))
                    else:
                        trRes.append('%s="%s"' % (attrCod, attr[attrCod]))
            trSpecialAttr[row] = " ".join(trRes)

        # Build the table
        html = ["<thead>"]
        html.append("<tr %s>%s</tr>" %
                    (trSpecialAttr[0] if 0 in trSpecialAttr else strTrAttr,
                     "".join([str(td) for td in self.__data[0]])))
        html.append("</thead>")
        html.append("<tbody>")
        for i, row in enumerate(self.__data[1:]):
            html.append(
                "<tr %s>%s</tr>" %
                (trSpecialAttr[i + 1] if i + 1 in trSpecialAttr else strTrAttr,
                 "".join([str(td) for td in row])))
        html.append("</tbody>")
        item = "<table %s>%s</table>" % (self.strAttr(), "".join(html))
        if self.headerBox is not None:
            return str(
                AresHtmlContainer.AresBox(self.htmlId,
                                          item,
                                          self.headerBox,
                                          properties=self.references))

        return item