def get_save_wdg(my): # add the popup popup = PopupWdg(id="save_search_wdg") popup.add("Save Search", "title") div = DivWdg() div.add("Save current search as: ") text = TextWdg("save_search_text") text.set_id("save_search_text") div.add(text) save_button = ButtonWdg("Save Search") behavior = {"type": "click", "mouse_btn": "LMB", "cbjs_action": "spt.dg_table.save_search_cbk(evt, bvr);"} save_button.add_behavior(behavior) cancel_button = ButtonWdg("Cancel") cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'") div.add(HtmlElement.hr()) button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(save_button) button_div.add(" ") button_div.add(cancel_button) div.add(button_div) popup.add(div, "content") return popup
def get_predefined_wdg(self): project = Project.get() project_type = project.get_type() from tactic.ui.container import PopupWdg popup = PopupWdg(id="predefined_db_columns", allow_page_activity=True, width="320px") popup.add_title("Predefined Database Columns") popup.add( self.get_section_wdg(view='predefined', default=True)) return popup
def get_display(my): sbox_popup_id = 'SearchBoxPopupWdg' search_container = DivWdg() search_container.set_id( "%s_search" % sbox_popup_id) search_container.add_style("display", "block") search_container.set_attr("spt_search_type", my.search_type) search_container.set_attr("spt_search_view", my.search_view) search_container.add(my.search_wdg) sbox_popup = PopupWdg(id=sbox_popup_id, allow_page_activity=True, width="720px") sbox_popup.add("TACTIC Search Box Window", "title") sbox_popup.add( search_container, 'content' ) return sbox_popup
def get_display(my): popup = PopupWdg( id="HelpPopupWdg", allow_page_activity=True, width="600px" ) popup.add("TACTIC™ Help", "title") content_div = DivWdg() inner_div = DivWdg() inner_div.set_style("background: #2f2f2f; color: #000000; border: 1px solid #000000; padding: 2px;") # TEMP ... inner_div.add( "Under Construction!" ); # Finished generating tools for Action Bar ... content_div.add(inner_div) popup.add(content_div, 'content') return popup
def get_retrieve_wdg(my): # add the popup popup = PopupWdg(id='retrieve_search_wdg') popup.add("Retrieve Saved Search", "title") div = DivWdg() div.add("List of Saved Searches: ") div.add(HtmlElement.br(2)) try: search = Search("config/widget_config") search.add_where("\"view\" like 'saved_search:%'") search.add_filter("search_type", my.search_type) configs = search.get_sobjects() except SearchException, e: print "WARNING: ", e configs = []
def get_display(self): use_popup = self.kwargs.get("use_popup") if use_popup in [True, 'true']: use_popup = True else: use_popup = False div = DivWdg() content = self.get_content() content.add_style("width: 600px") content.add_style("margin-left: auto") content.add_style("margin-right: auto") from tactic.ui.container import PopupWdg if use_popup: popup = PopupWdg(id="LicenseManagerWdg", width="500px", allow_page_activity="false", display='true', zstart=10000, allow_close=self.allow_close) popup.add("License Manager", "title") popup.add(content, "content") div.add(popup) behavior = { 'type': 'load', 'cbjs_action': ''' var el = $("LicenseManagerWdg"); el.setStyle("display",""); ''' } div.add_behavior(behavior) else: div.add(content) content.add_style("height: 500px") return div
def get_js_popup(my): # Add in javascript logger console pop-up ... # This is particularly useful for being able to print out debug info in javascript when testing # and debugging in IE or in FF without Firebug (where console.log is not defined) # js_popup_id = "WebClientOutputLogPopupWdg" js_popup = PopupWdg(id=js_popup_id, allow_page_activity=True, width="630px") js_popup.add("TACTIC™ Web Client Output Log", "title") js_content_div = DivWdg() button = ButtonWdg("Clear") button.add_style("margin: 5 10") button.add_event("onclick", "$('spt_js_log_output_div').innerHTML = ''") js_content_div.add(button) js_content_div.add( HtmlElement.hr() ) js_div = DivWdg(id="spt_js_log_output_div") js_div.add_style("background: #000000") js_div.add_style("font-family: Courier, Fixed, serif") js_div.add_style("font-size: 11px") js_div.add_style("padding: 3px") js_div.add_style("color: #929292") js_div.add_style("width: 600px") js_div.add_style("height: 400px") js_div.add_style("overflow: auto") # Get user preference for the Web Client Output Console logging level ... log_level = PrefSetting.get_value_by_key("js_logging_level") if not log_level: log_level = "WARNING" # set js logging level to 'WARNING' as a default! PrefSetting.create("js_logging_level",log_level) js_div.set_attr("spt_log_level", log_level) js_content_div.add( js_div ) js_popup.add( js_content_div, 'content' ) return js_popup
def get_predefined_wdg(my): project = Project.get() project_type = project.get_type() from tactic.ui.container import PopupWdg popup = PopupWdg(id="predefined_db_columns", allow_page_activity=True, width="320px") popup.add_title("Predefined Database Columns") popup.add(my.get_section_wdg(view='predefined', default=True)) return popup
def get_display(self): sbox_popup_id = 'SearchBoxPopupWdg' search_container = DivWdg() search_container.set_id( "%s_search" % sbox_popup_id) search_container.add_style("display", "block") search_container.set_attr("spt_search_type", self.search_type) search_container.set_attr("spt_search_view", self.search_view) search_container.add(self.search_wdg) sbox_popup = PopupWdg(id=sbox_popup_id, allow_page_activity=True, width="720px") sbox_popup.add("TACTIC Search Box Window", "title") sbox_popup.add( search_container, 'content' ) return sbox_popup
def get_display(self): popup = PopupWdg( id="HelpPopupWdg", allow_page_activity=True, width="600px" ) popup.add("TACTIC™ Help", "title") content_div = DivWdg() inner_div = DivWdg() inner_div.set_style("background: #2f2f2f; color: #000000; border: 1px solid #000000; padding: 2px;") # TEMP ... inner_div.add( "Under Construction!" ); # Finished generating tools for Action Bar ... content_div.add(inner_div) popup.add(content_div, 'content') return popup
def get_display(my): use_popup = my.kwargs.get("use_popup") if use_popup in [True, 'true']: use_popup = True else: use_popup = False div = DivWdg() content = my.get_content() content.add_style("width: 600px") content.add_style("margin-left: auto") content.add_style("margin-right: auto") from tactic.ui.container import PopupWdg if use_popup: popup = PopupWdg(id="LicenseManagerWdg", width="500px", allow_page_activity="false", display='true', zstart=10000, allow_close=my.allow_close) popup.add("License Manager", "title") popup.add(content, "content") div.add(popup) behavior = { 'type': 'load', 'cbjs_action': ''' var el = $(LicenseManagerWdg); el.setStyle("display",""); //var parent = el.getParent(".spt_panel"); //parent.setStyle("left: 0px"); //parent.setStyle("margin-right: auto"); ''' } div.add_behavior(behavior) else: div.add(content) content.add_style("height: 500px") return div
def get_save_wdg(my): # add the popup popup = PopupWdg(id='save_search_wdg') popup.add("Save Search", "title") div = DivWdg() div.add("Save current search as: ") text = TextWdg("save_search_text") text.set_id("save_search_text") div.add(text) save_button = ButtonWdg("Save Search") behavior = { 'type': 'click', 'mouse_btn': 'LMB', 'cbjs_action': 'spt.dg_table.save_search_cbk(evt, bvr);' } save_button.add_behavior(behavior) cancel_button = ButtonWdg("Cancel") cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'") div.add(HtmlElement.hr()) button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(save_button) button_div.add(" ") button_div.add(cancel_button) div.add(button_div) popup.add(div, "content") return popup
def get_display(self): if self.is_popup: icon_chooser_popup_id = "IconChooserPopup" icon_chooser_popup = PopupWdg(id=icon_chooser_popup_id, allow_page_activity=False, width="760px") icon_chooser_popup.add("Icon Chooser", "title") orig_icon_list = IconWdg.icons.keys() icon_list = ['-- No Icon --'] do_not_list = [ 'MAYA', 'HOUDINI', 'PROGRESS', 'CLIP_PLAY', 'XSI', 'CLIP_PAUSE', 'CHECK_OUT_LG', 'CHECK_OUT', 'PUBLISH_LG' ] for k in orig_icon_list: if k in do_not_list: continue icon_list.append(k) icon_list.sort() icon_list_len = float(len(icon_list)) num_cols = 5 num_rows = int(math.ceil(icon_list_len / float(num_cols))) chooser_wrapper_div = DivWdg() chooser_wrapper_div.add_class("SPT_ICON_CHOOSER_WRAPPER_DIV") chooser_bkg_rc = RoundedCornerDivWdg(hex_color_code="949494", corner_size="10") chooser_bkg_rc.set_dimensions(width_str='740px', content_height_str='520px') table = Table() for r in range(num_rows): table.add_row() for c in range(num_cols): td = table.add_cell() td.add_styles( "color: black; overflow: hidden; width: 140px; max-width: 140px; height: 20px;" ) td.add_styles( "border: 1px solid transparent; cursor: pointer;") td.add_behavior({ 'type': 'hover', 'mod_styles': 'background-color: #555555;' }) if c > 0: td.add_styles("border-left-color: black;") idx = int(c * num_rows + r) if idx < icon_list_len: icon_name = icon_list[idx] icon_path = '' if icon_name != '-- No Icon --': icon_path = IconWdg.get_icon_path(icon_name) icon = IconWdg(icon_name, icon_path) td.add(icon) text_span = SpanWdg() text_span.add_looks("fnt_code") text_span.add_styles("font-size: 10px") if len(icon_name) > 16: text_span.add("%s..." % icon_name[:15]) else: text_span.add(icon_name) td.add(text_span) if icon_name == '-- No Icon --': icon_name = '' td.add_class("SPT_ICON_SELECT_%s" % icon_name) if self.is_popup: cbjs_action = ''' var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV"); cwd.setProperty("spt_icon_selected", "%s"); cwd.setProperty("spt_icon_path", "%s"); spt.popup.close( spt.popup.get_popup( bvr.src_el ) ); spt.named_events.fire_event("%s",bvr); ''' % (icon_name, icon_path, "ICON_CHOOSER_SELECTION_MADE") else: cbjs_action = ''' var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV"); cwd.setProperty("spt_icon_selected", "%s"); cwd.setProperty("spt_icon_path", "%s"); spt.hide( cwd ); spt.named_events.fire_event("%s",bvr); ''' % (icon_name, icon_path, "ICON_CHOOSER_SELECTION_MADE") pass td.add_behavior({ 'type': 'click_up', 'cbjs_action': cbjs_action }) chooser_bkg_rc.add(table) chooser_wrapper_div.add(chooser_bkg_rc) if self.is_popup: icon_chooser_popup.add(chooser_wrapper_div, "content") return icon_chooser_popup return div
def get_display(my): web = WebContainer.get_web() tactic_header = Table() tactic_header.add_row() tactic_header.add_color("color", "color2") # tactic logo and release info skin = web.get_skin() src = '/context/skins/' + skin + '/images/tactic_logo.png' img = HtmlElement.img(src) img.add_class('hand') img.add_attr('title', 'Go to home page') img.add_behavior({'type': 'click_up', 'cbjs_action': "window.location='/tactic/'"}) rel_div = DivWdg() rel_div.add(" "*3) rel_div.add("Release: %s" %Environment.get_release_version() ) rel_div.add_style("font-size: 9px") # Need this to override the above color in add_looks rel_div.add_color("color", "color2") tactic_wdg = Table() tactic_wdg.add_style("width: 180px") tactic_wdg.add_row() td = tactic_wdg.add_cell( img ) td.set_style("width:100px") tactic_wdg.add_row() td = tactic_wdg.add_cell( rel_div ) td.set_style("text-align: left") td = tactic_header.add_cell( tactic_wdg ) # add the project thumb and title project = Project.get() if my.show_project: thumb_div = DivWdg() td = tactic_header.add_cell( thumb_div ) thumb_div.add_style("height: 28px") thumb_div.add_style("overflow: hidden") thumb_div.add_border(modifier=-10) thumb_div.add_style("-moz-border-radius: 3px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(project) thumb.set_icon_size("45") td.set_style("vertical-align: top; padding-right:14px;padding-left: 3px") td = tactic_header.add_cell( project.get_value("title") ) #td.add_looks( "fnt_title_1" ) td.add_style("font-size: 20px") td.add_style("white-space: nowrap") td.add_style("padding-left: 14px") # project selection td = tactic_header.add_cell() project_div = DivWdg() project_div.add_style("margin-top: -5px") project_div.add(ProjectSelectWdg() ) td.add( project_div ) td.set_style("padding-left: 14px") # Global Actions Gear Menu (contains links to Documentation) ... action_bar_btn_dd = PageHeaderGearMenuWdg() action_div = DivWdg(action_bar_btn_dd) action_div.add_style("margin-top: -5px") td = tactic_header.add_cell( action_div ) if PrefSetting.get_value_by_key('subscription_bar') == 'true': from message_wdg import SubscriptionBarWdg sub = SubscriptionBarWdg(mode='popup') tactic_header.add_cell(sub) # user login # user user = Environment.get_login() full_name = user.get_full_name() user_div = SpanWdg( HtmlElement.b( "%s " % full_name) , css='hand') user_div.set_style("padding-right:10px") # signout login = Environment.get_security().get_login() search_key = SearchKey.get_by_sobject(login) span = SpanWdg() span.add( user_div ) user_div.add_attr('spt_nudge_menu_vert', '20') td = tactic_header.add_cell(span) td.set_style("width:100%; text-align:right; white-space: nowrap") from tactic.ui.widget import SingleButtonWdg button = SingleButtonWdg(title='My Account', icon=IconWdg.USER, show_arrow=True) button_div = DivWdg(button) button_div.add_style("margin-top: -5px") button.add_attr('spt_nudge_menu_horiz', '-80') button.add_attr('spt_nudge_menu_vert', '10') td = tactic_header.add_cell(button_div) menus = my.get_smart_menu() # TODO: this part seems redundant to attach to both SmartMenu.add_smart_menu_set(user_div, [menus]) SmartMenu.assign_as_local_activator(user_div, None, True) SmartMenu.add_smart_menu_set(button, [menus]) SmartMenu.assign_as_local_activator(button, None, True) td.set_style("width:100%;") button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False) #button.add_behavior( { #'type': 'click_up', #'cbjs_action': ''' #window.open("/doc/") #''' #} ) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_help") ''' } ) from tactic.ui.container import DialogWdg help_dialog = DialogWdg(z_index=900, show_pointer=False) td.add(help_dialog) help_dialog.add_title("Help") help_dialog.add_class("spt_help") # container for help help_div = DivWdg() help_dialog.add(help_div) from help_wdg import HelpWdg help_wdg = HelpWdg() help_div.add(help_wdg) button_div = DivWdg(button) button_div.add_style("margin-top: -5px") td = tactic_header.add_cell(button_div) td.set_style("width:100%; text-align:right; white-space: nowrap") # Layout the Main Header Table main_div = DivWdg() # TEST: NEW LAYOUT if Config.get_value("install", "layout") == "fixed": main_div.add_style("position: fixed") main_div.add_style("z-index: 100") main_div.add_style("width: 100%") license = Environment.get_security().get_license() if not license.is_licensed(): from tactic.ui.app import LicenseManagerWdg license_manager = LicenseManagerWdg(use_popup=True) main_div.add(license_manager) # create the header table tactic_header_div = DivWdg() tactic_header_div.add(tactic_header) tactic_header_div.add_gradient("background", "background2", 10, -10) main_div.add(tactic_header_div) main_div.add( my.get_js_popup() ) """ main_div.add( HelpPopupWdg() ) # FIXME: is this even used at all? action_bar_popup = PopupWdg( id="ActionBarWdg_popup", allow_page_activity=True, width="636px" ) action_bar_popup.add_title( "TACTIC™ Action Bar" ) action_bar_popup.add( ActionBarWdg() ) main_div.add( action_bar_popup ) """ # FIXME(?): does this CommonPopup need to be at z_start=300? By default popups will be at z_start=200 popup = PopupWdg( id="CommonPopup", allow_page_activity=True, width="600px", z_start=300 ) popup.add('Tools', 'title') main_div.add( popup ) return main_div
def get_display(self): try: cmd = DatabaseManagerCbk() cmd.execute() except CommandException as e: error = str(e) else: error = None div = DivWdg() div.add_class("spt_database_manager_top") """ security = Environment.get_security() if not security.is_logged_in(): # if there is no database connection, then a user must login as # admin div.add( self.get_login_wdg() ) return div #security = Environment.get_security().get_login() #print(security) error_for_user = DatabaseErrorWdg() div.add(error_for_user) return div """ from tactic.ui.container import PopupWdg popup = PopupWdg(id="DatabaseManagerWdg", width="500px", allow_page_activity="false", display='true', zstart=10000, allow_close='false') popup.add("Database Manager", "title") content = DivWdg() content.add_style("background: #333") content.add_style("padding: 10px") content.add_style("border: solid 1px black") content.add_style("font-size: 1.2em") icon = IconWdg("Setup Manager", IconWdg.CREATE) content.add(icon) content.add("<b>TACTIC Database Manager</b>") content.add("<hr/>") content.add("<br/>") if not error: error = self.kwargs.get("error") if error: error_div = DivWdg() error_div.add_style("border: solid 1px #000") error_div.add_style("padding: 20px") icon = IconWdg("Setup Manager", IconWdg.ERROR) error_div.add(icon) error_div.add("ERROR: ") error_div.add(error) content.add(error_div) content.add("<br/>") content.add("<br/>") content.add( "<b>Please contact your Adminstrator.</b>" ) """ vendor = Config.get_value("database", "vendor") server = Config.get_value("database", "server") user = Config.get_value("database", "user") from pyasm.search import DbPasswordUtil password = DbPasswordUtil.get_password() table = Table(css="table") table.add_style("width: 100%") table.add_row() table.add_cell("Vendor: ") select = SelectWdg("database_vendor") select.set_option("values", "PostgreSQL|Oracle") select.set_value(server) table.add_cell(select) table.add_row() table.add_cell("Server: ") text = TextWdg("database_server") text.set_value(server) table.add_cell(text) table.add_row() table.add_cell("User: :") text = TextWdg("database_user") text.set_value(user) table.add_cell(text) table.add_row() table.add_cell("Password: :") td = table.add_cell() password = PasswordWdg("database_password") td.add(password) table.add_row() table.add_cell("Confirm Password :"******"password2") td.add(password) content.add(table) content.add("<hr/>") from pyasm.widget import ProdIconSubmitWdg, ProdIconButtonWdg test = ProdIconButtonWdg("Test") test.add_event("onclick", "var top=$(this).getParent('.spt_database_manager_top');var values=spt.api.Utility.get_input_values();var server=TacticServerStub.get();var user=values.database_user[0];var result=server.test_database_connection('localhost', {user:user})") #test.add_behavior( { # 'type': 'click_up', # 'cbjs_action': "alert('cow')" #} ) submit = ProdIconSubmitWdg("Save") submit.add_event("onclick", "document.form.submit()") cancel = ProdIconSubmitWdg("Cancel") cancel.add_event("onclick", "document.form.cancel()") button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(test) button_div.add(submit) button_div.add(cancel) content.add(button_div) """ popup.add(content, "content") div.add(popup) #div.add(content) return div
def get_example_display(self): div = DivWdg() div.add_class("SPT_SEARCH_CLASS_TAG_EXAMPLE") div.add("<br/><br/>") tt_div = DivWdg() tt_div.add_styles( "padding: 4px; width: 250px; text-align: center; border: 1px solid white;" ) tt_div.add("DIV in page with class 'SPT_FIND_ME_DIV'") tt_div.add_class("SPT_FIND_ME_DIV") tt_popup = PopupWdg(id="test_popup", allow_page_activity=True, width="600px") tt_popup.add_title("Test Popup") tt_div_p = DivWdg() tt_div_p.add_class("SPT_FIND_ME_POPUP") tt_div_p.add("DIV in POPUP with class 'SPT_FIND_ME_POPUP'") tt_btn_p = DivWdg() tt_btn_p.add_styles( "border: solid 1px white; padding: 4px; width: 200px; text-align: center; cursor: pointer;" ) tt_btn_p.add("find 'SPT_FIND_ME_DIV'") tt_btn_p.add_behavior( { 'type': 'click_up', 'cbjs_action': 'var tmp_el = spt.get_cousin( bvr.src_el, ' \ '".SPT_SEARCH_CLASS_TAG_EXAMPLE", ".SPT_FIND_ME_DIV", [] ); ' \ 'spt.ui_play.set_bg_to_next_basic_color( tmp_el ); ' } ) tt_popup.add(tt_div_p) tt_popup.add("<br/><br/>") tt_popup.add(tt_btn_p) tt_div.add(tt_popup) div.add(tt_div) div.add("<br/><br/>") tt_div2 = DivWdg() tt_div2.add_styles( "border: solid 1px white; padding: 4px; width: 100px; text-align: center; cursor: pointer;" ) tt_div2.add("launch popup") tt_div2.add_behavior({ 'type': 'click_up', 'cbjs_action': 'spt.popup.open( "%s" );' % 'test_popup' }) div.add(tt_div2) div.add("<br/><br/>") tt_div3 = DivWdg() tt_div3.add_styles( "border: solid 1px white; padding: 4px; width: 100px; text-align: center; cursor: pointer;" ) tt_div3.add("find in popup") tt_div3.add_behavior( { 'type': 'click_up', 'cbjs_action': 'var tmp_el = spt.get_cousin( bvr.src_el, ' \ '".SPT_SEARCH_CLASS_TAG_EXAMPLE", ".SPT_FIND_ME_POPUP", [] ); ' \ 'spt.ui_play.set_bg_to_next_basic_color( tmp_el ); ' } ) div.add(tt_div3) div.add("<br/><br/>") return div
def get_display(my): if my.is_popup: icon_chooser_popup_id = "IconChooserPopup" icon_chooser_popup = PopupWdg(id=icon_chooser_popup_id, allow_page_activity=False, width="760px") icon_chooser_popup.add("Icon Chooser", "title") orig_icon_list = IconWdg.icons.keys() icon_list = ['-- No Icon --'] do_not_list = [ 'MAYA', 'HOUDINI', 'PROGRESS', 'CLIP_PLAY', 'XSI', 'CLIP_PAUSE', 'CHECK_OUT_LG','CHECK_OUT','PUBLISH_LG' ] for k in orig_icon_list: if k in do_not_list: continue icon_list.append(k) icon_list.sort() icon_list_len = float(len(icon_list)) num_cols = 5 num_rows = int( math.ceil( icon_list_len / float(num_cols) ) ) chooser_wrapper_div = DivWdg() chooser_wrapper_div.add_class( "SPT_ICON_CHOOSER_WRAPPER_DIV" ) chooser_bkg_rc = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10") chooser_bkg_rc.set_dimensions( width_str='740px', content_height_str='520px' ) table = Table() for r in range(num_rows): table.add_row() for c in range(num_cols): td = table.add_cell() td.add_styles("color: black; overflow: hidden; width: 140px; max-width: 140px; height: 20px;") td.add_styles("border: 1px solid transparent; cursor: pointer;") td.add_behavior( {'type': 'hover', 'mod_styles': 'background-color: #555555;'} ) if c > 0: td.add_styles("border-left-color: black;") idx = int( c * num_rows + r ) if idx < icon_list_len: icon_name = icon_list[ idx ] icon_path = '' if icon_name != '-- No Icon --': icon_path = IconWdg.get_icon_path(icon_name) icon = IconWdg( icon_name, icon_path ) td.add(icon) text_span = SpanWdg() text_span.add_looks( "fnt_code" ) text_span.add_styles( "font-size: 10px" ) if len(icon_name) > 16: text_span.add( "%s..." % icon_name[:15] ) else: text_span.add( icon_name ) td.add( text_span ) if icon_name == '-- No Icon --': icon_name = '' td.add_class( "SPT_ICON_SELECT_%s" % icon_name ) if my.is_popup: cbjs_action = ''' var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV"); cwd.setProperty("spt_icon_selected", "%s"); cwd.setProperty("spt_icon_path", "%s"); spt.popup.close( spt.popup.get_popup( bvr.src_el ) ); spt.named_events.fire_event("%s",bvr); ''' % (icon_name, icon_path,"ICON_CHOOSER_SELECTION_MADE") else: cbjs_action = ''' var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV"); cwd.setProperty("spt_icon_selected", "%s"); cwd.setProperty("spt_icon_path", "%s"); spt.hide( cwd ); spt.named_events.fire_event("%s",bvr); ''' % (icon_name, icon_path,"ICON_CHOOSER_SELECTION_MADE") pass td.add_behavior( {'type': 'click_up', 'cbjs_action': cbjs_action} ) chooser_bkg_rc.add( table ) chooser_wrapper_div.add( chooser_bkg_rc ) if my.is_popup: icon_chooser_popup.add(chooser_wrapper_div, "content") return icon_chooser_popup return div
def get_example_display(self): div = DivWdg() div.add_class("SPT_SEARCH_CLASS_TAG_EXAMPLE") div.add( "<br/><br/>" ) tt_div = DivWdg() tt_div.add_styles("padding: 4px; width: 250px; text-align: center; border: 1px solid white;") tt_div.add("DIV in page with class 'SPT_FIND_ME_DIV'") tt_div.add_class( "SPT_FIND_ME_DIV" ) tt_popup = PopupWdg( id="test_popup", allow_page_activity=True, width="600px" ) tt_popup.add_title("Test Popup") tt_div_p = DivWdg() tt_div_p.add_class("SPT_FIND_ME_POPUP") tt_div_p.add( "DIV in POPUP with class 'SPT_FIND_ME_POPUP'" ) tt_btn_p = DivWdg() tt_btn_p.add_styles( "border: solid 1px white; padding: 4px; width: 200px; text-align: center; cursor: pointer;" ) tt_btn_p.add( "find 'SPT_FIND_ME_DIV'" ) tt_btn_p.add_behavior( { 'type': 'click_up', 'cbjs_action': 'var tmp_el = spt.get_cousin( bvr.src_el, ' \ '".SPT_SEARCH_CLASS_TAG_EXAMPLE", ".SPT_FIND_ME_DIV", [] ); ' \ 'spt.ui_play.set_bg_to_next_basic_color( tmp_el ); ' } ) tt_popup.add( tt_div_p ) tt_popup.add( "<br/><br/>" ) tt_popup.add( tt_btn_p ) tt_div.add( tt_popup ) div.add( tt_div ) div.add( "<br/><br/>" ) tt_div2 = DivWdg() tt_div2.add_styles( "border: solid 1px white; padding: 4px; width: 100px; text-align: center; cursor: pointer;" ) tt_div2.add( "launch popup" ) tt_div2.add_behavior( { 'type': 'click_up', 'cbjs_action': 'spt.popup.open( "%s" );' % 'test_popup' } ) div.add( tt_div2 ) div.add( "<br/><br/>" ) tt_div3 = DivWdg() tt_div3.add_styles( "border: solid 1px white; padding: 4px; width: 100px; text-align: center; cursor: pointer;" ) tt_div3.add( "find in popup" ) tt_div3.add_behavior( { 'type': 'click_up', 'cbjs_action': 'var tmp_el = spt.get_cousin( bvr.src_el, ' \ '".SPT_SEARCH_CLASS_TAG_EXAMPLE", ".SPT_FIND_ME_POPUP", [] ); ' \ 'spt.ui_play.set_bg_to_next_basic_color( tmp_el ); ' } ) div.add( tt_div3 ) div.add( "<br/><br/>" ) return div
def get_display(my): web = WebContainer.get_web() widget = Widget() html = HtmlElement("html") is_xhtml = False if is_xhtml: web.set_content_type("application/xhtml+xml") widget.add('''<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ''') html.add_attr("xmlns", "http://www.w3.org/1999/xhtml") #html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg") # add the copyright widget.add(my.get_copyright_wdg()) widget.add(html) # create the header head = HtmlElement("head") html.add(head) head.add( '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n' ) head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n') # Add the tactic favicon head.add( '<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>' ) # add the css styling head.add(my.get_css_wdg()) # add the title in the header project = Project.get() project_code = project.get_code() project_title = project.get_value("title") if web.is_admin_page(): is_admin = " - Admin" else: is_admin = "" if project_code == 'admin': head.add("<title>TACTIC Site Admin</title>\n") else: head.add("<title>%s%s</title>\n" % (project_title, is_admin)) # add the javascript libraries head.add(JavascriptImportWdg()) # add the body body = my.body html.add(body) body.add_event('onload', 'spt.onload_startup(this)') top = my.top # Add a NOSCRIPT tag block here to provide a warning message on browsers where 'Enable JavaScript' # is not checked ... TODO: clean up and re-style to make look nicer top.add(""" <NOSCRIPT> <div style="border: 2px solid black; background-color: #FFFF99; color: black; width: 600px; height: 70px; padding: 20px;"> <img src="%s" style="border: none;" /> <b>Javascript is not enabled on your browser!</b> <p>This TACTIC powered, web-based application requires JavaScript to be enabled in order to function. In your browser's options/preferences, please make sure that the 'Enable JavaScript' option is checked on, click OK to accept the settings change, and then refresh this web page.</p> </div> </NOSCRIPT> """ % (IconWdg.get_icon_path("ERROR"))) # add the content content_div = DivWdg() top.add(content_div) Container.put("TopWdg::content", content_div) # add a dummy button for global behaviors from tactic.ui.widget import ButtonNewWdg, IconButtonWdg ButtonNewWdg(title="DUMMY", icon=IconWdg.FILM) IconButtonWdg(title="DUMMY", icon=IconWdg.FILM) # NOTE: it does not need to be in the DOM. Just needs to be # instantiated #content_div.add(button) if my.widgets: content_wdg = my.get_widget('content') else: content_wdg = Widget() my.add(content_wdg) content_div.add(content_wdg) # add a calendar wdg from tactic.ui.widget import CalendarWdg cal_wdg = CalendarWdg(css_class='spt_calendar_template_top') cal_wdg.top.add_style('display: none') content_div.add(cal_wdg) if web.is_admin_page(): from tactic_branding_wdg import TacticCopyrightNoticeWdg branding = TacticCopyrightNoticeWdg(show_license_info=True) top.add(branding) # add the admin bar security = Environment.get_security() if not web.is_admin_page() and security.check_access( "builtin", "view_site_admin", "allow"): div = DivWdg() top.add(div) top.add_style("padding-top: 21px") div.add_class("spt_admin_bar") div.add_style("height: 15px") div.add_style("padding: 3px 0px 3px 15px") #div.add_style("margin-bottom: -5px") div.add_style("position: fixed") div.add_style("top: 0px") div.add_style("left: 0px") div.add_style("opacity: 0.7") div.add_style("width: 100%") #div.add_gradient("background", "background2", 20, 10) div.add_style("background-color", "#000") div.add_style("color", "#FFF") div.add_style("z-index", "1000") div.add_class("hand") div.set_box_shadow("0px 5px 5px") # remove icon_div = DivWdg() div.add(icon_div) icon_div.add_style("float: right") icon_div.add_style("margin-right: 10px") icon_div.add_style("margin-top: -3px") icon_button = IconButtonWdg(title="Remove Admin Bar", icon=IconWdg.G_CLOSE) icon_div.add(icon_button) icon_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var parent = bvr.src_el.getParent(".spt_admin_bar"); bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(parent); ''' }) div.add("<b>ADMIN >></b>") div.add_behavior({ 'type': 'listen', 'event_name': 'close_admin_bar', 'cbjs_action': ''' bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(bvr.src_el); ''' }) div.add_behavior({ 'type': 'mouseover', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.85) //new Fx.Tween(bvr.src_el).start('height', "30px"); ''' }) div.add_behavior({ 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.7) //new Fx.Tween(bvr.src_el).start('height', "15px"); ''' }) project_code = Project.get_project_code() div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var url = "/tactic/%s/admin/link/_startup"; window.open(url); ''' % project_code }) # Add the script editor listener load_div = DivWdg() top.add(load_div) load_div.add_behavior({ 'type': 'listen', 'event_name': 'show_script_editor', 'cbjs_action': ''' var js_popup_id = "TACTIC Script Editor"; var js_popup = $(js_popup_id); if( js_popup ) { spt.popup.toggle_display( js_popup_id, false ); } else { spt.panel.load_popup(js_popup_id, "tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} ); } ''' }) # deal with the palette defined in /index which can override the palette if my.kwargs.get("hash") == (): key = "index" search = Search("config/url") search.add_filter("url", "/%s/%%" % key, "like") search.add_filter("url", "/%s" % key) search.add_where("or") url = search.get_sobject() if url: xml = url.get_xml_value("widget") palette_key = xml.get_value("element/@palette") # look up palette the expression for index from pyasm.web import Palette palette = Palette.get() palette.set_palette(palette_key) colors = palette.get_colors() colors = jsondumps(colors) script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_colors(%s); env.set_palette('%s'); ''' % (colors, palette_key)) top.add(script) env = Environment.get() client_handoff_dir = env.get_client_handoff_dir(include_ticket=False, no_exception=True) client_asset_dir = env.get_client_repo_dir() login = Environment.get_login() user_name = login.get_value("login") user_id = login.get_id() login_groups = Environment.get_group_names() # add environment information script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_project('%s'); env.set_user('%s'); env.set_user_id('%s'); var login_groups = '%s'.split('|'); env.set_login_groups(login_groups); env.set_client_handoff_dir('%s'); env.set_client_repo_dir('%s'); ''' % (Project.get_project_code(), user_name, user_id, '|'.join(login_groups), client_handoff_dir, client_asset_dir)) top.add(script) # add a global container for commonly used widgets div = DivWdg() top.add(div) div.set_id("global_container") # add in the app busy widget # find out if there is an override for this search = Search("config/url") search.add_filter("url", "/app_busy") url = search.get_sobject() if url: busy_div = DivWdg() div.add(busy_div) busy_div.add_class("SPT_PUW") busy_div.add_styles( "display: none; position: absolute; z-index: 1000") busy_div.add_class("app_busy_msg_block") busy_div.add_style("width: 300px") busy_div.add_style("height: 100px") busy_div.add_style("padding: 20px") busy_div.add_color("background", "background3") busy_div.add_border() busy_div.set_box_shadow() busy_div.set_round_corners(20) busy_div.set_attr("id", "app_busy_msg_block") # put the custom url here title_wdg = DivWdg() busy_div.add(title_wdg) title_wdg.add_style("font-size: 20px") title_wdg.add_class("spt_app_busy_title") busy_div.add("<hr/>") msg_div = DivWdg() busy_div.add(msg_div) msg_div.add_class("spt_app_busy_msg") else: from page_header_wdg import AppBusyWdg div.add(AppBusyWdg()) # popup parent popup = DivWdg() popup.set_id("popup") div.add(popup) # create another general popup popup_div = DivWdg() popup_div.set_id("popup_container") popup_div.add_class("spt_panel") popup = PopupWdg(id="popup_template", destroy_on_close=True) popup_div.add(popup) div.add(popup_div) inner_html_div = DivWdg() inner_html_div.set_id("inner_html") div.add(inner_html_div) # add in a global color from tactic.ui.input import ColorWdg color = ColorWdg() div.add(color) # add in a global notify wdg from notify_wdg import NotifyWdg widget.add(NotifyWdg()) return widget
def get_display(self): try: cmd = DatabaseManagerCbk() cmd.execute() except CommandException as e: error = str(e) else: error = None div = DivWdg() div.add_class("spt_database_manager_top") """ security = Environment.get_security() if not security.is_logged_in(): # if there is no database connection, then a user must login as # admin div.add( self.get_login_wdg() ) return div #security = Environment.get_security().get_login() #print(security) error_for_user = DatabaseErrorWdg() div.add(error_for_user) return div """ from tactic.ui.container import PopupWdg popup = PopupWdg(id="DatabaseManagerWdg", width="500px", allow_page_activity="false", display='true', zstart=10000, allow_close='false') popup.add("Database Manager", "title") content = DivWdg() content.add_style("background: #333") content.add_style("padding: 10px") content.add_style("border: solid 1px black") content.add_style("font-size: 1.2em") icon = IconWdg("Setup Manager", IconWdg.CREATE) content.add(icon) content.add("<b>TACTIC Database Manager</b>") content.add("<hr/>") content.add("<br/>") if not error: error = self.kwargs.get("error") if error: error_div = DivWdg() error_div.add_style("border: solid 1px #000") error_div.add_style("padding: 20px") icon = IconWdg("Setup Manager", IconWdg.ERROR) error_div.add(icon) error_div.add("ERROR: ") error_div.add(error) content.add(error_div) content.add("<br/>") content.add("<br/>") content.add("<b>Please contact your Adminstrator.</b>") """ vendor = Config.get_value("database", "vendor") server = Config.get_value("database", "server") user = Config.get_value("database", "user") from pyasm.search import DbPasswordUtil password = DbPasswordUtil.get_password() table = Table(css="table") table.add_style("width: 100%") table.add_row() table.add_cell("Vendor: ") select = SelectWdg("database_vendor") select.set_option("values", "PostgreSQL|Oracle") select.set_value(server) table.add_cell(select) table.add_row() table.add_cell("Server: ") text = TextWdg("database_server") text.set_value(server) table.add_cell(text) table.add_row() table.add_cell("User: :") text = TextWdg("database_user") text.set_value(user) table.add_cell(text) table.add_row() table.add_cell("Password: :") td = table.add_cell() password = PasswordWdg("database_password") td.add(password) table.add_row() table.add_cell("Confirm Password :"******"password2") td.add(password) content.add(table) content.add("<hr/>") from pyasm.widget import ProdIconSubmitWdg, ProdIconButtonWdg test = ProdIconButtonWdg("Test") test.add_event("onclick", "var top=$(this).getParent('.spt_database_manager_top');var values=spt.api.Utility.get_input_values();var server=TacticServerStub.get();var user=values.database_user[0];var result=server.test_database_connection('localhost', {user:user})") #test.add_behavior( { # 'type': 'click_up', # 'cbjs_action': "alert('cow')" #} ) submit = ProdIconSubmitWdg("Save") submit.add_event("onclick", "document.form.submit()") cancel = ProdIconSubmitWdg("Cancel") cancel.add_event("onclick", "document.form.cancel()") button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(test) button_div.add(submit) button_div.add(cancel) content.add(button_div) """ popup.add(content, "content") div.add(popup) #div.add(content) return div