def get_color(my): color = Xml.get_attribute( my.node, "color" ) from pyasm.web import Palette theme = Palette.get().get_theme() if theme == 'dark': color = Common.modify_color(color, -50) return color
def get_default_task_xml(): global TASK_PIPELINE from pyasm.web import Palette palette = Palette.get() xml = Xml() xml.read_string(TASK_PIPELINE) nodes = Xml.get_nodes(xml, "pipeline/process") for node in nodes: process = Xml.get_attribute(node, "name") color = Task.get_default_color(process) Xml.set_attribute(node, "color", color) return xml.to_string()
def get_default_color(process): global default_xml global OTHER_COLORS #MTM added the if statements linked to statuses if process.title() == 'Pending': return "#d7d7d7" elif process.title() == 'Ready': return "#b2cee8" elif process.title() == 'On_Hold': return "#e8b2b8" elif process.title() == 'Client Response': return "#ddd5b8" elif process.title() == 'Internal Rejection': return "#ff0000" elif process.title() == 'External Rejection': return "#ff0000" elif process.title() == 'Failed QC': return "#ff0000" elif process.title() == 'Rejected': return "#ff0000" elif process.title() == 'Fix Needed': return "#c466a1" elif process.title() == 'In_Progress': return "#f5f3a4" elif process.title() == 'DR In_Progress': return "#d6e0a4" elif process.title() == 'BATON In_Progress': return "#c6e0a4" elif process.title() == 'Export In_Progress': return "#796999" elif process.title() == 'Need Buddy Check': return "#e3701a" elif process.title() == 'Buddy Check In_Progress': return "#1aade3" elif process.title() == 'Completed': return "#b7e0a5" node = default_xml.get_node("pipeline/process[@name='%s']" % process.title()) if node is None: return OTHER_COLORS.get(process.title()) color = default_xml.get_attribute(node, "color") if not color: color = OTHER_COLORS.get(process.title()) from pyasm.web import Palette theme = Palette.get() if theme == 'dark': color = Common.modify_color(color, -50) return color
def get_default_color(process): global default_xml global OTHER_COLORS node = default_xml.get_node("pipeline/process[@name='%s']" % process.title()) if node is None: return OTHER_COLORS.get(process.title()) color = default_xml.get_attribute(node, "color") if not color: color = OTHER_COLORS.get(process.title()) from pyasm.web import Palette theme = Palette.get() if theme == 'dark': color = Common.modify_color(color, -50) return color
def __init__(self): self.data = {} self.data['elements'] = [] palette = Palette.get() background = palette.color("background") color = palette.color("background3") self.data['bg_colour'] = background self.data['y_axis'] = { 'grid-colour': color, 'grid-visible': True, 'colour': color, } self.data['x_axis'] = { 'grid-colour': color, 'grid-visible': False, 'colour': color, }
def __init__(my): my.data = {} my.data['elements'] = [] palette = Palette.get() background = palette.color("background") color = palette.color("background3") my.data['bg_colour'] = background my.data['y_axis'] = { 'grid-colour': color, 'grid-visible': True, 'colour': color, } my.data['x_axis'] = { 'grid-colour': color, 'grid-visible': False, 'colour': color, }
def get_display(my): web = WebContainer.get_web() widget = Widget() html = HtmlElement("html") is_xhtml = False if is_xhtml: web.set_content_type("application/xhtml+xml") widget.add('''<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ''') html.add_attr("xmlns", "http://www.w3.org/1999/xhtml") #html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg") # add the copyright widget.add(my.get_copyright_wdg()) widget.add(html) # create the header head = HtmlElement("head") html.add(head) head.add( '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n' ) head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n') # Add the tactic favicon head.add( '<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>' ) # add the css styling head.add(my.get_css_wdg()) # add the title in the header project = Project.get() project_code = project.get_code() project_title = project.get_value("title") if web.is_admin_page(): is_admin = " - Admin" else: is_admin = "" if project_code == 'admin': head.add("<title>TACTIC Site Admin</title>\n") else: head.add("<title>%s%s</title>\n" % (project_title, is_admin)) # add the javascript libraries head.add(JavascriptImportWdg()) # add the body body = my.body html.add(body) body.add_event('onload', 'spt.onload_startup(this)') top = my.top # Add a NOSCRIPT tag block here to provide a warning message on browsers where 'Enable JavaScript' # is not checked ... TODO: clean up and re-style to make look nicer top.add(""" <NOSCRIPT> <div style="border: 2px solid black; background-color: #FFFF99; color: black; width: 600px; height: 70px; padding: 20px;"> <img src="%s" style="border: none;" /> <b>Javascript is not enabled on your browser!</b> <p>This TACTIC powered, web-based application requires JavaScript to be enabled in order to function. In your browser's options/preferences, please make sure that the 'Enable JavaScript' option is checked on, click OK to accept the settings change, and then refresh this web page.</p> </div> </NOSCRIPT> """ % (IconWdg.get_icon_path("ERROR"))) # add the content content_div = DivWdg() top.add(content_div) Container.put("TopWdg::content", content_div) # add a dummy button for global behaviors from tactic.ui.widget import ButtonNewWdg, IconButtonWdg ButtonNewWdg(title="DUMMY", icon=IconWdg.FILM) IconButtonWdg(title="DUMMY", icon=IconWdg.FILM) # NOTE: it does not need to be in the DOM. Just needs to be # instantiated #content_div.add(button) if my.widgets: content_wdg = my.get_widget('content') else: content_wdg = Widget() my.add(content_wdg) content_div.add(content_wdg) # add a calendar wdg from tactic.ui.widget import CalendarWdg cal_wdg = CalendarWdg(css_class='spt_calendar_template_top') cal_wdg.top.add_style('display: none') content_div.add(cal_wdg) if web.is_admin_page(): from tactic_branding_wdg import TacticCopyrightNoticeWdg branding = TacticCopyrightNoticeWdg(show_license_info=True) top.add(branding) # add the admin bar security = Environment.get_security() if not web.is_admin_page() and security.check_access( "builtin", "view_site_admin", "allow"): div = DivWdg() top.add(div) top.add_style("padding-top: 21px") div.add_class("spt_admin_bar") div.add_style("height: 15px") div.add_style("padding: 3px 0px 3px 15px") #div.add_style("margin-bottom: -5px") div.add_style("position: fixed") div.add_style("top: 0px") div.add_style("left: 0px") div.add_style("opacity: 0.7") div.add_style("width: 100%") #div.add_gradient("background", "background2", 20, 10) div.add_style("background-color", "#000") div.add_style("color", "#FFF") div.add_style("z-index", "1000") div.add_class("hand") div.set_box_shadow("0px 5px 5px") # remove icon_div = DivWdg() div.add(icon_div) icon_div.add_style("float: right") icon_div.add_style("margin-right: 10px") icon_div.add_style("margin-top: -3px") icon_button = IconButtonWdg(title="Remove Admin Bar", icon=IconWdg.G_CLOSE) icon_div.add(icon_button) icon_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var parent = bvr.src_el.getParent(".spt_admin_bar"); bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(parent); ''' }) div.add("<b>ADMIN >></b>") div.add_behavior({ 'type': 'listen', 'event_name': 'close_admin_bar', 'cbjs_action': ''' bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(bvr.src_el); ''' }) div.add_behavior({ 'type': 'mouseover', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.85) //new Fx.Tween(bvr.src_el).start('height', "30px"); ''' }) div.add_behavior({ 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.7) //new Fx.Tween(bvr.src_el).start('height', "15px"); ''' }) project_code = Project.get_project_code() div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var url = "/tactic/%s/admin/link/_startup"; window.open(url); ''' % project_code }) # Add the script editor listener load_div = DivWdg() top.add(load_div) load_div.add_behavior({ 'type': 'listen', 'event_name': 'show_script_editor', 'cbjs_action': ''' var js_popup_id = "TACTIC Script Editor"; var js_popup = $(js_popup_id); if( js_popup ) { spt.popup.toggle_display( js_popup_id, false ); } else { spt.panel.load_popup(js_popup_id, "tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} ); } ''' }) # deal with the palette defined in /index which can override the palette if my.kwargs.get("hash") == (): key = "index" search = Search("config/url") search.add_filter("url", "/%s/%%" % key, "like") search.add_filter("url", "/%s" % key) search.add_where("or") url = search.get_sobject() if url: xml = url.get_xml_value("widget") palette_key = xml.get_value("element/@palette") # look up palette the expression for index from pyasm.web import Palette palette = Palette.get() palette.set_palette(palette_key) colors = palette.get_colors() colors = jsondumps(colors) script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_colors(%s); env.set_palette('%s'); ''' % (colors, palette_key)) top.add(script) env = Environment.get() client_handoff_dir = env.get_client_handoff_dir(include_ticket=False, no_exception=True) client_asset_dir = env.get_client_repo_dir() login = Environment.get_login() user_name = login.get_value("login") user_id = login.get_id() login_groups = Environment.get_group_names() # add environment information script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_project('%s'); env.set_user('%s'); env.set_user_id('%s'); var login_groups = '%s'.split('|'); env.set_login_groups(login_groups); env.set_client_handoff_dir('%s'); env.set_client_repo_dir('%s'); ''' % (Project.get_project_code(), user_name, user_id, '|'.join(login_groups), client_handoff_dir, client_asset_dir)) top.add(script) # add a global container for commonly used widgets div = DivWdg() top.add(div) div.set_id("global_container") # add in the app busy widget # find out if there is an override for this search = Search("config/url") search.add_filter("url", "/app_busy") url = search.get_sobject() if url: busy_div = DivWdg() div.add(busy_div) busy_div.add_class("SPT_PUW") busy_div.add_styles( "display: none; position: absolute; z-index: 1000") busy_div.add_class("app_busy_msg_block") busy_div.add_style("width: 300px") busy_div.add_style("height: 100px") busy_div.add_style("padding: 20px") busy_div.add_color("background", "background3") busy_div.add_border() busy_div.set_box_shadow() busy_div.set_round_corners(20) busy_div.set_attr("id", "app_busy_msg_block") # put the custom url here title_wdg = DivWdg() busy_div.add(title_wdg) title_wdg.add_style("font-size: 20px") title_wdg.add_class("spt_app_busy_title") busy_div.add("<hr/>") msg_div = DivWdg() busy_div.add(msg_div) msg_div.add_class("spt_app_busy_msg") else: from page_header_wdg import AppBusyWdg div.add(AppBusyWdg()) # popup parent popup = DivWdg() popup.set_id("popup") div.add(popup) # create another general popup popup_div = DivWdg() popup_div.set_id("popup_container") popup_div.add_class("spt_panel") popup = PopupWdg(id="popup_template", destroy_on_close=True) popup_div.add(popup) div.add(popup_div) inner_html_div = DivWdg() inner_html_div.set_id("inner_html") div.add(inner_html_div) # add in a global color from tactic.ui.input import ColorWdg color = ColorWdg() div.add(color) # add in a global notify wdg from notify_wdg import NotifyWdg widget.add(NotifyWdg()) return widget
def get_display(my): from pyasm.biz import Project security = Environment.get_security() if not security.check_access("builtin", "side_bar_schema", "allow", default="deny"): return DivWdg() section_div = LabeledHidableWdg(label="Schema Views") section_div.set_attr('spt_class_name', Common.get_full_class_name(my) ) palette = Palette.get() color = palette.color("background3") project_div = RoundedCornerDivWdg(hex_color_code=color,corner_size="10") project_div.set_dimensions( width_str='175px', content_height_str='100px' ) project = Project.get() project_code = project.get_code() project_type = project.get_type() div = DivWdg() section_div.add(project_div) project_div.add(div) # get project type schema schema = Schema.get_by_code(project_code) if schema: div.add( my.get_schema_wdg(schema) ) #if not project_type: # raise SetupException("Project type not found for this [%s]" %project_code) if project_type: schema = Schema.get_predefined_schema(project_type) if schema: div.add( my.get_schema_wdg(schema) ) schema = Schema.get_predefined_schema('config') div.add( my.get_schema_wdg(schema) ) schema = Schema.get_admin_schema() div.add( my.get_schema_wdg(schema) ) return section_div # create a fake schema project = Project.get() db_name = project.get_database() sql = DbContainer.get(db_name) tables = sql.get_tables() tables.sort() tables_str = "\n".join( ['<search_type name="%s"/>'%x for x in tables] ) # look at all of the search objects for mapped tables search = Search("sthpw/search_object") #search.add_where('''"namespace" = 'MMS' or namespace = '{project}' ''') search.add_filter("namespace", 'MMS') search.add_filter("namespace", '{project}') search.add_where("or") search_types = search.get_sobjects() #for search_type in search_types: # print "hhhh: ", search_type schema_xml = ''' <schema> %s </schema> ''' % tables_str schema = SearchType.create("sthpw/schema") schema.set_value("code", "table") schema.set_value("schema", schema_xml) #div.add( my.get_schema_wdg(schema) ) return section_div
def get_display(my): web = WebContainer.get_web() widget = Widget() html = HtmlElement("html") is_xhtml = False if is_xhtml: web.set_content_type("application/xhtml+xml") widget.add('''<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ''') html.add_attr("xmlns", "http://www.w3.org/1999/xhtml") #html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg") # add the copyright widget.add( my.get_copyright_wdg() ) widget.add(html) # create the header head = HtmlElement("head") html.add(head) head.add('<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n') head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n') # Add the tactic favicon head.add('<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>') # add the css styling head.add(my.get_css_wdg()) # add the title in the header project = Project.get() project_code = project.get_code() project_title = project.get_value("title") if web.is_admin_page(): is_admin = " - Admin" else: is_admin = "" if project_code == 'admin': head.add("<title>TACTIC Site Admin</title>\n" ) else: head.add("<title>%s%s</title>\n" % (project_title, is_admin) ) # add the javascript libraries head.add( JavascriptImportWdg() ) # add the body body = my.body html.add( body ) # Add a NOSCRIPT tag block here to provide a warning message on browsers where 'Enable JavaScript' # is not checked ... TODO: clean up and re-style to make look nicer body.add( """ <NOSCRIPT> <div style="border: 2px solid black; background-color: #FFFF99; color: black; width: 600px; height: 70px; padding: 20px;"> <img src="%s" style="border: none;" /> <b>Javascript is not enabled on your browser!</b> <p>This TACTIC powered, web-based application requires JavaScript to be enabled in order to function. In your browser's options/preferences, please make sure that the 'Enable JavaScript' option is checked on, click OK to accept the settings change, and then refresh this web page.</p> </div> </NOSCRIPT> """ % ( IconWdg.get_icon_path("ERROR") ) ) # add the content if my.widgets: content_wdg = my.get_widget('content') else: content_wdg = Widget() my.add(content_wdg) body.add( content_wdg ) body.add_event('onload', 'spt.onload_startup(this)') if web.is_admin_page(): from tactic_branding_wdg import TacticCopyrightNoticeWdg branding = TacticCopyrightNoticeWdg(show_license_info=True) body.add(branding) # add the admin bar security = Environment.get_security() if not web.is_admin_page() and security.check_access("builtin", "view_site_admin", "allow"): div = DivWdg() body.add(div) body.add_style("padding-top: 21px") div.add_class("spt_admin_bar") div.add_style("height: 15px") div.add_style("padding: 3px 0px 3px 15px") #div.add_style("margin-bottom: -5px") div.add_style("position: fixed") div.add_style("top: 0px") div.add_style("left: 0px") div.add_style("opacity: 0.7") div.add_style("width: 100%") #div.add_gradient("background", "background2", 20, 10) div.add_style("background-color", "#000") div.add_style("color", "#FFF") div.add_style("z-index", "1000") div.add_class("hand") div.set_box_shadow("0px 5px 5px") # remove icon_div = DivWdg() div.add(icon_div) icon_div.add_style("float: right") icon_div.add_style("margin-right: 10px") icon_div.add_style("margin-top: -3px") icon_button = IconButtonWdg(title="Remove Admin Bar", icon=IconWdg.POPUP_WIN_CLOSE) icon_div.add(icon_button) icon_button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var parent = bvr.src_el.getParent(".spt_admin_bar"); spt.behavior.destroy_element(parent); $(document.body).setStyle("padding-top", "0px"); ''' } ) div.add("<b>ADMIN >></b>") div.add_behavior( { 'type': 'listen', 'event_name': 'close_admin_bar', 'cbjs_action': ''' spt.behavior.destroy_element(bvr.src_el); $(document.body).setStyle("padding-top", "0px"); ''' } ) div.add_behavior( { 'type': 'mouseover', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.85) //new Fx.Tween(bvr.src_el).start('height', "30px"); ''' } ) div.add_behavior( { 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.7) //new Fx.Tween(bvr.src_el).start('height', "15px"); ''' } ) project_code = Project.get_project_code() div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var url = "/tactic/%s/link/_startup"; window.open(url); ''' % project_code } ) # Add the script editor listener load_div = DivWdg() body.add(load_div) load_div.add_behavior( { 'type': 'listen', 'event_name': 'show_script_editor', 'cbjs_action': ''' var js_popup_id = "TACTIC Script Editor"; var js_popup = $(js_popup_id); if( js_popup ) { spt.popup.toggle_display( js_popup_id, false ); } else { spt.panel.load_popup(js_popup_id, "tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} ); } '''} ) # deal with the palette defined in /index which can override the palette if my.kwargs.get("hash") == (): key = "index" search = Search("config/url") search.add_filter("url", "/%s/%%"%key, "like") search.add_filter("url", "/%s"%key) search.add_where("or") url = search.get_sobject() if url: xml = url.get_xml_value("widget") palette_key = xml.get_value("element/@palette") # look up palette the expression for index from pyasm.web import Palette palette = Palette.get() palette.set_palette(palette_key) colors = palette.get_colors() colors = jsondumps(colors) script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_colors(%s); env.set_palette('%s'); ''' % (colors, palette_key) ) body.add(script) env = Environment.get() client_handoff_dir = env.get_client_handoff_dir(include_ticket=False, no_exception=True) client_asset_dir = env.get_client_repo_dir() login = Environment.get_login() user_name = login.get_value("login") user_id = login.get_id() login_groups = Environment.get_group_names() # add environment information script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_project('%s'); env.set_user('%s'); env.set_user_id('%s'); var login_groups = '%s'.split('|'); env.set_login_groups(login_groups); env.set_client_handoff_dir('%s'); env.set_client_repo_dir('%s'); ''' % (Project.get_project_code(), user_name, user_id, '|'.join(login_groups), client_handoff_dir,client_asset_dir)) body.add(script) # add a global container for commonly used widgets div = DivWdg() body.add(div) div.set_id("global_container") # add in the app busy widget # find out if there is an override for this search = Search("config/url") search.add_filter("url", "/app_busy") url = search.get_sobject() if url: busy_div = DivWdg() div.add(busy_div) busy_div.add_class( "SPT_PUW" ) busy_div.add_styles( "display: none; position: absolute; z-index: 1000" ) busy_div.add_class("app_busy_msg_block") busy_div.add_style("width: 300px") busy_div.add_style("height: 100px") busy_div.add_style("padding: 20px") busy_div.add_color("background", "background3") busy_div.add_border() busy_div.set_box_shadow() busy_div.set_round_corners(20) busy_div.set_attr("id","app_busy_msg_block") # put the custom url here title_wdg = DivWdg() busy_div.add(title_wdg) title_wdg.add_style("font-size: 20px") title_wdg.add_class("spt_app_busy_title") busy_div.add("<hr/>") msg_div = DivWdg() busy_div.add(msg_div) msg_div.add_class("spt_app_busy_msg") else: from page_header_wdg import AppBusyWdg div.add( AppBusyWdg() ) # popup parent popup = DivWdg() popup.set_id("popup") div.add(popup) # create another general popup popup_div = DivWdg() popup_div.set_id("popup_container") popup_div.add_class("spt_panel") popup = PopupWdg(id="popup_template",destroy_on_close=True) popup_div.add(popup) div.add(popup_div) # popup parent inner_html_div = DivWdg() inner_html_div.set_id("inner_html") div.add(inner_html_div) # add in a global color from tactic.ui.input import ColorWdg color = ColorWdg() div.add(color) # add in a global notify wdg from notify_wdg import NotifyWdg widget.add(NotifyWdg()) return widget
def get_display(self): from pyasm.biz import Project security = Environment.get_security() if not security.check_access("builtin", "side_bar_schema", "allow", default="deny"): return DivWdg() section_div = LabeledHidableWdg(label="Schema Views") section_div.set_attr('spt_class_name', Common.get_full_class_name(self) ) palette = Palette.get() color = palette.color("background3") project_div = RoundedCornerDivWdg(hex_color_code=color,corner_size="10") project_div.set_dimensions( width_str='175px', content_height_str='100px' ) project = Project.get() project_code = project.get_code() project_type = project.get_type() div = DivWdg() section_div.add(project_div) project_div.add(div) # get project type schema schema = Schema.get_by_code(project_code) if schema: div.add( self.get_schema_wdg(schema) ) #if not project_type: # raise SetupException("Project type not found for this [%s]" %project_code) if project_type: schema = Schema.get_predefined_schema(project_type) if schema: div.add( self.get_schema_wdg(schema) ) schema = Schema.get_predefined_schema('config') div.add( self.get_schema_wdg(schema) ) schema = Schema.get_admin_schema() div.add( self.get_schema_wdg(schema) ) return section_div # create a fake schema project = Project.get() db_name = project.get_database() sql = DbContainer.get(db_name) tables = sql.get_tables() tables.sort() tables_str = "\n".join( ['<search_type name="%s"/>'%x for x in tables] ) # look at all of the search objects for mapped tables search = Search("sthpw/search_object") #search.add_where('''"namespace" = 'MMS' or namespace = '{project}' ''') search.add_filter("namespace", 'MMS') search.add_filter("namespace", '{project}') search.add_where("or") search_types = search.get_sobjects() schema_xml = ''' <schema> %s </schema> ''' % tables_str schema = SearchType.create("sthpw/schema") schema.set_value("code", "table") schema.set_value("schema", schema_xml) #div.add( self.get_schema_wdg(schema) ) return section_div