class ProgressWdg(BaseRefreshWdg): '''A simple widget which displays the progress and an upload''' def init(self): self.progress_div = DivWdg() self.progress_id = self.progress_div.set_unique_id() def get_progress_id(self): return self.progress_id def get_display(self): top = self.top top.add_class("spt_progress_top") top.add_style("height: 10px") top.add_style("width: 200px") top.add_style("overflow: hidden") top.add_border() top.add(self.progress_div) self.progress_div.add_style("width: 0%") self.progress_div.add_gradient("background", "background2", 20) self.progress_div.add_style("height: 100%") self.progress_div.add(" ") self.progress_div.add( '<img height="10px" src="/context/icons/common/indicator_snake.gif" border="0"/>' ) return top
class ProgressWdg(BaseRefreshWdg): '''A simple widget which displays the progress and an upload''' def init(self): self.progress_div = DivWdg() self.progress_id = self.progress_div.set_unique_id() def get_progress_id(self): return self.progress_id def get_display(self): top = self.top top.add_class("spt_progress_top") top.add_style("height: 10px") top.add_style("width: 200px") top.add_style("overflow: hidden") top.add_border() top.add(self.progress_div) self.progress_div.add_style("width: 0%") self.progress_div.add_gradient("background", "background2", 20) self.progress_div.add_style("height: 100%") self.progress_div.add(" ") self.progress_div.add('<img height="10px" src="/context/icons/common/indicator_snake.gif" border="0"/>') return top
def get_section_wdg(my, title, description, image, behavior): section_wdg = DivWdg() section_wdg.set_round_corners() section_wdg.add_border() section_wdg.add_class("spt_report_top") section_wdg.add_style("width: 200px") section_wdg.add_style("height: 100px") section_wdg.add_style("overflow: hidden") section_wdg.add_style("margin: 10px") section_wdg.set_box_shadow("0px 0px 10px") title_wdg = DivWdg() section_wdg.add(title_wdg) title_wdg.add(title) title_wdg.add_style("height: 20px") title_wdg.add_style("padding: 3px") title_wdg.add_style("margin-top: 3px") title_wdg.add_style("font-weight: bold") title_wdg.add_gradient("background", "background") button = IconButtonWdg(title="Options", icon=IconWdg.ARROWHEAD_DARK_DOWN) title_wdg.add(button) button.add_style("float: right") # set up menus menu = my.get_menu() SmartMenu.add_smart_menu_set( button, { 'MENU_ITEM': menu } ) SmartMenu.assign_as_local_activator( button, "MENU_ITEM", True ) section_wdg.add_color("background", "background") #section_wdg.add_gradient("background", "background", 0, -3) section_wdg.add_behavior( { 'type': 'hover', 'add_color_modifier': -5, 'cb_set_prefix': 'spt.mouse.table_layout_hover', } ) desc_div = DivWdg() desc_div.add(description) desc_div.add_style("padding: 5px 10px 10px 5px") div = DivWdg() section_wdg.add(div) div.add_style("padding: 3px") div.add_style("margin: 5px") div.add_style("width: 65px") div.add_style("height: 50px") div.add_style("float: left") div.add(image) section_wdg.add(desc_div) div.add_style("overflow: hidden") section_wdg.add_behavior( behavior ) section_wdg.add_class("hand") return section_wdg
def get_error_wdg(my): div = DivWdg() error_div = DivWdg() error_div.add("Error %s" % my.status) div.add(error_div) error_div.add_style("font-size: 18px") error_div.add_style("font-weight: bold") error_div.add_style("padding: 10px") error_div.add_style("width: auto") error_div.add_gradient("background", "background") error_div.add_border() error_div.add_style("margin-left: 5px") error_div.add_style("margin-right: 5px") error_div.add_style("margin-top: -10px") div.add("<br/>") span = DivWdg() #span.add_color("color", "color") span.add_style("color", "#FFF") if my.status == 404: span.add( HtmlElement.b( "You have tried to access a url that is not recognized.")) else: span.add(HtmlElement.b(my.message)) span.add(HtmlElement.br(2)) web = WebContainer.get_web() root = web.get_site_root() if my.message.startswith('No project ['): label = 'You may need to correct the default_project setting in the TACTIC config.' else: label = "Go to the Main page for a list of valid projects" span.add(label) div.add(span) div.add(HtmlElement.br()) from tactic.ui.widget import ActionButtonWdg button_div = DivWdg() button_div.add_style("width: 90px") button_div.add_style("margin: 0px auto") div.add(button_div) button = ActionButtonWdg(title="Go to Main", tip='Click to go to main page') button_div.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = '/'; ''' }) button.add_event("onmouseup", "document.location='/'") return div
def get_elements_wdg(my): div = DivWdg() div.add_style("min-width: 200px") div.add_style("min-height: 500px") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add("Elements") title_wdg.add_style("padding: 5px") title_wdg.add_gradient("background", "background", -10) #element_names = ['Checkin', 'Checkout'] element_names = my.config.get_element_names() elements_wdg = DivWdg() div.add(elements_wdg) elements_wdg.add_style("padding: 5px") view = 'tab_config_whatever' hover = div.get_color("background", -10) for element_name in element_names: element_div = DivWdg() elements_wdg.add(element_div) element_div.add(element_name) element_div.add_style("padding: 3px") element_div.add_behavior( { 'type': 'hover', 'hover': hover, 'cbjs_action_over': '''bvr.src_el.setStyle("background", bvr.hover)''', 'cbjs_action_out': '''bvr.src_el.setStyle("background", "")''' } ) element_div.add_class("hand") element_div.add_behavior( { 'type': 'click_up', 'view': view, 'element_name': element_name, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_tab_edit_top"); var content = top.getElement(".spt_tab_edit_content"); var class_name = 'tactic.ui.tools.tab_edit_wdg.TabElementDefinitionWdg'; var kwargs = { view: bvr.view, element_name: bvr.element_name }; spt.panel.load(content, class_name, kwargs); ''' } ) return div
def get_display(my): # set the sobjects to all the widgets then preprocess for widget in my.widgets: widget.set_sobjects(my.sobjects) widget.set_parent_wdg(my) # preprocess the elements widget.preprocess() top = my.top my.set_as_panel(top) inner = DivWdg() top.add(inner) inner.add_color("background", "background") inner.add_color("color", "color") inner.add_class("spt_dashboard_top") title = DivWdg() inner.add(title) title.add(my.get_title()) 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 10px -10px") title.add_gradient("background", "background3", 5, -10) #table = Table() from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() inner.add(table) table.set_max_width() panels = my.get_panels() for panel in panels: title = panel.get('title') #if title in ['Data', None]: # tr, td = table.add_row_cell() #else: # td = table.add_cell() tr = table.add_row() td = table.add_cell(resize=False) td.add_style("min-height: 100px") td.add_style("vertical-align: top") panel = my.get_panel_wdg(td, panel) td.add(panel) return top
def get_error_wdg(my): div = DivWdg() error_div = DivWdg() error_div.add("Error %s" % my.status) div.add(error_div) error_div.add_style("font-size: 18px") error_div.add_style("font-weight: bold") error_div.add_style("padding: 10px") error_div.add_style("width: auto") error_div.add_gradient("background", "background") error_div.add_border() error_div.add_style("margin-left: 5px") error_div.add_style("margin-right: 5px") error_div.add_style("margin-top: -10px") div.add("<br/>") span = DivWdg() #span.add_color("color", "color") span.add_style("color", "#FFF") if my.status == 404: span.add(HtmlElement.b("You have tried to access a url that is not recognized.")) else: span.add(HtmlElement.b(my.message)) span.add(HtmlElement.br(2)) web = WebContainer.get_web() root = web.get_site_root() if my.message.startswith('No project ['): label = 'You may need to correct the default_project setting in the TACTIC config.' else: label = "Go to the Main page for a list of valid projects" span.add(label) div.add(span) div.add(HtmlElement.br()) from tactic.ui.widget import ActionButtonWdg button_div = DivWdg() button_div.add_style("width: 90px") button_div.add_style("margin: 0px auto") div.add(button_div) button = ActionButtonWdg(title="Go to Main", tip='Click to go to main page') button_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' document.location = '/'; ''' } ) button.add_event("onmouseup", "document.location='/'") return div
def get_display(my): top = my.top top.add_class("spt_share_top") my.set_as_panel(top) top.add_color("background", "background") title = DivWdg() top.add(title) 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 10px -10px") title.add_gradient("background", "background3", 5, -10) title.add("Share Project") # add the main layout #table = ResizableTableWdg() table = Table() table.add_color("color", "color") top.add(table) table.add_row() left = table.add_cell() left.add_border() left.add_style("vertical-align: top") left.add_style("min-width: 250px") left.add_style("height: 400px") left.add_color("background", "background3") left.add(my.get_share_wdg() ) right = table.add_cell() right.add_border() right.add_style("vertical-align: top") right.add_style("min-width: 400px") right.add_style("width: 100%") right.add_style("height: 400px") right.add_style("padding: 5px") right.add_class("spt_share_content") share_item_wdg = ShareItemWdg() right.add(share_item_wdg) return top
def get_display(self): top = self.top top.add_class("spt_share_top") self.set_as_panel(top) top.add_color("background", "background") title = DivWdg() top.add(title) 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 10px -10px") title.add_gradient("background", "background3", 5, -10) title.add("Share Project") # add the main layout #table = ResizableTableWdg() table = Table() table.add_color("color", "color") top.add(table) table.add_row() left = table.add_cell() left.add_border() left.add_style("vertical-align: top") left.add_style("min-width: 250px") left.add_style("height: 400px") left.add_color("background", "background3") left.add(self.get_share_wdg() ) right = table.add_cell() right.add_border() right.add_style("vertical-align: top") right.add_style("min-width: 400px") right.add_style("width: 100%") right.add_style("height: 400px") right.add_style("padding: 5px") right.add_class("spt_share_content") share_item_wdg = ShareItemWdg() right.add(share_item_wdg) return top
def get_section_wdg(self, title, description, image, behavior): section_wdg = DivWdg() section_wdg.set_round_corners() section_wdg.add_border() section_wdg.add_style("width: 200px") section_wdg.add_style("height: 100px") section_wdg.add_style("overflow: hidden") section_wdg.add_style("margin: 5px") section_wdg.set_box_shadow("1px 1px 1px 1px") title_wdg = DivWdg() section_wdg.add(title_wdg) title_wdg.add(title) title_wdg.add_style("height: 20px") title_wdg.add_style("padding: 3px") title_wdg.add_style("margin-top: 3px") title_wdg.add_style("font-weight: bold") title_wdg.add_gradient("background", "background") section_wdg.add_color("background", "background") #section_wdg.add_gradient("background", "background", 0, -3) section_wdg.add_behavior({ 'type': 'hover', 'add_color_modifier': -5, 'cb_set_prefix': 'spt.mouse.table_layout_hover', }) desc_div = DivWdg() desc_div.add(description) desc_div.add_style("padding: 0px 10px 10px 5px") div = DivWdg() section_wdg.add(div) div.add_style("padding: 3px") div.add_style("margin: 5px") #div.add_style("width: 210px") #div.add_style("height: 170px") #div.add_style("width: 80px") div.add_style("height: 50px") div.add_style("float: left") div.add(image) section_wdg.add(desc_div) div.add_style("overflow: hidden") section_wdg.add_behavior(behavior) section_wdg.add_class("hand") return section_wdg
def get_section_wdg2(self, title, description, image, behavior): section_wdg = DivWdg() section_wdg.set_round_corners() section_wdg.add_border() section_wdg.add_style("width: 200px") section_wdg.add_style("height: 175px") section_wdg.add_style("overflow: hidden") section_wdg.add_style("margin: 10px") section_wdg.set_box_shadow("1px 1px 1px 1px") title_wdg = DivWdg() section_wdg.add(title_wdg) title_wdg.add(title) title_wdg.add_style("height: 20px") title_wdg.add_style("padding: 3px") title_wdg.add_style("margin-top: 3px") title_wdg.add_style("font-weight: bold") title_wdg.add_gradient("background", "background") section_wdg.add_color("background", "background") section_wdg.add_behavior( { 'type': 'hover', 'add_color_modifier': -5, 'cb_set_prefix': 'spt.mouse.table_layout_hover', } ) desc_div = DivWdg() desc_div.add(description) desc_div.add_style("padding: 0px 10px 10px 5px") div = DivWdg() section_wdg.add(div) div.add_style("padding: 3px") div.add_style("margin: 5px") #div.add_style("width: 210px") #div.add_style("height: 170px") div.add_style("width: 105px") div.add_style("height: 85px") div.add(image) section_wdg.add(desc_div) div.add_style("overflow: hidden") section_wdg.add_behavior( behavior ) section_wdg.add_class("hand") return section_wdg
def get_display(my): paths = my.get_files() top = my.top top.add_style("padding: 10px") top.add_color("background", "background", -5) top.add_style("min-width: 500px") top.add_style("font-size: 12px") top.add_class("spt_sobject_dir_list_top") my.set_as_panel(top) inner = DivWdg() top.add(inner) show_title = my.kwargs.get("show_title") if show_title not in [False, 'false']: title_wdg = DivWdg() inner.add(title_wdg) title_wdg.add("File Browser [%s]" % my.sobject.get_code()) title_wdg.add_gradient("background", "background3") title_wdg.add_style("padding: 5px") title_wdg.add_style("margin: -10px -10px 10px -10px") title_wdg.add_style("font-weight: bold") show_shelf = my.kwargs.get("show_shelf") if show_shelf not in [False, 'false']: shelf_wdg = DivWdg() inner.add(shelf_wdg) shelf_wdg.add(my.get_shelf_wdg()) shelf_wdg.add_style("padding: 5px") shelf_wdg.add_style("margin: -5px -5px 15px -5px") shelf_wdg.add_style("font-weight: bold") base_dir = Environment.get_asset_dir() dir_list = SnapshotDirListWdg(base_dir=base_dir, location="server", show_base_dir=True, paths=paths, all_open=True, files=my.files, snapshots=my.snapshots) inner.add(dir_list) if my.kwargs.get("is_refresh"): return inner else: return top
def get_row_wdgXX(my, buttons, show_title=False): top = DivWdg() #top.add_style("-moz-transform: scale(1.0)") top.add_style("float: left") top.add_style("margin-left: 3px") top.add_style("margin-right: 3px") if show_title: top.add_style("height: 29px") else: top.add_style("height: 23px") top.add_style("height: 33px") left = DivWdg() left.set_round_corners(20) #left.add_style("-moz-border-radius-topleft: 20px") #left.add_style("-moz-border-radius-bottomleft: 20px") left.add_border() left.add_gradient("background", "background", 20, -35) #left.add_style("background: black") left.add_style("float: left") left.add_style("height: 100%") left.add_style("width: 5px") left.add_style("z-index: 0") left.add_style("margin-right: -1") top.add(left) for button in buttons: button.add_style("float: left") top.add(button) right = DivWdg() right.add_style("-moz-border-radius-topright: 20px") right.add_style("-moz-border-radius-bottomright: 20px") right.add_gradient("background", "background", 20, -35) #right.add_style("background: black") right.add_style("float: left") right.add_style("height: 100%") right.add_style("width: 5px") #right.add_style("margin-left: -1px") right.add_style("z-index: 0") right.add_style("border-style: solid") right.add_style("border-color: %s" % right.get_color("border") ) right.add_style("border-width: 1 1 1 0") top.add(right) return top
def get_display(my): paths = my.get_files() top = my.top top.add_style("padding: 10px") top.add_color("background", "background", -5) top.add_style("min-width: 500px") top.add_style("font-size: 12px") top.add_class("spt_sobject_dir_list_top") my.set_as_panel(top) inner = DivWdg() top.add(inner) show_title = my.kwargs.get("show_title") if show_title not in [False, 'false']: title_wdg = DivWdg() inner.add(title_wdg) title_wdg.add("File Browser [%s]" % my.sobject.get_code()) title_wdg.add_gradient("background", "background3") title_wdg.add_style("padding: 5px") title_wdg.add_style("margin: -10px -10px 10px -10px") title_wdg.add_style("font-weight: bold") show_shelf = my.kwargs.get("show_shelf") if show_shelf not in [False, 'false']: shelf_wdg = DivWdg() inner.add(shelf_wdg) shelf_wdg.add(my.get_shelf_wdg()) shelf_wdg.add_style("padding: 5px") shelf_wdg.add_style("margin: -5px -5px 15px -5px") shelf_wdg.add_style("font-weight: bold") base_dir = Environment.get_asset_dir() dir_list = SnapshotDirListWdg(base_dir=base_dir, location="server", show_base_dir=True,paths=paths, all_open=True, files=my.files, snapshots=my.snapshots) inner.add(dir_list) if my.kwargs.get("is_refresh"): return inner else: return top
def get_small_section_wdg(my, title, description, image, behavior): section_wdg = DivWdg() section_wdg.set_round_corners() section_wdg.add_border() section_wdg.add_style("width: 225px") section_wdg.add_style("height: 100px") section_wdg.add_style("overflow: hidden") section_wdg.add_style("margin: 10px") section_wdg.set_box_shadow("0px 0px 5px") title_wdg = DivWdg() section_wdg.add(title_wdg) title_wdg.add(title) title_wdg.add_style("height: 20px") title_wdg.add_style("padding: 3px") title_wdg.add_style("margin-top: 3px") title_wdg.add_style("font-weight: bold") title_wdg.add_gradient("background", "background") section_wdg.add_color("background", "background") #section_wdg.add_gradient("background", "background", 0, -3) section_wdg.add_behavior( { 'type': 'hover', 'add_color_modifier': -5, 'cb_set_prefix': 'spt.mouse.table_layout_hover', } ) desc_div = DivWdg() desc_div.add(description) desc_div.add_style("padding: 5px 10px 10px 5px") div = DivWdg() section_wdg.add(div) div.add_style("padding: 5px") div.add_style("margin: 5px") div.add_style("width: 65px") div.add_style("height: 50px") div.add_style("float: left") div.add_style("text-align: center") div.add(image) section_wdg.add(desc_div) div.add_style("overflow: hidden") section_wdg.add_behavior( behavior ) section_wdg.add_class("hand") return section_wdg
def get_panel_wdg(my, td, panel): title = panel.get("title") widget = panel.get("widget") width = panel.get("width") #height = panel.get("height") #if not height: # height = "250px" #td.add_style("height: %s" % height) if width: td.add_style("width: %s" % width) td.add_border() div = DivWdg() div.add_style("padding: 5px") #div.add_style("padding: 10px") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_style("padding: 5px") #title_wdg.add_style("margin: -12px -12px 10px -12px") title_wdg.add_style("margin: -7px -7px 5px -7px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") if title: title_wdg.add_gradient("background", "background", -10) title_wdg.add_color("color", "color", -10) title_wdg.add_border() title_wdg.add(title) from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias=my.get_help_alias()) help_wdg.add_style("float: right") help_wdg.add_style("margin-top: -5px") title_wdg.add(help_wdg) else: title_wdg.add_style("height: 10px") if widget: div.add(widget) return div
def get_row_wdgXX(my, buttons, show_title=False): top = DivWdg() #top.add_style("-moz-transform: scale(1.0)") top.add_style("float: left") top.add_style("margin-left: 3px") top.add_style("margin-right: 3px") if show_title: top.add_style("height: 29px") else: top.add_style("height: 23px") top.add_style("height: 33px") left = DivWdg() left.set_round_corners(20) #left.add_style("-moz-border-radius-topleft: 20px") #left.add_style("-moz-border-radius-bottomleft: 20px") left.add_border() left.add_gradient("background", "background", 20, -35) #left.add_style("background: black") left.add_style("float: left") left.add_style("height: 100%") left.add_style("width: 5px") left.add_style("z-index: 0") left.add_style("margin-right: -1") top.add(left) for button in buttons: button.add_style("float: left") top.add(button) right = DivWdg() right.add_style("-moz-border-radius-topright: 20px") right.add_style("-moz-border-radius-bottomright: 20px") right.add_gradient("background", "background", 20, -35) #right.add_style("background: black") right.add_style("float: left") right.add_style("height: 100%") right.add_style("width: 5px") #right.add_style("margin-left: -1px") right.add_style("z-index: 0") right.add_style("border-style: solid") right.add_style("border-color: %s" % right.get_color("border")) right.add_style("border-width: 1 1 1 0") top.add(right) return top
def get_display(self): top = self.top title = self.kwargs.get("title") title_wdg = DivWdg() top.add(title_wdg) title_wdg.add(title) title_wdg.add_style("font-size: 18px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("text-align: center") title_wdg.add_style("padding: 10px") title_wdg.add_style("margin: -10px -10px 10px -10px") title_wdg.add_gradient("background", "background3", 5, -10) return top
def get_display(my): top = my.top title = my.kwargs.get("title") title_wdg = DivWdg() top.add(title_wdg) title_wdg.add(title) title_wdg.add_style("font-size: 18px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("text-align: center") title_wdg.add_style("padding: 10px") title_wdg.add_style("margin: -10px -10px 10px -10px") title_wdg.add_gradient("background", "background3", 5, -10) return top
def get_display(my): top = my.top my.set_as_panel(top) top.add_color("background", "background") top.add_border() top.add_class("spt_tab_edit_top") my.config = my.get_config() table = ResizableTableWdg() top.add(table) table.add_color("color", "color") table.add_row() left = table.add_cell() left.add(my.get_elements_wdg() ) left.add_style("width: 200px") left.add_border() left.add_color("background", "background3") left.add_color("color", "color3") right = table.add_cell() right.add_border() title_wdg = DivWdg() right.add(title_wdg) title_wdg.add("Definition") title_wdg.add_style("padding: 5px") title_wdg.add_gradient("background", "background", -10) right_div = DivWdg() right.add(right_div) right_div.add_style("width: 500px") right_div.add_class("spt_tab_edit_content") return top
def get_display(my): title = DivWdg() title.add(my.name_of_title) title.add_style("padding: 5px") title.add_style("margin: -10px -10px 10px -10px") title.add_style("font-weight: bold") title.add_style("font-size: 14px") title.add_gradient("background", "background", -10) title.add_color("color", "color", -10) title.add_border() from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias=my.help_alias) help_wdg.add_style("float: right") help_wdg.add_style("margin-top: -5px") title.add(help_wdg) return title
def get_display(self): top = self.top self.set_as_panel(top) top.add_color("background", "background") top.add_border() top.add_class("spt_tab_edit_top") self.config = self.get_config() table = ResizableTableWdg() top.add(table) table.add_color("color", "color") table.add_row() left = table.add_cell() left.add(self.get_elements_wdg()) left.add_style("width: 200px") left.add_border() left.add_color("background", "background3") left.add_color("color", "color3") right = table.add_cell() right.add_border() title_wdg = DivWdg() right.add(title_wdg) title_wdg.add("Definition") title_wdg.add_style("padding: 5px") title_wdg.add_gradient("background", "background", -10) right_div = DivWdg() right.add(right_div) right_div.add_style("width: 500px") right_div.add_class("spt_tab_edit_content") return top
def get_group_wdg(self): div = DivWdg() title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") title_wdg.add_gradient("background", "background") title_wdg.add("Users") title_wdg.add_style("min-width: 200px") filtered_groups = self.kwargs.get("groups") if isinstance(filtered_groups, basestring): filtered_groups = filtered_groups.split("|") search = Search("sthpw/login_group") if filtered_groups: search.add_filters("login_group", filtered_groups) security = Environment.get_security() if not security.check_access("builtin", "view_site_admin", "allow"): search.add_filter("login_group", "admin", op="!=") search.add_project_filter() groups = search.get_sobjects() groups_div = DivWdg() div.add(groups_div) for group in groups: group_div = DivWdg() groups_div.add(group_div) title_div = DivWdg() group_div.add(title_div) title_div.add_color("background", "background3") title_div.add_color("color", "color3") title_div.add_style("margin-top: 5px") title_div.add_style("padding: 2px") swap = SwapDisplayWdg() title_div.add(swap) swap.add_style("float: left") title = DivWdg(group.get_value("login_group")) title_div.add(title) #title.add_style("float: left") title.add_style("font-weight: bold") title.add_style("padding-top: 2px") content_div = DivWdg() group_div.add(content_div) SwapDisplayWdg.create_swap_title(title, swap, div=content_div, is_open=True, action_script=None) logins = group.get_logins() logins_div = self.get_logins_wdg(logins) content_div.add(logins_div) content_div.add_style("padding-left: 15px") return div
def get_pipeline_wdg(my, pipeline_code): div = DivWdg() title = DivWdg() title.add_gradient("background", "background3", 0) title.add_style("height: 20px") title.add_style("font-weight: bold") title.add_style("padding: 4px") title.add_border() title.add("Pipeline") div.add(title) kwargs = { 'width': 800, 'height': 300, 'pipeline': pipeline_code, 'scale': 0.7, } pipeline = TaskDetailPipelineWdg(**kwargs) div.add(pipeline) load_div = DivWdg() div.add(load_div) # This is only for tasks!!!! enabled_tasks = set() from pyasm.biz import Task process = '' if my.parent: tasks = Task.get_by_sobject(my.parent) if my.sobject.has_value("process"): process = my.sobject.get_value("process") else: tasks = Task.get_by_sobject(my.sobject) for task in tasks: enabled_tasks.add(task.get_value("process")) enabled_tasks = list(enabled_tasks) load_div.add_behavior( { 'type': 'load', 'process': process, 'enabled_tasks': enabled_tasks, 'pipeline': pipeline_code, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_pipeline_wrapper"); spt.pipeline.init_cbk(top); var nodes = spt.pipeline.get_nodes_by_group(bvr.pipeline); for (var i = 0; i < nodes.length; i++) { var has_task = false; var node = nodes[i]; var node_name = spt.pipeline.get_node_name(node); for (var j = 0; j < bvr.enabled_tasks.length; j++) { if (node_name == bvr.enabled_tasks[j]) { has_task = true; break; } } if (!has_task && node) { spt.pipeline.disable_node(node); } } spt.pipeline.unselect_all_nodes(); var node = spt.pipeline.get_node_by_name(bvr.process); //process and node name could be different if (node) { node.setStyle("font-weight", "bold"); spt.pipeline.select_node(node); //spt.pipeline.center_node(node); } spt.pipeline.fit_to_canvas(bvr.pipeline); ''' } ) #div.add_style("padding: 10px") div.add_border() return div
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(my): top = my.top top.add_class("spt_changelist_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") #top.add_border() #top.add_style("padding", "10px") top.add_style("min-width: 600px") top.add_style("min-height: 400px") top.add_behavior({'type': 'load', 'cbjs_action': scm_get_onload_js()}) sync_dir = Environment.get_sandbox_dir() # HARD CODED project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot changelist = my.kwargs.get("changelist") if not changelist: changelist = WidgetSettings.get_value_by_key("current_changelist") else: WidgetSettings.set_value_by_key("current_changelist", changelist) if not changelist: changelist = 'default' changelists = my.kwargs.get("changelists") if not changelists: changelists = [] elif isinstance(changelists, basestring): changelists = changelists.replace("'", '"') changelists = jsonloads(changelists) top.add_behavior({ 'type': 'load', 'sync_dir': sync_dir, 'depot': depot, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' }) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_color("background", "background", -3) table.add_row() th = table.add_header("") th = table.add_header("Changelist") th.add_style("text-align: left") th = table.add_header("Description") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("Status") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Delete") th.add_style("text-align: left") #table.set_unique_id() #table.add_smart_styles("spt_changelist_item", { # 'text-align: right' # } )) bgcolor = table.get_color("background", -8) table.add_relay_behavior({ 'type': 'mouseover', 'bvr_match_class': 'spt_changelist_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' }) table.add_relay_behavior({ 'type': 'mouseout', 'bvr_match_class': 'spt_changelist_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' }) table.add_relay_behavior({ 'type': 'mouseup', 'bvr_match_class': "spt_changelist_radio", 'cbjs_action': ''' var changelist = bvr.src_el.value; var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", changelist); spt.app_busy.show("Loading Changelists Information"); spt.changelist.load(bvr.src_el, changelist); spt.app_busy.hide(); ''' }) for c in changelists: num_items = len(c.get("info")) name = c.get("change") tr = table.add_row() tr.add_class("spt_changelist_item") radio = RadioWdg("changelist") radio.add_class("spt_changelist_radio") table.add_cell(radio) radio.set_option("value", name) if name == changelist: radio.set_checked() table.add_cell(name) table.add_cell(c.get("desc")) table.add_cell(num_items) table.add_cell(c.get("status")) if num_items: icon = IconButtonWdg(title="View", icon=IconWdg.ZOOM) icon.add_behavior({ 'type': 'click_up', 'changelist': c.get("change"), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", bvr.changelist); spt.app_busy.show("Loading Changelist"); spt.changelist.load(bvr.src_el, bvr.changelist); spt.app_busy.hide(); ''' }) else: icon = '' table.add_cell(icon) if not num_items and name != 'default': icon = IconButtonWdg(title="Delete Changelist", icon=IconWdg.DELETE) else: icon = "" table.add_cell(icon) inner.add("<hr/>") files = my.kwargs.get("files") if isinstance(files, basestring): files = files.replace("'", '"') files = jsonloads(files) if files == None: inner.add_behavior({ 'type': 'load', 'location': location, 'changelist': changelist, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.changelist = {} spt.changelist.load = function(el, changelist) { var applet = spt.Applet.get(); var changelists = spt.scm.run("get_changelists_by_user",[]); var dflt = { 'change': 'default', 'status': 'pending' } changelists.push(dflt); changelists = changelists.reverse(); for (var i = 0; i < changelists.length; i++) { var info = spt.scm.run("get_changelist_files",[changelists[i].change]); changelists[i]['info'] = info; } // get the current chnage list var files = spt.scm.run("get_changelist_files",[changelist]); var path_info = {}; var sizes = []; for ( var i = 0; i < files.length; i++) { // FIXME: perforce specific var path = files[i].depotFile; path = path.replace(bvr.location, bvr.sync_dir); files[i].path = path; var size; if (applet.exists(path)) { var info = applet.get_path_info(path); size = info.size; } else { size = 0; } sizes.push(size); path_info[path] = 'editable'; } //var ret_val = spt.scm.status(bvr.sync_dir); //console.log(ret_val); var class_name = 'tactic.ui.checkin.changelist_wdg.ChangelistWdg'; var kwargs = { files: files, sizes: sizes, changelist: changelist, changelists: changelists, path_info: path_info, } var top = el.getParent(".spt_changelist_content"); spt.panel.load(top, class_name, kwargs); } spt.changelist.load(bvr.src_el, bvr.changelist); ''' }) content = DivWdg() inner.add(content) content.add_class("spt_changelist_content") if files == None: loading_wdg = DivWdg() content.add(loading_wdg) loading_wdg.add("<b>Loading ...</b>") loading_wdg.add_style("padding: 30px") elif files: title_wdg = DivWdg() title_wdg.add_style("height: 15px") title_wdg.add("Changelist: [%s]" % changelist) content.add(title_wdg) title_wdg.add_gradient("background", "background", -5) title_wdg.add_style("padding: 5px") title_wdg.add_border() #button = SingleButtonWdg(tip='Add New Changelist', icon=IconWdg.ADD) #content.add(button) content.add("<br/>") paths = [x.get("path") for x in files] sizes = my.kwargs.get("sizes") path_info = my.kwargs.get("path_info") from scm_dir_list_wdg import ScmDirListWdg # dummy search_key search_key = "sthpw/virtual?code=xx001" dir_list_wdg = ScmDirListWdg( base_dir=sync_dir, paths=paths, sizes=sizes, path_info=path_info, all_open=True, #search_key=search_key ) content.add(dir_list_wdg) else: content.add("Changelist: [%s]" % changelist) content.add("<br/>" * 2) no_files_wdg = DivWdg() content.add(no_files_wdg) no_files_wdg.add_style("padding: 20px") no_files_wdg.add_border() no_files_wdg.add("No files in changelist") no_files_wdg.add_color("color", "color3") no_files_wdg.add_color("background", "background3") no_files_wdg.add_style("font-weight: bold") no_files_wdg.add_style("text-align: center") return top
def get_display(my): top = my.top top.add_color("background", "background") top.add_color("color", "color") top.add_style("width", "400px") top.add_border() top.add_class("spt_delete_project_tool_top") project_code = my.kwargs.get("project_code") if project_code: project = Project.get_by_code(project_code) else: search_key = my.kwargs.get("search_key") project = Search.get_by_search_key(search_key) if project: project_code = project.get_code() title_wdg = DivWdg() if project: top.add(title_wdg) title_wdg.add(IconWdg(icon=IconWdg.WARNING)) title_wdg.add("Deleting Project: %s" % project.get_value("title")) title_wdg.add_gradient("background", "background", -10, -10) title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") content = DivWdg() top.add(content) content.add_style("padding: 10px") if not search_key: warning_msg = "Projects must be deleted individually" content.add(DivWdg(warning_msg, css='warning')) content.add("<br/>") return top warning_msg = "Deleting a project will delete the database associated with this project. All data will be lost. Please consider carefully before proceeding." if warning_msg: content.add(DivWdg(warning_msg, css='warning')) content.add("<br/>") if not project_code: content.add("This project [%s] has been deleted." % search_key) return top elif not project: content.add("This project [%s] has been deleted." % project_code) return top assert project_code assert project content.add("<br/>") content.add( "<b>WARNING: These items will be deleted, but the sTypes entries in search_objects table will be retained.</b> " ) content.add("<br/>") content.add("<br/>") total_items_wdg = DivWdg() total_items = 0 content.add(total_items_wdg) # find all of the sTypes details_wdg = DivWdg() content.add(details_wdg) details_wdg.add_style("max-height: 300px") details_wdg.add_style("overflow-y: auto") details_wdg.add_style("padding-left: 15px") details_wdg.add_border() search_types = project.get_search_types() related_types = [] for search_type_obj in search_types: search_type_wdg = DivWdg() title = search_type_obj.get_title() search_type = search_type_obj.get_value("search_type") search_type_wdg.add_style("margin-top: 5px") search_type_wdg.add_style("margin-bottom: 5px") details_wdg.add(search_type_wdg) search_type_wdg.add(title) search_type_wdg.add(" (%s)" % search_type) search = Search(search_type, project_code=project_code) count = search.get_count() total_items += count search_type_wdg.add(" - %s item(s)" % count) # TODO: this is similar to SearchType.get_related_types(). streamline at some point. related_types = my.get_related_types(search_type) for related_type in related_types: search = Search(related_type) full_search_type = "%s?project=%s" % (search_type, project_code) if related_type.startswith("sthpw/"): search.add_filter("search_type", full_search_type) count = search.get_count() if count == 0: continue total_items += count related_wdg = DivWdg() related_wdg.add_style('padding-left: 25px') search_type_wdg.add(related_wdg) related_wdg.add(related_type) related_wdg.add(" - %s item(s)" % count) if total_items: total_items_wdg.add("Total # of items to be deleted: ") total_items_wdg.add(total_items) total_items_wdg.add_style("font-size: 14px") total_items_wdg.add_style("font-weight: bold") total_items_wdg.add("<br/>") content.add("<br/>" * 2) content.add("<b>Do you wish to continue deleting? </b>") radio = RadioWdg("mode") radio.add_class("spt_mode_radio") radio.set_value("delete") content.add(radio) content.add("<br/>" * 2) #content.add("<b>Or do you just wish to retire the project? </b>") #radio = RadioWdg("mode") #radio.add_class("spt_mode_radio") #radio.set_value("retire") #content.add(radio) #content.add(radio) #content.add("<br/>"*2) #button = ActionButtonWdg(title="Retire") #content.add(button) #button.add_style("float: left") buttons = Table() content.add(buttons) buttons.add_row() buttons.add_style("margin-left: auto") buttons.add_style("margin-right: auto") buttons.add_style("width: 250px") button = ActionButtonWdg(title="Delete") buttons.add_cell(button) button.add_behavior({ 'type': 'click_up', #'search_type': search_type, 'project_code': project_code, 'related_types': related_types, 'cbjs_action': ''' spt.app_busy.show("Deleting"); var class_name = "tactic.ui.tools.DeleteProjectCmd"; var kwargs = { 'project_code': bvr.project_code, 'related_types': bvr.related_types }; var top = bvr.src_el.getParent(".spt_delete_project_tool_top"); var radios = top.getElements(".spt_mode_radio"); //if (!radios[0].checked && !radios[1].checked) { if (!radios[0].checked) { spt.alert("Please confirm the delete by checking the radio button."); spt.app_busy.hide(); return; } var mode = 'retire'; if (radios[0].checked == true) { mode = 'delete'; } if (mode == 'retire') { return; } var success = false; var server = TacticServerStub.get(); setTimeout(function() { spt.app_busy.show("Deleting Project ["+bvr.project_code+"]") var error_message = "Error deleting project ["+bvr.project_code+"]"; try { server.start({'title': 'Deleted Project ', 'description': 'Deleted Project [' + bvr.project_code + ']'}); server.execute_cmd(class_name, kwargs); success = true; var top = bvr.src_el.getParent(".spt_popup"); spt.popup.destroy(top); server.finish(); } catch(e) { error_message = spt.exception.handler(e); } spt.app_busy.hide(); if (success) { spt.notify.show_message("Successfully deleted project ["+bvr.project_code+"]"); spt.tab.set_main_body_tab(); spt.tab.reload_selected(); } else { if (error_message.test(/does not exist/)) error_message += '. You are advised to sign out and log in again.'; spt.error(error_message); } }, 100); ''' }) button = ActionButtonWdg(title="Cancel") buttons.add_cell(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_popup"); spt.popup.destroy(top); ''' }) return top
def get_display(my): top = my.top view = my.kwargs.get("view") top.add_class("spt_help_edit_content") search = Search("config/widget_config") search.add_filter("category", "HelpWdg") search.add_filter("view", view) sobject = search.get_sobject() if not sobject: value = "" search_key = "" else: xml_value = sobject.get_xml_value("config") value = xml_value.get_value("config/%s/html/div" % (view) ) search_key = sobject.get_search_key() title_wdg = DivWdg() top.add(title_wdg) title_wdg.add("<b>View: %s</b>" % view) title_wdg.add_style("font-style: bold") title_wdg.add_style("padding: 5px") title_wdg.add_gradient("background", "background", 0, -10) hidden = HiddenWdg("view") top.add(hidden) hidden.set_value(view) text = TextAreaWdg("content") text_id = text.set_unique_id() text.set_value(value) from tactic.ui.widget import ActionButtonWdg if sobject: delete_button = ActionButtonWdg(title="Delete") top.add(delete_button) delete_button.add_style("float: right") delete_button.add_style("margin-top: -3px") delete_button.add_behavior( { 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' if (!confirm("Are you sure you wish to delete this help page?")) { return; } var server = TacticServerStub.get(); server.delete_sobject(bvr.search_key); var top = bvr.src_el.getParent(".spt_help_edit_top"); spt.panel.refresh(top); ''' }) test_button = ActionButtonWdg(title="Preview") top.add(test_button) test_button.add_style("float: right") test_button.add_style("margin-top: -3px") test_button.add_behavior( { 'type': 'click_up', 'text_id': text_id, 'cbjs_action': ''' var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); var cmd = "CKEDITOR.instances." + bvr.text_id + ".getData()"; var text_value = eval( cmd ); bvr.options = {}; bvr.options.html = text_value; spt.named_events.fire_event("show_help", bvr) ''' }) save_button = ActionButtonWdg(title="Save") top.add(save_button) save_button.add_style("float: right") save_button.add_style("margin-top: -3px") top.add("<br/>") save_button.add_behavior( { 'type': 'click_up', 'text_id': text_id, 'cbjs_action': ''' spt.app_busy.show("Saving Help", " ") var top = bvr.src_el.getParent(".spt_help_edit_content"); var values = spt.api.Utility.get_input_values(top, null, false); var cmd = "CKEDITOR.instances." + bvr.text_id + ".getData()"; var text_value = eval( cmd ); values.content = text_value; var command = "tactic.ui.app.HelpEditCbk"; var kwargs = values; var server = TacticServerStub.get(); server.execute_cmd(command, kwargs); setTimeout("spt.app_busy.hide()", 200) ''' } ) #top.add("Style: ") #select = SelectWdg("style") #top.add(select) #select.set_option("values", "text|html") top.add("<br/>") top.add(text) text.set_value(value) text.add_style("width: 100%") text.add_style("height: 100%") text.add_style("min-height: 500px") text.add_style("display: none") text.add_behavior( { 'type': 'load', 'color': text.get_color("background", -10), 'text_id': text_id, 'cbjs_action': ''' var js_file = "ckeditor/ckeditor.js"; var url = "/context/spt_js/" + js_file; var js_el = document.createElement("script"); js_el.setAttribute("type", "text/javascript"); js_el.setAttribute("src", url); var head = document.getElementsByTagName("head")[0]; head.appendChild(js_el); setTimeout( function() { CKEDITOR.on( 'instanceReady', function( ev ) { ev.editor.dataProcessor.writer.indentationChars = ' '; }); var config = { toolbar: 'Full', uiColor: bvr.color, height: '500px' }; config.toolbar_Full = [ ['Source'], ['Cut','Copy','Paste'], ['Undo','Redo','-','Find','Replace'], ['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], '/', ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['HorizontalRule','SpecialChar'], ['Styles','Format','Font','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks'] ]; CKEDITOR.replace(bvr.text_id, config ); bvr.src_el.setStyle("display", ""); }, 500); ''' } ) return top
def get_display(my): top = my.top top.add_color("background", "background") top.add_color("color", "color") top.add_style("width", "400px") top.add_class('spt_delete_stype_top') top.add_border() project_code = Project.get_project_code() # Note search types should only really be deleted if they were just # created search_type = my.kwargs.get("search_type") if not search_type: node_name = my.kwargs.get("node_name") if node_name: #project_code = Project.get_project_code() search_type = "%s/%s" % (project_code, node_name) assert search_type built_in_stypes = ['task','note','work_hour','login','login_group','schema','project','login_in_group','snapshot','file','trigger','spt_trigger','widget_config','custom_script','notification','notification_log','file_access','cache','exception_log','milestone','pipeline','pref_list','pref_setting','project_type','repo','remote_repo','search_sobject','sobject_list','ticket','db_resource','wdg_settings','status_log','debug_log','transaction_log', 'sobject_log'] for tbl in built_in_stypes: if search_type == 'sthpw/%s'%tbl: top.add("sType [%s] is internal and cannot be deleted!" % search_type) top.add_style("font-size: 14px") top.add_style('padding: 20px') return top search_type_obj = SearchType.get(search_type) if not search_type: top.add("sType [%s] does not exist!" % search_type) top.add_style("font-size: 14px") top.add_style('padding: 20px') return top table = search_type_obj.get_table() db_val = search_type_obj.get_value('database') if db_val == '{project}': label = '' elif db_val == 'sthpw': label = 'built-in' else: label = 'project-specific' # warn if more than 1 sType point to the same table in the same project expr = "@GET(sthpw/search_type['table_name', '%s']['database', 'in', '{project}|%s']['namespace','%s'].search_type)" %(table, project_code, project_code) rtn = Search.eval(expr) warning_msg = '' if len(rtn) > 1: warning_msg = 'Warning: There is more than 1 sType [%s] pointing to the same table [%s]. Deleting will affect both sTypes.' %(', '.join(rtn), table) title_wdg = DivWdg() top.add(title_wdg) title_wdg.add(IconWdg(icon=IconWdg.WARNING)) title_wdg.add("Delete %s sType: %s" % (label,search_type)) title_wdg.add_gradient("background", "background", -10, -10) title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") content = DivWdg() top.add(content) content.add_style("padding: 10px") if warning_msg: content.add(DivWdg(warning_msg, css='warning')) content.add("<br/>") content.add("This sType uses the table \"%s\" to store items.<br/>" % table) content.add("<br/>") search = Search(search_type) count = search.get_count() content.add("Number of items in the table: %s<br/>" % count) content.add("<br/>") search.add_column("id") sobjects = search.get_sobjects() if sobjects: items_search_type = sobjects[0].get_search_type() search_ids = [x.get_id() for x in sobjects] notes_search = Search("sthpw/note") notes_search.add_filters("search_id", search_ids) notes_search.add_filter("search_type", items_search_type) note_count = notes_search.get_count() cb = CheckboxWdg('related_types') cb.set_attr('value', 'sthpw/note') content.add(cb) content.add(SpanWdg("Number of related notes: %s"% note_count, css='small') ) content.add(HtmlElement.br()) tasks_search = Search("sthpw/task") tasks_search.add_filters("search_id", search_ids) tasks_search.add_filter("search_type", items_search_type) task_count = tasks_search.get_count() cb = CheckboxWdg('related_types') cb.set_attr('value', 'sthpw/task') content.add(cb) content.add(SpanWdg("Number of related tasks: %s"% task_count, css='small') ) content.add(HtmlElement.br()) snapshots_search = Search("sthpw/snapshot") snapshots_search.add_filters("search_id", search_ids) snapshots_search.add_filter("search_type", items_search_type) snapshot_count = snapshots_search.get_count() cb = CheckboxWdg('related_types') cb.set_attr('value', 'sthpw/snapshot') content.add(cb) content.add(SpanWdg("Number of related snapshots: %s"% snapshot_count, css='small') ) content.add(HtmlElement.br()) pipelines_search = Search("sthpw/pipeline") pipelines_search.add_filter("search_type", search_type) pipeline_count = pipelines_search.get_count() cb = CheckboxWdg('related_types') cb.set_attr('value','sthpw/pipeline') content.add(cb) content.add(SpanWdg("Number of related pipelines: %s"% pipeline_count, css='small') ) content.add(HtmlElement.br(2)) content.add("<b>WARNING: Deleting the sType will delete all of these items.</b> ") content.add("<br/>"*2) content.add("Do you wish to continue deleting?") content.add("<br/>"*2) button_div = DivWdg() button_div.add_styles('width: 300px; height: 50px') button = ActionButtonWdg(title="Delete") button_div.add(button) content.add(button_div) button.add_style("float: left") button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'cbjs_action': ''' spt.app_busy.show("Deleting sType"); var class_name = "tactic.ui.tools.DeleteSearchTypeCmd"; var ui_top = bvr.src_el.getParent(".spt_delete_stype_top"); var values = spt.api.Utility.get_input_values(ui_top); var kwargs = { 'search_type': bvr.search_type, 'values': values }; var server = TacticServerStub.get(); try { server.start({'title': 'Delete sType', 'description': 'Delete sType [' + bvr.search_type + ']'}); server.execute_cmd(class_name, kwargs); var top = bvr.src_el.getParent(".spt_popup"); spt.pipeline.remove_node(top.stype_node); // force a schema save spt.named_events.fire_event('schema|save', bvr) top.destroy(); server.finish(); } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); spt.notify.show_message("Successfully deleted sType ["+bvr.search_type+"]"); ''' } ) button = ActionButtonWdg(title="Cancel") button.add_style("float: left") button_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_popup"); top.destroy(); ''' } ) 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") title = DivWdg() title.add("Advanced Project Setup Tools") 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 10px -10px") top.add(title) from tactic.ui.widget import TitleWdg subtitle = TitleWdg(name_of_title='', help_alias='project-startup-configuration') top.add(subtitle) title.add_gradient("background", "background3", 5, -10) top.add("<br/>") content = DivWdg() top.add(content) """ desc = DivWdg() content.add(desc) desc.add_style("text-align: left") desc.add_style("padding-left: 15px") desc.center() desc.add("The following tools are used for advanced project configuration.<br/><br/>") desc.add_style("width: 600px") """ button_div = DivWdg() button = SingleButtonWdg(title="Project Startup", icon=IconWdg.HOME) button_div.add(button) button_div.add_style("float: left") button_div.add_style("margin-top: -10px") 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: 'project-startup-configuration' }; spt.tab.add_new("_startup", "Startup", class_name, kwargs); ''' }) content.add(button_div) table = Table() content.add(table) table.add_color("color", "color") table.add_row() table.center() # Schema Editor td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Create Schema" description = '''The schema is a collection of nodes that layout the basic components of a project. Each node represents a separate list of items (sType) used in this project: ie Assets, Shots, Artwork, etc.''' #image = "<img src='/context/icons/64x64/schema_64.png'/>" image = "<img src='/context/images/getting_started_schema.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.tools.SchemaToolWdg'; var kwargs = { help_alias: 'project-schema' }; spt.tab.add_new("create_schema", "Create Schema", class_name, kwargs); ''' } schema_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(schema_wdg) # Workflow td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Create Workflow" image = "<img src='/context/images/getting_started_pipeline.png'/>" description = "Pipelines define how particular items of an sType will move through its lifecycle. Creating pipelines will also allow you to set up automatic triggers and notifications for each process." behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.tools.PipelineToolWdg'; var kwargs = { help_alias: 'project-workflow' }; spt.tab.add_new("create_workflow", "Create Workflow", class_name, kwargs); ''' } pipeline_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(pipeline_wdg) # Sidebar td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Manage Side Bar" #image = "<img src='/context/icons/64x64/sidebar_64.png'/>" image = "<img src='/context/images/getting_started_sidebar.png'/>" description = "The Side Bar can be easily configured to show specific views of your project to each user." behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.panel.ManageViewPanelWdg'; var kwargs = { help_alias: 'managing-sidebar' }; spt.tab.add_new("manage_project_views", "Manage Side Bar", class_name, kwargs); ''' } side_bar_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(side_bar_wdg) tr = table.add_row() # Manage View td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Manage Views" image = IconWdg("Manage Views", IconWdg.LIST_01) div = DivWdg(image) image = div description = "Manage the views within the project." behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.manager.ViewManagerWdg'; var kwargs = { help_alias: 'view-manager' }; spt.tab.add_new("manage_views", "Manage Views", class_name, kwargs); ''' } manage_view_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(manage_view_wdg) # Naming Conventions td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Naming Conventions" image = IconWdg("Naming Conventions", IconWdg.FOLDERS_01) div = DivWdg(image) image = div description = "Setup custom Directory and File naming conventions." behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'view': 'table', 'search_type': 'config/naming', help_alias: 'project-automation-file-naming' }; spt.tab.add_new("naming_conventions", "Naming Conventions", class_name, kwargs); ''' } naming_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(naming_wdg) # Users td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Manage Security" image = IconWdg("Manage Security", IconWdg.LOCK_32_01) div = DivWdg(image) image = div description = "Manage users and group permissions" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.SecurityWdg'; var kwargs = { }; spt.tab.add_new("manage_security", "Manage Security", class_name, kwargs); ''' } users_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(users_wdg) tr = table.add_row() # Script Editor td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Script Editor" image = IconWdg("Script Editor", IconWdg.SCRIPT_EDITOR_01) div = DivWdg(image) image = div description = "Edit and Create custom Python and Javascipt tools, triggers and scripts." behavior = { 'type': 'click_up', 'cbjs_action': ''' var title = "TACTIC Script Editor" var class_name = "tactic.ui.app.ShelfEditWdg" spt.panel.load_popup(title, class_name, {}, {"load_once": true} ) ''' } script_editor_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(script_editor_wdg) # Project Settings td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Project Settings" image = IconWdg("Project Settings", IconWdg.CONFIGURE_02) div = DivWdg(image) image = div description = "Setting for the current project." behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'view': 'table', 'search_type': 'config/prod_setting', help_alias: 'main' }; spt.tab.add_new("project_settings", "Project Settings", class_name, kwargs); ''' } prod_settings_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(prod_settings_wdg) # Widget Config td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Widget Config" image = IconWdg("Widget Config", IconWdg.WIDGET_CONFIG_01) div = DivWdg(image) image = div description = "Modify the base widget configurations for the project." behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'view': 'table', 'search_type': 'config/widget_config', help_alias: 'tactic-widgets' }; spt.tab.add_new("widget_config", "Widget Config", class_name, kwargs); ''' } config_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(config_wdg) # Quicklinks tr, td = table.add_row_cell() td.add_style("font-size: 14px") td.add("<br/>") div = DivWdg() title = DivWdg() div.add(title) div.add_color("background", "background") div.add_style("margin: 0px 10px 15px 10px") title.add("Quick Links") title.add_style("font-size: 16px") title.add_style("padding: 5px") title.add_gradient("background", "background") title.add_border() title.set_round_corners(corners=['TL', 'TR']) content_wdg = DivWdg() div.add(content_wdg) content_wdg.add_border() content_wdg.add_style("padding: 20px") content_wdg.add( "<div style='font-size: 12px'>The following links will help you find out more information on how to set up or use TACTIC.</div>" ) content_wdg.add("<hr/>") hover = title.get_color("background", -10) link_div = DivWdg() link_div.add_style("padding: 10px") content_wdg.add(link_div) icon = IconWdg("TACTIC Documentation", IconWdg.JUMP) link_div.add(icon) link = HtmlElement.href("TACTIC Documentation", "/doc/", target="_blank") link.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.help.set_top(); spt.help.load_alias("main"); ''' }) link.add_behavior({ 'type': 'hover', 'color': hover, 'cbjs_action_over': ''' bvr.src_el.setStyle("background", bvr.color); ''', 'cbjs_action_out': ''' bvr.src_el.setStyle("background", ""); ''' }) link_div.add(link) link.add_color("color", "color") link_div.add("<br/>" * 2) icon = IconWdg("Southpaw Web Site", IconWdg.JUMP) link_div.add(icon) link = HtmlElement.href("Southpaw Web Site", "http://www.southpawtech.com", target="_blank") link_div.add(link) link.add_color("color", "color") link.add_behavior({ 'type': 'hover', 'color': hover, 'cbjs_action_over': ''' bvr.src_el.setStyle("background", bvr.color); ''', 'cbjs_action_out': ''' bvr.src_el.setStyle("background", ""); ''' }) link_div.add("<br/>" * 2) icon = IconWdg("TACTIC Community", IconWdg.JUMP) link_div.add(icon) link = HtmlElement.href("TACTIC Community", "http://community.southpawtech.com", target="_blank") link_div.add(link) link.add_color("color", "color") link.add_behavior({ 'type': 'hover', 'color': hover, 'cbjs_action_over': ''' bvr.src_el.setStyle("background", bvr.color); ''', 'cbjs_action_out': ''' bvr.src_el.setStyle("background", ""); ''' }) td.add(div) return top
def get_section_wdg(my, title, description, image, behavior): section_wdg = DivWdg() section_wdg.set_round_corners() section_wdg.add_border() section_wdg.add_style("width: 225px") section_wdg.add_style("height: 200px") section_wdg.add_style("overflow: hidden") section_wdg.add_style("margin: 10px") section_wdg.set_box_shadow("2px 2px 2px 2px") title_wdg = DivWdg() section_wdg.add(title_wdg) title_wdg.add(title) title_wdg.add_style("height: 20px") title_wdg.add_style("padding: 3px") title_wdg.add_style("margin-top: 3px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("text-align: center") title_wdg.add_gradient("background", "background") section_wdg.add_color("background", "background") section_wdg.add_behavior({ 'type': 'hover', 'add_color_modifier': -3, 'cb_set_prefix': 'spt.mouse.table_layout_hover', }) section_wdg.add_behavior({ 'type': 'click', 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999"); ''' }) section_wdg.add_behavior({ 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "2px 2px 2px 2px #999"); ''', }) desc_div = DivWdg() desc_div.add(description) desc_div.add_style("padding: 5px 10px 10px 10px") desc_div.add_style("font-size: 1.1em") div = DivWdg() section_wdg.add(div) div.add_style("padding: 3px") div.add_style("margin: 10px") div.add_style("width: 209px") div.add_style("height: 64px") div.add_style("text-align: center") div.add(image) #div.set_box_shadow("1px 1px 1px 1px") section_wdg.add(desc_div) div.add_style("overflow: hidden") section_wdg.add_behavior(behavior) section_wdg.add_class("hand") return section_wdg
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_class("spt_reports_top") title = DivWdg() title.add("Dashboards") 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 10px -10px") title.add_gradient("background", "background3", 5, -10) top.add(title) from tactic.ui.widget import TitleWdg subtitle = TitleWdg(name_of_title='List of Dashboards', help_alias='project-startup-dashboards') top.add(subtitle) top.add("<br/>") dashboards = [] # read the config file from pyasm.widget import WidgetConfig tmp_path = __file__ dir_name = os.path.dirname(tmp_path) file_path = "%s/../config/dashboard-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: attrs = config.get_element_attributes(element_name) dashboard_data = {} kwargs = config.get_display_options(element_name) class_name = kwargs.get('class_name') dashboard_data['class_name'] = class_name dashboard_data['kwargs'] = kwargs dashboard_data['title'] = attrs.get("title") dashboard_data['description'] = attrs.get("description") dashboard_data['image'] = attrs.get("image") dashboard_data['image'] = attrs.get("image") dashboards.append(dashboard_data) # get all of the configs from the database search = Search("config/widget_config") search.add_filter("widget_type", "dashboard") db_configs = search.get_sobjects() for db_config in db_configs: dashboard_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") dashboard_data['class_name'] = "tactic.ui.panel.CustomLayoutWdg" dashboard_data['kwargs'] = kwargs dashboard_data['title'] = title dashboard_data['description'] = title dashboard_data['image'] = None dashboard_data['xml'] = xml dashboard_data['widget_type'] = db_config.get_value("widget_type") dashboards.append(dashboard_data) # create a bunch of panels table = Table() top.add(table) table.add_color("color", "color") table.add_style("margin-bottom: 20px") table.center() for i, dashboard in enumerate(dashboards): 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") title = dashboard description = dashboard.get("title") # Each node will contain a list of "items" and will be stored as a table in the database.''' class_name = dashboard.get("class_name") kwargs = dashboard.get("kwargs") title = dashboard.get("title") description = dashboard.get("description") xml = dashboard.get("xml") or "" image = dashboard.get("image") icon = dashboard.get("icon") 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() #image = IconWdg("Bar Chart", IconWdg.WARNING) image = IconWdg("Bar Chart", IconWdg.DASHBOARD_02) 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': ''' 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); ''' } 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) #from tactic.ui.container import TabWdg #tab = TabWdg(show_add=False) #top.add(tab) return top
def get_display(my): top = DivWdg() sobject = my.get_sobject() if not sobject: return top process = my.kwargs.get("process") #from tactic.ui.table import TaskElementWdg #task_wdg = TaskElementWdg() #task_wdg.set_sobject(my.sobject) #top.add(task_wdg) search = Search('sthpw/task') search.add_parent_filter(sobject) search.add_filter("process", process) tasks = search.get_sobjects() tasks_div = DivWdg() top.add(tasks_div) #tasks_div.add_style("padding: 0px 0px 20px 0px") tasks_div.add_style("margin: 10px") tasks_div.set_box_shadow() title = DivWdg() title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("All Tasks for process '%s':" % process) tasks_div.add(title) task_wdg = TableLayoutWdg(search_type="sthpw/task", view='single_process', show_row_select="false", show_insert="false", show_gear="false", show_search_limit="false", show_search=False, show_refresh="false", show_shelf="false") task_wdg.set_sobjects(tasks) tasks_div.add(task_wdg) #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table = Table() top.add(table) table.add_style("width: 100%") table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 50%") notes_div = DivWdg() td.add(notes_div) notes_div.set_box_shadow() notes_div.add_style("margin: 10px") title = DivWdg() notes_div.add(title) title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Notes:") from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=sobject.get_search_key(), process=process, context_hidden=True, show_note_expand=True) notes_div.add(discussion_wdg) search = Search('sthpw/snapshot') search.add_parent_filter(sobject) search.add_filter("process", process) snapshots = search.get_sobjects() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 50%") td.add_style("padding: 0 0 0 0") snapshots_div = DivWdg() td.add(snapshots_div) snapshots_div.set_box_shadow() snapshots_div.add_style("margin: 10px") title = DivWdg() title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Snapshots:") snapshots_div.add(title) snapshot_wdg = TableLayoutWdg(search_type="sthpw/snapshot", view='table', mode='simple', show_row_select=False, width='100%', show_shelf="false") snapshot_wdg.set_sobjects(snapshots) snapshots_div.add(snapshot_wdg) return top
def get_pipeline_wdg(my, pipeline_code): div = DivWdg() title = DivWdg() title.add_gradient("background", "background3", 0) title.add_style("height: 20px") title.add_style("font-weight: bold") title.add_style("padding: 4px") title.add_border() title.add("Pipeline") div.add(title) kwargs = { 'width': 800, 'height': 300, 'pipeline': pipeline_code, 'scale': 0.7, } pipeline = TaskDetailPipelineWdg(**kwargs) div.add(pipeline) load_div = DivWdg() div.add(load_div) # This is only for tasks!!!! enabled_tasks = set() from pyasm.biz import Task process = '' if my.parent: tasks = Task.get_by_sobject(my.parent) if my.sobject.has_value("process"): process = my.sobject.get_value("process") else: tasks = Task.get_by_sobject(my.sobject) for task in tasks: enabled_tasks.add(task.get_value("process")) enabled_tasks = list(enabled_tasks) load_div.add_behavior({ 'type': 'load', 'process': process, 'enabled_tasks': enabled_tasks, 'pipeline': pipeline_code, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_pipeline_wrapper"); spt.pipeline.init_cbk(top); var nodes = spt.pipeline.get_nodes_by_group(bvr.pipeline); for (var i = 0; i < nodes.length; i++) { var has_task = false; var node = nodes[i]; var node_name = spt.pipeline.get_node_name(node); for (var j = 0; j < bvr.enabled_tasks.length; j++) { if (node_name == bvr.enabled_tasks[j]) { has_task = true; break; } } if (!has_task && node) { spt.pipeline.disable_node(node); } } spt.pipeline.unselect_all_nodes(); var node = spt.pipeline.get_node_by_name(bvr.process); //process and node name could be different if (node) { node.setStyle("font-weight", "bold"); spt.pipeline.select_node(node); //spt.pipeline.center_node(node); } spt.pipeline.fit_to_canvas(bvr.pipeline); ''' }) #div.add_style("padding: 10px") div.add_border() return div
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_behavior( { 'type': 'load', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|hide_now", {} ); ''' } ) project = Project.get() title = DivWdg() title.add("Project Startup and Configuration") 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 10px -10px") top.add(title) title.add_gradient("background", "background3", 5, -10) shelf = DivWdg() top.add(shelf) shelf.add_style("margin-left: -8px") shelf.add_style("width: 130px") button_div = DivWdg() shelf.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-top: -3px") security = Environment.get_security() view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow') if view_side_bar: button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT) button_div.add(button) shelf.add("Toggle Side Bar") shelf.add_attr("title", "Toggle Side Bar (or press '1')") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' } ) shelf.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' } ) shelf.add_class("hand") else: shelf.add(" ") search_wdg = Table() top.add(search_wdg) search_wdg.add_row() search_wdg.add_class("spt_main_top") search_wdg.add_style("padding: 10px") search_wdg.add_style("margin: 20px auto") search_wdg.add_style("width: 430px") td = search_wdg.add_cell("Search: ") td.add_style("vertical-align: top") td.add_style("padding-top: 8px") custom_cbk = {} custom_cbk['enter'] = ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords != '') { var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); } ''' from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg #text = TextInputWdg(name="search") text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, width='280', height='42px') #text = TextWdg("search") text.add_class("spt_main_search") text.add_style("width: 290px") search_wdg.add_cell(text) search_wdg.add_style("font-weight: bold") search_wdg.add_style("font-size: 16px") icon_div = DivWdg() td = search_wdg.add_cell(icon_div) td.add_style("vertical-align: top") icon_div.add_style("width: 38px") icon_div.add_style("height: 27px") icon_div.add_style("padding-top: 7px") icon_div.add_style("padding-left: 4px") icon_div.add_style("text-align: center") #icon_div.add_gradient("background", "background3", 15, -10) icon_div.add_color("background", "background3", 10) over_color = icon_div.get_color("background3", 0) out_color = icon_div.get_color("background3", 10) icon_div.set_round_corners(5) icon_div.set_box_shadow("1px 1px 1px 1px") icon = IconWdg("Search", IconWdg.SEARCH_32, width=24) icon_div.add(icon) button = icon_div icon_div.add_class("hand") icon_div.add_behavior( { 'type': 'mouseover', 'color': over_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' } ) icon_div.add_behavior( { 'type': 'mouseout', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' } ) icon_div.add_behavior( { 'type': 'click', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-3"); bvr.src_el.setStyle("margin-right", "-2"); ''' } ) icon_div.add_behavior( { 'type': 'click_up', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' } ) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords == '') { return; } var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); ''' } ) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") # create a bunch of panels table = Table() table.add_color("color", "color") table.add_style("margin-bottom: 20px") table.center() top.add(table) table.add_row() #security = Environment.get_security() #if not security.check_access("builtin", "view_site_admin", "allow"): td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Configuration" #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.''' description = '''Configure a Project from start to finish.''' image = "<img src='/context/icons/64x64/configuration_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.ProjectConfigWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs); ''' } config_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) # Manage Users td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Users and Security" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" image = DivWdg() image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>" image.add(image_link) image1 = IconWdg("Manage Users", IconWdg.USER_32) image2 = IconWdg("Manage Users", IconWdg.USER_32) image3 = IconWdg("Manage Users", IconWdg.USER_32) image4 = IconWdg("Manage Users", IconWdg.USER_32) image.add(image1) image.add(image2) image.add("<br/>") image.add(image3) image.add(image4) description = '''Manage users that can access the system''' behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.UserConfigWdg'; var kwargs = { help_alias: 'project-startup-manage-users' }; spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs); ''' } manage_users_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(manage_users_wdg) # custom layout editor td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Custom Layouts" description = '''Create interfaces using the Custom Layout Editor.''' image = "<img src='/context/icons/64x64/layout_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.tools.CustomLayoutEditWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs); ''' } config_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) tr = table.add_row() # Plugins td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Plugin" image = IconWdg("Manage Plugin", IconWdg.PLUGIN_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Upload, install, remove and create TACTIC plugins.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.PluginWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs); ''' } plugin_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(plugin_wdg) # Examples td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Tools" image = IconWdg("Tools", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A collection of example views.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ToolsWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("tools", "Tools", class_name, kwargs); ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) # Share """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Shares" image = IconWdg("Shares", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Share project with other TACTIC installs.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ShareWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("shares", "Shares", class_name, kwargs); ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ # Advanced td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Advanced Setup" image = IconWdg("Advanced", IconWdg.ADVANCED_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A set of advanced configuration tools.''' 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) ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Documentation" description = '''TACTIC Documentation. * Project Setup Documentation<br/> <br/> * End User Documentation<br/> <br/> * Developer Documentation<br/> <br/> * System Administrator Documentation<br/> <br/> ''' image = "<img src='/context/images/getting_started_pipeline.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.help.load_alias("main") ''' } doc_wdg = my.get_section_wdg(title, description, image, behavior) td.add(doc_wdg) """ tr, td = table.add_row_cell() td.add_style("font-size: 14px") td.add("<br/>") from misc_wdg import QuickLinksWdg quick_links_wdg = QuickLinksWdg() td.add(quick_links_wdg) #td = table.add_cell() #totals_wdg = my.get_totals_wdg() #td.add(totals_wdg) return top
def get_sobject_detail_wdg(my): div = DivWdg() #div.add_style("float: right") div.add_style("width: 100%") div.add_style("height: 100%") div.add_style("padding-top: 5px") info_div = DivWdg() div.add(info_div) #info_div.add_style("display: none") info_div.add_class("spt_sobject_detail") #info_div.add_style("width: 300px") info_div.add_style("padding: 30px 0px 30px 0px") info_table = Table() info_table.add_color("color", "color") info_div.add(info_table) edit_div = DivWdg() info_div.add(edit_div) edit_div.add_style("margin-top: -35px") edit_div.add_style("margin-left: 1px") edit_div.add_style("margin-right: -2px") #edit_div.add_style("overflow: scroll") edit_div.add_style("height: 100%") view = my.kwargs.get("detail_view") if not view: view = "edit" ignore = ["preview", "notes"] element_names = ['name', 'description', 'tasks'] config = WidgetConfigView.get_by_search_type( search_type=my.full_search_type, view=view) config_element_names = config.get_element_names() for x in config_element_names: if x in ignore: continue if x not in element_names: element_names.append(x) # add the tile title = DivWdg() edit_div.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(" ") title.add_border() from tactic.ui.panel.edit_layout_wdg import EditLayoutWdg edit = EditLayoutWdg(search_type=my.full_search_type, mode='view', view="detail", search_key=my.search_key, width=400, title=' ', ignore=ignore, element_names=element_names) edit_div.add(edit) # TEST extra data from a related sobject """ related_search_type = "jobs/photo" element_names = ['photographer'] related = Search.eval("@SOBJECT(%s)" % related_search_type, my.sobject, single=True) if related: related_key = related.get_search_key() from tactic.ui.panel.edit_layout_wdg import EditLayoutWdg edit = EditLayoutWdg(search_type=search_type, mode='view', view="detail", search_key=related_key, width=400, title=' ', element_names=element_names) edit_div.add(edit) """ return div
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_behavior({ 'type': 'load', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|hide", {} ); ''' }) project = Project.get() title = TitleWdg(title='Client Home') top.add(title) shelf = DivWdg() top.add(shelf) shelf.add_style("margin-left: -8px") shelf.add_style("width: 130px") security = Environment.get_security() view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow') if view_side_bar: button_div = DivWdg() shelf.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-top: -3px") button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT) button_div.add(button) shelf.add("Toggle Side Bar") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' }) shelf.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' }) shelf.add_class("hand") else: shelf.add(" ") search_wdg = DivWdg() search_wdg.add_class("spt_main_top") top.add(search_wdg) search_wdg.add_style("padding: 10px") search_wdg.add_style("margin: 10px auto") search_wdg.add_style("width: 430px") search_wdg.add("Search: ") search_wdg.add(" " * 3) custom_cbk = {} custom_cbk['enter'] = ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords != '') { var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'table', 'keywords': keywords, 'simple_search_view': 'simple_search', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); } ''' from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg #text = TextInputWdg(name="search") text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk) #text = TextWdg("search") text.add_class("spt_main_search") text.add_style("width: 290px") search_wdg.add(text) search_wdg.add_style("font-weight: bold") search_wdg.add_style("font-size: 16px") button = ActionButtonWdg(title="Search") #search_wdg.add(button) button.add_style("float: right") #button.add_style("margin-top: -28px") icon_div = DivWdg() search_wdg.add(icon_div) icon_div.add_style("width: 38px") icon_div.add_style("height: 27px") icon_div.add_style("padding-top: 3px") icon_div.add_style("padding-left: 4px") icon_div.add_style("text-align: center") #icon_div.add_gradient("background", "background3", 15, -10) icon_div.add_color("background", "background3", 10) over_color = icon_div.get_color("background3", 0) out_color = icon_div.get_color("background3", 10) icon_div.set_round_corners(5) icon_div.set_box_shadow("1px 1px 1px 1px") icon = IconWdg("Search", IconWdg.SEARCH_32, width=24) icon_div.add(icon) icon_div.add_style("float: right") icon_div.add_style("margin-top: -5px") button = icon_div icon_div.add_class("hand") icon_div.add_behavior({ 'type': 'mouseover', 'color': over_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' }) icon_div.add_behavior({ 'type': 'mouseout', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' }) icon_div.add_behavior({ 'type': 'click', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-3"); bvr.src_el.setStyle("margin-right", "-2"); ''' }) icon_div.add_behavior({ 'type': 'click_up', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' }) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords == '') { return; } var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'table', 'keywords': keywords, 'simple_search_view': 'simple_search', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); ''' }) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") # create a bunch of panels table = Table() table.add_color("color", "color") table.add_style("margin-bottom: 20px") table.center() top.add(table) table.add_row() td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "My Approvals" description = '''View all pending items for approval<br/><br/> ''' #image = "<img src='/context/images/getting_started_pipeline.png'/>" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: 'sthpw/sobject_list', view: 'client_approval', show_shelf: false, show_select: false, element_names: ['preview', 'name', 'description', 'task_pipeline_vertical','notes'], is_editable: false, //expression: "@SOBJECT(sthpw/task['project_code','fickle3'].fickle3/cars.sthpw/sobject_list)" }; spt.tab.add_new("approvals", "Approvals", class_name, kwargs); ''' } config_wdg = my.get_section_wdg(title, description, image, behavior) td.add(config_wdg) td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "My Dashboard" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.''' # read the config file from pyasm.widget import WidgetConfig tmp_path = __file__ dir_name = os.path.dirname(tmp_path) file_path = "%s/../config/dashboard-conf.xml" % (dir_name) config = WidgetConfig.get(file_path=file_path, view="definition") #element_name = "my_dashboard" element_name = "my_dashboard" attrs = config.get_element_attributes(element_name) dashboard_data = {} kwargs = config.get_display_options(element_name) class_name = kwargs.get('class_name') dashboard_data['class_name'] = class_name dashboard_data['kwargs'] = kwargs dashboard_data['title'] = attrs.get("title") dashboard_data['description'] = attrs.get("description") dashboard_data['image'] = attrs.get("image") behavior = { 'type': 'click_up', 'dashboard': dashboard_data, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg'; var kwargs = {}; spt.tab.set_main_body_tab(); spt.tab.add_new("my_dashboard", "My Dashboard", bvr.dashboard.class_name, bvr.dashboard.kwargs); ''' } pipeline_wdg = my.get_section_wdg(title, description, image, behavior) td.add(pipeline_wdg) td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "My Reports" image = "<img src='/context/icons/64x64/report_64.png'/>" description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg'; var kwargs = {}; spt.tab.set_main_body_tab(); spt.tab.add_new("reports", "Reports", class_name, kwargs); //spt.panel.load_popup("Reports", class_name, kwargs); ''' } side_bar_wdg = my.get_section_wdg(title, description, image, behavior) td.add(side_bar_wdg) """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Documentation" description = '''TACTIC Documentation. <br/><br/> * Project Setup Documentation<br/> <br/> * End User Documentation<br/> <br/> * Developer Documentation<br/> <br/> * System Administrator Documentation<br/> <br/> ''' image = "<img src='/context/images/getting_started_pipeline.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.help.load_alias("main") ''' } doc_wdg = my.get_section_wdg(title, description, image, behavior) td.add(doc_wdg) """ tr, td = table.add_row_cell() td.add_style("font-size: 14px") td.add("<br/>" * 2) quick_links_wdg = QuickLinksWdg() td.add(quick_links_wdg) return top
def get_display(my): top = my.top top.add_color("background", "background") top.add_color("color", "color") top.add_style("width", "400px") top.add_border() top.add_class("spt_delete_project_tool_top") project_code = my.kwargs.get("project_code") if project_code: project = Project.get_by_code(project_code) else: search_key = my.kwargs.get("search_key") project = Search.get_by_search_key(search_key) if project: project_code = project.get_code() title_wdg = DivWdg() if project: top.add(title_wdg) title_wdg.add(IconWdg(icon=IconWdg.WARNING)) title_wdg.add("Deleting Project: %s" % project.get_value("title") ) title_wdg.add_gradient("background", "background", -10, -10) title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") content = DivWdg() top.add(content) content.add_style("padding: 10px") if not search_key: warning_msg = "Projects must be deleted individually" content.add(DivWdg(warning_msg, css='warning')) content.add("<br/>") return top warning_msg = "Deleting a project will delete the database associated with this project. All data will be lost. Please consider carefully before proceeding." if warning_msg: content.add(DivWdg(warning_msg, css='warning')) content.add("<br/>") if not project_code: content.add("This project [%s] has been deleted."%search_key) return top elif not project: content.add("This project [%s] has been deleted."%project_code) return top assert project_code assert project content.add("<br/>") content.add("<b>WARNING: These items will be deleted, but the sTypes entries in search_objects table will be retained.</b> ") content.add("<br/>") content.add("<br/>") total_items_wdg = DivWdg() total_items = 0 content.add(total_items_wdg) # find all of the sTypes details_wdg = DivWdg() content.add(details_wdg) details_wdg.add_style("max-height: 300px") details_wdg.add_style("overflow-y: auto") details_wdg.add_style("padding-left: 15px") details_wdg.add_border() search_types = project.get_search_types() related_types = [] for search_type_obj in search_types: search_type_wdg = DivWdg() title = search_type_obj.get_title() search_type = search_type_obj.get_value("search_type") search_type_wdg.add_style("margin-top: 5px") search_type_wdg.add_style("margin-bottom: 5px") details_wdg.add(search_type_wdg) search_type_wdg.add(title) search_type_wdg.add(" (%s)" % search_type ) search = Search( search_type, project_code=project_code ) count = search.get_count() total_items += count search_type_wdg.add(" - %s item(s)" % count) related_types = my.get_related_types(search_type) for related_type in related_types: search = Search(related_type) full_search_type = "%s?project=%s" % (search_type, project_code) if related_type.startswith("sthpw/"): search.add_filter("search_type", full_search_type) count = search.get_count() if count == 0: continue total_items += count related_wdg = DivWdg() related_wdg.add_style('padding-left: 25px') search_type_wdg.add(related_wdg) related_wdg.add(related_type) related_wdg.add(" - %s item(s)" % count) if total_items: total_items_wdg.add("Total # of items to be deleted: ") total_items_wdg.add(total_items) total_items_wdg.add_style("font-size: 14px") total_items_wdg.add_style("font-weight: bold") total_items_wdg.add("<br/>") content.add("<br/>"*2) content.add("<b>Do you wish to continue deleting? </b>") radio = RadioWdg("mode") radio.add_class("spt_mode_radio") radio.set_value("delete") content.add(radio) content.add("<br/>"*2) #content.add("<b>Or do you just wish to retire the project? </b>") #radio = RadioWdg("mode") #radio.add_class("spt_mode_radio") #radio.set_value("retire") #content.add(radio) #content.add(radio) #content.add("<br/>"*2) #button = ActionButtonWdg(title="Retire") #content.add(button) #button.add_style("float: left") buttons = Table() content.add(buttons) buttons.add_row() buttons.add_style("margin-left: auto") buttons.add_style("margin-right: auto") buttons.add_style("width: 250px") button = ActionButtonWdg(title="Delete") buttons.add_cell(button) button.add_behavior( { 'type': 'click_up', #'search_type': search_type, 'project_code': project_code, 'related_types': related_types, 'cbjs_action': ''' spt.app_busy.show("Deleting"); var class_name = "tactic.ui.tools.DeleteProjectCmd"; var kwargs = { 'project_code': bvr.project_code, 'related_types': bvr.related_types }; var top = bvr.src_el.getParent(".spt_delete_project_tool_top"); var radios = top.getElements(".spt_mode_radio"); //if (!radios[0].checked && !radios[1].checked) { if (!radios[0].checked) { spt.alert("Please confirm the delete by checking the radio button."); spt.app_busy.hide(); return; } var mode = 'retire'; if (radios[0].checked == true) { mode = 'delete'; } if (mode == 'retire') { return; } var success = false; var server = TacticServerStub.get(); setTimeout(function() { spt.app_busy.show("Deleting Project ["+bvr.project_code+"]") var error_message = "Error deleting project ["+bvr.project_code+"]"; try { server.start({'title': 'Deleted Project ', 'description': 'Deleted Project [' + bvr.project_code + ']'}); server.execute_cmd(class_name, kwargs); success = true; var top = bvr.src_el.getParent(".spt_popup"); spt.popup.destroy(top); server.finish(); } catch(e) { error_message = spt.exception.handler(e); } spt.app_busy.hide(); if (success) { spt.notify.show_message("Successfully deleted project ["+bvr.project_code+"]"); spt.tab.set_main_body_tab(); spt.tab.reload_selected(); } else { if (error_message.test(/does not exist/)) error_message += '. You are advised to sign out and log in again.'; spt.error(error_message); } }, 100); ''' } ) button = ActionButtonWdg(title="Cancel") buttons.add_cell(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_popup"); spt.popup.destroy(top); ''' } ) return top
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_behavior( { # 'type': 'load', # 'cbjs_action': ''' # spt.named_events.fire_event("side_bar|hide_now", {} ); # ''' #} ) project = Project.get() title = TitleWdg(title='Tools') top.add(title) shelf = DivWdg() top.add(shelf) shelf.add_style("margin-left: -8px") shelf.add_style("width: 130px") button_div = DivWdg() shelf.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-top: -3px") search_wdg = DivWdg() search_wdg.add_class("spt_main_top") top.add(search_wdg) search_wdg.add_style("padding: 10px") search_wdg.add_style("margin: 10px auto") search_wdg.add_style("width: 430px") search_wdg.add( "<div style='float: left; margin: 8px 10px;'>Search: </div>") custom_cbk = {} custom_cbk['enter'] = ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords != '') { var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'table', 'keywords': keywords, 'simple_search_view': 'simple_search', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); } ''' from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg #text = TextInputWdg(name="search") text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, height="42px") #text = TextWdg("search") text.add_class("spt_main_search") text.add_style("width: 290px") search_wdg.add(text) search_wdg.add_style("font-weight: bold") search_wdg.add_style("font-size: 16px") text.add_style("float: left") #search_wdg.add(button) #button.add_style("margin-top: -28px") icon_div = DivWdg() search_wdg.add(icon_div) icon_div.add_style("width: 38px") icon_div.add_style("height: 27px") icon_div.add_style("padding-top: 3px") icon_div.add_style("padding-left: 4px") icon_div.add_style("text-align: center") #icon_div.add_gradient("background", "background3", 15, -10) icon_div.add_color("background", "background3", 10) over_color = icon_div.get_color("background3", 0) out_color = icon_div.get_color("background3", 10) icon_div.set_round_corners(5) icon_div.set_box_shadow("1px 1px 1px 1px") icon = IconWdg("Search", IconWdg.SEARCH_32, width=24) icon_div.add(icon) icon_div.add_style("float: right") icon_div.add_style("margin-top: 4px") button = icon_div icon_div.add_class("hand") icon_div.add_behavior({ 'type': 'mouseover', 'color': over_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' }) icon_div.add_behavior({ 'type': 'mouseout', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' }) icon_div.add_behavior({ 'type': 'click', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-3"); bvr.src_el.setStyle("margin-right", "-2"); ''' }) icon_div.add_behavior({ 'type': 'click_up', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' }) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords == '') { return; } var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'table', 'keywords': keywords, 'simple_search_view': 'simple_search', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); ''' }) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") # create a bunch of panels table = Table() table.add_color("color", "color") table.add_style("margin-bottom: 20px") table.center() top.add(table) table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Themes" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Themes define the look and feel of a project.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.themes_wdg.ThemesWdg'; var kwargs = { help_alias: 'project-startup-dashboards' }; spt.tab.set_main_body_tab(); spt.tab.add_new("themes", "Themes", class_name, kwargs); ''' } dashboard_wdg = my.get_section_wdg(title, description, image, behavior) td.add(dashboard_wdg) td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Dashboards" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.''' # read the config file #from pyasm.widget import WidgetConfig #tmp_path = __file__ #dir_name = os.path.dirname(tmp_path) #file_path="%s/../config/dashboard-conf.xml" % (dir_name) #config = WidgetConfig.get(file_path=file_path, view="definition") # FIXME: this bypasses the link security #element_name = "dashboards" #attrs = config.get_element_attributes(element_name) #dashboard_data = {} #kwargs = config.get_display_options(element_name) #class_name = kwargs.get('class_name') behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg'; var kwargs = { help_alias: 'project-startup-dashboards' }; spt.tab.set_main_body_tab(); spt.tab.add_new("dashboards", "Dashboards", class_name, kwargs); ''' } dashboard_wdg = my.get_section_wdg(title, description, image, behavior) td.add(dashboard_wdg) td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Reports" image = "<img src='/context/icons/64x64/report_64.png'/>" description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg'; var kwargs = {}; spt.tab.set_main_body_tab(); spt.tab.add_new("reports", "Reports", class_name, kwargs); //spt.panel.load_popup("Reports", class_name, kwargs); ''' } side_bar_wdg = my.get_section_wdg(title, description, image, behavior) td.add(side_bar_wdg) td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Lists of Items" description = '''View all of the lists items for this project<br/><br/> ''' image = "<img src='/context/icons/48x48/search_type_48.png'/>" #image = "<img src='/context/images/getting_started_pipeline.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.HomeWdg'; var kwargs = {}; spt.tab.add_new("lists", "Lists", class_name, kwargs); ''' } config_wdg = my.get_section_wdg(title, description, image, behavior) td.add(config_wdg) tr, td = table.add_row_cell() td.add_style("font-size: 14px") td.add("<br/>" * 2) quick_links_wdg = QuickLinksWdg() td.add(quick_links_wdg) return top
def get_display(my): top = my.top top.add_color("background", "background") top.add_color("color", "color") top.add_style("width", "400px") top.add_class('spt_delete_stype_top') top.add_border() project_code = Project.get_project_code() # Note search types should only really be deleted if they were just # created search_type = my.kwargs.get("search_type") if not search_type: node_name = my.kwargs.get("node_name") if node_name: #project_code = Project.get_project_code() search_type = "%s/%s" % (project_code, node_name) assert search_type built_in_stypes = [ 'task', 'note', 'work_hour', 'login', 'login_group', 'schema', 'project', 'login_in_group', 'snapshot', 'file', 'trigger', 'spt_trigger', 'widget_config', 'custom_script', 'notification', 'notification_log', 'file_access', 'cache', 'exception_log', 'milestone', 'pipeline', 'pref_list', 'pref_setting', 'project_type', 'repo', 'remote_repo', 'search_sobject', 'sobject_list', 'ticket', 'db_resource', 'wdg_settings', 'status_log', 'debug_log', 'transaction_log', 'sobject_log' ] for tbl in built_in_stypes: if search_type == 'sthpw/%s' % tbl: top.add("sType [%s] is internal and cannot be deleted!" % search_type) top.add_style("font-size: 14px") top.add_style('padding: 20px') return top search_type_obj = SearchType.get(search_type) if not search_type: top.add("sType [%s] does not exist!" % search_type) top.add_style("font-size: 14px") top.add_style('padding: 20px') return top table = search_type_obj.get_table() db_val = search_type_obj.get_value('database') if db_val == '{project}': label = '' elif db_val == 'sthpw': label = 'built-in' else: label = 'project-specific' # warn if more than 1 sType point to the same table in the same project expr = "@GET(sthpw/search_type['table_name', '%s']['database', 'in', '{project}|%s']['namespace','%s'].search_type)" % ( table, project_code, project_code) rtn = Search.eval(expr) warning_msg = '' if len(rtn) > 1: warning_msg = 'Warning: There is more than 1 sType [%s] pointing to the same table [%s]. Deleting will affect both sTypes.' % ( ', '.join(rtn), table) title_wdg = DivWdg() top.add(title_wdg) title_wdg.add(IconWdg(icon=IconWdg.WARNING)) title_wdg.add("Delete %s sType: %s" % (label, search_type)) title_wdg.add_gradient("background", "background", -10, -10) title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") content = DivWdg() top.add(content) content.add_style("padding: 10px") if warning_msg: content.add(DivWdg(warning_msg, css='warning')) content.add("<br/>") content.add("This sType uses the table \"%s\" to store items.<br/>" % table) content.add("<br/>") search = Search(search_type) count = search.get_count() content.add("Number of items in the table: %s<br/>" % count) content.add("<br/>") search.add_column("id") sobjects = search.get_sobjects() if sobjects: items_search_type = sobjects[0].get_search_type() search_ids = [x.get_id() for x in sobjects] notes_search = Search("sthpw/note") notes_search.add_filters("search_id", search_ids) notes_search.add_filter("search_type", items_search_type) note_count = notes_search.get_count() cb = CheckboxWdg('related_types') cb.set_attr('value', 'sthpw/note') content.add(cb) content.add( SpanWdg("Number of related notes: %s" % note_count, css='small')) content.add(HtmlElement.br()) tasks_search = Search("sthpw/task") tasks_search.add_filters("search_id", search_ids) tasks_search.add_filter("search_type", items_search_type) task_count = tasks_search.get_count() cb = CheckboxWdg('related_types') cb.set_attr('value', 'sthpw/task') content.add(cb) content.add( SpanWdg("Number of related tasks: %s" % task_count, css='small')) content.add(HtmlElement.br()) snapshots_search = Search("sthpw/snapshot") snapshots_search.add_filters("search_id", search_ids) snapshots_search.add_filter("search_type", items_search_type) snapshot_count = snapshots_search.get_count() cb = CheckboxWdg('related_types') cb.set_attr('value', 'sthpw/snapshot') content.add(cb) content.add( SpanWdg("Number of related snapshots: %s" % snapshot_count, css='small')) content.add(HtmlElement.br()) pipelines_search = Search("sthpw/pipeline") pipelines_search.add_filter("search_type", search_type) pipeline_count = pipelines_search.get_count() cb = CheckboxWdg('related_types') cb.set_attr('value', 'sthpw/pipeline') content.add(cb) content.add( SpanWdg("Number of related pipelines: %s" % pipeline_count, css='small')) content.add(HtmlElement.br(2)) content.add( "<b>WARNING: Deleting the sType will delete all of these items.</b> " ) content.add("<br/>" * 2) content.add("Do you wish to continue deleting?") content.add("<br/>" * 2) button_div = DivWdg() button_div.add_styles('width: 300px; height: 50px') button = ActionButtonWdg(title="Delete") button_div.add(button) content.add(button_div) button.add_style("float: left") button.add_behavior({ 'type': 'click_up', 'search_type': search_type, 'cbjs_action': ''' spt.app_busy.show("Deleting sType"); var class_name = "tactic.ui.tools.DeleteSearchTypeCmd"; var ui_top = bvr.src_el.getParent(".spt_delete_stype_top"); var values = spt.api.Utility.get_input_values(ui_top); var kwargs = { 'search_type': bvr.search_type, 'values': values }; var server = TacticServerStub.get(); try { server.start({'title': 'Delete sType', 'description': 'Delete sType [' + bvr.search_type + ']'}); server.execute_cmd(class_name, kwargs); var top = bvr.src_el.getParent(".spt_popup"); spt.pipeline.remove_node(top.stype_node); // force a schema save spt.named_events.fire_event('schema|save', bvr) top.destroy(); server.finish(); } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); spt.notify.show_message("Successfully deleted sType ["+bvr.search_type+"]"); ''' }) button = ActionButtonWdg(title="Cancel") button.add_style("float: left") button_div.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_popup"); top.destroy(); ''' }) return top
def get_error_wdg(my): div = DivWdg() error_div = DivWdg() error_div.add("Error %s - Permission Denied" % my.status) div.add(error_div) error_div.add_style("font-size: 16px") error_div.add_style("font-weight: bold") error_div.add_style("width: 97%") error_div.add_gradient("background", "background") error_div.add_border() error_div.add_style("margin-left: 5px") error_div.add_style("margin-top: -10px") div.add("<br/>") span = DivWdg() #span.add_color("color", "color") span.add_style("color", "#FFF") if my.status == 403: span.add("<b>You have tried to access a url that is not permitted.</b>") else: span.add(HtmlElement.b(my.message)) span.add(HtmlElement.br(2)) web = WebContainer.get_web() root = web.get_site_root() span.add("Go back to the Main page for a list of valid projects") div.add(span) div.add(HtmlElement.br()) table = Table() div.add(table) table.add_row() table.add_style("margin-left: auto") table.add_style("margin-right: auto") from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Go to Main", tip='Click to go to main page') table.add_cell(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' document.location = '/projects'; ''' } ) button.add_style("margin-left: auto") button.add_style("margin-right: auto") button = ActionButtonWdg(title="Sign Out", tip='Click to Sign Out') table.add_cell(button) button.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='%s'; ''' % root } ) button.add_style("margin-left: auto") button.add_style("margin-right: auto") return div
def get_display(my): relative_dir = my.kwargs.get("relative_dir") my.relative_dir = relative_dir div = DivWdg() div.add_class("spt_ingest_top") div.add_style("width: 100%px") div.add_style("min-width: 500px") div.add_style("padding: 20px") div.add_color("background", "background") title_div = DivWdg() div.add(title_div) title_div.add("Ingest Files") title_div.add_style("font-size: 14px") title_div.add_style("font-weight: bold") title_div.add_style("padding: 10px") title_div.add_color("background", "background3") title_div.add_border() my.search_type = my.kwargs.get("search_type") if not my.search_type: div.add("No search type specfied") return div if relative_dir: folder_div = DivWdg() div.add(folder_div) folder_div.add("Folder: %s" % relative_dir) folder_div.add_style("opacity: 0.5") folder_div.add_style("font-style: italic") folder_div.add_style("margin-bottom: 10px") title_div.add_style("margin: -20px -21px 5px -21px") else: title_div.add_style("margin: -20px -21px 15px -21px") div.add("Add files or drag/drop files to be uploaded and ingested:") div.add("<br/>"*2) data_div = my.get_data_wdg() data_div.add_style("float: left") data_div.add_style("float: left") div.add(data_div) # create the help button help_button_wdg = DivWdg() div.add(help_button_wdg) help_button_wdg.add_style("margin-top: -3px") help_button_wdg.add_style("float: right") help_button = ActionButtonWdg(title="?", tip="Ingestion Widget Help", size='s') help_button_wdg.add(help_button) help_button.add_behavior( { 'type': 'click_up', 'cbjs_action': '''spt.help.load_alias("ingestion_widget")''' } ) from tactic.ui.input import Html5UploadWdg upload = Html5UploadWdg(multiple=True) div.add(upload) button = ActionButtonWdg(title="Add") button.add_style("float: right") button.add_style("margin-top: -3px") div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var files_el = top.getElement(".spt_upload_files"); var onchange = function (evt) { var files = spt.html5upload.get_files(); for (var i = 0; i < files.length; i++) { spt.drag.show_file(files[i], files_el, 0, true); } } spt.html5upload.set_form( top ); spt.html5upload.select_file( onchange ); ''' } ) button = ActionButtonWdg(title="Clear") button.add_style("float: right") button.add_style("margin-top: -3px") div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var file_els = top.getElements(".spt_upload_file"); for ( var i = 0; i < file_els.length; i++) { spt.behavior.destroy( file_els[i] ); }; ''' } ) div.add("<br clear='all'/>") files_div = DivWdg() files_div.add_style("position: relative") files_div.add_class("spt_upload_files") div.add(files_div) files_div.add_style("max-height: 300px") files_div.add_style("height: 300px") files_div.add_style("overflow-y: auto") files_div.add_border() files_div.add_style("padding: 3px") files_div.add_color("background", "background3") #files_div.add_style("display: none") bgcolor = div.get_color("background3") bgcolor2 = div.get_color("background3", -3) files_div.add_behavior( { 'type': 'mouseenter', 'bgcolor': bgcolor2, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.bgcolor) ''' } ) files_div.add_behavior( { 'type': 'mouseout', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.bgcolor) ''' } ) background = DivWdg() background.add_class("spt_files_background") files_div.add(background) background.add_style("font-size: 4.0em") background.add_style("font-weight: bold") background.add_style("opacity: 0.1") background.add_style("position: absolute") background.add_style("left: 50%") background.add_style("top: 100px") background.add_border() inner_background = DivWdg("Drag Files Here") background.add(inner_background) inner_background.set_style("position: absolute") inner_background.set_style("margin-left: -50%") # Test drag and drop files files_div.add_attr("ondragenter", "return false") files_div.add_attr("ondragover", "return false") files_div.add_attr("ondrop", "spt.drag.noop(event, this)") files_div.add_behavior( { 'type': 'load', 'cbjs_action': ''' spt.drag = {} var background; spt.drag.show_file = function(file, top, delay, icon) { if (!background) { background = top.getElement(".spt_files_background"); background.setStyle("display", "none"); } var template = top.getElement(".spt_upload_file_template"); var clone = spt.behavior.clone(template); clone.removeClass("spt_upload_file_template"); clone.addClass("spt_upload_file"); clone.setStyle("display", ""); if (typeof(delay) == 'undefined') { delay = 0; } // remember the file handle clone.file = file; var name = file.name; var size = parseInt(file.size / 1024 * 10) / 10; var thumb_el = clone.getElement(".spt_thumb"); var date_label_el = clone.getElement(".spt_date_label"); var date_el = clone.getElement(".spt_date"); //var loadingImage = loadImage( setTimeout( function() { if (icon) { var loadingImage = loadImage( file, function (img) { thumb_el.appendChild(img); }, {maxWidth: 80, maxHeight: 60, canvas: true, contain: true} ); } else { var img = $(document.createElement("div")); img.setStyle("width", "60"); img.setStyle("height", "40"); //img.innerHTML = "MP4"; img.setStyle("border", "solid 1px black") thumb_el.appendChild(img); } loadImage.parseMetaData( file, function(data) { if (data.exif) { var date = data.exif.get('DateTimeOriginal'); if (date) { date_label_el.innerHTML = date; if (date_el) { date_el.value = date; } } } } ); }, delay ); /* var reader = new FileReader(); reader.thumb_el = thumb_el; reader.onload = function(e) { this.thumb_el.innerHTML = [ '<img class="thumb" src="', e.target.result, '" title="', escape(name), '" width="60px"', '" padding="5px"', '"/>' ].join(''); } reader.readAsDataURL(file); */ clone.getElement(".spt_name").innerHTML = file.name; clone.getElement(".spt_size").innerHTML = size + " KB"; clone.inject(top); } spt.drag.noop = function(evt, el) { var top = $(el).getParent(".spt_ingest_top"); var files_el = top.getElement(".spt_upload_files"); evt.stopPropagation(); evt.preventDefault(); evt.dataTransfer.dropEffect = 'copy'; var files = evt.dataTransfer.files; var delay = 0; var skip = false; for (var i = 0; i < files.length; i++) { var size = files[i].size; if (size >= 10*1024*1024) { spt.drag.show_file(files[i], files_el, 0, false); } else { spt.drag.show_file(files[i], files_el, delay, true); if (size < 100*1024) delay += 50; else if (size < 1024*1024) delay += 500; else if (size < 10*1024*1024) delay += 1000; } } } ''' } ) # create a template that will be filled in for each file files_div.add_relay_behavior( { 'type': 'mouseenter', 'color': files_div.get_color("background3", -5), 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' } ) files_div.add_relay_behavior( { 'type': 'mouseleave', 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' bvr.src_el.setStyle("background", ""); ''' } ) files_div.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': 'spt_remove', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_upload_file"); spt.behavior.destroy_element(top); ''' } ) """ metadata_view = "test/wizard/metadata" files_div.add_relay_behavior( { 'type': 'mouseup', 'view': metadata_view, 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' var class_name = 'tactic.ui.panel.CustomLayoutWdg'; var kwargs = { view: bvr.view } spt.app_busy.show("Loading Metadata"); spt.panel.load_popup("Metadata", class_name, kwargs); spt.app_busy.hide(); ''' } ) """ # template for each file item file_template = DivWdg() file_template.add_class("spt_upload_file_template") files_div.add(file_template) file_template.add_style("margin-bottom: 3px") file_template.add_style("padding: 3px") file_template.add_style("height: 40px") file_template.add_style("display: none") thumb_div = DivWdg() file_template.add(thumb_div) thumb_div.add_style("float: left") thumb_div.add_style("width: 60"); thumb_div.add_style("height: 40"); thumb_div.add_style("overflow: hidden"); thumb_div.add_style("margin: 3 10 3 0"); thumb_div.add_class("spt_thumb") info_div = DivWdg() file_template.add(info_div) info_div.add_style("float: left") name_div = DivWdg() name_div.add_class("spt_name") info_div.add(name_div) name_div.add("image001.jpg") name_div.add_style("width: 150px") """ dialog = DialogWdg(display="false", show_title=False) info_div.add(dialog) dialog.set_as_activator(info_div, offset={'x':0,'y':10}) dialog_data_div = DivWdg() dialog_data_div.add_color("background", "background") dialog_data_div.add_style("padding", "10px") dialog.add(dialog_data_div) dialog_data_div.add("Category: ") text = TextInputWdg(name="category") dialog_data_div.add(text) text.add_class("spt_category") text.add_style("padding: 1px") """ date_div = DivWdg() date_div.add_class("spt_date_label") info_div.add(date_div) date_div.add("") date_div.add_style("opacity: 0.5") date_div.add_style("font-size: 0.8em") date_div.add_style("font-style: italic") date_div.add_style("margin-top: 3px") hidden_date_div = HiddenWdg("date") hidden_date_div.add_class("spt_date") info_div.add(date_div) size_div = DivWdg() size_div.add_class("spt_size") file_template.add(size_div) size_div.add("433Mb") size_div.add_style("float: left") size_div.add_style("width: 150px") size_div.add_style("text-align: right") remove_div = DivWdg() remove_div.add_class("spt_remove") file_template.add(remove_div) icon = IconButtonWdg(title="Remove", icon=IconWdg.DELETE) icon.add_style("float: right") remove_div.add(icon) #remove_div.add_style("text-align: right") div.add("<br/>") info = DivWdg() div.add(info) info.add_class("spt_upload_info") progress_div = DivWdg() progress_div.add_class("spt_upload_progress_top") div.add(progress_div) progress_div.add_style("width: 100%") progress_div.add_style("height: 15px") progress_div.add_style("margin-bottom: 10px") progress_div.add_border() #progress_div.add_style("display: none") progress = DivWdg() progress_div.add(progress) progress.add_class("spt_upload_progress") progress.add_style("width: 0px") progress.add_style("height: 100%") progress.add_gradient("background", "background3", -10) progress.add_style("text-align: right") progress.add_style("overflow: hidden") progress.add_style("padding-right: 3px") from tactic.ui.app import MessageWdg progress.add_behavior( { 'type': 'load', 'cbjs_action': MessageWdg.get_onload_js() } ) # NOTE: files variable is passed in automatically upload_init = ''' var server = TacticServerStub.get(); server.start( {description: "Upload and check-in of ["+files.length+"] files"} ); var info_el = top.getElement(".spt_upload_info"); info_el.innerHTML = "Uploading ..."; ''' upload_progress = ''' var top = bvr.src_el.getParent(".spt_ingest_top"); progress_el = top.getElement(".spt_upload_progress"); var percent = Math.round(evt.loaded * 100 / evt.total); progress_el.setStyle("width", percent + "%"); progress_el.innerHTML = String(percent) + "%"; ''' on_complete = ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var progress_el = top.getElement(".spt_upload_progress"); progress_el.innerHTML = "100%"; progress_el.setStyle("width", "100%"); var info_el = top.getElement(".spt_upload_info"); var search_type = bvr.kwargs.search_type; var relative_dir = bvr.kwargs.relative_dir; var filenames = []; for (var i = 0; i != files.length;i++) { var name = files[i].name; filenames.push(name); } var key = spt.message.generate_key(); var values = spt.api.get_input_values(top); //var category = values.category[0]; var keywords = values.keywords[0]; var extra_data = values.extra_data[0]; var parent_key = values.parent_key[0]; var convert_el = top.getElement(".spt_image_convert") var convert = spt.api.get_input_values(convert_el); var processes = values.process; if (processes) { process = processes[0]; if (!process) { process = null; } } else { process = null; } var kwargs = { search_type: search_type, relative_dir: relative_dir, filenames: filenames, key: key, parent_key: parent_key, //category: category, keywords: keywords, extra_data: extra_data, process: process, convert: convert, } on_complete = function() { spt.info("Ingest complete"); server.finish(); var file_els = top.getElements(".spt_upload_file"); for ( var i = 0; i < file_els.length; i++) { spt.behavior.destroy( file_els[i] ); }; var background = top.getElement(".spt_files_background"); background.setStyle("display", ""); spt.message.stop_interval(key); }; var class_name = bvr.action_handler; server.execute_cmd(class_name, kwargs, null, {on_complete:on_complete}); on_progress = function(message) { msg = JSON.parse(message.message); var percent = msg.progress; var description = msg.description; info_el.innerHTML = description; progress_el.setStyle("width", percent+"%"); progress_el.innerHTML = percent + "%"; } spt.message.set_interval(key, on_progress, 2000); ''' upload_div = DivWdg() div.add(upload_div) #button = UploadButtonWdg(**kwargs) button = ActionButtonWdg(title="Ingest") upload_div.add(button) button.add_style("float: right") upload_div.add_style("margin-bottom: 15px") upload_div.add("<br clear='all'/>") action_handler = my.kwargs.get("action_handler") if not action_handler: action_handler = 'tactic.ui.tools.IngestUploadCmd'; button.add_behavior( { 'type': 'click_up', 'action_handler': action_handler, 'kwargs': { 'search_type': my.search_type, 'relative_dir': relative_dir }, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var file_els = top.getElements(".spt_upload_file"); // get the server that will be used in the callbacks var server = TacticServerStub.get(); // retrieved the stored file handles var files = []; for (var i = 0; i < file_els.length; i++) { files.push( file_els[i].file ); } if (files.length == 0) { alert("No files selected"); return; } // defined the callbacks var upload_start = function(evt) { } var upload_progress = function(evt) { %s; } var upload_complete = function(evt) { %s; spt.app_busy.hide(); } var upload_file_kwargs = { files: files, upload_start: upload_start, upload_complete: upload_complete, upload_progress: upload_progress }; if (bvr.ticket) upload_file_kwargs['ticket'] = bvr.ticket; %s; spt.html5upload.set_form( top ); spt.html5upload.upload_file(upload_file_kwargs); ''' % (upload_progress, on_complete, upload_init) } ) return div
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 get_display(my): top = my.top top.add_class("spt_changelist_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") #top.add_border() #top.add_style("padding", "10px") top.add_style("min-width: 600px") top.add_style("min-height: 400px") top.add_behavior( { 'type': 'load', 'cbjs_action': scm_get_onload_js() } ) sync_dir = Environment.get_sandbox_dir() # HARD CODED project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot changelist = my.kwargs.get("changelist") if not changelist: changelist = WidgetSettings.get_value_by_key("current_changelist") else: WidgetSettings.set_value_by_key("current_changelist", changelist) if not changelist: changelist = 'default' changelists = my.kwargs.get("changelists") if not changelists: changelists = [] elif isinstance(changelists, basestring): changelists = changelists.replace("'", '"') changelists = jsonloads(changelists) top.add_behavior( { 'type': 'load', 'sync_dir': sync_dir, 'depot': depot, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' } ) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_color("background", "background", -3) table.add_row() th = table.add_header("") th = table.add_header("Changelist") th.add_style("text-align: left") th = table.add_header("Description") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("Status") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Delete") th.add_style("text-align: left") #table.set_unique_id() #table.add_smart_styles("spt_changelist_item", { # 'text-align: right' # } )) bgcolor = table.get_color("background", -8) table.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_changelist_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' } ) table.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_changelist_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' } ) table.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': "spt_changelist_radio", 'cbjs_action': ''' var changelist = bvr.src_el.value; var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", changelist); spt.app_busy.show("Loading Changelists Information"); spt.changelist.load(bvr.src_el, changelist); spt.app_busy.hide(); ''' } ) for c in changelists: num_items = len(c.get("info")) name = c.get("change") tr = table.add_row() tr.add_class("spt_changelist_item") radio = RadioWdg("changelist") radio.add_class("spt_changelist_radio") table.add_cell(radio) radio.set_option("value", name) if name == changelist: radio.set_checked() table.add_cell(name) table.add_cell(c.get("desc")) table.add_cell(num_items) table.add_cell(c.get("status")) if num_items: icon = IconButtonWdg(title="View", icon=IconWdg.ZOOM) icon.add_behavior( { 'type': 'click_up', 'changelist': c.get("change"), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", bvr.changelist); spt.app_busy.show("Loading Changelist"); spt.changelist.load(bvr.src_el, bvr.changelist); spt.app_busy.hide(); ''' } ) else: icon = '' table.add_cell(icon) if not num_items and name != 'default': icon = IconButtonWdg(title="Delete Changelist", icon=IconWdg.DELETE) else: icon = "" table.add_cell(icon) inner.add("<hr/>") files = my.kwargs.get("files") if isinstance(files, basestring): files = files.replace("'", '"') files = jsonloads(files) if files == None: inner.add_behavior( { 'type': 'load', 'location': location, 'changelist': changelist, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.changelist = {} spt.changelist.load = function(el, changelist) { var applet = spt.Applet.get(); var changelists = spt.scm.run("get_changelists_by_user",[]); var dflt = { 'change': 'default', 'status': 'pending' } changelists.push(dflt); changelists = changelists.reverse(); for (var i = 0; i < changelists.length; i++) { var info = spt.scm.run("get_changelist_files",[changelists[i].change]); changelists[i]['info'] = info; } // get the current chnage list var files = spt.scm.run("get_changelist_files",[changelist]); var path_info = {}; var sizes = []; for ( var i = 0; i < files.length; i++) { // FIXME: perforce specific var path = files[i].depotFile; path = path.replace(bvr.location, bvr.sync_dir); files[i].path = path; var size; if (applet.exists(path)) { var info = applet.get_path_info(path); size = info.size; } else { size = 0; } sizes.push(size); path_info[path] = 'editable'; } //var ret_val = spt.scm.status(bvr.sync_dir); //console.log(ret_val); var class_name = 'tactic.ui.checkin.changelist_wdg.ChangelistWdg'; var kwargs = { files: files, sizes: sizes, changelist: changelist, changelists: changelists, path_info: path_info, } var top = el.getParent(".spt_changelist_content"); spt.panel.load(top, class_name, kwargs); } spt.changelist.load(bvr.src_el, bvr.changelist); ''' } ) content = DivWdg() inner.add(content) content.add_class("spt_changelist_content") if files == None: loading_wdg = DivWdg() content.add(loading_wdg) loading_wdg.add("<b>Loading ...</b>") loading_wdg.add_style("padding: 30px") elif files: title_wdg = DivWdg() title_wdg.add_style("height: 15px") title_wdg.add("Changelist: [%s]" % changelist) content.add(title_wdg) title_wdg.add_gradient("background", "background", -5) title_wdg.add_style("padding: 5px") title_wdg.add_border() #button = SingleButtonWdg(tip='Add New Changelist', icon=IconWdg.ADD) #content.add(button) content.add("<br/>") paths = [x.get("path") for x in files] sizes = my.kwargs.get("sizes") path_info = my.kwargs.get("path_info") from scm_dir_list_wdg import ScmDirListWdg # dummy search_key search_key = "sthpw/virtual?code=xx001" dir_list_wdg = ScmDirListWdg( base_dir=sync_dir, paths=paths, sizes=sizes, path_info=path_info, all_open=True, #search_key=search_key ) content.add(dir_list_wdg) else: content.add("Changelist: [%s]" % changelist) content.add("<br/>"*2) no_files_wdg = DivWdg() content.add(no_files_wdg) no_files_wdg.add_style("padding: 20px") no_files_wdg.add_border() no_files_wdg.add("No files in changelist") no_files_wdg.add_color("color", "color3") no_files_wdg.add_color("background", "background3") no_files_wdg.add_style("font-weight: bold") no_files_wdg.add_style("text-align: center") return top
def get_display(my): relative_dir = my.kwargs.get("relative_dir") my.relative_dir = relative_dir div = DivWdg() div.add_class("spt_ingest_top") div.add_style("width: 100%px") div.add_style("min-width: 500px") div.add_style("padding: 20px") div.add_color("background", "background") my.search_type = my.kwargs.get("search_type") if not my.search_type: div.add("No search type specfied") return div if relative_dir: folder_div = DivWdg() div.add(folder_div) folder_div.add("Folder: %s" % relative_dir) folder_div.add_style("opacity: 0.5") folder_div.add_style("font-style: italic") folder_div.add_style("margin-bottom: 10px") data_div = my.get_data_wdg() data_div.add_style("float: left") data_div.add_style("float: left") div.add(data_div) # create the help button help_button_wdg = DivWdg() div.add(help_button_wdg) help_button_wdg.add_style("float: right") help_button = ActionButtonWdg(title="?", tip="Ingestion Widget Help", size='s') help_button_wdg.add(help_button) help_button.add_behavior({ 'type': 'click_up', 'cbjs_action': '''spt.help.load_alias("ingestion_widget")''' }) from tactic.ui.input import Html5UploadWdg upload = Html5UploadWdg(multiple=True) div.add(upload) button = ActionButtonWdg(title="Add") button.add_style("float: right") button.add_style("margin-top: -3px") div.add(button) button.add_behavior({ 'type': 'click_up', 'normal_ext': File.NORMAL_EXT, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var files_el = top.getElement(".spt_to_ingest_files"); var regex = new RegExp('(' + bvr.normal_ext.join('|') + ')$', 'i'); //clear upload progress var upload_bar = top.getElement('.spt_upload_progress'); if (upload_bar) { upload_bar.setStyle('width','0%'); upload_bar.innerHTML = ''; } var onchange = function (evt) { var files = spt.html5upload.get_files(); var delay = 0; for (var i = 0; i < files.length; i++) { var size = files[i].size; var file_name = files[i].name; var is_normal = regex.test(file_name); if (size >= 10*1024*1024 || is_normal) { spt.drag.show_file(files[i], files_el, 0, false); } else { spt.drag.show_file(files[i], files_el, delay, true); if (size < 100*1024) delay += 50; else if (size < 1024*1024) delay += 500; else if (size < 10*1024*1024) delay += 1000; } } } spt.html5upload.clear(); spt.html5upload.set_form( top ); spt.html5upload.select_file( onchange ); ''' }) button = ActionButtonWdg(title="Clear") button.add_style("float: right") button.add_style("margin-top: -3px") div.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var file_els = top.getElements(".spt_upload_file"); for ( var i = 0; i < file_els.length; i++) { spt.behavior.destroy( file_els[i] ); }; ''' }) div.add("<br clear='all'/>") div.add("<br clear='all'/>") border_color_light = div.get_color("background2", 8) border_color_dark = div.get_color("background2", -15) background_mouseout = div.get_color("background3", 10) background_mouseenter = div.get_color("background3", 8) files_div = DivWdg() files_div.add_style("position: relative") files_div.add_class("spt_to_ingest_files") div.add(files_div) files_div.add_style("max-height: 300px") files_div.add_style("height: 300px") files_div.add_style("overflow-y: auto") files_div.add_style("padding: 3px") files_div.add_color("background", background_mouseout) files_div.add_style("border: 3px dashed %s" % border_color_light) files_div.add_style("border-radius: 20px 20px 20px 20px") files_div.add_style("z-index: 1") #files_div.add_style("display: none") bgcolor = div.get_color("background3") bgcolor2 = div.get_color("background3", -3) #style_text = "text-align: center; margin-top: 100px; color: #A0A0A0; font-size: 3.0em; z-index: 10;" background = DivWdg() background.add_class("spt_files_background") files_div.add(background) background.add_style("text-align: center") background.add_style("margin-top: 100px") background.add_style("opacity: 0.65") background.add_style("font-size: 3.0em") background.add_style("z-index: 10") background_text = DivWdg("<p>Drag Files Here</p>") background.add(background_text) files_div.add_behavior({ 'type': 'mouseover', 'cbjs_action': ''' bvr.src_el.setStyle("border","3px dashed %s") bvr.src_el.setStyle("background","%s") ''' % (border_color_dark, background_mouseenter) }) files_div.add_behavior({ 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("border", "3px dashed %s") bvr.src_el.setStyle("background","%s") ''' % (border_color_light, background_mouseout) }) # Test drag and drop files files_div.add_attr("ondragenter", "return false") files_div.add_attr("ondragover", "return false") files_div.add_attr("ondrop", "spt.drag.noop(event, this)") files_div.add_behavior({ 'type': 'load', 'normal_ext': File.NORMAL_EXT, 'cbjs_action': ''' spt.drag = {} var background; spt.drag.show_file = function(file, top, delay, icon) { if (!background) { background = top.getElement(".spt_files_background"); if (background) background.setStyle("display", "none"); } var template = top.getElement(".spt_upload_file_template"); var clone = spt.behavior.clone(template); clone.removeClass("spt_upload_file_template"); clone.addClass("spt_upload_file"); clone.setStyle("display", ""); if (typeof(delay) == 'undefined') { delay = 0; } // remember the file handle clone.file = file; var name = file.name; var size = parseInt(file.size / 1024 * 10) / 10; var thumb_el = clone.getElement(".spt_thumb"); var date_label_el = clone.getElement(".spt_date_label"); var date_el = clone.getElement(".spt_date"); //var loadingImage = loadImage( setTimeout( function() { var draw_empty_icon = function() { var img = $(document.createElement("div")); img.setStyle("width", "58"); img.setStyle("height", "34"); //img.innerHTML = "MP4"; img.setStyle("border", "1px dotted #222") thumb_el.appendChild(img); }; if (icon) { var loadingImage = loadImage( file, function (img) { if (img.width) thumb_el.appendChild(img); else draw_empty_icon(); }, {maxWidth: 80, maxHeight: 60, canvas: true, contain: true} ); } else { draw_empty_icon(); } loadImage.parseMetaData( file, function(data) { if (data.exif) { var date = data.exif.get('DateTimeOriginal'); if (date) { date_label_el.innerHTML = date; if (date_el) { date_el.value = date; } } } } ); }, delay ); /* var reader = new FileReader(); reader.thumb_el = thumb_el; reader.onload = function(e) { this.thumb_el.innerHTML = [ '<img class="thumb" src="', e.target.result, '" title="', escape(name), '" width="60px"', '" padding="5px"', '"/>' ].join(''); } reader.readAsDataURL(file); */ clone.getElement(".spt_name").innerHTML = file.name; clone.getElement(".spt_size").innerHTML = size + " KB"; clone.inject(top); } spt.drag.noop = function(evt, el) { var top = $(el).getParent(".spt_ingest_top"); var files_el = top.getElement(".spt_to_ingest_files"); evt.stopPropagation(); evt.preventDefault(); evt.dataTransfer.dropEffect = 'copy'; var files = evt.dataTransfer.files; var delay = 0; var skip = false; var regex = new RegExp('(' + bvr.normal_ext.join('|') + ')$', 'i'); for (var i = 0; i < files.length; i++) { var size = files[i].size; var file_name = files[i].name; var is_normal = regex.test(file_name); if (size >= 10*1024*1024 || is_normal) { spt.drag.show_file(files[i], files_el, 0, false); } else { spt.drag.show_file(files[i], files_el, delay, true); if (size < 100*1024) delay += 50; else if (size < 1024*1024) delay += 500; else if (size < 10*1024*1024) delay += 1000; } } } ''' }) # create a template that will be filled in for each file files_div.add_relay_behavior({ 'type': 'mouseenter', 'color': files_div.get_color("background3", -5), 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' }) files_div.add_relay_behavior({ 'type': 'mouseleave', 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' bvr.src_el.setStyle("background", ""); ''' }) files_div.add_relay_behavior({ 'type': 'mouseup', 'bvr_match_class': 'spt_remove', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_upload_file"); spt.behavior.destroy_element(top); ''' }) """ metadata_view = "test/wizard/metadata" files_div.add_relay_behavior( { 'type': 'mouseup', 'view': metadata_view, 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' var class_name = 'tactic.ui.panel.CustomLayoutWdg'; var kwargs = { view: bvr.view } spt.app_busy.show("Loading Metadata"); spt.panel.load_popup("Metadata", class_name, kwargs); spt.app_busy.hide(); ''' } ) """ # template for each file item file_template = DivWdg() file_template.add_class("spt_upload_file_template") files_div.add(file_template) file_template.add_style("margin-bottom: 3px") file_template.add_style("padding: 3px") file_template.add_style("height: 40px") file_template.add_style("display: none") thumb_div = DivWdg() file_template.add(thumb_div) thumb_div.add_style("float: left") thumb_div.add_style("width: 60") thumb_div.add_style("height: 40") thumb_div.add_style("overflow: hidden") thumb_div.add_style("margin: 3 10 3 0") thumb_div.add_class("spt_thumb") info_div = DivWdg() file_template.add(info_div) info_div.add_style("float: left") name_div = DivWdg() name_div.add_class("spt_name") info_div.add(name_div) name_div.add("image001.jpg") name_div.add_style("width: 150px") """ dialog = DialogWdg(display="false", show_title=False) info_div.add(dialog) dialog.set_as_activator(info_div, offset={'x':0,'y':10}) dialog_data_div = DivWdg() dialog_data_div.add_color("background", "background") dialog_data_div.add_style("padding", "10px") dialog.add(dialog_data_div) dialog_data_div.add("Category: ") text = TextInputWdg(name="category") dialog_data_div.add(text) text.add_class("spt_category") text.add_style("padding: 1px") """ date_div = DivWdg() date_div.add_class("spt_date_label") info_div.add(date_div) date_div.add("") date_div.add_style("opacity: 0.5") date_div.add_style("font-size: 0.8em") date_div.add_style("font-style: italic") date_div.add_style("margin-top: 3px") hidden_date_div = HiddenWdg("date") hidden_date_div.add_class("spt_date") info_div.add(date_div) size_div = DivWdg() size_div.add_class("spt_size") file_template.add(size_div) size_div.add("433Mb") size_div.add_style("float: left") size_div.add_style("width: 150px") size_div.add_style("text-align: right") remove_div = DivWdg() remove_div.add_class("spt_remove") file_template.add(remove_div) icon = IconButtonWdg(title="Remove", icon=IconWdg.DELETE) icon.add_style("float: right") remove_div.add(icon) #remove_div.add_style("text-align: right") div.add("<br/>") info = DivWdg() div.add(info) info.add_class("spt_upload_info") progress_div = DivWdg() progress_div.add_class("spt_upload_progress_top") div.add(progress_div) progress_div.add_style("width: 100%") progress_div.add_style("height: 15px") progress_div.add_style("margin-bottom: 10px") progress_div.add_border() #progress_div.add_style("display: none") progress = DivWdg() progress_div.add(progress) progress.add_class("spt_upload_progress") progress.add_style("width: 0px") progress.add_style("height: 100%") progress.add_gradient("background", "background3", -10) progress.add_style("text-align: right") progress.add_style("overflow: hidden") progress.add_style("padding-right: 3px") from tactic.ui.app import MessageWdg progress.add_behavior({ 'type': 'load', 'cbjs_action': MessageWdg.get_onload_js() }) # NOTE: files variable is passed in automatically upload_init = ''' server.start( {description: "Upload and check-in of ["+files.length+"] files"} ); var info_el = top.getElement(".spt_upload_info"); info_el.innerHTML = "Uploading ..."; ''' upload_progress = ''' var top = bvr.src_el.getParent(".spt_ingest_top"); progress_el = top.getElement(".spt_upload_progress"); var percent = Math.round(evt.loaded * 100 / evt.total); progress_el.setStyle("width", percent + "%"); progress_el.innerHTML = String(percent) + "%"; ''' oncomplete_script_path = my.kwargs.get("oncomplete_script_path") oncomplete_script = '' if oncomplete_script_path: script_folder, script_title = oncomplete_script_path.split("/") oncomplete_script_expr = "@GET(config/custom_script['folder','%s']['title','%s'].script)" % ( script_folder, script_title) server = TacticServerStub.get() oncomplete_script_ret = server.eval(oncomplete_script_expr, single=True) if oncomplete_script_ret: oncomplete_script = '''var top = bvr.src_el.getParent(".spt_ingest_top"); var file_els = top.getElements(".spt_upload_file"); for ( var i = 0; i < file_els.length; i++) { spt.behavior.destroy( file_els[i] ); };''' + oncomplete_script_ret script_found = True else: script_found = False oncomplete_script = "alert('Error: oncomplete script not found');" if not oncomplete_script: oncomplete_script = ''' var click_action = function() { var fade = true; var pop = spt.popup.get_popup(top) spt.popup.close(pop, fade); } spt.info("Ingest Completed", {click: click_action}); server.finish(); var file_els = top.getElements(".spt_upload_file"); for ( var i = 0; i < file_els.length; i++) { spt.behavior.destroy( file_els[i] ); }; var background = top.getElement(".spt_files_background"); background.setStyle("display", ""); spt.message.stop_interval(key); var info_el = top.getElement(".spt_upload_info"); info_el.innerHTML = ''; if (spt.table) { spt.table.run_search(); } spt.panel.refresh(top); ''' script_found = True on_complete = ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var update_data_top = top.getElement(".spt_edit_top"); var progress_el = top.getElement(".spt_upload_progress"); progress_el.innerHTML = "100%"; progress_el.setStyle("width", "100%"); var info_el = top.getElement(".spt_upload_info"); var search_type = bvr.kwargs.search_type; var relative_dir = bvr.kwargs.relative_dir; var update_mode_select = top.getElement(".spt_update_mode_select"); var update_mode = update_mode_select.value; var filenames = []; for (var i = 0; i != files.length;i++) { var name = files[i].name; filenames.push(name); } var key = spt.message.generate_key(); var values = spt.api.get_input_values(top); //var category = values.category[0]; //var keywords = values.keywords[0]; var extra_data = values.extra_data ? values.extra_data[0]: {}; var parent_key = values.parent_key[0]; var convert_el = top.getElement(".spt_image_convert") var convert = spt.api.get_input_values(convert_el); var processes = values.process; if (processes) { process = processes[0]; if (!process) { process = null; } } else { process = null; } var return_array = false; var update_data = spt.api.get_input_values(update_data_top, null, return_array); var kwargs = { search_type: search_type, relative_dir: relative_dir, filenames: filenames, key: key, parent_key: parent_key, //category: category, //keywords: keywords, extra_data: extra_data, update_data: update_data, process: process, convert: convert, update_mode: update_mode, } on_complete = function(rtn_data) { ''' + oncomplete_script + ''' }; var class_name = bvr.action_handler; // TODO: make the async_callback return throw an e so we can run // server.abort server.execute_cmd(class_name, kwargs, null, {on_complete:on_complete}); on_progress = function(message) { msg = JSON.parse(message.message); var percent = msg.progress; var description = msg.description; info_el.innerHTML = description; progress_el.setStyle("width", percent+"%"); progress_el.innerHTML = percent + "%"; } spt.message.set_interval(key, on_progress, 2000); ''' upload_div = DivWdg() div.add(upload_div) #button = UploadButtonWdg(**kwargs) button = ActionButtonWdg(title="Ingest") upload_div.add(button) button.add_style("float: right") upload_div.add_style("margin-bottom: 15px") upload_div.add("<br clear='all'/>") action_handler = my.kwargs.get("action_handler") if not action_handler: action_handler = 'tactic.ui.tools.IngestUploadCmd' button.add_behavior({ 'type': 'click_up', 'action_handler': action_handler, 'kwargs': { 'search_type': my.search_type, 'relative_dir': relative_dir, 'script_found': script_found, }, 'cbjs_action': ''' if (bvr.kwargs.script_found != true) { spt.alert("Error: provided on_complete script not found"); return; } var top = bvr.src_el.getParent(".spt_ingest_top"); var file_els = top.getElements(".spt_upload_file"); // get the server that will be used in the callbacks var server = TacticServerStub.get(); // retrieved the stored file handles var files = []; for (var i = 0; i < file_els.length; i++) { files.push( file_els[i].file ); } if (files.length == 0) { alert("Either click 'Add' or drag some files over to ingest."); return; } // defined the callbacks var upload_start = function(evt) { } var upload_progress = function(evt) { %s; } var upload_complete = function(evt) { %s; spt.app_busy.hide(); } var upload_file_kwargs = { files: files, upload_start: upload_start, upload_complete: upload_complete, upload_progress: upload_progress }; if (bvr.ticket) upload_file_kwargs['ticket'] = bvr.ticket; %s; spt.html5upload.set_form( top ); spt.html5upload.upload_file(upload_file_kwargs); ''' % (upload_progress, on_complete, upload_init) }) return div
def get_sobject_detail_wdg(my): div = DivWdg() #div.add_style("float: right") div.add_style("width: 100%") div.add_style("height: 100%") div.add_style("padding-top: 5px") """ button_div.add_class("spt_left") div.add(button_div) button = IconButtonWdg(title="Show More Details", icon=IconWdg.RIGHT) button_div.add(button) button_div.add_style("position: absolute") button_div.add_style("margin-left: -30px") button_div.add_style("margin-top: -2px") button_div.add_style("display: none") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_detail_top"); var detail = top.getElement(".spt_sobject_detail"); spt.toggle_show_hide(detail); var left = top.getElement(".spt_left"); spt.hide(left); var right = top.getElement(".spt_right"); spt.show(right); ''' } ) button_div = DivWdg() button_div.add_class("spt_right") div.add(button_div) button = IconButtonWdg(title="Show More Details", icon=IconWdg.LEFT) button_div.add(button) button_div.add_style("position: absolute") button_div.add_style("margin-left: -30px") button_div.add_style("margin-top: -2px") #button_div.add_style("display: none") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_detail_top"); var detail = top.getElement(".spt_sobject_detail"); spt.toggle_show_hide(detail); var left = top.getElement(".spt_left"); spt.show(left); var right = top.getElement(".spt_right"); spt.hide(right); ''' } ) """ info_div = DivWdg() div.add( info_div ) #info_div.add_style("display: none") info_div.add_class("spt_sobject_detail") #info_div.add_style("width: 300px") info_div.add_style("padding: 30px 0px 30px 0px") info_table = Table() info_table.add_color("color", "color") info_div.add(info_table) edit_div = DivWdg() info_div.add(edit_div) edit_div.add_style("margin-top: -35px") edit_div.add_style("margin-left: 1px") edit_div.add_style("margin-right: -2px") #edit_div.add_style("overflow: scroll") edit_div.add_style("height: 100%") view = my.kwargs.get("detail_view") if not view: view = "edit" ignore = ["preview", "notes"] element_names = ['name','description','tasks'] config = WidgetConfigView.get_by_search_type(search_type=my.full_search_type, view=view) config_element_names = config.get_element_names() for x in config_element_names: if x in ignore: continue if x not in element_names: element_names.append(x) # add the tile title = DivWdg() edit_div.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(" ") title.add_border() from tactic.ui.panel.edit_layout_wdg import EditLayoutWdg edit = EditLayoutWdg(search_type=my.full_search_type, mode='view', view="detail", search_key=my.search_key, width=400, title=' ', ignore=ignore, element_names=element_names) edit_div.add(edit) return div
def get_container(my, xml): # handle the container element_node = xml.get_node("config/tmp/element") attrs = Xml.get_attributes(element_node) element_name = attrs.get("name") show_resize_scroll = attrs.get("show_resize_scroll") if not show_resize_scroll: show_resize_scroll = my.kwargs.get("show_resize_scroll") if not show_resize_scroll: show_resize_scroll = "false" # look for attributes in the element tag for specifying a title action button to plug # into the title bar of the custom section ... # title_action_icon = attrs.get("title_action_icon") title_action_script = attrs.get("title_action_script") title_action_label = attrs.get("title_action_label") if title_action_script and not title_action_label: title_action_label = '[action]' # get the width and height for the element content ... width = attrs.get("width") height = attrs.get("height") if width and height: container = ContainerWdg( inner_width=width, inner_height=height, show_resize_scroll=show_resize_scroll ) else: container = ContainerWdg(show_resize_scroll=show_resize_scroll) # create the title title = attrs.get("title") if not title: title = Common.get_display_title(element_name) title_wdg = DivWdg() SmartMenu.assign_as_local_activator( title_wdg, 'HEADER_CTX' ) title_wdg.add_style("margin: 0px 0px 5px 0px") title_wdg.add_gradient("background", "background", 0) title_wdg.add_color("color", "color") title_wdg.add_style("padding", "5px") if title_action_script: # add an action button if an action script code was found in the attributes of the element proj = Project.get_project_code() script_search = Search("config/custom_script") script_sobj = script_search.get_by_search_key( "config/custom_script?project=%s&code=%s" % (proj, title_action_script) ) script = script_sobj.get_value('script') icon_str = "HELP" if title_action_icon: icon_str = title_action_icon action_btn = HtmlElement.img( IconWdg.get_icon_path(icon_str) ) action_btn.set_attr('title',title_action_label) # action_btn = IconWdg( title_action_label, icon=icon) action_btn.add_behavior( {'type': 'click_up', 'cbjs_action': script } ) action_btn.add_styles( "cursor: pointer; float: right;" ) title_wdg.add( action_btn ) title_wdg.add(title) container.add(title_wdg) return container
def get_display(my): top = DivWdg() sobject = my.get_sobject() if not sobject: return top process = my.kwargs.get("process") #from tactic.ui.table import TaskElementWdg #task_wdg = TaskElementWdg() #task_wdg.set_sobject(my.sobject) #top.add(task_wdg) search = Search('sthpw/task') search.add_parent_filter(sobject) search.add_filter("process", process) tasks = search.get_sobjects() tasks_div = DivWdg() top.add(tasks_div) #tasks_div.add_style("padding: 0px 0px 20px 0px") tasks_div.add_style("margin: 10px") tasks_div.set_box_shadow() title = DivWdg() title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("All Tasks for process '%s':" % process) tasks_div.add(title) task_wdg = TableLayoutWdg(search_type="sthpw/task",view='single_process', show_row_select="false", show_insert="false", show_gear="false", show_search_limit="false", show_search=False, show_refresh="false", show_shelf="false") task_wdg.set_sobjects(tasks) tasks_div.add(task_wdg) #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table = Table() top.add(table) table.add_style("width: 100%") table.add_row() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 50%") notes_div = DivWdg() td.add(notes_div) notes_div.set_box_shadow() notes_div.add_style("margin: 10px") title = DivWdg() notes_div.add(title) title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Notes:") from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=sobject.get_search_key(), process=process, context_hidden=True, show_note_expand=True) notes_div.add(discussion_wdg) search = Search('sthpw/snapshot') search.add_parent_filter(sobject) search.add_filter("process", process) snapshots = search.get_sobjects() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 50%") td.add_style("padding: 0 0 0 0") snapshots_div = DivWdg() td.add(snapshots_div) snapshots_div.set_box_shadow() snapshots_div.add_style("margin: 10px") title = DivWdg() title.add_gradient("background", "background3", 0, -10) title.add_color("color", "color3", -10) title.add_border() title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Snapshots:") snapshots_div.add(title) snapshot_wdg = TableLayoutWdg(search_type="sthpw/snapshot",view='table', mode='simple', show_row_select=False, width='100%', show_shelf="false") snapshot_wdg.set_sobjects(snapshots) snapshots_div.add(snapshot_wdg) return top
def get_display(self): top = self.top top.add_style("position: absolute") top.add_style("top: 300") top.add_style("left: 600") top.add_style("display: none") top.set_id("spt_hot_box") top.add_style("margin: 0 auto") top.add_behavior( { 'type': 'listen', 'event_name': 'hotbox|toggle', 'cbjs_action': ''' var size = $(window).getSize(); bvr.src_el.setStyle("left", size.x/2-300); bvr.src_el.setStyle("top", size.y/2-200); if (bvr.src_el.getStyle("display") == "none") { spt.show(bvr.src_el); spt.body.add_focus_element(bvr.src_el); spt.popup.show_background(); } else { spt.hide(bvr.src_el); spt.popup.hide_background(); } ''' } ) top.add_behavior( { 'type': 'listen', 'event_name': 'hotbox|close', 'cbjs_action': ''' spt.hide(bvr.src_el); spt.popup.hide_background(); ''' } ) div = DivWdg() top.add(div) div.add_style("width: 630px") div.add_style("height: 400px") div.add_style("opacity: 0.8") div.add_gradient("background", "background3", 10) div.add_style("position: fixed") div.add_style("z-index: 1000") #div.set_box_shadow("2px 2px 4px 4px") div.set_box_shadow(color="#000") div.set_round_corners(25) div.add_border() content_top_wdg = DivWdg() content_top_wdg.add_style("position: fixed") top.add(content_top_wdg) content_top_wdg.add_style("padding: 20px 50px 50px 50px") content_top_wdg.add_style("z-index: 1001") content_top_wdg.add_style("width: 550px") content_top_wdg.add_style("height: 400px") close_wdg = DivWdg() content_top_wdg.add(close_wdg) icon = IconWdg('Close Quick Links', "BS_REMOVE") close_wdg.add(icon) #close_wdg.add_style("position: fixed") #close_wdg.add_style("float: right") close_wdg.add_style("position: absolute") close_wdg.add_style("top: 10px") close_wdg.add_style("right: 30px") close_wdg.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("hotbox|close"); ''' } ) close_wdg.add_class("hand") content_wdg = self.get_content_wdg() content_top_wdg.add(content_wdg) return top
def get_elements_wdg(self): div = DivWdg() div.add_style("min-width: 200px") div.add_style("min-height: 500px") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add("Elements") title_wdg.add_style("padding: 5px") title_wdg.add_gradient("background", "background", -10) #element_names = ['Checkin', 'Checkout'] element_names = self.config.get_element_names() elements_wdg = DivWdg() div.add(elements_wdg) elements_wdg.add_style("padding: 5px") view = 'tab_config_whatever' hover = div.get_color("background", -10) for element_name in element_names: element_div = DivWdg() elements_wdg.add(element_div) element_div.add(element_name) element_div.add_style("padding: 3px") element_div.add_behavior({ 'type': 'hover', 'hover': hover, 'cbjs_action_over': '''bvr.src_el.setStyle("background", bvr.hover)''', 'cbjs_action_out': '''bvr.src_el.setStyle("background", "")''' }) element_div.add_class("hand") element_div.add_behavior({ 'type': 'click_up', 'view': view, 'element_name': element_name, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_tab_edit_top"); var content = top.getElement(".spt_tab_edit_content"); var class_name = 'tactic.ui.tools.tab_edit_wdg.TabElementDefinitionWdg'; var kwargs = { view: bvr.view, element_name: bvr.element_name }; spt.panel.load(content, class_name, kwargs); ''' }) return div
def get_filter_wdg(my): div = DivWdg() div.add_style("padding: 10px") div.add_style("margin: -10 -10 10 -10") div.add_style("min-width: 600px") div.add_class("spt_view_manager_filter") from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias="view-manager|what-are-views") div.add(help_wdg) help_wdg.add_style("float: right") div.add("<b>Search Type:</b> ") div.add_gradient("background", "background", -10) security = Environment.get_security() project = Project.get() if security.check_access("builtin", "view_site_admin", "allow"): search_type_objs = project.get_search_types(include_sthpw=True, include_config=True) else: search_type_objs = project.get_search_types() search_types = [x.get_value("search_type") for x in search_type_objs] titles = ["%s (%s)" % (x.get_value("search_type"), x.get_value("title")) for x in search_type_objs] select = SelectWdg(name="search_type") select.set_option("values", search_types) select.set_option("labels", titles) select.add_empty_option("-- Select --") select.set_persistence() # select.set_persist_on_submit() # security = Environment.get_security() # if security.check_access("builtin", "view_site_admin", "allow"): # select_mode = SearchTypeSelectWdg.ALL # else: # select_mode = SearchTypeSelectWdg.ALL_BUT_STHPW # select = SearchTypeSelectWdg(name='search_type', \ # mode=select_mode) behavior = { "type": "change", "cbjs_action": """ var manager_top = bvr.src_el.getParent(".spt_view_manager_top"); var input = spt.api.Utility.get_input(manager_top, 'search_type'); var view_input = spt.api.Utility.get_input(manager_top, 'view'); var view_input_value = ''; if (view_input != null) { view_input_value = view_input.value; } var values = {'search_type': input.value, 'view': view_input_value, 'is_refresh': 'true'}; spt.panel.refresh(manager_top, values);""" # //spt.panel.refresh(manager_top, values);''' } select.add_behavior(behavior) select.set_value(my.search_type) div.add(select) if not my.search_type: content = DivWdg() content.add_style("width: 400px") content.add_style("height: 400px") div.add(content) content.add_style("padding: 20px") content.add(IconWdg("WARNING", IconWdg.WARNING)) content.add("No Search Type Selected") content.add_border() content.add_style("margin-top: 20px") content.add_color("background", "background") content.add_style("font-weight: bold") return div div.add(" ") div.add("<b>View: </b>") view_wdg = SelectWdg("view") view_wdg.set_value(my.view) view_wdg.add_empty_option("-- Select --") view_wdg.add_behavior(behavior) div.add(view_wdg) search = Search("config/widget_config") search.add_filter("search_type", my.search_type) db_configs = search.get_sobjects() views = set() for db_config in db_configs: view = db_config.get_value("view") if view.startswith("link_search:"): continue views.update([view]) # print "search_type: ", my.search_type # print "view: ", views, my.view if my.search_type and my.view: config_view = WidgetConfigView.get_by_search_type(my.search_type, my.view) configs = config_view.get_configs() for x in configs: view = x.get_view() file_path = x.get_file_path() if view != my.view: continue if file_path and file_path.endswith("DEFAULT-conf.xml"): continue config_views = x.get_all_views() views.update(config_views) views_list = list(views) views_list.sort() view_wdg.set_option("values", views_list) return div
def get_main_section_wdg(my, title, description, image, behavior, img_height="64px"): section_wdg = DivWdg() #section_wdg.set_round_corners() section_wdg.add_border() section_wdg.add_style("width: 225px") section_wdg.add_style("height: 225px") section_wdg.add_style("overflow: hidden") section_wdg.add_style("margin: -5px 5px 10px 5px") #section_wdg.add_style("margin: 10px") #section_wdg.set_box_shadow() title_wdg = DivWdg() section_wdg.add(title_wdg) title_wdg.add(title) title_wdg.add_style("height: 20px") title_wdg.add_style("padding: 3px") title_wdg.add_style("margin-top: 3px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("text-align: center") title_wdg.add_gradient("background", "background") section_wdg.add_color("background", "background") section_wdg.add_behavior( { 'type': 'hover', 'add_color_modifier': -3, 'cb_set_prefix': 'spt.mouse.table_layout_hover', } ) shadow = section_wdg.get_color("shadow") section_wdg.add_behavior( { 'type': 'click', 'shadow': shadow, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 5px " + bvr.shadow); ''' } ) section_wdg.add_behavior( { 'type': 'mouseenter', 'shadow': shadow, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 5px " + bvr.shadow); ''', } ) section_wdg.add_behavior( { 'type': 'mouseleave', 'shadow': shadow, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 0px " + bvr.shadow); ''', } ) desc_div = DivWdg() desc_div.add(description) desc_div.add_style("padding: 5px 10px 10px 10px") #desc_div.add_style("font-size: 1.5em") #desc_div.add_style("font-weight: bold") div = DivWdg() section_wdg.add(div) div.add_style("padding: 3px") div.add_style("margin: 10px") div.add_style("width: 209px") div.add_style("height: %s" % img_height) div.add_style("text-align: center") div.add(image) #div.set_box_shadow("1px 1px 1px 1px") section_wdg.add(desc_div) div.add_style("overflow: hidden") section_wdg.add_behavior( behavior ) section_wdg.add_class("hand") return section_wdg
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(self): 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_behavior({ 'type': 'load', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|hide_now", {} ); ''' }) project = Project.get() title = DivWdg() title.add("Project Startup and Configuration") 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 10px -10px") top.add(title) title.add_gradient("background", "background3", 5, -10) shelf = DivWdg() top.add(shelf) shelf.add_style("margin-left: -8px") shelf.add_style("width: 130px") button_div = DivWdg() shelf.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-top: -3px") security = Environment.get_security() view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow') if view_side_bar: button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT) button_div.add(button) shelf.add("Toggle Side Bar") shelf.add_attr("title", "Toggle Side Bar (or press '1')") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' }) shelf.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' }) shelf.add_class("hand") else: shelf.add(" ") search_wdg = Table() top.add(search_wdg) search_wdg.add_row() search_wdg.add_class("spt_main_top") search_wdg.add_style("padding: 10px") search_wdg.add_style("margin: 20px auto") search_wdg.add_style("width: 430px") td = search_wdg.add_cell("Search: ") td.add_style("vertical-align: top") td.add_style("padding-top: 8px") custom_cbk = {} custom_cbk['enter'] = ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords != '') { var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); } ''' from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg #text = TextInputWdg(name="search") text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, width='280', height='42px') #text = TextWdg("search") text.add_class("spt_main_search") text.add_style("width: 290px") search_wdg.add_cell(text) search_wdg.add_style("font-weight: bold") search_wdg.add_style("font-size: 16px") icon_div = DivWdg() td = search_wdg.add_cell(icon_div) td.add_style("vertical-align: top") icon_div.add_style("width: 38px") icon_div.add_style("height: 27px") icon_div.add_style("padding-top: 7px") icon_div.add_style("padding-left: 4px") icon_div.add_style("text-align: center") #icon_div.add_gradient("background", "background3", 15, -10) icon_div.add_color("background", "background3", 10) over_color = icon_div.get_color("background3", 0) out_color = icon_div.get_color("background3", 10) icon_div.set_round_corners(5) icon_div.set_box_shadow("1px 1px 1px 1px") icon = IconWdg("Search", IconWdg.SEARCH_32, width=24) icon_div.add(icon) button = icon_div icon_div.add_class("hand") icon_div.add_behavior({ 'type': 'mouseover', 'color': over_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' }) icon_div.add_behavior({ 'type': 'mouseout', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' }) icon_div.add_behavior({ 'type': 'click', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-3"); bvr.src_el.setStyle("margin-right", "-2"); ''' }) icon_div.add_behavior({ 'type': 'click_up', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' }) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords == '') { return; } var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); ''' }) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") # create a bunch of panels table = Table() table.add_color("color", "color") table.add_style("margin-bottom: 20px") table.center() top.add(table) table.add_row() #security = Environment.get_security() #if not security.check_access("builtin", "view_site_admin", "allow"): td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Configuration" #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.''' description = '''Configure a Project from start to finish.''' image = "<img src='/context/icons/64x64/configuration_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.ProjectConfigWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs); ''' } config_wdg = self.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) # Manage Users td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Users and Security" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" image = DivWdg() image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>" image.add(image_link) image1 = IconWdg("Manage Users", IconWdg.USER_32) image2 = IconWdg("Manage Users", IconWdg.USER_32) image3 = IconWdg("Manage Users", IconWdg.USER_32) image4 = IconWdg("Manage Users", IconWdg.USER_32) image.add(image1) image.add(image2) image.add("<br/>") image.add(image3) image.add(image4) description = '''Manage users that can access the system''' behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.UserConfigWdg'; var kwargs = { help_alias: 'project-startup-manage-users' }; spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs); ''' } manage_users_wdg = self.get_main_section_wdg(title, description, image, behavior) td.add(manage_users_wdg) # custom layout editor td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Custom Layouts" description = '''Create interfaces using the Custom Layout Editor.''' image = "<img src='/context/icons/64x64/layout_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.tools.CustomLayoutEditWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs); ''' } config_wdg = self.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) tr = table.add_row() # Plugins td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Plugins" image = IconWdg("Manage Plugins", IconWdg.PLUGIN_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Upload, install, remove and create TACTIC plugins.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.PluginWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs); ''' } plugin_wdg = self.get_small_section_wdg(title, description, image, behavior) td.add(plugin_wdg) # Examples td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Tools" image = IconWdg("Tools", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A collection of example views.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ToolsWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("tools", "Tools", class_name, kwargs); ''' } share_wdg = self.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) # Share """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Shares" image = IconWdg("Shares", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Share project with other TACTIC installs.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ShareWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("shares", "Shares", class_name, kwargs); ''' } share_wdg = self.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ # Advanced td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Advanced Setup" image = IconWdg("Advanced", IconWdg.ADVANCED_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A set of advanced configuration tools.''' 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) ''' } share_wdg = self.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Documentation" description = '''TACTIC Documentation. * Project Setup Documentation<br/> <br/> * End User Documentation<br/> <br/> * Developer Documentation<br/> <br/> * System Administrator Documentation<br/> <br/> ''' image = "<img src='/context/images/getting_started_pipeline.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.help.load_alias("main") ''' } doc_wdg = self.get_section_wdg(title, description, image, behavior) td.add(doc_wdg) """ tr, td = table.add_row_cell() td.add_style("font-size: 14px") td.add("<br/>") from misc_wdg import QuickLinksWdg quick_links_wdg = QuickLinksWdg() td.add(quick_links_wdg) #td = table.add_cell() #totals_wdg = self.get_totals_wdg() #td.add(totals_wdg) return top
def get_display(self): self.config_search_type = self.kwargs.get("config_search_type") if not self.config_search_type: self.config_search_type = "SideBarWdg" title = self.kwargs.get('title') config = self.kwargs.get('config') view = self.kwargs.get('view') width = self.kwargs.get('width') #sortable = self.kwargs.get('sortable') if not width: width = "175" self.prefix = self.kwargs.get("prefix") if not self.prefix: self.prefix = "side_bar" self.mode = self.kwargs.get("mode") if not self.mode: self.mode = 'view' self.default = self.kwargs.get('default') == 'True' div = DivWdg() div.add_class("spt_section_top") div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") # create the top widgets label = SpanWdg() label.add(title) label.add_style("font-size: 1.1em") section_div = LabeledHidableWdg(label=label) div.add(section_div) section_div.set_attr('spt_class_name', Common.get_full_class_name(self)) for name, value in self.kwargs.items(): if name == "config": continue section_div.set_attr("spt_%s" % name, value) bgcolor = label.get_color("background3") project_div = RoundedCornerDivWdg(hex_color_code=bgcolor, corner_size="10") project_div.set_dimensions(width_str='%spx' % width, content_height_str='100px') content_div = project_div.get_content_wdg() #project_div = DivWdg() #content_div = project_div section_div.add(project_div) content_div.add_class("spt_side_bar_content") content_div.add_attr("spt_view", view) if type(view) in types.StringTypes: view = [view] view_margin_top = '4px' web = WebContainer.get_web() for viewx in view: config = self.get_config(self.config_search_type, viewx, default=self.default) if not config: continue # make up a title title = DivWdg() title.add_gradient("background", "side_bar_title", 0, -15, default="background") title.add_color("color", "side_bar_title_color", default="color") title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top) if not web.is_IE(): title.add_styles("margin-left: -5px; margin-right: -5px;") title.add_looks("navmenu_header") title.add_style("height: 18px") title.add_style("padding-top: 2px") """ title = DivWdg() title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top ) if not web.is_IE(): title.add_styles( "margin-left: -10px; margin-right: -10px;") title.add_looks( "navmenu_header" ) """ # FIXME: not sure if this logic should be here. It basically # makes special titles for certain view names view_attrs = config.get_view_attributes() title_str = view_attrs.get("title") if not title_str: if viewx.startswith("self_view_"): title_str = "My Views" else: title_str = viewx title_str = Common.get_display_title(title_str) title_label = SpanWdg() title_label.add_styles("margin-left: 6px; padding-bottom: 2px;") title_label.add_looks("fnt_title_5 fnt_bold") title_label.add(title_str) title.add(title_label) content_div.add(title) info = {'counter': 10, 'view': viewx} self.generate_section(config, content_div, info) error_list = Container.get_seq(self.ERR_MSG) if error_list: span = SpanWdg() span.add_style('background', 'red') span.add('<br/>'.join(error_list)) content_div.add(span) Container.clear_seq(self.ERR_MSG) self.add_dummy(config, content_div) return div