def get_display(my): # just refresh the whole thing widget = DivWdg() outer_widget = DivWdg(css='spt_view_panel') search_div = DivWdg() search_bvr = { 'type': 'click_up', 'cbjs_action': 'spt.dg_table.search_cbk(evt, bvr)', 'override_class_name': 'tactic.ui.cgapp.AppShotPanelWdg', 'override_target': 'bvr.src_el.getParent(".spt_app_shot_panel")', 'extra_args': {'instance_search_type': my.instance_search_type, 'asset_search_type': my.asset_search_type} #'panel_id': 'main_body_search' } # WARNING: this is made just for main search box and won't be compatible with the simple search wdg search_wdg = SearchWdg(search_type=my.search_type, custom_search_view='search_shot_loader', parent_key='', filter=''\ , display='block', custom_filter_view='', state=None, run_search_bvr=search_bvr) #from tactic.ui.app.simple_search_wdg import SimpleSearchWdg #search_wdg = SimpleSearchWdg(search_type=my.search_type, search_view=my.simple_search_view, state=None, run_search_bvr=search_bvr) search_div.add( HtmlElement.spacer_div(1,10) ) search_div.add(search_wdg) # if there is result, it could only be one shot search = search_wdg.get_search() shots = search.get_sobjects() # avoid getting a shot when no shot is selected if not my.shot_code and len(shots) == 1: my.shot_code = shots[0].get_code() outer_widget.add(search_div) my.set_as_panel(outer_widget, class_name='spt_panel spt_view_panel spt_app_shot_panel') #show_shot_panel = False #if show_shot_panel: panel = ViewPanelWdg( search_type=my.search_type, \ inline_search=True, show_search='false', show_refresh='false', view=my.view, \ run_search_bvr=search_bvr, simple_search_view=my.simple_search_view) panel.set_sobjects(shots) widget.add(panel) show_instances_in_shot = ProdSetting.get_value_by_key("show_instances_in_shot_panel") if show_instances_in_shot != "false": widget.add(HtmlElement.h3("Asset Instances in Shot [%s]" %my.shot_code)) widget.add(HtmlElement.br(2)) asset_inst_panel = AppAssetInstancePanelWdg(search_type=my.search_type, instance_search_type=my.instance_search_type, asset_search_type=my.asset_search_type, shot_code=my.shot_code, show_search='false') widget.add(asset_inst_panel) outer_widget.add(widget) return outer_widget
def get_display(self): from tactic.ui.panel import ViewPanelWdg, CustomLayoutWdg top = self.top detail_view = self.kwargs.get("detail_view") if detail_view: self.kwargs['view'] = detail_view layout = CustomLayoutWdg(**self.kwargs) else: top.add_style("margin: 20px") day = self.kwargs.get("day") title = self.kwargs.get("st_title") title = Common.pluralize(title) title_wdg = DivWdg() top.add(title_wdg) title_wdg.add( "<div style='font-size: 25px'>%s for date: %s</div>" % (title, day)) title_wdg.add("List of %s on this day." % title) title_wdg.add("<hr/>") self.kwargs['show_shelf'] = False layout = ViewPanelWdg(**self.kwargs) top.add(layout) return top
def get_display(my): top = DivWdg() my.set_as_panel(top) search_class = 'tactic.ui.app.simple_search_wdg.SimpleSearchWdg' # for now add a table layout wdg from tactic.ui.panel import ViewPanelWdg my.view = 'manage' my.search_type = my.kwargs.get("search_type") table = ViewPanelWdg(search_type=my.search_type, view=my.view, search_class=search_class) top.add(table) return top
def get_display(my): from tactic.ui.panel import ViewPanelWdg top = my.top top.add_style("margin: 20px") day = my.kwargs.get("day") title = my.kwargs.get("st_title") title = Common.pluralize(title) title_wdg = DivWdg() top.add(title_wdg) title_wdg.add("<div style='font-size: 25px'>%s for date: %s</div>" % (title, day)) title_wdg.add("List of %s that are due on this day." % title) title_wdg.add("<hr/>") my.kwargs['show_shelf'] = False layout = ViewPanelWdg(**my.kwargs) top.add(layout) return top
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_checkout_top") top.add_color("background", "background") top.add_style("width: 800px") inner = DivWdg() top.add(inner) snapshot_codes = my.kwargs.get("snapshot_codes") search_keys = my.kwargs.get("search_keys") if snapshot_codes: if isinstance(snapshot_codes, basestring): snapshots_codes = eval(snapshot_codes) search = Search("sthpw/snapshot") search.add_filters("code", snapshot_codes) snapshots = search.get_sobjects() elif search_keys: if isinstance(search_keys, basestring): search_keys = eval(search_keys) sobjects = Search.get_by_search_keys(search_keys) snapshots = [] for sobject in sobjects: snapshot = Snapshot.get_latest_by_sobject(sobject, process="publish") if snapshot: snapshots.append(snapshot) snapshot_codes = [] for snapshot in snapshots: snapshot_codes.append( snapshot.get("code") ) if not snapshot_codes: no_snapshots_div = DivWdg() no_snapshots_div.add("No files in selection") inner.add(no_snapshots_div) return top sandbox_dir = Environment.get_sandbox_dir("default") project_code = Project.get_project_code() sandbox_dir = "%s/%s" % (sandbox_dir, project_code) base_dir = my.kwargs.get("base_dir") if base_dir: title_div = DivWdg() inner.add(title_div) title_div.add_color("background", "background3") title_div.add_color("color", "color3") title_div.add_style("padding", "15px") title_div.add_style("font-weight: bold") title_div.add("Path: %s" % base_dir) inner.add("Check-out to: %s" % sandbox_dir) button_div = ButtonRowWdg() inner.add(button_div) button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH) button_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); spt.panel.refresh(top) ''' } ) web = WebContainer.get_web() if web.use_applet(): button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT) button_div.add(button) button.add_behavior( { 'type': 'click_up', 'snapshot_codes': snapshot_codes, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); var progress = top.getElement(".spt_checkout_progress"); var message = top.getElement(".spt_checkout_message"); var snapshot_codes = bvr.snapshot_codes; var num_snapshots = snapshot_codes.length; var server = TacticServerStub.get(); for (var i = 0; i < snapshot_codes.length; i++) { var snapshot_code = snapshot_codes[i]; var percent = parseInt( (i+1) / (num_snapshots-1) * 100); var desc = "Checking out: "+(i+1)+" of "+num_snapshots+": "+snapshot_code; progress.setStyle("width", percent + "%"); message.innerHTML = desc; server.checkout_snapshot(snapshot_code, null, {file_types: ['main'], filename_mode: 'source'}); } progress.setStyle("width", "100%"); progress.setStyle("background", "#0F0"); message.innerHTML = "" ''' } ) button = ButtonNewWdg(title="Sandbox", icon=IconWdg.FOLDER_GO) button_div.add(button) button.add_behavior( { 'type': 'click_up', 'sandbox_dir': sandbox_dir, 'cbjs_action': ''' var applet = spt.Applet.get(); applet.open_explorer(bvr.sandbox_dir); ''' } ) msg_div = DivWdg() inner.add(msg_div) msg_div.add_class("spt_checkout_message") msg_div.add(" ") progress_div = DivWdg() inner.add(progress_div) progress_div.add_style("width: auto") progress_div.add_style("height: 15px") progress_div.add_style("margin: 0px 10px 10px 10px") progress_div.add_border() progress = DivWdg() progress.add_class("spt_checkout_progress") progress_div.add(progress) progress.add_style("background", "#F00") progress.add_style("width", "0%") progress.add(" ") snapshot_div = DivWdg() inner.add(snapshot_div) layout = ViewPanelWdg( search_type="sthpw/snapshot", show_shelf=False, edit=False, width="100%", element_names=['preview','file','context','version','timestamp','description'], ) snapshot_div.add(layout) layout.set_sobjects(snapshots[:50]) if my.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_display(self): # just refresh the whole thing widget = DivWdg() outer_widget = DivWdg(css='spt_view_panel') search_div = DivWdg() search_bvr = { 'type': 'click_up', 'cbjs_action': 'spt.dg_table.search_cbk(evt, bvr)', 'override_class_name': 'tactic.ui.cgapp.AppShotPanelWdg', 'override_target': 'bvr.src_el.getParent(".spt_app_shot_panel")', 'extra_args': { 'instance_search_type': self.instance_search_type, 'asset_search_type': self.asset_search_type } #'panel_id': 'main_body_search' } # WARNING: this is made just for main search box and won't be compatible with the simple search wdg search_wdg = SearchWdg(search_type=self.search_type, custom_search_view='search_shot_loader', parent_key='', filter=''\ , display='block', custom_filter_view='', state=None, run_search_bvr=search_bvr) #from tactic.ui.app.simple_search_wdg import SimpleSearchWdg #search_wdg = SimpleSearchWdg(search_type=self.search_type, search_view=self.simple_search_view, state=None, run_search_bvr=search_bvr) search_div.add(HtmlElement.spacer_div(1, 10)) search_div.add(search_wdg) # if there is result, it could only be one shot search = search_wdg.get_search() shots = search.get_sobjects() # avoid getting a shot when no shot is selected if not self.shot_code and len(shots) == 1: self.shot_code = shots[0].get_code() outer_widget.add(search_div) self.set_as_panel( outer_widget, class_name='spt_panel spt_view_panel spt_app_shot_panel') #show_shot_panel = False #if show_shot_panel: panel = ViewPanelWdg( search_type=self.search_type, \ inline_search=True, show_search='false', show_refresh='false', view=self.view, \ run_search_bvr=search_bvr, simple_search_view=self.simple_search_view) panel.set_sobjects(shots) widget.add(panel) show_instances_in_shot = ProdSetting.get_value_by_key( "show_instances_in_shot_panel") if show_instances_in_shot != "false": widget.add( HtmlElement.h3("Asset Instances in Shot [%s]" % self.shot_code)) widget.add(HtmlElement.br(2)) asset_inst_panel = AppAssetInstancePanelWdg( search_type=self.search_type, instance_search_type=self.instance_search_type, asset_search_type=self.asset_search_type, shot_code=self.shot_code, show_search='false') widget.add(asset_inst_panel) outer_widget.add(widget) return outer_widget
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_checkout_top") top.add_color("background", "background") top.add_style("width: 800px") inner = DivWdg() top.add(inner) snapshot_codes = my.kwargs.get("snapshot_codes") search_keys = my.kwargs.get("search_keys") if snapshot_codes: if isinstance(snapshot_codes, basestring): snapshots_codes = eval(snapshot_codes) search = Search("sthpw/snapshot") search.add_filters("code", snapshot_codes) snapshots = search.get_sobjects() elif search_keys: if isinstance(search_keys, basestring): search_keys = eval(search_keys) sobjects = Search.get_by_search_keys(search_keys) snapshots = [] for sobject in sobjects: snapshot = Snapshot.get_latest_by_sobject(sobject, process="publish") if snapshot: snapshots.append(snapshot) snapshot_codes = [] for snapshot in snapshots: snapshot_codes.append(snapshot.get("code")) if not snapshot_codes: no_snapshots_div = DivWdg() no_snapshots_div.add("No files in selection") inner.add(no_snapshots_div) return top sandbox_dir = Environment.get_sandbox_dir("default") project_code = Project.get_project_code() sandbox_dir = "%s/%s" % (sandbox_dir, project_code) base_dir = my.kwargs.get("base_dir") if base_dir: title_div = DivWdg() inner.add(title_div) title_div.add_color("background", "background3") title_div.add_color("color", "color3") title_div.add_style("padding", "15px") title_div.add_style("font-weight: bold") title_div.add("Path: %s" % base_dir) inner.add("Check-out to: %s" % sandbox_dir) button_div = ButtonRowWdg() inner.add(button_div) button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); spt.panel.refresh(top) ''' }) web = WebContainer.get_web() if web.use_applet(): button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'snapshot_codes': snapshot_codes, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); var progress = top.getElement(".spt_checkout_progress"); var message = top.getElement(".spt_checkout_message"); var snapshot_codes = bvr.snapshot_codes; var num_snapshots = snapshot_codes.length; var server = TacticServerStub.get(); for (var i = 0; i < snapshot_codes.length; i++) { var snapshot_code = snapshot_codes[i]; var percent = parseInt( (i+1) / (num_snapshots-1) * 100); var desc = "Checking out: "+(i+1)+" of "+num_snapshots+": "+snapshot_code; progress.setStyle("width", percent + "%"); message.innerHTML = desc; server.checkout_snapshot(snapshot_code, null, {file_types: ['main'], filename_mode: 'source'}); } progress.setStyle("width", "100%"); progress.setStyle("background", "#0F0"); message.innerHTML = "" ''' }) button = ButtonNewWdg(title="Sandbox", icon=IconWdg.FOLDER_GO) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'sandbox_dir': sandbox_dir, 'cbjs_action': ''' var applet = spt.Applet.get(); applet.open_explorer(bvr.sandbox_dir); ''' }) msg_div = DivWdg() inner.add(msg_div) msg_div.add_class("spt_checkout_message") msg_div.add(" ") progress_div = DivWdg() inner.add(progress_div) progress_div.add_style("width: auto") progress_div.add_style("height: 15px") progress_div.add_style("margin: 0px 10px 10px 10px") progress_div.add_border() progress = DivWdg() progress.add_class("spt_checkout_progress") progress_div.add(progress) progress.add_style("background", "#F00") progress.add_style("width", "0%") progress.add(" ") snapshot_div = DivWdg() inner.add(snapshot_div) layout = ViewPanelWdg( search_type="sthpw/snapshot", show_shelf=False, edit=False, width="100%", element_names=[ 'preview', 'file', 'context', 'version', 'timestamp', 'description' ], ) snapshot_div.add(layout) layout.set_sobjects(snapshots[:50]) if my.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_display(my): my.doc_mode = my.kwargs.get("doc_mode") path = my.kwargs.get("path") my.search_type = my.kwargs.get("search_type") my.last_path = None doc_key = my.kwargs.get("doc_key") if doc_key: my.doc = Search.get_by_search_key(doc_key) snapshot = Snapshot.get_latest_by_sobject(my.doc) if snapshot: my.last_path = snapshot.get_lib_path_by_type('main') path = my.doc.get_value("link") # TEST TEST TEST if not path: #path = "/home/apache/pdf/mongodb.txt" #path = "/home/apache/assets/google_docs.html" #path = "/home/apache/pdf/star_wars.txt" path = "https://docs.google.com/document/d/1AC_YR8X8wbKsshkJ1h8EjZuFIr41guvqXq3_PXgaqJ0/pub?embedded=true" path = "https://docs.google.com/document/d/1WPUmXYoSkR2cz0NcyM2vqQYO6OGZW8BAiDL31YEj--M/pub" #path = "https://docs.google.com/spreadsheet/pub?key=0Al0xl-XktnaNdExraEE4QkxVQXhaOFh1SHIxZmZMQ0E&single=true&gid=0&output=html" path = "/home/apache/tactic/doc/alias.json" if not my.search_type: my.search_type = "test3/shot" my.column = "description" top = my.top top.add_class("spt_document_top") my.set_as_panel(top) #table = Table() table = ResizableTableWdg() top.add(table) table.add_row() table.set_max_width() left_td = table.add_cell() left_td.add_style("vertical-align: top") title = DivWdg() left_td.add(title) title.add_style("padding: 10px") title.add_color("background", "background3") button = IconButtonWdg(title="Refresh", icon=IconWdg.REFRESH) title.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.app_busy.show("Reloading Document"); var top = bvr.src_el.getParent(".spt_document_top"); spt.panel.refresh(top); spt.app_busy.hide(); ''' }) button.add_style("float: left") button = IconButtonWdg(title="Save", icon=IconWdg.SAVE) title.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' ''' }) button.add_style("float: left") if not my.doc_mode: my.doc_mode = "text" select = SelectWdg("doc_mode") select.set_option("values", "text|formatted") title.add(select) select.set_value(my.doc_mode) select.add_behavior({ 'type': 'change', 'cbjs_action': ''' spt.app_busy.show("Reloading Document"); var top = bvr.src_el.getParent(".spt_document_top"); var value = bvr.src_el.value; top.setAttribute("spt_doc_mode", value); spt.panel.refresh(top); spt.app_busy.hide(); ''' }) title.add("<br clear='all'/>") #title.add(path) text_wdg = DivWdg() text_wdg.add_class("spt_document_content") left_td.add(text_wdg) #if path.startswith("https://docs.google.com/spreadsheet"): # #path = "http://www.southpawtech.com.com" # text_wdg.add(''' # <iframe class="spt_document_iframe" style="width: 100%%; height: auto; min-height: 600px; font-size: 1.0em" src="%s"></iframe> # ''' % path) # text_wdg.add_style("overflow-x: hidden") if True: if not my.last_path and my.doc: tmp_dir = Environment.get_tmp_dir() tmp_path = '%s/last_path.txt' % tmp_dir f = open(tmp_path, 'w') text = my.get_text(path, highlight=False) f.write(text) f.close() cmd = FileCheckin(my.doc, tmp_path) Command.execute_cmd(cmd) else: save = False if save: # open up the last path f = open(my.last_path, 'r') last_text = f.read() text = my.get_text(path, None, highlight=False) if last_text != text: tmp_dir = Environment.get_tmp_dir() tmp_path = '%s/last_path.txt' % tmp_dir f = open(tmp_path, 'w') f.write(text) f.write(text) f.close() cmd = FileCheckin(my.doc, tmp_path) Command.execute_cmd(cmd) text = my.get_text(path, my.last_path) lines = text.split("\n") if my.doc_mode == "text": num_lines = len(lines) """ line_div = HtmlElement.pre() text_wdg.add(line_div) line_div.add_style("width: 20px") line_div.add_style("float: left") line_div.add_style("text-align: right") line_div.add_style("opacity: 0.3") line_div.add_style("padding-right: 10px") for i in range(0, num_lines*2): line_div.add(i+1) line_div.add("<br/>") """ if my.doc_mode == "text": pre = HtmlElement.pre() pre.add_style("white-space: pre-wrap") else: pre = DivWdg() pre = DivWdg() text_wdg.add(pre) text_wdg.add_style("padding: 10px 5px") text_wdg.add_style("max-height: 600px") text_wdg.add_style("overflow-y: auto") text_wdg.add_style("width: 600px") text_wdg.add_class("spt_resizable") pre.add_style("font-family: courier") if my.doc_mode == "formatted": pre.add(text) else: line_table = Table() pre.add(line_table) line_table.add_style("width: 100%") count = 1 for line in lines: #line = line.replace(" ", " ") tr = line_table.add_row() if count % 2 == 0: tr.add_color("background", "background", -2) td = line_table.add_cell() # FIXME: hacky if line.startswith('''<span style='background: #CFC'>'''): is_new = True else: td.add_style("vertical-align: top") text = TextWdg() text.add_style("border", "none") text.add_style("text-align", "right") text.add_style("width", "25px") text.add_style("margin", "0 10 0 0") text.add_style("opacity", "0.5") text.set_value(count) td.add(text) count += 1 is_new = False td = line_table.add_cell() if not is_new: SmartMenu.assign_as_local_activator(td, 'TEXT_CTX') tr.add_class("spt_line") else: SmartMenu.assign_as_local_activator(td, 'TEXT_NEW_CTX') tr.add_class("spt_new_line") td.add_class("spt_line_content") td.add(line) #from tactic.ui.app import AceEditorWdg #editor = AceEditorWdg(code=text, show_options=False, readonly=True, height="600px") #text_wdg.add(editor) # add a click on spt_item text_wdg.add_relay_behavior({ 'type': 'mouseup', 'bvr_match_class': 'spt_document_item', 'search_type': my.search_type, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_document_top"); var data_el = top.getElement(".spt_document_data"); var search_key = bvr.src_el.getAttribute("spt_search_key"); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': bvr.search_type, 'search_key': search_key, } spt.panel.load(data_el, class_name, kwargs); ''' }) # add a double click on spt_item bgcolor = text_wdg.get_color("background", -10) text_wdg.add_relay_behavior({ 'type': 'mouseover', 'bvr_match_class': 'spt_document_item', 'search_type': my.search_type, 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("opacity", "1.0"); //bvr.src_el.setStyle("font-weight", "normal"); bvr.src_el.setStyle("background", bvr.bgcolor); ''' }) # add a double click on spt_item text_wdg.add_relay_behavior({ 'type': 'mouseout', 'bvr_match_class': 'spt_document_item', 'search_type': my.search_type, 'cbjs_action': ''' bvr.src_el.setStyle("opacity", "1.0"); //bvr.src_el.setStyle("font-weight", "bold"); bvr.src_el.setStyle("background", ""); ''' }) # add a context menu ctx_menu = my.get_text_context_menu() ctx_new_menu = my.get_text_new_context_menu() menus_in = { 'TEXT_CTX': ctx_menu, 'TEXT_NEW_CTX': ctx_new_menu, } SmartMenu.attach_smart_context_menu(text_wdg, menus_in, False) panel = ViewPanelWdg(search_type=my.search_type, layout="blah") right_td = table.add_cell() right_td.add_style("vertical-align: top") panel_div = DivWdg() panel_div.add_class("spt_document_data") right_td.add(panel_div) panel_div.add(panel) text_wdg.add_behavior({ 'type': 'load', 'cbjs_action': r''' spt.document = {}; spt.document.selected_text = null; spt.document.get_selected_text = function(frame) { var t = ''; if (frame) { var rng = frame.contentWindow.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (window.getSelection) // FF4 with one tab open? { var rng = window.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (document.getSelection) // FF4 with multiple tabs open? { var rng = document.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (document.selection) // IE8 { var rng = document.selection.createRange(); // expand range to enclose any word partially enclosed in it rng.expand("word"); t = rng.text; } // convert newline chars to spaces, collapse whitespace, and trim non-word chars return t.replace(/^\W+|\W+$/g, ''); //return t.replace(/\r?\n/g, " ").replace(/\s+/g, " ").replace(/^\W+|\W+$/g, ''); } // expand FF range to enclose any word partially enclosed in it spt.document.expandtoword = function(range) { if (range.collapsed) { return; } while (range.startOffset > 0 && range.toString()[0].match(/\w/)) { range.setStart(range.startContainer, range.startOffset - 1); } while (range.endOffset < range.endContainer.length && range.toString()[range.toString().length - 1].match(/\w/)) { range.setEnd(range.endContainer, range.endOffset + 1); } } ''' }) top.add_relay_behavior({ 'type': 'mouseup', 'bvr_match_class': 'spt_document_content', 'cbjs_action': r''' //spt.ace_editor.set_editor_top(bvr.src_el); //var text = spt.ace_editor.get_selection(); var text = spt.document.get_selected_text(); text = text.replace(/\n\n/mg, "\n"); text = text.replace(/\n\n/mg, "\n"); spt.document.selected_text = text + ""; ''' }) return top
def get_display(self): top = self.top self.set_as_panel(top) top.add_class("spt_checkin_dependency_top") top.add_color("background", "background") top.add_color("color", "color") top.add_style("width: 800px") title = DivWdg() top.add(title) title.add("Current Dependencies") title.add_color("color", "color3") title.add_color("background", "background3") title.add_style("font-size: 1.2em") title.add_style("font-weight: bold") title.add_style("padding: 10px 10px") # Not sure what to do with this yet search_key = self.kwargs.get("search_key") search_key = None snapshot_key = self.kwargs.get("snapshot_key") process = self.kwargs.get("process") if not process: process = "publish" if snapshot_key: snapshot = Search.get_by_search_key(snapshot_key) elif search_key: sobject = Search.get_by_search_key(search_key) snapshot = Snapshot.get_latest_by_sobject(sobject, process=process) else: snapshot = None #context = self.kwargs.get("context") #context = "publish/X6.tex" from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Browse") button.add_style("float: left") top.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var files = applet.open_file_browser(); alert(files); ''' }) from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Clipboard") button.add_style("float: left") top.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': r''' var server = TacticServerStub.get(); var items = server.eval("@SOBJECT(sthpw/clipboard['category','select']['login',$LOGIN])") var search_keys = spt.table.get_all_search_keys(); for (var i = 0; i < items.length; i++) { var item = items[i]; var search_key = item.search_type + "&code=" + item.search_code; search_keys.push(search_key); } var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); top.setAttribute("spt_snapshot_keys", search_keys.join("|")) spt.panel.refresh(top); spt.tab.set_tab_top_from_child(bvr.src_el); var content = spt.tab.get_content("Dependency"); var activator = content.activator; activator.setAttribute("spt_depend_keys", search_keys.join("|")); ''' }) button = ActionButtonWdg(title="Remove") button.add_style("float: left") top.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); var layout = top.getElement(".spt_layout"); spt.table.set_layout(layout); spt.table.remove_selected(); var search_keys = spt.table.get_all_search_keys(); alert(search_keys); spt.tab.set_tab_top_from_child(bvr.src_el); var content = spt.tab.get_content("Dependency"); var activator = content.activator; activator.setAttribute("spt_depend_keys", search_keys.join("|")); activator.setStyle("border", "solid 1px green"); ''' }) """ button = ActionButtonWdg(title="Attach") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); var layout = top.getElement(".spt_layout"); spt.table.set_layout(layout); var search_keys = spt.table.get_selected_search_keys(); ''' } ) """ top.add("<br clear='all'/>") sobject_wdg = DivWdg() top.add(sobject_wdg) #text = TextInputWdg("search_type") #sobject_wdg.add(text) depend_keys = self.kwargs.get("depend_keys") if isinstance(depend_keys, basestring): depend_keys = depend_keys.split("|") if depend_keys: ref_snapshots = Search.get_by_search_keys(depend_keys) elif snapshot: # get the already existing snapshots ref_snapshots = snapshot.get_all_ref_snapshots(snapshot) else: ref_snapshots = [] snapshot_keys = self.kwargs.get("snapshot_keys") if snapshot_keys: snapshot_keys = snapshot_keys.split("|") extra_snapshots = Search.get_by_search_keys(snapshot_keys) for extra_snapshot in extra_snapshots: extra_snapshot = Snapshot.get_latest_by_sobject( extra_snapshot, process=process) if extra_snapshot: ref_snapshots.append(extra_snapshot) if not ref_snapshots: return top #print "ref: ", ref_snapshots search_type = "jobs/media" search_type = "sthpw/snapshot" from tactic.ui.panel import ViewPanelWdg panel = ViewPanelWdg( search_type=search_type, show_shelf=False, ) #layout='tile', panel.set_sobjects(ref_snapshots) top.add(panel) return top
def get_display(my): expr_filter = "sthpw/login['login','not in','admin|guest']['begin']['license_type','user']['license_type','is','NULL']['or']" current_users = Search.eval("@COUNT(%s)" %expr_filter) top = my.top top.add_class("spt_panel_user_top") top.add_style("min-width: 400px") tool_div = DivWdg() # tool_div.add_style('margin-bottom','8px') tool_div.add_style('display','inline-flex') tool_div.add_style('width','50%') tool_div.add_style('margin-bottom','-4px') button = ActionButtonWdg(title="Add", tip="Add New User") button.add_style('align-self: flex-end') tool_div.add(button) button.add_style("float: left") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/login", view: "insert", show_header: false, } var popup = spt.panel.load_popup("Create New User", class_name, kwargs); var top = bvr.src_el.getParent(".spt_panel_user_top"); popup.on_save_cbk = function() { spt.panel.refresh(top); } ''' } ) security = Environment.get_security() license = security.get_license() num_left = license.get_num_licenses_left() current_users = license.get_current_users() #max_users = license.get_max_users() div = DivWdg('Users') div.add_style('align-self: flex-end') div.add_styles("margin: 0 0 6px 20px") badge_span = SpanWdg(css='badge') badge_span.add_style('margin-left','6px') badge_span.add(current_users) div.add(badge_span) tool_div.add(div) tool_div2 = DivWdg() # tool_div.add_style('margin-bottom','8px') tool_div2.add_style('display','inline-flex') tool_div2.add_style('justify-content','flex-end') tool_div2.add_style('width','50%') top.add(tool_div) top.add(tool_div2) if num_left < 1000: div = DivWdg('Users Left') div.add_style('align-self: flex-end') div.add_styles("margin: 0 0 6px 20px") badge_span = SpanWdg(css='badge') badge_span.add_style('margin-left','6px') badge_span.add(num_left) div.add(badge_span) tool_div.add(div) top.add(tool_div) show_security = my.kwargs.get("show_security") if show_security not in ['false', False]: button = ActionButtonWdg(title="Security") button.add_style('align-self: flex-end') #button.add_styles("position: absolute; right: 10px;") tool_div2.add(button) #button.add_style("margin-top: -8px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.SecurityWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("Security", "Security", class_name) ''' } ) br = HtmlElement.br(clear=True) top.add(br) if not current_users: div = DivWdg() top.add(div) div.add_style("text-align: center") div.add_border() div.add_style("min-height: 150px") div.add_style("margin: 15px 30px 30px 30px") div.add_style("padding: 30px 20px 0px 20px") div.add_color("background", "background3") icon = IconWdg( "WARNING", IconWdg.WARNING ) div.add(icon) div.add("<b>No users have been added</b>") div.add("<br/><br/>") div.add("For more information, read the help docs: ") from tactic.ui.app import HelpButtonWdg help = HelpButtonWdg(alias=my.get_help_alias()) div.add(help) div.add("<br/>") div.add("Click on the 'Add' button above to start adding new users.") return top div = DivWdg() top.add(div) #div.add_style("max-height: 300px") #div.add_style("overflow-y: auto") expr = "@SEARCH(%s)" %expr_filter panel = ViewPanelWdg(search_type='sthpw/login',view='manage_user',show_insert='false',\ show_gear='false', show_select='false', height='700', expression=expr,\ simple_search_view='simple_manage_filter', show_column_manager='false',\ show_layout_switcher='false', show_expand='false') div.add(panel) div.add_style('margin-top', '4px') return top """
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_checkin_dependency_top") top.add_color("background", "background") top.add_color("color", "color") top.add_style("width: 800px") title = DivWdg() top.add(title) title.add("Current Dependencies") title.add_color("color", "color3") title.add_color("background", "background3") title.add_style("font-size: 1.2em") title.add_style("font-weight: bold") title.add_style("padding: 10px 10px") # Not sure what to do with this yet search_key = my.kwargs.get("search_key") search_key = None snapshot_key = my.kwargs.get("snapshot_key") process = my.kwargs.get("process") if not process: process = "publish" if snapshot_key: snapshot = Search.get_by_search_key(snapshot_key) elif search_key: sobject = Search.get_by_search_key(search_key) snapshot = Snapshot.get_latest_by_sobject(sobject, process=process) else: snapshot = None #context = my.kwargs.get("context") #context = "publish/X6.tex" from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Browse") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var files = applet.open_file_browser(); alert(files); ''' } ) from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Clipboard") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': r''' var server = TacticServerStub.get(); var items = server.eval("@SOBJECT(sthpw/clipboard['category','select']['login',$LOGIN])") var search_keys = spt.table.get_all_search_keys(); for (var i = 0; i < items.length; i++) { var item = items[i]; var search_key = item.search_type + "&code=" + item.search_code; search_keys.push(search_key); } var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); top.setAttribute("spt_snapshot_keys", search_keys.join("|")) spt.panel.refresh(top); spt.tab.set_tab_top_from_child(bvr.src_el); var content = spt.tab.get_content("Dependency"); var activator = content.activator; activator.setAttribute("spt_depend_keys", search_keys.join("|")); ''' } ) button = ActionButtonWdg(title="Remove") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); var layout = top.getElement(".spt_layout"); spt.table.set_layout(layout); spt.table.remove_selected(); var search_keys = spt.table.get_all_search_keys(); alert(search_keys); spt.tab.set_tab_top_from_child(bvr.src_el); var content = spt.tab.get_content("Dependency"); var activator = content.activator; activator.setAttribute("spt_depend_keys", search_keys.join("|")); activator.setStyle("border", "solid 1px green"); ''' } ) """ button = ActionButtonWdg(title="Attach") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); var layout = top.getElement(".spt_layout"); spt.table.set_layout(layout); var search_keys = spt.table.get_selected_search_keys(); ''' } ) """ top.add("<br clear='all'/>") sobject_wdg = DivWdg() top.add(sobject_wdg) #text = TextInputWdg("search_type") #sobject_wdg.add(text) depend_keys = my.kwargs.get("depend_keys") print "depend_keys: ", depend_keys if isinstance(depend_keys, basestring): depend_keys = depend_keys.split("|") if depend_keys: ref_snapshots = Search.get_by_search_keys(depend_keys) elif snapshot: # get the already existing snapshots ref_snapshots = snapshot.get_all_ref_snapshots(snapshot) else: ref_snapshots = [] snapshot_keys = my.kwargs.get("snapshot_keys") if snapshot_keys: snapshot_keys = snapshot_keys.split("|") extra_snapshots = Search.get_by_search_keys(snapshot_keys) for extra_snapshot in extra_snapshots: extra_snapshot = Snapshot.get_latest_by_sobject(extra_snapshot, process=process) if extra_snapshot: ref_snapshots.append(extra_snapshot) if not ref_snapshots: return top print "ref: ", ref_snapshots search_type = "jobs/media" search_type = "sthpw/snapshot" from tactic.ui.panel import ViewPanelWdg panel = ViewPanelWdg( search_type=search_type, show_shelf=False, ) #layout='tile', panel.set_sobjects(ref_snapshots) top.add(panel) return top