def get_display(self): parser = self.kwargs.get("parser") self.search_key = self.kwargs.get("search_key") sobject = Search.get_by_search_key(self.search_key) if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject elif sobject.get_base_search_type() == "sthpw/file": # if it is a file object snapshot = sobject.get_parent() else: snapshots = Snapshot.get_by_sobject(sobject, is_latest=True) snapshot = snapshots[0] # Extension determine UI class for preview thumb_path = snapshot.get_web_path_by_type("icon") web_src = snapshot.get_web_path_by_type("web") from pyasm.biz import File file_type = "main" lib_path = snapshot.get_lib_path_by_type(file_type) src = snapshot.get_web_path_by_type(file_type) if not web_src: web_src = src parts = os.path.splitext(src) ext = parts[1] ext = ext.lstrip(".") ext = ext.lower() #parent = snapshot.get_parent() top = self.top self.set_as_panel(top) if ext == "pdf": iframe = HtmlElement.iframe() iframe.set_attr('src', src) iframe.add_style("width: 100%") iframe.add_style("height: 800px") top.add(iframe) return top from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) tr = table.add_row() # These bvrs allow for smooth switching if switching between files # like in the RepoBrowserWdg tr.add_style("height: 200px") load_height_bvr = { 'type': 'load', 'cbjs_action': ''' var last_height = spt.container.get_value("last_img_height"); if (last_height) { bvr.src_el.setStyle("height", last_height); } ''' } tr.add_behavior(load_height_bvr) unload_height_bvr = { 'type': 'unload', 'cbjs_action': ''' var last_height = bvr.src_el.getStyle("height"); spt.container.set_value("last_img_height", last_height); ''' } tr.add_behavior(unload_height_bvr) table.add_style("width: 100%") table.add_style("text-align", "center") from tactic.ui.widget import EmbedWdg td = table.add_cell() td.add_color( "background", "background", ) td.add_style("vertical-align: middle") td.add_style("height: inherit") td.add_style("overflow-x: auto") if ext in ['txt', 'html', 'ini']: content_div = DivWdg() f = open(lib_path, 'r') content = f.read(10000) f.close() if not content: text = "No Content" else: size = os.path.getsize(lib_path) from pyasm.common import FormatValue value = FormatValue().get_format_value(size, "KB") content_div.add("Showing first 10K of %s<hr/>" % value) text = TextAreaWdg() text.add(content) text.add_style("width: 100%") text.add_style("height: 100%") text.add_style("padding: 10px") text.add_style("border: none") text.add_attr("readonly", "true") content_div.add(text) td.add(content_div) content_div.add_style("color", "#000") content_div.add_style("width", "auto") content_div.add_style("margin", "20px") content_div.add_style("height", "100%") elif ext in File.IMAGE_EXT or ext == "gif": if lib_path.find("#") != -1: img = DivWdg() file_range = snapshot.get_file_range() file_range_div = DivWdg() file_range_div.add("File Range: %s" % file_range.get_display()) img.add(file_range_div) file_range_div.add_style("font-size: 1.4em") file_range_div.add_style("margin: 15px 0px") """ left_chevron = IconWdg("Previous", "BS_CHEVRON_LEFT") file_range_div.add(left_chevron) right_chevron = IconWdg("Next", "BS_CHEVRON_RIGHT") file_range_div.add(right_chevron) """ expanded_paths = snapshot.get_expanded_web_paths() lib_paths = snapshot.get_expanded_lib_paths() lib_path = lib_paths[0] items_div = DivWdg() img.add(items_div) items_div.add_style("width: auto") for path in expanded_paths: item = HtmlElement.img(src=path) items_div.add(item) item.add_style("max-height: 300px") item.add_style("height: auto") item.add_style("width: 32%") item.add_style("margin: 2px") item.add_style("display: inline-block") #item.add_class("spt_resizable") img.add_style("margin: 20px") img.add_style("max-height: 400px") img.add_style("overflow-y: auto") img.add_style("overflow-hidden: auto") img.add_style("text-align: left") else: if ext == "gif": img = HtmlElement.img(src=src) else: img = HtmlElement.img(src=web_src) img.add_style("height: inherit") img.add_style("width: auto") td.add(img) elif ext in File.VIDEO_EXT: embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path, preload="auto", controls=True) td.add(embed_wdg) embed_wdg.add_style("margin: auto auto") embed_wdg.add_class("spt_resizable") embed_wdg.add_behavior(load_height_bvr) embed_wdg.add_behavior(unload_height_bvr) else: thumb_table = DivWdg() td.add(thumb_table) thumb_table.add_behavior({ 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' }) thumb_table.add_class("hand") thumb_table.add_style("width: 200px") thumb_table.add_style("height: 125px") thumb_table.add_style("padding: 5px") thumb_table.add_style("margin-left: 20px") thumb_table.add_style("display: inline-block") thumb_table.add_style("vertical-align: top") thumb_table.add_style("overflow-y: hidden") from tactic.ui.panel import ThumbWdg2 thumb = ThumbWdg2() thumb_table.add(thumb) thumb.set_sobject(snapshot) table.add_row() td = table.add_cell() from tactic.ui.checkin import PathMetadataWdg from tactic.ui.checkin import SnapshotMetadataWdg from pyasm.widget import SelectWdg select = SelectWdg(name="parser") select.add_style("width: 125px") select.add_style("margin-top: 0px") select.add_style("margin-right: 10px") select.add_empty_option("-- Metadata --") td.add(select) select.add_style("float: right") select.set_option("values", ["IPTC", "EXIF", "XMP", "ImageMagick", "PIL"]) select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var parser = bvr.src_el.value; spt.panel.refresh_element(bvr.src_el, {parser: parser}) ''' }) if parser: select.set_value(parser) title_div = DivWdg() td.add(title_div) title_div.add("<div style='font-size: 16px'>File Metadata</div>") title_div.add("<div>Metadata extracted directly from the file</div>") title_div.add("<hr/>") title_div.add_style("text-align: left") title_div.add_style("margin: 0px 10px") metadata_div = DivWdg() td.add(metadata_div) metadata_div.add_style("max-height: 400px") metadata_div.add_style("overflow-y: auto") metadata_div.add_style("overflow-x: hidden") metadata_div.add_style("margin: 20px 0px 20px 10px") metadata_div.add_style("text-align: left") use_tactic_tags = self.kwargs.get("use_tactic_tags") server_src = lib_path # get it dynamically by path metadata_wdg = PathMetadataWdg(path=server_src, parser=parser, use_tactic_tags=use_tactic_tags, search_key=self.search_key) metadata_div.add(metadata_wdg) top.add("<br/>") return top
def get_display(my): top = my.top top.add_class("spt_help_edit_top") top.add_color("background", "background") view = my.kwargs.get("view") from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) table.add_color("color", "color") table.add_style("width: 100%") table.add_style("height: 500px") table.add_row() left = table.add_cell() left.add_color("background", "background3") title_wdg = Table() title_wdg.add_row() left.add(title_wdg) title_wdg.add_gradient("background", "background", 0, -10) title_wdg.add_style("padding: 5px") title_wdg.add_style("margin-bottom: 5px") title_wdg.add_style("width: 100%") title_div = DivWdg("<b>Help Pages</b>") title_cell = title_wdg.add_cell(title_div) title_cell.add_style("width: 100%") from tactic.ui.widget import ActionButtonWdg insert_button = ActionButtonWdg(title="+", size="small") insert_button.add_style("margin-top: -3px") insert_button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = "tactic.ui.panel.EditWdg" var view = "edit" var title = "Add new help doc" var cbjs_insert = "spt.tab.reload_selected();" var kwargs = { 'view': view, 'search_type': 'config/widget_config', 'default': '{"category":"HelpWdg"}', 'ignore': 'search_type|login|config', 'mode': 'insert', //'cbjs_insert': cbjs_insert } spt.panel.load_popup(title, class_name, kwargs); ''' }) title_wdg.add_cell(insert_button) docs_wdg = my.get_doc_wdg() left.add(docs_wdg) left.add_style("width: 150px") left.add_style("min-width: 150px") left.add_style("min-height: 500px") left.add_style("vertical-align: top") left.add_border() right = table.add_cell() right.add_style("vertical-align: top") right.add_border() content = HelpEditContentWdg(view=view) right.add(content) return top
def get_display(my): my.search_key = my.kwargs.get("search_key") sobject = Search.get_by_search_key(my.search_key) if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject elif sobject.get_base_search_type() == "sthpw/file": # if it is a file object snapshot = sobject.get_parent() else: snapshots = Snapshot.get_by_sobject(sobject) snapshot = snapshots[0] #parent = snapshot.get_parent() top = my.top from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) table.add_row() table.add_style("width: 100%") from tactic.ui.widget import EmbedWdg td = table.add_cell() td.add_color("background", "background",) td.add_style("vertical-align: middle") td.add_style("height: 200px") td.add_style("overflow-x: auto") file_type = "icon" thumb_path = snapshot.get_web_path_by_type(file_type) file_type = "main" src = snapshot.get_web_path_by_type(file_type) parts = os.path.splitext(src) ext = parts[1] ext = ext.lower() if ext in ['.doc','.xls']: from pyasm.widget import ThumbWdg link = ThumbWdg.find_icon_link(src) img = HtmlElement.img(src=link) href = DivWdg() href.add_style("text-align: center") href.add(img) td.add(href) href.add_behavior( { 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' } ) href.add_class("hand") else: embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path) td.add(embed_wdg) embed_wdg.add_style("margin: auto auto") embed_wdg.add_class("spt_resizable") embed_wdg.add_style("width: 100%") embed_wdg.add_style("height: 240px") embed_wdg.add_behavior( { 'type': 'load', 'cbjs_action': ''' var last_height = spt.container.get_value("last_img_height"); if (last_height) { bvr.src_el.setStyle("height", last_height); } ''' } ) embed_wdg.add_behavior( { 'type': 'unload', 'cbjs_action': ''' var last_height = bvr.src_el.getStyle("height"); spt.container.set_value("last_img_height", last_height); ''' } ) table.add_row() td = table.add_cell() from tactic.ui.checkin import PathMetadataWdg from tactic.ui.checkin import SnapshotMetadataWdg metadata_div = DivWdg() td.add(metadata_div) metadata_div.add_style("max-height: 400px") metadata_div.add_style("overflow-y: auto") metadata_div.add_style("overflow-x: hidden") parser = my.kwargs.get("parser") use_tactic_tags = my.kwargs.get("use_tactic_tags") file_type = "main" server_src = snapshot.get_lib_path_by_type(file_type) # get it dynamically by path metadata_wdg = PathMetadataWdg(path=server_src, parser=parser, use_tactic_tags=use_tactic_tags) metadata_div.add(metadata_wdg) #else: # metadata_wdg = SnapshotMetadataWdg(snapshot=snapshot) # metadata_div.add(metadata_wdg) top.add("<br/>") return top
def get_display(my): my.search_key = my.kwargs.get("search_key") sobject = Search.get_by_search_key(my.search_key) if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject elif sobject.get_base_search_type() == "sthpw/file": # if it is a file object snapshot = sobject.get_parent() else: snapshots = Snapshot.get_by_sobject(sobject) snapshot = snapshots[0] #parent = snapshot.get_parent() top = my.top from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) table.add_row() table.add_style("width: 100%") from tactic.ui.widget import EmbedWdg td = table.add_cell() td.add_color( "background", "background", ) td.add_style("vertical-align: middle") td.add_style("height: 200px") td.add_style("overflow-x: auto") file_type = "icon" thumb_path = snapshot.get_web_path_by_type(file_type) file_type = "main" src = snapshot.get_web_path_by_type(file_type) parts = os.path.splitext(src) ext = parts[1] ext = ext.lower() if ext in ['.doc', '.xls']: from pyasm.widget import ThumbWdg link = ThumbWdg.find_icon_link(src) img = HtmlElement.img(src=link) href = DivWdg() href.add_style("text-align: center") href.add(img) td.add(href) href.add_behavior({ 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' }) href.add_class("hand") else: embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path) td.add(embed_wdg) embed_wdg.add_style("margin: auto auto") embed_wdg.add_class("spt_resizable") embed_wdg.add_style("width: 100%") embed_wdg.add_style("height: 240px") embed_wdg.add_behavior({ 'type': 'load', 'cbjs_action': ''' var last_height = spt.container.get_value("last_img_height"); if (last_height) { bvr.src_el.setStyle("height", last_height); } ''' }) embed_wdg.add_behavior({ 'type': 'unload', 'cbjs_action': ''' var last_height = bvr.src_el.getStyle("height"); spt.container.set_value("last_img_height", last_height); ''' }) table.add_row() td = table.add_cell() from tactic.ui.checkin import PathMetadataWdg from tactic.ui.checkin import SnapshotMetadataWdg metadata_div = DivWdg() td.add(metadata_div) metadata_div.add_style("max-height: 400px") metadata_div.add_style("overflow-y: auto") metadata_div.add_style("overflow-x: hidden") parser = my.kwargs.get("parser") use_tactic_tags = my.kwargs.get("use_tactic_tags") file_type = "main" server_src = snapshot.get_lib_path_by_type(file_type) # get it dynamically by path metadata_wdg = PathMetadataWdg(path=server_src, parser=parser, use_tactic_tags=use_tactic_tags) metadata_div.add(metadata_wdg) #else: # metadata_wdg = SnapshotMetadataWdg(snapshot=snapshot) # metadata_div.add(metadata_wdg) top.add("<br/>") return top
def get_display(my): is_admin_project = Project.get().is_admin() security = Environment.get_security() if is_admin_project and not security.check_access("builtin", "view_site_admin", "allow"): return Error403Wdg() # create the elements config = WidgetConfig.get(xml=my.config_xml, view="application") left_nav_handler = config.get_display_handler("left_nav") left_nav_options = config.get_display_options("left_nav") view_side_bar = None if left_nav_handler: left_nav_wdg = Common.create_from_class_path(left_nav_handler, [], left_nav_options) # caching side_bar_cache = my.get_side_bar_cache(left_nav_wdg) else: view_side_bar = False # create the main table core_table = Table() core_table.add_tbody() core_table.set_style("border: 0px; border-collapse: collapse; width: 100%;") # add a spacer row #spacer_tr = core_table.add_row() #spacer_tr.add_style("width: 100%") #td = core_table.add_cell() #td.set_style("min-height: 1px; height: 1px;") #core_table.add_cell() #core_table.add_cell() # determine if the side bar is visible if view_side_bar == None: view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow') # add the main cells tr, td = core_table.add_row_cell() td.add_style("padding: 0px") td.add_style("margin: 0px") # add the main resizable table from tactic.ui.container import ResizableTableWdg main_table = ResizableTableWdg() main_table.set_keep_table_size() main_table.add_style("width: 100%") td.add(main_table) left_nav_td = main_table.add_cell() if view_side_bar: left_nav_td.add_class("spt_panel") left_nav_td.add_style("padding: 0px") main_body_td = main_table.add_cell(resize=False) main_body_td.add_style("padding: 10px") main_body_td.set_style( "width: 100%; vertical-align: top; text-align: center; padding-top: 3px" ) if view_side_bar: left_nav_td.set_style( "vertical-align: top" ) # create the left navigation panel left_nav_div = DivWdg() left_nav_td.add(left_nav_div) left_nav_div.set_id("side_bar" ) # add the detail to the panel left_nav_div.add_attr("spt_class_name", left_nav_handler) for name, value in left_nav_options.items(): left_nav_div.add_attr("spt_%s" % name, value) left_nav_div.add_style("max_width: 185px") left_nav_div.add_style("width: 185px") left_nav_div.add_style("text-align: right") left_nav_div.add_style("vertical-align: top") left_nav_div.add_style("overflow: hidden") left_nav_div.add_class("spt_resizable") side_bar_inner = DivWdg() left_nav_div.add(side_bar_inner) #side_bar_inner.add_style("padding-left: 1px") side_bar_inner.add_style("width: 100%") # add side bar to nav side_bar_inner.add(side_bar_cache) left_nav_div.add_style("border-style: solid") left_nav_div.add_style("border-width: 0px 1px 0px 0px") #left_nav_div.add_color("border-color", "border") left_nav_div.add_color("border-color", "border", -10) web = WebContainer.get_web() browser = web.get_browser() if browser in ['Qt','Webkit']: min_width = "1px" else: min_width = "0px" left_nav_div.add_behavior( { 'type': 'listen', 'event_name': 'side_bar|hide_now', 'min_width': min_width, 'cbjs_action': ''' var size = bvr.src_el.getSize(); bvr.src_el.setAttribute("spt_size", size.x); bvr.src_el.setStyle("width", bvr.min_width); ''' } ) left_nav_div.add_behavior( { 'type': 'listen', 'event_name': 'side_bar|hide', 'min_width': min_width, 'cbjs_action': ''' var size = bvr.src_el.getSize(); bvr.src_el.setAttribute("spt_size", size.x); new Fx.Tween(bvr.src_el, {duration:'short'}).start('width', bvr.min_width); ''' } ) left_nav_div.add_behavior( { 'type': 'listen', 'event_name': 'side_bar|show', 'min_width': min_width, 'cbjs_action': ''' var width = bvr.src_el.getAttribute("spt_size"); if (!width) { width = 185; } if (parseInt(width) < 5) { width = 185; } //bvr.src_el.setStyle("width", width + "px"); new Fx.Tween(bvr.src_el, {duration:'short'}).start('width', bvr.min_width, width+"px"); ''' } ) left_nav_div.add_behavior( { 'type': 'listen', 'event_name': 'side_bar|toggle', 'cbjs_action': ''' var size = bvr.src_el.getSize(); if (size.x < 5) { spt.named_events.fire_event("side_bar|show", {} ); } else { spt.named_events.fire_event("side_bar|hide", {} ); } ''' } ) # create the main body panel palette = WebContainer.get_palette() color = palette.color("background2") main_body_rounded = DivWdg() main_body_inner = main_body_rounded main_body_inner.add_style("min-height: 500px") # DEBREACATED """ # add a breadcrumb breadcrumb_wdg = DivWdg() # hide the breadcrumb breadcrumb_wdg.add_style("display", "none") Container.put("breadcrumb", breadcrumb_wdg) breadcrumb_wdg.set_id("breadcrumb") breadcrumb_wdg.add_style("text-align: left") breadcrumb_wdg.add_looks( "fnt_title_3" ) main_body_inner.add(breadcrumb_wdg) """ main_body_panel = DivWdg() main_body_panel.set_id("main_body") main_body_panel.add_class("spt_main_panel") main_body_inner.add(main_body_panel) tab = MainBodyTabWdg() main_body_panel.add(tab) # TEST: NEW LAYOUT if Config.get_value("install", "layout") == "fixed": main_body_panel.add_style("margin-top: 31px") main_body_rounded.add_color("background", "background") main_body_rounded.add_style("padding: 3px 0px 0px 0px") # add the content to the main body panel try: if my.widget: tab.add(my.widget) element_name = my.widget.get_name() else: main_body_handler = config.get_display_handler("main_body") main_body_options = config.get_display_options("main_body") element_name = main_body_options.get("element_name") title = main_body_options.get("title") main_body_content = Common.create_from_class_path(main_body_handler, [], main_body_options) # get the web values from top_layout main_body_values = config.get_web_options("main_body") web = WebContainer.get_web() if isinstance(main_body_values, dict): for name, value in main_body_values.items(): web.set_form_value(name, value) main_body_content.set_name(element_name) tab.add(main_body_content, element_name, title) my.set_as_panel(main_body_panel, class_name=main_body_handler, kwargs=main_body_options) main_body_panel.add_behavior( { 'type': 'load', 'element_name': element_name, 'cbjs_action': ''' if (spt.help) spt.help.set_view(bvr.element_name); ''' } ) except Exception, e: # handle an error in the drawing buffer = my.get_buffer_on_exception() error_wdg = my.handle_exception(e) main_body_content = DivWdg() main_body_content.add(error_wdg) main_body_content = main_body_content.get_buffer_display() tab.add(main_body_content, element_name, title)
def get_display(self): parser = self.kwargs.get("parser") self.search_key = self.kwargs.get("search_key") sobject = Search.get_by_search_key(self.search_key) if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject elif sobject.get_base_search_type() == "sthpw/file": # if it is a file object snapshot = sobject.get_parent() else: snapshots = Snapshot.get_by_sobject(sobject, is_latest=True) snapshot = snapshots[0] # Extension determine UI class for preview thumb_path = snapshot.get_web_path_by_type("icon") web_src = snapshot.get_web_path_by_type("web") from pyasm.biz import File file_type = "main" lib_path = snapshot.get_lib_path_by_type(file_type) src = snapshot.get_web_path_by_type(file_type) if not web_src: web_src = src parts = os.path.splitext(src) ext = parts[1] ext = ext.lstrip(".") ext = ext.lower() #parent = snapshot.get_parent() top = self.top self.set_as_panel(top) if ext == "pdf": iframe = HtmlElement.iframe() iframe.set_attr('src', src) iframe.add_style("width: 100%") iframe.add_style("height: 800px") top.add(iframe) return top from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) tr = table.add_row() # These bvrs allow for smooth switching if switching between files # like in the RepoBrowserWdg tr.add_style("height: 200px") load_height_bvr = { 'type': 'load', 'cbjs_action': ''' var last_height = spt.container.get_value("last_img_height"); if (last_height) { bvr.src_el.setStyle("height", last_height); } ''' } tr.add_behavior(load_height_bvr) unload_height_bvr = { 'type': 'unload', 'cbjs_action': ''' var last_height = bvr.src_el.getStyle("height"); spt.container.set_value("last_img_height", last_height); ''' } tr.add_behavior(unload_height_bvr) table.add_style("width: 100%") table.add_style("text-align", "center") from tactic.ui.widget import EmbedWdg td = table.add_cell() td.add_color("background", "background",) td.add_style("vertical-align: middle") td.add_style("height: inherit") td.add_style("overflow-x: auto") if ext in ['txt','html', 'ini']: content_div = DivWdg() f = open(lib_path, 'r') content = f.read(10000) f.close() if not content: text = "No Content" else: size = os.path.getsize(lib_path) from pyasm.common import FormatValue value = FormatValue().get_format_value(size, "KB") content_div.add("Showing first 10K of %s<hr/>" % value) text = TextAreaWdg() text.add(content) text.add_style("width: 100%") text.add_style("height: 100%") text.add_style("padding: 10px") text.add_style("border: none") text.add_attr("readonly", "true") content_div.add(text) td.add(content_div) content_div.add_style("color", "#000") content_div.add_style("width", "auto") content_div.add_style("margin", "20px") content_div.add_style("height", "100%") elif ext in File.IMAGE_EXT or ext == "gif": if lib_path.find("#") != -1: img = DivWdg() file_range = snapshot.get_file_range() file_range_div = DivWdg() file_range_div.add("File Range: %s" % file_range.get_display()) img.add(file_range_div) file_range_div.add_style("font-size: 1.4em") file_range_div.add_style("margin: 15px 0px") """ left_chevron = IconWdg("Previous", "BS_CHEVRON_LEFT") file_range_div.add(left_chevron) right_chevron = IconWdg("Next", "BS_CHEVRON_RIGHT") file_range_div.add(right_chevron) """ expanded_paths = snapshot.get_expanded_web_paths() lib_paths = snapshot.get_expanded_lib_paths() lib_path = lib_paths[0] items_div = DivWdg() img.add(items_div) items_div.add_style("width: auto") for path in expanded_paths: item = HtmlElement.img(src=path) items_div.add(item) item.add_style("max-height: 300px") item.add_style("height: auto") item.add_style("width: 32%") item.add_style("margin: 2px") item.add_style("display: inline-block") #item.add_class("spt_resizable") img.add_style("margin: 20px") img.add_style("max-height: 400px") img.add_style("overflow-y: auto") img.add_style("overflow-hidden: auto") img.add_style("text-align: left") else: if ext == "gif": img = HtmlElement.img(src=src) else: img = HtmlElement.img(src=web_src) img.add_style("height: inherit") img.add_style("width: auto") td.add(img) elif ext in File.VIDEO_EXT: embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path, preload="auto", controls=True) td.add(embed_wdg) embed_wdg.add_style("margin: auto auto") embed_wdg.add_class("spt_resizable") embed_wdg.add_behavior(load_height_bvr) embed_wdg.add_behavior(unload_height_bvr) else: thumb_table = DivWdg() td.add(thumb_table) thumb_table.add_behavior( { 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' } ) thumb_table.add_class("hand") thumb_table.add_style("width: 200px") thumb_table.add_style("height: 125px") thumb_table.add_style("padding: 5px") thumb_table.add_style("margin-left: 20px") thumb_table.add_style("display: inline-block") thumb_table.add_style("vertical-align: top") thumb_table.add_style("overflow-y: hidden") from tactic.ui.panel import ThumbWdg2 thumb = ThumbWdg2() thumb_table.add(thumb) thumb.set_sobject(snapshot) table.add_row() td = table.add_cell() from tactic.ui.checkin import PathMetadataWdg from tactic.ui.checkin import SnapshotMetadataWdg from pyasm.widget import SelectWdg select = SelectWdg(name="parser") select.add_style("width: 125px") select.add_style("margin-top: 0px") select.add_style("margin-right: 10px") select.add_empty_option("-- Metadata --") td.add(select) select.add_style("float: right") select.set_option("values", ["IPTC","EXIF","XMP","ImageMagick","PIL"]) select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var parser = bvr.src_el.value; spt.panel.refresh_element(bvr.src_el, {parser: parser}) ''' } ) if parser: select.set_value(parser) title_div = DivWdg() td.add(title_div) title_div.add("<div style='font-size: 16px'>File Metadata</div>") title_div.add("<div>Metadata extracted directly from the file</div>") title_div.add("<hr/>") title_div.add_style("text-align: left") title_div.add_style("margin: 0px 10px") metadata_div = DivWdg() td.add(metadata_div) metadata_div.add_style("max-height: 400px") metadata_div.add_style("overflow-y: auto") metadata_div.add_style("overflow-x: hidden") metadata_div.add_style("margin: 20px 0px 20px 10px") metadata_div.add_style("text-align: left") use_tactic_tags = self.kwargs.get("use_tactic_tags") server_src = lib_path # get it dynamically by path metadata_wdg = PathMetadataWdg(path=server_src, parser=parser, use_tactic_tags=use_tactic_tags, search_key=self.search_key) metadata_div.add(metadata_wdg) top.add("<br/>") return top
def get_display(my): my.search_key = my.kwargs.get("search_key") sobject = Search.get_by_search_key(my.search_key) if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject elif sobject.get_base_search_type() == "sthpw/file": # if it is a file object snapshot = sobject.get_parent() else: snapshots = Snapshot.get_by_sobject(sobject) snapshot = snapshots[0] #parent = snapshot.get_parent() top = my.top from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) table.add_row() table.add_style("width: 100%") from tactic.ui.widget import EmbedWdg td = table.add_cell() td.add_color("background", "background",) td.add_style("vertical-align: middle") td.add_style("height: 200px") td.add_style("overflow-x: auto") file_type = "icon" thumb_path = snapshot.get_web_path_by_type(file_type) file_type = "main" src = snapshot.get_web_path_by_type(file_type) lib_path = snapshot.get_lib_path_by_type(file_type) parts = os.path.splitext(src) ext = parts[1] ext = ext.lower() content_div = DivWdg() if ext in ['.doc','.xls']: from pyasm.widget import ThumbWdg link = ThumbWdg.find_icon_link(src) img = HtmlElement.img(src=link) href = DivWdg() href.add_style("text-align: center") href.add(img) td.add(href) href.add_behavior( { 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' } ) href.add_class("hand") elif ext in ['.txt','.html', '.ini']: f = open(lib_path, 'r') content = f.read(10000) f.close() if not content: text = "No Content" else: size = os.path.getsize(lib_path) from pyasm.common import FormatValue value = FormatValue().get_format_value(size, "KB") content_div.add("Showing first 10K of %s<hr/>" % value) text = TextAreaWdg() text.add(content) text.add_style("width: 100%") text.add_style("height: 300px") text.add_style("padding: 10px") text.add_style("border: none") text.add_attr("readonly", "true") content_div.add(text) td.add(content_div) content_div.add_style("color", "#000") content_div.add_style("width", "auto") content_div.add_style("margin", "20px") elif thumb_path == "__DYNAMIC__": td.add("No Preview") else: embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path) td.add(embed_wdg) embed_wdg.add_style("margin: auto auto") embed_wdg.add_class("spt_resizable") embed_wdg.add_style("width: 100%") embed_wdg.add_style("height: 240px") embed_wdg.add_behavior( { 'type': 'load', 'cbjs_action': ''' var last_height = spt.container.get_value("last_img_height"); if (last_height) { bvr.src_el.setStyle("height", last_height); } ''' } ) embed_wdg.add_behavior( { 'type': 'unload', 'cbjs_action': ''' var last_height = bvr.src_el.getStyle("height"); spt.container.set_value("last_img_height", last_height); ''' } ) table.add_row() td = table.add_cell() from tactic.ui.checkin import PathMetadataWdg from tactic.ui.checkin import SnapshotMetadataWdg metadata_div = DivWdg() td.add(metadata_div) metadata_div.add_style("max-height: 400px") metadata_div.add_style("overflow-y: auto") metadata_div.add_style("overflow-x: hidden") parser = my.kwargs.get("parser") use_tactic_tags = my.kwargs.get("use_tactic_tags") file_type = "main" server_src = snapshot.get_lib_path_by_type(file_type) # get it dynamically by path metadata_wdg = PathMetadataWdg(path=server_src, parser=parser, use_tactic_tags=use_tactic_tags) metadata_div.add(metadata_wdg) #else: # metadata_wdg = SnapshotMetadataWdg(snapshot=snapshot) # metadata_div.add(metadata_wdg) top.add("<br/>") return top
def get_display(self): is_admin_project = Project.get().is_admin() security = Environment.get_security() if is_admin_project and not security.check_access( "builtin", "view_site_admin", "allow"): return Error403Wdg() # create the elements config = WidgetConfig.get(xml=self.config_xml, view="application") left_nav_handler = config.get_display_handler("left_nav") left_nav_options = config.get_display_options("left_nav") view_side_bar = None if left_nav_handler: left_nav_wdg = Common.create_from_class_path( left_nav_handler, [], left_nav_options) # caching side_bar_cache = self.get_side_bar_cache(left_nav_wdg) else: view_side_bar = False # create the main table core_table = Table() core_table.add_tbody() core_table.set_style( "border: 0px; border-collapse: collapse; width: 100%;") # add a spacer row #spacer_tr = core_table.add_row() #spacer_tr.add_style("width: 100%") #td = core_table.add_cell() #td.set_style("min-height: 1px; height: 1px;") #core_table.add_cell() #core_table.add_cell() # determine if the side bar is visible if view_side_bar == None: view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow') # add the main cells tr, td = core_table.add_row_cell() td.add_style("padding: 0px") td.add_style("margin: 0px") # add the main resizable table from tactic.ui.container import ResizableTableWdg main_table = ResizableTableWdg() main_table.set_keep_table_size() main_table.add_style("width: 100%") td.add(main_table) left_nav_td = main_table.add_cell() if view_side_bar: left_nav_td.add_class("spt_panel") left_nav_td.add_style("padding: 0px") main_body_td = main_table.add_cell(resize=False) main_body_td.add_style("padding: 10px") main_body_td.set_style( "width: 100%; vertical-align: top; text-align: center; padding-top: 3px" ) if view_side_bar: left_nav_td.set_style("vertical-align: top") # create the left navigation panel left_nav_div = DivWdg() left_nav_td.add(left_nav_div) left_nav_div.set_id("side_bar") # add the detail to the panel left_nav_div.add_attr("spt_class_name", left_nav_handler) for name, value in left_nav_options.items(): left_nav_div.add_attr("spt_%s" % name, value) left_nav_div.add_style("max_width: 185px") left_nav_div.add_style("width: 185px") left_nav_div.add_style("text-align: right") left_nav_div.add_style("vertical-align: top") left_nav_div.add_style("overflow: hidden") left_nav_div.add_class("spt_resizable") side_bar_inner = DivWdg() left_nav_div.add(side_bar_inner) #side_bar_inner.add_style("padding-left: 1px") side_bar_inner.add_style("width: 100%") # add side bar to nav side_bar_inner.add(side_bar_cache) left_nav_div.add_style("border-style: solid") left_nav_div.add_style("border-width: 0px 1px 0px 0px") #left_nav_div.add_color("border-color", "border") left_nav_div.add_color("border-color", "border", -10) web = WebContainer.get_web() browser = web.get_browser() if browser in ['Qt', 'Webkit']: min_width = "1px" else: min_width = "0px" left_nav_div.add_behavior({ 'type': 'listen', 'event_name': 'side_bar|hide_now', 'min_width': min_width, 'cbjs_action': ''' var size = bvr.src_el.getSize(); bvr.src_el.setAttribute("spt_size", size.x); bvr.src_el.setStyle("width", bvr.min_width); ''' }) left_nav_div.add_behavior({ 'type': 'listen', 'event_name': 'side_bar|hide', 'min_width': min_width, 'cbjs_action': ''' var size = bvr.src_el.getSize(); bvr.src_el.setAttribute("spt_size", size.x); new Fx.Tween(bvr.src_el, {duration:'short'}).start('width', bvr.min_width); ''' }) left_nav_div.add_behavior({ 'type': 'listen', 'event_name': 'side_bar|show', 'min_width': min_width, 'cbjs_action': ''' var width = bvr.src_el.getAttribute("spt_size"); if (!width) { width = 185; } if (parseInt(width) < 5) { width = 185; } //bvr.src_el.setStyle("width", width + "px"); new Fx.Tween(bvr.src_el, {duration:'short'}).start('width', bvr.min_width, width+"px"); ''' }) left_nav_div.add_behavior({ 'type': 'listen', 'event_name': 'side_bar|toggle', 'cbjs_action': ''' var size = bvr.src_el.getSize(); if (size.x < 5) { spt.named_events.fire_event("side_bar|show", {} ); } else { spt.named_events.fire_event("side_bar|hide", {} ); } ''' }) # create the main body panel palette = WebContainer.get_palette() color = palette.color("background2") main_body_rounded = DivWdg() main_body_inner = main_body_rounded main_body_inner.add_style("min-height: 500px") # DEBREACATED """ # add a breadcrumb breadcrumb_wdg = DivWdg() # hide the breadcrumb breadcrumb_wdg.add_style("display", "none") Container.put("breadcrumb", breadcrumb_wdg) breadcrumb_wdg.set_id("breadcrumb") breadcrumb_wdg.add_style("text-align: left") breadcrumb_wdg.add_looks( "fnt_title_3" ) main_body_inner.add(breadcrumb_wdg) """ main_body_panel = DivWdg() main_body_panel.set_id("main_body") main_body_panel.add_class("spt_main_panel") main_body_inner.add(main_body_panel) tab = MainBodyTabWdg() main_body_panel.add(tab) # TEST: NEW LAYOUT if Config.get_value("install", "layout") == "fixed": main_body_panel.add_style("margin-top: 31px") main_body_rounded.add_color("background", "background") main_body_rounded.add_style("padding: 3px 0px 0px 0px") # add the content to the main body panel try: if self.widget: tab.add(self.widget) element_name = self.widget.get_name() else: main_body_handler = config.get_display_handler("main_body") main_body_options = config.get_display_options("main_body") element_name = main_body_options.get("element_name") title = main_body_options.get("title") main_body_content = Common.create_from_class_path( main_body_handler, [], main_body_options) # get the web values from top_layout main_body_values = config.get_web_options("main_body") web = WebContainer.get_web() if isinstance(main_body_values, dict): for name, value in main_body_values.items(): web.set_form_value(name, value) main_body_content.set_name(element_name) tab.add(main_body_content, element_name, title) self.set_as_panel(main_body_panel, class_name=main_body_handler, kwargs=main_body_options) main_body_panel.add_behavior({ 'type': 'load', 'element_name': element_name, 'cbjs_action': ''' if (spt.help) spt.help.set_view(bvr.element_name); ''' }) except Exception as e: # handle an error in the drawing buffer = self.get_buffer_on_exception() error_wdg = self.handle_exception(e) main_body_content = DivWdg() main_body_content.add(error_wdg) main_body_content = main_body_content.get_buffer_display() tab.add(main_body_content, element_name, title) # add the main container container_div = DivWdg() container_div.set_style("width: 100%;") # NOTE: the td should not be the sliding element! So we create a div inside the TD to be the sliding element main_body_div = DivWdg() main_body_div.set_id("horizontal_main_body_slider") main_body_div.add(main_body_inner) """ # get the global drag_ghost_div drag_ghost_div = self.get_drag_ghost_div() drag_ghost_div.set_id( "drag_ghost_copy" ) drag_ghost_div.add_class( "SPT_PUW" ) # make it a Page Utility Widget (now processed client side) drag_ghost_div.set_z_start( 400 ) """ from page_header_wdg import PageHeaderWdg header_panel = DivWdg() header_panel.set_id("main_header") header_panel.add_attr("spt_class_name", "tactic.ui.app.PageHeaderWdg") header_wdg = PageHeaderWdg() header_panel.add(header_wdg) container_div.add(header_panel.get_buffer_display()) main_body_dis = main_body_div.get_buffer_display() main_body_td.add(main_body_dis) container_div.add(core_table) #container_div.add( drag_ghost_div ) is_admin = False security = Environment.get_security() if security.check_access("builtin", "view_site_admin", "allow"): is_admin = True if is_admin: from quick_box_wdg import QuickBoxWdg quick_box = QuickBoxWdg() container_div.add(quick_box) container_div.add_behavior({ 'type': 'load', 'cbjs_action': ''' spt.named_events.fire_event("close_admin_bar"); ''' }) return container_div
def get_display(my): top = my.top top.add_class("spt_help_edit_top") top.add_color("background", "background") view = my.kwargs.get("view") from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) table.add_color("color", "color") table.add_style("width: 100%") table.add_style("height: 500px") table.add_row() left = table.add_cell() left.add_color("background", "background3") title_wdg = Table() title_wdg.add_row() left.add(title_wdg) title_wdg.add_gradient("background", "background", 0, -10) title_wdg.add_style("padding: 5px") title_wdg.add_style("margin-bottom: 5px") title_wdg.add_style("width: 100%") title_div = DivWdg("<b>Help Pages</b>") title_cell = title_wdg.add_cell(title_div) title_cell.add_style("width: 100%") from tactic.ui.widget import ActionButtonWdg insert_button = ActionButtonWdg(title="+", size="small") insert_button.add_style("margin-top: -3px") insert_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var class_name = "tactic.ui.panel.EditWdg" var view = "edit" var title = "Add new help doc" var cbjs_insert = "spt.tab.reload_selected();" var kwargs = { 'view': view, 'search_type': 'config/widget_config', 'default': '{"category":"HelpWdg"}', 'ignore': 'search_type|login|config', 'mode': 'insert', //'cbjs_insert': cbjs_insert } spt.panel.load_popup(title, class_name, kwargs); ''' }) title_wdg.add_cell(insert_button) docs_wdg = my.get_doc_wdg() left.add(docs_wdg) left.add_style("width: 150px") left.add_style("min-width: 150px") left.add_style("min-height: 500px") left.add_style("vertical-align: top") left.add_border() right = table.add_cell() right.add_style("vertical-align: top") right.add_border() content = HelpEditContentWdg(view=view) right.add(content) return top
def get_display(my): my.search_key = my.kwargs.get("search_key") my.sobject = Search.get_by_search_key(my.search_key) snapshot = my.sobject.get_parent() parent = snapshot.get_parent() top = my.top from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) table.add_row() table.add_style("width: 100%") #td = table.add_cell() #thumb_div = DivWdg() #td.add(thumb_div) #thumb = ThumbWdg() #thumb_div.add(thumb) #thumb_div.add_class("spt_resizable") #thumb.set_sobject(parent) #thumb.set_icon_size(120) from tactic.ui.widget import EmbedWdg td = table.add_cell() td.add_color("background", "background",) td.add_style("vertical-align: middle") td.add_style("height: 200px") td.add_style("overflow-x: auto") src = my.sobject.get_web_path() parts = os.path.splitext(src) ext = parts[1] ext = ext.lower() if ext in ['.doc','.xls']: from pyasm.widget import ThumbWdg link = ThumbWdg.find_icon_link(src) img = HtmlElement.img(src=link) href = DivWdg() href.add_style("text-align: center") href.add(img) td.add(href) href.add_behavior( { 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' } ) href.add_class("hand") else: embed_wdg = EmbedWdg(src=src) td.add(embed_wdg) embed_wdg.add_style("margin: auto auto") embed_wdg.add_class("spt_resizable") embed_wdg.add_style("width: 100%") embed_wdg.add_style("height: 240px") embed_wdg.add_behavior( { 'type': 'load', 'cbjs_action': ''' var last_height = spt.container.get_value("last_img_height"); if (last_height) { bvr.src_el.setStyle("height", last_height); } ''' } ) embed_wdg.add_behavior( { 'type': 'unload', 'cbjs_action': ''' var last_height = bvr.src_el.getStyle("height"); spt.container.set_value("last_img_height", last_height); ''' } ) table.add_row() from tactic.ui.checkin import SnapshotMetadataWdg metadata_wdg = SnapshotMetadataWdg(snapshot=snapshot) td = table.add_cell() metadata_div = DivWdg() td.add(metadata_div) metadata_div.add_style("max-height: 400px") metadata_div.add_style("overflow-y: auto") metadata_div.add_style("overflow-x: hidden") metadata_div.add(metadata_wdg) top.add("<br/>") return top
def get_content_wdg(my): div = DivWdg() div.add_class("spt_tool_top") #table = Table() from tactic.ui.container import ResizableTableWdg from table_layout_wdg import FastTableLayoutWdg table = ResizableTableWdg() table.add_style("table-layout", "fixed") table.add_style("width: 100%") div.add(table) table.add_row() td = table.add_cell() kwargs = my.kwargs.copy() td.add_style("vertical-align: top") layout_div = DivWdg() layout_div.add_style("min-height: 500px") layout_div.add_style("height: auto") td.add(layout_div) td.add_style("overflow: hidden") kwargs['show_shelf'] = False kwargs['show_search_limit'] = False kwargs['expand_on_load'] = False layout = FastTableLayoutWdg(**kwargs) layout_div.add(layout) layout.set_sobjects(my.sobjects) #from tactic.ui.panel import TileLayoutWdg #layout = TileLayoutWdg(**my.kwargs) #layout_div.add(layout) td = table.add_cell() td.add_border(color="#EEE") td.add_style("vertical-align: top") content = DivWdg() td.add(content) content.add_class("spt_tool_content") content.add_border(color="#EEE") content.add_style("margin: -1px") content.add_style("height: 100%") #content.add_style("padding: 0px 20px") no_content_wdg = DivWdg() content.add(no_content_wdg) no_content_wdg.add("<br/>"*3) ''' The no content message displays tool icons and a message in format: <tools> <msg> ''' tool_icons = my.kwargs.get('tool_icon') if isinstance(tool_icons, basestring): tool_icon_lst = tool_icons.split("|") else: tool_icon_lst = None if tool_icon_lst: for icon in tool_icon_lst: icon = IconWdg(icon=icon) icon.add_style("padding", "5px") no_content_wdg.add(icon) no_content_wdg.add("</br></br>") tool_msg = my.kwargs.get('tool_msg') if tool_msg: no_content_wdg.add("<p>%s<p>" % tool_msg) else: no_content_wdg.add("Click the tool(s) to modify settings.") #no_content_wdg.add_style("opacity: 0.5") no_content_wdg.add_style("margin: 30px auto") no_content_wdg.add_color("color", "color3") no_content_wdg.add_color("background", "background3") no_content_wdg.add_style("text-align", "center") no_content_wdg.add_style("padding-top: 20px") no_content_wdg.add_style("padding-bottom: 20px") no_content_wdg.add_style("width: 350px") no_content_wdg.add_style("height: 110px") no_content_wdg.add_style("margin: 30px auto") no_content_wdg.add_border() return div
def get_content_wdg(my): div = DivWdg() div.add_class("spt_tool_top") #table = Table() from tactic.ui.container import ResizableTableWdg from table_layout_wdg import FastTableLayoutWdg table = ResizableTableWdg() table.add_style("table-layout", "fixed") table.add_style("width: 100%") div.add(table) table.add_row() td = table.add_cell() kwargs = my.kwargs.copy() td.add_style("vertical-align: top") layout_div = DivWdg() layout_div.add_style("min-height: 500px") layout_div.add_style("height: auto") td.add(layout_div) td.add_style("overflow: hidden") kwargs['show_shelf'] = False kwargs['show_search_limit'] = False kwargs['expand_on_load'] = False layout = FastTableLayoutWdg(**kwargs) layout_div.add(layout) layout.set_sobjects(my.sobjects) #from tactic.ui.panel import TileLayoutWdg #layout = TileLayoutWdg(**my.kwargs) #layout_div.add(layout) td = table.add_cell() td.add_border(color="#EEE") td.add_style("vertical-align: top") content = DivWdg() td.add(content) content.add_class("spt_tool_content") content.add_border(color="#EEE") content.add_style("margin: -1px") content.add_style("height: 100%") #content.add_style("padding: 0px 20px") no_content_wdg = DivWdg() content.add(no_content_wdg) no_content_wdg.add("<br/>"*3) no_content_wdg.add("<i>-- No Content --</i>") #no_content_wdg.add_style("opacity: 0.5") no_content_wdg.add_style("margin: 30px auto") no_content_wdg.add_color("color", "color3") no_content_wdg.add_color("background", "background3") no_content_wdg.add_style("text-align", "center") no_content_wdg.add_style("padding-top: 20px") no_content_wdg.add_style("padding-bottom: 20px") no_content_wdg.add_style("width: 350px") no_content_wdg.add_style("height: 110px") no_content_wdg.add_style("margin: 30px auto") no_content_wdg.add_border() return div