def get_info_wdg(my): div = DivWdg() div.set_name("Info") div.add_style("padding: 20px") table = Table() div.add(table) table.add_color("color", "color") #table.add_style("height: 280px") table.set_unique_id() table.add_smart_style("spt_table_header", "width", "200px") table.add_smart_style("spt_table_header", "text-align", "right") table.add_smart_style("spt_table_header", "padding-right", "20px") table.add_smart_style("spt_table_header", "margin-bottom", "10px") table.add_smart_style("spt_table_element", "vertical-align", "top") table.add_row() #if my.mode == 'insert': # read_only = False #else: # read_only = True read_only = False code = Config.get_value("install", "server") or "" td = table.add_cell() td.add_class("spt_table_header") td.add("Code: ") td.add_style("vertical-align: top") text = TextInputWdg(name="code", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(code) return div
def get_info_wdg(self): div = DivWdg() div.set_name("Info") div.add_style("padding: 20px") table = Table() div.add(table) table.add_color("color", "color") #table.add_style("height: 280px") table.set_unique_id() table.add_smart_style("spt_table_header", "width", "200px") table.add_smart_style("spt_table_header", "text-align", "right") table.add_smart_style("spt_table_header", "padding-right", "20px") table.add_smart_style("spt_table_header", "margin-bottom", "10px") table.add_smart_style("spt_table_element", "vertical-align", "top") table.add_row() #if self.mode == 'insert': # read_only = False #else: # read_only = True read_only = False code = Config.get_value("install", "server") or "" td = table.add_cell() td.add_class("spt_table_header") td.add("Code: ") td.add_style("vertical-align: top") text = TextInputWdg(name="code", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(code) return div
def get_display(my): search_key = my.kwargs.get("search_key") snapshot = my.kwargs.get("snapshot") if snapshot: my.snapshot = snapshot else: my.snapshot = SearchKey.get_by_search_key(search_key) assert my.snapshot metadata = my.snapshot.get_metadata() top = my.top top.add_color("background", "background") table = Table() table.set_max_width() top.add(table) table.set_unique_id() table.add_border() table.add_smart_styles("spt_cell", { 'padding': '3px' } ) tr = table.add_row() tr.add_gradient("background", "background3") th = table.add_header("Property") th.add_style("min-width: 200px") th.add_style("padding: 5px") th = table.add_header("Value") th.add_style("min-width: 400px") th.add_style("padding: 5px") keys = metadata.get("__keys__") if not keys: keys = metadata.keys() empty = False if not keys: empty = True keys = ['','','','','','',''] table.add_smart_styles("spt_cell", { 'height': '20px' } ) for i, key in enumerate(keys): value = metadata.get(key) title = Common.get_display_title(key) tr = table.add_row() if i % 2: tr.add_color("background", "background") tr.add_color("color", "color") else: tr.add_color("background", "background", -8) tr.add_color("color", "color") td = table.add_cell() td.add_class("spt_cell") td.add(title) td = table.add_cell() td.add_class("spt_cell") td.add(value) if empty: div = DivWdg() top.add(div) div.add_style("height: 30px") div.add_style("width: 150px") div.add_style("margin-top: -110px") div.center() div.add("<b>No Metadata</b>") div.add_border() div.add_color("background", "background3") div.add_color("color", "color3") div.add_style("padding: 20px") div.add_style("text-align: center") top.add_style("min-height: 200px") return top
def get_display(my): search_key = my.kwargs.get("search_key") path = my.kwargs.get("path") parser_str = my.kwargs.get("parser") use_tactic_tags = my.kwargs.get("use_tactic_tags") from pyasm.checkin import PILMetadataParser, ImageMagickMetadataParser, ExifMetadataParser, BaseMetadataParser if parser_str: parser = BaseMetadataParser.get_parser(parser_str, path) else: parser = BaseMetadataParser.get_parser_by_path(path) if parser: if use_tactic_tags in ['true', True]: metadata = parser.get_tactic_metadata() else: metadata = parser.get_metadata() else: metadata = {} top = my.top top.add_color("background", "background") table = Table() table.set_max_width() top.add(table) table.set_unique_id() table.add_border() table.add_smart_styles("spt_cell", { 'padding': '3px' } ) tr = table.add_row() tr.add_gradient("background", "background3") th = table.add_header("Property") th.add_style("min-width: 200px") th.add_style("padding: 5px") th = table.add_header("Value") th.add_style("min-width: 400px") th.add_style("padding: 5px") keys = metadata.get("__keys__") if not keys: keys = metadata.keys() empty = False if not keys: empty = True keys = ['','','','','','',''] table.add_smart_styles("spt_cell", { 'height': '20px' } ) for i, key in enumerate(keys): value = metadata.get(key) title = Common.get_display_title(key) tr = table.add_row() if i % 2: tr.add_color("background", "background") tr.add_color("color", "color") else: tr.add_color("background", "background", -8) tr.add_color("color", "color") td = table.add_cell() td.add_class("spt_cell") td.add(title) td = table.add_cell() td.add_class("spt_cell") if len(str(value)) > 500: inside = DivWdg() td.add(inside) value = value[:500] inside.add(value) inside.add_style("max-width: 600px") else: td.add(value) if empty: div = DivWdg() top.add(div) div.add_style("height: 30px") div.add_style("width: 150px") div.add_style("margin-top: -110px") div.center() div.add("<b>No Metadata</b>") div.add_border() div.add_color("background", "background3") div.add_color("color", "color3") div.add_style("padding: 20px") div.add_style("text-align: center") top.add_style("min-height: 200px") return top
def get_display(self): search_key = self.kwargs.get("search_key") snapshot = self.kwargs.get("snapshot") if snapshot: self.snapshot = snapshot else: self.snapshot = SearchKey.get_by_search_key(search_key) assert self.snapshot metadata = self.snapshot.get_metadata() top = self.top top.add_color("background", "background") table = Table() table.set_max_width() top.add(table) table.set_unique_id() table.add_border() table.add_smart_styles("spt_cell", {'padding': '3px'}) tr = table.add_row() tr.add_color("background", "background", -5) th = table.add_header("Property") th.add_style("min-width: 200px") th.add_style("padding: 5px") th = table.add_header("Value") th.add_style("min-width: 400px") th.add_style("padding: 5px") keys = metadata.get("__keys__") if not keys: keys = metadata.keys() empty = False if not keys: empty = True keys = ['', '', '', '', '', '', ''] table.add_smart_styles("spt_cell", {'height': '20px'}) for i, key in enumerate(keys): value = metadata.get(key) title = Common.get_display_title(key) tr = table.add_row() if i % 2: tr.add_color("background", "background") tr.add_color("color", "color") else: tr.add_color("background", "background", -8) tr.add_color("color", "color") td = table.add_cell() td.add_class("spt_cell") td.add(title) td = table.add_cell() td.add_class("spt_cell") td.add(value) if empty: div = DivWdg() top.add(div) div.add_style("height: 30px") div.add_style("width: 150px") div.add_style("margin-top: -110px") div.center() div.add("<b>No Metadata</b>") div.add_border() div.add_color("background", "background3") div.add_color("color", "color3") div.add_style("padding: 20px") div.add_style("text-align: center") top.add_style("min-height: 200px") return top
def get_display(self): search_key = self.kwargs.get("search_key") path = self.kwargs.get("path") parser_str = self.kwargs.get("parser") use_tactic_tags = self.kwargs.get("use_tactic_tags") from pyasm.checkin import BaseMetadataParser #parser_str = "EXIF" if parser_str: parser = BaseMetadataParser.get_parser(parser_str, path) else: parser = BaseMetadataParser.get_parser_by_path(path) if parser: if use_tactic_tags in ['true', True]: metadata = parser.get_tactic_metadata() else: metadata = parser.get_metadata() else: metadata = {} parser_title = parser.get_title() top = self.top top.add_color("background", "background") top.add_class("spt_metadata_top") shelf = DivWdg() top.add(shelf) from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Add Selected to Keywords", width="200") shelf.add(button) shelf.add_style("margin: 10px 0px") button.add_behavior({ 'search_key': search_key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_metadata_top"); var values = spt.api.get_input_values(top, null, true); var searchables = values.searchable; var items = []; for (var i = 0; i < searchables.length; i++) { if (searchables[i] == "") { continue; } items.push(searchables[i]); } var server = TacticServerStub.get(); var class_name = 'spt.modules.workflow.AssetAddMetadataToKeywordsCmd'; var kwargs = { search_key: bvr.search_key, items: items, }; server.p_execute_cmd(class_name, kwargs) .then( function() { spt.api.clear_inputs(top); spt.notify.show_message("Added Keywords"); } ) ''' }) table = Table() table.add_style("width: 100%") #table.add_style("table-layout: fixed") top.add(table) table.set_unique_id() table.add_smart_styles("spt_cell", {'padding': '3px'}) tr, td = table.add_row_cell() td.add(parser_title) td.add_style("height: 20px") td.add_style("font-weight: bold") td.add_style("padding: 5px 3px") td.add_color("background", "background", -5) border_color = td.get_color("border") td.add_color("border-bottom", "solid 1px %s" % border_color) tr.add_class("tactic_hover") """ tr = table.add_row() tr.add_color("background", "background", -5) th = table.add_header("Property") th.add_style("min-width: 200px") th.add_style("padding: 5px") th = table.add_header("Value") #th.add_style("min-width: 400px") th.add_style("padding: 5px") """ keys = metadata.get("__keys__") if not keys: keys = metadata.keys() empty = False if not keys: empty = True keys = ['', '', '', '', '', '', ''] table.add_smart_styles("spt_cell", {'height': '20px'}) keys.sort() for i, key in enumerate(keys): value = metadata.get(key) value = Common.process_unicode_string(value) if not isinstance(key, basestring): key = str(key) #title = Common.get_display_title(key) title = key tr = table.add_row() tr.add_class("tactic_hover") if i % 2: tr.add_color("background", "background", -2) tr.add_color("color", "color") else: tr.add_color("background", "background") tr.add_color("color", "color") td = table.add_cell() td.add_class("spt_cell") td.add(title) td.add_style("width: 300px") td.add_style("min-width: 200px") td = table.add_cell() td.add_class("spt_cell") if len(str(value)) > 500: inside = DivWdg() td.add(inside) value = value[:500] inside.add(value) inside.add_style("max-width: 600px") else: td.add(value) td.add_style("max-width: 600px") td.add_style("overflow: hidden") td.add_style("text-overflow: ellipsis") td.add_style("white-space: nowrap") td = table.add_cell() td.add_class("spt_cell") try: is_ascii = True for c in str(value): if ord(c) > 128: is_ascii = False break if not is_ascii: continue except Exception as e: print("WARNING: ", e) continue from pyasm.widget import CheckboxWdg checkbox = CheckboxWdg("searchable") checkbox.add_attr("spt_is_multiple", "true") td.add(checkbox) td.add_style("width: 40px") td.add_style("max-width: 30px") checkbox.set_option("value", "%s|%s|%s" % (parser_title, key, value)) if empty: div = DivWdg() top.add(div) div.add_style("height: 30px") div.add_style("width: 150px") div.add_style("margin-top: -110px") div.center() div.add("<b>No Metadata</b>") div.add_border() div.add_color("background", "background3") div.add_color("color", "color3") div.add_style("padding: 20px") div.add_style("text-align: center") top.add_style("min-height: 200px") return top
def get_info_wdg(my): div = DivWdg() div.set_name("Info") div.add_style("padding: 20px") table = Table() div.add(table) table.add_color("color", "color") #table.add_style("height: 280px") table.set_unique_id() table.add_smart_style("spt_table_header", "width", "200px") table.add_smart_style("spt_table_header", "text-align", "right") table.add_smart_style("spt_table_header", "padding-right", "20px") table.add_smart_style("spt_table_header", "margin-bottom", "10px") table.add_smart_style("spt_table_element", "vertical-align", "top") #if my.mode == 'insert': # read_only = False #else: # read_only = True read_only = False code = my.server.get_code() or "" description = my.server.get_value("description") or "" table.add_row() td = table.add_cell() td.add_class("spt_table_header") td.add("Code: ") td.add_style("vertical-align: top") text = TextInputWdg(name="code", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(code) table.add_row() td = table.add_cell() td.add_class("spt_table_header") td.add("Description: ") td.add_style("vertical-align: top") text = TextAreaWdg(name="description", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(description) table.add_row() td = table.add_cell() td.add_class("spt_table_header") td.add("Base Directory: ") td.add_style("vertical-align: top") text = TextInputWdg(name="base_dir", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(my.base_dir) return div
def get_display(my): search_key = my.kwargs.get("search_key") path = my.kwargs.get("path") parser_str = my.kwargs.get("parser") use_tactic_tags = my.kwargs.get("use_tactic_tags") from pyasm.checkin import PILMetadataParser, ImageMagickMetadataParser, ExifMetadataParser, BaseMetadataParser if parser_str: parser = BaseMetadataParser.get_parser(parser_str, path) else: parser = BaseMetadataParser.get_parser_by_path(path) if parser: if use_tactic_tags in ['true', True]: metadata = parser.get_tactic_metadata() else: metadata = parser.get_metadata() else: metadata = {} top = my.top top.add_color("background", "background") table = Table() table.set_max_width() top.add(table) table.set_unique_id() table.add_border() table.add_smart_styles("spt_cell", {'padding': '3px'}) tr = table.add_row() tr.add_gradient("background", "background3") th = table.add_header("Property") th.add_style("min-width: 200px") th.add_style("padding: 5px") th = table.add_header("Value") th.add_style("min-width: 400px") th.add_style("padding: 5px") keys = metadata.get("__keys__") if not keys: keys = metadata.keys() empty = False if not keys: empty = True keys = ['', '', '', '', '', '', ''] table.add_smart_styles("spt_cell", {'height': '20px'}) for i, key in enumerate(keys): value = metadata.get(key) title = Common.get_display_title(key) tr = table.add_row() if i % 2: tr.add_color("background", "background") tr.add_color("color", "color") else: tr.add_color("background", "background", -8) tr.add_color("color", "color") td = table.add_cell() td.add_class("spt_cell") td.add(title) td = table.add_cell() td.add_class("spt_cell") if len(str(value)) > 500: inside = DivWdg() td.add(inside) value = value[:500] inside.add(value) inside.add_style("max-width: 600px") else: td.add(value) if empty: div = DivWdg() top.add(div) div.add_style("height: 30px") div.add_style("width: 150px") div.add_style("margin-top: -110px") div.center() div.add("<b>No Metadata</b>") div.add_border() div.add_color("background", "background3") div.add_color("color", "color3") div.add_style("padding: 20px") div.add_style("text-align: center") top.add_style("min-height: 200px") return top
def get_display(self): search_key = self.kwargs.get("search_key") path = self.kwargs.get("path") parser_str = self.kwargs.get("parser") use_tactic_tags = self.kwargs.get("use_tactic_tags") from pyasm.checkin import BaseMetadataParser #parser_str = "EXIF" if parser_str: parser = BaseMetadataParser.get_parser(parser_str, path) else: parser = BaseMetadataParser.get_parser_by_path(path) if parser: if use_tactic_tags in ['true', True]: metadata = parser.get_tactic_metadata() else: metadata = parser.get_metadata() else: metadata = {} parser_title = parser.get_title() top = self.top top.add_color("background", "background") top.add_class("spt_metadata_top") shelf = DivWdg() top.add(shelf) from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Add Selected to Keywords", width="200") shelf.add(button) shelf.add_style("margin: 10px 0px") button.add_behavior( { 'search_key': search_key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_metadata_top"); var values = spt.api.get_input_values(top, null, true); var searchables = values.searchable; var items = []; for (var i = 0; i < searchables.length; i++) { if (searchables[i] == "") { continue; } items.push(searchables[i]); } var server = TacticServerStub.get(); var class_name = 'spt.modules.workflow.AssetAddMetadataToKeywordsCmd'; var kwargs = { search_key: bvr.search_key, items: items, }; server.p_execute_cmd(class_name, kwargs) .then( function() { spt.api.clear_inputs(top); spt.notify.show_message("Added Keywords"); } ) ''' } ) table = Table() table.add_style("width: 100%") #table.add_style("table-layout: fixed") top.add(table) table.set_unique_id() table.add_smart_styles("spt_cell", { 'padding': '3px' } ) tr, td = table.add_row_cell() td.add(parser_title) td.add_style("height: 20px") td.add_style("font-weight: bold") td.add_style("padding: 5px 3px") td.add_color("background", "background", -5) border_color = td.get_color("border") td.add_color("border-bottom", "solid 1px %s" % border_color) tr.add_class("tactic_hover") """ tr = table.add_row() tr.add_color("background", "background", -5) th = table.add_header("Property") th.add_style("min-width: 200px") th.add_style("padding: 5px") th = table.add_header("Value") #th.add_style("min-width: 400px") th.add_style("padding: 5px") """ keys = metadata.get("__keys__") if not keys: keys = metadata.keys() empty = False if not keys: empty = True keys = ['','','','','','',''] table.add_smart_styles("spt_cell", { 'height': '20px' } ) keys.sort() for i, key in enumerate(keys): value = metadata.get(key) value = Common.process_unicode_string(value) if not isinstance(key, basestring): key = str(key) #title = Common.get_display_title(key) title = key tr = table.add_row() tr.add_class("tactic_hover") if i % 2: tr.add_color("background", "background", -2) tr.add_color("color", "color") else: tr.add_color("background", "background") tr.add_color("color", "color") td = table.add_cell() td.add_class("spt_cell") td.add(title) td.add_style("width: 300px") td.add_style("min-width: 200px") td = table.add_cell() td.add_class("spt_cell") if len(str(value)) > 500: inside = DivWdg() td.add(inside) value = value[:500] inside.add(value) inside.add_style("max-width: 600px") else: td.add(value) td.add_style("max-width: 600px") td.add_style("overflow: hidden") td.add_style("text-overflow: ellipsis") td.add_style("white-space: nowrap") td = table.add_cell() td.add_class("spt_cell") try: is_ascii = True for c in str(value): if ord(c) > 128: is_ascii = False break if not is_ascii: continue except Exception as e: print("WARNING: ", e) continue from pyasm.widget import CheckboxWdg checkbox = CheckboxWdg("searchable") checkbox.add_attr("spt_is_multiple", "true") td.add(checkbox) td.add_style("width: 40px") td.add_style("max-width: 30px") checkbox.set_option("value", "%s|%s|%s" % (parser_title,key,value)) if empty: div = DivWdg() top.add(div) div.add_style("height: 30px") div.add_style("width: 150px") div.add_style("margin-top: -110px") div.center() div.add("<b>No Metadata</b>") div.add_border() div.add_color("background", "background3") div.add_color("color", "color3") div.add_style("padding: 20px") div.add_style("text-align: center") top.add_style("min-height: 200px") return top