def get_logins_wdg(self, logins): logins_div = DivWdg() for login in logins: login_div = DivWdg() logins_div.add(login_div) login_div.add_style("padding: 5px") #login_div.add_style("height: 30px") login_div.add_style("margin: 0 5px 5px 0") login_div.add_attr("spt_login", login.get_value("login")) thumb_div = DivWdg() login_div.add(thumb_div) thumb_div.add_style("float: left") thumb_div.add_style("margin-right: 5px") thumb_div.add_style("padding-top: 1px") thumb = ThumbWdg() thumb.set_sobject(login) thumb_div.add(thumb) thumb.set_icon_size(15) login_div.add(login.get_full_name()) login_div.add_behavior({ 'type': 'click_up', 'sobject_display_expr': self.sobject_display_expr, 'tab_view': self.tab_view, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_schedule_top"); var class_name = 'tactic.ui.tools.schedule_wdg.ScheduleUserToolWdg'; var login = bvr.src_el.getAttribute("spt_login") var kwargs = { login: login }; if (bvr.sobject_display_expr) kwargs['sobject_display_expr'] = bvr.sobject_display_expr; if (bvr.tab_view) kwargs['tab_view'] = bvr.tab_view; var content = top.getElement(".spt_schedule_content"); spt.panel.load(content, class_name, kwargs); ''' }) login_div.add_hover() return logins_div
def get_logins_wdg(my, logins): logins_div = DivWdg() for login in logins: login_div = DivWdg() logins_div.add(login_div) login_div.add_style("padding: 5px") # login_div.add_style("height: 30px") login_div.add_style("margin: 0 5px 5px 0") login_div.add_attr("spt_login", login.get_value("login")) thumb_div = DivWdg() login_div.add(thumb_div) thumb_div.add_style("float: left") thumb_div.add_style("margin-right: 5px") thumb_div.add_style("padding-top: 1px") thumb = ThumbWdg() thumb.set_sobject(login) thumb_div.add(thumb) thumb.set_icon_size(15) login_div.add(login.get_full_name()) login_div.add_behavior( { "type": "click_up", "sobject_display_expr": my.sobject_display_expr, "tab_view": my.tab_view, "cbjs_action": """ var top = bvr.src_el.getParent(".spt_schedule_top"); var class_name = 'tactic.ui.tools.schedule_wdg.ScheduleUserToolWdg'; var login = bvr.src_el.getAttribute("spt_login") var kwargs = { login: login }; if (bvr.sobject_display_expr) kwargs['sobject_display_expr'] = bvr.sobject_display_expr; if (bvr.tab_view) kwargs['tab_view'] = bvr.tab_view; var content = top.getElement(".spt_schedule_content"); spt.panel.load(content, class_name, kwargs); """, } ) login_div.add_hover() return logins_div
def get_title_wdg(my): if my.parent: code = my.parent.get_value("code", no_exception=True) name = my.parent.get_value("name", no_exception=True) search_type_obj = my.parent.get_search_type_obj() else: code = my.sobject.get_value("code", no_exception=True) name = my.sobject.get_value("name", no_exception=True) search_type_obj = my.sobject.get_search_type_obj() title = DivWdg() search = Search("sthpw/snapshot") search.add_filter("search_type", "sthpw/search_type") search.add_filter("search_code", search_type_obj.get_value("code")) if search.get_sobject(): thumb = ThumbWdg() title.add(thumb) thumb.set_icon_size(30) thumb.set_sobject(search_type_obj) thumb.add_style("float: left") title.add_color("background", "background3") title.add_style("height: 20px") title.add_style("padding: 6px") title.add_style("font-weight: bold") title.add_style("font-size: 1.4em") title.add_border() stype_title = search_type_obj.get_value("title") if stype_title: title.add("%s: " % stype_title) if name: title.add("%s" % name) if code: title.add(" <i style='font-size: 0.8; opacity: 0.7'>(%s)</i>" % code) elif code: title.add("%s" % code) else: title.add("(No name)") return title
def display_shot(my, shot, widget, count, is_current=False): thumb = ThumbWdg() thumb.set_sobject(shot) thumb.set_icon_size(45) widget.add(" " * 5 * count + "L ") widget.add(thumb) widget.add(" ") span = SpanWdg() if is_current: span.add_style("background: #eee") span.add_style("font-weight: bold") span.add_style("font-size: 1.1em") span.add(shot.get_code()) span.add(" ") span.add(shot.get_value("description")) widget.add(span) widget.add("<br/>")
def display_shot(my, shot, widget, count, is_current=False): thumb = ThumbWdg() thumb.set_sobject(shot) thumb.set_icon_size(45) widget.add( " " * 5 * count + "L ") widget.add(thumb) widget.add(" ") span = SpanWdg() if is_current: span.add_style("background: #eee") span.add_style("font-weight: bold") span.add_style("font-size: 1.1em") span.add(shot.get_code()) span.add(" ") span.add(shot.get_value("description")) widget.add(span) widget.add("<br/>")
def get_title_wdg(my): if my.parent: code = my.parent.get_value("code", no_exception=True) name = my.parent.get_value("name", no_exception=True) search_type_obj = my.parent.get_search_type_obj() else: code = my.sobject.get_value("code", no_exception=True) name = my.sobject.get_value("name", no_exception=True) search_type_obj = my.sobject.get_search_type_obj() title = DivWdg() search = Search("sthpw/snapshot") search.add_filter("search_type", "sthpw/search_type") search.add_filter("search_code", search_type_obj.get_value("code")) if search.get_sobject(): thumb = ThumbWdg() title.add(thumb) thumb.set_icon_size(30) thumb.set_sobject(search_type_obj) thumb.add_style("float: left") title.add_color("background", "background", -5) title.add_style("height: 23px") title.add_style("padding: 10px") title.add_style("font-weight: bold") title.add_style("font-size: 1.4em") title.add_border() stype_title = search_type_obj.get_value("title") if stype_title: title.add("%s: " % stype_title) if name: title.add("%s" % name) if code: title.add(" <i style='font-size: 0.8; opacity: 0.7'>(%s)</i>" % code) elif code: title.add("%s" % code) else: title.add("(No name)") return title
def handle_missing_instance(my, table, instance, asset): asset_code = asset.get_code() table.add_row() table.add_blank_cell() # add the thumbnail thumb = ThumbWdg() thumb.set_name("images") thumb.set_sobject(asset) thumb.set_icon_size(45) table.add_cell(thumb) info_wdg = Widget() info_wdg.add("<b>%s</b>" % instance) info_wdg.add("<div style='font-size: 0.8em'>%s</div>" % asset_code) table.add_cell(info_wdg) table.add_blank_cell()
def handle_missing_instance(my, table, instance, asset): asset_code = asset.get_code() table.add_row() table.add_blank_cell() # add the thumbnail thumb = ThumbWdg() thumb.set_name("images") thumb.set_sobject(asset) thumb.set_icon_size(45) table.add_cell(thumb) info_wdg = Widget() info_wdg.add("<b>%s</b>" % instance) info_wdg.add("<div style='font-size: 0.8em'>%s</div>" % asset_code ) table.add_cell(info_wdg) table.add_blank_cell()
def get_group_wdg(self, prev_sobj): if not self.is_preprocessed: self.preprocess() sobject = self.get_current_sobject() ref_sobj = self.get_ref_obj(sobject) self.current_ref_sobj = ref_sobj if not ref_sobj: return "Undetermined parent: [%s]" % SearchKey.get_by_sobject(sobject) widget = DivWdg() # add add button #from tactic.ui.widget import TextBtnWdg, TextBtnSetWdg #buttons_list = [] #buttons_list.append( { # 'label': '+', 'tip': 'Add Another Item', # 'bvr': { 'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)" } #} ) #add_btn = TextBtnSetWdg( float="right", buttons=buttons_list, # spacing=6, size='small', side_padding=0 ) #widget.add(add_btn) from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title='+', tip='Add Another Item', size='small') widget.add(button) button.add_style("float: right") button.add_behavior( { 'type': 'click_up', 'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)" } ) label = "Attach" label_option = self.get_option("label") if label_option: label = label_option table = Table() table.add_color("color", "color") table.add_row() search_key = sobject.get_search_key() # add a thumbe widget thumb = ThumbWdg() thumb.set_icon_size(40) thumb.set_sobject(ref_sobj) thumb.set_option('latest_icon', 'true') table.add_cell(thumb) # add the text description name_span = DivWdg(ref_sobj.get_code()) name_span.add_style('margin-left: 20px') table.add_cell(name_span) if ref_sobj.has_value("name"): name_span.add( " - " ) name_span.add( ref_sobj.get_value("name") ) #status = ref_sobj.get_value("status", no_exception=True) #if status: # span = SpanWdg("(status:%s)" % ref_sobj.get_value("status")) # table.add_cell(span) if ref_sobj.has_value("description"): description_wdg = ExpandableTextWdg("description") description_wdg.set_max_length(200) description_wdg.set_sobject(ref_sobj) td = table.add_cell( description_wdg ) td.add_style("padding-left: 15px") # FIXME: not sure about the layout here #if ref_sobj.has_value("pipeline_code"): # pipeline_code = ref_sobj.get_value("pipeline_code") # span = SpanWdg("(pipeline:%s)" % pipeline_code ) # td = table.add_cell(span) # td.add_style("padding-left: 15px") widget.add(table) return widget
def get_display(my): div = DivWdg() sobject = my.get_sobject_from_kwargs() if not sobject: div.add("SObject not found") return div search_type_obj = sobject.get_search_type_obj() title = search_type_obj.get_title() title_wdg = DivWdg() title_wdg.add_style("font-size: 1.8em") title_wdg.add("%s: %s" % (title, sobject.get_code() ) ) div.add(title_wdg) div.add(HtmlElement.hr()) table = Table() table.set_max_width() col1 = table.add_col() col1.add_style('width: 200px') col2 = table.add_col() col2.add_style('width: 320px') col3 = table.add_col() col3.add_style('width: 400px') table.add_row() from pyasm.widget import ThumbWdg, DiscussionWdg, SObjectTaskTableElement td = table.add_cell() td.add_style("vertical-align: top") td.add_style("border-right: solid 1px") title = DivWdg() title.add_class("maq_search_bar") #x = DivWdg("[?] [x]") #x.add_style("float: right") #title.add(x) title.add("Info") td.add(title) thumb = ThumbWdg() thumb.set_sobject(sobject) thumb.set_option("detail", "false") td.add(thumb) from pyasm.prod.web import AssetInfoWdg info = AssetInfoWdg() info.thumb = thumb info.set_sobject(sobject) td.add(info) # tasks td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding-left: 5px") td.add_style("border-right: solid 1px") title = DivWdg() title.add_class("maq_search_bar") #x = DivWdg("[x]") #x.add_style("float: right") #title.add(x) title.add("Tasks") td.add(title) task_wdg = SObjectTaskTableElement() task_wdg.set_sobject(sobject) td.add(task_wdg) td.add_style('cell-padding','10') # discussion td = table.add_cell() #td.add_style("min-width: 300px") #td.add_style("width: 600px") td.add_style("vertical-align: top") td.add_style("padding-left: 5px") td.add_style("border-right: solid 1px") title = DivWdg() title.add_class("maq_search_bar") #x = DivWdg("[x]") #x.add_style("float: right") #title.add(x) title.add("Notes") td.add(title) discussion_wdg = DiscussionWdg() discussion_wdg.preprocess() discussion_wdg.set_sobject(sobject) td.add(discussion_wdg) note_panel = discussion_wdg.get_note_menu() td.add(note_panel) div.add(table) div.add(HtmlElement.hr()) div.add(HtmlElement.br(clear="all")) title_wdg = DivWdg() title_wdg.add_class("maq_search_bar") #x = DivWdg("[x]") #x.add_style("float: right") #title_wdg.add(x) #title_wdg.add_style("font-size: 1.5em") title_wdg.add("Detail" ) div.add(title_wdg) div.add(HtmlElement.br()) # TEST getting schema search_type = sobject.get_base_search_type() schema = Schema.get_by_sobject(sobject) child_types = schema.get_child_types(search_type) # add a second table table = Table() table.set_max_width() # show the snapshots for this sobject search_type = "sthpw/snapshot" search = Search(search_type) search.add_sobject_filter(sobject) search.set_limit(25) sobjects = search.get_sobjects() table.add_row() nav_td = table.add_cell() nav_td.add_style("width: 100px") nav_td.add_style("vertical-align: top") section_wdg = my.get_section_wdg(sobject) nav_td.add( section_wdg ) parent_key = SearchKey.get_by_sobject(sobject) content_wdg = ViewPanelWdg(search_type=search_type, element_name='Snapshots', \ title='Snapshots', view='table', parent_key=parent_key, do_search=True) #content_wdg.set_sobjects(sobjects) content_td = table.add_cell() content_td.set_id("sobject_relation") content_td.add_style("display: table-cell") content_td.add_style("vertical-align: top") content_td.add_style("padding-left: 10px") content_td.add(content_wdg) div.add(table) return div
def get_display(my): web = WebContainer.get_web() tactic_header = Table() tactic_header.add_row() tactic_header.add_color("color", "color2") # tactic logo and release info skin = web.get_skin() src = '/context/skins/' + skin + '/images/tactic_logo.png' img = HtmlElement.img(src) img.add_class('hand') img.add_attr('title', 'Go to home page') img.add_behavior({'type': 'click_up', 'cbjs_action': "window.location='/tactic/'"}) rel_div = DivWdg() rel_div.add(" "*3) rel_div.add("Release: %s" %Environment.get_release_version() ) rel_div.add_style("font-size: 9px") # Need this to override the above color in add_looks rel_div.add_color("color", "color2") tactic_wdg = Table() tactic_wdg.add_style("width: 180px") tactic_wdg.add_row() td = tactic_wdg.add_cell( img ) td.set_style("width:100px") tactic_wdg.add_row() td = tactic_wdg.add_cell( rel_div ) td.set_style("text-align: left") td = tactic_header.add_cell( tactic_wdg ) # add the project thumb and title project = Project.get() if my.show_project: thumb_div = DivWdg() td = tactic_header.add_cell( thumb_div ) thumb_div.add_style("height: 28px") thumb_div.add_style("overflow: hidden") thumb_div.add_border(modifier=-10) thumb_div.add_style("-moz-border-radius: 3px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(project) thumb.set_icon_size("45") td.set_style("vertical-align: top; padding-right:14px;padding-left: 3px") td = tactic_header.add_cell( project.get_value("title") ) #td.add_looks( "fnt_title_1" ) td.add_style("font-size: 20px") td.add_style("white-space: nowrap") td.add_style("padding-left: 14px") # project selection td = tactic_header.add_cell() project_div = DivWdg() project_div.add_style("margin-top: -5px") project_div.add(ProjectSelectWdg() ) td.add( project_div ) td.set_style("padding-left: 14px") # Global Actions Gear Menu (contains links to Documentation) ... action_bar_btn_dd = PageHeaderGearMenuWdg() action_div = DivWdg(action_bar_btn_dd) action_div.add_style("margin-top: -5px") td = tactic_header.add_cell( action_div ) if PrefSetting.get_value_by_key('subscription_bar') == 'true': from message_wdg import SubscriptionBarWdg sub = SubscriptionBarWdg(mode='popup') tactic_header.add_cell(sub) # user login # user user = Environment.get_login() full_name = user.get_full_name() user_div = SpanWdg( HtmlElement.b( "%s " % full_name) , css='hand') user_div.set_style("padding-right:10px") # signout login = Environment.get_security().get_login() search_key = SearchKey.get_by_sobject(login) span = SpanWdg() span.add( user_div ) user_div.add_attr('spt_nudge_menu_vert', '20') td = tactic_header.add_cell(span) td.set_style("width:100%; text-align:right; white-space: nowrap") from tactic.ui.widget import SingleButtonWdg button = SingleButtonWdg(title='My Account', icon=IconWdg.USER, show_arrow=True) button_div = DivWdg(button) button_div.add_style("margin-top: -5px") button.add_attr('spt_nudge_menu_horiz', '-80') button.add_attr('spt_nudge_menu_vert', '10') td = tactic_header.add_cell(button_div) menus = my.get_smart_menu() # TODO: this part seems redundant to attach to both SmartMenu.add_smart_menu_set(user_div, [menus]) SmartMenu.assign_as_local_activator(user_div, None, True) SmartMenu.add_smart_menu_set(button, [menus]) SmartMenu.assign_as_local_activator(button, None, True) td.set_style("width:100%;") button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False) #button.add_behavior( { #'type': 'click_up', #'cbjs_action': ''' #window.open("/doc/") #''' #} ) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_help") ''' } ) from tactic.ui.container import DialogWdg help_dialog = DialogWdg(z_index=900, show_pointer=False) td.add(help_dialog) help_dialog.add_title("Help") help_dialog.add_class("spt_help") # container for help help_div = DivWdg() help_dialog.add(help_div) from help_wdg import HelpWdg help_wdg = HelpWdg() help_div.add(help_wdg) button_div = DivWdg(button) button_div.add_style("margin-top: -5px") td = tactic_header.add_cell(button_div) td.set_style("width:100%; text-align:right; white-space: nowrap") # Layout the Main Header Table main_div = DivWdg() # TEST: NEW LAYOUT if Config.get_value("install", "layout") == "fixed": main_div.add_style("position: fixed") main_div.add_style("z-index: 100") main_div.add_style("width: 100%") license = Environment.get_security().get_license() if not license.is_licensed(): from tactic.ui.app import LicenseManagerWdg license_manager = LicenseManagerWdg(use_popup=True) main_div.add(license_manager) # create the header table tactic_header_div = DivWdg() tactic_header_div.add(tactic_header) tactic_header_div.add_gradient("background", "background2", 10, -10) main_div.add(tactic_header_div) main_div.add( my.get_js_popup() ) """ main_div.add( HelpPopupWdg() ) # FIXME: is this even used at all? action_bar_popup = PopupWdg( id="ActionBarWdg_popup", allow_page_activity=True, width="636px" ) action_bar_popup.add_title( "TACTIC™ Action Bar" ) action_bar_popup.add( ActionBarWdg() ) main_div.add( action_bar_popup ) """ # FIXME(?): does this CommonPopup need to be at z_start=300? By default popups will be at z_start=200 popup = PopupWdg( id="CommonPopup", allow_page_activity=True, width="600px", z_start=300 ) popup.add('Tools', 'title') main_div.add( popup ) return main_div
def handle_instance(my, table, instance, asset, node_name='', publish=True, allow_ref_checkin=False): # handle the case where asset is not defined if not asset: table.add_row() table.add_blank_cell() table.add_blank_cell() # FIXME: Maya specific parts = instance.split(":") instance_name = parts[0] asset_code = parts[1] if instance_name == asset_code: table.add_cell(instance_name) else: table.add_cell(instance) td = table.add_cell() td.add("< %s node >" % my.session.get_node_type(instance_name)) table.add_blank_cell() return # get the pipeline for this asset and handlers for the pipeline process_name = my.process_select.get_value() handler_hidden = my.get_handler_input(asset, process_name) pipeline = Pipeline.get_by_sobject(asset) # TEST: switch this to using node name instead, if provided if node_name: instance_node = my.session.get_node(node_name) else: instance_node = my.session.get_node(instance) if instance_node is None: return if Xml.get_attribute(instance_node,"reference") == "true": is_ref = True else: is_ref = False namespace = Xml.get_attribute(instance_node, "namespace") if not namespace: namespace = instance asset_code = asset.get_code() is_set = False if asset.get_value('asset_type', no_exception=True) in ['set','section']: is_set = True tr = table.add_row() if is_set: tr.add_class("group") if publish and (allow_ref_checkin or not is_ref): checkbox = CheckboxWdg("asset_instances") if is_set: checkbox = CheckboxWdg("set_instances") checkbox.set_option("value", "%s|%s|%s" % \ (namespace, asset_code, instance) ) checkbox.set_persist_on_submit() td = table.add_cell(checkbox) else: td = table.add_blank_cell() # only one will be added even if there are multiple if handler_hidden: td.add(handler_hidden) # add the thumbnail thumb = ThumbWdg() thumb.set_name("images") thumb.set_sobject(asset) thumb.set_icon_size(60) table.add_cell(thumb) info_wdg = Widget() info_wdg.add(HtmlElement.b(instance)) if not node_name: node_name = '%s - %s' %(asset_code, asset.get_name()) info_div = DivWdg(node_name) info_div.add_style('font-size: 0.8em') info_wdg.add(info_div) info_div.add(HtmlElement.br(2)) if pipeline: info_div.add(pipeline.get_code()) table.add_cell(info_wdg) # by default can't checkin references if not allow_ref_checkin and is_ref: #icon = IconWdg("error", IconWdg.ERROR) #td = table.add_cell(icon) td = table.add_cell() td.add(HtmlElement.b("Ref. instance")) ''' import_button = ProdIconButtonWdg('import') import_button.add_event('onclick', "import_instance('%s')" %instance) td.add(import_button) ''' table.add_cell(my.get_save_wdg(my.current_sobject) ) elif publish: textarea = TextAreaWdg() textarea.set_persist_on_submit() textarea.set_name("%s_description" % instance) textarea.set_attr("cols", "35") textarea.set_attr("rows", "2") table.add_cell(textarea) table.add_cell(my.get_save_wdg(my.current_sobject) ) else: table.add_blank_cell() table.add_blank_cell()
def get_display(self): self.search_key = self.kwargs.get("search_key") self.context = self.kwargs.get("context") assert self.search_key assert self.context top = DivWdg() self.set_as_panel(top) top.add_class("spt_review_top") table = Table() top.add(table) table.add_row() left = table.add_cell() left.add_style("vertical-align: top") button = IconButtonWdg("Visual Notes", IconWdg.EDIT) button.add_behavior( { 'type': 'click_up', 'kwargs': { 'search_key': self.search_key, 'context': self.context, }, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_review_top"); var content = top.getElement(".spt_review_content"); spt.panel.load(content, "tactic.ui.widget.visual_notes_wdg.VisualNotesWdg", bvr.kwargs); ''' } ) left.add(button) # add a refresh button and a gear menu button = IconButtonWdg("Refresh", IconWdg.REFRESH) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var panel = bvr.src_el.getParent(".spt_review_top"); spt.panel.refresh(panel); ''' } ) left.add(button) right = table.add_cell() right.add_style("vertical-align: top") right.add("Image Area") content_div = DivWdg() content_div.add_class("spt_review_content") content_div.add_style("padding: 5px") content_div.add_style("margin: 5px") content_div.add_style("border: solid 1px #999") content_div.add_style("min-width: 500px") content_div.add_style("min-height: 400px") content_div.add_style("height: 100%") right.add(content_div) sobject = Search.get_by_search_key(self.search_key) note_context = "%s|note" % self.context snapshots = Search.eval("@SOBJECT(sthpw/snapshot['context','=','%s'])" % note_context, [sobject]) vnotes_div = DivWdg() vnotes_div.add_style("overflow: auto") vnotes_div.add_style("width: 200px") vnotes_div.add_style("min-height: 400px") vnotes_div.add_style("max-height: 600px") vnotes_div.add_style("border: solid 1px #999") vnotes_div.add_style("padding: 5px") vnotes_div.add_style("margin: 5px") left.add(vnotes_div) if not snapshots: vnotes_div.add("<b>No review notes available</b>") notes_wdg = VisualNotesWdg(search_key=self.search_key,context=self.context) content_div.add(notes_wdg) for snapshot in snapshots: vnote_div = DivWdg() vnotes_div.add(vnote_div) file_obj = snapshot.get_file_by_type('main') if not file_obj: vnote_div.add("None found") continue rel_path = file_obj.get_value("relative_dir") file_name = file_obj.get_value("file_name") image_url = "/assets/%s/%s" % (rel_path, file_name) login = snapshot.get_value("login") date = snapshot.get_value("timestamp") import dateutil date_str = dateutil.parser.parse(date).strftime("%b %m %Y - %H:%M") login_div = DivWdg() login_div.add_style("padding: 2px") login_div.add("User: "******"<b>%s</b><br/>" % login ) login_div.add("Date: ") login_div.add( "<b>%s</b><br/>" % date_str ) vnote_div.add(login_div) from pyasm.widget import ThumbWdg thumb_div = DivWdg() thumb_div.add_style("margin-left: 10px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_has_img_link(False) thumb.set_option("detail", "false") thumb.set_option("icon_size", "80") thumb.set_sobject(snapshot) vnote_div.add(thumb_div) #file_obj = snapshot.get_file_by_type('icon') #rel_path = file_obj.get_value("relative_dir") #file_name = file_obj.get_value("file_name") #icon_url = "/assets/%s/%s" % (rel_path, file_name) #vnote_div.add("<img src='%s'/>" % icon_url ) #vnote_div.add(snapshot.get_code() ) vnote_div.add_attr("spt_image_url", image_url ) vnote_div.add_class('hand') vnote_div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var value = bvr.src_el.innerHTML; var image_url = bvr.src_el.getAttribute("spt_image_url"); var top = bvr.src_el.getParent(".spt_review_top"); var content = top.getElement(".spt_review_content"); content.innerHTML = "<img src='"+image_url+"'/>"; ''' } ) # get the related note to this vnote #notes = vnotes_div.get_related_notes() search = Search("sthpw/note") search.add_parent_filter(sobject) notes = search.get_sobjects() #for note in notes: # vnote_div.add(note.get_value("note")) from pyasm.biz import SObjectConnection connections, related_notes = SObjectConnection.get_connected_sobjects(snapshot, direction='src') for related_note in related_notes: vnote_div.add(related_note.get_value("note") ) print "related_notes: ", related_notes vnote_div.add("<hr/>") return top
def get_preview_wdg(cls, subscription, category='', message_code=''): size = 60 if subscription: category = subscription.get_value("category") message_code = subscription.get_value("message_code") if category == 'sobject': sobject = Search.get_by_search_key(message_code) thumb = DivWdg() thumb_wdg = ThumbWdg() thumb.add(thumb_wdg) thumb_wdg.set_sobject(sobject) thumb_wdg.set_icon_size(size) search_code = sobject.get_code() thumb.add_behavior( { 'type': 'click_up', 'search_key': message_code, 'search_code': search_code, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.SObjectDetailWdg'; var kwargs = { search_key: bvr.search_key } spt.tab.set_main_body_tab(); var title = "Detail ["+bvr.search_code+"]"; spt.app_busy.show("Loading " + bvr.search_code); spt.tab.add_new(bvr.search_code, title, class_name, kwargs); spt.app_busy.hide(); ''' } ) elif category == 'chat': thumb = DivWdg() thumb.add_style("width: %s" % size) thumb.add_style("height: %s" % (size*3/4)) thumb.add_border() thumb.add_style('text-align: center') thumb.add_class("hand") message = Search.get_by_code("sthpw/message", message_code) login_code = message.get_value("login") login = Search.get_by_code("sthpw/login", login_code) thumb_wdg = ThumbWdg() thumb.add(thumb_wdg) thumb_wdg.set_sobject(login) thumb_wdg.set_icon_size(size) if subscription: key = subscription.get_value("message_code") thumb.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var class_name = 'tactic.ui.app.ChatSessionWdg'; var kwargs = { 'key': bvr.key, } spt.panel.load_popup("Chat: " + bvr.key, class_name, kwargs); ''' } ) else: if not category: category = "default" thumb = DivWdg() thumb.add_style("width: %s" % size) thumb.add_style("height: %s" % (size*3/4)) thumb.add_border() thumb.add_color("background", "background") thumb.add("<br/>") thumb.add(category) thumb.add_style('text-align: center') thumb.add_class("hand") thumb.add_style("margin: 3px") return thumb
def get_display(my): my.is_refresh = my.kwargs.get('is_refresh') =='true' if not my.is_refresh: top = DivWdg(css='spt_view_panel') my.set_as_panel(top) else: top = Widget() div = DivWdg(css="filter_box") div.add("<b>Current Session</b>") top.add(div) # the button which initiates the introspection button = IntrospectWdg() #button.add_style("float", "right") top.add(button) top.add("<br clear='all'/>") session = SessionContents.get() if not session: widget.add("<h3>No contents in session</h3>") return widget table = Table() table.add_class("table") table.add_style("width: 100%") table.add_row() table.add_header(" ") table.add_header("Type") table.add_header("Asset") table.add_header("Node Name") table.add_header("Node Type") table.add_header("Reference") table.add_header("Session") table.add_header("Latest") node_names = session.get_node_names() for node_name in node_names: table.add_row() # snapshot_code snapshot_code = session.get_snapshot_code(node_name, "shot") if not snapshot_code: snapshot_code = session.get_snapshot_code(node_name, "anim") if not snapshot_code: snapshot_code = session.get_snapshot_code(node_name, "asset") snapshot = Snapshot.get_by_code(snapshot_code) sobject = None if snapshot: sobject = snapshot.get_sobject() base = sobject.get_search_type_obj().get_base_search_type() thumb = ThumbWdg() thumb.set_icon_size(60) # FIXME: make this more automatic if base == "prod/shot_instance": thumb_sobj = sobject.get_parent("prod/asset") thumb.set_sobject(thumb_sobj) else: thumb.set_sobject(sobject) table.add_cell(thumb) title = sobject.get_search_type_obj().get_title() table.add_cell( title ) # TODO: this should be more automatic! if base == "prod/shot_instance": asset_code = sobject.get_value("asset_code") shot_code = sobject.get_value("shot_code") name = sobject.get_value("name") table.add_cell("%s: %s in %s" % (name,asset_code,shot_code)) else: code = sobject.get_code() name = sobject.get_name() if code == name: table.add_cell( "%s" % (code) ) else: table.add_cell( "%s - %s" % (code, name) ) else: table.add_cell("<i>No snapshot</i>") table.add_cell("---") table.add_cell("---") # display the node name table.add_cell(node_name) # display node type table.add_cell( session.get_node_type(node_name) ) # display if it is a reference is_reference = session.is_reference(node_name) if is_reference: table.add_cell( "Yes" ) else: table.add_cell( "No" ) if snapshot: # add the snapshot info context = snapshot.get_value("context") version = snapshot.get_value("version") table.add_cell( "%s v%0.2d" % (context, version)) else: table.add_cell("---") table.add_cell( my.get_version_wdg(session,snapshot,node_name) ) top.add(table) return top
def get_display(self): web = WebContainer.get_web() palette = web.get_palette() widget = DivWdg() widget.add_style("width: 100%") widget.add_style("text-align: center") from tactic.ui.app import PageHeaderWdg header = PageHeaderWdg(show_project=False) widget.add(header) security = Environment.get_security() search = Search("sthpw/project") search.add_where("\"code\" not in ('sthpw', 'admin', 'unittest')") search.add_where("\"type\" not in ('resource')") # hide template projects if security.check_access("builtin", "view_site_admin", "allow") or security.check_access( "builtin", "view_template_projects", "allow"): pass else: search.add_op("begin") search.add_filter("is_template", True, op='!=') search.add_filter("is_template", 'NULL', quoted=False, op='is') search.add_op("or") search.add_order_by("category") projects = search.get_sobjects() num = len(projects) # sort by project if num < 5: columns = 1 icon_size = 90 width = 500 elif num < 15: columns = 2 icon_size = 60 width = 700 else: columns = 3 icon_size = 45 width = 800 div = DivWdg() div.add_style("margin-left: auto") div.add_style("margin-right: auto") #div.add_style("width: 520px") div.center() widget.add(div) #logo = TacticLogoWdg() #div.add(logo) div.add("<br/>" * 3) bg_color = palette.color("background") #div.add_color("color", "color") from tactic.ui.container import RoundedCornerDivWdg div = RoundedCornerDivWdg(hex_color_code=bg_color, corner_size="10") div.set_dimensions(width_str='%spx' % width, content_height_str='50px') div.add_border() div.add_style("overflow: hidden") div.set_box_shadow() div.add_style("margin-left: auto") div.add_style("margin-right: auto") div.add_style("width: %spx" % width) table = Table() table.set_max_width() table.add_style("margin-left: auto") table.add_style("margin-right: auto") table.add_style("background-color: %s" % bg_color) table.add_color("color", "color") tr, td = table.add_row_cell() logo_div = DivWdg() logo_div.add_gradient("background", "background3", -5, -10) td.add(logo_div) logo = TacticLogoWdg() logo_div.add(logo) logo_div.add_style("margin: -6 -6 6 -6") app_name = WebContainer.get_web().get_app_name() security = Environment.get_security() last_category = None has_category = False index = 0 # if TACTIC has not been set up, show the configuration page # FIXME: what is the requirement for is_installed? config_path = Config.get_config_path() if not os.path.exists(config_path): is_installed = False else: is_installed = True #is_installed = True # filter out projects due to security filtered = [] for i, project in enumerate(projects): from pyasm.security import get_security_version security_version = get_security_version() if security_version >= 2: key = {"code": project.get_code()} key2 = {"code": "*"} keys = [key, key2] default = "deny" if not security.check_access( "project", keys, "allow", default=default): continue else: if not security.check_access( "project", project.get_code(), "view", default="allow"): continue filtered.append(project) projects = filtered if not is_installed: tr, td = table.add_row_cell() #from tactic.ui.startup import DbConfigWdg #td.add(DbConfigWdg()) title_div = DivWdg() td.add(title_div) title_div.add_style("padding: 5px") title_div.add_style("font-weight: bold") title_div.add("Getting Started ...") title_div.add_gradient("background", "background", -10) projects_div = DivWdg() projects_div.add_style("padding: 20px") td.add(projects_div) projects_div.add_style("text-align: center") projects_div.add("Welcome to TACTIC ...<br/>") projects_div.add_style("font-size: 22px") msg_div = DivWdg() td.add(msg_div) msg_div.add( "Configure TACTIC to connect to an external database and set up asset folders.<br/><br/>" ) msg_div.add_style("text-align: center") action = ActionButtonWdg(title='Confgure', size='medium') action.add_style("margin-left: auto") action.add_style("margin-right: auto") td.add(action) action.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic/admin/#/link/configure"; ''' }) msg_div = DivWdg() td.add(msg_div) msg_div.add( "<br/><br/>Or start using TACTIC with default configuration with an internal database.<br/><br/>" ) msg_div.add_style("text-align: center") action = ActionButtonWdg(title='Start >>', size='medium') action.add_style("margin-left: auto") action.add_style("margin-right: auto") td.add(action) action.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic"; ''' }) msg_div = DivWdg() td.add(msg_div) msg_div.add("<br/><br/><br/>") msg_div.add_style("text-align: center") elif projects: num_projets = 0 for i, project in enumerate(projects): category = project.get_value("category") if category is not None and category != last_category: table.add_row() tr, td = table.add_row_cell() category_div = DivWdg() td.add(category_div) if has_category and not category: category_div.add(" ") else: category_div.add(category) category_div.add_style("padding: 8px") category_div.add_style("font-size: 16px") category_div.add_style("font-weight: bold") category_div.add_color("color", "color") category_div.add_gradient("background", "background3", 0, -10) category_div.add_color("color", "color3") #category_div.set_round_corners() if last_category == None: category_div.add_style("margin: -6 -6 6 -6") else: category_div.add_style("margin: 15 -6 0 -6") table.add_row() has_category = True index = 0 index += 1 last_category = category thumb = ThumbWdg() thumb.set_name("snapshot") thumb.set_sobject(project) thumb.set_show_clipboard(False) thumb.set_has_img_link(False) thumb.set_icon_size(icon_size) code = project.get_code() title = project.get_value("title") # Restrict the length of project name if len(title) >= 36: title = title[:36] + "..." if app_name != 'Browser': href = HtmlElement.href(HtmlElement.h2(title), ref='/tactic/%s/%s'\ %(code, app_name)) img_href = HtmlElement.href(thumb, ref='/tactic/%s/%s'\ %(code, app_name)) link = '/tactic/%s/%s' % (code, app_name) else: href = HtmlElement.href(HtmlElement.h2(title), ref="/tactic/%s/" % code) img_href = DivWdg(thumb) img_href.add_behavior({ 'type': 'click_up', 'code': code, 'cbjs_action': ''' document.location = '/tactic/'+bvr.code+'/'; ''' }) link = '/tactic/%s/' % code href = href.get_buffer_display() if (index - 1) % columns == 0: table.add_row() td = table.add_cell() img_div = DivWdg() img_div.add(img_href) img_div.add_style("margin-right: 20px") img_div.add_style("float: left") img_div.add_border() #img_div.set_round_corners() img_div.set_box_shadow("0px 1px 5px") project_div = DivWdg() td.add(project_div) td.add_style("width: 230px") project_div.add_style("font-size: 16px") project_div.add_style("font-weight: bold") project_div.add_style("vertical-align: middle") project_div.add(img_div) #project_div.add(href) project_div.add(title) if project.get_value("is_template") == True: project_div.add( "<br/><i style='opacity: 0.5; font-size: 12px'>(template)</i>" ) project_div.add_style("height: %spx" % (icon_size - 10)) project_div.add_style("padding: 8px 10px 2px 20px") project_div.add_color("background", "background") project_div.add_behavior({ 'type': 'hover', 'add_color_modifier': -3, 'cb_set_prefix': 'spt.mouse.table_layout_hover', }) project_div.set_round_corners() project_div.add_class("hand") project_div.add_behavior({ 'type': 'click_up', 'link': link, 'title': title, 'cbjs_action': ''' document.location = bvr.link; ''' }) elif not security.check_access( "builtin", "view_site_admin", "allow", default="deny") and not security.check_access( "builtin", "create_projects", "allow", default="deny"): tr, td = table.add_row_cell() msg_div = DivWdg() td.add(msg_div) from pyasm.widget import IconWdg icon = IconWdg("WARNING", IconWdg.WARNING) msg_div.add(icon) msg_div.add("You are not permitted to view any projects") msg_div.add_style("font-size: 16px") msg_div.add_style("text-align: center") msg_div.add_style("font-weight: bold") msg_div.add_style("margin: 50px") msg_div.add("<br/>" * 2) msg_div.add("Please click to Sign Out:<br/>") action = ActionButtonWdg(title='Sign Out >>', size='m') msg_div.add(action) action.add_style('margin: 5px auto') action.add_style('text-align: center') web = WebContainer.get_web() action.add_behavior({ 'type': 'click_up', 'login': web.get_user_name(), 'cbjs_action': ''' var server = TacticServerStub.get(); server.execute_cmd("SignOutCmd", {login: bvr.login} ); window.location.href='/'; ''' }) else: tr, td = table.add_row_cell() title_div = DivWdg() td.add(title_div) title_div.add_style("padding: 10px") title_div.add_style("margin: -8px -6px 20px -6px") title_div.add_style("font-weight: bold") title_div.add("Getting Started ...") title_div.add_gradient("background", "background", -10) projects_div = DivWdg() projects_div.add_style("padding: 20px") td.add(projects_div) projects_div.add_style("text-align: center") projects_div.add("No Projects have been created ...<br/><br/>") projects_div.add_style("font-size: 22px") action = ActionButtonWdg(title='Create Project >>', size='large') action.add_style("margin-left: auto") action.add_style("margin-right: auto") projects_div.add(action) action.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic/admin/link/create_project"; ''' }) if security.check_access("builtin", "view_site_admin", "allow"): admin_div = DivWdg() #href = HtmlElement.href(HtmlElement.h2('Admin Site'), ref='/tactic/admin/') #admin_div.add(href) #admin_div.add_border() admin_div.add_style("font-size: 16px") admin_div.add_style("font-weight: bold") admin_div.add_style("height: 30px") link_div = DivWdg() link_div.add_class("hand") admin_div.add(link_div) link_div.add("Go to Admin Site") link_div.add_style("text-align: center") link_div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = '/tactic/admin/'; ''' }) tr, td = table.add_row_cell() td.add("<hr/><br/>") td.add(admin_div) div.add(table) widget.add(div) # Note sure what this is for #BaseAppServer.add_onload_script('spt.first_load=false') div.add_behavior({ 'type': 'load', 'cbjs_action': '''spt.first_load=false''' }) return widget
def get_display(my): my.sobject = my.get_sobject() top = DivWdg() top.add_class("spt_detail_top") top.add_color("background", "background") top.add_color("color", "color") if not my.sobject: top.add("No SObject defined for this widget") return top if my.parent: my.search_type = my.parent.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.parent) top.add_attr("spt_parent_key", my.search_key) my.pipeline_code = my.parent.get_value("pipeline_code", no_exception=True) my.full_search_type = my.parent.get_search_type() else: my.pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True) my.search_type = my.sobject.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.sobject) my.full_search_type = my.sobject.get_search_type() if not my.pipeline_code: my.pipeline_code = 'default' top.add_style("text-align: left") my.set_as_panel(top) table = Table() #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table.add_color("background", "background") table.add_color("color", "color") top.add(table) table.set_max_width() table.add_row() if my.parent: code = my.parent.get_value("code", no_exception=True) name = my.parent.get_value("name", no_exception=True) search_type_obj = my.parent.get_search_type_obj() else: code = my.sobject.get_value("code", no_exception=True) name = my.sobject.get_value("name", no_exception=True) search_type_obj = my.sobject.get_search_type_obj() # add the title td = table.add_cell() td.add_attr("colspan", "3") title = DivWdg() search = Search("sthpw/snapshot") search.add_filter("search_type", "sthpw/search_type") search.add_filter("search_code", search_type_obj.get_value("code")) if search.get_sobject(): thumb = ThumbWdg() title.add(thumb) thumb.set_icon_size(30) thumb.set_sobject(search_type_obj) thumb.add_style("float: left") td.add(title) title.add_color("background", "background3") title.add_style("height: 20px") title.add_style("padding: 6px") title.add_style("font-weight: bold") title.add_style("font-size: 1.4em") stype_title = search_type_obj.get_value("title") if stype_title: title.add("%s: " % stype_title) if name: title.add("%s" % name) if code: title.add(" <i style='font-size: 0.8; opacity: 0.7'>(%s)</i>" % code) elif code: title.add("%s" % code) else: title.add("(No name)") title.add_border() table.add_row() # left td = table.add_cell() td.add_style("width: 300px") td.add_style("min-width: 300px") td.add_style("vertical-align: top") div = DivWdg() td.add(div) div.add_class("spt_sobject_detail_top") thumb_table = Table() div.add(thumb_table) thumb_table.add_row() from tactic.ui.panel import ThumbWdg2 thumb = ThumbWdg2() # use a larger version for clearer display #thumb.set_icon_type('web') if my.parent: thumb.set_sobject(my.parent) search_key = my.parent.get_search_key() else: thumb.set_sobject(my.sobject) search_key = my.sobject.get_search_key() gallery_div = DivWdg() div.add(gallery_div) gallery_div.add_class("spt_tile_gallery") thumb_table.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_sobject_detail_top"); var gallery_el = top.getElement(".spt_tile_gallery"); var class_name = 'tactic.ui.widget.gallery_wdg.GalleryWdg'; var kwargs = { search_key: bvr.search_key, search_keys: [bvr.search_key], }; spt.panel.load(gallery_el, class_name, kwargs); ''' }) # prefer to see the original image, then web #thumb.set_option('image_link_order', 'main|web|icon') #thumb.set_option("detail", "false") #thumb.set_option("icon_size", "100%") td = thumb_table.add_cell(thumb) td.add_style("vertical-align: top") td.add_style("width: auto") td.add_style("padding: 15px") sobject_info_wdg = my.get_sobject_info_wdg() sobject_info_wdg.add_style("width: auto") td.add(sobject_info_wdg) if my.search_type == 'sthpw/task' and not my.parent: pass else: sobject_info_wdg = my.get_sobject_detail_wdg() td = table.add_cell() td.add(sobject_info_wdg) td.add_style("vertical-align: top") td.add_style("overflow: hidden") # right td = table.add_cell() td.add_style("text-align: left") td.add_style("vertical-align: top") td.add_class("spt_notes_wrapper") notes_div = DivWdg() td.add(notes_div) from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=my.search_key, context_hidden=False, show_note_expand=False) notes_div.add(discussion_wdg) notes_div.add_style("min-width: 300px") notes_div.add_style("height: 200") notes_div.add_style("overflow-y: auto") notes_div.add_class("spt_resizable") # get the process if my.parent: process = my.sobject.get_value("process") else: process = '' # content tr = table.add_row() td = table.add_cell() td.add_attr("colspan", "5") #td.add_attr("colspan", "3") # create a state for tab. The tab only passes a search key # parent key search_key = SearchKey.get_by_sobject(my.sobject) parent_key = "" if search_key.startswith("sthpw/"): parent = my.sobject.get_parent() if parent: parent_key = parent.get_search_key() state = { 'search_key': search_key, 'parent_key': parent_key, 'process': process, } WebState.get().push(state) config_xml = my.get_config_xml() config = WidgetConfig.get(view="tab", xml=config_xml) if process: custom_view = "tab_config_%s" % process else: custom_view = "tab_config" search = Search("config/widget_config") search.add_filter("category", "TabWdg") search.add_filter("search_type", my.search_type) search.add_filter("view", custom_view) custom_config_sobj = search.get_sobject() if custom_config_sobj: custom_config_xml = custom_config_sobj.get_value("config") custom_config = WidgetConfig.get(view=custom_view, xml=custom_config_xml) config = WidgetConfigView(search_type='TabWdg', view=custom_view, configs=[custom_config, config]) #menu = my.get_extra_menu() #tab = TabWdg(config=config, state=state, extra_menu=menu) tab = TabWdg(config=config, state=state, show_add=False, show_remove=False, tab_offset=5) tab.add_style("margin: 0px -2px -2px -2px") td.add(tab) td.add_style("padding-top: 10px") return top
def get_display(self): web = WebContainer.get_web() palette = web.get_palette() widget = DivWdg() widget.add_style("width: 100%") widget.add_style("text-align: center") from tactic.ui.app import PageHeaderWdg header = PageHeaderWdg(show_project=False) widget.add( header ) security = Environment.get_security() search = Search("sthpw/project") search.add_where("\"code\" not in ('sthpw', 'admin', 'unittest')") search.add_where("\"type\" not in ('resource')") # hide template projects if security.check_access("builtin", "view_site_admin", "allow") or security.check_access("builtin", "view_template_projects", "allow"): pass else: search.add_op("begin") search.add_filter("is_template", True, op='!=') search.add_filter("is_template", 'NULL', quoted=False, op='is') search.add_op("or") search.add_order_by("category") projects = search.get_sobjects() num = len(projects) # sort by project if num < 5: columns = 1 icon_size = 90 width = 500 elif num < 15: columns = 2 icon_size = 60 width = 700 else: columns = 3 icon_size = 45 width = 800 div = DivWdg() div.add_style("margin-left: auto") div.add_style("margin-right: auto") #div.add_style("width: 520px") div.center() widget.add(div) #logo = TacticLogoWdg() #div.add(logo) div.add("<br/>"*3) bg_color = palette.color("background") #div.add_color("color", "color") from tactic.ui.container import RoundedCornerDivWdg div = RoundedCornerDivWdg(hex_color_code=bg_color,corner_size="10") div.set_dimensions( width_str='%spx' % width, content_height_str='50px' ) div.add_border() div.add_style("overflow: hidden") div.set_box_shadow() div.add_style("margin-left: auto") div.add_style("margin-right: auto") div.add_style("width: %spx" % width) table = Table() table.set_max_width() table.add_style("margin-left: auto") table.add_style("margin-right: auto") table.add_style("background-color: %s" % bg_color) table.add_color("color", "color") tr, td = table.add_row_cell() logo_div = DivWdg() logo_div.add_gradient("background", "background3", -5, -10) td.add(logo_div) logo = TacticLogoWdg() logo_div.add(logo) logo_div.add_style("margin: -6 -6 6 -6") app_name = WebContainer.get_web().get_app_name() security = Environment.get_security() last_category = None has_category = False index = 0 # if TACTIC has not been set up, show the configuration page # FIXME: what is the requirement for is_installed? config_path = Config.get_config_path() if not os.path.exists(config_path): is_installed = False else: is_installed = True #is_installed = True # filter out projects due to security filtered = [] for i, project in enumerate(projects): from pyasm.security import get_security_version security_version = get_security_version() if security_version >= 2: key = { "code": project.get_code() } key2 = { "code": "*" } keys = [key, key2] default = "deny" if not security.check_access("project", keys, "allow", default=default): continue else: if not security.check_access("project", project.get_code(), "view", default="allow"): continue filtered.append(project) projects = filtered if not is_installed: tr, td = table.add_row_cell() #from tactic.ui.startup import DbConfigWdg #td.add(DbConfigWdg()) title_div = DivWdg() td.add(title_div) title_div.add_style("padding: 5px") title_div.add_style("font-weight: bold") title_div.add("Getting Started ...") title_div.add_gradient("background", "background", -10) projects_div = DivWdg() projects_div.add_style("padding: 20px") td.add(projects_div) projects_div.add_style("text-align: center") projects_div.add("Welcome to TACTIC ...<br/>") projects_div.add_style("font-size: 22px") msg_div = DivWdg() td.add(msg_div) msg_div.add("Configure TACTIC to connect to an external database and set up asset folders.<br/><br/>") msg_div.add_style("text-align: center") action = ActionButtonWdg(title='Confgure', size='medium') action.add_style("margin-left: auto") action.add_style("margin-right: auto") td.add(action) action.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic/admin/#/link/configure"; ''' } ) msg_div = DivWdg() td.add(msg_div) msg_div.add("<br/><br/>Or start using TACTIC with default configuration with an internal database.<br/><br/>") msg_div.add_style("text-align: center") action = ActionButtonWdg(title='Start >>', size='medium') action.add_style("margin-left: auto") action.add_style("margin-right: auto") td.add(action) action.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic"; ''' } ) msg_div = DivWdg() td.add(msg_div) msg_div.add("<br/><br/><br/>") msg_div.add_style("text-align: center") elif projects: num_projets = 0 for i, project in enumerate(projects): category = project.get_value("category") if category is not None and category != last_category: table.add_row() tr, td = table.add_row_cell() category_div = DivWdg() td.add(category_div) if has_category and not category: category_div.add(" ") else: category_div.add(category) category_div.add_style("padding: 8px") category_div.add_style("font-size: 16px") category_div.add_style("font-weight: bold") category_div.add_color("color", "color") category_div.add_gradient("background", "background3",0, -10) category_div.add_color("color", "color3") #category_div.set_round_corners() if last_category == None: category_div.add_style("margin: -6 -6 6 -6") else: category_div.add_style("margin: 15 -6 0 -6") table.add_row() has_category = True index = 0 index += 1 last_category = category thumb = ThumbWdg() thumb.set_name("snapshot") thumb.set_sobject(project) thumb.set_show_clipboard(False) thumb.set_has_img_link(False) thumb.set_icon_size(icon_size) code = project.get_code() title = project.get_value("title") # Restrict the length of project name if len(title) >= 36: title = title[:36] + "..." if app_name != 'Browser': href = HtmlElement.href(HtmlElement.h2(title), ref='/tactic/%s/%s'\ %(code, app_name)) img_href = HtmlElement.href(thumb, ref='/tactic/%s/%s'\ %(code, app_name)) link = '/tactic/%s/%s' % (code, app_name) else: href = HtmlElement.href(HtmlElement.h2(title), ref="/tactic/%s/" % code) img_href = DivWdg(thumb) img_href.add_behavior( { 'type': 'click_up', 'code': code, 'cbjs_action': ''' document.location = '/tactic/'+bvr.code+'/'; ''' } ) link = '/tactic/%s/' % code href = href.get_buffer_display() if (index-1) % columns == 0: table.add_row() td = table.add_cell() img_div = DivWdg() img_div.add(img_href) img_div.add_style("margin-right: 20px") img_div.add_style("float: left") img_div.add_border() #img_div.set_round_corners() img_div.set_box_shadow("0px 1px 5px") project_div = DivWdg() td.add(project_div) td.add_style("width: 230px") project_div.add_style("font-size: 16px") project_div.add_style("font-weight: bold") project_div.add_style("vertical-align: middle") project_div.add(img_div) #project_div.add(href) project_div.add(title) if project.get_value("is_template") == True: project_div.add("<br/><i style='opacity: 0.5; font-size: 12px'>(template)</i>") project_div.add_style("height: %spx" % (icon_size-10)) project_div.add_style("padding: 8px 10px 2px 20px") project_div.add_color("background", "background") project_div.add_behavior( { 'type': 'hover', 'add_color_modifier': -3, 'cb_set_prefix': 'spt.mouse.table_layout_hover', } ) project_div.set_round_corners() project_div.add_class("hand") project_div.add_behavior( { 'type': 'click_up', 'link': link, 'title': title, 'cbjs_action': ''' document.location = bvr.link; ''' } ) elif not security.check_access("builtin", "view_site_admin", "allow", default="deny") and not security.check_access("builtin", "create_projects", "allow", default="deny"): tr, td = table.add_row_cell() msg_div = DivWdg() td.add(msg_div) from pyasm.widget import IconWdg icon = IconWdg("WARNING", IconWdg.WARNING) msg_div.add(icon) msg_div.add("You are not permitted to view any projects") msg_div.add_style("font-size: 16px") msg_div.add_style("text-align: center") msg_div.add_style("font-weight: bold") msg_div.add_style("margin: 50px") msg_div.add("<br/>"*2) msg_div.add("Please click to Sign Out:<br/>") action = ActionButtonWdg(title='Sign Out >>', size='m') msg_div.add(action) action.add_style('margin: 5px auto') action.add_style('text-align: center') web = WebContainer.get_web() action.add_behavior( { 'type': 'click_up', 'login': web.get_user_name(), 'cbjs_action': ''' var server = TacticServerStub.get(); server.execute_cmd("SignOutCmd", {login: bvr.login} ); window.location.href='/'; ''' } ) else: tr, td = table.add_row_cell() title_div = DivWdg() td.add(title_div) title_div.add_style("padding: 10px") title_div.add_style("margin: -8px -6px 20px -6px") title_div.add_style("font-weight: bold") title_div.add("Getting Started ...") title_div.add_gradient("background", "background", -10) projects_div = DivWdg() projects_div.add_style("padding: 20px") td.add(projects_div) projects_div.add_style("text-align: center") projects_div.add("No Projects have been created ...<br/><br/>") projects_div.add_style("font-size: 22px") action = ActionButtonWdg(title='Create Project >>', size='large') action.add_style("margin-left: auto") action.add_style("margin-right: auto") projects_div.add(action) action.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic/admin/link/create_project"; ''' } ) if security.check_access("builtin", "view_site_admin", "allow"): admin_div = DivWdg() #href = HtmlElement.href(HtmlElement.h2('Admin Site'), ref='/tactic/admin/') #admin_div.add(href) #admin_div.add_border() admin_div.add_style("font-size: 16px") admin_div.add_style("font-weight: bold") admin_div.add_style("height: 30px") link_div = DivWdg() link_div.add_class("hand") admin_div.add(link_div) link_div.add("Go to Admin Site") link_div.add_style("text-align: center") link_div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' document.location = '/tactic/admin/'; ''' } ) tr, td = table.add_row_cell() td.add("<hr/><br/>") td.add(admin_div) div.add(table) widget.add(div) # Note sure what this is for #BaseAppServer.add_onload_script('spt.first_load=false') div.add_behavior( { 'type': 'load', 'cbjs_action': '''spt.first_load=false''' } ) return widget
def get_display(my): my.sobject = my.get_sobject() top = DivWdg() top.add_class("spt_detail_top") top.add_color("background", "background") top.add_color("color", "color") if not my.sobject: top.add("No SObject defined for this widget") return top if my.parent: my.search_type = my.parent.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.parent) top.add_attr("spt_parent_key", my.search_key) my.pipeline_code = my.parent.get_value("pipeline_code", no_exception=True) my.full_search_type = my.parent.get_search_type() else: my.pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True) my.search_type = my.sobject.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.sobject) my.full_search_type = my.sobject.get_search_type() if not my.pipeline_code: my.pipeline_code = 'default' top.add_style("text-align: left") my.set_as_panel(top) table = Table() #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table.add_color("background", "background") table.add_color("color", "color") top.add(table) table.set_max_width() table.add_row() if my.parent: code = my.parent.get_value("code", no_exception=True) name = my.parent.get_value("name", no_exception=True) search_type_obj = my.parent.get_search_type_obj() else: code = my.sobject.get_value("code", no_exception=True) name = my.sobject.get_value("name", no_exception=True) search_type_obj = my.sobject.get_search_type_obj() # add the title td = table.add_cell() td.add_attr("colspan", "3") title = DivWdg() search = Search("sthpw/snapshot") search.add_filter("search_type", "sthpw/search_type") search.add_filter("search_code", search_type_obj.get_value("code")) if search.get_sobject(): thumb = ThumbWdg() title.add(thumb) thumb.set_icon_size(30) thumb.set_sobject(search_type_obj) thumb.add_style("float: left") td.add(title) title.add_color("background", "background3") title.add_style("height: 20px") title.add_style("padding: 6px") title.add_style("font-weight: bold") title.add_style("font-size: 1.4em") stype_title = search_type_obj.get_value("title") if stype_title: title.add("%s: " % stype_title) if name: title.add("%s" % name) if code: title.add(" <i style='font-size: 0.8; opacity: 0.7'>(%s)</i>" % code) elif code: title.add("%s" % code) else: title.add("(No name)") title.add_border() table.add_row() # left td = table.add_cell() td.add_style("width: 300px") td.add_style("min-width: 300px") td.add_style("vertical-align: top") div = DivWdg() td.add(div) div.add_class("spt_sobject_detail_top") thumb_table = Table() div.add(thumb_table) thumb_table.add_row() from tactic.ui.panel import ThumbWdg2 thumb = ThumbWdg2() # use a larger version for clearer display #thumb.set_icon_type('web') if my.parent: thumb.set_sobject(my.parent) search_key = my.parent.get_search_key() else: thumb.set_sobject(my.sobject) search_key = my.sobject.get_search_key() gallery_div = DivWdg() div.add( gallery_div ) gallery_div.add_class("spt_tile_gallery") thumb_table.add_behavior( { 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_sobject_detail_top"); var gallery_el = top.getElement(".spt_tile_gallery"); var class_name = 'tactic.ui.widget.gallery_wdg.GalleryWdg'; var kwargs = { search_key: bvr.search_key, search_keys: [bvr.search_key], }; spt.panel.load(gallery_el, class_name, kwargs); ''' } ) # prefer to see the original image, then web #thumb.set_option('image_link_order', 'main|web|icon') #thumb.set_option("detail", "false") #thumb.set_option("icon_size", "100%") td = thumb_table.add_cell(thumb) td.add_style("vertical-align: top") td.add_style("width: auto") td.add_style("padding: 15px") sobject_info_wdg = my.get_sobject_info_wdg() sobject_info_wdg.add_style("width: auto") td.add(sobject_info_wdg) if my.search_type == 'sthpw/task' and not my.parent: pass else: sobject_info_wdg = my.get_sobject_detail_wdg() td = table.add_cell() td.add(sobject_info_wdg) td.add_style("vertical-align: top") td.add_style("overflow: hidden") # right td = table.add_cell() td.add_style("text-align: left") td.add_style("vertical-align: top") td.add_class("spt_notes_wrapper") notes_div = DivWdg() td.add(notes_div) from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=my.search_key, context_hidden=False,\ show_note_expand=False) notes_div.add(discussion_wdg) menu = discussion_wdg.get_menu_wdg(notes_div) notes_div.add(menu) notes_div.add_style("min-width: 300px") notes_div.add_style("height: 200") notes_div.add_style("overflow-y: auto") notes_div.add_class("spt_resizable") # get the process if my.parent: process = my.sobject.get_value("process") else: process = '' # content tr = table.add_row() td = table.add_cell() td.add_attr("colspan", "5") #td.add_attr("colspan", "3") # create a state for tab. The tab only passes a search key # parent key search_key = SearchKey.get_by_sobject(my.sobject) parent_key = "" if search_key.startswith("sthpw/"): parent = my.sobject.get_parent() if parent: parent_key = parent.get_search_key() state = { 'search_key': search_key, 'parent_key': parent_key, 'process': process, } WebState.get().push(state) config_xml = my.get_config_xml() config = WidgetConfig.get(view="tab", xml=config_xml) if process: custom_view = "tab_config_%s" % process else: custom_view = "tab_config" search = Search("config/widget_config") search.add_filter("category", "TabWdg") search.add_filter("search_type", my.search_type) search.add_filter("view", custom_view) custom_config_sobj = search.get_sobject() if custom_config_sobj: custom_config_xml = custom_config_sobj.get_value("config") custom_config = WidgetConfig.get(view=custom_view, xml=custom_config_xml) config = WidgetConfigView(search_type='TabWdg', view=custom_view, configs=[custom_config, config]) #menu = my.get_extra_menu() #tab = TabWdg(config=config, state=state, extra_menu=menu) tab = TabWdg(config=config, state=state, show_add=False, show_remove=False, tab_offset=5 ) tab.add_style("margin: 0px -2px -2px -2px") td.add(tab) td.add_style("padding-top: 10px") return top
def get_display(self): div = DivWdg() search_type = "prod/asset" search_type_obj = SearchType.get(search_type) title = search_type_obj.get_title() title_wdg = DivWdg() title_wdg.add_style("font-size: 1.8em") title_wdg.add("%s" % (title)) div.add(title_wdg) div.add(HtmlElement.hr()) table = Table() div.add(table) table.set_max_width() table.add_row() from pyasm.widget import ThumbWdg, DiscussionWdg, SObjectTaskTableElement td = table.add_cell() td.add_style("width: 250px") td.add_style("vertical-align: top") td.add_style("border-right: solid 1px") title = DivWdg() title.add_class("maq_search_bar") x = DivWdg("[?] [x]") x.add_style("float: right") title.add(x) title.add("Info") td.add(title) thumb = ThumbWdg() thumb.set_sobject(sobject) td.add(thumb) from pyasm.prod.web import AssetInfoWdg info = AssetInfoWdg() info.thumb = thumb info.set_sobject(sobject) td.add(info) td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding-left: 5px") td.add_style("border-right: solid 1px") # notes title = DivWdg() title.add_class("maq_search_bar") x = DivWdg("[x]") x.add_style("float: right") title.add(x) title.add("Notes") td.add(title) discussion_wdg = DiscussionWdg() discussion_wdg.preprocess() discussion_wdg.set_sobject(sobject) td.add(discussion_wdg) td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding-left: 5px") td.add_style("border-right: solid 1px") # tasks title = DivWdg() title.add_class("maq_search_bar") x = DivWdg("[x]") x.add_style("float: right") title.add(x) title.add("Custom Properties") td.add(title) search = Search("prod/custom_property") search.add_filter("search_type", "sample3d/book") sobjects = search.get_sobjects() table = TableLayoutWdg(search_type="prod/custom_property", view='table') table.set_sobjects(sobjects) td.add(table) div.add(HtmlElement.hr()) div.add(HtmlElement.br(clear="all")) title_wdg = DivWdg() title_wdg.add_class("maq_search_bar") x = DivWdg("[x]") x.add_style("float: right") title_wdg.add(x) #title_wdg.add_style("font-size: 1.5em") title_wdg.add("Detail") div.add(title_wdg) div.add(HtmlElement.br()) # TEST getting schema search_type = sobject.get_base_search_type() schema = Schema.get_by_sobject(sobject) # add a second table table = Table() table.set_max_width() # show the snapshots for this sobject search_type = "sthpw/snapshot" search = Search(search_type) search.add_sobject_filter(sobject) search.set_limit(50) sobjects = search.get_sobjects() table.add_row() nav_td = table.add_cell() nav_td.add_style("width: 100px") nav_td.add_style("vertical-align: top") #section_wdg = self.get_section_wdg(sobject) #nav_td.add( section_wdg ) #from tactic.ui.panel import ManageViewPanelWdg #defined = ManageViewPanelWdg() from tactic.ui.panel import ManageViewWdg defined = ManageViewWdg() nav_td.add(defined) #content_wdg = TableLayoutWdg(search_type=search_type, view='table') #content_wdg.set_sobjects(sobjects) #content_td = table.add_cell() #content_td.set_id("sobject_relation") #content_td.add_style("display: table-cell") #content_td.add_style("vertical-align: top") #content_td.add(content_wdg) div.add(table) return div
def get_display(my): web = WebContainer.get_web() show_multi_project = web.get_form_value('show_multi_project') project = Project.get() search_type_objs = project.get_search_types(include_multi_project=show_multi_project) top = my.top top.add_class("spt_panel_stype_list_top") #top.add_style("min-width: 400px") #top.add_style("max-width: 1000px") #top.add_style("width: 100%") top.center() button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED) top.add(button) button.add_style("float: right") button.add_style("margin-top: -8px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.ProjectStartWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("project_setup", "Project Setup", class_name) ''' } ) button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon=IconWdg.ADD) top.add(button) button.add_style("float: left") button.add_style("margin-top: -8px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.SearchTypeCreatorWdg'; var kwargs = { }; var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs); var top = bvr.src_el.getParent(".spt_panel_stype_list_top"); popup.on_register_cbk = function() { spt.panel.refresh(top); } ''' } ) cb = CheckboxWdg('show_multi_project', label=' show multi-project') if show_multi_project: cb.set_checked() cb.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var panel = bvr.src_el.getParent('.spt_panel_stype_list_top') spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked}); ''' }) span = SpanWdg(css='small') top.add(span) top.add(cb) top.add("<br clear='all'/>") #search_type_objs = [] if not search_type_objs: arrow_div = DivWdg() top.add(arrow_div) icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32) icon.add_style("margin-top: -20") icon.add_style("margin-left: -15") icon.add_style("position: absolute") arrow_div.add(icon) arrow_div.add(" "*5) arrow_div.add("<b>Click to Add</b>") arrow_div.add_style("position: relative") arrow_div.add_style("margin-top: 5px") arrow_div.add_style("margin-left: 20px") arrow_div.add_style("float: left") arrow_div.add_style("padding: 25px") arrow_div.set_box_shadow("0px 5px 20px") arrow_div.set_round_corners(30) arrow_div.add_color("background", "background") div = DivWdg() top.add(div) div.add_border() div.add_style("min-height: 180px") div.add_style("width: 600px") div.add_style("margin: 30px auto") div.add_style("padding: 20px") div.add_color("background", "background3") icon = IconWdg( "WARNING", IconWdg.WARNING ) div.add(icon) div.add("<b>No Searchable Types have been created</b>") div.add("<br/><br/>") div.add("Searchables Types contain lists of items that are managed in this project. Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours.") div.add("<br/>"*2) div.add("For more information, read the help docs: ") from tactic.ui.app import HelpButtonWdg help = HelpButtonWdg(alias="main") div.add(help) div.add("<br/>") div.add("Click on the 'Add' button above to start adding new types.") return top div = DivWdg() top.add(div) #div.add_style("max-height: 300px") #div.add_style("overflow-y: auto") table = Table() div.add(table) table.add_style("margin-top: 10px") table.set_max_width() # group mouse over table.add_relay_behavior( { 'type': "mouseover", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})" } ) table.add_relay_behavior( { 'type': "mouseout", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})" } ) tr = table.add_row() tr.add_color("color", "color") tr.add_gradient("background", "background", -10) th = table.add_header("") th.add_style("text-align: left") th = table.add_header("Title") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Add") th.add_style("text-align: left") th = table.add_header("Import") th.add_style("text-align: left") th = table.add_header("Custom Columns") th.add_style("text-align: left") th = table.add_header("Workflow") th.add_style("text-align: left") th = table.add_header("Notifications") th.add_style("text-align: left") th = table.add_header("Triggers") th.add_style("text-align: left") th = table.add_header("Edit") th.add_style("text-align: left") #th = table.add_header("Security") #th.add_style("text-align: left") for i, search_type_obj in enumerate(search_type_objs): tr = table.add_row() tr.add_class("spt_row") if not i or not i%2: tr.add_color("background", "background3") else: tr.add_color("background", "background", -2 ) thumb = ThumbWdg() thumb.set_sobject(search_type_obj) thumb.set_icon_size(30) td = table.add_cell(thumb) search_type = search_type_obj.get_value("search_type") title = search_type_obj.get_title() table.add_cell(title) try: search = Search(search_type) count = search.get_count() if count: table.add_cell("%s item/s" % count) else: table.add_cell(" ") except: td = table.add_cell("< No table >") td.add_style("font-style: italic") td.add_style("color: #F00") continue #search = Search(search_type) #search.add_interval_filter("timestamp", "today") #created_today = search.get_count() #table.add_cell(created_today) td = table.add_cell() button = IconButtonWdg(title="View", icon=IconWdg.ZOOM) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': title, 'cbjs_action': ''' var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; // use tab var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); //spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) button.add_style("float: left") arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN) arrow_button.add_style("margin-left: 20px") td.add(arrow_button) cbk = ''' var activator = spt.smenu.get_activator(bvr); var class_name = bvr.class_name; var layout = bvr.layout; var kwargs = { search_type: bvr.search_type, layout: layout, view: bvr.view, simple_search_view: 'simple_search', element_names: bvr.element_names, }; // use tab var top = activator.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new('%s', '%s', class_name, kwargs); ''' % (title, title) from tactic.ui.panel import SwitchLayoutMenu SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False) td = table.add_cell() button = IconButtonWdg(title="Add", icon=IconWdg.ADD) td.add(button) button.add_behavior( { 'type': 'listen', 'search_type': search_type, 'event_name': 'startup_save:' + search_type_obj.get_title(), 'title': search_type_obj.get_title(), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); ''' } ) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': search_type_obj.get_title(), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: bvr.search_type, view: "insert", save_event: "startup_save:" + bvr.title } spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); ''' } ) """ td = table.add_cell() button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': title, 'cbjs_action': ''' var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'checkin', element_names: ['preview','code','name','description','history','general_checkin','notes'] }; // use tab var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); //spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) """ td = table.add_cell() button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': "Import Data", 'cbjs_action': ''' var class_name = 'tactic.ui.widget.CsvImportWdg'; var kwargs = { search_type: bvr.search_type, }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': "Add Custom Columns", 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ColumnEditWdg'; var kwargs = { search_type: bvr.search_type, }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE) button.add_style("float: left") td.add(button) search = Search("sthpw/pipeline") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg( "Has Items", IconWdg.CHECK, width=8 ) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior( { 'type': 'click_up', 'title': 'Workflow', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.PipelineEditWdg'; var kwargs = { search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL) button.add_style("float: left") td.add(button) search = Search("sthpw/notification") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg( "Has Items", IconWdg.CHECK, width=8 ) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior( { 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.TriggerToolWdg'; var kwargs = { mode: "search_type", search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT) td.add(button) button.add_style("float: left") search = Search("config/trigger") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg( "Has Items", IconWdg.CHECK, width=8 ) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior( { 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.TriggerToolWdg'; var kwargs = { mode: "search_type", search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_key': search_type_obj.get_search_key(), 'cbjs_action': ''' var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/sobject", view: "edit_startup", search_key: bvr.search_key } spt.panel.load_popup("Edit Searchable Type", class_name, kwargs); ''' } ) """ td = table.add_cell() button = IconButtonWdg(title="Security", icon=IconWdg.LOCK) td.add(button) button.add_behavior( { 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' alert("security"); ''' } ) """ columns_wdg = DivWdg() top.add(columns_wdg) return top
def get_display(my): div = DivWdg() search_type = "prod/asset" search_type_obj = SearchType.get(search_type) title = search_type_obj.get_title() title_wdg = DivWdg() title_wdg.add_style("font-size: 1.8em") title_wdg.add("%s" % (title) ) div.add(title_wdg) div.add(HtmlElement.hr()) table = Table() div.add(table) table.set_max_width() table.add_row() from pyasm.widget import ThumbWdg, DiscussionWdg, SObjectTaskTableElement td = table.add_cell() td.add_style("width: 250px") td.add_style("vertical-align: top") td.add_style("border-right: solid 1px") title = DivWdg() title.add_class("maq_search_bar") x = DivWdg("[?] [x]") x.add_style("float: right") title.add(x) title.add("Info") td.add(title) thumb = ThumbWdg() thumb.set_sobject(sobject) td.add(thumb) from pyasm.prod.web import AssetInfoWdg info = AssetInfoWdg() info.thumb = thumb info.set_sobject(sobject) td.add(info) td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding-left: 5px") td.add_style("border-right: solid 1px") # notes title = DivWdg() title.add_class("maq_search_bar") x = DivWdg("[x]") x.add_style("float: right") title.add(x) title.add("Notes") td.add(title) discussion_wdg = DiscussionWdg() discussion_wdg.preprocess() discussion_wdg.set_sobject(sobject) td.add(discussion_wdg) td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding-left: 5px") td.add_style("border-right: solid 1px") # tasks title = DivWdg() title.add_class("maq_search_bar") x = DivWdg("[x]") x.add_style("float: right") title.add(x) title.add("Custom Properties") td.add(title) search = Search("prod/custom_property") search.add_filter("search_type", "sample3d/book") sobjects = search.get_sobjects() table = TableLayoutWdg(search_type="prod/custom_property", view='table') table.set_sobjects(sobjects) td.add(table) div.add(HtmlElement.hr()) div.add(HtmlElement.br(clear="all")) title_wdg = DivWdg() title_wdg.add_class("maq_search_bar") x = DivWdg("[x]") x.add_style("float: right") title_wdg.add(x) #title_wdg.add_style("font-size: 1.5em") title_wdg.add("Detail" ) div.add(title_wdg) div.add(HtmlElement.br()) # TEST getting schema search_type = sobject.get_base_search_type() schema = Schema.get_by_sobject(sobject) # add a second table table = Table() table.set_max_width() # show the snapshots for this sobject search_type = "sthpw/snapshot" search = Search(search_type) search.add_sobject_filter(sobject) search.set_limit(50) sobjects = search.get_sobjects() table.add_row() nav_td = table.add_cell() nav_td.add_style("width: 100px") nav_td.add_style("vertical-align: top") #section_wdg = my.get_section_wdg(sobject) #nav_td.add( section_wdg ) #from tactic.ui.panel import ManageViewPanelWdg #defined = ManageViewPanelWdg() from tactic.ui.panel import ManageViewWdg defined = ManageViewWdg() nav_td.add(defined) #content_wdg = TableLayoutWdg(search_type=search_type, view='table') #content_wdg.set_sobjects(sobjects) #content_td = table.add_cell() #content_td.set_id("sobject_relation") #content_td.add_style("display: table-cell") #content_td.add_style("vertical-align: top") #content_td.add(content_wdg) div.add(table) return div
def get_chat_wdg(my, key, interval=False): div = DivWdg() div.add_class("spt_chat_session_top") div.add_color("background", "background") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_color("background", "background3") title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_border() icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE) icon.add_style("float: right") icon.add_style("margin-top: -5px") title_wdg.add(icon) icon.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var server = TacticServerStub.get(); var top = bvr.src_el.getParent(".spt_chat_session_top"); spt.behavior.destroy_element(top); ''' } ) current_user = Environment.get_user_name() logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key) for login in logins: if login.get_value("login") == current_user: continue thumb = ThumbWdg() thumb.set_icon_size(45) thumb.set_sobject(login) thumb.add_style("float: left") thumb.add_style("margin: -5px 10px 0px -5px") title_wdg.add(thumb) title_wdg.add(login.get_value("display_name")) title_wdg.add("<br clear='all'/>") history_div = DivWdg() div.add(history_div) history_div.add_class("spt_chat_history") history_div.add_style("width: auto") history_div.add_style("height: auto") history_div.add_style("max-height: 400px") history_div.add_style("padding: 5px") history_div.add_class("spt_resizable") history_div.add_border() history_div.add_style("overflow-y: auto") #history_div.add_style("font-size: 0.9em") search = Search("sthpw/message_log") search.add_filter("message_code", key) search.add_order_by("timestamp") message_logs = search.get_sobjects() last_login = None; last_date = None; for message_log in message_logs: login = message_log.get("login") message = message_log.get("message") timestamp = message_log.get_datetime_value("timestamp") #timestamp = timestamp.strftime("%b %d, %Y - %H:%M") timestamp_str = timestamp.strftime("%H:%M") date_str = timestamp.strftime("%b %d, %Y") msg = ""; msg += "<table style='margin-top: 5px; font-size: 0.9em; width: 100%'><tr><td colspan='2'>"; if date_str != last_date: msg += "<br/><b style='font-size: 1.0em'>"+date_str+"</b><hr/></td></tr>"; msg += "<tr><td>"; last_login = None if login != last_login: msg += "<b>"+login+"</b><br/>"; msg += message.replace("\n",'<br/>'); msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>"; msg += timestamp_str; msg += "</td></tr></table>"; history_div.add(msg) last_login = login last_date = date_str history_div.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.scrollTop = bvr.src_el.scrollHeight; ''' } ) if message_logs: last_message = message_logs[-1].get("message") last_login = message_logs[-1].get("login") else: last_message = "" last_login = "" div.add_attr("spt_last_message", last_message) div.add_attr("spt_last_login", last_login) if interval: div.add_behavior( { 'type': 'load', 'key': key, 'cbjs_action': r''' var text_el = bvr.src_el.getElement(".spt_chat_text"); var history_el = bvr.src_el.getElement(".spt_chat_history"); var callback = function(message) { //history_el.setStyle("background", "red"); var login = message.login; var timestamp = message.timestamp; if (timestamp) { var parts = timestamp.split(" "); parts = parts[1].split("."); timestamp = parts[0]; } else { timestamp = ""; } var tmp = message.message || ""; var last_message = bvr.src_el.getAttribute("spt_last_message"); var last_login = bvr.src_el.getAttribute("spt_last_login"); if (tmp == last_message && login == last_login) { return; } bvr.src_el.setAttribute("spt_last_message", tmp); bvr.src_el.setAttribute("spt_last_login", login); var msg = ""; msg += "<table style='margin-top: 5px; font-size: 0.9em; width: 100%'><tr><td>"; if (login != last_login) { msg += "<b>"+login+"</b><br/>"; } msg += tmp.replace(/\n/g,'<br/>'); msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>"; msg += timestamp; msg += "</td></tr></table>"; if (msg == history_el.last_msg) { return; } history_el.innerHTML = history_el.innerHTML + msg; // remember last message history_el.last_msg = msg; history_el.scrollTop = history_el.scrollHeight; } spt.message.set_interval(bvr.key, callback, 3000, bvr.src_el); ''' } ) text = TextAreaWdg("chat") div.add(text) text.add_class("spt_chat_text") text.add_style("width: 100%") text.add_style("padding: 5px") text.add_style("margin-top: -1px") text.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.addEvent("keydown", function(e) { var keys = ['tab','keys(control+enter)', 'enter']; var key = e.key; var input = bvr.src_el if (keys.indexOf(key) > -1) e.stop(); if (key == 'tab') { } else if (key == 'enter') { if (e.control == false) { pass; } else { // TODO: check if it's multi-line first //... use ctrl-ENTER for new-line, regular ENTER (RETURN) accepts value //var tvals = parse_selected_text(input); //input.value = tvals[0] + "\\n" + tvals[1]; //spt.set_cursor_position( input, tvals[0].length + 1 ); } } } ) ''' } ) button = ActionButtonWdg(title="Send") div.add(button) button.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chat_session_top"); var text_el = top.getElement(".spt_chat_text"); var message = text_el.value; if (!message) { return; } var history_el = top.getElement(".spt_chat_history"); var category = "chat"; var server = TacticServerStub.get(); var key = bvr.key; var last_message = server.log_message(key, message, {category:category, status:"in_progress"}); text_el.value = ""; ''' } ) return div
def get_display(my): search = Search("sthpw/login") logins = search.get_sobjects() top = my.top top.add_class("spt_panel_user_top") top.add_style("min-width: 400px") button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK) top.add(button) button.add_style("float: right") 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) ''' }) button = SingleButtonWdg(title="Add", tip="Add New User", icon=IconWdg.ADD) top.add(button) button.add_style("float: left") button.add_style("margin-top: -8px") top.add("<br clear='all'/>") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/login", view: "edit", } 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); } ''' }) #logins = [] if not logins: arrow_div = DivWdg() top.add(arrow_div) arrow_div.add("<b><<< Click to Add</b>") arrow_div.add_style("position: relative") arrow_div.add_style("margin-top: -35px") arrow_div.add_style("margin-left: 35px") arrow_div.add_style("float: left") arrow_div.add_style("padding: 5px") arrow_div.set_box_shadow("1px 1px 2px 2px") arrow_div.set_round_corners(10, corners=['TL', 'BL']) div = DivWdg() top.add(div) div.add_border() div.add_style("min-height: 180px") div.add_style("margin: 15px 30px 30px 30px") div.add_style("padding: 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") table = Table() table.set_max_width() table.add_style("margin-top: 10px") div.add(table) # group mouse over table.add_relay_behavior({ 'type': "mouseover", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})" }) table.add_relay_behavior({ 'type': "mouseout", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})" }) tr = table.add_row() tr.add_color("color", "color") tr.add_gradient("background", "background", -10) th = table.add_header(" ") th.add_style("text-align: left") th = table.add_header("Login") th.add_style("text-align: left") th = table.add_header("First Name") th.add_style("text-align: left") th = table.add_header("Last Name") th.add_style("text-align: left") th = table.add_header("Display Name") th.add_style("text-align: left") th = table.add_header("Activity") th.add_style("text-align: left") th = table.add_header("Groups") th.add_style("text-align: left") th = table.add_header("Security") th.add_style("text-align: left") th = table.add_header("Edit") th.add_style("text-align: left") for i, login in enumerate(logins): tr = table.add_row() tr.add_class("spt_row") if not i or not i % 2: tr.add_color("background", "background3") else: tr.add_color("background", "background", -2) thumb = ThumbWdg() thumb.set_sobject(login) thumb.set_icon_size(30) td = table.add_cell(thumb) td = table.add_cell(login.get_value("login")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("first_name")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("last_name")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("display_name")) td.add_style("padding: 3px") search_key = login.get_search_key() login_code = login.get_code() full_name = login.get_full_name() td = table.add_cell() button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR) td.add(button) button.add_behavior({ 'type': 'click_up', 'login_code': login_code, 'full_name': full_name, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.ScheduleUserToolWdg'; var kwargs = { login: bvr.login_code } var title = bvr.full_name + ' Schedule'; var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new("user_schedule", title, class_name, kwargs); //spt.panel.load_popup("Activty", class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.GroupAssignWdg'; var kwargs = { search_key: bvr.search_key }; var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Security", icon=IconWdg.LOCK) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.GroupSummaryWdg'; var kwargs = { search_key: bvr.search_key }; var popup = spt.panel.load_popup("Security Summary", class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Edit User", icon=IconWdg.EDIT) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_panel_user_top"); var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/login", view: "edit", search_key: bvr.search_key } var popup = spt.panel.load_popup("Create New User", class_name, kwargs); popup.on_save_cbk = function() { spt.panel.refresh(top); } ''' }) return top
def get_display(my): my.sobject = my.get_sobject() top = DivWdg() top.add_class("spt_detail_top") top.add_color("background", "background") top.add_color("color", "color") if not my.sobject: top.add("No SObject defined for this widget") return top if my.parent: my.search_type = my.parent.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.parent) top.add_attr("spt_parent_key", my.search_key) my.pipeline_code = my.parent.get_value("pipeline_code", no_exception=True) my.full_search_type = my.parent.get_search_type() else: my.pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True) my.search_type = my.sobject.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.sobject) my.full_search_type = my.sobject.get_search_type() if not my.pipeline_code: my.pipeline_code = 'default' top.add_style("text-align: left") my.set_as_panel(top) table = Table() #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table.add_color("background", "background") table.add_color("color", "color") top.add(table) table.set_max_width() table.add_row() # left #td = table.add_cell(resize=False) td = table.add_cell() #td.add_style("padding: 10px") td.add_style("width: 200px") td.add_style("min-width: 200px") td.add_style("vertical-align: top") #td.add_border() #td.add_style("border-style: solid") #td.add_style("border-width: 1px 0 1px 1px") #td.add_color("border-color", "border") #td.add_color("background", "background", -10) if my.parent: code = my.parent.get_code() else: code = my.sobject.get_code() # add the tile title = DivWdg() td.add(title) title.add_gradient("background", "background3", 0, -10) title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add_style("font-size: 1.4em") title.add("%s" % code) title.add_border() div = DivWdg() td.add(div) div.add_class("spt_sobject_detail_top") thumb_table = Table() div.add(thumb_table) thumb_table.add_row() thumb = ThumbWdg() # use a larger version for clearer display thumb.set_icon_type('web') # prefer to see the original image, then web thumb.set_option('image_link_order', 'main|web|icon') thumb.set_option("detail", "false") thumb.set_option("icon_size", "100%") td = thumb_table.add_cell(thumb) td.add_style("vertical-align: top") td.add_style("width: 240px") td.add_style("padding: 15px") if my.parent: thumb.set_sobject(my.parent) else: thumb.set_sobject(my.sobject) sobject_info_wdg = my.get_sobject_info_wdg() sobject_info_wdg.add_style("width: 200px") td.add(sobject_info_wdg) if my.search_type == 'sthpw/task' and not my.parent: pass else: sobject_info_wdg = my.get_sobject_detail_wdg() td = table.add_cell() td.add(sobject_info_wdg) td.add_style("vertical-align: top") td.add_style("overflow: hidden") # right td = table.add_cell() td.add_style("text-align: left") td.add_style("vertical-align: top") #td.add_color("background", "background", -10) td.add_class("spt_notes_wrapper") #td.add_border() # add the title title = DivWdg() td.add(title) title.add_gradient("background", "background3", 0, -10) title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Notes") title.add_border() notes_div = DivWdg() td.add(notes_div) from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=my.search_key, context_hidden=False, show_note_expand=False) notes_div.add(discussion_wdg) notes_div.add_style("min-width: 300px") notes_div.add_style("height: 200") notes_div.add_style("overflow-y: auto") notes_div.add_class("spt_resizable") # get the process if my.parent: process = my.sobject.get_value("process") else: process = '' # content tr = table.add_row() td = table.add_cell() td.add_attr("colspan", "5") #td.add_attr("colspan", "3") # create a state for tab. The tab only passes a search key # parent key search_key = SearchKey.get_by_sobject(my.sobject) parent = my.sobject.get_parent() if parent: parent_key = parent.get_search_key() else: parent_key = "" state = { 'search_key': search_key, 'parent_key': parent_key, 'process': process, } WebState.get().push(state) config_xml = my.get_config_xml() config = WidgetConfig.get(view="tab", xml=config_xml) if process: custom_view = "tab_config_%s" % process else: custom_view = "tab_config" search = Search("config/widget_config") search.add_filter("category", "TabWdg") search.add_filter("search_type", my.search_type) search.add_filter("view", custom_view) custom_config_sobj = search.get_sobject() if custom_config_sobj: custom_config_xml = custom_config_sobj.get_value("config") custom_config = WidgetConfig.get(view=custom_view, xml=custom_config_xml) config = WidgetConfigView(search_type='TabWdg', view=custom_view, configs=[custom_config, config]) #menu = my.get_extra_menu() #tab = TabWdg(config=config, state=state, extra_menu=menu) tab = TabWdg(config=config, state=state, show_add=False, show_remove=False, tab_offset=5) tab.add_style("margin: 0px -2px -2px -2px") td.add(tab) td.add_style("padding-top: 10px") return top
def get_display(my): top = my.top login = my.kwargs.get("login") if not login or login == "$LOGIN": login = Environment.get_user_name() login_sobj = Login.get_by_code(login) # top.add_style("margin-top: -2px") # top.add_style("margin-left: -2px") thumb_div = DivWdg() thumb_div.add_style("float: left") thumb_div.add_style("margin-right: 5px") thumb_div.add_style("margin-bottom: 5px") thumb_div.add_style("padding-top: 1px") thumb = ThumbWdg() thumb.set_sobject(login_sobj) thumb_div.add(thumb) thumb.set_icon_size(90) thumb.set_aspect("height") full_name = login_sobj.get_full_name() info_wdg = DivWdg() top.add(info_wdg) name_wdg = DivWdg() info_wdg.add(thumb_div) info_wdg.add(name_wdg) name_wdg.add(" " * 3) name_wdg.add(full_name) name_wdg.add_style("font-size: 1.5em") name_wdg.add_style("font-weight: bold") name_wdg.add_style("padding: 5px") # name_wdg.add_style("margin-left: -10px") name_wdg.add_color("background", "background3") name_wdg.add_style("height: 20px") name_wdg.add_style("margin-bottom: 0px") name_wdg.add_border() info_wdg.add("<br/>") from tactic.ui.container import TabWdg # return if the supplied tab view has a config xml if my.tab_view: search = Search("config/widget_config") search.add_filter("category", "TabWdg") search.add_filter("view", my.tab_view) config_sobj = search.get_sobject() if config_sobj: config_xml = config_sobj.get_value("config") # replace the variable $login with the login clicked if login: config_xml = config_xml.replace("$login", login) tab = TabWdg(config_xml=config_xml, view=my.tab_view, show_add=False, show_remove=False) top.add(tab) return top config_xml = [] config_xml.append("<config>") config_xml.append("<tab>") config_xml.append( """ <element name='activity'> <display class='tactic.ui.widget.ActivityCalendarWdg'> <login>%s</login> <cell_width>100px</cell_width> <cell_height>50px</cell_height> <show_header>true</show_header> <show_border>false</show_border> </display> </element> """ % login ) config_xml.append( """ <element name='schedule'> <display class='tactic.ui.widget.TaskCalendarWdg'> <assigned>%s</assigned> <sobject_display_expr>%s</sobject_display_expr> <show_header>true</show_header> <show_border>false</show_border> </display> </element> """ % (login, my.sobject_display_expr) ) config_xml.append( """ <element name='tasks'> <display class='tactic.ui.panel.FastTableLayoutWdg'> <search_type>sthpw/task</search_type> <view>table</view> <expression>@SOBJECT(sthpw/task['assigned','%s']['@ORDER_BY', 'bid_start_date desc'])</expression> <mode>simple</mode> </display> </element> """ % login ) config_xml.append( """ <element name='work_hours'> <display class='tactic.ui.widget.SObjectCalendarWdg'> <login>%s</login> <!-- <cell_width>100px</cell_width> --> <cell_height>50px</cell_height> <show_header>true</show_header> <show_border>false</show_border> <search_type>sthpw/work_hour</search_type> <handler>tactic.ui.widget.WorkHourCalendarDayWdg</handler> <start_date_col>day</start_date_col> <end_date_col>day</end_date_col> </display> </element> """ % login ) config_xml.append( """ <element name='recent transactions'> <display class='tactic.ui.panel.FastTableLayoutWdg'> <search_type>sthpw/transaction_log</search_type> <view>table</view> <expression>@SOBJECT(sthpw/transaction_log['login','%s']['@ORDER_BY','timestamp desc']['@LIMIT','30'])</expression> <element_names>code,timestamp,namespace,description,transaction_log_hidden</element_names> <show_shelf>false</show_shelf> <show_select>false</show_select> </display> </element> """ % login ) config_xml.append("</tab>") config_xml.append("</config>") config_xml = "".join(config_xml) tab = TabWdg(config_xml=config_xml, view="tab", show_add=False, show_remove=False) top.add(tab) tab.add_style("margin-left: -2px") tab.add_style("margin-right: -2px") return top
def get_preview_wdg(cls, subscription, category='', message_code=''): size = 60 if subscription: category = subscription.get_value("category") message_code = subscription.get_value("message_code") if category == 'sobject': sobject = Search.get_by_search_key(message_code) thumb = DivWdg() thumb_wdg = ThumbWdg() thumb.add(thumb_wdg) thumb_wdg.set_sobject(sobject) thumb_wdg.set_icon_size(size) search_code = sobject.get_code() thumb.add_behavior( { 'type': 'click_up', 'search_key': message_code, 'search_code': search_code, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.SObjectDetailWdg'; var kwargs = { search_key: bvr.search_key } spt.tab.set_main_body_tab(); var title = "Detail ["+bvr.search_code+"]"; spt.app_busy.show("Loading " + bvr.search_code); spt.tab.add_new(bvr.search_code, title, class_name, kwargs); spt.app_busy.hide(); ''' } ) elif category == 'chat': thumb = DivWdg() thumb.add_style("width: %s" % size) thumb.add_style("height: %s" % (size*3/4)) thumb.add_border() thumb.add_style('text-align: center') thumb.add_class("hand") message = Search.get_by_code("sthpw/message", message_code) login_code = message.get_value("login") login = Search.get_by_code("sthpw/login", login_code) thumb_wdg = ThumbWdg() thumb.add(thumb_wdg) thumb_wdg.set_sobject(login) thumb_wdg.set_icon_size(size) if subscription: key = subscription.get_value("message_code") thumb.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var class_name = 'tactic.ui.app.ChatSessionWdg'; var kwargs = { 'key': bvr.key, } spt.panel.load_popup("Chat: " + bvr.key, class_name, kwargs); ''' } ) else: if not category: category = "default" preview_text = "No Preview Available" thumb = DivWdg() thumb.add_style("width: %s" % size) thumb.add_style("height: %s" % (size*3/4)) thumb.add_border() thumb.add_color("background", "background") #thumb.add("<br/>") thumb.add(preview_text) thumb.add_style('text-align: center') thumb.add_class("hand") thumb.add_style("margin: 3px") return thumb
def get_display(my): top = DivWdg() top.add_border() top.add_style("padding: 10px") top.add_color("color", "color") top.add_gradient("background", "background", 0, -5) #top.add_style("height: 550px") top.add_class("spt_reports_top") my.set_as_panel(top) inner = DivWdg() top.add(inner) title = DivWdg() title.add("Reports") title.add_style("font-size: 18px") title.add_style("font-weight: bold") title.add_style("text-align: center") title.add_style("padding: 10px") title.add_style("margin: -10px -10px 0px -10px") inner.add(title) title.add_gradient("background", "background3", 5, -10) from tactic.ui.widget import TitleWdg subtitle = TitleWdg(name_of_title='List of Built in Reports',help_alias='main') inner.add(subtitle) inner.add("<br/>") button_div = DivWdg() inner.add(button_div) button_div.add_class("spt_buttons_top") button_div.add_style("margin-top: -5px") button_div.add_style("margin-bottom: 30px") button_div.add_border() button_div.add_style("margin-top: -15px") button_div.add_style("margin-bottom: 0px") button_div.add_style("width: 100%") button_div.add_style("height: 33px") button_div.add_color("background", "background2") button_div.add_style("margin-left: auto") button_div.add_style("margin-right: auto") button = SingleButtonWdg(title="Collapse", icon=IconWdg.HOME) button_div.add(button) button.add_style("float: left") button.add_style("left: 5px") button.add_style("top: 5px") # FIXME: get home for the user #home = 'tactic.ui.startup.ContentCreatorWdg' home = 'tactic.ui.startup.MainWdg' button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.MainWdg'; var kwargs = { help_alias: 'main' }; spt.tab.add_new("_startup", "Startup", class_name, kwargs); ''' } ) """ button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP) button_div.add(button) button.add_class("spt_collapse") inner.add(button_div) button.add_style("float: left") button.add_style("left: 5px") button.add_style("top: 5px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_reports_top"); var element = top.getElement(".spt_reports_list"); var buttons = bvr.src_el.getParent(".spt_buttons_top"); expand = buttons.getElement(".spt_expand"); new Fx.Tween(element).start('margin-top', "-400px"); expand.setStyle("display", ""); bvr.src_el.setStyle("display", "none"); ''' } ) button = SingleButtonWdg(title="Expand", icon=IconWdg.ARROW_DOWN) button.add_style("display: none") button.add_class("spt_expand") button_div.add(button) button.add_style("left: 5px") button.add_style("top: 5px") inner.add(button_div) button.add_style("float: left") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_reports_top"); var element = top.getElement(".spt_reports_list"); var buttons = bvr.src_el.getParent(".spt_buttons_top"); collapse = buttons.getElement(".spt_collapse"); new Fx.Tween(element).start('margin-top', "0px"); collapse.setStyle("display", ""); bvr.src_el.setStyle("display", "none"); ''' } ) """ reports = [] # read the config file from pyasm.widget import WidgetConfig tmp_path = __file__ dir_name = os.path.dirname(tmp_path) file_path="%s/../config/reports-conf.xml" % (dir_name) config = WidgetConfig.get(file_path=file_path, view="definition") category = my.kwargs.get('category') # get all of the configs from the database if not category or category in ["custom_reports", "custom_charts"]: search = Search("config/widget_config") search.add_op("begin") if category == "custom_reports": search.add_filter("widget_type", "report") elif category == "custom_charts": search.add_filter("widget_type", "chart") elif not category: search.add_filters("widget_type", ["chart","report"]) search.add_op("or") db_configs = search.get_sobjects() else: db_configs = [] element_names = my.kwargs.get("element_names") if element_names is None: element_names = config.get_element_names() project = Project.get() for element_name in element_names: key = {'project': project.get_code(), 'element': element_name} key2 = {'project': project.get_code(), 'element': '*'} key3 = {'element': element_name} key4 = {'element': '*'} keys = [key, key2, key3, key4] if not top.check_access("link", keys, "view", default="deny"): continue attrs = config.get_element_attributes(element_name) report_data = {} kwargs = config.get_display_options(element_name) class_name = kwargs.get('class_name') # the straight xml definition contains the sidebar class_name # with LinkWdg ... we shouldn't use this, so build the # element from scratch #xml = config.get_element_xml(element_name) from pyasm.search import WidgetDbConfig xml = WidgetDbConfig.build_xml_definition(class_name, kwargs) report_data['class_name'] = class_name report_data['kwargs'] = kwargs report_data['title'] = attrs.get("title") report_data['description'] = attrs.get("description") report_data['image'] = attrs.get("image") report_data['xml'] = xml reports.append(report_data) for db_config in db_configs: element_name = db_config.get_value("view") key = {'project': project.get_code(), 'element': element_name} key2 = {'project': project.get_code(), 'element': '*'} key3 = {'element': element_name} key4 = {'element': '*'} keys = [key, key2, key3, key4] if not top.check_access("link", keys, "view", default="deny"): continue report_data = {} view = db_config.get_value("view") kwargs = { 'view': view } parts = view.split(".") title = Common.get_display_title(parts[-1]) xml = db_config.get_value("config") report_data['class_name'] = "tactic.ui.panel.CustomLayoutWdg" report_data['kwargs'] = kwargs report_data['title'] = title report_data['description'] = title report_data['image'] = None report_data['xml'] = xml report_data['widget_type'] = db_config.get_value("widget_type") if report_data['widget_type'] == 'report': report_data['category'] = "custom_reports" elif report_data['widget_type'] == 'chart': report_data['category'] = "custom_charts" reports.append(report_data) """ report_data = { 'title': 'Tasks Completed This Week', 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'kwargs': { 'search_type': 'sthpw/task', 'view': 'table' }, } reports.append(report_data) """ if category == 'list_item_reports' or not category: search_types = Project.get().get_search_types() for search_type in search_types: base_key = search_type.get_base_key() key = {'project': project.get_code(), 'code': base_key} key2 = {'project': project.get_code(), 'code': '*'} key3 = {'code': base_key} key4 = {'code': '*'} keys = [key, key2, key3, key4] if not top.check_access("search_type", keys, "view", default="deny"): continue if not SearchType.column_exists(base_key, "pipeline_code"): continue thumb_div = DivWdg() image = thumb_div thumb_div.add_border() thumb_div.set_box_shadow("1px 1px 1px 1px") thumb_div.add_style("width: 60px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(search_type) thumb.set_icon_size(60) report_data = { 'title': '%s Workflow Status' % search_type.get_title(), 'description': 'Number of items in each process', 'class_name': 'tactic.ui.report.stype_report_wdg.STypeReportWdg', 'kwargs': { 'search_type': base_key }, 'image': thumb_div } reports.append(report_data) report_data = { 'title': '%s Labor Cost Report' % search_type.get_title(), 'description': 'Labor Cost Breakdown for each Item', 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'kwargs': { 'search_type': search_type.get_code(), 'view': "table", 'show_header': False, 'mode': 'simple', 'element_names': "preview,code,title,cost_breakdown,bid_hours,bid_cost,actual_hours,actual_cost,overbudget,variance" }, 'image': IconWdg("", IconWdg.REPORT_03) } reports.append(report_data) table2 = Table() inner.add(table2) table2.add_style("width: 100%") categories_div = DivWdg() td = table2.add_cell(categories_div) td.add_style("vertical-align: top") td.add_style("width: 200px") td.add_color("background", "background3") td.add_border() #categories_div.add_style("margin: -1px 0px 0px -1px") categories_div.add_style("padding-top: 10px") #categories_div.add_style("float: left") categories_div.add_color("color", "color3") categories = config.get_all_views() categories.insert(-1, "list_item_reports") categories.insert(-1, "custom_charts") categories.insert(-1, "custom_reports") table_div = DivWdg() td = table2.add_cell(table_div) td.add_style("vertical-align: top") table_div.add_class("spt_reports_list") table_div.add_border() table_div.add_color("background", "background", -5) table_div.add_style("min-height: 500px") for i, category in enumerate(categories): if i == len(categories) - 1: categories_div.add("<hr/>") config.set_view(category) element_names = config.get_element_names() if category == "definition": title = "All Reports" else: title = Common.get_display_title(category) category_div = DivWdg() categories_div.add(category_div) category_div.add(title) category_div.add_style("padding: 5px") category_div.add_class("hand") category_div.add_behavior( { 'type': 'click_up', 'category': category, 'element_names': element_names, 'class_name': Common.get_full_class_name(my), 'cbjs_action': ''' var kwargs = { is_refresh: true, category: bvr.category, element_names: bvr.element_names } //spt.panel.refresh(top, kwargs); var top = bvr.src_el.getParent(".spt_reports_top"); spt.panel.load(top, bvr.class_name, kwargs); ''' } ) bgcolor = category_div.get_color("background3", -10) category_div.add_behavior( { 'type': 'mouseover', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.bgcolor); ''' } ) category_div.add_behavior( { 'type': 'mouseout', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background", ""); ''' } ) # create a bunch of panels table = Table() table_div.add(table) table.add_color("color", "color") table.add_style("margin-top: 20px") table.center() table_div.add_style("margin: -3px -3px -1px -2px") if not reports: tr = table.add_row() td = table.add_cell() td.add("There are no reports defined.") td.add_style("padding: 50px") if my.kwargs.get("is_refresh") in ['true', True]: return inner else: return top for i, report in enumerate(reports): #if i == 0 or i%4 == 0: if i%3 == 0: tr = table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = report #description = '''The schema is used to layout the basic components of your project. Each component represents a list of items that you use in your business everyday.''' description = report.get("title") # Each node will contain a list of "items" and will be stored as a table in the database.''' class_name = report.get("class_name") kwargs = report.get("kwargs") title = report.get("title") description = report.get("description") widget_type = report.get("widget_type") image = report.get("image") icon = report.get("icon") xml = report.get("xml") if image: div = DivWdg() if isinstance(image, basestring): image = image.upper() image = eval("IconWdg('', IconWdg.%s)" % image) div.add_style("margin-left: 15px") div.add_style("margin-top: 5px") else: image = image div.add(image) image = div elif icon: icon = icon.upper() image = eval("IconWdg('', IconWdg.%s)" % icon) else: div = DivWdg() """ import random num = random.randint(0,3) if num == 1: image = IconWdg("Bar Chart", IconWdg.GRAPH_BAR_01) elif num == 2: image = IconWdg("Bar Chart", IconWdg.GRAPH_LINE_01) else: image = IconWdg("Bar Chart", IconWdg.GRAPH_BAR_02) """ if widget_type == "chart": image = IconWdg("Chart", IconWdg.GRAPH_BAR_02) else: image = IconWdg("No Image", IconWdg.WARNING) div.add_style("margin-left: 15px") div.add_style("margin-top: 5px") div.add(image) image = div behavior = { 'type': 'click_up', 'title': title, 'class_name': class_name, 'kwargs': kwargs, 'cbjs_action': ''' spt.tab.set_main_body_tab(); //var top = bvr.src_el.getParent(".spt_reports_top"); //spt.tab.set_tab_top(top); spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs); ''' } schema_wdg = my.get_section_wdg(title, description, image, behavior) schema_wdg.add_behavior( { 'type': 'load', 'title': title, 'class_name': class_name, 'xml': xml, 'kwargs': kwargs, 'cbjs_action': ''' var report_top = bvr.src_el; report_top.kwargs = bvr.kwargs; report_top.class_name = bvr.class_name; report_top.element_name = bvr.title; report_top.xml = bvr.xml; ''' } ) td.add(schema_wdg) inner.add("<br/>") #from tactic.ui.container import TabWdg #tab = TabWdg(show_add=False) #inner.add(tab) if my.kwargs.get("is_refresh") in ['true', True]: return inner else: return top
def handle_instance(my, table, instance, asset, node_name='', publish=True, allow_ref_checkin=False): # handle the case where asset is not defined if not asset: table.add_row() table.add_blank_cell() table.add_blank_cell() # FIXME: Maya specific parts = instance.split(":") instance_name = parts[0] asset_code = parts[1] if instance_name == asset_code: table.add_cell(instance_name) else: table.add_cell(instance) td = table.add_cell() td.add("< %s node >" % my.session.get_node_type(instance_name)) table.add_blank_cell() return # get the pipeline for this asset and handlers for the pipeline process_name = my.process_select.get_value() handler_hidden = my.get_handler_input(asset, process_name) pipeline = Pipeline.get_by_sobject(asset) # TEST: switch this to using node name instead, if provided if node_name: instance_node = my.session.get_node(node_name) else: instance_node = my.session.get_node(instance) if instance_node is None: return if Xml.get_attribute(instance_node, "reference") == "true": is_ref = True else: is_ref = False namespace = Xml.get_attribute(instance_node, "namespace") if not namespace: namespace = instance asset_code = asset.get_code() is_set = False if asset.get_value('asset_type', no_exception=True) in ['set', 'section']: is_set = True tr = table.add_row() if is_set: tr.add_class("group") if publish and (allow_ref_checkin or not is_ref): checkbox = CheckboxWdg("asset_instances") if is_set: checkbox = CheckboxWdg("set_instances") checkbox.set_option("value", "%s|%s|%s" % \ (namespace, asset_code, instance) ) checkbox.set_persist_on_submit() td = table.add_cell(checkbox) else: td = table.add_blank_cell() # only one will be added even if there are multiple if handler_hidden: td.add(handler_hidden) # add the thumbnail thumb = ThumbWdg() thumb.set_name("images") thumb.set_sobject(asset) thumb.set_icon_size(60) table.add_cell(thumb) info_wdg = Widget() info_wdg.add(HtmlElement.b(instance)) if not node_name: node_name = '%s - %s' % (asset_code, asset.get_name()) info_div = DivWdg(node_name) info_div.add_style('font-size: 0.8em') info_wdg.add(info_div) info_div.add(HtmlElement.br(2)) if pipeline: info_div.add(pipeline.get_code()) table.add_cell(info_wdg) # by default can't checkin references if not allow_ref_checkin and is_ref: #icon = IconWdg("error", IconWdg.ERROR) #td = table.add_cell(icon) td = table.add_cell() td.add(HtmlElement.b("Ref. instance")) ''' import_button = ProdIconButtonWdg('import') import_button.add_event('onclick', "import_instance('%s')" %instance) td.add(import_button) ''' table.add_cell(my.get_save_wdg(my.current_sobject)) elif publish: textarea = TextAreaWdg() textarea.set_persist_on_submit() textarea.set_name("%s_description" % instance) textarea.set_attr("cols", "35") textarea.set_attr("rows", "2") table.add_cell(textarea) table.add_cell(my.get_save_wdg(my.current_sobject)) else: table.add_blank_cell() table.add_blank_cell()
def init(my): # get the args in the URL args = WebContainer.get_web().get_form_args() search_type = args['search_type'] search_id = args['search_id'] sobject = Search.get_by_id(search_type, search_id) main_div = DivWdg() main_div.add_style("width: 95%") main_div.add_style("float: right") my.add(main_div) if isinstance(sobject, Shot): content_id ='summary_story_%s' %sobject.get_id() title_id = 'story_head_%s' %sobject.get_id() story_div = DivWdg(id=content_id) story_div.add_style('display','block') story_head = HtmlElement.h3("Storyboard") my.add_title_style(story_head, title_id, content_id) main_div.add(story_head) main_div.add(story_div) storyboard_table = TableWdg("prod/storyboard", "summary", css='minimal') search = Search("prod/storyboard") search.add_filter( sobject.get_foreign_key(), sobject.get_code() ) sobjects = search.get_sobjects() storyboard_table.set_sobjects(sobjects) story_div.add(storyboard_table) # add reference material search = Search("sthpw/connection") search.add_filter("src_search_type", search_type) search.add_filter("src_search_id", search_id) connections = search.get_sobjects() if connections: content_id ='summary_ref_%s' %sobject.get_id() title_id = 'ref_head_%s' %sobject.get_id() ref_head = HtmlElement.h3("Reference") my.add_title_style(ref_head, title_id, content_id) ref_div = DivWdg(id = content_id) ref_div.add_style('display','block') for connection in connections: thumb = ThumbWdg() thumb.set_name("snapshot") dst_search_type = connection.get_value("dst_search_type") dst_search_id = connection.get_value("dst_search_id") dst = Search.get_by_id(dst_search_type, dst_search_id) thumb.set_sobject(dst) ref_div.add(thumb) main_div.add(ref_head) main_div.add(ref_div) task_head = HtmlElement.h3("Tasks") content_id ='summary_task_%s' %sobject.get_id() title_id = 'task_head_%s' %sobject.get_id() my.add_title_style(task_head, title_id, content_id) main_div.add(task_head) task_div = DivWdg(id=content_id) task_div.add_style('display','block') main_div.add(task_div) search = Search("sthpw/task") #if process != "": # search.add_filter("process", process) search.add_filter("search_type", search_type) search.add_filter("search_id", search_id) #search.set_limit(4) task_table = TableWdg("sthpw/task", "summary", css='minimal') task_table.set_id('sthpw/task%s' % search_id) task_table.set_search(search) task_div.add(task_table) content_id ='summary_hist_%s' %sobject.get_id() title_id = 'hist_head_%s' %sobject.get_id() hist_head = HtmlElement.h3("Checkin History") my.add_title_style(hist_head, title_id, content_id) hist_div = DivWdg(id=content_id) hist_div.add_style('display','block') main_div.add(hist_head) main_div.add(hist_div) from flash_asset_history_wdg import FlashAssetHistoryWdg history = FlashAssetHistoryWdg() hist_div.add(history) main_div.add(HtmlElement.br())
def get_display(my): search = Search("sthpw/login") logins = search.get_sobjects() top = my.top top.add_class("spt_panel_user_top") top.add_style("min-width: 400px") button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK) top.add(button) button.add_style("float: right") 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) ''' } ) button = SingleButtonWdg(title="Add", tip="Add New User", icon=IconWdg.ADD) top.add(button) button.add_style("float: left") button.add_style("margin-top: -8px") top.add("<br clear='all'/>") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/login", view: "edit", } 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); } ''' } ) #logins = [] if not logins: arrow_div = DivWdg() top.add(arrow_div) arrow_div.add("<b><<< Click to Add</b>") arrow_div.add_style("position: relative") arrow_div.add_style("margin-top: -35px") arrow_div.add_style("margin-left: 35px") arrow_div.add_style("float: left") arrow_div.add_style("padding: 5px") arrow_div.set_box_shadow("1px 1px 2px 2px") arrow_div.set_round_corners(10, corners=['TL','BL']) div = DivWdg() top.add(div) div.add_border() div.add_style("min-height: 180px") div.add_style("margin: 15px 30px 30px 30px") div.add_style("padding: 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") table = Table() table.set_max_width() table.add_style("margin-top: 10px") div.add(table) # group mouse over table.add_relay_behavior( { 'type': "mouseover", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})" } ) table.add_relay_behavior( { 'type': "mouseout", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})" } ) tr = table.add_row() tr.add_color("color", "color") tr.add_gradient("background", "background", -10) th = table.add_header(" ") th.add_style("text-align: left") th = table.add_header("Login") th.add_style("text-align: left") th = table.add_header("First Name") th.add_style("text-align: left") th = table.add_header("Last Name") th.add_style("text-align: left") th = table.add_header("Display Name") th.add_style("text-align: left") th = table.add_header("Activity") th.add_style("text-align: left") th = table.add_header("Groups") th.add_style("text-align: left") th = table.add_header("Security") th.add_style("text-align: left") th = table.add_header("Edit") th.add_style("text-align: left") for i, login in enumerate(logins): tr = table.add_row() tr.add_class("spt_row") if not i or not i%2: tr.add_color("background", "background3") else: tr.add_color("background", "background", -2 ) thumb = ThumbWdg() thumb.set_sobject(login) thumb.set_icon_size(30) td = table.add_cell(thumb) td = table.add_cell(login.get_value("login")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("first_name")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("last_name")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("display_name")) td.add_style("padding: 3px") search_key = login.get_search_key() login_code = login.get_code() full_name = login.get_full_name() td = table.add_cell() button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR) td.add(button) button.add_behavior( { 'type': 'click_up', 'login_code': login_code, 'full_name': full_name, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.ScheduleUserToolWdg'; var kwargs = { login: bvr.login_code } var title = bvr.full_name + ' Schedule'; var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new("user_schedule", title, class_name, kwargs); //spt.panel.load_popup("Activty", class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.GroupAssignWdg'; var kwargs = { search_key: bvr.search_key }; var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Security", icon=IconWdg.LOCK) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.GroupSummaryWdg'; var kwargs = { search_key: bvr.search_key }; var popup = spt.panel.load_popup("Security Summary", class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Edit User", icon=IconWdg.EDIT) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_panel_user_top"); var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/login", view: "edit", search_key: bvr.search_key } var popup = spt.panel.load_popup("Create New User", class_name, kwargs); popup.on_save_cbk = function() { spt.panel.refresh(top); } ''' } ) return top
def get_display(my): my.search_key = my.kwargs.get("search_key") my.context = my.kwargs.get("context") assert my.search_key assert my.context top = DivWdg() my.set_as_panel(top) top.add_class("spt_review_top") table = Table() top.add(table) table.add_row() left = table.add_cell() left.add_style("vertical-align: top") button = IconButtonWdg("Visual Notes", IconWdg.EDIT) button.add_behavior( { "type": "click_up", "kwargs": {"search_key": my.search_key, "context": my.context}, "cbjs_action": """ var top = bvr.src_el.getParent(".spt_review_top"); var content = top.getElement(".spt_review_content"); spt.panel.load(content, "tactic.ui.widget.visual_notes_wdg.VisualNotesWdg", bvr.kwargs); """, } ) left.add(button) # add a refresh button and a gear menu button = IconButtonWdg("Refresh", IconWdg.REFRESH) button.add_behavior( { "type": "click_up", "cbjs_action": """ var panel = bvr.src_el.getParent(".spt_review_top"); spt.panel.refresh(panel); """, } ) left.add(button) right = table.add_cell() right.add_style("vertical-align: top") right.add("Image Area") content_div = DivWdg() content_div.add_class("spt_review_content") content_div.add_style("padding: 5px") content_div.add_style("margin: 5px") content_div.add_style("border: solid 1px #999") content_div.add_style("min-width: 500px") content_div.add_style("min-height: 400px") content_div.add_style("height: 100%") right.add(content_div) sobject = Search.get_by_search_key(my.search_key) note_context = "%s|note" % my.context snapshots = Search.eval("@SOBJECT(sthpw/snapshot['context','=','%s'])" % note_context, [sobject]) vnotes_div = DivWdg() vnotes_div.add_style("overflow: auto") vnotes_div.add_style("width: 200px") vnotes_div.add_style("min-height: 400px") vnotes_div.add_style("max-height: 600px") vnotes_div.add_style("border: solid 1px #999") vnotes_div.add_style("padding: 5px") vnotes_div.add_style("margin: 5px") left.add(vnotes_div) if not snapshots: vnotes_div.add("<b>No review notes available</b>") notes_wdg = VisualNotesWdg(search_key=my.search_key, context=my.context) content_div.add(notes_wdg) for snapshot in snapshots: vnote_div = DivWdg() vnotes_div.add(vnote_div) file_obj = snapshot.get_file_by_type("main") if not file_obj: vnote_div.add("None found") continue rel_path = file_obj.get_value("relative_dir") file_name = file_obj.get_value("file_name") image_url = "/assets/%s/%s" % (rel_path, file_name) login = snapshot.get_value("login") date = snapshot.get_value("timestamp") import dateutil date_str = dateutil.parser.parse(date).strftime("%b %m %Y - %H:%M") login_div = DivWdg() login_div.add_style("padding: 2px") login_div.add("User: "******"<b>%s</b><br/>" % login) login_div.add("Date: ") login_div.add("<b>%s</b><br/>" % date_str) vnote_div.add(login_div) from pyasm.widget import ThumbWdg thumb_div = DivWdg() thumb_div.add_style("margin-left: 10px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_has_img_link(False) thumb.set_option("detail", "false") thumb.set_option("icon_size", "80") thumb.set_sobject(snapshot) vnote_div.add(thumb_div) # file_obj = snapshot.get_file_by_type('icon') # rel_path = file_obj.get_value("relative_dir") # file_name = file_obj.get_value("file_name") # icon_url = "/assets/%s/%s" % (rel_path, file_name) # vnote_div.add("<img src='%s'/>" % icon_url ) # vnote_div.add(snapshot.get_code() ) vnote_div.add_attr("spt_image_url", image_url) vnote_div.add_class("hand") vnote_div.add_behavior( { "type": "click_up", "cbjs_action": """ var value = bvr.src_el.innerHTML; var image_url = bvr.src_el.getAttribute("spt_image_url"); var top = bvr.src_el.getParent(".spt_review_top"); var content = top.getElement(".spt_review_content"); content.innerHTML = "<img src='"+image_url+"'/>"; """, } ) # get the related note to this vnote # notes = vnotes_div.get_related_notes() search = Search("sthpw/note") search.add_parent_filter(sobject) notes = search.get_sobjects() # for note in notes: # vnote_div.add(note.get_value("note")) from pyasm.biz import SObjectConnection connections, related_notes = SObjectConnection.get_connected_sobjects(snapshot, direction="src") for related_note in related_notes: vnote_div.add(related_note.get_value("note")) print "related_notes: ", related_notes vnote_div.add("<hr/>") return top
def get_chat_wdg(self, key, interval=False): div = DivWdg() div.add_class("spt_chat_session_top") div.add_color("background", "background") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_color("background", "background3") title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_border() icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE) icon.add_style("float: right") icon.add_style("margin-top: -5px") title_wdg.add(icon) icon.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var server = TacticServerStub.get(); var top = bvr.src_el.getParent(".spt_chat_session_top"); spt.behavior.destroy_element(top); ''' } ) current_user = Environment.get_user_name() logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key) for login in logins: if login.get_value("login") == current_user: continue thumb = ThumbWdg() thumb.set_icon_size(45) thumb.set_sobject(login) thumb.add_style("float: left") thumb.add_style("margin: -5px 10px 0px -5px") title_wdg.add(thumb) title_wdg.add(login.get_value("display_name")) title_wdg.add("<br clear='all'/>") history_div = DivWdg() div.add(history_div) history_div.add_class("spt_chat_history") history_div.add_style("width: auto") history_div.add_style("height: auto") history_div.add_style("max-height: 400px") history_div.add_style("padding: 5px") history_div.add_class("spt_resizable") history_div.add_border() history_div.add_style("overflow-y: auto") #history_div.add_style("font-size: 0.9em") search = Search("sthpw/message_log") search.add_filter("message_code", key) search.add_order_by("timestamp") message_logs = search.get_sobjects() last_login = None; last_date = None; for message_log in message_logs: login = message_log.get("login") message = message_log.get("message") timestamp = message_log.get_datetime_value("timestamp") #timestamp = timestamp.strftime("%b %d, %Y - %H:%M") timestamp_str = timestamp.strftime("%H:%M") date_str = timestamp.strftime("%b %d, %Y") if login != last_login: table = Table() history_div.add(table) table.add_row() table.add_style("width: 100%") table.add_style("margin-top: 15px") login_sobj = Search.get_by_code("sthpw/login", login) thumb_div = DivWdg() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 75px") thumb_div = DivWdg() td.add(thumb_div) thumb_div.add_style("overflow: hidden") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(login_sobj) thumb.set_icon_size(60) display_name = login_sobj.get("display_name") td = table.add_cell() td.add_style("padding-top: 3px") name_div = DivWdg() td.add(name_div) name_div.add_style("color", "#214e75") name_div.add_style("font-size", "1.3em") name_div.add(display_name) msg = ""; msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'>"; if date_str != last_date: msg += "<tr><td colspan='2' style='text-align: right'><br/><b style='font-size: 1.0em'>"+date_str+"</b></td></tr>"; last_login = None msg += "<tr><td>" msg += message.replace("\n",'<br/>') msg += "</td><td style='vertical-align: top; text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top; opacity: 0.7;'>"; msg += timestamp_str; msg += "</td></tr></table>"; td.add(msg) last_login = login last_date = date_str history_div.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.scrollTop = bvr.src_el.scrollHeight; ''' } ) if message_logs: last_message = message_logs[-1].get("message") last_login = message_logs[-1].get("login") else: last_message = "" last_login = "" div.add_attr("spt_last_message", last_message) div.add_attr("spt_last_login", last_login) if interval: div.add_behavior( { 'type': 'load', 'key': key, 'cbjs_action': r''' var text_el = bvr.src_el.getElement(".spt_chat_text"); var history_el = bvr.src_el.getElement(".spt_chat_history"); var callback = function(message) { //history_el.setStyle("background", "red"); var login = message.login; var timestamp = message.timestamp; if (timestamp) { var parts = timestamp.split(" "); parts = parts[1].split("."); timestamp = parts[0]; } else { timestamp = ""; } var tmp = message.message || ""; var last_message = bvr.src_el.getAttribute("spt_last_message"); var last_login = bvr.src_el.getAttribute("spt_last_login"); if (tmp == last_message && login == last_login) { return; } bvr.src_el.setAttribute("spt_last_message", tmp); bvr.src_el.setAttribute("spt_last_login", login); var msg = ""; msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'><tr><td>"; if (login != last_login) { msg += "<b>"+login+"</b><br/>"; } msg += tmp.replace(/\n/g,'<br/>'); msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>"; msg += timestamp; msg += "</td></tr></table>"; if (msg == history_el.last_msg) { return; } history_el.innerHTML = history_el.innerHTML + msg; // remember last message history_el.last_msg = msg; history_el.scrollTop = history_el.scrollHeight; } spt.message.set_interval(bvr.key, callback, 3000, bvr.src_el); ''' } ) text = TextAreaWdg("chat") div.add(text) text.add_class("spt_chat_text") text.add_style("width: 100%") text.add_style("padding: 5px") #text.add_style("margin-top: -1px") text.add_style("margin-top: 5px") text.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.addEvent("keydown", function(e) { var keys = ['tab','keys(control+enter)', 'enter']; var key = e.key; var input = bvr.src_el if (keys.indexOf(key) > -1) e.stop(); if (key == 'tab') { } else if (key == 'enter') { if (e.control == false) { pass; } else { // TODO: check if it's multi-line first //... use ctrl-ENTER for new-line, regular ENTER (RETURN) accepts value //var tvals = parse_selected_text(input); //input.value = tvals[0] + "\\n" + tvals[1]; //spt.set_cursor_position( input, tvals[0].length + 1 ); } } } ) ''' } ) button = ActionButtonWdg(title="Send") div.add(button) button.add_style("float: right") button.add_style("margin: 5px") button.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chat_session_top"); var text_el = top.getElement(".spt_chat_text"); var message = text_el.value; if (!message) { return; } var history_el = top.getElement(".spt_chat_history"); var category = "chat"; var server = TacticServerStub.get(); var key = bvr.key; var last_message = server.log_message(key, message, {category:category, status:"in_progress"}); text_el.value = ""; ''' } ) div.add("<br clear='all'/>") return div
def get_group_wdg(self, prev_sobj): if not self.is_preprocessed: self.preprocess() sobject = self.get_current_sobject() ref_sobj = self.get_ref_obj(sobject) self.current_ref_sobj = ref_sobj if not ref_sobj: return "Undetermined parent: [%s]" % SearchKey.get_by_sobject( sobject) widget = DivWdg() # add add button #from tactic.ui.widget import TextBtnWdg, TextBtnSetWdg #buttons_list = [] #buttons_list.append( { # 'label': '+', 'tip': 'Add Another Item', # 'bvr': { 'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)" } #} ) #add_btn = TextBtnSetWdg( float="right", buttons=buttons_list, # spacing=6, size='small', side_padding=0 ) #widget.add(add_btn) from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title='+', tip='Add Another Item', size='small') widget.add(button) button.add_style("float: right") button.add_behavior({ 'type': 'click_up', 'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)" }) label = "Attach" label_option = self.get_option("label") if label_option: label = label_option table = Table() table.add_color("color", "color") table.add_row() search_key = sobject.get_search_key() # add a thumbe widget thumb = ThumbWdg() thumb.set_icon_size(40) thumb.set_sobject(ref_sobj) thumb.set_option('latest_icon', 'true') table.add_cell(thumb) # add the text description name_span = DivWdg(ref_sobj.get_code()) name_span.add_style('margin-left: 20px') table.add_cell(name_span) if ref_sobj.has_value("name"): name_span.add(" - ") name_span.add(ref_sobj.get_value("name")) #status = ref_sobj.get_value("status", no_exception=True) #if status: # span = SpanWdg("(status:%s)" % ref_sobj.get_value("status")) # table.add_cell(span) if ref_sobj.has_value("description"): description_wdg = ExpandableTextWdg("description") description_wdg.set_max_length(200) description_wdg.set_sobject(ref_sobj) td = table.add_cell(description_wdg) td.add_style("padding-left: 15px") # FIXME: not sure about the layout here #if ref_sobj.has_value("pipeline_code"): # pipeline_code = ref_sobj.get_value("pipeline_code") # span = SpanWdg("(pipeline:%s)" % pipeline_code ) # td = table.add_cell(span) # td.add_style("padding-left: 15px") widget.add(table) return widget
def get_display(my): my.sobject = my.get_sobject() top = DivWdg() top.add_class("spt_detail_top") top.add_color("background", "background") top.add_color("color", "color") if not my.sobject: top.add("No SObject defined for this widget") return top if my.parent: my.search_type = my.parent.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.parent) top.add_attr("spt_parent_key", my.search_key) my.pipeline_code = my.parent.get_value("pipeline_code", no_exception=True) my.full_search_type = my.parent.get_search_type() else: my.pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True) my.search_type = my.sobject.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.sobject) my.full_search_type = my.sobject.get_search_type() if not my.pipeline_code: my.pipeline_code = 'default' top.add_style("text-align: left") my.set_as_panel(top) table = Table() #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table.add_color("background", "background") table.add_color("color", "color") top.add(table) table.set_max_width() table.add_row() # left #td = table.add_cell(resize=False) td = table.add_cell() #td.add_style("padding: 10px") td.add_style("width: 200px") td.add_style("min-width: 200px") td.add_style("vertical-align: top") #td.add_border() #td.add_style("border-style: solid") #td.add_style("border-width: 1px 0 1px 1px") #td.add_color("border-color", "border") #td.add_color("background", "background", -10) if my.parent: code = my.parent.get_code() else: code = my.sobject.get_code() # add the tile title = DivWdg() td.add(title) title.add_gradient("background", "background3", 0, -10) title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add_style("font-size: 1.4em") title.add("%s" % code) title.add_border() div = DivWdg() td.add(div) div.add_class("spt_sobject_detail_top") thumb_table = Table() div.add(thumb_table) thumb_table.add_row() thumb = ThumbWdg() # use a larger version for clearer display thumb.set_icon_type('web') # prefer to see the original image, then web thumb.set_option('image_link_order', 'main|web|.swf') thumb.set_option("detail", "false") thumb.set_option("icon_size", "100%") td = thumb_table.add_cell(thumb) td.add_style("vertical-align: top") td.add_style("width: 200px") td.add_style("padding: 20px") if my.parent: thumb.set_sobject(my.parent) else: thumb.set_sobject(my.sobject) sobject_info_wdg = my.get_sobject_info_wdg() sobject_info_wdg.add_style("width: 200px") td.add(sobject_info_wdg) if my.search_type == 'sthpw/task' and not my.parent: pass else: sobject_info_wdg = my.get_sobject_detail_wdg() td = table.add_cell() td.add(sobject_info_wdg) td.add_style("vertical-align: top") #td.add_color("background", "background", -10) td.add_style("overflow: hidden") #td.add_style("border-style: solid") #td.add_style("border-width: 1px 1px 1px 0px") #td.add_color("border-color", "border") # right td = table.add_cell() td.add_style("text-align: left") td.add_style("vertical-align: top") #td.add_color("background", "background", -10) td.add_class("spt_notes_wrapper") #td.add_border() # add the title title = DivWdg() td.add(title) title.add_gradient("background", "background3", 0, -10) title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Notes") title.add_border() notes_div = DivWdg() td.add(notes_div) from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=my.search_key, context_hidden=False, show_note_expand=False) notes_div.add(discussion_wdg) notes_div.add_style("min-width: 300px") notes_div.add_style("height: 200") notes_div.add_style("overflow-y: auto") notes_div.add_class("spt_resizable") # get the process if my.parent: process = my.sobject.get_value("process") else: process = '' # content tr = table.add_row() td = table.add_cell() td.add_attr("colspan", "5") #td.add_attr("colspan", "3") # create a state for tab. The tab only passes a search key # parent key search_key = SearchKey.get_by_sobject(my.sobject) parent = my.sobject.get_parent() if parent: parent_key = parent.get_search_key() else: parent_key = "" state = { 'search_key': search_key, 'parent_key': parent_key, 'process': process, } WebState.get().push(state) config_xml = my.get_config_xml() config = WidgetConfig.get(view="tab", xml=config_xml) if process: custom_view = "tab_config_%s" % process else: custom_view = "tab_config" search = Search("config/widget_config") search.add_filter("category", "TabWdg") search.add_filter("search_type", my.search_type) search.add_filter("view", custom_view) custom_config_sobj = search.get_sobject() if custom_config_sobj: custom_config_xml = custom_config_sobj.get_value("config") custom_config = WidgetConfig.get(view=custom_view, xml=custom_config_xml) config = WidgetConfigView(search_type='TabWdg', view=custom_view, configs=[custom_config, config]) #menu = my.get_extra_menu() #tab = TabWdg(config=config, state=state, extra_menu=menu) tab = TabWdg(config=config, state=state, show_add=False, show_remove=False, tab_offset=5 ) tab.add_style("margin: 0px -2px -2px -2px") td.add(tab) td.add_style("padding-top: 10px") return top
def get_display(self): top = DivWdg() top.add_border() top.add_style("padding: 10px") top.add_color("color", "color") top.add_color("background", "background") #top.add_style("height: 550px") top.add_class("spt_reports_top") title = DivWdg() title.add("Searchable Lists") title.add_style("font-size: 18px") title.add_style("font-weight: bold") title.add_style("text-align: center") title.add_style("padding: 10px") title.add_style("margin: -10px -10px 0px -10px") top.add(title) title.add_gradient("background", "background3", 5, -10) top.add("<br/>") button_div = DivWdg() top.add(button_div) button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP) button_div.add(button) top.add(button_div) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_reports_top"); var element = top.getElement(".spt_reports_list"); spt.toggle_show_hide(element) ''' } ) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") reports = [] # read the config file """ from pyasm.widget import WidgetConfig tmp_path = __file__ dir_name = os.path.dirname(tmp_path) file_path="%s/../config/reports-conf.xml" % (dir_name) config = WidgetConfig.get(file_path=file_path, view="definition") element_names = config.get_element_names() for element_name in element_names: print "element_name: ", element_name attrs = config.get_element_attributes(element_name) report_data = {} kwargs = config.get_display_options(element_name) class_name = kwargs.get('class_name') report_data['class_name'] = class_name report_data['kwargs'] = kwargs report_data['title'] = attrs.get("title") report_data['description'] = attrs.get("description") reports.append(report_data) """ project = Project.get() project_code = project.get_code() search_type_objs = project.get_search_types() filtered = [] for search_type_obj in search_type_objs: search_type = search_type_obj.get_value("search_type") # FIXME: this code is also present from pyasm.security import get_security_version security_version = get_security_version() if security_version >= 2 and not search_type.startswith("sthpw/") and not search_type.startswith("config/"): security = Environment.get_security() table = search_type_obj.get_value("table_name") default = "deny" key = { "element": "%s_list" % table } key2 = { "element": "%s_list" % table, "project": project_code } key3 = { "element": "*" } key4 = { "element": "*", "project": project_code } keys = [key, key2, key3, key4] if not security.check_access("link", keys, "view", default=default): continue key = { "code": search_type } key2 = { "code": "*" } keys = [key, key2] if not security.check_access("search_type", keys, "view", default=default): continue filtered.append(search_type_obj) search_type_objs = filtered for search_type_sobj in search_type_objs: description = search_type_sobj.get_value("description") search_type = search_type_sobj.get_value("search_type") search = Search(search_type) count = search.get_count() title_div = DivWdg() items_div = DivWdg() title_div.add(items_div) items_div.add_style("font-size: 9px") items_div.add_style("font-weight: italic") items_div.add_style("float: right") items_div.add("%s item/s" % count) title_div.add(search_type_sobj.get_title()) description_div = DivWdg() description_div.add(description) description_div.add_style("padding: 5px") if not description: description_div.add("<br/>(No description)") description_div.add_style("font-style: italic") description_div.add_style("opacity: 0.3") report_data = { 'title': search_type_sobj.get_title(), 'title_wdg': title_div, 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'kwargs': { 'search_type': search_type, 'view': 'table', 'simple_search_view': 'simple_search' }, 'description': description_div, 'search_type': search_type_sobj } reports.append(report_data) # create a bunch of panels list_div = DivWdg() top.add(list_div) list_div.add_class("spt_reports_list") table = Table() list_div.add(table) table.add_color("color", "color") table.add_style("margin-bottom: 5px") table.center() top.add("<br clear='all'/>") for i, report in enumerate(reports): if i == 0 or i%4 == 0: tr = table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") class_name = report.get("class_name") kwargs = report.get("kwargs") title = report.get("title") description = report.get("description") #image = "<img src='/context/images/getting_started_schema.png'/>" image = "<img src='/context/images/getting_started_pipeline.png'/>" thumb_div = DivWdg() image = thumb_div thumb_div.add_border() thumb_div.set_box_shadow("1px 1px 1px 1px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(report.get("search_type")) thumb.set_icon_size(60) behavior = { 'type': 'click_up', 'title': title, 'class_name': class_name, 'kwargs': kwargs, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_reports_top"); //spt.tab.set_main_body_tab(); spt.tab.set_tab_top(top); var kwargs = {}; spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs); ''' } title_wdg = report.get("title_wdg") schema_wdg = self.get_section_wdg(title_wdg, description, image, behavior) td.add(schema_wdg) from tactic.ui.container import TabWdg tab = TabWdg(show_add=False) top.add(tab) return top
def get_display(self): top = self.top login = self.kwargs.get("login") if not login or login == "$LOGIN": login = Environment.get_user_name() login_sobj = Login.get_by_code(login) #top.add_style("margin-top: -2px") #top.add_style("margin-left: -2px") thumb_div = DivWdg() thumb_div.add_style("float: left") thumb_div.add_style("margin-right: 5px") thumb_div.add_style("margin-bottom: 5px") thumb_div.add_style("padding-top: 1px") thumb = ThumbWdg() thumb.set_sobject(login_sobj) thumb_div.add(thumb) thumb.set_icon_size(90) thumb.set_aspect("height") full_name = login_sobj.get_full_name() info_wdg = DivWdg() top.add(info_wdg) name_wdg = DivWdg() info_wdg.add(thumb_div) info_wdg.add(name_wdg) name_wdg.add(" " * 3) name_wdg.add(full_name) name_wdg.add_style("font-size: 1.5em") name_wdg.add_style("font-weight: bold") name_wdg.add_style("padding: 5px") #name_wdg.add_style("margin-left: -10px") name_wdg.add_color("background", "background3") name_wdg.add_style("height: 20px") name_wdg.add_style("margin-bottom: 0px") name_wdg.add_border() info_wdg.add("<br/>") from tactic.ui.container import TabWdg # return if the supplied tab view has a config xml if self.tab_view: search = Search("config/widget_config") search.add_filter("category", "TabWdg") search.add_filter("view", self.tab_view) config_sobj = search.get_sobject() if config_sobj: config_xml = config_sobj.get_value('config') # replace the variable $login with the login clicked if login: config_xml = config_xml.replace('$login', login) tab = TabWdg(config_xml=config_xml, view=self.tab_view, show_add=False, show_remove=False) top.add(tab) return top config_xml = [] config_xml.append('<config>') config_xml.append('<tab>') config_xml.append(''' <element name='schedule'> <display class='tactic.ui.widget.TaskCalendarWdg'> <assigned>%s</assigned> <sobject_display_expr>%s</sobject_display_expr> <show_header>true</show_header> <show_border>false</show_border> </display> </element> ''' % (login, self.sobject_display_expr)) config_xml.append(''' <element name='activity'> <display class='tactic.ui.widget.ActivityCalendarWdg'> <login>%s</login> <cell_width>100px</cell_width> <cell_height>50px</cell_height> <show_header>true</show_header> <show_border>false</show_border> </display> </element> ''' % login) config_xml.append(''' <element name='tasks'> <display class='tactic.ui.panel.FastTableLayoutWdg'> <search_type>sthpw/task</search_type> <view>table</view> <expression>@SOBJECT(sthpw/task['assigned','%s']['@ORDER_BY', 'bid_start_date desc'])</expression> <mode>simple</mode> </display> </element> ''' % login) config_xml.append(''' <element name='work_hours'> <display class='tactic.ui.widget.SObjectCalendarWdg'> <login>%s</login> <!-- <cell_width>100px</cell_width> --> <cell_height>50px</cell_height> <show_header>true</show_header> <show_border>false</show_border> <search_type>sthpw/work_hour</search_type> <handler>tactic.ui.widget.WorkHourCalendarDayWdg</handler> <start_date_col>day</start_date_col> <end_date_col>day</end_date_col> </display> </element> ''' % login) config_xml.append(''' <element name='recent transactions'> <display class='tactic.ui.panel.FastTableLayoutWdg'> <search_type>sthpw/transaction_log</search_type> <view>table</view> <expression>@SOBJECT(sthpw/transaction_log['login','%s']['@ORDER_BY','timestamp desc']['@LIMIT','30'])</expression> <element_names>code,timestamp,namespace,description,transaction_log_hidden</element_names> <show_shelf>false</show_shelf> <show_select>false</show_select> </display> </element> ''' % login) config_xml.append('</tab>') config_xml.append('</config>') config_xml = "".join(config_xml) tab = TabWdg(config_xml=config_xml, view='tab', show_add=False, show_remove=False) top.add(tab) tab.add_style("margin-left: -2px") tab.add_style("margin-right: -2px") return top
def get_display(self): self.is_refresh = self.kwargs.get('is_refresh') =='true' if not self.is_refresh: top = DivWdg(css='spt_view_panel') self.set_as_panel(top) else: top = Widget() div = DivWdg(css="filter_box") div.add("<b>Current Session</b>") top.add(div) # the button which initiates the introspection button = IntrospectWdg() #button.add_style("float", "right") top.add(button) top.add("<br clear='all'/>") session = SessionContents.get() if not session: widget.add("<h3>No contents in session</h3>") return widget table = Table() table.add_class("table") table.add_style("width: 100%") table.add_row() table.add_header(" ") table.add_header("Type") table.add_header("Asset") table.add_header("Node Name") table.add_header("Node Type") table.add_header("Reference") table.add_header("Session") table.add_header("Latest") node_names = session.get_node_names() for node_name in node_names: table.add_row() # snapshot_code snapshot_code = session.get_snapshot_code(node_name, "shot") if not snapshot_code: snapshot_code = session.get_snapshot_code(node_name, "anim") if not snapshot_code: snapshot_code = session.get_snapshot_code(node_name, "asset") snapshot = Snapshot.get_by_code(snapshot_code) sobject = None if snapshot: sobject = snapshot.get_sobject() base = sobject.get_search_type_obj().get_base_search_type() thumb = ThumbWdg() thumb.set_icon_size(60) # FIXME: make this more automatic if base == "prod/shot_instance": thumb_sobj = sobject.get_parent("prod/asset") thumb.set_sobject(thumb_sobj) else: thumb.set_sobject(sobject) table.add_cell(thumb) title = sobject.get_search_type_obj().get_title() table.add_cell( title ) # TODO: this should be more automatic! if base == "prod/shot_instance": asset_code = sobject.get_value("asset_code") shot_code = sobject.get_value("shot_code") name = sobject.get_value("name") table.add_cell("%s: %s in %s" % (name,asset_code,shot_code)) else: code = sobject.get_code() name = sobject.get_name() if code == name: table.add_cell( "%s" % (code) ) else: table.add_cell( "%s - %s" % (code, name) ) else: table.add_cell("<i>No snapshot</i>") table.add_cell("---") table.add_cell("---") # display the node name table.add_cell(node_name) # display node type table.add_cell( session.get_node_type(node_name) ) # display if it is a reference is_reference = session.is_reference(node_name) if is_reference: table.add_cell( "Yes" ) else: table.add_cell( "No" ) if snapshot: # add the snapshot info context = snapshot.get_value("context") version = snapshot.get_value("version") table.add_cell( "%s v%0.2d" % (context, version)) else: table.add_cell("---") table.add_cell( self.get_version_wdg(session,snapshot,node_name) ) top.add(table) return top
def get_display(my): top = DivWdg() top.add_border() top.add_style("padding: 10px") top.add_color("color", "color") top.add_color("background", "background") #top.add_style("height: 550px") top.add_class("spt_reports_top") title = DivWdg() title.add("Searchable Lists") title.add_style("font-size: 18px") title.add_style("font-weight: bold") title.add_style("text-align: center") title.add_style("padding: 10px") title.add_style("margin: -10px -10px 0px -10px") top.add(title) title.add_gradient("background", "background3", 5, -10) top.add("<br/>") button_div = DivWdg() top.add(button_div) button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP) button_div.add(button) top.add(button_div) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_reports_top"); var element = top.getElement(".spt_reports_list"); spt.toggle_show_hide(element) ''' } ) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") reports = [] # read the config file """ from pyasm.widget import WidgetConfig tmp_path = __file__ dir_name = os.path.dirname(tmp_path) file_path="%s/../config/reports-conf.xml" % (dir_name) config = WidgetConfig.get(file_path=file_path, view="definition") element_names = config.get_element_names() for element_name in element_names: print "element_name: ", element_name attrs = config.get_element_attributes(element_name) report_data = {} kwargs = config.get_display_options(element_name) class_name = kwargs.get('class_name') report_data['class_name'] = class_name report_data['kwargs'] = kwargs report_data['title'] = attrs.get("title") report_data['description'] = attrs.get("description") reports.append(report_data) """ project = Project.get() project_code = project.get_code() search_type_objs = project.get_search_types() filtered = [] for search_type_obj in search_type_objs: search_type = search_type_obj.get_value("search_type") # FIXME: this code is also present from pyasm.security import get_security_version security_version = get_security_version() if security_version >= 2 and not search_type.startswith("sthpw/") and not search_type.startswith("config/"): security = Environment.get_security() table = search_type_obj.get_value("table_name") default = "deny" key = { "element": "%s_list" % table } key2 = { "element": "%s_list" % table, "project": project_code } key3 = { "element": "*" } key4 = { "element": "*", "project": project_code } keys = [key, key2, key3, key4] if not security.check_access("link", keys, "view", default=default): continue key = { "code": search_type } key2 = { "code": "*" } keys = [key, key2] if not security.check_access("search_type", keys, "view", default=default): continue filtered.append(search_type_obj) search_type_objs = filtered for search_type_sobj in search_type_objs: description = search_type_sobj.get_value("description") search_type = search_type_sobj.get_value("search_type") search = Search(search_type) count = search.get_count() title_div = DivWdg() items_div = DivWdg() title_div.add(items_div) items_div.add_style("font-size: 9px") items_div.add_style("font-weight: italic") items_div.add_style("float: right") items_div.add("%s item/s" % count) title_div.add(search_type_sobj.get_title()) description_div = DivWdg() description_div.add(description) description_div.add_style("padding: 5px") if not description: description_div.add("<br/>(No description)") description_div.add_style("font-style: italic") description_div.add_style("opacity: 0.3") report_data = { 'title': search_type_sobj.get_title(), 'title_wdg': title_div, 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'kwargs': { 'search_type': search_type, 'view': 'table', 'simple_search_view': 'simple_search' }, 'description': description_div, 'search_type': search_type_sobj } reports.append(report_data) # create a bunch of panels list_div = DivWdg() top.add(list_div) list_div.add_class("spt_reports_list") table = Table() list_div.add(table) table.add_color("color", "color") table.add_style("margin-bottom: 5px") table.center() top.add("<br clear='all'/>") for i, report in enumerate(reports): if i == 0 or i%4 == 0: tr = table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") class_name = report.get("class_name") kwargs = report.get("kwargs") title = report.get("title") description = report.get("description") #image = "<img src='/context/images/getting_started_schema.png'/>" image = "<img src='/context/images/getting_started_pipeline.png'/>" thumb_div = DivWdg() image = thumb_div thumb_div.add_border() thumb_div.set_box_shadow("1px 1px 1px 1px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(report.get("search_type")) thumb.set_icon_size(60) behavior = { 'type': 'click_up', 'title': title, 'class_name': class_name, 'kwargs': kwargs, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_reports_top"); //spt.tab.set_main_body_tab(); spt.tab.set_tab_top(top); var kwargs = {}; spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs); ''' } title_wdg = report.get("title_wdg") schema_wdg = my.get_section_wdg(title_wdg, description, image, behavior) td.add(schema_wdg) from tactic.ui.container import TabWdg tab = TabWdg(show_add=False) top.add(tab) return top