def get_instructions_textarea_wdg(instructions_sobject, width=600, height=600): """ Given an instructions sobject, get a TextArea widget to hold all of its text. Optionally, pass in the width and height of the TextArea widget. :param instructions_sobject: twog/instructions sobject :param width: int :param height: int :return: DivWdg (holding the TextArea widget) """ instructions_div = DivWdg() instructions_div.add_style('margin', '10px') instructions_textarea_wdg = TextAreaWdg() instructions_textarea_wdg.set_id('instructions_textarea') instructions_textarea_wdg.set_name('instructions_textarea') instructions_textarea_wdg.add_style('width', '{0}px'.format(width)) instructions_textarea_wdg.add_style('height', '{0}px'.format(height)) instructions_text = instructions_sobject.get('instructions_text') instructions_textarea_wdg.set_value(instructions_text) instructions_div.add(instructions_textarea_wdg) return instructions_div
def get_display(my): top = DivWdg() text = TextAreaWdg() text.add_style("width: 98%") text.add_style("height: 90%") top.add(text) return top
def get_display(my): my.run_init() name = my.get_name() if not name: name = my.kwargs.get("name") if my.is_refresh: widget = Widget() else: widget = DivWdg() my.set_as_panel(widget) widget.add_class("spt_note_top") widget.set_attr("spt_name", name) widget.set_attr("spt_parent_key", my.parent_key) web = WebContainer.get_web() value = web.get_form_value(name) text = TextAreaWdg(name) widget.add(text) if value: text.set_value(value) text.add_style("width: 100%") text.add_style("min-width: 200") text.add_attr("rows", "5") text.add_class('spt_note_text') color = text.get_color("background", -10) text.add_behavior({ 'type': 'blur', 'cbjs_action': ''' //spt.dg_table._toggle_commit_btn($(this), false); var el = bvr.src_el; var td = el.getParent(".spt_table_td"); var tbody = el.getParent(".spt_table_tbody"); td.setStyle('background-color','#909977'); td.addClass('spt_value_changed'); tbody.addClass('spt_value_changed'); td.setAttribute('spt_input_value', el.value); ''' }) #text.add_event("onblur", "spt.dg_table._toggle_commit_btn($(this), false);$(this).getParent('.spt_table_td').setStyle('background-color','#030');$(this).getParent('.spt_table_td').addClass('spt_value_changed');$(this).getParent('.spt_table_tbody').addClass('spt_value_changed');$(this).getParent('.spt_table_td').setAttribute('spt_input_value',this.value)") #text.add_event("onclick", "spt.dg_table.edit_cell_cbk( this, spt.kbd.special_keys_map.ENTER)" ); #behavior = { # 'type': 'keyboard', # 'kbd_handler_name': 'DgTableMultiLineTextEdit' #} #text.add_behavior(behavior) action_wdg = my.get_action_wdg(name) widget.add(action_wdg) return widget
def get_display(self): self.run_init() name = self.get_name() if not name: name = self.kwargs.get("name") if self.is_refresh: widget = Widget() else: widget = DivWdg() self.set_as_panel(widget) widget.add_class("spt_note_top") widget.set_attr("spt_name", name) widget.set_attr("spt_parent_key", self.parent_key) web = WebContainer.get_web() value = web.get_form_value(name) text = TextAreaWdg(name) widget.add(text) if value: text.set_value(value) text.add_style("width: 100%") text.add_style("min-width: 200") text.add_attr("rows", "5") text.add_class('spt_note_text') color = text.get_color("background", -10); text.add_behavior( { 'type': 'blur', 'cbjs_action': ''' //spt.dg_table._toggle_commit_btn($(this), false); var el = bvr.src_el; var td = el.getParent(".spt_table_td"); var tbody = el.getParent(".spt_table_tbody"); td.setStyle('background-color','#909977'); td.addClass('spt_value_changed'); tbody.addClass('spt_value_changed'); td.setAttribute('spt_input_value', el.value); ''' } ) #text.add_event("onblur", "spt.dg_table._toggle_commit_btn($(this), false);$(this).getParent('.spt_table_td').setStyle('background-color','#030');$(this).getParent('.spt_table_td').addClass('spt_value_changed');$(this).getParent('.spt_table_tbody').addClass('spt_value_changed');$(this).getParent('.spt_table_td').setAttribute('spt_input_value',this.value)") #text.add_event("onclick", "spt.dg_table.edit_cell_cbk( this, spt.kbd.special_keys_map.ENTER)" ); #behavior = { # 'type': 'keyboard', # 'kbd_handler_name': 'DgTableMultiLineTextEdit' #} #text.add_behavior(behavior) action_wdg = self.get_action_wdg(name) widget.add(action_wdg) return widget
def get_text_area_input_wdg(name, width=400, styles=None): textarea_wdg = TextAreaWdg() textarea_wdg.set_id(name) textarea_wdg.set_name(name) textarea_wdg.add_style('width', '{0}px'.format(width)) if styles is None: styles = [] for style in styles: textarea_wdg.add_style(style[0], style[1]) return textarea_wdg
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): 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_data_wdg(my): div = DivWdg() from pyasm.biz import Pipeline from pyasm.widget import SelectWdg search_type_obj = SearchType.get(my.search_type) base_type = search_type_obj.get_base_key() search = Search("sthpw/pipeline") search.add_filter("search_type", base_type) pipelines = search.get_sobjects() if pipelines: pipeline = pipelines[0] process_names = pipeline.get_process_names() if process_names: table = Table() div.add(table) table.add_row() table.add_cell("Process: ") select = SelectWdg("process") table.add_cell(select) process_names.append("---") process_names.append("publish") process_names.append("icon") select.set_option("values", process_names) #### buttons = Table() div.add(buttons) buttons.add_row() button = IconButtonWdg(title="Add Data", icon=IconWdg.FOLDER) buttons.add_cell(button) dialog = DialogWdg(display="false", show_title=False) div.add(dialog) dialog.set_as_activator(button, offset={'x':-10,'y':10}) dialog_data_div = DivWdg() dialog_data_div.add_color("background", "background") dialog_data_div.add_style("padding", "20px") dialog.add(dialog_data_div) # Order folders by date name_div = DivWdg() dialog_data_div.add(name_div) name_div.add_style("margin: 15px 0px") if SearchType.column_exists(my.search_type, "relative_dir"): category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "none") category_div.add(checkbox) category_div.add(" No categories") category_div.add_style("margin-bottom: 5px") checkbox.set_option("checked", "true") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_day") category_div.add(checkbox) category_div.add(" Categorize files by Day") category_div.add_style("margin-bottom: 5px") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_week") category_div.add(checkbox) category_div.add(" Categorize files by Week") category_div.add_style("margin-bottom: 5px") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_year") category_div.add(checkbox) category_div.add(" Categorize files by Year") category_div.add_style("margin-bottom: 5px") """ checkbox = RadioWdg("category") checkbox.set_option("value", "custom") name_div.add(checkbox) name_div.add(" Custom") """ name_div.add("<br/>") hidden = HiddenWdg(name="parent_key") dialog_data_div.add(hidden) hidden.add_class("spt_parent_key") parent_key = my.kwargs.get("parent_key") or "" if parent_key: hidden.set_value(parent_key) dialog_data_div.add("Keywords:<br/>") dialog.add(dialog_data_div) text = TextAreaWdg(name="keywords") dialog_data_div.add(text) text.add_class("spt_keywords") text.add_style("padding: 1px") dialog_data_div.add("<br/>"*2) extra_data = my.kwargs.get("extra_data") if not isinstance(extra_data, basestring): extra_data = jsondumps(extra_data) dialog_data_div.add("Extra Data (JSON):<br/>") text = TextAreaWdg(name="extra_data") dialog_data_div.add(text) if extra_data != "null": text.set_value(extra_data) text.add_class("spt_extra_data") text.add_style("padding: 1px") #### TEST Image options """ button = IconButtonWdg(title="Resize", icon=IconWdg.FILM) buttons.add_cell(button) dialog = DialogWdg(display="false", show_title=False) div.add(dialog) dialog.set_as_activator(button, offset={'x':-10,'y':10}) try: from spt.tools.convert import ConvertOptionsWdg convert_div = DivWdg() dialog.add(convert_div) convert_div.add_style("padding: 20px") convert_div.add_color("background", "background") convert_div.add_class("spt_image_convert") convert = ConvertOptionsWdg() convert_div.add(convert) except: pass """ # use base name for name """ name_div = DivWdg() dialog_data_div.add(name_div) name_div.add_style("margin: 15px 0px") checkbox = CheckboxWdg("use_file_name") name_div.add(checkbox) name_div.add(" Use name of file for name") name_div.add("<br/>") checkbox = CheckboxWdg("use_base_name") name_div.add(checkbox) name_div.add(" Remove extension") name_div.add("<br/>") checkbox = CheckboxWdg("file_keywords") name_div.add(checkbox) name_div.add(" Use file name for keywords") """ return div
def get_display(my): my.sobject = my.kwargs.get("sobject") search_key = my.sobject.get_search_key() top = DivWdg() top.add_class("spt_checkin_publish") top.add_style("padding: 10px") margin_top = '60px' top.add_style("margin-top", margin_top) top.add_style("position: relative") current_changelist = WidgetSettings.get_value_by_key("current_changelist") current_branch = WidgetSettings.get_value_by_key("current_branch") current_workspace = WidgetSettings.get_value_by_key("current_workspace") top.add("Branch: %s<br/>" % current_branch) top.add("Changelist: %s<br/>" % current_changelist) top.add("Workspace: %s<br/>" % current_workspace) top.add("<br/>") checked_out_div = DivWdg() checkbox = CheckboxWdg("editable") top.add(checked_out_div) checkbox.add_class("spt_checkin_editable") checked_out_div.add(checkbox) checked_out_div.add("Leave files editable") top.add("<br/>") top.add("Publish Description<br/>") text = TextAreaWdg("description") # this needs to be set or it will stick out to the right text.add_style("width: 220px") text.add_class("spt_checkin_description") top.add(text) # add as a note note_div = DivWdg() top.add(note_div) note_div.add_class("spt_add_note") checkbox = CheckboxWdg("add_note") web = WebContainer.get_web() browser = web.get_browser() if browser in ['Qt']: checkbox.add_style("margin-top: -4px") checkbox.add_style("margin-right: 3px") note_div.add_style("margin-top: 3px") checkbox.add_class("spt_checkin_add_note") note_div.add(checkbox) note_div.add("Also add as note") top.add("<br/><br/>") button = ActionButtonWdg(title="Check-in", icon=IconWdg.PUBLISH, size='medium') top.add(button) my.repo_type = 'perforce' if my.repo_type == 'perforce': # the depot is set per project (unless overridden) project = my.sobject.get_project() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() asset_dir = Environment.get_asset_dir() sandbox_dir = Environment.get_sandbox_dir() changelist = WidgetSettings.get_value_by_key("current_changelist") button.add_behavior( { 'type': 'click_up', 'depot': depot, 'changelist': changelist, 'sandbox_dir': sandbox_dir, 'search_key': search_key, 'cbjs_action': ''' var paths = spt.checkin.get_selected_paths(); spt.app_busy.show("Checking in "+paths.length+" file/s into Perforce"); var top = bvr.src_el.getParent(".spt_checkin_top"); var description = top.getElement(".spt_checkin_description").value; var add_note = top.getElement(".spt_checkin_add_note").value; var editable = top.getElement(".spt_checkin_editable").value; if (editable == 'on') { editable = true; } else { editable = false; } var process = top.getElement(".spt_checkin_process").value; // check into TACTIC var server = TacticServerStub.get(); var revisions = []; server.start({description: "File Check-in"}); try { var top = bvr.src_el.getParent(".spt_checkin_top"); var el = top.getElement(".spt_mode"); var mode = el.value; // check-in the changelist var changelist = 'default'; if (mode == 'changelist') { var scm_info = spt.scm.run("commit_changelist", [changelist, description]); for ( var i = 1; i < scm_info.length-1; i++) { // the first item is the changelist number //console.log(scm_info[i]); var action = scm_info[i]; revision = action.rev; revisions.push(revision); // Do an inplace check-in into TACTIC var path = action.depotFile; var parts = path.split("/"); var filename = parts[parts.length-1]; var context = process + "/" + filename; var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} ); } } else { // check in all of the files for ( var i = 0; i < paths.length; i++) { var path = paths[i]; var scm_info = spt.scm.run("commit_file", [path, description, editable]); // the first item is the changelist number var action = scm_info[1]; revision = action.rev; revisions.push(revision); var parts = path.split("/"); var filename = parts[parts.length-1]; var context = process + "/" + filename; //path = path.replace(bvr.sandbox_dir, "//"+bvr.depot); // NOTE: this assumes project == depot path = path.replace(bvr.sandbox_dir, "//"); // Do an inplace check-in into TACTIC var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} ); } } if (add_note == 'on') { var note = []; note.push('CHECK-IN'); for (var i = 0; i < paths.length; i++) { var parts = paths[i].split("/"); var filename = parts[parts.length-1]; note.push(filename+' (v'+revisions[i]+')'); } note.push(': '); note.push(description); note = note.join(" "); server.create_note(bvr.search_key, note, {process: process}); } server.finish({description: "File Check-in ["+paths.length+" file/s]"}); spt.panel.refresh(top); } catch(e) { spt.error("Error detected: " + e.msg) //console.log(e); server.abort(); } spt.app_busy.hide(); ''' } ) else: button.add_behavior(behavior) button.add_style("margin-right: auto") button.add_style("margin-left: auto") button.add_style("margin-top: 20px") button.add_style("margin-bottom: 20px") top.add("<br clear='all'/>") top.add("<hr/>") hidden = HiddenWdg("checkin_type") top.add(hidden) hidden.add_class("spt_checkin_type") grey_out_div = DivWdg() top.add(grey_out_div) grey_out_div.add_class("spt_publish_disable") grey_out_div.add_style("position: absolute") grey_out_div.add_style("left: 0px") grey_out_div.add_style("top: 10px") grey_out_div.add_style("opacity: 0.6") grey_out_div.add_color("background", "background") grey_out_div.add_style("height: 100%") grey_out_div.add_style("width: 100%") #grey_out_div.add_border() return top
def get_display(my): top = my.top view = my.kwargs.get("view") top.add_class("spt_help_edit_content") search = Search("config/widget_config") search.add_filter("category", "HelpWdg") search.add_filter("view", view) sobject = search.get_sobject() if not sobject: value = "" search_key = "" else: xml_value = sobject.get_xml_value("config") value = xml_value.get_value("config/%s/html/div" % (view)) search_key = sobject.get_search_key() title_wdg = DivWdg() top.add(title_wdg) title_wdg.add("<b>View: %s</b>" % view) title_wdg.add_style("font-style: bold") title_wdg.add_style("padding: 5px") title_wdg.add_gradient("background", "background", 0, -10) hidden = HiddenWdg("view") top.add(hidden) hidden.set_value(view) text = TextAreaWdg("content") text_id = text.set_unique_id() text.set_value(value) from tactic.ui.widget import ActionButtonWdg if sobject: delete_button = ActionButtonWdg(title="Delete") top.add(delete_button) delete_button.add_style("float: right") delete_button.add_style("margin-top: -3px") delete_button.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' if (!confirm("Are you sure you wish to delete this help page?")) { return; } var server = TacticServerStub.get(); server.delete_sobject(bvr.search_key); var top = bvr.src_el.getParent(".spt_help_edit_top"); spt.panel.refresh(top); ''' }) test_button = ActionButtonWdg(title="Preview") top.add(test_button) test_button.add_style("float: right") test_button.add_style("margin-top: -3px") test_button.add_behavior({ 'type': 'click_up', 'text_id': text_id, 'cbjs_action': ''' var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); var cmd = "CKEDITOR.instances." + bvr.text_id + ".getData()"; var text_value = eval( cmd ); bvr.options = {}; bvr.options.html = text_value; spt.named_events.fire_event("show_help", bvr) ''' }) save_button = ActionButtonWdg(title="Save") top.add(save_button) save_button.add_style("float: right") save_button.add_style("margin-top: -3px") top.add("<br/>") save_button.add_behavior({ 'type': 'click_up', 'text_id': text_id, 'cbjs_action': ''' spt.app_busy.show("Saving Help", " ") var top = bvr.src_el.getParent(".spt_help_edit_content"); var values = spt.api.Utility.get_input_values(top, null, false); var cmd = "CKEDITOR.instances." + bvr.text_id + ".getData()"; var text_value = eval( cmd ); values.content = text_value; var command = "tactic.ui.app.HelpEditCbk"; var kwargs = values; var server = TacticServerStub.get(); server.execute_cmd(command, kwargs); setTimeout("spt.app_busy.hide()", 200) ''' }) #top.add("Style: ") #select = SelectWdg("style") #top.add(select) #select.set_option("values", "text|html") top.add("<br/>") top.add(text) text.set_value(value) text.add_style("width: 100%") text.add_style("height: 100%") text.add_style("min-height: 500px") text.add_style("display: none") text.add_behavior({ 'type': 'load', 'color': text.get_color("background", -10), 'text_id': text_id, 'cbjs_action': ''' var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); setTimeout( function() { CKEDITOR.on( 'instanceReady', function( ev ) { ev.editor.dataProcessor.writer.indentationChars = ' '; }); var config = { toolbar: 'Full', uiColor: bvr.color, height: '500px' }; config.toolbar_Full = [ ['Source'], ['Cut','Copy','Paste'], ['Undo','Redo','-','Find','Replace'], ['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], '/', ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['HorizontalRule','SpecialChar'], ['Styles','Format','Font','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks'] ]; CKEDITOR.replace(bvr.text_id, config ); bvr.src_el.setStyle("display", ""); }, 500); ''' }) return top
class CKEditorWdg(BaseRefreshWdg): def init(self): name = self.kwargs.get("name") assert(name) self.text = TextAreaWdg(name) self.text_id = self.kwargs.get("text_id") if not self.text_id: self.text_id = self.text.set_unique_id() def get_display(self): top = self.top top.add_style("min-width: 600px") top.add_class("spt_ckeditor_top") top.add_attr("text_id", self.text_id) top.add(self.text) value = self.kwargs.get("value") if value: self.text.set_value(value) self.text.add_style("width: 100%") self.text.add_style("height: 100%") self.text.add_style("min-height: 500px") self.text.add_style("display: none") self.text.set_id(self.text_id) self.text.add_behavior( { 'type': 'load', 'color': self.text.get_color("background", -10), 'text_id': self.text_id, 'cbjs_action': ''' /* var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); */ var init = function() { CKEDITOR.on( 'instanceReady', function( ev ) { ev.editor.dataProcessor.writer.indentationChars = ' '; }); var config = { toolbar: 'Full', uiColor: bvr.color, height: '800px' }; /* config.toolbar_Full = [ ['Source'], //['Cut','Copy','Paste'], ['Undo','Redo','-','Find','Replace'], ['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], '/', ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['HorizontalRule','SpecialChar'], ['Styles','Format','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks'] ]; */ config.toolbar_Full = [ { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] }, { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] }, { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] }, { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] }, '/', { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv', '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] }, { name: 'links', items : [ 'Link','Unlink','Anchor' ] }, { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] }, '/', { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] }, { name: 'colors', items : [ 'TextColor','BGColor' ] }, { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] } ]; config.entities = false; config.basicEntities = false; config.extraAllowedContent = 'iframe[*]'; config.allowedContent = true; config.enterMode = CKEDITOR.ENTER_BR; var instance = CKEDITOR.instances[ bvr.text_id ]; if (instance) instance.destroy(); CKEDITOR.replace(bvr.text_id, config ); //var html = ''; //editor = CKEDITOR.appendTo( bvr.text_id, config, html ); bvr.src_el.setStyle("display", "none"); spt.ckeditor = {}; spt.ckeditor.get_value = function(text_id) { var text_value = CKEDITOR.instances[ text_id ].getData(); return text_value; } spt.ckeditor.set_value = function(text_id, data) { CKEDITOR.instances[ text_id ].setData(data); } } spt.dom.load_js(['ckeditor/ckeditor.js'], init); ''' } ) return top
def get_data_wdg(my): div = DivWdg() from pyasm.biz import Pipeline from pyasm.widget import SelectWdg search_type_obj = SearchType.get(my.search_type) base_type = search_type_obj.get_base_key() search = Search("sthpw/pipeline") search.add_filter("search_type", base_type) pipelines = search.get_sobjects() if pipelines: pipeline = pipelines[0] process_names = pipeline.get_process_names() if process_names: table = Table() div.add(table) table.add_row() table.add_cell("Process: ") select = SelectWdg("process") table.add_cell(select) process_names.append("---") process_names.append("publish") process_names.append("icon") select.set_option("values", process_names) #### buttons = Table() div.add(buttons) buttons.add_row() button = IconButtonWdg(title="Fill in Data", icon=IconWdg.EDIT) buttons.add_cell(button) dialog = DialogWdg(display="false", show_title=False) div.add(dialog) dialog.set_as_activator(button, offset={'x': -10, 'y': 10}) dialog_data_div = DivWdg() dialog_data_div.add_color("background", "background") dialog_data_div.add_style("padding", "20px") dialog.add(dialog_data_div) # Order folders by date name_div = DivWdg() dialog_data_div.add(name_div) name_div.add_style("margin: 15px 0px") if SearchType.column_exists(my.search_type, "relative_dir"): category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "none") category_div.add(checkbox) category_div.add(" No categories") category_div.add_style("margin-bottom: 5px") checkbox.set_option("checked", "true") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_day") category_div.add(checkbox) category_div.add(" Categorize files by Day") category_div.add_style("margin-bottom: 5px") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_week") category_div.add(checkbox) category_div.add(" Categorize files by Week") category_div.add_style("margin-bottom: 5px") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_year") category_div.add(checkbox) category_div.add(" Categorize files by Year") category_div.add_style("margin-bottom: 5px") """ checkbox = RadioWdg("category") checkbox.set_option("value", "custom") name_div.add(checkbox) name_div.add(" Custom") """ name_div.add("<br/>") ingest_data_view = my.kwargs.get('ingest_data_view') from tactic.ui.panel import EditWdg sobject = SearchType.create(my.search_type) edit = EditWdg(search_key=sobject.get_search_key(), mode='view', view=ingest_data_view) dialog_data_div.add(edit) hidden = HiddenWdg(name="parent_key") dialog_data_div.add(hidden) hidden.add_class("spt_parent_key") parent_key = my.kwargs.get("parent_key") or "" if parent_key: hidden.set_value(parent_key) extra_data = my.kwargs.get("extra_data") if not isinstance(extra_data, basestring): extra_data = jsondumps(extra_data) if extra_data and extra_data != "null": # it needs a TextArea instead of Hidden because of JSON data text = TextAreaWdg(name="extra_data") text.add_style('display: none') text.set_value(extra_data) dialog_data_div.add(text) """ dialog_data_div.add("Keywords:<br/>") dialog.add(dialog_data_div) text = TextAreaWdg(name="keywords") dialog_data_div.add(text) text.add_class("spt_keywords") text.add_style("padding: 1px") dialog_data_div.add("<br/>"*2) text.add_class("spt_extra_data") text.add_style("padding: 1px") """ #### TEST Image options """ button = IconButtonWdg(title="Resize", icon=IconWdg.FILM) buttons.add_cell(button) dialog = DialogWdg(display="false", show_title=False) div.add(dialog) dialog.set_as_activator(button, offset={'x':-10,'y':10}) try: from spt.tools.convert import ConvertOptionsWdg convert_div = DivWdg() dialog.add(convert_div) convert_div.add_style("padding: 20px") convert_div.add_color("background", "background") convert_div.add_class("spt_image_convert") convert = ConvertOptionsWdg() convert_div.add(convert) except: pass """ # use base name for name """ name_div = DivWdg() dialog_data_div.add(name_div) name_div.add_style("margin: 15px 0px") checkbox = CheckboxWdg("use_file_name") name_div.add(checkbox) name_div.add(" Use name of file for name") name_div.add("<br/>") checkbox = CheckboxWdg("use_base_name") name_div.add(checkbox) name_div.add(" Remove extension") name_div.add("<br/>") checkbox = CheckboxWdg("file_keywords") name_div.add(checkbox) name_div.add(" Use file name for keywords") """ return div
def get_display(self): top = DivWdg() name = self.get_name() top.add_class("spt_note_input_top") context = self.get_option("context") if not context: context = name sobject = self.get_option("sobject") if not sobject: search_key = self.get_option("search_key") sobject = Search.get_by_search_key(search_key) else: search_key = sobject.get_search_key() if search_key or (sobject and not sobject.is_insert()): search = Search("sthpw/note") #search.add_relationship_filters(self.filtered_parents, type='hierarchy') search.add_parent_filter(sobject) search.add_filter("context", context) search.add_order_by("process") search.add_order_by("context") search.add_order_by("timestamp desc") search.add_filter("context", context) count = search.get_count() last_note = search.get_sobject() else: last_note = None count = 0 #if not last_note: # last_note = SearchType.create("sthpw/note") # last_note.set_value("login", "") # last_note.set_value("timestamp", "") # last_note.set_value("note", "") if last_note: last_div = DivWdg() top.add(last_div) table = Table() table.add_style("width: 100%") table.add_attr("cellpadding", "0px") table.add_attr("cellspacing", "0px") last_div.add(table) table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 5px 15px 10px 5px") table.add_border() table.add_color("background", "background", -5) note_str = last_note.get_value("note") login = last_note.get_value("login") if not login: login = "******" date = last_note.get_datetime_value("timestamp") if date: date_str = "<i style='font-size: 0.8em'>%s</i>" % date.strftime( "%Y-%m-%d") else: date_str = "" login = "******" % login td.add("%s - %s<br/>" % (date_str, login)) note_str_div = DivWdg() note_str_div.add(note_str) note_str_div.add_style("padding: 10px 15px 10px 10px") #td = table.add_cell( note_str_div ) td.add(note_str_div) #td.add_style("vertical-align: top") #td.add_style("padding: 10px 15px 10px 10px") """ td.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_input_top"); var text_el = top.getElement(".spt_add_entry"); text_el.setStyle("display", ""); ''' } ) """ # log if count == 0: td = table.add_cell("") elif count == 1: td = table.add_cell( "<i style='font-size: 0.8em'>More...><br/>(%s entry)</i>" % count) else: td = table.add_cell( "<i style='font-size: 0.8em'>More...><br/>(%s entries)</i>" % count) td.add_style("vertical-align: top") td.add_style("padding: 3px") td.add_class("hand") td.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'context': context, 'cbjs_action': ''' var class_name = 'tactic.ui.input.note_input_wdg.NoteHistoryWdg'; var kwargs = { search_key: bvr.search_key, context: bvr.context } spt.panel.load_popup("Notes Log", class_name, kwargs); ''' }) name = self.get_input_name() text = TextAreaWdg(name) top.add(text) text.add_style("width: 100%") text.add_class("spt_add_entry") """ if search_key and not sobject.is_insert(): from tactic.ui.widget import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=search_key, context_hidden=False, show_note_expand=False, show_add=False) top.add(discussion_wdg) """ return top
class CKEditorWdg(BaseRefreshWdg): def init(self): name = self.kwargs.get("name") assert (name) self.text = TextAreaWdg(name) self.text_id = self.kwargs.get("text_id") if not self.text_id: self.text_id = self.text.set_unique_id() def get_display(self): top = self.top top.add_style("min-width: 600px") top.add_class("spt_ckeditor_top") top.add_attr("text_id", self.text_id) top.add(self.text) value = self.kwargs.get("value") if value: self.text.set_value(value) self.text.add_style("width: 100%") self.text.add_style("height: 100%") self.text.add_style("min-height: 500px") self.text.add_style("display: none") self.text.set_id(self.text_id) self.text.add_behavior({ 'type': 'load', 'color': self.text.get_color("background", -10), 'text_id': self.text_id, 'cbjs_action': ''' /* var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); */ var init = function() { CKEDITOR.on( 'instanceReady', function( ev ) { ev.editor.dataProcessor.writer.indentationChars = ' '; }); var config = { toolbar: 'Full', uiColor: bvr.color, height: '800px' }; /* config.toolbar_Full = [ ['Source'], //['Cut','Copy','Paste'], ['Undo','Redo','-','Find','Replace'], ['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], '/', ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['HorizontalRule','SpecialChar'], ['Styles','Format','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks'] ]; */ config.toolbar_Full = [ { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] }, { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] }, { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] }, { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] }, '/', { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv', '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] }, { name: 'links', items : [ 'Link','Unlink','Anchor' ] }, { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] }, '/', { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] }, { name: 'colors', items : [ 'TextColor','BGColor' ] }, { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] } ]; config.entities = false; config.basicEntities = false; config.extraAllowedContent = 'iframe[*]'; config.allowedContent = true; config.enterMode = CKEDITOR.ENTER_BR; var instance = CKEDITOR.instances[ bvr.text_id ]; if (instance) instance.destroy(); CKEDITOR.replace(bvr.text_id, config ); //var html = ''; //editor = CKEDITOR.appendTo( bvr.text_id, config, html ); bvr.src_el.setStyle("display", "none"); spt.ckeditor = {}; spt.ckeditor.get_value = function(text_id) { var text_value = CKEDITOR.instances[ text_id ].getData(); return text_value; } spt.ckeditor.set_value = function(text_id, data) { CKEDITOR.instances[ text_id ].setData(data); } } spt.dom.load_js(['ckeditor/ckeditor.js'], init); ''' }) return top
def get_data_wdg(my): div = DivWdg() from pyasm.biz import Pipeline from pyasm.widget import SelectWdg search_type_obj = SearchType.get(my.search_type) base_type = search_type_obj.get_base_key() search = Search("sthpw/pipeline") search.add_filter("search_type", base_type) pipelines = search.get_sobjects() if pipelines: pipeline = pipelines[0] process_names = pipeline.get_process_names() if process_names: table = Table() div.add(table) table.add_row() table.add_cell("Process: ") select = SelectWdg("process") table.add_cell(select) process_names.append("---") process_names.append("publish") process_names.append("icon") select.set_option("values", process_names) #### buttons = Table() div.add(buttons) buttons.add_row() #button = IconButtonWdg(title="Fill in Data", icon=IconWdg.EDIT) button = ActionButtonWdg(title="Metadata") button.add_style("float: left") button.add_style("margin-top: -3px") buttons.add_cell(button) select_label = DivWdg("Update mode") select_label.add_style("float: left") select_label.add_style("margin-top: -3px") select_label.add_style("margin-left: 20px") buttons.add_cell(select_label) update_mode_option = my.kwargs.get("update_mode") if not update_mode_option: update_mode_option = "true" update_mode = SelectWdg(name="update mode") update_mode.add_class("spt_update_mode_select") update_mode.set_option("values", ["false", "true", "sequence"]) update_mode.set_option("labels", ["Off", "On", "Sequence"]) update_mode.set_option("default", update_mode_option) update_mode.add_style("float: left") update_mode.add_style("margin-top: -3px") update_mode.add_style("margin-left: 5px") update_mode.add_style("margin-right: 5px") buttons.add_cell(update_mode) update_info = DivWdg() update_info.add_class("glyphicon") update_info.add_class("glyphicon-info-sign") update_info.add_style("float: left") update_info.add_style("margin-top: -3px") update_info.add_style("margin-left: 10px") update_info.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.info("When update mode is on, if a file shares the name of one other file in the asset library, the file will update on ingest. If more than one file shares the name of an ingested asset, a new asset is created.<br> If sequence mode is selected, the system will update the sobject on ingest if a file sequence sharing the same name already exists.", {type: 'html'}); ''' }) buttons.add_cell(update_info) dialog = DialogWdg(display="false", show_title=False) div.add(dialog) dialog.set_as_activator(button, offset={'x': -10, 'y': 10}) dialog_data_div = DivWdg() dialog_data_div.add_color("background", "background") dialog_data_div.add_style("padding", "20px") dialog.add(dialog_data_div) # Order folders by date name_div = DivWdg() dialog_data_div.add(name_div) name_div.add_style("margin: 15px 0px") if SearchType.column_exists(my.search_type, "relative_dir"): category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "none") category_div.add(checkbox) category_div.add(" No categories") category_div.add_style("margin-bottom: 5px") checkbox.set_option("checked", "true") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_day") category_div.add(checkbox) category_div.add(" Categorize files by Day") category_div.add_style("margin-bottom: 5px") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_week") category_div.add(checkbox) category_div.add(" Categorize files by Week") category_div.add_style("margin-bottom: 5px") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_year") category_div.add(checkbox) category_div.add(" Categorize files by Year") category_div.add_style("margin-bottom: 5px") """ checkbox = RadioWdg("category") checkbox.set_option("value", "custom") name_div.add(checkbox) name_div.add(" Custom") """ name_div.add("<br/>") ingest_data_view = my.kwargs.get('ingest_data_view') from tactic.ui.panel import EditWdg sobject = SearchType.create(my.search_type) edit = EditWdg(search_key=sobject.get_search_key(), mode='view', view=ingest_data_view) dialog_data_div.add(edit) hidden = HiddenWdg(name="parent_key") dialog_data_div.add(hidden) hidden.add_class("spt_parent_key") parent_key = my.kwargs.get("parent_key") or "" if parent_key: hidden.set_value(parent_key) extra_data = my.kwargs.get("extra_data") if not isinstance(extra_data, basestring): extra_data = jsondumps(extra_data) if extra_data and extra_data != "null": # it needs a TextArea instead of Hidden because of JSON data text = TextAreaWdg(name="extra_data") text.add_style('display: none') text.set_value(extra_data) dialog_data_div.add(text) """ dialog_data_div.add("Keywords:<br/>") dialog.add(dialog_data_div) text = TextAreaWdg(name="keywords") dialog_data_div.add(text) text.add_class("spt_keywords") text.add_style("padding: 1px") dialog_data_div.add("<br/>"*2) text.add_class("spt_extra_data") text.add_style("padding: 1px") """ #### TEST Image options """ button = IconButtonWdg(title="Resize", icon=IconWdg.FILM) buttons.add_cell(button) dialog = DialogWdg(display="false", show_title=False) div.add(dialog) dialog.set_as_activator(button, offset={'x':-10,'y':10}) try: from spt.tools.convert import ConvertOptionsWdg convert_div = DivWdg() dialog.add(convert_div) convert_div.add_style("padding: 20px") convert_div.add_color("background", "background") convert_div.add_class("spt_image_convert") convert = ConvertOptionsWdg() convert_div.add(convert) except: pass """ # use base name for name """ name_div = DivWdg() dialog_data_div.add(name_div) name_div.add_style("margin: 15px 0px") checkbox = CheckboxWdg("use_file_name") name_div.add(checkbox) name_div.add(" Use name of file for name") name_div.add("<br/>") checkbox = CheckboxWdg("use_base_name") name_div.add(checkbox) name_div.add(" Remove extension") name_div.add("<br/>") checkbox = CheckboxWdg("file_keywords") name_div.add(checkbox) name_div.add(" Use file name for keywords") """ return div
def get_chat_wdg(my, key, interval=False): div = DivWdg() div.add_class("spt_chat_session_top") div.add_color("background", "background") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_color("background", "background3") title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_border() icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE) icon.add_style("float: right") icon.add_style("margin-top: -5px") title_wdg.add(icon) icon.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var server = TacticServerStub.get(); var top = bvr.src_el.getParent(".spt_chat_session_top"); spt.behavior.destroy_element(top); ''' } ) current_user = Environment.get_user_name() logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key) for login in logins: if login.get_value("login") == current_user: continue thumb = ThumbWdg() thumb.set_icon_size(45) thumb.set_sobject(login) thumb.add_style("float: left") thumb.add_style("margin: -5px 10px 0px -5px") title_wdg.add(thumb) title_wdg.add(login.get_value("display_name")) title_wdg.add("<br clear='all'/>") history_div = DivWdg() div.add(history_div) history_div.add_class("spt_chat_history") history_div.add_style("width: auto") history_div.add_style("height: auto") history_div.add_style("max-height: 400px") history_div.add_style("padding: 5px") history_div.add_class("spt_resizable") history_div.add_border() history_div.add_style("overflow-y: auto") #history_div.add_style("font-size: 0.9em") search = Search("sthpw/message_log") search.add_filter("message_code", key) search.add_order_by("timestamp") message_logs = search.get_sobjects() last_login = None; last_date = None; for message_log in message_logs: login = message_log.get("login") message = message_log.get("message") timestamp = message_log.get_datetime_value("timestamp") #timestamp = timestamp.strftime("%b %d, %Y - %H:%M") timestamp_str = timestamp.strftime("%H:%M") date_str = timestamp.strftime("%b %d, %Y") msg = ""; msg += "<table style='margin-top: 5px; font-size: 0.9em; width: 100%'><tr><td colspan='2'>"; if date_str != last_date: msg += "<br/><b style='font-size: 1.0em'>"+date_str+"</b><hr/></td></tr>"; msg += "<tr><td>"; last_login = None if login != last_login: msg += "<b>"+login+"</b><br/>"; msg += message.replace("\n",'<br/>'); msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>"; msg += timestamp_str; msg += "</td></tr></table>"; history_div.add(msg) last_login = login last_date = date_str history_div.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.scrollTop = bvr.src_el.scrollHeight; ''' } ) if message_logs: last_message = message_logs[-1].get("message") last_login = message_logs[-1].get("login") else: last_message = "" last_login = "" div.add_attr("spt_last_message", last_message) div.add_attr("spt_last_login", last_login) if interval: div.add_behavior( { 'type': 'load', 'key': key, 'cbjs_action': r''' var text_el = bvr.src_el.getElement(".spt_chat_text"); var history_el = bvr.src_el.getElement(".spt_chat_history"); var callback = function(message) { //history_el.setStyle("background", "red"); var login = message.login; var timestamp = message.timestamp; if (timestamp) { var parts = timestamp.split(" "); parts = parts[1].split("."); timestamp = parts[0]; } else { timestamp = ""; } var tmp = message.message || ""; var last_message = bvr.src_el.getAttribute("spt_last_message"); var last_login = bvr.src_el.getAttribute("spt_last_login"); if (tmp == last_message && login == last_login) { return; } bvr.src_el.setAttribute("spt_last_message", tmp); bvr.src_el.setAttribute("spt_last_login", login); var msg = ""; msg += "<table style='margin-top: 5px; font-size: 0.9em; width: 100%'><tr><td>"; if (login != last_login) { msg += "<b>"+login+"</b><br/>"; } msg += tmp.replace(/\n/g,'<br/>'); msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>"; msg += timestamp; msg += "</td></tr></table>"; if (msg == history_el.last_msg) { return; } history_el.innerHTML = history_el.innerHTML + msg; // remember last message history_el.last_msg = msg; history_el.scrollTop = history_el.scrollHeight; } spt.message.set_interval(bvr.key, callback, 3000, bvr.src_el); ''' } ) text = TextAreaWdg("chat") div.add(text) text.add_class("spt_chat_text") text.add_style("width: 100%") text.add_style("padding: 5px") text.add_style("margin-top: -1px") text.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.addEvent("keydown", function(e) { var keys = ['tab','keys(control+enter)', 'enter']; var key = e.key; var input = bvr.src_el if (keys.indexOf(key) > -1) e.stop(); if (key == 'tab') { } else if (key == 'enter') { if (e.control == false) { pass; } else { // TODO: check if it's multi-line first //... use ctrl-ENTER for new-line, regular ENTER (RETURN) accepts value //var tvals = parse_selected_text(input); //input.value = tvals[0] + "\\n" + tvals[1]; //spt.set_cursor_position( input, tvals[0].length + 1 ); } } } ) ''' } ) button = ActionButtonWdg(title="Send") div.add(button) button.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chat_session_top"); var text_el = top.getElement(".spt_chat_text"); var message = text_el.value; if (!message) { return; } var history_el = top.getElement(".spt_chat_history"); var category = "chat"; var server = TacticServerStub.get(); var key = bvr.key; var last_message = server.log_message(key, message, {category:category, status:"in_progress"}); text_el.value = ""; ''' } ) return div
def get_import_wdg(self): div = DivWdg() if self.data: div.add("<br/>"*2) div.add("The following TACTIC share was found: ") div.add("<br/>"*2) data_input = TextAreaWdg("data") data_input.add_style("display: none") div.add(data_input) #print "xxxx: ", self.data data_str = jsondumps(self.data) #data_str = data_str.replace('"', "'") print "data: ", data_str data_input.set_value(data_str) table = Table() div.add(table) table.set_max_width() table.add_style("margin-left: 20px") table.add_style("margin-right: 20px") for name, value in self.data.items(): name = Common.get_display_title(name) table.add_row() table.add_cell(name) table.add_cell(value) div.add("<br/>"*2) div.add( self.get_versions_wdg() ) div.add("<br/>"*2) # check to see if the project exists project_code = self.data.get("project_code") project_code = self.data.get("projects") project = Project.get_by_code(project_code) #if project: if False: msg_div = DivWdg() div.add(msg_div) msg_div.add_style("padding: 20px") msg_div.add_color("background", "background3") msg_div.add_color("color", "color") msg_div.add_border() icon = IconWdg("WARNING", IconWdg.WARNING) msg_div.add(icon) icon.add_style("float: left") msg_div.add("The project with code [%s] already exists. You must remove the installed project before trying to import this one." % project_code) return div if self.data.get("is_encrypted") == "true": div.add("The transactions in this share is encrypted. Please provide an encryption key to decrypt the transactions<br/><br/>") div.add("Encryption Key: ") text = TextWdg("encryption_key") div.add(text) div.add("<br/>"*2) button = ActionButtonWdg(title="Import >>") button.add_style("float: right") div.add(button) div.add("<br/>"*2) button.add_behavior( { 'type': 'click_up', 'project_code': project_code, 'cbjs_action': ''' spt.app_busy.show("Importing Project "+bvr.project_code+"..."); var top = bvr.src_el.getParent(".spt_sync_import_top"); var values = spt.api.Utility.get_input_values(top, null, false); var cmd = "tactic.ui.sync.SyncImportCmd"; var server = TacticServerStub.get(); server.execute_cmd(cmd, values, {}, {use_transaction: false}); spt.notify.show_message("Finished importing project"); spt.app_busy.hide(); document.location = '/tactic/'+bvr.project_code; ''' } ) return div
def get_display(my): my.sobject = my.kwargs.get("sobject") search_key = my.sobject.get_search_key() top = DivWdg() top.add_class("spt_checkin_publish") top.add_style("padding: 10px") margin_top = '60px' top.add_style("margin-top", margin_top) top.add_style("position: relative") current_changelist = WidgetSettings.get_value_by_key( "current_changelist") current_branch = WidgetSettings.get_value_by_key("current_branch") current_workspace = WidgetSettings.get_value_by_key( "current_workspace") top.add("Branch: %s<br/>" % current_branch) top.add("Changelist: %s<br/>" % current_changelist) top.add("Workspace: %s<br/>" % current_workspace) top.add("<br/>") checked_out_div = DivWdg() checkbox = CheckboxWdg("editable") top.add(checked_out_div) checkbox.add_class("spt_checkin_editable") checked_out_div.add(checkbox) checked_out_div.add("Leave files editable") top.add("<br/>") top.add("Publish Description<br/>") text = TextAreaWdg("description") # this needs to be set or it will stick out to the right text.add_style("width: 220px") text.add_class("spt_checkin_description") top.add(text) # add as a note note_div = DivWdg() top.add(note_div) note_div.add_class("spt_add_note") checkbox = CheckboxWdg("add_note") web = WebContainer.get_web() browser = web.get_browser() if browser in ['Qt']: checkbox.add_style("margin-top: -4px") checkbox.add_style("margin-right: 3px") note_div.add_style("margin-top: 3px") checkbox.add_class("spt_checkin_add_note") note_div.add(checkbox) note_div.add("Also add as note") top.add("<br/><br/>") button = ActionButtonWdg(title="Check-in", icon=IconWdg.PUBLISH, size='medium') top.add(button) my.repo_type = 'perforce' if my.repo_type == 'perforce': # the depot is set per project (unless overridden) project = my.sobject.get_project() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() asset_dir = Environment.get_asset_dir() sandbox_dir = Environment.get_sandbox_dir() changelist = WidgetSettings.get_value_by_key("current_changelist") button.add_behavior({ 'type': 'click_up', 'depot': depot, 'changelist': changelist, 'sandbox_dir': sandbox_dir, 'search_key': search_key, 'cbjs_action': ''' var paths = spt.checkin.get_selected_paths(); spt.app_busy.show("Checking in "+paths.length+" file/s into Perforce"); var top = bvr.src_el.getParent(".spt_checkin_top"); var description = top.getElement(".spt_checkin_description").value; var add_note = top.getElement(".spt_checkin_add_note").value; var editable = top.getElement(".spt_checkin_editable").value; if (editable == 'on') { editable = true; } else { editable = false; } var process = top.getElement(".spt_checkin_process").value; // check into TACTIC var server = TacticServerStub.get(); var revisions = []; server.start({description: "File Check-in"}); try { var top = bvr.src_el.getParent(".spt_checkin_top"); var el = top.getElement(".spt_mode"); var mode = el.value; // check-in the changelist var changelist = 'default'; if (mode == 'changelist') { var scm_info = spt.scm.run("commit_changelist", [changelist, description]); for ( var i = 1; i < scm_info.length-1; i++) { // the first item is the changelist number //console.log(scm_info[i]); var action = scm_info[i]; revision = action.rev; revisions.push(revision); // Do an inplace check-in into TACTIC var path = action.depotFile; var parts = path.split("/"); var filename = parts[parts.length-1]; var context = process + "/" + filename; var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} ); } } else { // check in all of the files for ( var i = 0; i < paths.length; i++) { var path = paths[i]; var scm_info = spt.scm.run("commit_file", [path, description, editable]); // the first item is the changelist number var action = scm_info[1]; revision = action.rev; revisions.push(revision); var parts = path.split("/"); var filename = parts[parts.length-1]; var context = process + "/" + filename; //path = path.replace(bvr.sandbox_dir, "//"+bvr.depot); // NOTE: this assumes project == depot path = path.replace(bvr.sandbox_dir, "//"); // Do an inplace check-in into TACTIC var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} ); } } if (add_note == 'on') { var note = []; note.push('CHECK-IN'); for (var i = 0; i < paths.length; i++) { var parts = paths[i].split("/"); var filename = parts[parts.length-1]; note.push(filename+' (v'+revisions[i]+')'); } note.push(': '); note.push(description); note = note.join(" "); server.create_note(bvr.search_key, note, {process: process}); } server.finish({description: "File Check-in ["+paths.length+" file/s]"}); spt.panel.refresh(top); } catch(e) { spt.error("Error detected: " + e.msg) //console.log(e); server.abort(); } spt.app_busy.hide(); ''' }) else: button.add_behavior(behavior) button.add_style("margin-right: auto") button.add_style("margin-left: auto") button.add_style("margin-top: 20px") button.add_style("margin-bottom: 20px") top.add("<br clear='all'/>") top.add("<hr/>") hidden = HiddenWdg("checkin_type") top.add(hidden) hidden.add_class("spt_checkin_type") grey_out_div = DivWdg() top.add(grey_out_div) grey_out_div.add_class("spt_publish_disable") grey_out_div.add_style("position: absolute") grey_out_div.add_style("left: 0px") grey_out_div.add_style("top: 10px") grey_out_div.add_style("opacity: 0.6") grey_out_div.add_color("background", "background") grey_out_div.add_style("height: 100%") grey_out_div.add_style("width: 100%") #grey_out_div.add_border() return top
def get_display(self): top = DivWdg() name = self.get_name() top.add_class("spt_note_input_top") context = self.get_option("context") if not context: context = name sobject = self.get_option("sobject") if not sobject: search_key = self.get_option("search_key") sobject = Search.get_by_search_key(search_key) else: search_key = sobject.get_search_key() if search_key or (sobject and not sobject.is_insert()): search = Search("sthpw/note") #search.add_relationship_filters(self.filtered_parents, type='hierarchy') search.add_parent_filter(sobject) search.add_filter("context", context) search.add_order_by("process") search.add_order_by("context") search.add_order_by("timestamp desc") search.add_filter("context", context) count = search.get_count() last_note = search.get_sobject() else: last_note = None count = 0 #if not last_note: # last_note = SearchType.create("sthpw/note") # last_note.set_value("login", "") # last_note.set_value("timestamp", "") # last_note.set_value("note", "") if last_note: last_div = DivWdg() top.add(last_div) table = Table() table.add_style("width: 100%") table.add_attr("cellpadding", "0px") table.add_attr("cellspacing", "0px") last_div.add(table) table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 5px 15px 10px 5px") table.add_border() table.add_color("background", "background", -5) note_str = last_note.get_value("note") login = last_note.get_value("login") if not login: login = "******" date = last_note.get_datetime_value("timestamp") if date: date_str = "<i style='font-size: 0.8em'>%s</i>" % date.strftime("%Y-%m-%d") else: date_str = "" login = "******" % login td.add("%s - %s<br/>" % (date_str, login)) note_str_div = DivWdg() note_str_div.add(note_str) note_str_div.add_style("padding: 10px 15px 10px 10px") #td = table.add_cell( note_str_div ) td.add( note_str_div ) #td.add_style("vertical-align: top") #td.add_style("padding: 10px 15px 10px 10px") """ td.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_input_top"); var text_el = top.getElement(".spt_add_entry"); text_el.setStyle("display", ""); ''' } ) """ # log if count == 0: td = table.add_cell( "" ) elif count == 1: td = table.add_cell( "<i style='font-size: 0.8em'>More...><br/>(%s entry)</i>" % count ) else: td = table.add_cell( "<i style='font-size: 0.8em'>More...><br/>(%s entries)</i>" % count ) td.add_style("vertical-align: top") td.add_style("padding: 3px") td.add_class("hand") td.add_behavior( { 'type': 'click_up', 'search_key': search_key, 'context': context, 'cbjs_action': ''' var class_name = 'tactic.ui.input.note_input_wdg.NoteHistoryWdg'; var kwargs = { search_key: bvr.search_key, context: bvr.context } spt.panel.load_popup("Notes Log", class_name, kwargs); ''' } ) name = self.get_input_name() text = TextAreaWdg(name) top.add(text) text.add_style("width: 100%") text.add_class("spt_add_entry") """ if search_key and not sobject.is_insert(): from tactic.ui.widget import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=search_key, context_hidden=False, show_note_expand=False, show_add=False) top.add(discussion_wdg) """ return top
def get_chat_wdg(self, key, interval=False): div = DivWdg() div.add_class("spt_chat_session_top") div.add_color("background", "background") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_color("background", "background3") title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_border() icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE) icon.add_style("float: right") icon.add_style("margin-top: -5px") title_wdg.add(icon) icon.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var server = TacticServerStub.get(); var top = bvr.src_el.getParent(".spt_chat_session_top"); spt.behavior.destroy_element(top); ''' } ) current_user = Environment.get_user_name() logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key) for login in logins: if login.get_value("login") == current_user: continue thumb = ThumbWdg() thumb.set_icon_size(45) thumb.set_sobject(login) thumb.add_style("float: left") thumb.add_style("margin: -5px 10px 0px -5px") title_wdg.add(thumb) title_wdg.add(login.get_value("display_name")) title_wdg.add("<br clear='all'/>") history_div = DivWdg() div.add(history_div) history_div.add_class("spt_chat_history") history_div.add_style("width: auto") history_div.add_style("height: auto") history_div.add_style("max-height: 400px") history_div.add_style("padding: 5px") history_div.add_class("spt_resizable") history_div.add_border() history_div.add_style("overflow-y: auto") #history_div.add_style("font-size: 0.9em") search = Search("sthpw/message_log") search.add_filter("message_code", key) search.add_order_by("timestamp") message_logs = search.get_sobjects() last_login = None; last_date = None; for message_log in message_logs: login = message_log.get("login") message = message_log.get("message") timestamp = message_log.get_datetime_value("timestamp") #timestamp = timestamp.strftime("%b %d, %Y - %H:%M") timestamp_str = timestamp.strftime("%H:%M") date_str = timestamp.strftime("%b %d, %Y") if login != last_login: table = Table() history_div.add(table) table.add_row() table.add_style("width: 100%") table.add_style("margin-top: 15px") login_sobj = Search.get_by_code("sthpw/login", login) thumb_div = DivWdg() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 75px") thumb_div = DivWdg() td.add(thumb_div) thumb_div.add_style("overflow: hidden") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(login_sobj) thumb.set_icon_size(60) display_name = login_sobj.get("display_name") td = table.add_cell() td.add_style("padding-top: 3px") name_div = DivWdg() td.add(name_div) name_div.add_style("color", "#214e75") name_div.add_style("font-size", "1.3em") name_div.add(display_name) msg = ""; msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'>"; if date_str != last_date: msg += "<tr><td colspan='2' style='text-align: right'><br/><b style='font-size: 1.0em'>"+date_str+"</b></td></tr>"; last_login = None msg += "<tr><td>" msg += message.replace("\n",'<br/>') msg += "</td><td style='vertical-align: top; text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top; opacity: 0.7;'>"; msg += timestamp_str; msg += "</td></tr></table>"; td.add(msg) last_login = login last_date = date_str history_div.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.scrollTop = bvr.src_el.scrollHeight; ''' } ) if message_logs: last_message = message_logs[-1].get("message") last_login = message_logs[-1].get("login") else: last_message = "" last_login = "" div.add_attr("spt_last_message", last_message) div.add_attr("spt_last_login", last_login) if interval: div.add_behavior( { 'type': 'load', 'key': key, 'cbjs_action': r''' var text_el = bvr.src_el.getElement(".spt_chat_text"); var history_el = bvr.src_el.getElement(".spt_chat_history"); var callback = function(message) { //history_el.setStyle("background", "red"); var login = message.login; var timestamp = message.timestamp; if (timestamp) { var parts = timestamp.split(" "); parts = parts[1].split("."); timestamp = parts[0]; } else { timestamp = ""; } var tmp = message.message || ""; var last_message = bvr.src_el.getAttribute("spt_last_message"); var last_login = bvr.src_el.getAttribute("spt_last_login"); if (tmp == last_message && login == last_login) { return; } bvr.src_el.setAttribute("spt_last_message", tmp); bvr.src_el.setAttribute("spt_last_login", login); var msg = ""; msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'><tr><td>"; if (login != last_login) { msg += "<b>"+login+"</b><br/>"; } msg += tmp.replace(/\n/g,'<br/>'); msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>"; msg += timestamp; msg += "</td></tr></table>"; if (msg == history_el.last_msg) { return; } history_el.innerHTML = history_el.innerHTML + msg; // remember last message history_el.last_msg = msg; history_el.scrollTop = history_el.scrollHeight; } spt.message.set_interval(bvr.key, callback, 3000, bvr.src_el); ''' } ) text = TextAreaWdg("chat") div.add(text) text.add_class("spt_chat_text") text.add_style("width: 100%") text.add_style("padding: 5px") #text.add_style("margin-top: -1px") text.add_style("margin-top: 5px") text.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.addEvent("keydown", function(e) { var keys = ['tab','keys(control+enter)', 'enter']; var key = e.key; var input = bvr.src_el if (keys.indexOf(key) > -1) e.stop(); if (key == 'tab') { } else if (key == 'enter') { if (e.control == false) { pass; } else { // TODO: check if it's multi-line first //... use ctrl-ENTER for new-line, regular ENTER (RETURN) accepts value //var tvals = parse_selected_text(input); //input.value = tvals[0] + "\\n" + tvals[1]; //spt.set_cursor_position( input, tvals[0].length + 1 ); } } } ) ''' } ) button = ActionButtonWdg(title="Send") div.add(button) button.add_style("float: right") button.add_style("margin: 5px") button.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chat_session_top"); var text_el = top.getElement(".spt_chat_text"); var message = text_el.value; if (!message) { return; } var history_el = top.getElement(".spt_chat_history"); var category = "chat"; var server = TacticServerStub.get(); var key = bvr.key; var last_message = server.log_message(key, message, {category:category, status:"in_progress"}); text_el.value = ""; ''' } ) div.add("<br clear='all'/>") return div
def get_buttons_wdg(my): buttons_div = DivWdg() buttons_div.add_style("margin-left: 20px") buttons_div.add_style("margin-right: 20px") # add brush size text_note_wdg = DivWdg() text_note_wdg.add("<b>Text Note</b>") buttons_div.add(text_note_wdg) text_note = TextAreaWdg("spt_text_note") text_note.add_style("width: 400px") text_note.add_class("spt_text_note") buttons_div.add(text_note) from pyasm.widget import IconButtonWdg, IconWdg save_button = IconButtonWdg("Export", IconWdg.SAVE) save_button.add_style("float: right") buttons_div.add(save_button) script = ''' try { function getFlashMovie(movieName) { var isIE = navigator.appName.indexOf("Microsoft") != -1; return (isIE) ? window[movieName] : document[movieName]; } spt.app_busy.show("Exporting Visual Note", " ") var data = getFlashMovie("visual_notes_wdg").visual_notes_export(); var applet = spt.Applet.get(); var server = TacticServerStub.get(); //server.start(); var search_key = bvr.kwargs.search_key; var txt_path = "c:/sthpw/sandbox/temp/visual_notes/visual_notes_temp.txt" var jpg_path = "c:/sthpw/sandbox/temp/visual_notes/visual_notes_temp.jpg" applet.create_file(txt_path, data); applet.decodeFileToFile(txt_path, jpg_path); var top_el = bvr.src_el.getParent(".spt_visual_notes_top"); var context = bvr.kwargs.context; var snapshot = server.simple_checkin(search_key, context, jpg_path); //var note_context = context + "|note"; var note_context = context; var note = top_el.getElement(".spt_text_note").value; var note_sobj = server.insert("sthpw/note", { note: note, context: note_context}, {parent_key: search_key} ); server.connect_sobjects( snapshot, note_sobj); //server.finish("Visual Notes"); spt.app_busy.hide(); alert("Visual note added for [" + context + "]"); } catch(err) { spt.app_busy.hide(); alert(err); } ''' save_button.add_behavior( { 'type': 'click_up', 'cbjs_action': script, 'kwargs': { 'search_key': my.search_key, 'context': my.note_context } }) return buttons_div
def get_display(my): top = my.top view = my.kwargs.get("view") top.add_class("spt_help_edit_content") search = Search("config/widget_config") search.add_filter("category", "HelpWdg") search.add_filter("view", view) sobject = search.get_sobject() if not sobject: value = "" search_key = "" else: xml_value = sobject.get_xml_value("config") value = xml_value.get_value("config/%s/html/div" % (view) ) search_key = sobject.get_search_key() title_wdg = DivWdg() top.add(title_wdg) title_wdg.add("<b>View: %s</b>" % view) title_wdg.add_style("font-style: bold") title_wdg.add_style("padding: 5px") title_wdg.add_gradient("background", "background", 0, -10) hidden = HiddenWdg("view") top.add(hidden) hidden.set_value(view) text = TextAreaWdg("content") text_id = text.set_unique_id() text.set_value(value) from tactic.ui.widget import ActionButtonWdg if sobject: delete_button = ActionButtonWdg(title="Delete") top.add(delete_button) delete_button.add_style("float: right") delete_button.add_style("margin-top: -3px") delete_button.add_behavior( { 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' if (!confirm("Are you sure you wish to delete this help page?")) { return; } var server = TacticServerStub.get(); server.delete_sobject(bvr.search_key); var top = bvr.src_el.getParent(".spt_help_edit_top"); spt.panel.refresh(top); ''' }) test_button = ActionButtonWdg(title="Preview") top.add(test_button) test_button.add_style("float: right") test_button.add_style("margin-top: -3px") test_button.add_behavior( { 'type': 'click_up', 'text_id': text_id, 'cbjs_action': ''' var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); var cmd = "CKEDITOR.instances." + bvr.text_id + ".getData()"; var text_value = eval( cmd ); bvr.options = {}; bvr.options.html = text_value; spt.named_events.fire_event("show_help", bvr) ''' }) save_button = ActionButtonWdg(title="Save") top.add(save_button) save_button.add_style("float: right") save_button.add_style("margin-top: -3px") top.add("<br/>") save_button.add_behavior( { 'type': 'click_up', 'text_id': text_id, 'cbjs_action': ''' spt.app_busy.show("Saving Help", " ") var top = bvr.src_el.getParent(".spt_help_edit_content"); var values = spt.api.Utility.get_input_values(top, null, false); var cmd = "CKEDITOR.instances." + bvr.text_id + ".getData()"; var text_value = eval( cmd ); values.content = text_value; var command = "tactic.ui.app.HelpEditCbk"; var kwargs = values; var server = TacticServerStub.get(); server.execute_cmd(command, kwargs); setTimeout("spt.app_busy.hide()", 200) ''' } ) #top.add("Style: ") #select = SelectWdg("style") #top.add(select) #select.set_option("values", "text|html") top.add("<br/>") top.add(text) text.set_value(value) text.add_style("width: 100%") text.add_style("height: 100%") text.add_style("min-height: 500px") text.add_style("display: none") text.add_behavior( { 'type': 'load', 'color': text.get_color("background", -10), 'text_id': text_id, 'cbjs_action': ''' var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); setTimeout( function() { CKEDITOR.on( 'instanceReady', function( ev ) { ev.editor.dataProcessor.writer.indentationChars = ' '; }); var config = { toolbar: 'Full', uiColor: bvr.color, height: '500px' }; config.toolbar_Full = [ ['Source'], ['Cut','Copy','Paste'], ['Undo','Redo','-','Find','Replace'], ['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], '/', ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['HorizontalRule','SpecialChar'], ['Styles','Format','Font','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks'] ]; CKEDITOR.replace(bvr.text_id, config ); bvr.src_el.setStyle("display", ""); }, 500); ''' } ) return top
def get_import_wdg(my): div = DivWdg() if my.data: div.add("<br/>" * 2) div.add("The following TACTIC share was found: ") div.add("<br/>" * 2) data_input = TextAreaWdg("data") data_input.add_style("display: none") div.add(data_input) #print "xxxx: ", my.data data_str = jsondumps(my.data) #data_str = data_str.replace('"', "'") print "data: ", data_str data_input.set_value(data_str) table = Table() div.add(table) table.set_max_width() table.add_style("margin-left: 20px") table.add_style("margin-right: 20px") for name, value in my.data.items(): name = Common.get_display_title(name) table.add_row() table.add_cell(name) table.add_cell(value) div.add("<br/>" * 2) div.add(my.get_versions_wdg()) div.add("<br/>" * 2) # check to see if the project exists project_code = my.data.get("project_code") project_code = my.data.get("projects") project = Project.get_by_code(project_code) #if project: if False: msg_div = DivWdg() div.add(msg_div) msg_div.add_style("padding: 20px") msg_div.add_color("background", "background3") msg_div.add_color("color", "color") msg_div.add_border() icon = IconWdg("WARNING", IconWdg.WARNING) msg_div.add(icon) icon.add_style("float: left") msg_div.add( "The project with code [%s] already exists. You must remove the installed project before trying to import this one." % project_code) return div if my.data.get("is_encrypted") == "true": div.add( "The transactions in this share is encrypted. Please provide an encryption key to decrypt the transactions<br/><br/>" ) div.add("Encryption Key: ") text = TextWdg("encryption_key") div.add(text) div.add("<br/>" * 2) button = ActionButtonWdg(title="Import >>") button.add_style("float: right") div.add(button) div.add("<br/>" * 2) button.add_behavior({ 'type': 'click_up', 'project_code': project_code, 'cbjs_action': ''' spt.app_busy.show("Importing Project "+bvr.project_code+"..."); var top = bvr.src_el.getParent(".spt_sync_import_top"); var values = spt.api.Utility.get_input_values(top, null, false); var cmd = "tactic.ui.sync.SyncImportCmd"; var server = TacticServerStub.get(); server.execute_cmd(cmd, values, {}, {use_transaction: false}); spt.notify.show_message("Finished importing project"); spt.app_busy.hide(); document.location = '/tactic/'+bvr.project_code; ''' }) return div
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_data_wdg(my): div = DivWdg() from pyasm.biz import Pipeline from pyasm.widget import SelectWdg search_type_obj = SearchType.get(my.search_type) base_type = search_type_obj.get_base_key() search = Search("sthpw/pipeline") search.add_filter("search_type", base_type) pipelines = search.get_sobjects() if pipelines: pipeline = pipelines[0] process_names = pipeline.get_process_names() if process_names: table = Table() div.add(table) table.add_row() table.add_cell("Process: ") select = SelectWdg("process") table.add_cell(select) process_names.append("---") process_names.append("publish") process_names.append("icon") select.set_option("values", process_names) #### buttons = Table() div.add(buttons) buttons.add_row() #button = IconButtonWdg(title="Fill in Data", icon=IconWdg.EDIT) button = ActionButtonWdg(title="Metadata") button.add_style("float: left") button.add_style("margin-top: -3px") buttons.add_cell(button) select_label = DivWdg("Update mode"); select_label.add_style("float: left") select_label.add_style("margin-top: -3px") select_label.add_style("margin-left: 20px") buttons.add_cell(select_label) update_mode_option = my.kwargs.get("update_mode") if not update_mode_option: update_mode_option = "true" update_mode = SelectWdg(name="update mode") update_mode.add_class("spt_update_mode_select") update_mode.set_option("values", ["false", "true", "sequence"]) update_mode.set_option("labels", ["Off", "On", "Sequence"]) update_mode.set_option("default", update_mode_option) update_mode.add_style("float: left") update_mode.add_style("margin-top: -3px") update_mode.add_style("margin-left: 5px") update_mode.add_style("margin-right: 5px") buttons.add_cell(update_mode) update_info = DivWdg() update_info.add_class("glyphicon") update_info.add_class("glyphicon-info-sign") update_info.add_style("float: left") update_info.add_style("margin-top: -3px") update_info.add_style("margin-left: 10px") update_info.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.info("When update mode is on, if a file shares the name of one other file in the asset library, the file will update on ingest. If more than one file shares the name of an ingested asset, a new asset is created.<br> If sequence mode is selected, the system will update the sobject on ingest if a file sequence sharing the same name already exists.", {type: 'html'}); ''' } ) buttons.add_cell(update_info); dialog = DialogWdg(display="false", show_title=False) div.add(dialog) dialog.set_as_activator(button, offset={'x':-10,'y':10}) dialog_data_div = DivWdg() dialog_data_div.add_color("background", "background") dialog_data_div.add_style("padding", "20px") dialog.add(dialog_data_div) # Order folders by date name_div = DivWdg() dialog_data_div.add(name_div) name_div.add_style("margin: 15px 0px") if SearchType.column_exists(my.search_type, "relative_dir"): category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "none") category_div.add(checkbox) category_div.add(" No categories") category_div.add_style("margin-bottom: 5px") checkbox.set_option("checked", "true") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_day") category_div.add(checkbox) category_div.add(" Categorize files by Day") category_div.add_style("margin-bottom: 5px") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_week") category_div.add(checkbox) category_div.add(" Categorize files by Week") category_div.add_style("margin-bottom: 5px") category_div = DivWdg() name_div.add(category_div) checkbox = RadioWdg("category") checkbox.set_option("value", "by_year") category_div.add(checkbox) category_div.add(" Categorize files by Year") category_div.add_style("margin-bottom: 5px") """ checkbox = RadioWdg("category") checkbox.set_option("value", "custom") name_div.add(checkbox) name_div.add(" Custom") """ name_div.add("<br/>") ingest_data_view = my.kwargs.get('ingest_data_view') from tactic.ui.panel import EditWdg sobject = SearchType.create(my.search_type) edit = EditWdg(search_key =sobject.get_search_key(), mode='view', view=ingest_data_view ) dialog_data_div.add(edit) hidden = HiddenWdg(name="parent_key") dialog_data_div.add(hidden) hidden.add_class("spt_parent_key") parent_key = my.kwargs.get("parent_key") or "" if parent_key: hidden.set_value(parent_key) extra_data = my.kwargs.get("extra_data") if not isinstance(extra_data, basestring): extra_data = jsondumps(extra_data) if extra_data and extra_data != "null": # it needs a TextArea instead of Hidden because of JSON data text = TextAreaWdg(name="extra_data") text.add_style('display: none') text.set_value(extra_data) dialog_data_div.add(text) """ dialog_data_div.add("Keywords:<br/>") dialog.add(dialog_data_div) text = TextAreaWdg(name="keywords") dialog_data_div.add(text) text.add_class("spt_keywords") text.add_style("padding: 1px") dialog_data_div.add("<br/>"*2) text.add_class("spt_extra_data") text.add_style("padding: 1px") """ #### TEST Image options """ button = IconButtonWdg(title="Resize", icon=IconWdg.FILM) buttons.add_cell(button) dialog = DialogWdg(display="false", show_title=False) div.add(dialog) dialog.set_as_activator(button, offset={'x':-10,'y':10}) try: from spt.tools.convert import ConvertOptionsWdg convert_div = DivWdg() dialog.add(convert_div) convert_div.add_style("padding: 20px") convert_div.add_color("background", "background") convert_div.add_class("spt_image_convert") convert = ConvertOptionsWdg() convert_div.add(convert) except: pass """ # use base name for name """ name_div = DivWdg() dialog_data_div.add(name_div) name_div.add_style("margin: 15px 0px") checkbox = CheckboxWdg("use_file_name") name_div.add(checkbox) name_div.add(" Use name of file for name") name_div.add("<br/>") checkbox = CheckboxWdg("use_base_name") name_div.add(checkbox) name_div.add(" Remove extension") name_div.add("<br/>") checkbox = CheckboxWdg("file_keywords") name_div.add(checkbox) name_div.add(" Use file name for keywords") """ return div