Skip to content

Commit

Permalink
Add function to TrafficLight #51
Browse files Browse the repository at this point in the history
  • Loading branch information
marlyk committed Mar 1, 2020
1 parent cc52c50 commit c582a54
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 25 deletions.
6 changes: 3 additions & 3 deletions epyk/core/css/styles/GrpClsImage.py
@@ -1,6 +1,3 @@
"""
"""

from epyk.core.css.styles import GrpCls
from epyk.core.css.styles.attributes import AttrClsImage
Expand All @@ -10,7 +7,10 @@ class ClassIcon(GrpCls.ClassHtml):
@property
def css(self):
"""
Description:
------------
Property to the underlying CSS definition to be added to the style HTML tag of a component
:rtype: AttrClsImage.AttrIcon
"""
if self._css_struct is None:
Expand Down
2 changes: 2 additions & 0 deletions epyk/core/html/Html.py
Expand Up @@ -258,6 +258,8 @@ def add_menu(self, context_menu):

def add_icon(self, text, css=None, position="before"):
"""
Description:
------------
Add an icon to the HTML object
Example
Expand Down
11 changes: 5 additions & 6 deletions epyk/core/html/HtmlImage.py
Expand Up @@ -275,22 +275,21 @@ class Badge(Html.Html):
__reqCss = ['bootstrap', 'font-awesome']

def __init__(self, report, text, label, icon, background_color, color, url, tooltip, options, profile):
super(Badge, self).__init__(report, None, css_attrs={"color": color, 'background-color': background_color},
profile=profile)
super(Badge, self).__init__(report, None, css_attrs={"color": color, 'background-color': background_color}, profile=profile)
self.add_label(label, css={"vertical-align": "middle", "width": 'none', "height": 'none'})
self.__options = OptButton.OptionsBadge(self, options)
if self.options.badge_position == 'left':
self.add_icon(icon, css={"float": 'None', "font-size": Defaults_css.font(5)}, position="after")
self.add_icon(icon, css={"float": 'None', 'margin-left': "5px"}, position="after")
else:
self.add_icon(icon, css={"float": 'left', "font-size": Defaults_css.font(5)})
self.add_icon(icon, css={"float": 'left', 'margin-left': "5px"})
self.link = None
if url is not None:
self.link = self._report.ui.links.external(text, url).css({"color": "inherit", 'display': 'inline-block',
"padding": "2px 2px 0 2px", "border-radius": "20px", "width": "auto", "height": Defaults_css.font()})
"padding": "2px 0px 0 6px", "border-radius": "20px", "width": "auto", "font-size": Defaults_css.font(-2)})
self.link.inReport = False
else:
self.link = self._report.ui.text(text).css({'display': 'inline-block',
"padding": "2px 2px 0 2px", "border-radius": "20px", "width": "auto", "height": Defaults_css.font()})
"padding": "2px 0px 0 6px", "border-radius": "20px", "width": "auto", "font-size": Defaults_css.font(-2)})
self.link.css(self.options.badge_css)
self.link.inReport = False
self.attr['class'].add("badge") # From bootstrap
Expand Down
23 changes: 20 additions & 3 deletions epyk/core/html/HtmlText.py
Expand Up @@ -202,10 +202,27 @@ def click(self, jsFncs, profile=False):
return super(Text, self).click(jsFncs, profile)

@property
def dom(self):
def val(self):
"""
Javascript Functions
Description:
------------
Property to get the jquery value of the HTML object in a python HTML object.
This method can be used in any jsFunction to get the value of a component in the browser.
This method will only be used on the javascript side, so please do not consider it in your algorithm in Python
:returns: Javascript string with the function to get the current value of the component
"""
return self._vals

@val.setter
def val(self, val):
self._vals = val

@property
def dom(self):
"""
Description:
------------
Return all the Javascript functions defined for an HTML Component.
Those functions will use plain javascript by default.
Expand All @@ -216,7 +233,7 @@ def dom(self):
if self._dom is None:
self._dom = JsHtml.JsHtmlRich(self, report=self._report)
return self._dom

@property
def options(self):
"""
Expand Down
9 changes: 4 additions & 5 deletions epyk/core/html/HtmlTextComp.py
Expand Up @@ -99,8 +99,9 @@ def __str__(self):
<div %(strAttr)s>
<div %(clsTag)s style="padding-top:10px;width:%(width)spx;height:%(height)spx;vertical-align:middle;background-color:%(bgcolor)s"></div>
<div "%(clsTitle)s"><a style="text-decoration:none"></a></div>%(helper)s
</div>''' % {"strAttr": self.get_attrs(pyClassNames=self.style.get_classes()), "clsTag": self._report.style.getClsTag(['CssDivBubble'], loadCls=True),
'clsTitle': self._report.style.getClsTag(['CssTitle'], loadCls=True), 'bgcolor': self.background_color,
</div>''' % {"strAttr": self.get_attrs(pyClassNames=self.style.get_classes()), "clsTag": ''# self._report.style.getClsTag(['CssDivBubble'], loadCls=True)
, 'clsTitle': '' #self._report.style.getClsTag(['CssTitle'], loadCls=True)
, 'bgcolor': self.background_color,
'helper': self.helper, 'height': bubble_height, 'width': bubble_width}


Expand Down Expand Up @@ -145,7 +146,6 @@ def __str__(self):
class TextWithBorder(Html.Html):
__reqCss, __reqJs = ['font-awesome'], ['font-awesome']
name, category, callFnc = 'Text with Border and Icon', 'Rich', 'textborder'
# _grpCls = GrpCls.CssGrpClassBase

def __init__(self, report, recordSet, width, height, align, helper, profile):
super(TextWithBorder, self).__init__(report, recordSet, css_attrs={"width": width, "height": height}, profile=profile)
Expand Down Expand Up @@ -283,7 +283,6 @@ class DocScript(Html.Html):
Security checks are done in the script to ensure they are TAGS as open
"""
docTypes = set(['documentation', 'code'])
# _grpCls = GrpCls.CssGrpClassBase
__reqCss, __reqJs = ['font-awesome', 'bootstrap'], ['font-awesome', 'jquery']
name, category, callFnc = 'Script Documentation', 'Text', 'doc'

Expand Down Expand Up @@ -326,7 +325,7 @@ def __init__(self, report, vals, language, width, height, isEditable, trimSpaces
super(Prism, self).__init__(report, vals, css_attrs={"width": width, "height": height}, profile=profile)
self.isEditable = isEditable
self.trimSpaces = trimSpaces
self.style.addCls('language-%s' % language)
self.attr['class'].add('language-%s' % language)
if align == 'center':
self.css('margin', 'auto')

Expand Down
35 changes: 33 additions & 2 deletions epyk/interfaces/components/CompMenus.py
Expand Up @@ -199,7 +199,7 @@ def divisor(self, data, divider=None, width=(100, '%'), height=(None, 'px'), opt
div +=self.context.rptObj.ui.text(data[-1]).css({"display": 'inline-block'})
return div

def button(self, value, object, width=("auto", ''), height=(None, 'px'), options=None, profile=False):
def button(self, value, object, symbol=None, width=("auto", ''), height=(None, 'px'), options=None, profile=False):
"""
Description:
------------
Expand All @@ -213,11 +213,13 @@ def button(self, value, object, width=("auto", ''), height=(None, 'px'), options
----------
:param value:
:param object:
:param symbol:
:param width:
:param height:
:param options:
:param profile:
"""

div = self.context.rptObj.ui.div(width=width, height=height, options=options, profile=profile)
div.item = object
content = self.context.rptObj.ui.div(object, width=("auto", ''))
Expand All @@ -227,9 +229,38 @@ def button(self, value, object, width=("auto", ''), height=(None, 'px'), options
content.style.css.background = self.context.rptObj.theme.greys[0]
content.style.css.z_index = 5
content.style.css.position = 'absolute'
but = self.context.rptObj.ui.button(value, width=width, profile=profile)
if symbol is None:
symbol = self.context.rptObj.symbols.shapes.BLACK_DOWN_POINTING_SMALL_TRIANGLE
but = self.context.rptObj.ui.button("%s %s" % (value, symbol),
width=width, profile=profile)
div += but
div += content
div.on("mouseover", [content.dom.css({"display": 'block'})])
div.on("mouseout", [content.dom.css({"display": 'none'})])
return div

def toolbar(self, data, width=("auto", ''), height=(None, 'px'), options=None, profile=False):
"""
Description:
------------
Usage:
------
tb = rptObj.ui.menus.toolbar(["fas fa-paint-brush", "fas fa-code"])
tb[1].link.val = 4589
tb[1].tooltip("This is a tooltip")
tb[0].style.css.color = 'red'
Attributes:
----------
:param data:
:param width:
:param height:
:param options:
:param profile:
"""
div = self.context.rptObj.ui.div(width=width, height=height, options=options, profile=profile)
for d in data:
div += self.context.rptObj.ui.images.badge(icon=d, text="", options={"badge_position": 'right'})
div[-1].style.css.cursor = 'pointer'
return div
3 changes: 0 additions & 3 deletions epyk/interfaces/components/CompTags.py
@@ -1,6 +1,3 @@
"""
"""

import sys

Expand Down
3 changes: 0 additions & 3 deletions epyk/interfaces/components/CompVignets.py
@@ -1,6 +1,3 @@
"""
Interface to the Vignets HTML components
"""

from epyk.core import html
from epyk.core.css import Defaults as Defaults_css
Expand Down

0 comments on commit c582a54

Please sign in to comment.