def get_text_value(self): '''for csv export''' self.sobject = self.get_current_sobject() #self.init_kwargs() if not self.expression and not self.alt_expression: return super(ExpressionElementWdg, self).get_display() if self.alt_expression: result = self._get_result(self.sobject, self.alt_expression) else: result = self._get_result(self.sobject, self.expression) if isinstance(result, list): delimiter = ',' result = delimiter.join(result) format_str = self.kwargs.get("display_format") if format_str: format_val = FormatValue() format_value = format_val.get_format_value(result, format_str) result = format_value name = self.get_name() self.sobject.set_value(name, result) return result
def get_display(my): top = my.top sobjects = my.sobjects sobject = my.get_current_sobject() index = my.get_current_index() column = my.get_option("column") sobject = my.get_current_sobject() sobj_value = sobject.get_value(column) if sobj_value: my.total += sobj_value format_str = my.get_option('format') if format_str: format = FormatValue() #display = format.get_format_value(value, "$#,###.##") display = format.get_format_value(my.total, format_str) else: display = my.total value_div = DivWdg() top.add(value_div) value_div.add_style("float: right") value_div.add(display) name = my.get_name() sobject.set_value(name, my.total) #sobject.commit() return top
def get_display(self): top = self.top sobjects = self.sobjects sobject = self.get_current_sobject() index = self.get_current_index() column = self.get_option("column") sobject = self.get_current_sobject() sobj_value = sobject.get_value(column) if sobj_value: self.total += sobj_value format_str = self.get_option('format') if format_str: format = FormatValue() #display = format.get_format_value(value, "$#,###.##") display = format.get_format_value(self.total, format_str) else: display = self.total value_div = DivWdg() top.add(value_div) value_div.add_style("float: right") value_div.add(display) name = self.get_name() sobject.set_value(name, self.total) #sobject.commit() return top
def get_text_value(self): '''for csv export''' self.sobject = self.get_current_sobject() #self.init_kwargs() if not self.expression and not self.alt_expression: return super(ExpressionElementWdg, self).get_display() if self.alt_expression: result = self._get_result(self.sobject, self.alt_expression) else: result = self._get_result(self.sobject, self.expression) if isinstance(result, list): delimiter = ',' result = delimiter.join(result) format_str = self.kwargs.get("display_format") if format_str: format_val = FormatValue() format_value = format_val.get_format_value( result, format_str ) result = format_value name = self.get_name() self.sobject.set_value(name, result) return result
def get_display(my): top = DivWdg() format_str = my.kwargs.get('format') value = my.kwargs.get('value') format = FormatValue() display_value = format.get_format_value(value, format_str) widget = my.get_format_wdg(value, format_str, display_value) top.add(widget) return top
def get_display(self): top = DivWdg() format_str = self.kwargs.get('format') value = self.kwargs.get('value') format = FormatValue() display_value = format.get_format_value( value, format_str ) widget = self.get_format_wdg(value, format_str, display_value) top.add(widget) return top
def get_text_value(my): """for csv export""" my.sobject = my.get_current_sobject() my.init_kwargs() if not my.expression and not my.alt_expression: return super(ExpressionElementWdg, my).get_display() if my.alt_expression: result = my._get_result(my.sobject, my.alt_expression) else: result = my._get_result(my.sobject, my.expression) format_str = my.kwargs.get("display_format") if format_str: format_val = FormatValue() format_value = format_val.get_format_value(result, format_str) result = format_value return result
def get_text_value(my): '''for csv export''' my.sobject = my.get_current_sobject() my.init_kwargs() if not my.expression and not my.alt_expression: return super(ExpressionElementWdg, my).get_display() if my.alt_expression: result = my._get_result(my.sobject, my.alt_expression) else: result = my._get_result(my.sobject, my.expression) format_str = my.kwargs.get("display_format") if format_str: format_val = FormatValue() format_value = format_val.get_format_value(result, format_str) result = format_value name = my.get_name() my.sobject.set_value(name, result) return result
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 handle_item_div(my, item_div, dirname, basename): table = Table() item_div.add(table) table.add_row() table.add_style("width: 100%") icon_string = my.get_file_icon(dirname, basename) icon_div = DivWdg() td = table.add_cell(icon_div) td.add_style("width: 15px") icon = IconWdg("%s/%s" % (dirname, basename), icon_string) icon_div.add(icon) icon_div.add_style("float: left") icon_div.add_style("margin-top: -1px") path = "%s/%s" % (dirname, basename) status = my.path_info.get(path) margin_left = -16 if status == 'same': check = IconWdg("No Changes", IconWdg.CHECK, width=12) elif status == 'added': check = IconWdg("Added", IconWdg.NEW, width=16) margin_left = -18 elif status == 'unversioned': check = IconWdg("Unversioned", IconWdg.HELP, width=12) elif status == 'missing': check = IconWdg("Missing", IconWdg.WARNING, width=12) elif status == 'editable': check = IconWdg("Editable", IconWdg.EDIT, width=12) elif status == 'modified': check = IconWdg("Modified", IconWdg.WARNING, width=12) else: check = IconWdg("Error (unknown status)", IconWdg.ERROR, width=12) if check: td = table.add_cell(check) td.add_style("width: 3px") check.add_style("float: left") check.add_style("margin-left: %spx" % margin_left) check.add_style("margin-top: 4px") item_div.add_color("color", "color", [0, 0, 50]) if status == 'missing': item_div.add_style("opacity: 0.3") else: item_div.add_style("opacity: 0.8") name_div = DivWdg() td = table.add_cell(name_div) name_div.add(basename) name_div.add_style("float: left") if status != "same": name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" % status) spath = path.replace(" ", "_") # add the size of the file size_div = DivWdg() td = table.add_cell(size_div) td.add_style("width: 60px") size = my.sizes.get(spath) if size is None or size == -1: size_div.add("-") else: size_div.add(FormatValue().get_format_value(size, 'KB')) size_div.add_style("margin-right: 5px") size_div.add_style('text-align: right') # FIXME: this still is needed right now, although really used. my.subcontext_options = [] if not my.subcontext_options: subcontext = TextWdg("subcontext") subcontext = HiddenWdg("subcontext") subcontext.add_class("spt_subcontext") subcontext.add_style("float: right") else: subcontext = SelectWdg("subcontext") subcontext = HiddenWdg("subcontext") subcontext.set_option("show_missing", False) subcontext.set_option("values", my.subcontext_options) subcontext.add_empty_option("----") subcontext.add_behavior({ 'type': 'click_up', 'propagate_evt': False, 'cbjs_action': ''' bvr.src_el.focus(); ''' }) subcontext.add_style("display: none") item_div.add(subcontext)
def handle_item_div(self, item_div, dirname, basename): path = "%s/%s" % (dirname, basename) if self.info.get("file_type") == 'missing': icon_string = IconWdg.DELETE tip = 'Missing [%s]' % path else: icon_string = self.get_file_icon(dirname, basename) tip = path icon_div = DivWdg() item_div.add(icon_div) icon = IconWdg(tip, icon_string) icon_div.add(icon) icon_div.add_style("float: left") icon_div.add_style("margin-top: -1px") self.handle_dir_or_item(item_div, dirname, basename) size_div = DivWdg() size_div.add(FormatValue().get_format_value(self.sizes.get(path), 'KB')) size_div.add_style("float: left") item_div.add(size_div) #size_div.add_style("margin-right: 30px") size_div.add_style("width: 60px") size_div.add_style('text-align: right') #icon_div = DivWdg() #item_div.add(icon_div) #icon = IconWdg("Delvered to next process", IconWdg.JUMP) #icon_div.add(icon) #icon_div.add_style("float: right") #icon_div.add_style("margin-top: -1px") depend_wdg = DivWdg() #item_div.add(depend_wdg) depend_wdg.add_style("height: 12px") depend_wdg.add_style("float: left") depend_wdg.add_style("overflow: hidden") file_obj = self.checked_in_paths.get(path) if file_obj: snapshot = file_obj.get_parent() depend_wdg.add_attr("spt_snapshot_key", snapshot.get_search_key()) item_div.add(depend_wdg) if self.sobject: search_key = self.sobject.get_search_key() depend_wdg.add_attr("spt_search_key", search_key) depend_button = IconWdg("Dependency", IconWdg.CONNECT, width=12) #depend_wdg.add(depend_button) depend_wdg.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var search_key = bvr.src_el.getAttribute("spt_search_key"); var snapshot_key = bvr.src_el.getAttribute("spt_snapshot_key"); var top = bvr.src_el.getParent(".spt_dir_list_item"); var depend_keys = top.getAttribute("spt_depend_keys"); var class_name = 'tactic.ui.checkin.CheckinDependencyWdg'; var kwargs = { search_key: search_key, snapshot_key: snapshot_key, depend_keys: depend_keys }; //var popup = spt.panel.load_popup("Dependencies", class_name, kwargs); //popup.activator = top; spt.tab.set_tab_top_from_child(bvr.src_el); var header = spt.tab.add_new("Dependency", "Dependency", class_name, kwargs); var content = spt.tab.get_content("Dependency"); content.setStyle("border", "solid 1px red"); top.setStyle("border", "solid 1px blue"); content.activator = top; ''' }) item_div.add("<br clear='all'/>")
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 handle_item_div(self, item_div, dirname, basename): path = "%s/%s" % (dirname, basename) if self.info.get("file_type") == 'missing': icon_string = IconWdg.DELETE tip = 'Missing [%s]' % path else: icon_string = self.get_file_icon(dirname, basename) tip = path icon_div = DivWdg() item_div.add(icon_div) icon = IconWdg(tip, icon_string) icon_div.add(icon) icon_div.add_style("float: left") icon_div.add_style("margin-top: -1px") # add the file name filename_div = DivWdg() item_div.add(filename_div) filename_div.add_style("float: left") filename_div.add_style("overflow: hidden") snapshot = self.snapshots.get(path) file_type = self.info.get('file_type') if file_type == 'sequence': if snapshot: file_range = snapshot.get_file_range() start_frame = file_range.get_frame_start() end_frame = file_range.get_frame_end() basename = re.sub(re.compile("#+"), "(%s-%s)" % (start_frame, end_frame), basename) #file_names = snapshot.get_expanded_file_names() filename_div.add(basename) else: filename_div.add(basename) else: filename_div.add(basename) if snapshot: snapshot_div = DivWdg() item_div.add(snapshot_div) snapshot_div.add_style("float: left") snapshot_div.add_style("font-style: italic") snapshot_div.add_style("opacity: 0.5") process = snapshot.get_value("process") version = snapshot.get_value("version") if version == 0: version = 'current' elif version == -1: version = 'lastest' else: version = 'v%s' % version snapshot_div.add(" (%s %s)" % (version, process)) #size = snapshot.get_value("st_size") # Right now, the size is taken from the file system, however, # should we be reporting the database size? size = self.info.get('size') if not size: size = 0 from pyasm.common import FormatValue size = FormatValue().get_format_value(size, 'KB') filesize_div = DivWdg() item_div.add(filesize_div) filesize_div.add(size) #filesize_div.add_style("width: 200px") filesize_div.add_style("text-align: right")