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(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(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): 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