def get_category_preview_wdg(self, paths, title=None, tags={}): div = DivWdg() if not title: title = "Paths" div.add("%s (%s)<hr/>" % (title, len(paths))) if not paths: div.add("-- None --<br/>") paths_div = DivWdg() div.add(paths_div) from pyasm.widget import ThumbWdg for path in paths: path_div = DivWdg() paths_div.add(path_div) path_div.add_style("float: left") path_div.add_style("min-height: 60px") path_div.add_style("margin: 15px") path_div.add_style("width: 60px") icon_link = ThumbWdg.find_icon_link(path) path_div.add("<div><img width='60px' src='%s'/></div>" % icon_link) filename = os.path.basename(path) #path_div.add(path) path_div.add(filename) if tags: path_tags = tags.get(path) path_div.add(" " * 10) path_div.add(path_tags['sobject']) div.add("<br clear='all'/>") return div
def get_category_preview_wdg(self, paths, title=None, tags={}): div = DivWdg() if not title: title = "Paths" div.add("%s (%s)<hr/>" % (title, len(paths)) ) if not paths: div.add("-- None --<br/>") paths_div = DivWdg() div.add(paths_div) from pyasm.widget import ThumbWdg for path in paths: path_div = DivWdg() paths_div.add(path_div) path_div.add_style("float: left") path_div.add_style("min-height: 60px") path_div.add_style("margin: 15px") path_div.add_style("width: 60px") icon_link = ThumbWdg.find_icon_link(path) path_div.add("<div><img width='60px' src='%s'/></div>" % icon_link) filename = os.path.basename(path) #path_div.add(path) path_div.add(filename) if tags: path_tags = tags.get(path) path_div.add( " "*10) path_div.add(path_tags['sobject']) div.add("<br clear='all'/>") return div
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): top = my.top src = my.kwargs.get("src") file = my.kwargs.get("file") if file: src = file.get_web_path() opacity = 1.0 if not src: src = "/context/icons/logo/tactic_silver.png" opacity = 0.6 height = my.kwargs.get("height") width = my.kwargs.get("width") index = my.kwargs.get("index") if not height: height = "auto" if not width: width = "100%" width = "100%" height = "auto" #div = DivWdg() #top.add(div) div = top div.add_class("unselectable") div.add_style("opacity", opacity) div.add_style("overflow-x: hidden") div.add_style("overflow-y: hidden") div.add_style("margin-left: auto") div.add_style("margin-right: auto") div.add_style("text-align: center") if height: div.add_style("height", height) if width: div.add_style("width", width) parts = os.path.splitext(src) ext = parts[1] ext = ext.lower() click = my.kwargs.get("click") if click in [False, 'false']: click = False else: click = True thumb_path = my.kwargs.get("thumb_path") preload = my.kwargs.get("preload") if not preload: preload = "none" ext = ext.lstrip(".") if ext in File.IMAGE_EXT: embed = HtmlElement.img(src) embed.add_style("width: 100%") embed.add_style("height: auto") elif ext in File.VIDEO_EXT: from tactic.ui.widget import VideoWdg embed = DivWdg() if not thumb_path: thumb_path = "/context/icons/logo/tactic_sml.png" controls = my.kwargs.get("controls") if not controls: controls = "true" video_id = None sources = [src] source_types = ["video/mp4"] poster = thumb_path width = '100%' height = '100%' #width = "640" #height = "480" video = VideoWdg(video_id=video_id, sources=sources, source_types=source_types, poster=poster, preload=preload, controls=controls, width=width, height=height, index=index) embed.add(video) video.get_video().add_class("spt_resizable") click = False else: #embed = HtmlElement.embed(src) if thumb_path: img = HtmlElement.img(thumb_path) else: from pyasm.widget import ThumbWdg link = ThumbWdg.find_icon_link(src) img = HtmlElement.img(link) img.add_style("width: 50%") img.add_style("margin: 20px 20px") embed = DivWdg(img) div.add(embed) if click: embed.add_behavior( { 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' } ) embed.add_class("hand") #embed.add_style("width", "100%") # NOTE: to keep true original aspect ratio, don't set this height # and let GalleryWdg inner load script to take care of it on load # that js portion needs uncommenting as well #embed.add_style("height", "100%") #embed.set_box_shadow("1px 1px 1px 1px") return top
def get_display(my): top = my.top src = my.kwargs.get("src") file = my.kwargs.get("file") if file: src = file.get_web_path() opacity = 1.0 if not src: src = "/context/icons/logo/tactic_silver.png" opacity = 0.6 height = my.kwargs.get("height") width = my.kwargs.get("width") index = my.kwargs.get("index") if not height: height = "auto" if not width: width = "100%" width = "100%" height = "auto" #div = DivWdg() #top.add(div) div = top div.add_class("unselectable") div.add_style("opacity", opacity) div.add_style("overflow-x: hidden") div.add_style("overflow-y: hidden") div.add_style("margin-left: auto") div.add_style("margin-right: auto") div.add_style("text-align: center") if height: div.add_style("height", height) if width: div.add_style("width", width) parts = os.path.splitext(src) ext = parts[1] ext = ext.lower() click = my.kwargs.get("click") if click in [False, 'false']: click = False else: click = True thumb_path = my.kwargs.get("thumb_path") preload = my.kwargs.get("preload") if not preload: preload = "none" ext = ext.lstrip(".") if ext in File.IMAGE_EXT: embed = HtmlElement.img(src) embed.add_style("width: 100%") embed.add_style("height: auto") elif ext in File.VIDEO_EXT: from tactic.ui.widget import VideoWdg embed = DivWdg() if not thumb_path: thumb_path = "/context/icons/logo/tactic_sml.png" controls = my.kwargs.get("controls") if not controls: controls = "true" video_id = None sources = [src] source_types = ["video/mp4"] poster = thumb_path width = '100%' height = '100%' #width = "640" #height = "480" video = VideoWdg(video_id=video_id, sources=sources, source_types=source_types, poster=poster, preload=preload, controls=controls, width=width, height=height, index=index) embed.add(video) video.get_video().add_class("spt_resizable") click = False else: #embed = HtmlElement.embed(src) if thumb_path: img = HtmlElement.img(thumb_path) else: from pyasm.widget import ThumbWdg link = ThumbWdg.find_icon_link(src) img = HtmlElement.img(link) img.add_style("width: 50%") img.add_style("margin: 20px 20px") embed = DivWdg(img) div.add(embed) if click: embed.add_behavior({ 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' }) embed.add_class("hand") #embed.add_style("width", "100%") # NOTE: to keep true original aspect ratio, don't set this height # and let GalleryWdg inner load script to take care of it on load # that js portion needs uncommenting as well #embed.add_style("height", "100%") #embed.set_box_shadow("1px 1px 1px 1px") 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 find_icon_link(my, file_path, repo_path=None): from pyasm.widget import ThumbWdg return ThumbWdg.find_icon_link(file_path, repo_path)
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(my): my.init_kwargs() sobject = my.get_current_sobject() table = Table(css='minimal') table.add_color("color", "color") table.add_style("font-size: 0.9em") snapshots = my.get_snapshot(my.mode) for snapshot in snapshots: table.add_row() value = my.get_input_value(sobject, snapshot) current_version = snapshot.get_value("version") current_context = snapshot.get_value("context") current_revision = snapshot.get_value("revision", no_exception=True) current_snapshot_type = snapshot.get_value("snapshot_type") # hack hard coded type translation if current_snapshot_type == "anim_export": current_snapshot_type = "anim" # ignore icon context completely if current_context == "icon": table.add_blank_cell() table.add_cell("(---)") return table checkbox = CheckboxWdg('%s_%s' %(my.search_type, my.CB_NAME)) # this is added back in for now to work with 3.7 Fast table checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True}) checkbox.add_class('spt_latest_%s' %my.mode) checkbox.set_option("value", value ) table.add_cell( checkbox ) load_all = False if load_all: checkbox.set_checked() # add the file type icon xml = snapshot.get_snapshot_xml() file_name = xml.get_value("snapshot/file/@name") icon_link = ThumbWdg.find_icon_link(file_name) image = HtmlElement.img(icon_link) image.add_style("width: 15px") table.add_cell(image) namespace = my.get_namespace(sobject, snapshot) asset_code = my.get_asset_code() # force asset mode = True my.session.set_asset_mode(asset_mode=my.get_session_asset_mode()) node_name = my.get_node_name(snapshot, asset_code, namespace) # get session info session_context = session_version = session_revision = None if my.session: session_context = my.session.get_context(node_name, asset_code, current_snapshot_type) session_version = my.session.get_version(node_name, asset_code, current_snapshot_type) session_revision = my.session.get_revision(node_name, asset_code,current_snapshot_type) # Maya Specific: try with namespace in front of it for referencing referenced_name = '%s:%s' %(namespace, node_name) if not session_context or not session_version: session_context = my.session.get_context(referenced_name, asset_code, current_snapshot_type) session_version = my.session.get_version(referenced_name, asset_code, current_snapshot_type) session_revision = my.session.get_revision(referenced_name, asset_code, current_snapshot_type) from version_wdg import CurrentVersionContextWdg, SubRefWdg version_wdg = CurrentVersionContextWdg() data = {'session_version': session_version, \ 'session_context': session_context, \ 'session_revision': session_revision, \ 'current_context': current_context, \ 'current_version': current_version, \ 'current_revision': current_revision } version_wdg.set_options(data) table.add_cell(version_wdg, "no_wrap") td = table.add_cell(HtmlElement.b("(%s)" %current_context)) td.add_tip("Snapshot code: %s" % snapshot.get_code()) #table.add_cell(snapshot.get_code() ) #if snapshot.is_current(): # current = IconWdg("current", IconWdg.CURRENT) # table.add_cell(current) #else: # table.add_blank_cell() # handle subreferences has_subreferences = True xml = snapshot.get_xml_value("snapshot") refs = xml.get_nodes("snapshot/file/ref") if my.mode == "output" and refs: table.add_row() td = table.add_cell() swap = SwapDisplayWdg.get_triangle_wdg() td.add(swap) td.add("[ %s reference(s)" % len(refs)) #td.add_style("text-align: right") sub_ref_wdg = SubRefWdg() sub_ref_wdg.set_info(snapshot, my.session, namespace) swap.add_action_script( sub_ref_wdg.get_on_script(), "toggle_display('%s')" % sub_ref_wdg.get_top_id() ) status = sub_ref_wdg.get_overall_status() td.add(SpanWdg(VersionWdg.get(status), css='small_left')) td.add(']') td.add( sub_ref_wdg ) td.add_style('padding-left: 10px') #else: if not snapshots: table.add_row() table.add_blank_cell() table.add_cell("(---)") return table
def get_display(my): my.init_kwargs() sobject = my.get_current_sobject() table = Table(css='minimal') table.add_color("color", "color") table.add_style("font-size: 0.9em") snapshots = my.get_snapshot(my.mode) for snapshot in snapshots: table.add_row() value = my.get_input_value(sobject, snapshot) current_version = snapshot.get_value("version") current_context = snapshot.get_value("context") current_revision = snapshot.get_value("revision", no_exception=True) current_snapshot_type = snapshot.get_value("snapshot_type") # hack hard coded type translation if current_snapshot_type == "anim_export": current_snapshot_type = "anim" # ignore icon context completely if current_context == "icon": table.add_blank_cell() table.add_cell("(---)") return table checkbox = CheckboxWdg('%s_%s' % (my.search_type, my.CB_NAME)) # this is added back in for now to work with 3.7 Fast table checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True}) checkbox.add_class('spt_latest_%s' % my.mode) checkbox.set_option("value", value) table.add_cell(checkbox) load_all = False if load_all: checkbox.set_checked() # add the file type icon xml = snapshot.get_snapshot_xml() file_name = xml.get_value("snapshot/file/@name") icon_link = ThumbWdg.find_icon_link(file_name) image = HtmlElement.img(icon_link) image.add_style("width: 15px") table.add_cell(image) namespace = my.get_namespace(sobject, snapshot) asset_code = my.get_asset_code() # force asset mode = True my.session.set_asset_mode(asset_mode=my.get_session_asset_mode()) node_name = my.get_node_name(snapshot, asset_code, namespace) # get session info session_context = session_version = session_revision = None if my.session: session_context = my.session.get_context( node_name, asset_code, current_snapshot_type) session_version = my.session.get_version( node_name, asset_code, current_snapshot_type) session_revision = my.session.get_revision( node_name, asset_code, current_snapshot_type) # Maya Specific: try with namespace in front of it for referencing referenced_name = '%s:%s' % (namespace, node_name) if not session_context or not session_version: session_context = my.session.get_context( referenced_name, asset_code, current_snapshot_type) session_version = my.session.get_version( referenced_name, asset_code, current_snapshot_type) session_revision = my.session.get_revision( referenced_name, asset_code, current_snapshot_type) from version_wdg import CurrentVersionContextWdg, SubRefWdg version_wdg = CurrentVersionContextWdg() data = {'session_version': session_version, \ 'session_context': session_context, \ 'session_revision': session_revision, \ 'current_context': current_context, \ 'current_version': current_version, \ 'current_revision': current_revision } version_wdg.set_options(data) table.add_cell(version_wdg, "no_wrap") td = table.add_cell(HtmlElement.b("(%s)" % current_context)) td.add_tip("Snapshot code: %s" % snapshot.get_code()) #table.add_cell(snapshot.get_code() ) #if snapshot.is_current(): # current = IconWdg("current", IconWdg.CURRENT) # table.add_cell(current) #else: # table.add_blank_cell() # handle subreferences has_subreferences = True xml = snapshot.get_xml_value("snapshot") refs = xml.get_nodes("snapshot/file/ref") if my.mode == "output" and refs: table.add_row() td = table.add_cell() swap = SwapDisplayWdg.get_triangle_wdg() td.add(swap) td.add("[ %s reference(s)" % len(refs)) #td.add_style("text-align: right") sub_ref_wdg = SubRefWdg() sub_ref_wdg.set_info(snapshot, my.session, namespace) swap.add_action_script( sub_ref_wdg.get_on_script(), "toggle_display('%s')" % sub_ref_wdg.get_top_id()) status = sub_ref_wdg.get_overall_status() td.add(SpanWdg(VersionWdg.get(status), css='small_left')) td.add(']') td.add(sub_ref_wdg) td.add_style('padding-left: 10px') #else: if not snapshots: table.add_row() table.add_blank_cell() table.add_cell("(---)") return table
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_display(self): top = self.top layout = self.kwargs.get("layout") or "landscape" search_key = self.kwargs.get("search_key") file = self.kwargs.get("file") if search_key: sobject = Search.get_by_search_key(search_key) if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject else: snapshot = Snapshot.get_latest_by_sobject(sobject) src = snapshot.get_web_path_by_type() elif file: src = file.get_web_path() else: src = self.kwargs.get("src") opacity = 1.0 if not src: src = "/context/icons/logo/tactic_silver.png" opacity = 0.6 height = self.kwargs.get("height") width = self.kwargs.get("width") index = self.kwargs.get("index") if not height: height = "100%" if not width: width = "100%" # don't hard code width and height #width = "100%" #height = "auto" #div = DivWdg() #top.add(div) div = top div.add_class("unselectable") div.add_style("opacity", opacity) div.add_style("overflow-x: hidden") div.add_style("overflow-y: hidden") div.add_style("margin-left: auto") div.add_style("margin-right: auto") div.add_style("text-align: center") if height: div.add_style("height", height) if width: div.add_style("width", width) parts = os.path.splitext(src) ext = parts[1] ext = ext.lower() click = self.kwargs.get("click") if click in [False, 'false']: click = False else: click = True thumb_path = self.kwargs.get("thumb_path") preload = self.kwargs.get("preload") if not preload: preload = "none" ext = ext.lstrip(".") if ext in File.IMAGE_EXT: embed = DivWdg() embed.add_style("display: inline-block") embed.add_style("vertical-align: top") if layout == "landscape": embed.add_style("width: auto") embed.add_style("height: 100%") else: embed.add_style("width: 100%") embed.add_style("height: auto") if src.find("#") != -1: file_range = self.kwargs.get("file_range") for i in range(1, 16): expand = src.replace("####", "%0.4d" % i) item = HtmlElement.img(expand) embed.add(item) item.add_style("width: 25%") embed.add_style("overflow-y: auto") embed.add_style("text-align: left") #embed.add_behavior( { # 'type': 'load', # 'cbjs_action': ''' # new Scrollable(bvr.src_el) # ''' #} ) elif src.find("|") != -1: paths = src.split("|") for path in paths: item = HtmlElement.img(path) embed.add(item) item.add_style("width: 25%") embed.add_style("overflow-y: auto") embed.add_style("text-align: left") else: if isinstance(src, unicode): src = src.encode("utf-8") src = urllib.pathname2url(src) img = HtmlElement.img(src) embed.add(img) if layout == "landscape": img.add_style("width: auto") img.add_style("height: 100%") else: img.add_style("width: 100%") img.add_style("height: auto") elif ext in File.VIDEO_EXT: from tactic.ui.widget import VideoWdg embed = DivWdg() #if not thumb_path: # thumb_path = "/context/icons/logo/tactic_sml.png" controls = self.kwargs.get("controls") video_id = None sources = [src] source_types = ["video/mp4"] poster = thumb_path width = '100%' height = '100%' #width = "640" #height = "480" video = VideoWdg(video_id=video_id, sources=sources, source_types=source_types, poster=poster, preload=preload, controls=controls, width=width, height=height, index=index) embed.add(video) video.get_video().add_class("spt_resizable") click = False else: #embed = HtmlElement.embed(src) if thumb_path: img = HtmlElement.img(thumb_path) else: from pyasm.widget import ThumbWdg link = ThumbWdg.find_icon_link(src) img = HtmlElement.img(link) img.add_style("width: 50%") img.add_style("margin: 20px 20px") embed = DivWdg(img) div.add(embed) if click: embed.add_behavior( { 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' } ) embed.add_class("hand") return top