Exemplo n.º 1
0
 def __str__(self):
   """ Return the html string representation """
   items = AresItem.Item('<div class="page" style="margin-left:25%;margin-right:25%">')
   commentFiles = {}
   configPath = os.path.join(self.http['DIRECTORY'], 'config', self.dataSourceName)
   if not os.path.exists(configPath):
     os.makedirs(configPath)
   for pyFile in os.listdir(configPath):
     configFile = open(os.path.join(configPath, pyFile))
     content = configFile.read()
     if content != '':
       commentFiles[pyFile.replace(".cfg", "")] = content
     configFile.close()
   for i, val in enumerate(self.vals):
     objectId = "%s_%s" % (self.htmlId, i)
     items.add(1, '<div style="white-space: pre;" ondblclick="$(\'#in_%s\').show() ; $(\'#in_cmmt_%s\').focus()" id="%s">%s</div>' % (objectId, objectId, objectId, val))
     inCmmtId = 'in_cmmt_%s' % objectId
     if inCmmtId in commentFiles:
       items.add(1, '<div id="in_%s">' % objectId)
       items.add(2, '<textarea class="bubble_cmmt" id="%s" onblur="leaveBox($(\'#in_%s\'), $(this)) ;">%s</textarea>' % (inCmmtId, objectId, commentFiles[inCmmtId]))
     else:
       items.add(1, '<div id="in_%s" style="display:none;">' % objectId)
       items.add(2, '<textarea class="bubble_cmmt" id="%s" onblur="leaveBox($(\'#in_%s\'), $(this)) ;"></textarea>' % (inCmmtId, objectId))
     items.add(2, '<button type="button" class="btn btn-success" style="margin-bottom:10px;margin-left:5px" onclick="save_cmmt($(this), $(\'#in_cmmt_%s\')) ;">Save</button>' % objectId)
     items.add(2, '<button type="button" id="in_cmmt_%s_cl" class="btn btn-danger" style="margin-bottom:10px;" onclick="cancel_cmmt($(\'#in_%s\'), $(\'#in_cmmt_%s\')) ;">Cancel</button>' % (objectId, objectId, objectId))
     items.add(1, '</div>')
   items.add(0, '</div>')
   return str(items)
Exemplo n.º 2
0
 def __str__(self):
     res = AresItem.Item("<p>%s</p>" % self.text)
     res.add(1, "<p><h1><center>%s</center></h1></p>" % self.vals)
     res.add(0, "</div>")
     box = AresBox(self.htmlId, res, self.title, properties=self.references)
     box.cssCls = self.cssCls
     return str(box)
Exemplo n.º 3
0
 def __str__(self):
   """ Return the String representation of a HTML Comment input section """
   item = AresItem.Item('<div class="form-group">', self.incIndent)
   item.add(1, '<label for="%s">%s:</label>' % (self.vals.replace(" ", "").lower(), self.vals))
   item.add(2, '<textarea %s rows="%s" >%s</textarea>' % (self.strAttr(), self.rows, self.dflt))
   item.add(0, '</div>')
   return str(item)
Exemplo n.º 4
0
 def __str__(self):
   """  String representation of the HTML object """
   item = AresItem.Item('<blockquote %s">' % self.strAttr())
   item.add(1, "<p>%s</p>" % self.vals[0])
   item.add(1, "<small>by <cite>%s</cite></small>" % self.vals[1])
   item.add(0 , "</blockquote>")
   return str(item)
Exemplo n.º 5
0
 def __str__(self):
   """ Return the html string representation """
   items = AresItem.Item(' <div style="cursor:pointer;width:200px" %s>' % self.strAttr())
   for val in self.vals:
     items.add(1, "  <p id='%s_%s' align='center' style='width:100%%;padding:3px'>%s</p>" % (self.htmlId, val, val) )
   items.add(9, "</div>")
   return str(items)
Exemplo n.º 6
0
    def __str__(self):

        url = self.resolve()

        item = AresItem.Item(
            """<form action="%s" method="POST" enctype="multipart/form-data" >"""
            % url)
        item.add(1, """<div style="padding-top:3px" id="%s">""" % self.htmlId)
        item.add(
            2, """<br><input type="file" name="file" />
            <select name="File Type" required> """)
        item.add(3, """ <option value="report">report</option>""")
        item.add(3,
                 """ <option value="configuration">configuration</option>""")
        item.add(3, """ <option value="ajax">ajax</option>""")
        item.add(3, """ <option value="javascript">javascript</option>""")
        item.add(3, """ <option value="views">views</option>""")
        item.add(3, """ <option value="outputs">outputs</option>""")
        item.add(3, """ <option value="styles">styles</option>""")
        item.add(3, """ <option value="saved">saved</option>""")
        item.add(2, """ </select>""")
        item.add(1, """ </div>""")
        item.add(
            1,
            """ <button type="button" class="btn-xs fa fa-plus" onClick="addInputForUpload('%s');"></button><br>"""
            % (self.htmlId))
        item.add(1, """ <br><input type="submit"/>""")
        item.add(0, """ <form/>""")
        return str(item)
Exemplo n.º 7
0
    def __init__(self,
                 aresObj,
                 jsSrcRef,
                 eventType,
                 jsFnc,
                 data=None,
                 url=None):
        """
    """
        if not eventType in self.mapEvent:
            # This is a check to control the number of events per class
            # Also because some of them might require specific display
            raise Exception('%s not defined for this %s!' %
                            (eventType, self.__class__))

        if not isinstance(jsFnc, (list, AresItem.Item)):
            splitFnc = jsFnc.strip().split("\n")
            items = AresItem.Item(splitFnc[0].strip())
            for line in splitFnc[1:]:
                items.add(0, line.strip())
            jsItemFnc = items
        else:
            jsItemFnc = jsFnc
        self.jsAttr = {
            'src': jsSrcRef,
            'eventType': eventType,
            'fnc': jsItemFnc,
            'htmlId': self.htmlId,
            'data': data,
            'url': url
        }
Exemplo n.º 8
0
 def __str__(self):
     """ Return the String representation of a HTML Modal Object """
     item = AresItem.Item(
         '<button type="button" class="%s" data-toggle="modal" data-target="#%s" style="cursor: pointer">%s</button>'
         % (' '.join(self.btnCls), self.htmlId, self.name), self.incIndent)
     item.add(
         0,
         '<div %s tabindex="-1" role="dialog" aria-labelledby="%sTitle" aria-hidden="true">'
         % (self.strAttr(), self.htmlId))
     item.add(1, '<div class="modal-dialog">')
     item.add(2, '<div class="modal-content">')
     item.add(
         3, '<div class="logo_small" id="%sTitle">%s</div>' %
         (self.htmlId, self.modal_header))
     item.add(
         3,
         '<div class="modal-body" style="overflow-y:scroll;max-height:%spx;margin-bottom:10px">'
         % self.maxHeight)
     for val in self.vals:
         if hasattr(val, 'incIndent'):
             val.incIndent = 4
             item.add(0, str(val))
         else:
             item.add(4, str(val))
     item.add(3, '</div>')
     item.add(2, '</div>')
     item.add(1, '</div>')
     item.add(0, '</div>')
     return str(item)
Exemplo n.º 9
0
 def __str__(self):
     """ Return the HTML display of a split container"""
     res = AresItem.Item('')
     for htmlObj in self.vals:
         res.add(1, str(htmlObj))
         htmlObj.graph()
     return str(res)
Exemplo n.º 10
0
 def __str__(self):
     """  Return the HTML representation of the Box objects """
     attr = 'style="%s"' % ";".join(
         ["%s:%s" % (key, val) for key, val in self.cssAttr.items()])
     item = AresItem.Item('<div class="%s" id="%s_main" %s>' %
                          (" ".join(self.cssCls), self.htmlId, attr))
     item.add(1, '<div class="ares-panel-heading">')
     item.add(
         2,
         '<strong><i class="fa fa-table" aria-hidden="true"></i>&nbsp;%s</strong>'
         % self.headerBox)
     item.add(
         3,
         '<button class="btn btn-xs " id="%s_close" name="ares_close"></button>'
         % self.htmlId)
     item.add(
         3,
         '<button class="btn btn-xs" id="%s_min" name="ares_min"></button>'
         % self.htmlId)
     item.add(
         3,
         '<button class="btn btn-xs " id="%s_zoom" name="ares_zoom" onclick="ZoomIn(\'%s\', \'%s\')"></button>'
         % (self.htmlId, self.htmlId, self.idContainer))
     if self.prop is not None:
         item.add(
             3,
             '<button class="btn btn-xs" name="ares_prop" data-toggle="modal" data-target="#%s_prop"></button>'
             % self.htmlId)
     item.add(1, '</div>')
     item.add(
         1,
         '<div class="panel-body table-responsive" id="%s" style="padding:8px">'
         % self.htmlId)
     item.add(2, self.vals)
     item.add(1, '</div>')
     item.add(0, '</div>')
     if self.prop is not None:
         item.add(
             0,
             '<div class="modal fade" id="%s_prop" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">'
             % self.htmlId)
         item.add(1, '<div class="modal-dialog" role="document">')
         item.add(1, '<div class="modal-content">')
         item.add(1, '<div class="modal-header">')
         item.add(
             1,
             '<h5 class="modal-title" id="exampleModalLabel">Html / Js documentation</h5>'
         )
         item.add(1, '</div>')
         item.add(1, '<div class="modal-body">')
         for prop in self.prop:
             item.add(0,
                      '<a href="%s" target="_blank">%s</a>' % (prop, prop))
         item.add(1, '</div>')
         item.add(1, '</div>')
         item.add(1, '</div>')
         item.add(0, '</div>')
     return str(item)
Exemplo n.º 11
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)
Exemplo n.º 12
0
 def __str__(self):
     """ Return the HTML representation of a Tabular object """
     item = AresItem.Item('<ul %s>' % self.strAttr())
     item.add(1,
              '<li class="active"><a href="#">%s</a></li>' % self.vals[0])
     for val in self.vals[1:]:
         item.add(2, '<li><a href="#">%s</a></li>' % val)
     item.add(0, '</ul>')
     return str(item)
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 def __str__(self):
     """ Return the String representation of a HTML List """
     item = AresItem.Item('<ul %s>' % self.strAttr())
     for label, cnt in self.vals:
         item.add(
             1,
             '<li class="list-group-item">%s<span class="badge">%s</span></li>'
             % (label, cnt))
     item.add(0, '</ul>')
     return str(item)
Exemplo n.º 15
0
 def __str__(self):
     """ Return the HTML string for a select """
     item = AresItem.Item('<select %s>' % self.strAttr(), self.incIndent)
     for group, vals in self.vals:
         item.add(1, '<optgroup label="%s">' % group)
         for v in vals:
             item.add(2, '<option>%s</option>' % v)
         item.add(1, '</optgroup>')
     item.add(0, '</select>')
     return str(item)
Exemplo n.º 16
0
 def __str__(self):
     """ Return the String representation of a HTML List """
     item = AresItem.Item(None)
     for val in self.vals:
         item.add(3, val)
     return str(
         AresBox(self.htmlId,
                 item,
                 self.headerBox,
                 properties=self.references))
Exemplo n.º 17
0
 def __str__(self):
     """ Return the String representation of a HTML Input object """
     self.attr['type'] = self.inputType
     self.attr['value'] = self.value
     item = AresItem.Item('<div class="form-group">', self.incIndent)
     item.add(
         1, '<label for="%s">%s:</label>' %
         (self.vals.replace(" ", "").lower(), self.vals))
     item.add(2, '<input %s>' % self.strAttr())
     item.add(0, '</div>')
     return str(item)
Exemplo n.º 18
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)
Exemplo n.º 19
0
    def extendJsFnc(self, jsFnc):
        """ Add the extr actions to the even function """
        if not isinstance(jsFnc, (list, AresItem.Item)):
            splitFnc = jsFnc.strip().split("\n")
            items = AresItem.Item(splitFnc[0].strip())
            for line in splitFnc[1:]:
                items.add(0, line.strip())
            jsItemFnc = items
        else:
            jsItemFnc = jsFnc

        self.jsAttr['fnc'] = self.jsAttr['fnc'].join(jsItemFnc)
Exemplo n.º 20
0
 def __str__(self):
     """ Return the String representation of a HTML Modal Object """
     item = AresItem.Item(
         '<button type="button" class="btn btn-primary" %s style="cursor: pointer">%s</button>'
         % (self.strAttr(), self.name), self.incIndent)
     self.js(
         'click', '''
           $('#popup-info').css('top', '110px');
           $('#popup-info').css('left', '110px');
           $('#popup-black-background').toggle();
           $('#popup-info').toggle();
         ''')
     return str(item)
Exemplo n.º 21
0
 def __str__(self):
     """  Return the String representation of the Javascripts methods """
     self.jsAttr['fnc'].incIndent = 2
     jsFnc = str(self.jsAttr['fnc'])[1:]  # remove the empty line at the top
     eventDefinition = self.mapEvent[self.jsAttr['eventType']]
     items = AresItem.Item(eventDefinition[0] % self.jsAttr)
     if '%(' in jsFnc:
         items.add(0, jsFnc % self.jsAttr['eventType'])
     else:
         items.add(0, jsFnc)
     for i, strEvent in enumerate(eventDefinition[1:]):
         items.add(len(eventDefinition) - i - 1, strEvent)
     return str(items)
Exemplo n.º 22
0
 def __str__(self):
     """  String representation of a Drop Down item """
     items = AresItem.Item('<div class="dropdown">')
     items.add(
         1, '<button class="%s" type="button" data-toggle="dropdown">%s' %
         (self.getClass(), self.title))
     items.add(3, '<span class="caret"></span>')
     items.add(2, '</button>')
     items.add(1, '<ul class="dropdown-menu" id="%s">' % self.htmlId)
     self.addCategory(items, 2, self.vals)
     items.add(1, "</ul>")
     items.add(0, "</div>")
     self.aresObj.jsGlobal.add(
         "%s_allow_tables = %s" %
         (self.htmlId, json.dumps(self.allowTableFilter)))
     return str(items)
Exemplo n.º 23
0
 def __str__(self):
     """ Return the HTML string for a select """
     item = AresItem.Item('<div class="form-group">', self.incIndent)
     item.add(1, '<label for="sel1">%s:</label>' % self.title)
     item.add(1, '<select %s>' % self.strAttr())
     for val in self.vals:
         if val == self.selected:
             item.add(
                 3, '<option value="%s" selected>%s</option>' % (val, val))
         else:
             item.add(3, '<option value="%s">%s</option>' % (val, val))
     item.add(1, '</select>')
     item.add(0, '</div>')
     self.jsOnLoad.add('var data_%s = %s;' %
                       (self.htmlId, json.dumps(list(self.vals))))
     return str(item)
Exemplo n.º 24
0
    def __str__(self):
        """ Return the HTML display of a split container"""
        res = AresItem.Item('<div %s>' % self.strAttr())
        for css, htmlObj in self.vals:
            if css == '':
                strAttr = ";".join(
                    ["%s:%s" % (key, val) for key, val in self.cssRow.items()])
                res.add(1, '<div style="%s">%s</div>' % (strAttr, htmlObj))
            else:
                res.add(1, '<div class="%s">%s</div>' % (css, htmlObj))
            htmlObj.graph()
        res.add(0, '</div>')
        if self.aresObj.withContainer:
            return str(TextContainer(self.aresObj, str(res)))

        return str(res)
Exemplo n.º 25
0
 def __str__(self):
   """ Display the file upload object """
   self.headerBox = 'Select a file '
   items = AresItem.Item('<div class="panel panel-success">')
   items.add(1, '<div class="panel-heading">')
   items.add(2, '<strong><i class="fa fa-file" aria-hidden="true"></i>&nbsp;%s</strong>' % self.headerBox)
   items.add(1, '</div>')
   items.add(1, '<div class="panel-body">')
   items.add(2, '<div class="col-lg-7" style="padding:5px">')
   items.add(3, '<label class="btn btn-default btn-file" style="width:100%%; height:100%%" id="value_%s">' % self.htmlId)
   items.add(4, 'Browse a file<input type="file" style="display: none;"  %s>' % self.strAttr())
   items.add(3, '</label>')
   items.add(3, '<button type="button" id="button_%s" class="btn btn-success" style="height:35px"><span class="fa fa-check-square-o">&nbsp;Upload</span></button>' % self.htmlId)
   items.add(2, '</div>')
   items.add(1, '</div>')
   items.add(0, '</div>')
   return str(items)
Exemplo n.º 26
0
    def __str__(self):

        url = self.resolve()

        item = AresItem.Item(
            """<form action="%s" method="POST" enctype="multipart/form-data" >"""
            % url)
        item.add(1, """<div style="padding-top:3px" id="%s">""" % self.htmlId)
        item.add(2, """<br><input type="file" name="file" /> """)
        item.add(1, """ </div>""")
        item.add(
            1,
            """ <button type="button" class="btn-xs fa fa-plus" onClick="addInputforDeploy('%s');"></button><br>"""
            % (self.htmlId))
        item.add(1, """ <br><input type="submit"/>""")
        item.add(0, """ <form/>""")
        return str(item)
Exemplo n.º 27
0
    def __str__(self):
        """ Return the String representation of a HTML List """
        item = AresItem.Item('<ul %s>' % self.strAttr())
        cssLi = ""
        if self.cssClsLi:
            cssLi = 'class="%s"' % " ".join(self.cssClsLi)
        for label in self.vals:

            item.add(3, '<li %s>%s</li>' % (cssLi, label))
        item.add(2, '</ul>')
        if self.headerBox is not None:
            return str(
                AresBox(self.htmlId,
                        item,
                        self.headerBox,
                        properties=self.references))

        return str(item)
Exemplo n.º 28
0
 def post(self, evenType, jsDef, dataTable, fileParserClass, fileName, fileCod, folder):
   """ Button Post request """
   url = render_template_string('''{{ url_for(\'ares.ajaxCall\', report_name=\'_AresReports\', script=\'SrvSaveToFile\') }}''')
   preAjax = AresItem.Item("var %s = %s.html();" % (self.htmlId, self.jqId))
   preAjax.add(0, "%s.html('<i class=\"fa fa-spinner fa-spin\"></i> Processing'); " % self.jqId)
   jsDef = '''
             %s
             $.post("%s", {fileName: %s, parserModule: '%s', reportName: '%s', datatable: %s, static_code: '%s', folder: '%s'}, function(data) {
                 var res = JSON.parse(data) ;
                 var data = res.data ;
                 var status = res.status ;
                 %s
                 %s.html(%s);
             } );
           ''' % (preAjax, url,
                  fileName, fileParserClass, self.aresObj.http['REPORT_NAME'], dataTable.val, fileCod, folder,
                  jsDef, self.jqId, self.htmlId)
   self.js(evenType, jsDef, url=url)
Exemplo n.º 29
0
  def post(self, evenType, scriptName, jsDef, attr, subPost=False):
    """ Button Post request """
    url = render_template_string('''{{ url_for(\'ares.ajaxCall\', report_name=\'%s\', script=\'%s\') }}''' % (self.aresObj.http['REPORT_NAME'], scriptName))
    data = json.dumps(attr, cls=AresHtml.SetEncoder)
    for stToConv in ['.data().toArray()', '.val()', '.serializeArray()']:
      data = data.replace('%s"' % stToConv, stToConv)
    for stToConv, strReplace in [('$(', '"$('), (': datatable_', ': "datatable_')]:
      data = data.replace(strReplace, stToConv)
    preAjax = AresItem.Item("var %s = %s.html();" % (self.htmlId, self.jqId))
    preAjax.add(0, "%s.html('<i class=\"fa fa-spinner fa-spin\"></i> Processing'); " % self.jqId)
    preAjax.add(0, attr.get('preAjaxJs', ''))
    if subPost:
      jsDef = '''
                    %s
                    $.post("%s", %s, function(data) {
                        var res = JSON.parse(data) ;
                        var data = res.data ;
                        $.post(data, function(data2) {
                          var res = JSON.parse(data2);
                          location.reload()
                          });

                        var status = res.status ;
                        %s
                        %s.html(%s);
                    } );
                  ''' % (preAjax, url, data, jsDef, self.jqId, self.htmlId)
    else:
      jsDef = '''
                %s
                $.post("%s", %s, function(data) {
                    var res = JSON.parse(data) ;
                    var data = res.data ;
                    var status = res.status ;
                    %s
                    %s.html(%s);
                } );
              ''' % (preAjax, url, data, jsDef, self.jqId, self.htmlId)
    self.js(evenType, jsDef, url=url)
Exemplo n.º 30
0
  def __str__(self):
    """
    """
    self.js('drop', '''
                      event.originalEvent.preventDefault();
                      event.originalEvent.stopPropagation();
                      var file = event.originalEvent.dataTransfer.files; // FileList object.

                      //files is a FileList of File objects. List some properties.
                      var form_data = new FormData();
                      $.each(event.originalEvent.dataTransfer.files, function(i, file) {
                        form_data.append('file_' + i, file);
                        i ++;
                      });
                      %s
                    ''' % self.drop())
    items = AresItem.Item('<div ondrop="drop(event)" style="border: 1px dotted black;text-align:center;padding:5px;background-color:#F8F8F8" %s>' % self.strAttr())
    items.add(1, "<h3>")
    items.add(2, "<b>%s</b>" % self.vals) # + Add Scripts
    items.add(1, "</h3>")
    items.add(1, "Drop scripts here to upload")
    items.add(0, "</div>")
    return str(items)