def get_display(self): # NOTE: need to add this to fit as a table layout self.chunk_size = 10000 self.edit_permission = True self.view_editable = True search_key = self.kwargs.get("search_key") if search_key: sobject = Search.get_by_search_key(search_key) self.sobjects = [sobject] elif self.kwargs.get("do_search") != "false": self.handle_search() top = DivWdg() self.top = top self.set_as_panel(top) top.add_class("spt_sobject_top") inner = DivWdg() top.add(inner) inner.add_color("background", "background") inner.add_color("color", "color") # NOTE: this is not the table and is called this for backwards # compatibility inner.add_class("spt_table") inner.add_class("spt_layout") # set the sobjects to all the widgets then preprocess for widget in self.widgets: widget.set_sobjects(self.sobjects) widget.set_parent_wdg(self) # preprocess the elements widget.preprocess() #is_refresh = self.kwargs.get("is_refresh") #if self.kwargs.get("show_shelf") not in ['false', False]: # action = self.get_action_wdg() # inner.add(action) # get all the edit widgets """ if self.view_editable and self.edit_permission: edit_wdgs = self.get_edit_wdgs() edit_div = DivWdg() edit_div.add_class("spt_edit_top") edit_div.add_style("display: none") inner.add(edit_div) for name, edit_wdg in edit_wdgs.items(): edit_div.add(edit_wdg) """ inner.set_unique_id() inner.add_smart_style("spt_header", "vertical-align", "top") inner.add_smart_style("spt_header", "text-align", "left") inner.add_smart_style("spt_header", "width", "150px") inner.add_smart_style("spt_header", "padding", "5px") border = inner.get_color("table_border") #inner.add_smart_style("spt_header", "border", "solid 1px %s" % border) inner.add_smart_style("spt_cell_edit", "background-repeat", "no-repeat") inner.add_smart_style("spt_cell_edit", "background-position", "bottom right") inner.add_smart_style("spt_cell_edit", "padding", "5px") inner.add_smart_style("spt_cell_edit", "min-width", "200px") for i, sobject in enumerate(self.sobjects): table = Table() table.add_color("color", "color") table.add_style("padding: 10px") #table.add_style("margin-bottom: 10px") table.add_style("width: 100%") inner.add(table) for j, widget in enumerate(self.widgets): name = widget.get_name() if name == 'preview': continue widget.set_current_index(i) title = widget.get_title() tr = table.add_row() if isinstance(title, HtmlElement): title.add_style("float: left") th = table.add_header(title) th.add_class("spt_header") td = table.add_cell(widget.get_buffer_display()) td.add_class("spt_cell_edit") if j % 2 == 0: tr.add_color("background-color", "background", -1) else: tr.add_color("background-color", "background") # indicator that a cell is editable #td.add_event( "onmouseover", "$(this).setStyle('background-image', " \ # "'url(/context/icons/silk/page_white_edit.png)')" ) #td.add_event( "onmouseout", "$(this).setStyle('background-image', '')") # extra stuff to make it work with ViewPanelWdg top.add_class("spt_table_top") class_name = Common.get_full_class_name(self) top.add_attr("spt_class_name", class_name) inner.add_class("spt_table_content") inner.add_attr("spt_search_type", self.kwargs.get('search_type')) inner.add_attr("spt_view", self.kwargs.get('view')) if self.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_display(my): top = my.top my.set_as_panel(top) top.add_style("width: 500px") template_dir = my.kwargs.get("template_dir") manifest_path = "%s/manifest.xml" % template_dir f = open(manifest_path) manifest_xml = f.read() f.close() template = os.path.basename(template_dir) button = ActionButtonWdg(title="Delete", tip="Delete template from installation") button.add_style("float: right") top.add(button) button.add_behavior( { 'type': 'click_up', 'template': template, 'cbjs_action': ''' var template = bvr.template; if (!confirm("Are you sure you wish to delete the ["+template+"] template?") ) { return; } var cmd = "tactic.ui.app.ProjectTemplateDeleteCmd"; var server = TacticServerStub.get(); spt.app_busy.show("Removing Template", template) var kwargs = { 'template': template } try { server.execute_cmd(cmd, kwargs); var top = bvr.src_el.getParent(".spt_project_template_top"); spt.panel.refresh(top); } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); ''' } ) button = ActionButtonWdg(title="Save As", tip="Save template as file") button.add_style("float: right") top.add(button) button.add_behavior( { 'type': 'click_up', 'template_dir': template_dir, 'cbjs_action': ''' var applet = spt.Applet.get(); var dirname = applet.open_file_browser(); if (!dirname) { return; } var class_name = 'tactic.ui.app.ProjectTemplateDownloadCmd'; var kwargs = { 'template_dir': bvr.template_dir } var server = TacticServerStub.get(); var ret_val = server.execute_cmd(class_name, kwargs); var info = ret_val['info']; var filename = info['filename']; var env = spt.Environment.get(); var ticket = env.get_ticket(); var server = env.get_server_url(); var url = server + "/assets/_cache/" + ticket + "/" + filename; applet.download_file(url, dirname + "/" + filename); applet.open_explorer(dirname); ''' } ) #button = ActionButtonWdg(title="Dump", tip="Create a template from a project") #button.add_style("float: right") #top.add(button) #button.add_behavior( { # 'type': 'click_up', # 'cbjs_action': ''' # ''' #} ) info_div = DivWdg() top.add(info_div) info_div.add_style("padding: 20px") info_div.set_unique_id() info_div.add_smart_style("spt_none", "font-style", "italic") info_div.add_smart_style("spt_none", "opacity", "0.5") #project = Project.get() # import the transaction data from tactic.command import PluginInstaller installer = PluginInstaller(manifest=manifest_xml) project_path = "%s/%s" % (template_dir, "sthpw_project.spt") jobs = installer.import_data(project_path, commit=False) project = jobs[0] project_code = project.get_code() info_div.add("<br/>") info_div.add("Template Code: <b>%s</b><br/>" % project_code) info_div.add("<br/>") info_div.add("Title: <b>%s</b><br/>" % project.get_value("title")) info_div.add("<br/>") description = project.get_value("description", no_exception=True) if not description: description = "<span class='spt_none'>None</span>" info_div.add("Description: %s<br/>" % description) info_div.add("<br/>") version = project.get_value("version", no_exception=True) if not version: version = "<span class='spt_none'>None</span>" info_div.add("Version: %s<br/>" % version) info_div.add("<br/>") status = project.get_value("status", no_exception=True) if not status: status = "<span class='spt_none'>None</span>" info_div.add("Status: %s<br/>" % status ) info_div.add("<br/>") top.add("<span style='opacity: 0.5'>Manifest Path: %s</span>" % manifest_path) return top
def get_display(self): top = DivWdg() top.add_color("background", "background") top.add_color("color", "color") top.add_style("min-width: 600px") os_name = os.name top.set_unique_id() top.add_smart_style("spt_info_title", "background", self.top.get_color("background3")) top.add_smart_style("spt_info_title", "padding", "3px") top.add_smart_style("spt_info_title", "font-weight", "bold") # server title_div = DivWdg() top.add(title_div) title_div.add("Server") title_div.add_class("spt_info_title") os_div = DivWdg() top.add(os_div) os_info = platform.uname() try: os_login = os.getlogin() except Exception: os_login = os.environ.get("LOGNAME") table = Table() table.add_color("color", "color") table.add_style("margin: 10px") os_div.add(table) for i, title in enumerate( ['OS', 'Node Name', 'Release', 'Version', 'Machine']): table.add_row() td = table.add_cell("%s: " % title) td.add_style("width: 150px") table.add_cell(os_info[i]) table.add_row() table.add_cell("CPU Count: ") try: import multiprocessing table.add_cell(multiprocessing.cpu_count()) except (ImportError, NotImplementedError): table.add_cell("n/a") table.add_row() table.add_cell("Login: "******"Python") title_div.add_class("spt_info_title") table = Table() table.add_color("color", "color") table.add_style("margin: 10px") top.add(table) table.add_row() td = table.add_cell("Version: ") td.add_style("width: 150px") table.add_cell(sys.version) # client title_div = DivWdg() top.add(title_div) title_div.add("Client") title_div.add_class("spt_info_title") web = WebContainer.get_web() user_agent = web.get_env("HTTP_USER_AGENT") table = Table() table.add_color("color", "color") table.add_style("margin: 10px") top.add(table) table.add_row() td = table.add_cell("User Agent: ") td.add_style("width: 150px") table.add_cell(user_agent) table.add_row() td = table.add_cell("TACTIC User: "******"Performance Test") title_div.add_class("spt_info_title") performance_wdg = PerformanceWdg() top.add(performance_wdg) top.add('<br/>') # mail server title_div = DivWdg() top.add(title_div) title_div.add("Mail Server") title_div.add_class("spt_info_title") table = Table(css='email_server') table.add_color("color", "color") table.add_style("margin: 10px") top.add(table) table.add_row() td = table.add_cell("Server: ") td.add_style("width: 150px") mailserver = Config.get_value("services", "mailserver") has_mailserver = True if mailserver: table.add_cell(mailserver) else: table.add_cell("None configured") has_mailserver = False login = Login.get_by_login('admin') login_email = login.get_value('email') table.add_row() td = table.add_cell("From: ") td.add_style("width: 150px") text = TextWdg('email_from') text.set_attr('size', '40') text.set_value(login_email) text.add_class('email_from') table.add_cell(text) table.add_row() td = table.add_cell("To: ") td.add_style("width: 150px") text = TextWdg('email_to') text.set_attr('size', '40') text.add_class('email_to') text.set_value(login_email) table.add_cell(text) button = ActionButtonWdg(title='Email Send Test') table.add_row_cell('<br/>') table.add_row() table.add_cell(button) button.add_style("float: right") button.add_behavior({ 'type': 'click_up', 'has_mailserver': has_mailserver, 'cbjs_action': ''' if (!bvr.has_mailserver) { spt.alert('You have to fill in mailserver and possibly other mail related options in the TACTIC config file to send email.'); return; } var s = TacticServerStub.get(); try { spt.app_busy.show('Sending email'); var from_txt = bvr.src_el.getParent('.email_server').getElement('.email_from'); var to_txt = bvr.src_el.getParent('.email_server').getElement('.email_to'); var rtn = s.execute_cmd('pyasm.command.EmailTriggerTestCmd', {'sender_email': from_txt.value, 'recipient_emails': to_txt.value.split(','), 'msg': 'Simple Email Test by TACTIC'} ); if (rtn.status == 'OK') { spt.info("Email sent successfully to " + to_txt.value) } } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); ''' }) top.add('<br/>') self.handle_directories(top) #table.add_row() #td = table.add_cell("TACTIC User: ") #table.add_cell( web.get_user_name() ) top.add('<br/>') top.add(DivWdg('Link Test', css='spt_info_title')) top.add('<br/>') top.add(LinkLoadTestWdg()) top.add('<br/>') self.handle_python_script_test(top) top.add('<br/>') self.handle_sidebar_clear(top) return top
def get_display(self): # NOTE: need to add this to fit as a table layout self.chunk_size = 10000 self.edit_permission = True self.view_editable = True search_key = self.kwargs.get("search_key") if search_key: sobject = Search.get_by_search_key(search_key) self.sobjects = [sobject] elif self.kwargs.get("do_search") != "false": self.handle_search() top = DivWdg() self.top = top self.set_as_panel(top) top.add_class("spt_sobject_top") inner = DivWdg() top.add(inner) inner.add_color("background", "background") inner.add_color("color", "color") # NOTE: this is not the table and is called this for backwards # compatibility inner.add_class("spt_table") inner.add_class("spt_layout") # set the sobjects to all the widgets then preprocess for widget in self.widgets: widget.set_sobjects(self.sobjects) widget.set_parent_wdg(self) # preprocess the elements widget.preprocess() #is_refresh = self.kwargs.get("is_refresh") #if self.kwargs.get("show_shelf") not in ['false', False]: # action = self.get_action_wdg() # inner.add(action) # get all the edit widgets """ if self.view_editable and self.edit_permission: edit_wdgs = self.get_edit_wdgs() edit_div = DivWdg() edit_div.add_class("spt_edit_top") edit_div.add_style("display: none") inner.add(edit_div) for name, edit_wdg in edit_wdgs.items(): edit_div.add(edit_wdg) """ inner.set_unique_id() inner.add_smart_style("spt_header", "vertical-align", "top") inner.add_smart_style("spt_header", "text-align", "left") inner.add_smart_style("spt_header", "width", "150px") inner.add_smart_style("spt_header", "padding", "5px") border = inner.get_color("table_border") #inner.add_smart_style("spt_header", "border", "solid 1px %s" % border) inner.add_smart_style("spt_cell_edit", "background-repeat", "no-repeat") inner.add_smart_style("spt_cell_edit", "background-position", "bottom right") inner.add_smart_style("spt_cell_edit", "padding", "5px") inner.add_smart_style("spt_cell_edit", "min-width", "200px") for i, sobject in enumerate(self.sobjects): table = Table() table.add_color("color", "color") table.add_style("padding: 10px") #table.add_style("margin-bottom: 10px") table.add_style("width: 100%") inner.add(table) for j, widget in enumerate(self.widgets): name = widget.get_name() if name == 'preview': continue widget.set_current_index(i) title = widget.get_title() tr = table.add_row() if isinstance(title, HtmlElement): title.add_style("float: left") th = table.add_header(title) th.add_class("spt_header") td = table.add_cell(widget.get_buffer_display()) td.add_class("spt_cell_edit") if j % 2 == 0: tr.add_color("background-color", "background", -1) else: tr.add_color("background-color", "background") # indicator that a cell is editable #td.add_event( "onmouseover", "$(this).setStyle('background-image', " \ # "'url(/context/icons/silk/page_white_edit.png)')" ) #td.add_event( "onmouseout", "$(this).setStyle('background-image', '')") # extra stuff to make it work with ViewPanelWdg top.add_class("spt_table_top"); class_name = Common.get_full_class_name(self) top.add_attr("spt_class_name", class_name) inner.add_class("spt_table_content"); inner.add_attr("spt_search_type", self.kwargs.get('search_type')) inner.add_attr("spt_view", self.kwargs.get('view')) if self.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_display(self): top = DivWdg() top.add_color("background", "background") top.add_color("color", "color") top.add_style("min-width: 600px") os_name = os.name top.set_unique_id() top.add_smart_style("spt_info_title", "background", self.top.get_color("background3")) top.add_smart_style("spt_info_title", "padding", "3px") top.add_smart_style("spt_info_title", "font-weight", "bold") # server title_div = DivWdg() top.add(title_div) title_div.add("Server") title_div.add_class("spt_info_title") os_div = DivWdg() top.add(os_div) os_info = platform.uname() try: os_login = os.getlogin() except Exception: os_login = os.environ.get("LOGNAME") table = Table() table.add_color("color", "color") table.add_style("margin: 10px") os_div.add(table) for i, title in enumerate(['OS','Node Name','Release','Version','Machine']): table.add_row() td = table.add_cell("%s: " % title) td.add_style("width: 150px") table.add_cell( os_info[i] ) table.add_row() table.add_cell("CPU Count: ") try : import multiprocessing table.add_cell( multiprocessing.cpu_count() ) except (ImportError, NotImplementedError): table.add_cell( "n/a" ) table.add_row() table.add_cell("Login: "******"Python") title_div.add_class("spt_info_title") table = Table() table.add_color("color", "color") table.add_style("margin: 10px") top.add(table) table.add_row() td = table.add_cell("Version: ") td.add_style("width: 150px") table.add_cell( sys.version ) # client title_div = DivWdg() top.add(title_div) title_div.add("Client") title_div.add_class("spt_info_title") web = WebContainer.get_web() user_agent = web.get_env("HTTP_USER_AGENT") table = Table() table.add_color("color", "color") table.add_style("margin: 10px") top.add(table) table.add_row() td = table.add_cell("User Agent: ") td.add_style("width: 150px") table.add_cell( user_agent ) table.add_row() td = table.add_cell("TACTIC User: "******"Performance Test") title_div.add_class("spt_info_title") performance_wdg = PerformanceWdg() top.add(performance_wdg) top.add('<br/>') # mail server title_div = DivWdg() top.add(title_div) title_div.add("Mail Server") title_div.add_class("spt_info_title") table = Table(css='email_server') table.add_color("color", "color") table.add_style("margin: 10px") top.add(table) table.add_row() td = table.add_cell("Server: ") td.add_style("width: 150px") mailserver = Config.get_value("services", "mailserver") has_mailserver = True if mailserver: table.add_cell( mailserver ) else: table.add_cell("None configured") has_mailserver = False login = Login.get_by_login('admin') login_email = login.get_value('email') table.add_row() td = table.add_cell("From: ") td.add_style("width: 150px") text = TextWdg('email_from') text.set_attr('size', '40') text.set_value(login_email) text.add_class('email_from') table.add_cell(text) table.add_row() td = table.add_cell("To: ") td.add_style("width: 150px") text = TextWdg('email_to') text.set_attr('size', '40') text.add_class('email_to') text.set_value(login_email) table.add_cell(text) button = ActionButtonWdg(title='Email Send Test') table.add_row_cell('<br/>') table.add_row() table.add_cell(button) button.add_style("float: right") button.add_behavior( { 'type': 'click_up', 'has_mailserver': has_mailserver, 'cbjs_action': ''' if (!bvr.has_mailserver) { spt.alert('You have to fill in mailserver and possibly other mail related options in the TACTIC config file to send email.'); return; } var s = TacticServerStub.get(); try { spt.app_busy.show('Sending email'); var from_txt = bvr.src_el.getParent('.email_server').getElement('.email_from'); var to_txt = bvr.src_el.getParent('.email_server').getElement('.email_to'); var rtn = s.execute_cmd('pyasm.command.EmailTriggerTestCmd', {'sender_email': from_txt.value, 'recipient_emails': to_txt.value.split(','), 'msg': 'Simple Email Test by TACTIC'} ); if (rtn.status == 'OK') { spt.info("Email sent successfully to " + to_txt.value) } } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); ''' }) top.add('<br/>') self.handle_directories(top) #table.add_row() #td = table.add_cell("TACTIC User: ") #table.add_cell( web.get_user_name() ) top.add('<br/>') top.add(DivWdg('Link Test', css='spt_info_title')) top.add('<br/>') top.add(LinkLoadTestWdg()) top.add('<br/>') self.handle_python_script_test(top) top.add('<br/>') self.handle_sidebar_clear(top) return top
def get_display(self): top = self.top self.set_as_panel(top) top.add_style("width: 500px") template_dir = self.kwargs.get("template_dir") manifest_path = "%s/manifest.xml" % template_dir f = open(manifest_path) manifest_xml = f.read() f.close() template = os.path.basename(template_dir) button = ActionButtonWdg(title="Delete", tip="Delete template from installation") button.add_style("float: right") top.add(button) button.add_behavior( { 'type': 'click_up', 'template': template, 'cbjs_action': ''' var template = bvr.template; if (!confirm("Are you sure you wish to delete the ["+template+"] template?") ) { return; } var cmd = "tactic.ui.app.ProjectTemplateDeleteCmd"; var server = TacticServerStub.get(); spt.app_busy.show("Removing Template", template) var kwargs = { 'template': template } try { server.execute_cmd(cmd, kwargs); var top = bvr.src_el.getParent(".spt_project_template_top"); spt.panel.refresh(top); } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); ''' } ) button = ActionButtonWdg(title="Save As", tip="Save template as file") button.add_style("float: right") top.add(button) button.add_behavior( { 'type': 'click_up', 'template_dir': template_dir, 'cbjs_action': ''' var applet = spt.Applet.get(); var dirname = applet.open_file_browser(); if (!dirname) { return; } var class_name = 'tactic.ui.app.ProjectTemplateDownloadCmd'; var kwargs = { 'template_dir': bvr.template_dir } var server = TacticServerStub.get(); var ret_val = server.execute_cmd(class_name, kwargs); var info = ret_val['info']; var filename = info['filename']; var env = spt.Environment.get(); var ticket = env.get_ticket(); var server = env.get_server_url(); var url = server + "/assets/_cache/" + ticket + "/" + filename; applet.download_file(url, dirname + "/" + filename); applet.open_explorer(dirname); ''' } ) #button = ActionButtonWdg(title="Dump", tip="Create a template from a project") #button.add_style("float: right") #top.add(button) #button.add_behavior( { # 'type': 'click_up', # 'cbjs_action': ''' # ''' #} ) info_div = DivWdg() top.add(info_div) info_div.add_style("padding: 20px") info_div.set_unique_id() info_div.add_smart_style("spt_none", "font-style", "italic") info_div.add_smart_style("spt_none", "opacity", "0.5") #project = Project.get() # import the transaction data from tactic.command import PluginInstaller installer = PluginInstaller(manifest=manifest_xml) project_path = "%s/%s" % (template_dir, "sthpw_project.spt") jobs = installer.import_data(project_path, commit=False) project = jobs[0] project_code = project.get_code() info_div.add("<br/>") info_div.add("Template Code: <b>%s</b><br/>" % project_code) info_div.add("<br/>") info_div.add("Title: <b>%s</b><br/>" % project.get_value("title")) info_div.add("<br/>") description = project.get_value("description", no_exception=True) if not description: description = "<span class='spt_none'>None</span>" info_div.add("Description: %s<br/>" % description) info_div.add("<br/>") version = project.get_value("version", no_exception=True) if not version: version = "<span class='spt_none'>None</span>" info_div.add("Version: %s<br/>" % version) info_div.add("<br/>") status = project.get_value("status", no_exception=True) if not status: status = "<span class='spt_none'>None</span>" info_div.add("Status: %s<br/>" % status ) info_div.add("<br/>") top.add("<span style='opacity: 0.5'>Manifest Path: %s</span>" % manifest_path) return top