def get_left_wdg(my, view="layout"): search_type = my.get_left_search_type() search = Search(search_type) left_div = DivWdg() left_div.add_style("margin: 10px") title = DivWdg(css="maq_search_bar") title.add(search.get_search_type_obj().get_title()) left_div.add(title) asset_filter = my.get_left_filter(search) if asset_filter: filter_box = DivWdg(asset_filter, css='filter_box') left_div.add(filter_box) asset_filter.alter_search(search) #assets_table = TableWdg(search_type, view) from tactic.ui.panel import TableLayoutWdg assets_table = TableLayoutWdg(table_id='table_left', search_type=search_type, view=view) assets_table.set_sobjects(search.get_sobjects(), search) left_div.add(assets_table) return left_div
def get_display(self): # create the asset tab widget = DivWdg(css="spt_view_panel") self.set_as_panel(widget) search_wdg = self.get_search_wdg() widget.add(search_wdg) widget.add(HtmlElement.br()) search = search_wdg.get_search() # the filter for searching assets #div = DivWdg(css="filter_box") #snap_filter = SnapshotFilterWdg() #div.add(snap_filter) #widget.add(div) table_id = "main_body_table" from tactic.ui.panel import TableLayoutWdg snap_table = TableLayoutWdg(table_id=table_id, search_type=Snapshot.SEARCH_TYPE, \ view="log", inline_search=True) snap_table.alter_search(search) widget.add(snap_table) search.add_order_by("timestamp desc") sobjects = search.get_sobjects() #search.add_filter("login", Environment.get_login().get_login()) #widget.set_search(search) snap_table.set_sobjects(sobjects, search) return widget
def get_right_wdg(my, view="layout"): search_type = my.get_right_search_type() search = Search(search_type) right_div = DivWdg() right_div.add_style("margin: 10px") title = DivWdg(css="maq_search_bar") title.add(search.get_search_type_obj().get_title()) right_div.add(title) shot_filter = my.get_right_filter(search) if shot_filter: shot_filter.alter_search(search) filter_wdg = DivWdg(css="filter_box") if shot_filter: filter_wdg.add(shot_filter) right_div.add(filter_wdg) from tactic.ui.panel import TableLayoutWdg shots_table = TableLayoutWdg(table_id='table_right', search_type=search_type, view=view) #shots_table = TableWdg(my.get_right_search_type(), view) shots_table.set_sobjects(search.get_sobjects(), search) right_div.add(shots_table) return right_div
def check(my): if my.mode == 'export_matched': from tactic.ui.panel import TableLayoutWdg table = TableLayoutWdg(search_type=my.search_type, view=my.view,\ show_search_limit='false', search_limit=-1, search_view=my.search_view,\ search_class=my.search_class, simple_search_view=my.simple_search_view, init_load_num=-1) table.handle_search() search_objs = table.sobjects my.selected_search_keys = SearchKey.get_by_sobjects(search_objs, use_id=True) return True for sk in my.input_search_keys: st = SearchKey.extract_search_type(sk) if st not in my.search_type_list: my.search_type_list.append(st) id = SearchKey.extract_id(sk) if id == '-1': continue my.selected_search_keys.append(sk) if len(my.search_type_list) > 1: my.check_passed = False my.error_msg = 'More than 1 search type is selected. Please keep the selection to one type only.' return False if not my.search_type_list and my.mode == 'export_selected': my.check_passed = False my.error_msg = 'Search type cannot be identified. Please select a valid item.' return False return True
def get_display(self): top = self.top self.set_as_panel(top) top.set_unique_id() top.add_style("min-width: 600px") top.add_style("max-height: 600px") top.add_style("overflow-y: auto") top.add_color("background", "background") top.add_color("color", "color") sobject = self.kwargs.get("sobject") if not sobject: search_key = self.kwargs.get("search_key") sobject = Search.get_by_search_key(search_key) else: search_key = sobject.get_search_key() context = self.kwargs.get("context") search = Search("sthpw/note") #search.add_relationship_filters(self.filtered_parents, type='hierarchy') search.add_parent_filter(sobject) search.add_order_by("process") search.add_order_by("context") search.add_order_by("timestamp desc") if context: search.add_filter("context", context) notes = search.get_sobjects() top.add_smart_style("spt_note", "padding", "15px") for i, note in enumerate(notes): note_div = DivWdg() top.add(note_div) note_div.add(self.get_note_wdg(note)) if i % 2 == 0: note_div.add_color("background", "background", -3) top.add("<br/><hr/><br/>") from tactic.ui.panel import TableLayoutWdg table = TableLayoutWdg( search_type="sthpw/note", show_shelf=False, show_select=False, element_names=['login', 'timestamp', 'note', 'delete']) table.set_sobjects(notes) top.add(table) return top
def get_table(my, sobject, snapshots): parent_key = SearchKey.get_by_sobject(sobject) table = TableLayoutWdg(table_id='snapshot_history_table', search_type='sthpw/snapshot', view='checkin_history', show_search_limit=False, show_gear=False, show_insert=False, parent_key=parent_key, mode='simple') table.set_sobjects(snapshots) return table """
def get_display(self): top = DivWdg() self.set_as_panel(top) sobject = SearchType.create("sthpw/virtual") sobject.set_value("mon", "3") sobject.set_value("tue", "2") sobject.set_value("wed", "5") config = ''' <week> <element name="week"/> <element name="parent"/> <element name="category"/> <element name="description"/> <element name="mon"/> <element name="tue"/> <element name="wed"/> <element name="thu"/> <element name="fri"/> <element name="total"/> </week> ''' table = TableLayoutWdg(search_type='sthpw/virtual', view='week') top.add(table) return top
def check(my): if my.mode == 'export_matched': from tactic.ui.panel import TableLayoutWdg my.table = TableLayoutWdg(search_type=my.search_type, view=my.view,\ show_search_limit='false', search_limit=-1, search_view=my.search_view,\ search_class=my.search_class, simple_search_view=my.simple_search_view, init_load_num=-1) my.table.handle_search() search_objs = my.table.sobjects my.selected_search_keys = SearchKey.get_by_sobjects(search_objs, use_id=True) return True for sk in my.input_search_keys: st = SearchKey.extract_search_type(sk) if st not in my.search_type_list: my.search_type_list.append(st) id = SearchKey.extract_id(sk) if id == '-1': continue my.selected_search_keys.append(sk) if len(my.search_type_list) > 1: my.check_passed = False my.error_msg = 'More than 1 search type is selected. Please keep the selection to one type only.' return False if not my.search_type_list and my.mode == 'export_selected': my.check_passed = False my.error_msg = 'Search type cannot be identified. Please select a valid item.' return False return True
def get_table(my, sobject, snapshots): parent_key = SearchKey.get_by_sobject(sobject) table = TableLayoutWdg( table_id="snapshot_history_table", search_type="sthpw/snapshot", view="checkin_history", show_search_limit=False, show_gear=False, show_insert=False, parent_key=parent_key, mode="simple", ) table.set_sobjects(snapshots) return table """
def get_display(my): widget = DivWdg() my.set_as_panel(widget, class_name='spt_view_panel spt_panel') # create a table widget and set the sobjects to it table_id = "main_body_table" table = TableLayoutWdg(table_id=table_id, search_type="sthpw/notification_log", \ view="table", inline_search=True, search_view='search') search_type = "sthpw/notification_log" from tactic.ui.app import SearchWdg search_wdg = SearchWdg(search_type=search_type, view='search') widget.add(search_wdg) search = search_wdg.get_search() table.alter_search(search) sobjects = search.get_sobjects() table.set_sobjects(sobjects, search) widget.add(table) return widget
def get_display(my): widget = DivWdg() my.set_as_panel(widget, class_name='spt_view_panel spt_panel') # create a table widget and set the sobjects to it table_id = "main_body_table" filter = my.kwargs.get('filter') table = TableLayoutWdg(table_id=table_id, search_type="sthpw/timecard", \ view="table", inline_search=True, filter=filter, search_view='search' ) search_type = "sthpw/timecard" from tactic.ui.app import SearchWdg search_wdg = SearchWdg(search_type=search_type, view='search', filter=filter) widget.add(search_wdg) search = search_wdg.get_search() # FIX to current project timecard for now search.add_filter('project_code', Project.get_project_code()) #search.add_project_filter() table.alter_search(search) print "SEA ", search.get_statement() sobjects = search.get_sobjects() print "SOB ", sobjects table.set_sobjects(sobjects, search) widget.add(table) #widget.add(SpecialDayWdg()) return widget
def get_display(self): widget = DivWdg(css="spt_view_panel") search_wdg = self.get_search_wdg() widget.add(search_wdg) widget.add(HtmlElement.br()) search = search_wdg.get_search() type = self.kwargs.get('type') view = self.kwargs.get('view') if not view: view = 'table' table_id = "main_body_table" table = TableLayoutWdg(table_id=table_id, search_type=Submission.SEARCH_TYPE, \ view=view, inline_search=True) table.alter_search(search) sobjs = search.get_sobjects(redo=True) table.set_sobjects(sobjs, search) widget.add(table) return widget
def get_display(my): if my.is_refresh: top = Widget() my.add(top) web = WebContainer.get_web() my.checked_processes = web.get_form_values('process_names') left_checked_processes = web.get_form_values('left_process_names') right_checked_processes = web.get_form_values( 'right_process_names') is_split_view = web.get_form_values('split_view') == 'true' else: top = my.get_viewer() my.process_names = [x for x in my.process_names if x] if my.is_refresh: if my.process_names: table = Table() table.add_row() td = table.add_cell() expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join( my.process_names) table_id = 'main_table_left' left_table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\ show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression ) if my.resize: from tactic.ui.container import ResizeScrollWdg inner_wdg = ResizeScrollWdg(width='500px', height='500px', scroll_bar_size_str='thick', scroll_expansion='inside') inner_wdg.add(left_table) td.add(inner_wdg) else: td.add(left_table) top.add(table) return top
def get_display(self): widget = DivWdg() self.set_as_panel( widget, class_name='spt_view_panel spt_panel spt_app_asset_inst_panel') parent_search_type = self.search_type if self.show_search: # Have to limit this search to just its parent.. cuz if the target is prod/shot_instance # and its parent search is ShotFilterWdg, it's hard to isolate what shot has been selected search_bvr = { 'type': 'click_up', 'cbjs_action': 'spt.dg_table.search_cbk(evt, bvr)', 'override_class_name': 'tactic.ui.cgapp.AppAssetInstancePanelWdg', 'override_target': "bvr.src_el.getParent('.spt_app_asset_inst_panel')" } search_wdg = SearchWdg(search_type=parent_search_type, view='search_shot_loader', parent_key='', filter=''\ , display='block', custom_filter_view='', state=None, run_search_bvr=search_bvr) widget.add(HtmlElement.spacer_div(1, 10)) widget.add(search_wdg) # if there is result, it could only be one shot search = search_wdg.get_search() shots = search.get_sobjects() if not self.shot and len(shots) == 1: self.shot = shots[0] # create the asset table table_id = "main_body_asset_instance_table" if not self.shot: return widget # get any parent shots parent_code = self.shot.get_value("parent_code") shot_code = self.shot.get_code() # add the search make sure set elements are not shown search = Search(self.instance_search_type) if parent_code != "": search.add_filters(self.shot.get_foreign_key(), [shot_code, parent_code]) else: search.add_filter(self.shot.get_foreign_key(), shot_code) search.add_where("\"type\" in ('set_item', 'asset')") search.add_order_by('asset_code') instances = search.get_sobjects() # if parent shot and current shot has the same instance, hide the # parent's one top_instances = [] for instance in instances: if instance.get_value('type') != 'set_item': top_instances.append(instance) #instances = ShotInstance.filter_instances(instances, shot_code) top_instances = ShotInstance.filter_instances(top_instances, shot_code) # TODO: just add asset name to the ShotInstance table # get the original asset names aux_data = ShotInstance.get_aux_data(top_instances, self.asset_search_type) values = FilterData.get().get_values_by_index('view_action_option', 0) state = {} if not self.show_search: if values: state['process'] = values.get('load_%s_process' % parent_search_type) else: process_filter = ProcessFilterWdg(None, parent_search_type) state['process'] = process_filter.get_value() Container.put("global_state", state) from tactic.ui.cgapp import CGAppLoaderWdg cg_wdg = CGAppLoaderWdg(view='load', search_type=self.instance_search_type) widget.add(cg_wdg) if not top_instances: widget.add('No Asset Instances in Shot.') else: asset_table = TableLayoutWdg(table_id = table_id, search_type=self.instance_search_type,\ view="load", inline_search=False, aux_info = aux_data, mode='simple') #asset_table = ViewPanelWdg( search_type=search_type, inline_search=False, \ # show_general_search=False, view='load', state=state, mode='simple') asset_table.set_sobjects(top_instances) widget.add(asset_table) shot_inst_names = [inst.get_code() for inst in instances] self.add_unassigned_instances(widget, shot_inst_names) return widget
def get_category_wdg2(self, paths, title=None, tags={}): if not paths: paths = [] div = DivWdg() if not title: title = "Paths" div.add("%s (%s)<hr/>" % (title, len(paths)) ) #if not paths: # div.add("-- None --<br/>") table = Table() div.add(table) table.add_color("color", "color") base_dir = self.kwargs.get("base_dir") sobjects = [] tags_keys = set() for path in paths: sobject = SearchType.create("sthpw/virtual") basename = os.path.basename(path) dirname = os.path.dirname(path) # FIXME: need session base reldir = dirname.replace("%s" % base_dir, "") reldir = dirname if not reldir: reldir = ' ' else: reldir.lstrip("/") if not basename: basename = ' ' sobject.set_value("folder", reldir) sobject.set_value("file_name", basename) sobjects.append(sobject) if tags: path_tags = tags.get(path) if path_tags: for key, value in path_tags.get("sobject").items(): sobject.set_value(key, value) tags_keys.add(key) from tactic.ui.panel import TableLayoutWdg element_names = ['path'] element_names.extend( list(tags_keys) ) #show_metadata = False #if not show_metadata: # element_names.remove('metadata') config_xml = self.get_config_xml(list(tags_keys)) layout = TableLayoutWdg(search_type='sthpw/virtual', view='report', config_xml=config_xml, element_names=element_names, mode='simple') # FIXME: just show first 200 results layout.set_sobjects(sobjects[:200]) div.add(layout) return div
def get_viewer(my): top = DivWdg(css='spt_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('main context') split_div = FloatDivWdg(css='spt_split_cb') div = DivWdg(css='spt_main_context_cb') content_div = DivWdg() content_div.add_color('color', 'color') content_div.add_style('padding: 10px') SwapDisplayWdg.create_swap_title(title, swap, content_div, is_open=False) div.add(swap) div.add(title) checkbox_name = 'split_screen' split_cb = CheckboxWdg(checkbox_name, label='Split View') split_cb.persistence = True split_cb.persistence_obj = split_cb key = split_cb.get_key() #cb.add_style('float: left') split_cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top"); var table_top = top.getElement(".spt_note_viewer_table"); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_context_cb; var kwargs = { process_names: processes}; if (bvr.src_el.checked) { kwargs.split_view = 'true'; kwargs.show_context = 'true'; kwargs.left_process_names = processes; kwargs.right_process_names = processes; } spt.input.save_selected(bvr, '%s','%s'); spt.app_busy.show("Note Viewer", 'Loading') ; setTimeout(function(){ spt.panel.refresh(table_top, kwargs, false); if (bvr.src_el.checked) spt.hide(cbs); else spt.show(cbs); spt.app_busy.hide(); }, 50 ); ''' % (checkbox_name, key) }) split_div.add(split_cb) top.add(split_div) top.add(div) div.add(content_div) top.add(HtmlElement.br()) checkbox_name = 'note_main_context_cb' cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb my.checked_process_names = cb.get_values() for value in my.process_names: #my.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in my.checked_process_names: my.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_main_context_cb; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, key) }) content_div.add(cb) table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join( my.checked_processes) if split_cb.is_checked(): table = my.get_split_viewer() else: table_id = 'main_table1' table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\ show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression ) my.set_as_panel(table_top) table_top.add_style('float: left') top.add(table_top) table_top.add(table) return top
def get_display(my): if my.is_refresh: top = Widget() my.add(top) else: container = DivWdg() my.add(container) #parent = SearchKey.get_by_search_key(my.search_key) top = DivWdg() container.add(top) my.set_as_panel(top) top.add_style("margin-top: -2px") top.add_class("spt_uber_notes_top") from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias="note-sheet-widget") top.add(help_button) help_button.add_style("float: right") table_id = 'sub_table' view = 'table' span = DivWdg(css='spt_input_group') top.add(span) span.add_border() span.add_style("height: 27px") span.add_style("padding: 5px") button_div = DivWdg() span.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-right: 10px") table = Table() button_div.add(table) table.add_row() from tactic.ui.widget import SingleButtonWdg refresh = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH) table.add_cell(refresh) refresh.add_style("float: left") refresh.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var values = spt.api.Utility.get_input_values(tbody); spt.panel.refresh(top, values, false); ''' }) save = SingleButtonWdg(title="Save", icon=IconWdg.SAVE) table.add_cell(save) save.add_style("float: left") save.add_behavior({ 'type': 'click_up', 'update_current_only': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var table = top.getElement(".spt_table"); bvr.src_el = table; spt.dg_table.update_row(evt, bvr) ''' }) process = SingleButtonWdg(title="Show Processes", icon=IconWdg.PROCESS, show_arrow=True) table.add_cell(process) from tactic.ui.container import DialogWdg process_dialog = DialogWdg(display=False) span.add(process_dialog) process_dialog.set_as_activator(process) process_dialog.add_title("Processes") process_div = DivWdg() process_dialog.add(process_div) #process_div.add_style("padding: 5px") process_div.add_color("background", "background") process_div.add_color("color", "color") process_div.add_border() refresh = ActionButtonWdg(title="Refresh") refresh.add_style('margin: 0 auto 10px auto') process_div.add(refresh) refresh.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var values = spt.api.Utility.get_input_values(tbody); spt.panel.refresh(top, values, false); ''' }) process_div.add("<hr/>") selected_process_names = [] step = 0 for idx, value in enumerate(my.process_names): checkbox_name = 'note_process_cb' if my.child_mode: selected_process_names.append(value) #break cb = CheckboxWdg(checkbox_name, label=value) cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) #cb.set_persistence() cb.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.input.save_selected(bvr, '%s','%s'); ''' % (checkbox_name, key) }) # only 1 is selected in child_mode if cb.is_checked(): selected_process_names.append(value) if idx == 0 or idx == 10 * step: # add a new inner div inner_div = my._get_inner_div() process_div.add(inner_div, 'inner%s' % step) step += 1 inner_div.add(cb) inner_div.add("<br/>") # if less than 10, make it wider if len(my.process_names) < 10: inner_div.add_style('width: 100px') # add a master private checkbox if not my.child_mode: checkbox_name = 'note_master_private_cb' cb = CheckboxWdg(checkbox_name, label='make notes private') cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var inputs = spt.api.Utility.get_inputs(tbody,'is_private'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = bvr.src_el.checked; spt.input.save_selected(bvr, '%s','%s'); ''' % (checkbox_name, key) }) cb_span = DivWdg(cb, css='small') cb_span.add_styles( 'border-left: 1px dotted #bbb; margin-left: 10px') span.add(cb_span) main_config_view = my._get_main_config(view, selected_process_names) sobject_dict = {} # TODO: do a union all search or by order number = 1 for value in selected_process_names: search = Search('sthpw/note') search.add_filter('project_code', Project.get_project_code()) search.add_filter('context', value) search.add_filter('search_type', my.parent_search_type) search.add_filter('search_id', my.parent_search_id) search.add_order_by('timestamp desc') search.add_limit(1) sobject = search.get_sobject() if sobject: sobject_dict[value] = sobject #sobjects = search.get_sobjects() # virtual sobject for placeholder, we can put more than 1 maybe? sobject = SearchType.create('sthpw/note') edit_config = my._get_edit_config('edit', selected_process_names) edit_configs = {'sthpw/note': edit_config} Container.put("CellEditWdg:configs", edit_configs) table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view='table', config=main_config_view, aux_info={ 'sobjects': sobject_dict, 'parent': my.parent }, mode="simple", show_row_select=False, show_insert=False, show_commit_all=True, show_refresh='false', state={'parent_key': my.search_key}) table.set_sobject(sobject) top.add(table) return super(NoteSheetWdg, my).get_display()
def get_viewer(my): top = DivWdg(css='spt_single_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('context') title.add_color('color', 'color') div = DivWdg(css='spt_context_cb') div.add_color('color', 'color') SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False) checkbox_name = 'split_screen' checked_process_names = [] if my.show_context: top.add(swap) top.add(title) top.add(div) #checkbox_name = 'note_context_cb' checkbox_name = my.checkbox_name cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb checked_process_names = cb.get_values() for value in my.process_names: #my.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in checked_process_names: my.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_single_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.%s; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, checkbox_name, key) }) div.add(cb) else: web = WebContainer.get_web() checked_process_names = web.get_form_values('process_names') table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join( checked_process_names) table_id = 'main_table1' table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\ show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression ) if my.resize: from tactic.ui.container import ResizeScrollWdg inner_wdg = ResizeScrollWdg(width='500px', height='500px', scroll_bar_size_str='thick', scroll_expansion='inside') inner_wdg.add(table) table_top.add(inner_wdg) else: table_top.add(table) my.set_as_panel(table_top) top.add(table_top) return top
def get_display(self): if self.mode == 'detail': upstream = True div = DivWdg() self.snapshot_code = self.kwargs.get('snapshot_code') ref_snapshot = Snapshot.get_by_code(self.snapshot_code) self._handle_snapshot(ref_snapshot, div, upstream, recursive=False) return div self.web = WebContainer.get_web() if self.sobjects: snapshot = self.sobjects[0] else: search_type = self.kwargs.get("search_type") search_id = self.kwargs.get("search_id") snapshot = None if search_type == Snapshot.SEARCH_TYPE: snapshot = Search.get_by_id(search_type, search_id) else: snapshot = Snapshot.get_latest(search_type, search_id) if not snapshot: self.add(HtmlElement.h3("No snapshot found")) return super(DependencyWdg,self).get_display() widget = DivWdg() widget.add_style('min-width: 700px') if self.show_title: self.add(HtmlElement.h3("Asset Dependency")) from tactic.ui.panel import TableLayoutWdg table = TableLayoutWdg(search_type="sthpw/snapshot", mode='simple', view='table', width='700px') table.add_style('min-width: 700px') table.set_sobject(snapshot) widget.add(table) sobject = snapshot.get_sobject() search_type_obj = sobject.get_search_type_obj() #file_div = DivWdg(css='left_content discussion_child') file_div = DivWdg() file_div.add_color("background", "background", -20) file_div.add_color("color", "color") file_div.add_style("padding: 5px") file_div.add_border() #file_div.add_style('margin','0 10px 0 10px') file_div.add_style('padding','10px 0 0 10px') #file_div.add_style('-moz-border-radius: 6px') title = DivWdg() title.add_style("font-weight: bold") title.add_style("font-size: 1.2em") #title.add_style('margin-left', '10px') if self.show_title: title.add(search_type_obj.get_title() ) title.add(" - ") title.add(sobject.get_code() ) if sobject.has_value("description"): title.add(" : ") title.add(sobject.get_value("description") ) file_div.add(title) file_div.add(HtmlElement.br()) # find out how many 1st level ref nodes we are dealing with xml = snapshot.get_xml_value("snapshot") #self.total_ref_count = len(xml.get_nodes("snapshot/file/ref | snapshot/ref |snapshot/input_ref| snapshot/fref")) self._handle_snapshot(snapshot, file_div, upstream=True, recursive=True ) self._handle_snapshot(snapshot, file_div, upstream=False, recursive=True ) #widget.add(widget) widget.add(file_div) widget.add(HtmlElement.br(2)) #return super(DependencyWdg,self).get_display() return widget
def get_display(my): top = DivWdg() sobject = my.get_sobject() if not sobject: return top process = my.kwargs.get("process") #from tactic.ui.table import TaskElementWdg #task_wdg = TaskElementWdg() #task_wdg.set_sobject(my.sobject) #top.add(task_wdg) search = Search('sthpw/task') search.add_parent_filter(sobject) search.add_filter("process", process) tasks = search.get_sobjects() tasks_div = DivWdg() top.add(tasks_div) #tasks_div.add_style("padding: 0px 0px 20px 0px") tasks_div.add_style("margin: 10px") tasks_div.set_box_shadow() title = DivWdg() title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("All Tasks for process '%s':" % process) tasks_div.add(title) task_wdg = TableLayoutWdg(search_type="sthpw/task",view='single_process', show_row_select="false", show_insert="false", show_gear="false", show_search_limit="false", show_search=False, show_refresh="false", show_shelf="false") task_wdg.set_sobjects(tasks) tasks_div.add(task_wdg) #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table = Table() top.add(table) table.add_style("width: 100%") table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 50%") notes_div = DivWdg() td.add(notes_div) notes_div.set_box_shadow() notes_div.add_style("margin: 10px") title = DivWdg() notes_div.add(title) title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Notes:") from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=sobject.get_search_key(), process=process, context_hidden=True, show_note_expand=True) notes_div.add(discussion_wdg) search = Search('sthpw/snapshot') search.add_parent_filter(sobject) search.add_filter("process", process) snapshots = search.get_sobjects() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 50%") td.add_style("padding: 0 0 0 0") snapshots_div = DivWdg() td.add(snapshots_div) snapshots_div.set_box_shadow() snapshots_div.add_style("margin: 10px") title = DivWdg() title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Snapshots:") snapshots_div.add(title) snapshot_wdg = TableLayoutWdg(search_type="sthpw/snapshot",view='table', mode='simple', show_row_select=False, width='100%', show_shelf="false") snapshot_wdg.set_sobjects(snapshots) snapshots_div.add(snapshot_wdg) return top
def get_display(my): top = DivWdg() sobject = my.get_sobject() if not sobject: return top process = my.kwargs.get("process") #from tactic.ui.table import TaskElementWdg #task_wdg = TaskElementWdg() #task_wdg.set_sobject(my.sobject) #top.add(task_wdg) search = Search('sthpw/task') search.add_parent_filter(sobject) search.add_filter("process", process) tasks = search.get_sobjects() tasks_div = DivWdg() top.add(tasks_div) #tasks_div.add_style("padding: 0px 0px 20px 0px") tasks_div.add_style("margin: 10px") tasks_div.set_box_shadow() title = DivWdg() title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("All Tasks for process '%s':" % process) tasks_div.add(title) task_wdg = TableLayoutWdg(search_type="sthpw/task", view='single_process', show_row_select="false", show_insert="false", show_gear="false", show_search_limit="false", show_search=False, show_refresh="false", show_shelf="false") task_wdg.set_sobjects(tasks) tasks_div.add(task_wdg) #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table = Table() top.add(table) table.add_style("width: 100%") table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 50%") notes_div = DivWdg() td.add(notes_div) notes_div.set_box_shadow() notes_div.add_style("margin: 10px") title = DivWdg() notes_div.add(title) title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Notes:") from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=sobject.get_search_key(), process=process, context_hidden=True, show_note_expand=True) notes_div.add(discussion_wdg) search = Search('sthpw/snapshot') search.add_parent_filter(sobject) search.add_filter("process", process) snapshots = search.get_sobjects() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 50%") td.add_style("padding: 0 0 0 0") snapshots_div = DivWdg() td.add(snapshots_div) snapshots_div.set_box_shadow() snapshots_div.add_style("margin: 10px") title = DivWdg() title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Snapshots:") snapshots_div.add(title) snapshot_wdg = TableLayoutWdg(search_type="sthpw/snapshot", view='table', mode='simple', show_row_select=False, width='100%', show_shelf="false") snapshot_wdg.set_sobjects(snapshots) snapshots_div.add(snapshot_wdg) return top
def get_display(my): top = my.top search = Search("sthpw/snapshot") search.add_order_by("timestamp desc") search.add_filter("code", "61239PG") snapshot = search.get_sobject() xml = snapshot.get_value("snapshot") files = snapshot.get_all_file_objects() ref_snapshots = snapshot.get_all_ref_snapshots() table = Table() top.add(table) table.add_row() td = table.add_cell() canvas = my.get_canvas() td.add(canvas) table.add_row() td = table.add_cell() from tactic.ui.panel import TableLayoutWdg file_table = TableLayoutWdg(search_type="sthpw/file", view='table') td.add(file_table) table.set_sobjects(files) xml = [] xml.append("<dependency>") for file in files: file_name = file.get_value("file_name") xml.append('''<node name="%s"/>''' % file_name) xml.append('''<node name="%s"/>''' % snapshot.get_code()) for ref_snapshot in ref_snapshots: code = ref_snapshot.get_code() xml.append('''<node name="%s"/>''' % code) xml.append('''<connect from="%s" to="%s"/>''' % (code, snapshot.get_code())) xml.append("</dependency>") xml = "\n".join(xml) div = DivWdg() top.add(div) div.add_behavior({ 'type': 'load', 'xml': xml, 'cbjs_action': ''' var group = 'dependency'; var color = '#336655'; spt.pipeline.import_xml(bvr.xml, group, color); ''' }) return top
def get_display(my): widget = DivWdg() my.set_as_panel(widget, class_name='spt_view_panel spt_panel spt_app_asset_inst_panel') parent_search_type= my.search_type if my.show_search: # Have to limit this search to just its parent.. cuz if the target is prod/shot_instance # and its parent search is ShotFilterWdg, it's hard to isolate what shot has been selected search_bvr = { 'type': 'click_up', 'cbjs_action': 'spt.dg_table.search_cbk(evt, bvr)', 'override_class_name': 'tactic.ui.cgapp.AppAssetInstancePanelWdg', 'override_target': "bvr.src_el.getParent('.spt_app_asset_inst_panel')" } search_wdg = SearchWdg(search_type=parent_search_type, view='search_shot_loader', parent_key='', filter=''\ , display='block', custom_filter_view='', state=None, run_search_bvr=search_bvr) widget.add( HtmlElement.spacer_div(1,10) ) widget.add(search_wdg) # if there is result, it could only be one shot search = search_wdg.get_search() shots = search.get_sobjects() if not my.shot and len(shots) == 1: my.shot= shots[0] # create the asset table table_id = "main_body_asset_instance_table" if not my.shot: return widget # get any parent shots parent_code = my.shot.get_value("parent_code") shot_code = my.shot.get_code() # add the search make sure set elements are not shown search = Search(my.instance_search_type) if parent_code != "": search.add_filters(my.shot.get_foreign_key(), [shot_code,parent_code] ) else: search.add_filter(my.shot.get_foreign_key(), shot_code ) search.add_where("\"type\" in ('set_item', 'asset')") search.add_order_by('asset_code') instances = search.get_sobjects() # if parent shot and current shot has the same instance, hide the # parent's one top_instances = [] for instance in instances: if instance.get_value('type') != 'set_item': top_instances.append(instance) #instances = ShotInstance.filter_instances(instances, shot_code) top_instances = ShotInstance.filter_instances(top_instances, shot_code) # TODO: just add asset name to the ShotInstance table # get the original asset names aux_data = ShotInstance.get_aux_data(top_instances, my.asset_search_type) values = FilterData.get().get_values_by_index('view_action_option', 0) state = {} if not my.show_search: if values: state['process'] = values.get('load_%s_process'% parent_search_type) else: process_filter = ProcessFilterWdg(None, parent_search_type) state['process'] = process_filter.get_value() Container.put("global_state", state) from tactic.ui.cgapp import CGAppLoaderWdg cg_wdg = CGAppLoaderWdg(view='load', search_type=my.instance_search_type) widget.add(cg_wdg) if not top_instances: widget.add('No Asset Instances in Shot.') else: asset_table = TableLayoutWdg(table_id = table_id, search_type=my.instance_search_type,\ view="load", inline_search=False, aux_info = aux_data, mode='simple') #asset_table = ViewPanelWdg( search_type=search_type, inline_search=False, \ # show_general_search=False, view='load', state=state, mode='simple') asset_table.set_sobjects(top_instances) widget.add(asset_table) shot_inst_names = [inst.get_code() for inst in instances] my.add_unassigned_instances(widget, shot_inst_names) return widget
def get_display(self): self.search_type = self.kwargs.get('search_type') self.element_name = self.kwargs.get('element_name') assert self.search_type assert self.element_name class_name = 'tactic.ui.app.aggregate_wdg.AggregateCmd' interval = 120 priority = None if self.kwargs.get('is_refresh'): user = Environment.get_user_name() # these interval jobs need to have a specific code code = "aggregate|%s|%s" % (self.search_type, self.element_name) # check to see if the job exists #job = Search.get_by_code("sthpw/queue", code) job = None if not job: job = SearchType.create("sthpw/queue") #job.set_value("code", code) job.set_value("project_code", Project.get_project_code()) job.set_value("class_name", class_name) job.set_value("command", class_name) job.set_value("serialized", str(self.kwargs)) job.set_value("interval", 120) job.set_value("state", 'pending') job.set_value("queue", 'interval') job.set_value("priority", 9999) job.set_value("login", user) job.commit() self.view = self.kwargs.get('view') if not self.view: self.view = 'definition' top = DivWdg() self.set_as_panel(top) action_div = DivWdg() top.add(action_div) refresh = IconButtonWdg("Refresh", IconWdg.REFRESH) refresh.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_panel"); spt.panel.refresh(top); ''' }) action_div.add(refresh) register_div = DivWdg() register_div.add_class("spt_queue_register") top.add(register_div) register_div.add_style("border: solid 1px black") register_div.add_style("padding: 20px") register_div.add("Register new interval aggregate") table = Table() table.add_style("margin: 15px") register_div.add(table) table.add_row() table.add_cell("command: ") table.add_cell(class_name) #table.add_row() #table.add_cell("priority: ") #table.add_cell(priority) table.add_row() table.add_cell("interval: ") td = table.add_cell("every ") td.set_attr("title", "Recalculation interval") text = TextWdg("interval") text.add_style("width: 30px") text.set_value(interval) td.add(text) unit_select = SelectWdg("unit") unit_select.set_value(interval) unit_select.set_option("values", "seconds|minutes|hours|days") td.add(" ") td.add(unit_select) table.add_row() table.add_cell("queue: ") table.add_cell("interval") from pyasm.widget import ProdIconButtonWdg button = ProdIconButtonWdg("Register") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_queue_register") var values = spt.api.get_input_values(top); var top = bvr.src_el.getParent(".spt_panel"); spt.panel.refresh(top); ''' }) register_div.add(button) from pyasm.widget import ProdIconButtonWdg button = ProdIconButtonWdg("Cancel") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' alert('cancel'); ''' }) register_div.add(button) ''' cmd = AggregateCmd(**self.kwargs) print "registering scheduled task" scheduler = Scheduler.get() scheduler.start_thread() task = AggregateRefreshTask(name="cow", command=cmd) scheduler.add_interval_task(task, 10, mode='forked') scheduler.cancel_task("cow", delay=35) ''' top.add("<br/>") top.add("<b>Current Job Queue</b>") top.add("<br/><br/>") from tactic.ui.panel import TableLayoutWdg table = TableLayoutWdg(search_type='sthpw/queue', view='test') top.add(table) return top
def get_category_wdg2(self, paths, title=None, tags={}): if not paths: paths = [] div = DivWdg() if not title: title = "Paths" div.add("%s (%s)<hr/>" % (title, len(paths))) #if not paths: # div.add("-- None --<br/>") table = Table() div.add(table) table.add_color("color", "color") base_dir = self.kwargs.get("base_dir") sobjects = [] tags_keys = set() for path in paths: sobject = SearchType.create("sthpw/virtual") basename = os.path.basename(path) dirname = os.path.dirname(path) # FIXME: need session base reldir = dirname.replace("%s" % base_dir, "") reldir = dirname if not reldir: reldir = ' ' else: reldir.lstrip("/") if not basename: basename = ' ' sobject.set_value("folder", reldir) sobject.set_value("file_name", basename) sobjects.append(sobject) if tags: path_tags = tags.get(path) if path_tags: for key, value in path_tags.get("sobject").items(): sobject.set_value(key, value) tags_keys.add(key) from tactic.ui.panel import TableLayoutWdg element_names = ['path'] element_names.extend(list(tags_keys)) #show_metadata = False #if not show_metadata: # element_names.remove('metadata') config_xml = self.get_config_xml(list(tags_keys)) layout = TableLayoutWdg(search_type='sthpw/virtual', view='report', config_xml=config_xml, element_names=element_names, mode='simple') # FIXME: just show first 200 results layout.set_sobjects(sobjects[:200]) div.add(layout) return div
def get_display(self): top = self.top self.set_as_panel(top) top.set_unique_id() top.add_style("min-width: 600px") top.add_style("max-height: 600px") top.add_style("overflow-y: auto") top.add_color("background", "background") top.add_color("color", "color") sobject = self.kwargs.get("sobject") if not sobject: search_key = self.kwargs.get("search_key") sobject = Search.get_by_search_key(search_key) else: search_key = sobject.get_search_key() context = self.kwargs.get("context") search = Search("sthpw/note") #search.add_relationship_filters(self.filtered_parents, type='hierarchy') search.add_parent_filter(sobject) search.add_order_by("process") search.add_order_by("context") search.add_order_by("timestamp desc") if context: search.add_filter("context", context) notes = search.get_sobjects() top.add_smart_style("spt_note", "padding", "15px") for i, note in enumerate(notes): note_div = DivWdg() top.add( note_div ) note_div.add( self.get_note_wdg(note) ) if i % 2 == 0: note_div.add_color("background", "background", -3) top.add("<br/><hr/><br/>") from tactic.ui.panel import TableLayoutWdg table = TableLayoutWdg( search_type="sthpw/note", show_shelf=False, show_select=False, element_names=['login','timestamp','note','delete']) table.set_sobjects(notes) top.add(table) return top