def get_display(self): # Set up the outer <div> to hold all the form elements outer_div = DivWdg() outer_div.add_class('new-order-entry-form') outer_div.set_id('new-order-entry-form') # Set up the <input> widget for 'name' outer_div.add(HtmlElement.label('Name')) name_input = TextInputWdg(name='name') outer_div.add(name_input) # Set up the <input> widget for 'po_number' outer_div.add(HtmlElement.label('PO Number')) po_number_input = TextInputWdg() po_number_input.set_name('po_number') outer_div.add(po_number_input) # Set up the <select> widget and it's options for 'client' outer_div.add(HtmlElement.label('Client')) client_select_wdg = get_select_widget_from_search_type('twog/client', 'client', 'name', 'code') outer_div.add(client_select_wdg) # Set up the Save button save_button = SubmitWdg('Save') save_button.add_behavior(self.save_button_behavior()) outer_div.add(save_button) # Set up the Save and Add button save_and_add_button = SubmitWdg('Save and Add') save_and_add_button.add_behavior(self.save_and_add_button_behavior()) outer_div.add(save_and_add_button) return outer_div
def get_display(self): outer_div = DivWdg() outer_div.add_class('new-work-order-entry-form') page_label = "Work Order for {0}".format(self.title_order) outer_div.add(page_label) process_input = TextInputWdg() process_input.set_name('process') outer_div.add(get_label_widget('Process')) outer_div.add(process_input) instructions_input = TextAreaInputWdg() instructions_input.set_name('instructions') outer_div.add(get_label_widget('Instructions')) outer_div.add(instructions_input) description_input = TextAreaInputWdg() description_input.set_name('description') outer_div.add(get_label_widget('Description (Optional)')) outer_div.add(description_input) submit_button = SubmitWdg('Submit') submit_button.add_behavior(self.submit_button_behavior()) outer_div.add(submit_button) return outer_div
def get_display(self): # Set up the outer <div> to hold all the form elements outer_div = DivWdg() outer_div.add_class('new-order-entry-form') outer_div.set_id('new-order-entry-form') # Set up the <input> widget for 'name' outer_div.add(HtmlElement.label('Name')) name_input = TextInputWdg(name='name') outer_div.add(name_input) # Set up the <input> widget for 'po_number' outer_div.add(HtmlElement.label('PO Number')) po_number_input = TextInputWdg() po_number_input.set_name('po_number') outer_div.add(po_number_input) # Set up the <select> widget and it's options for 'client' outer_div.add(HtmlElement.label('Client')) client_select_wdg = get_select_widget_from_search_type( 'twog/client', 'client', 'name', 'code') outer_div.add(client_select_wdg) # Set up the Save button save_button = SubmitWdg('Save') save_button.add_behavior(self.save_button_behavior()) outer_div.add(save_button) # Set up the Save and Add button save_and_add_button = SubmitWdg('Save and Add') save_and_add_button.add_behavior(self.save_and_add_button_behavior()) outer_div.add(save_and_add_button) return outer_div
def get_text_input_wdg(name, width=200, pretext=None): textbox_wdg = TextInputWdg() textbox_wdg.set_id(name) textbox_wdg.set_name(name) textbox_wdg.add_style('width', '{0}px'.format(width)) if pretext: textbox_wdg.set_value(pretext) return textbox_wdg
def get_text_input_wdg(self, field_name, width=200): textbox_wdg = TextInputWdg() textbox_wdg.set_id(field_name) textbox_wdg.set_name(field_name) textbox_wdg.add_style('width', '{0}px'.format(width)) if hasattr(self, field_name): textbox_wdg.set_value(getattr(self, field_name)) return textbox_wdg
def get_name_input_wdg(self, width=500): textbox_wdg = TextInputWdg() textbox_wdg.set_id('name_data') textbox_wdg.set_name('name_data') textbox_wdg.add_style('width', '{0}px'.format(width)) try: textbox_wdg.set_value(self.prequal_eval_sobject.get('name')) except AttributeError: pass return textbox_wdg
def get_text_input_wdg(self, field_name, width=200): textbox_wdg = TextInputWdg() textbox_wdg.set_id(field_name) textbox_wdg.set_name(field_name) textbox_wdg.add_style('width', '{0}px'.format(width)) try: textbox_wdg.set_value(self.prequal_eval_sobject.get(field_name)) except AttributeError: pass return textbox_wdg
def get_text_input_wdg_for_audio_config(self, name, width=200, line_data=None): textbox_wdg = TextInputWdg() textbox_wdg.set_id(name) textbox_wdg.set_name(name) textbox_wdg.add_style('width', '{0}px'.format(width)) if line_data: textbox_wdg.set_value(line_data) return textbox_wdg
def get_text_input_wdg(name, width=200, line_data=None): textbox_wdg = TextInputWdg() textbox_wdg.set_id(name) textbox_wdg.set_name(name) textbox_wdg.add_style('width', '{0}px'.format(width)) if line_data: textbox_wdg.set_value(line_data) return textbox_wdg
def get_add_chat_wdg(my): div = DivWdg() div.add_border() div.add_style("padding: 20px") div.add_class("spt_add_chat_top") table = Table() table.add_style("width: auto") div.add(table) table.add_row() text = TextInputWdg(title="user", icon="USER_ADD") table.add_cell(text) text.add_class("spt_add_chat_user") add_button = ActionButtonWdg(title="Start Chat") table.add_cell(add_button) add_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_add_chat_top"); var el = top.getElement(".spt_add_chat_user"); var user = el.value; if (!user) { alert("Specify a valid user to chat with"); return; } // new chat var server = TacticServerStub.get(); var category = "chat"; var class_name = 'tactic.ui.app.ChatCmd'; var kwargs = { users: [user] } server.execute_cmd(class_name, kwargs); spt.panel.refresh(bvr.src_el); ''' }) return div
def get_add_chat_wdg(my): div = DivWdg() div.add_border() div.add_style("padding: 20px") div.add_class("spt_add_chat_top") table = Table() table.add_style("width: auto") div.add(table) table.add_row() text = TextInputWdg(title="user", icon="USER_ADD") table.add_cell(text) text.add_class("spt_add_chat_user") add_button = ActionButtonWdg(title="Start Chat") table.add_cell(add_button) add_button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_add_chat_top"); var el = top.getElement(".spt_add_chat_user"); var user = el.value; if (!user) { alert("Specify a valid user to chat with"); return; } // new chat var server = TacticServerStub.get(); var category = "chat"; var class_name = 'tactic.ui.app.ChatCmd'; var kwargs = { users: [user] } server.execute_cmd(class_name, kwargs); spt.panel.refresh(bvr.src_el); ''' } ) return div
def get_sqlite_wdg(my): div = DivWdg() div.add_class("spt_db_options") div.add_attr("spt_vendor", "Sqlite") div.add_style("padding: 20px") div.add("Database Folder: ") text = TextInputWdg(name="database/sqlite_db_dir") div.add(text) db_dir = Config.get_value("database", "sqlite_db_dir") if not db_dir: data_dir = Environment.get_data_dir() db_dir = "%s/db" % data_dir text.set_value(db_dir) return div
def configure_category(my, title, category, options, options_type={}): div = DivWdg() title_wdg = DivWdg() div.add(title_wdg) #from tactic.ui.widget.swap_display_wdg import SwapDisplayWdg #swap = SwapDisplayWdg() #div.add(swap) title_wdg.add("<b>%s</b>" % title) table = Table() div.add(table) #table.add_color("color", "color") table.add_style("color: #000") table.add_style("margin: 20px") for option in options: table.add_row() display_title = Common.get_display_title(option) td = table.add_cell("%s: " % display_title) td.add_style("width: 150px") option_type = options_type.get(option) validation_scheme = "" #add selectWdg for those options whose type is bool if option_type == 'bool': text = SelectWdg(name="%s/%s" % (category, option)) text.set_option('values', 'true|false') text.set_option('empty', 'true') text.add_style("margin-left: 0px") elif option.endswith('password'): text = PasswordInputWdg(name="%s/%s" % (category, option)) # dealing with options whose type is number else: if option_type == 'number': validation_scheme = 'INTEGER' else: validation_scheme = "" text = TextInputWdg(name="%s/%s" % (category, option), validation_scheme=validation_scheme, read_only="false") value = Config.get_value(category, option) if value: text.set_value(value) table.add_cell(text) return div
def get_title_input_wdg(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') section_span.add('Title: ') textbox_wdg = TextInputWdg() textbox_wdg.set_id('title_data') textbox_wdg.set_name('title_data') textbox_wdg.add_style('width', '{0}px'.format(200)) try: textbox_wdg.set_value(self.prequal_eval_sobject.get('title')) except AttributeError: pass section_span.add(textbox_wdg) return section_span
def get_info_wdg(my): div = DivWdg() div.set_name("Info") div.add_style("padding: 20px") table = Table() div.add(table) table.add_color("color", "color") #table.add_style("height: 280px") table.set_unique_id() table.add_smart_style("spt_table_header", "width", "200px") table.add_smart_style("spt_table_header", "text-align", "right") table.add_smart_style("spt_table_header", "padding-right", "20px") table.add_smart_style("spt_table_header", "margin-bottom", "10px") table.add_smart_style("spt_table_element", "vertical-align", "top") table.add_row() #if my.mode == 'insert': # read_only = False #else: # read_only = True read_only = False code = Config.get_value("install", "server") or "" td = table.add_cell() td.add_class("spt_table_header") td.add("Code: ") td.add_style("vertical-align: top") text = TextInputWdg(name="code", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(code) return div
def get_display(self): outer_div = DivWdg() outer_div.add_class('new-order-entry-form') order_name_input = TextInputWdg() order_name_input.set_name('name') outer_div.add(get_label_widget('Name')) outer_div.add(order_name_input) po_number_input = TextInputWdg() po_number_input.set_name('po_number') outer_div.add(get_label_widget('PO Number')) outer_div.add(po_number_input) client_select_wdg = get_select_widget_from_search_type('twog/client', 'client', 'name', 'code') outer_div.add(get_label_widget('Client')) outer_div.add(client_select_wdg) sales_rep_select_wdg = get_select_widget_from_search_type('sthpw/login_in_group', 'Client', 'login_full_name', 'code', [('login_group', 'sales')]) outer_div.add(get_label_widget('Sales Rep')) outer_div.add(sales_rep_select_wdg) submit_button = SubmitWdg('Submit') submit_button.add_behavior(self.submit_button_behavior()) outer_div.add(submit_button) return outer_div
def get_display(self): outer_div = DivWdg() outer_div.add_class('new-title-entry-form') title_name_input = TextInputWdg() title_name_input.set_name('name') outer_div.add(get_label_widget('Name')) outer_div.add(title_name_input) episode_input = TextInputWdg() episode_input.set_name('episode') outer_div.add(get_label_widget('Episode')) outer_div.add(episode_input) description_input = TextAreaInputWdg() description_input.set_name('description') outer_div.add(get_label_widget('Description')) outer_div.add(description_input) submit_button = SubmitWdg('Submit') submit_button.add_behavior(self.submit_button_behavior()) outer_div.add(submit_button) return outer_div
def get_info_wdg(self): div = DivWdg() div.set_name("Info") div.add_style("padding: 20px") table = Table() div.add(table) table.add_color("color", "color") #table.add_style("height: 280px") table.set_unique_id() table.add_smart_style("spt_table_header", "width", "200px") table.add_smart_style("spt_table_header", "text-align", "right") table.add_smart_style("spt_table_header", "padding-right", "20px") table.add_smart_style("spt_table_header", "margin-bottom", "10px") table.add_smart_style("spt_table_element", "vertical-align", "top") table.add_row() #if self.mode == 'insert': # read_only = False #else: # read_only = True read_only = False code = Config.get_value("install", "server") or "" td = table.add_cell() td.add_class("spt_table_header") td.add("Code: ") td.add_style("vertical-align: top") text = TextInputWdg(name="code", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(code) return div
def configure_category(my, title, category, options): div = DivWdg() title_wdg = DivWdg() div.add(title_wdg) #from tactic.ui.widget.swap_display_wdg import SwapDisplayWdg #swap = SwapDisplayWdg() #div.add(swap) title_wdg.add("<b>%s</b>" % title) table = Table() div.add(table) #table.add_color("color", "color") table.add_style("color: #000") table.add_style("margin: 20px") for option in options: table.add_row() display_title = Common.get_display_title(option) td = table.add_cell("%s: " % display_title) td.add_style("width: 150px") if option.endswith('password'): text = PasswordInputWdg(name="%s/%s" % (category, option)) else: text = TextInputWdg(name="%s/%s" % (category, option)) value = Config.get_value(category, option) if value: text.set_value(value) table.add_cell(text) return div
def get_nav_wdg(self): #base_dir = self.kwargs.get("base_dir") #location = self.kwargs.get("location") base_dir = self.session.get_value("base_dir") location = self.session.get_value("location") nav_wdg = DivWdg() nav_wdg.add("<b>Session 101 - Clean up self Crap</b><hr/>") nav_wdg.add_style("margin-bottom: 10px") nav_wdg.add_class("spt_file_nav") nav_wdg.add_style("width: 575px") nav_wdg.add_border() nav_wdg.set_round_corners() nav_wdg.add_style("padding: 5px") button = ActionButtonWdg(title="Scan", tip="Scan for files in specified folder") button.add_style("float: right") button.add_style("margin-top: -5px") nav_wdg.add(button) from tactic.ui.input import TextInputWdg title_wdg = "Session Title: " nav_wdg.add(title_wdg) text = TextInputWdg(name="title") text.add_class("spt_title") text.add_style("width: 300px") nav_wdg.add(text) nav_wdg.add("<br/><br/>") folder_wdg = "Base folder of this session: " nav_wdg.add(folder_wdg) text = TextInputWdg(name="base_dir") text.add_class("spt_base_dir") text.add_style("width: 300px") if base_dir: text.set_value(base_dir) nav_wdg.add(text) # add a hidden paths variable text = HiddenWdg("paths") text.add_class("spt_paths") nav_wdg.add(text) nav_wdg.add("<br/>") # add a hidden paths variable select = SelectWdg("location") if location: select.set_value(location) nav_wdg.add("<br/>") nav_wdg.add("Folder is on ") nav_wdg.add(select) select.set_option("values", "local|server") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var nav = top.getElement(".spt_file_nav"); var nav_values = spt.api.Utility.get_input_values(nav,null,false); var base_dir = nav_values.base_dir; var location = nav_values.location; spt.app_busy.show("Scanning", base_dir); if (location == 'local') { var applet = spt.Applet.get(); var paths = applet.list_dir(base_dir, 2); var paths_el = nav.getElement(".spt_paths"); var js_paths = []; for (var i = 0; i < paths.length; i++) { var js_path = paths[i].replace(/\\\\/g,"/"); if (applet.is_dir(js_path) ) { js_path = js_path + '/'; js_paths.push(js_path); } //if (i > 100) break; else { js_paths.push(js_path); } } paths_el.value = js_paths.join("|"); } //var nav_values = spt.api.Utility.get_input_values(nav,null,false); //spt.panel.refresh(top, nav_values); spt.tab.set_tab_top(top); spt.tab.select("files") var class_name = "tactic.ui.tools.IngestionToolDirListWdg"; var kwargs = { base_dir: base_dir, location: location, paths: js_paths } spt.tab.load_selected("files", "Files", class_name, kwargs); spt.app_busy.hide(); ''' }) return nav_wdg
def get_text_input_for_element_eval_line_wdg(name, data, is_checked, width=200, timecode=False): textbox_wdg = TextInputWdg() textbox_wdg.set_id(name) textbox_wdg.set_name(name) textbox_wdg.add_style('width', '{0}px'.format(width)) if not is_checked: textbox_wdg.add_style('font-weight', 'bold') if timecode: textbox_wdg.add_behavior(get_add_colons_for_time_behavior()) if data: textbox_wdg.set_value(data) return textbox_wdg
def get_display(self): top = self.top top.add_color("background", "background") top.add_class("spt_columns_top") self.set_as_panel(top) top.add_style("padding: 10px") search_type = self.kwargs.get("search_type") search_type_obj = SearchType.get(search_type) inner = DivWdg() top.add(inner) inner.add_style("width: 800px") #text = TextWdg("search_type") text = HiddenWdg("search_type") inner.add(text) text.set_value(search_type) title_wdg = DivWdg() inner.add(title_wdg) title_wdg.add( search_type_obj.get_title() ) title_wdg.add(" <i style='font-size: 9px;opacity: 0.5'>(%s)</i>" % search_type) title_wdg.add_style("padding: 5px") title_wdg.add_color("background", "background3") title_wdg.add_color("color", "color3") title_wdg.add_style("margin: -10px -10px 10px -10px") title_wdg.add_style("font-weight: bold") shelf_wdg = DivWdg() inner.add(shelf_wdg) shelf_wdg.add_style("height: 35px") button = ActionButtonWdg(title='Create', color="default", icon="BS_SAVE") shelf_wdg.add(button) shelf_wdg.add_style("float: right") button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ColumnEditCbk'; var top = bvr.src_el.getParent(".spt_columns_top"); var elements = top.getElements(".spt_columns_element"); var values = []; for (var i = 0; i < elements.length; i++ ) { var data = spt.api.Utility.get_input_values(elements[i], null, false); values.push(data) } var kwargs = { search_type: bvr.search_type, values: values } var server = TacticServerStub.get(); try { server.execute_cmd(class_name, kwargs); var names = []; for (var i = 0; i < values.length; i++) { var name = values[i].name; name = name.strip(); if (name == '') { continue; } names.push(name); } // Unless there is a table here, we should not do this. // Better handled with a callback //spt.table.add_columns(names) // prevent grabbing all values, pass in a dummy one spt.panel.refresh(top, {'refresh': true}); } catch(e) { spt.alert(spt.exception.handler(e)); } ''' } ) # add the headers table = Table() inner.add(table) table.add_style("width: 100%") tr = table.add_row() tr.add_color("background", "background", -5) th = table.add_header("Column Name") th.add_style("width: 190px") th.add_style("text-align: left") th.add_style("padding: 8px 0px") th = table.add_header("Format") th.add_style("text-align: left") th.add_style("padding: 8px 0px") from tactic.ui.container import DynamicListWdg dyn_list = DynamicListWdg() inner.add(dyn_list) from tactic.ui.manager import FormatDefinitionEditWdg for i in range(0, 4): column_div = DivWdg() column_div.add_class("spt_columns_element") if i == 0: dyn_list.add_template(column_div) else: dyn_list.add_item(column_div) column_div.add_style("padding: 3px") column_div.add_style("float: left") table = Table() column_div.add(table) table.add_row() from tactic.ui.input import TextInputWdg text_wdg = TextInputWdg(name="name", height="30px", width="170px") text_wdg.add_class("form-control") text_wdg.add_class("display: inline-block") td = table.add_cell(text_wdg) text_wdg.add_behavior( { 'type': 'blur', 'cbjs_action': ''' var value = bvr.src_el.value; var code = spt.convert_to_alpha_numeric(value); bvr.src_el.value = code; ''' } ) option = { 'name': '_dummy', 'values': 'integer|float|percent|currency|date|time|scientific|boolean|text|timecode', } format_wdg = FormatDefinitionEditWdg(option=option) td = table.add_cell(format_wdg) td.add_style("width: 550px") td.add_style("padding-left: 10px") # show the current columns title_wdg = DivWdg() inner.add(title_wdg) title_wdg.add_style("margin-top: 25px") title_wdg.add("<b>Existing Columns</b>") title_wdg.add_style("padding: 5px") title_wdg.add_style("margin: 20px -10px 10px -10px") inner.add("<hr/>") config = WidgetConfigView.get_by_search_type(search_type, "definition") element_names = config.get_element_names() table = Table() inner.add(table) table.add_style("width: 100%") tr = table.add_row() tr.add_color("background", "background", -5) th = table.add_header("Column") th.add_style("text-align: left") th.add_style("padding: 5px 0px") th = table.add_header("Data Type") th.add_style("text-align: left") th.add_style("padding: 5px 0px") th = table.add_header("Format") th.add_style("text-align: left") th.add_style("padding: 5px 0px") th = table.add_header("Edit") th.add_style("text-align: left") th.add_style("padding: 5px 0px") count = 0 for element_name in element_names: display_class = config.get_display_handler(element_name) if display_class != 'tactic.ui.table.FormatElementWdg': continue table.add_row() display_options = config.get_display_options(element_name) format = display_options.get("format") if not format: format = '<i>text</i>' data_type = display_options.get("type") table.add_cell(element_name) table.add_cell(data_type) table.add_cell(format) td = table.add_cell() button = IconButtonWdg(title="Edit Definition", icon="BS_EDIT") td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'element_name': element_name, 'cbjs_action': ''' var class_name = 'tactic.ui.manager.ElementDefinitionWdg'; var kwargs = { search_type: bvr.search_type, view: 'definition', element_name: bvr.element_name }; spt.panel.load_popup("Element Definition", class_name, kwargs); ''' } ) count += 1 if not count: table.add_row() td = table.add_cell() td.add_style("height: 80px") td.add("No existing columns found") td.add_style("text-align: center") td.add_color("background", "background", -2) if self.kwargs.get("is_refresh"): return inner else: return top
def common_wdg(my, vendor): div = DivWdg() div.add_class("spt_db_options") div.add_style("margin: 20px") if vendor != 'MySQL': div.add_attr("spt_vendor", "Other") table = Table() div.add(table) table.add_color("color", "color") table.add_row() table.add_cell("Server: ") text = TextInputWdg(name="server") text.set_value("localhost") table.add_cell(text) server = Config.get_value("database", "server") if server: text.set_value(server) table.add_row() table.add_cell("Port: ") text = TextInputWdg(name="port") table.add_cell(text) port = Config.get_value("database", "port") if port: text.set_value(port) table.add_row() table.add_cell("Login: "******"user") table.add_cell(text) user = Config.get_value("database", "user") if user: text.set_value(user) table.add_row() text = PasswordInputWdg(name="password") table.add_cell("Password: "******"database", "password") if password: text.set_value(password) if vendor == 'MySQL': div.add_attr("spt_vendor", "MySQL") table.add_row() text = TextInputWdg(name="encoding") table.add_cell("Encoding: ") table.add_cell(text) encoding = Config.get_value("database", "encoding") if encoding: text.set_value(encoding) table.add_row() text = TextInputWdg(name="charset") table.add_cell("Charset: ") table.add_cell(text) charset = Config.get_value("database", "charset") if charset: text.set_value(charset) #from pyasm.search import Sql #sql.connect() return div
def get_display(my): top = my.top top.add_class("spt_sign_in_top") top.add_color("background", "background") top.add_style("padding: 30px") top.add_style("width: 300px") icon = IconWdg("Not signed in", IconWdg.WARNING) top.add(icon) top.add("You are not signed into Perforce.") top.add("<br/>" * 2) table = Table() top.add(table) from tactic.ui.input import TextInputWdg, PasswordInputWdg table.add_row() td = table.add_cell("Port: ") td.add_style("width: 75px") text = TextInputWdg(name="port") td = table.add_cell(text) td.add_style("vertical-align: top") text.set_value("1666") table.add_row() td = table.add_cell("Login: "******"vertical-align: top") td.add_style("width: 75px") text = TextInputWdg(name="user") td = table.add_cell(text) td.add_style("vertical-align: top") user = Environment.get_user_name() text.set_value(user) table.add_row() td = table.add_cell("Password: "******"vertical-align: top") text = PasswordInputWdg(name="password") table.add_cell(text) tr = table.add_row() table.add_row_cell(" ") tr = table.add_row() tr.add_class("spt_workspaces") #tr.add_style("display: none") td = table.add_cell("Workspace: ") td.add_style("vertical-align: top") workspaces = my.kwargs.get("workspaces") td = table.add_cell() button = ActionButtonWdg(width='55', title="Lookup") td.add(button) button.add_style("float: right") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' try { var workspaces = spt.scm.get_workspaces(); var clients = []; for (var i = 0; i < workspaces.length; i++) { clients.push(workspaces[i].client); } clients = clients.join("|"); var kwargs = { workspaces: clients } spt.scm.show_login(kwargs); } catch(e) { spt.scm.signout_user(); spt.scm.show_login(); } ''' }) if not workspaces: text = TextInputWdg(name="workspace") text.add_style("width: 165px") td.add(text) else: select = SelectWdg("workspace") td.add(select) select.set_option("values", workspaces) top.add("<br/>" * 2) button = ActionButtonWdg(title="Sign In >>", size='medium') top.add(button) button.add_style("float: right") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_sign_in_top"); var values = spt.api.get_input_values(top); var port = values.port[0]; var user = values.user[0]; var password = values.password[0]; var client = values.workspace[0]; if (!port) { alert("No port specified"); return; } if (!user) { alert("No user specified"); return; } if (!client) { alert("No workspace specified"); return; } // login in user spt.scm.port = port; spt.scm.user = user; spt.scm.password = password; // test the connection var ping = spt.scm.ping(); if (ping != "OK") { alert("Cannot connect to Perforce") spt.scm.signout_user(); spt.scm.show_login(); } else { spt.scm.client = client; // close the popup var popup = bvr.src_el.getParent(".spt_popup"); if (popup) { spt.popup.destroy(popup); } // NOTE: this is global: find a check-in widget and refresh var checkin_el = $(document.body).getElement(".spt_checkin_top"); spt.panel.refresh(checkin_el); } ''' }) top.add("<br/>" * 2) return top
def get_upload_wdg(my): '''get search type select and upload wdg''' key = 'csv_import' widget = DivWdg(css='spt_import_csv') widget.add_color('color','color') widget.add_color('background','background') widget.add_style('width: 600px') # get the search type stype_div = DivWdg() widget.add(stype_div) # DEPRECATED # handle new search_types """ new_search_type = CheckboxWdg("new_search_type_checkbox") new_search_type.add_event("onclick", "toggle_display('new_search_type_div')") new_search_type_div = DivWdg() new_search_type_div.set_id("new_search_type_div") name_input = TextWdg("asset_name") title = TextWdg("asset_title") description = TextAreaWdg("asset_description") table = Table() table.set_id('csv_main_body') table.add_style("margin: 10px 10px") table.add_col().set_attr('width','140') table.add_col().set_attr('width','400') table.add_row() table.add_header("Search Type: ").set_attr('align','left') table.add_cell(name_input) table.add_row() table.add_header("Title: ").set_attr('align','left') table.add_cell(title) table.add_row() table.add_header("Description: ").set_attr('align','left') table.add_cell(description) new_search_type_div.add(table) new_search_type_div.add_style("display: none") #widget.add(new_search_type_div) """ show_stype_select = my.kwargs.get("show_stype_select") if show_stype_select in ['true',True] or not my.search_type: title = DivWdg("<b>Select sType to import data into:</b> ") stype_div.add( title ) title.add_style("float: left") search_type_select = SearchTypeSelectWdg("search_type_filter", mode=SearchTypeSelectWdg.ALL) search_type_select.add_empty_option("-- Select --") if not search_type_select.get_value(): search_type_select.set_value(my.search_type) search_type_select.set_persist_on_submit() stype_div.add(search_type_select) search_type_select.add_behavior( {'type': 'change', \ 'cbjs_action': "spt.panel.load('csv_import_main','%s', {}, {\ 'search_type_filter': bvr.src_el.value});" %(Common.get_full_class_name(my)) } ) else: hidden = HiddenWdg("search_type_filter") stype_div.add(hidden) hidden.set_value(my.search_type) if my.search_type: sobj = None try: sobj = SObjectFactory.create(my.search_type) except ImportError: widget.add(HtmlElement.br()) widget.add(SpanWdg('WARNING: Import Error encountered. Please choose another search type.', css='warning')) return widget required_columns = sobj.get_required_columns() if required_columns: widget.add(HtmlElement.br()) req_span = SpanWdg("Required Columns: ", css='med') req_span.add_color('color','color') widget.add(req_span) #required_columns = ['n/a'] req_span.add(', '.join(required_columns)) widget.add( HtmlElement.br() ) if my.file_path: hidden = HiddenWdg("file_path", my.file_path) widget.add(hidden) if my.web_url: file_span = FloatDivWdg('URL: <i>%s</i> ' %my.web_url, css='med') else: if not my.data: file_span = FloatDivWdg('File uploaded: <i>%s</i> ' %os.path.basename(my.file_path), css='med') else: lines = len(my.data.split("\n")) file_span = FloatDivWdg("Uploaded [%s] lines of entries: " % lines) file_span.add_color('color','color') file_span.add_style('margin: 8px 0 0 10px') file_span.add_style('font-size: 14px') widget.add(file_span) button = ActionButtonWdg(title='Change') button.add_style('float','left') button.add_behavior( {'type': 'click_up', \ 'cbjs_action': "spt.panel.load('csv_import_main','%s', {}, {\ 'search_type_filter': '%s'});" %(Common.get_full_class_name(my), my.search_type) } ) widget.add(button) widget.add("<br clear='all'/>") widget.add(HtmlElement.br()) return widget widget.add_style("overflow-y: auto") msg = DivWdg() widget.add(msg) msg.add_border() msg.add_style("width: 500px") msg.add_color("background", "background3") msg.add_style("padding: 30px") msg.add_style("margin: 10 auto") #msg.add_style("text-align: center") msg.add( "<div style='float: left; padding-top: 6px; margin-right: 105px'><b>Upload a csv file: </b></div>") ticket = Environment.get_security().get_ticket_key() on_complete = '''var server = TacticServerStub.get(); var file = spt.html5upload.get_file(); if (file) { var file_name = file.name; // clean up the file name the way it is done in the server //file_name = spt.path.get_filesystem_name(file_name); var server = TacticServerStub.get(); var class_name = 'tactic.ui.widget.CsvImportWdg'; var values = spt.api.Utility.get_input_values('csv_import_main'); values['is_refresh'] = true; values['file_name'] = file_name; values['html5_ticket'] = '%s'; try { var info = spt.panel.load('csv_import_main', class_name, {}, values); spt.app_busy.hide(); } catch(e) { spt.alert(spt.exception.handler(e)); } } else { alert('Error: file object cannot be found.') } spt.app_busy.hide();'''%ticket from tactic.ui.input import UploadButtonWdg browse = UploadButtonWdg(name='new_csv_upload', title="Browse", tip="Click to choose a csv file",\ on_complete=on_complete, ticket=ticket) browse.add_style('float: left') msg.add(browse) # this is now only used in the copy and paste Upload button for backward-compatibility upload_wdg = SimpleUploadWdg(key=key, show_upload=False) upload_wdg.add_style('display: none') msg.add(upload_wdg) msg.add("<br/>") msg.add("<div style='margin: 30px; text-align: center'>-- OR --</div>") msg.add("<b>Published URL: </b><br/>") from tactic.ui.input import TextInputWdg text = TextInputWdg(name="web_url") text.add_style("width: 100%") msg.add(text) msg.add("<div style='margin: 30px; text-align: center'>-- OR --</div>") msg.add("<b>Copy and Paste from a Spreadsheet: </b><br/>") text = TextAreaWdg("data") text.add_style('width: 100%') text.add_style('height: 100px') text.add_class("spt_import_cut_paste") msg.add(text) msg.add("<br/>"*3) button = ActionButtonWdg(title="Parse") button.add_style("margin: 5px auto") msg.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_import_top"); var el = top.getElement(".spt_import_cut_paste"); var value = el.value; var csv = []; // convert to a csv file! lines = value.split("\\n"); for (var i = 0; i < lines.length; i++) { if (lines[i] == '') { continue; } var parts = lines[i].split("\\t"); var new_line = []; for (var j = 0; j < parts.length; j++) { if (parts[j] == '') { new_line.push(''); } else { new_line.push('"'+parts[j]+'"'); } } new_line = new_line.join(","); csv.push(new_line); } csv = csv.join("\\n") /* // FIXME: need to get a local temp directory var applet = spt.Applet.get(); var path = spt.browser.os_is_Windows() ? "C:/sthpw/copy_n_paste.csv" : "/tmp/sthpw/copy_n_paste.csv"; applet.create_file(path, csv); // upload the file applet.upload_file(path) applet.rmtree(path); var top = bvr.src_el.getParent(".spt_import_csv"); var hidden = top.getElement(".spt_upload_hidden"); hidden.value = path; var file_name = spt.path.get_basename(hidden.value); file_name = spt.path.get_filesystem_name(file_name); */ var class_name = 'tactic.ui.widget.CsvImportWdg'; var values = spt.api.Utility.get_input_values('csv_import_main'); values['is_refresh'] = true; //values['file_name'] = file_name; values['data'] = csv; var info = spt.panel.load('csv_import_main', class_name, {}, values); ''' } ) return widget
def get_timecode_textbox(self, name, width=200, line_data=None): timecode_textbox = TextInputWdg() timecode_textbox.set_id(name) timecode_textbox.set_name(name) timecode_textbox.add_style('width', '{0}px'.format(width)) timecode_textbox.add_behavior(get_add_colons_for_time_behavior()) if line_data: timecode_textbox.set_value(line_data) return timecode_textbox
def get_file_mode_wdg(my): div = DivWdg() div.add_style("margin-top: 15px") div.add_style("margin-bottom: 15px") div.add_class("spt_file_mode") # drop folder div.add( "A writable folder is required. This is the folder that sync will drop the transacton file into. This folder should be common to all shares that need to have recieve the transactions." ) div.add("<br/>" * 2) # only valid for standalone browser = WebContainer.get_web().get_browser() if browser == 'Qt': button = ActionButtonWdg(title="Browse") div.add(button) button.add_style("float: right") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var files = applet.open_file_browser(); if (files.length == 0) { return; } var dir = files[0]; if (!applet.is_dir(dir)) { spt.alert("Please select a folder"); return; } var top = bvr.src_el.getParent(".spt_file_mode"); var folder_el = top.getElement(".spt_sync_folder"); folder_el.value = dir; ''' }) div.add("Sync Folder: ") text = TextInputWdg(name="sync_folder") text.add_class("spt_sync_folder") text.add_style("width: 300px") div.add(text) #div.add("<br/>"*2) #div.add("Set whether this transaction is plaintext, zipped or encrypted.") div.add("<br/>" * 3) div.add( "The transactions can be encrypted with an encryption ticket. All shares must set this to be the same value in order for the transaction to be appropriately encrypted and decrypted." ) div.add("<br/>" * 2) div.add("Encrypt Transactions? ") checkbox = CheckboxWdg("is_encrypted") div.add(checkbox) checkbox.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_file_mode"); var el = top.getElement(".spt_encrypt"); if (el.getStyle("display") == "none") { el.setStyle("display", ""); } else { el.setStyle("display", "none"); } ''' }) #div.add("Set whether this transaction is plaintext, zipped or encrypted.") encrypt_div = DivWdg() encrypt_div.add_class("spt_encrypt") div.add(encrypt_div) encrypt_div.add_style("display: none") encrypt_div.add_style("padding: 30px 20px 30px 20px") encrypt_div.add("Encryption Key: ") text = TextWdg("encrypt_key") text.add_style("width: 300px") encrypt_div.add(text) #div.add(my.get_ticket_wdg()) return div
def get_base_dir_wdg(my): div = DivWdg() title = DivWdg() div.add(title) title.add("Sync Project Import: ") title.add_style("font-size: 14px") title.add_style("font-weight: bold") div.add("<br/>") base_dir = my.kwargs.get("base_dir") is_local = False if is_local: button = ActionButtonWdg(title="Browse") div.add(button) button.add_style("float: right") button.add_style("margin-top: -5px") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var files = applet.open_file_browser(); if (!files.length) { return; } var file = files[0]; var top = bvr.src_el.getParent(".spt_sync_import_top"); var el = top.getElement(".spt_sync_base_dir"); el.value = file; ''' }) div.add("Share Location: ") text = TextInputWdg(name="base_dir") div.add(text) text.add_class("spt_sync_base_dir") text.add_style("width: 300px") if base_dir: text.set_value(base_dir) text.add_behavior({ 'type': 'blur', 'is_local': is_local, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_sync_import_top"); var applet = spt.Applet.get(); var value = bvr.src_el.value; var manifest_path = value + "/tactic.txt"; if (!value) { return; } if (bvr.is_local) { if (!applet.exists(value)) { alert('Share folder does not exist.'); return; } if (!applet.exists(manifest_path)) { alert('Cannot find manifest file.'); return; } var data = applet.read_file(manifest_path); var json = JSON.parse(data); data = JSON.stringify(json); top.setAttribute("spt_data", data) } top.setAttribute("spt_base_dir", value) spt.panel.refresh(top); ''' }) return div
def get_base_dir_wdg(self): div = DivWdg() title = DivWdg() div.add(title) title.add("Sync Project Import: ") title.add_style("font-size: 14px") title.add_style("font-weight: bold") div.add("<br/>") base_dir = self.kwargs.get("base_dir") is_local = False if is_local: button = ActionButtonWdg(title="Browse") div.add(button) button.add_style("float: right") button.add_style("margin-top: -5px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var files = applet.open_file_browser(); if (!files.length) { return; } var file = files[0]; var top = bvr.src_el.getParent(".spt_sync_import_top"); var el = top.getElement(".spt_sync_base_dir"); el.value = file; ''' } ) div.add("Share Location: ") text = TextInputWdg(name="base_dir") div.add(text) text.add_class("spt_sync_base_dir") text.add_style("width: 300px") if base_dir: text.set_value(base_dir) text.add_behavior( { 'type': 'blur', 'is_local': is_local, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_sync_import_top"); var applet = spt.Applet.get(); var value = bvr.src_el.value; var manifest_path = value + "/tactic.txt"; if (!value) { return; } if (bvr.is_local) { if (!applet.exists(value)) { alert('Share folder does not exist.'); return; } if (!applet.exists(manifest_path)) { alert('Cannot find manifest file.'); return; } var data = applet.read_file(manifest_path); var json = JSON.parse(data); data = JSON.stringify(json); top.setAttribute("spt_data", data) } top.setAttribute("spt_base_dir", value) spt.panel.refresh(top); ''' } ) return div
def get_info_wdg(my): div = DivWdg() div.set_name("Info") div.add_style("padding: 20px") table = Table() div.add(table) table.add_color("color", "color") #table.add_style("height: 280px") table.set_unique_id() table.add_smart_style("spt_table_header", "width", "200px") table.add_smart_style("spt_table_header", "text-align", "right") table.add_smart_style("spt_table_header", "padding-right", "20px") table.add_smart_style("spt_table_header", "margin-bottom", "10px") table.add_smart_style("spt_table_element", "vertical-align", "top") #if my.mode == 'insert': # read_only = False #else: # read_only = True read_only = False code = my.server.get_code() or "" description = my.server.get_value("description") or "" table.add_row() td = table.add_cell() td.add_class("spt_table_header") td.add("Code: ") td.add_style("vertical-align: top") text = TextInputWdg(name="code", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(code) table.add_row() td = table.add_cell() td.add_class("spt_table_header") td.add("Description: ") td.add_style("vertical-align: top") text = TextAreaWdg(name="description", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(description) table.add_row() td = table.add_cell() td.add_class("spt_table_header") td.add("Base Directory: ") td.add_style("vertical-align: top") text = TextInputWdg(name="base_dir", read_only=read_only) td = table.add_cell() td.add_class("spt_table_element") td.add(text) text.set_value(my.base_dir) return div
def get_file_mode_wdg(self): div = DivWdg() div.add_style("margin-top: 15px") div.add_style("margin-bottom: 15px") div.add_class("spt_file_mode") # drop folder div.add("A writable folder is required. This is the folder that sync will drop the transacton file into. This folder should be common to all shares that need to have recieve the transactions.") div.add("<br/>"*2) # only valid for standalone browser = WebContainer.get_web().get_browser() if browser == 'Qt': button = ActionButtonWdg(title="Browse") div.add(button) button.add_style("float: right") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var files = applet.open_file_browser(); if (files.length == 0) { return; } var dir = files[0]; if (!applet.is_dir(dir)) { spt.alert("Please select a folder"); return; } var top = bvr.src_el.getParent(".spt_file_mode"); var folder_el = top.getElement(".spt_sync_folder"); folder_el.value = dir; ''' } ) div.add("Sync Folder: ") text = TextInputWdg(name="sync_folder") text.add_class("spt_sync_folder") text.add_style("width: 300px") div.add(text) #div.add("<br/>"*2) #div.add("Set whether this transaction is plaintext, zipped or encrypted.") div.add("<br/>"*3) div.add("The transactions can be encrypted with an encryption ticket. All shares must set this to be the same value in order for the transaction to be appropriately encrypted and decrypted.") div.add("<br/>"*2) div.add("Encrypt Transactions? ") checkbox = CheckboxWdg("is_encrypted") div.add(checkbox) checkbox.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_file_mode"); var el = top.getElement(".spt_encrypt"); if (el.getStyle("display") == "none") { el.setStyle("display", ""); } else { el.setStyle("display", "none"); } ''' } ) #div.add("Set whether this transaction is plaintext, zipped or encrypted.") encrypt_div = DivWdg() encrypt_div.add_class("spt_encrypt") div.add(encrypt_div) encrypt_div.add_style("display: none") encrypt_div.add_style("padding: 30px 20px 30px 20px") encrypt_div.add("Encryption Key: ") text = TextWdg("encrypt_key") text.add_style("width: 300px") encrypt_div.add(text) #div.add(self.get_ticket_wdg()) return div
def get_display(self): top = self.top self.set_as_panel(top) top.add_class("spt_ingestion_top") top.add_color("background", "background", -5) self.data = {} rules_div = DivWdg() top.add(rules_div) rules_div.add_style("padding: 10px") rules_div.add("Rules: ") rules_select = SelectWdg("rule_code") rule_code = self.get_value('rule_code') if rule_code: rules_select.set_value(rule_code) rules_select.set_option("query", "config/ingest_rule|code|title") rules_select.add_empty_option("-- New --") rules_div.add(rules_select) rules_select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var class_name = 'tactic.ui.tools.IngestionToolWdg'; spt.panel.load(top, class_name, {rule_code: value} ); ''' }) rules_div.add("<hr/>") # read from the database if rule_code: search = Search("config/ingest_rule") search.add_filter("code", rule_code) sobject = search.get_sobject() else: sobject = None if sobject: self.data = sobject.get_value("data") if self.data: self.data = jsonloads(self.data) session_code = self.kwargs.get("session_code") if session_code: session = Search.get_by_code("config/ingest_session", session_code) else: if sobject: session = sobject.get_related_sobject("config/ingest_session") print("sobject: ", sobject.get_code(), sobject.get_value("spt_ingest_session_code")) print("parent: ", session) else: session = None if not session: #session = SearchType.create("config/ingest_session") #session.set_value("code", "session101") #session.set_value("location", "local") ##session.set_value("base_dir", "C:") top.add("No session defined!!!") return top rule = "" filter = "" ignore = "" # get the base path if sobject: base_dir = sobject.get_value("base_dir") else: base_dir = '' #else: # base_dir = self.get_value("base_dir") #if not base_dir: # base_dir = '' if sobject: title = sobject.get_value("title") else: title = '' if sobject: code = sobject.get_value("code") else: code = '' file_list = self.get_value("file_list") scan_type = self.get_value("scan_type") action_type = self.get_value("action_type") rule = self.get_value("rule") if not rule: rule = base_dir # get the rule for this path checkin_mode = "dir" depth = 0 table = Table() rules_div.add(table) table.add_color("color", "color") from tactic.ui.input.text_input_wdg import TextInputWdg # add the title table.add_row() td = table.add_cell() td.add("Title: ") td = table.add_cell() text = TextInputWdg(name="title") td.add(text) if title: text.set_value(title) text.add_class("spt_title") text.add_style("width: 400px") #text.add_color("background", "background", -10) # add the optional code table.add_row() td = table.add_cell() td.add("Code (optional): ") td = table.add_cell() text = TextInputWdg(name="code") td.add(text) if code: text.set_value(code) text.set_readonly() text.add_color("background", "background", -10) text.add_class("spt_code") text.add_style("width: 400px") table.add_row() td = table.add_cell() td.add_style("height: 10px") td.add("<hr/>") table.add_row() td = table.add_cell() td.add("<b>Scan:</b><br/>") td.add( "The following information will be used to find the paths that will be operated on by the ingestion process<br/><br/>" ) # add a scan type table.add_row() td = table.add_cell() td.add("Type: ") select = SelectWdg("scan_type") select.add_class("spt_scan_type") td = table.add_cell() td.add(select) select.set_value(self.get_value("action")) labels = ['Simple List', 'Rule', 'Script'] values = ['list', 'rule', 'script'] select.set_option("values", values) select.set_option("labels", labels) if scan_type: select.set_value(scan_type) table.add_row() table.add_cell(" ") select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var elements = top.getElements(".spt_scan_list"); for (var i = 0; i < elements.length; i++) { if (value == 'list') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_scan_rule"); for (var i = 0; i < elements.length; i++) { if (value == 'rule') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_scan_script"); for (var i = 0; i < elements.length; i++) { if (value == 'script') spt.show(elements[i]); else spt.hide(elements[i]); } ''' }) # add in a list of stuff tbody = table.add_tbody() tbody.add_class("spt_scan_list") if scan_type != 'list': tbody.add_style("display: none") tr = table.add_row() td = table.add_cell() td.add("List of files: ") td = table.add_cell() text = TextAreaWdg(name="file_list") td.add(text) text.add_style("width: 400px") #text.set_readonly() #text.add_color("background", "background", -10) text.set_value(file_list) table.close_tbody() # add rule scan mode tbody = table.add_tbody() tbody.add_class("spt_scan_rule") if scan_type != 'rule': tbody.add_style("display: none") # add the path tr = table.add_row() td = table.add_cell() td.add("Starting Path: ") td = table.add_cell() hidden = HiddenWdg("session_code", session.get_code()) td.add(hidden) text = TextInputWdg(name="base_dir") td.add(text) text.set_value(base_dir) text.add_style("width: 400px") #text.set_readonly() #text.add_color("background", "background", -10) text.set_value(base_dir) # add rule tr = table.add_row() td = table.add_cell() td.add("Tag Rule: ") td = table.add_cell() text = TextInputWdg(name="rule") td.add(text) text.add_style("width: 400px") text.set_value(rule) tr = table.add_row() td = table.add_cell() td.add("Filter: ") td = table.add_cell() text = TextWdg("filter") td.add(text) text.set_value(self.get_value("filter")) text.add_style("width: 400px") text.add_style("padding: 2px") text.add_style("-moz-border-radius: 5px") tr = table.add_row() td = table.add_cell() td.add("Ignore: ") td = table.add_cell() text = TextWdg("ignore") td.add(text) text.set_value(self.get_value("ignore")) text.set_value(ignore) text.add_style("width: 400px") text.add_style("padding: 2px") text.add_style("-moz-border-radius: 5px") table.add_row() td = table.add_cell() td.add("Validation script: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextInputWdg(name="validation_script") text.set_value(self.get_value("validation_script")) text.add_style("width: 400px") td.add(text) icon = IconButtonWdg(title='Edit Validation Script', icon=IconWdg.EDIT) icon.add_style("float: right") td.add(icon) icon.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_script_editor"); var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); var kwargs = { script_path: values.validation_script } setTimeout( function() { spt.js_edit.display_script_cbk(evt, kwargs) }, 500 ); ''' }) table.close_tbody() # add the script path tbody = table.add_tbody() tbody.add_class("spt_scan_script") if scan_type != 'script': tbody.add_style("display: none") tr = table.add_row() td = table.add_cell() td.add("Script Path: ") td = table.add_cell() text = TextInputWdg(name="script_path") td.add(text) text.add_style("width: 400px") table.close_tbody() table.add_row() td = table.add_cell("<hr/>") table.add_row() td = table.add_cell() td.add("<b>Action</b><br/>") td.add( "The following information define the actions that will be used on each matched path<br/><br/>" ) # pick the type of action table.add_row() td = table.add_cell() td.add("Type: ") select = SelectWdg("action_type") td = table.add_cell() td.add(select) labels = ['Checkin', 'Ignore'] values = ['checkin', 'ignore'] select.set_option("values", values) select.set_option("labels", labels) select.add_empty_option("-- Select --") if action_type: select.set_value(action_type) select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var elements = top.getElements(".spt_action_ignore"); for (var i = 0; i < elements.length; i++) { if (value == 'ignore') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_action_checkin"); for (var i = 0; i < elements.length; i++) { if (value == 'checkin') spt.show(elements[i]); else spt.hide(elements[i]); } ''' }) table.add_row() td = table.add_cell("<br/>") # add the script path tbody = table.add_tbody() tbody.add_class("spt_action_checkin") if action_type != 'checkin': tbody.add_style("display: none") # add the checkin type table.add_row() td = table.add_cell() td.add("Action: ") select = SelectWdg("action") td = table.add_cell() td.add(select) select.set_value(self.get_value("action")) labels = ['File Checkin', 'Directory Checkin', 'Sequence Checkin'] values = ['file', 'directory', 'sequence', 'ignore'] select.set_option("values", values) select.set_option("labels", labels) table.add_row() td = table.add_cell() td.add("Mode: ") select = SelectWdg("mode") td = table.add_cell() td.add(select) labels = ['Copy', 'Move', 'In Place'] values = ['copy', 'move', 'inplace'] select.set_option("values", values) select.set_option("labels", labels) # add the search_type table.add_row() td = table.add_cell() td.add("sType: ") td = table.add_cell() select = SelectWdg("search_type") td.add(select) search_types = Project.get().get_search_types() values = [x.get_value("search_type") for x in search_types] select.set_option("values", values) search_type = self.kwargs.get("search_type") if search_type: select.set_value(search_type) # add the search_type table.add_row() td = table.add_cell() td.add("Context: ") td = table.add_cell() select = SelectWdg("context") td.add(select) select.set_option("values", ['publish', 'by rule', 'custom']) # add extra values extra_div = DivWdg() text = TextWdg("extra_name") text.add_attr("spt_is_multiple", "true") extra_div.add(text) extra_div.add(" = ") text = TextWdg("extra_value") extra_div.add(text) text.add_attr("spt_is_multiple", "true") template_div = DivWdg() text = TextWdg("extra_name") text.add_attr("spt_is_multiple", "true") template_div.add(text) template_div.add(" = ") text = TextWdg("extra_value") template_div.add(text) text.add_attr("spt_is_multiple", "true") table.close_tbody() table.add_row() td = table.add_cell("<br/>") table.add_row() td = table.add_cell() td.add("Extra Keywords: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("keywords") text.add_style("width: 300px") td.add(text) table.add_row() td = table.add_cell() td.add("Extra Values: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() extra_list = DynamicListWdg() td.add(extra_list) extra_list.add_item(extra_div) extra_list.add_template(template_div) table.add_row() table.add_cell(" ") table.add_row() td = table.add_cell() td.add("Process script: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("process_script") text.add_style("width: 300px") td.add(text) text.set_value(self.get_value("process_script")) icon = IconButtonWdg(title='Edit Process Script', icon=IconWdg.EDIT) icon.add_style("float: right") td.add(icon) icon.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_script_editor"); var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); var kwargs = { script_path: values.process_script } // need to wait for this setTimeout( function() { spt.js_edit.display_script_cbk(evt, kwargs) }, 500 ); ''' }) table.add_row() td = table.add_cell() td.add("Custom Naming: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("naming") text.add_style("width: 300px") td.add(text) table.add_row() td = table.add_cell() #td.add("<br clear='all'/>") td.add("<hr/>") behavior = { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); spt.app_busy.show("Scanning ...", values.base_dir); var class_name = 'tactic.ui.tools.IngestionProcessWdg'; var server = TacticServerStub.get(); values.mode = bvr.mode; values.is_local = 'true'; // scan client side if (values.is_local == 'true') { var base_dir = values.base_dir; var applet = spt.Applet.get(); var files = applet.list_recursive_dir(base_dir); // turn into a string var files_in_js = []; for (var i = 0; i < files.length; i++) { var file = files[i].replace(/\\\\/g, "/"); files_in_js.push( file ); } values.files = files_in_js; values.base_dir = base_dir; /* var server = TacticServerStub.get(); var handoff_dir = server.get_handoff_dir(); var applet = spt.Applet.get(); for (var i = 0; i < files_in_js.length; i++) { try { var parts = files_in_js[i].split("/"); var filename = parts[parts.length-1]; spt.app_busy.show("Copying files to handoff", filename); applet.copy_file(files_in_js[i], handoff_dir+"/"+filename); } catch(e) { log.error(e); } } */ } var info_el = top.getElement(".spt_info"); spt.panel.load(info_el, class_name, values); spt.app_busy.hide(); ''' } # Save button button = ActionButtonWdg(title="Save", tip="Save Rule") td.add(button) button.add_style("float: right") behavior['mode'] = 'save' button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); spt.app_busy.show("Saving ..."); var class_name = 'tactic.command.CheckinRuleSaveCmd'; var server = TacticServerStub.get(); server.execute_cmd(class_name, values); spt.panel.refresh(top, {}); spt.app_busy.hide(); ''' }) # Scan button button = ActionButtonWdg(title="Scan", tip="Click to Scan") td.add(button) button.add_style("float: left") # set a limit #limit = TextWdg("limit") #td.add(limit) #text.add_style("float: left") behavior = behavior.copy() behavior['mode'] = 'scan' button.add_behavior(behavior) # Test button button = ActionButtonWdg(title="Test", tip="Do a test of this rule") td.add(button) behavior = behavior.copy() behavior['mode'] = 'test' button.add_behavior(behavior) button.add_style("float: left") # Ingest button button = ActionButtonWdg(title="Ingest", tip="Click to start ingesting") td.add(button) behavior = behavior.copy() behavior['mode'] = 'checkin' button.add_behavior(behavior) table.add_behavior({ 'type': 'listen', 'event_name': 'file_browser|select', 'cbjs_action': ''' var dirname = bvr.firing_data.dirname; var top = bvr.src_el.getParent(".spt_ingestion_top"); var kwargs = { base_dir: dirname }; spt.panel.load(top, top.getAttribute("spt_class_name"), kwargs); ''' }) top.add(self.get_info_wdg()) return top
def get_display(self): top = self.top top.add_class("spt_sign_in_top") top.add_color("background", "background") top.add_style("padding: 30px") top.add_style("width: 300px") icon = IconWdg("Not signed in", IconWdg.WARNING) top.add(icon) top.add("You are not signed into Perforce.") top.add("<br/>"*2) table = Table() top.add(table) from tactic.ui.input import TextInputWdg, PasswordInputWdg table.add_row() td = table.add_cell("Port: ") td.add_style("width: 75px") text = TextInputWdg(name="port") td = table.add_cell(text) td.add_style("vertical-align: top") text.set_value("1666") table.add_row() td = table.add_cell("Login: "******"vertical-align: top") td.add_style("width: 75px") text = TextInputWdg(name="user") td = table.add_cell(text) td.add_style("vertical-align: top") user = Environment.get_user_name() text.set_value(user) table.add_row() td = table.add_cell("Password: "******"vertical-align: top") text = PasswordInputWdg(name="password") table.add_cell(text) tr = table.add_row() table.add_row_cell(" ") tr = table.add_row() tr.add_class("spt_workspaces") #tr.add_style("display: none") td = table.add_cell("Workspace: ") td.add_style("vertical-align: top") workspaces = self.kwargs.get("workspaces") td = table.add_cell() button = ActionButtonWdg(width='55', title="Lookup") td.add(button) button.add_style("float: right") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' try { var workspaces = spt.scm.get_workspaces(); var clients = []; for (var i = 0; i < workspaces.length; i++) { clients.push(workspaces[i].client); } clients = clients.join("|"); var kwargs = { workspaces: clients } spt.scm.show_login(kwargs); } catch(e) { spt.scm.signout_user(); spt.scm.show_login(); } ''' } ) if not workspaces: text = TextInputWdg(name="workspace") text.add_style("width: 165px") td.add(text) else: select = SelectWdg("workspace") td.add(select) select.set_option("values", workspaces) top.add("<br/>"*2) button = ActionButtonWdg(title="Sign In >>", size='medium') top.add(button) button.add_style("float: right") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_sign_in_top"); var values = spt.api.get_input_values(top); var port = values.port[0]; var user = values.user[0]; var password = values.password[0]; var client = values.workspace[0]; if (!port) { alert("No port specified"); return; } if (!user) { alert("No user specified"); return; } if (!client) { alert("No workspace specified"); return; } // login in user spt.scm.port = port; spt.scm.user = user; spt.scm.password = password; // test the connection var ping = spt.scm.ping(); if (ping != "OK") { alert("Cannot connect to Perforce") spt.scm.signout_user(); spt.scm.show_login(); } else { spt.scm.client = client; // close the popup var popup = bvr.src_el.getParent(".spt_popup"); if (popup) { spt.popup.destroy(popup); } // NOTE: this is global: find a check-in widget and refresh var checkin_el = $(document.body).getElement(".spt_checkin_top"); spt.panel.refresh(checkin_el); } ''' } ) top.add("<br/>"*2) return top
def get_display(my): top = my.top top.add_class("spt_sign_in_top") top.add_color("background", "background") top.add_style("padding: 30px") top.add_style("width: 300px") icon = IconWdg("Not signed in", IconWdg.WARNING) top.add(icon) top.add("You are not signed into Perforce.") top.add("<br/>"*2) table = Table() top.add(table) from tactic.ui.input import TextInputWdg, PasswordInputWdg table.add_row() td = table.add_cell("Port: ") td.add_style("width: 75px") text = TextInputWdg(name="port") table.add_cell(text) text.set_value("1666") tr = table.add_row() table.add_row_cell(" ") table.add_row() td = table.add_cell("Login: "******"width: 75px") text = TextInputWdg(name="user") table.add_cell(text) user = Environment.get_user_name() text.set_value(user) table.add_row() table.add_cell("Password: "******"password") table.add_cell(text) tr = table.add_row() table.add_row_cell(" ") tr = table.add_row() table.add_cell("Workspace: ") text = TextInputWdg(name="workspace") table.add_cell(text) text.add_class("spt_workspace") top.add("<br/>"*2) button = ActionButtonWdg(title="Sign In", icon=IconWdg.PUBLISH, size='medium') top.add(button) button.add_style("float: right") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_sign_in_top"); var values = spt.api.get_input_values(top); var port = values.port[0]; var user = values.user[0]; var password = values.password[0]; var client = values.workspace[0]; // login in user spt.scm.port = port; spt.scm.user = user; spt.scm.password = password; spt.scm.client = client; // test the connection var ping = spt.scm.ping(); if (ping != "OK") { spt.scm.show_login(); return; } // TODO: get the workspaces and use this as a list // For now, just fill it in with the first one if (!client) { var workspaces = spt.scm.get_workspaces(); if (workspaces.length > 0) { var workspace = workspaces[0]; var Root = workspace.root; // TODO: make sure Root == snapshot_dir console.log("workspace"); console.log(workspace); var client = workspace.client; var workspace_el = top.getElement(".spt_workspace"); workspace_el.value = client; } return; } // check the workspaces if (!spt.scm.check_workspace()) { alert("Problem with current workspace"); spt.scm.show_login(); return; } // close the popup var popup = bvr.src_el.getParent(".spt_popup"); if (popup) { spt.popup.destroy(popup); } // NOTE: this is global: find a check-in widget and refresh var checkin_el = $(document.body).getElement(".spt_checkin_top"); spt.panel.refresh(checkin_el); ''' } ) top.add("<br/>"*2) return top
def get_priority_widget(outer_div): priority_input = TextInputWdg() priority_input.set_name('priority') outer_div.add(get_label_widget('Priority')) outer_div.add(priority_input)
def get_text_input_wdg(name, data, width=200, timecode=False): textbox_wdg = TextInputWdg() textbox_wdg.set_id(name) textbox_wdg.set_name(name) textbox_wdg.add_style('width', '{0}px'.format(width)) if timecode: textbox_wdg.add_behavior(get_add_colons_for_time_behavior()) if data: textbox_wdg.set_value(data) return textbox_wdg
def get_nav_wdg(self): #base_dir = self.kwargs.get("base_dir") #location = self.kwargs.get("location") base_dir = self.session.get_value("base_dir") location = self.session.get_value("location") nav_wdg = DivWdg() nav_wdg.add("<b>Session 101 - Clean up self Crap</b><hr/>") nav_wdg.add_style("margin-bottom: 10px") nav_wdg.add_class("spt_file_nav") nav_wdg.add_style("width: 575px") nav_wdg.add_border() nav_wdg.set_round_corners() nav_wdg.add_style("padding: 5px") button = ActionButtonWdg(title="Scan", tip="Scan for files in specified folder") button.add_style("float: right") button.add_style("margin-top: -5px") nav_wdg.add(button) from tactic.ui.input import TextInputWdg title_wdg = "Session Title: " nav_wdg.add(title_wdg) text = TextInputWdg(name="title") text.add_class("spt_title") text.add_style("width: 300px") nav_wdg.add(text) nav_wdg.add("<br/><br/>") folder_wdg = "Base folder of this session: " nav_wdg.add(folder_wdg) text = TextInputWdg(name="base_dir") text.add_class("spt_base_dir") text.add_style("width: 300px") if base_dir: text.set_value(base_dir) nav_wdg.add(text) # add a hidden paths variable text = HiddenWdg("paths") text.add_class("spt_paths") nav_wdg.add(text) nav_wdg.add("<br/>") # add a hidden paths variable select = SelectWdg("location") if location: select.set_value(location) nav_wdg.add("<br/>") nav_wdg.add("Folder is on ") nav_wdg.add(select) select.set_option("values", "local|server") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var nav = top.getElement(".spt_file_nav"); var nav_values = spt.api.Utility.get_input_values(nav,null,false); var base_dir = nav_values.base_dir; var location = nav_values.location; spt.app_busy.show("Scanning", base_dir); if (location == 'local') { var applet = spt.Applet.get(); var paths = applet.list_dir(base_dir, 2); var paths_el = nav.getElement(".spt_paths"); var js_paths = []; for (var i = 0; i < paths.length; i++) { var js_path = paths[i].replace(/\\\\/g,"/"); if (applet.is_dir(js_path) ) { js_path = js_path + '/'; js_paths.push(js_path); } //if (i > 100) break; else { js_paths.push(js_path); } } paths_el.value = js_paths.join("|"); } //var nav_values = spt.api.Utility.get_input_values(nav,null,false); //spt.panel.refresh(top, nav_values); spt.tab.set_tab_top(top); spt.tab.select("files") var class_name = "tactic.ui.tools.IngestionToolDirListWdg"; var kwargs = { base_dir: base_dir, location: location, paths: js_paths } spt.tab.load_selected("files", "Files", class_name, kwargs); spt.app_busy.hide(); ''' } ) return nav_wdg
def get_display(my): top = my.top top.add_class("spt_script_editor_top") """ top.add_class("SPT_CHANGE") top.add_behavior( { 'type': 'load', 'cbjs_action': ''' register_change = function(bvr) { var change_top = bvr.src_el.getParent(".SPT_CHANGE"); change_top.addClass("SPT_HAS_CHANGES"); change_top.update_change(change_top, bvr); } has_changes = function(bvr) { var change_top = bvr.src_el.getParent(".SPT_CHANGE"); return change_top.hasClass("SPT_HAS_CHANGES"); } bvr.src_el.update_change = function(top, bvr) { change_el = top.getElement(".spt_change_element"); change_el.setStyle("display", ""); } ''' } ) """ change_div = DivWdg() top.add(change_div) #change_div.add("CHANGES!!!") change_div.add_style("display: none") change_div.add_class("spt_change_element") top.add_class("spt_panel") top.add_class("spt_js_editor") top.add_attr("spt_class_name", Common.get_full_class_name(my)) top.add_color("background", "background") top.add_style("padding", "10px") div = DivWdg() top.add(div) # if script_path script_path = my.kwargs.get("script_path") search_key = my.kwargs.get("search_key") if script_path: search = Search("config/custom_script") dirname = os.path.dirname(script_path) basename = os.path.basename(script_path) search.add_filter("folder", dirname) search.add_filter("title", basename) script_sobj = search.get_sobject() elif search_key: script_sobj = Search.get_by_search_key(search_key) else: script_sobj = None if script_sobj: script_code = script_sobj.get_value("code") script_folder = script_sobj.get_value("folder") script_name = script_sobj.get_value("title") script_value = script_sobj.get_value("script") script_language = script_sobj.get_value("langauge") else: script_code = '' script_folder = '' script_name = '' script_value = '' editor = AceEditorWdg(custom_script=script_sobj) my.editor_id = editor.get_editor_id() if not Container.get_dict("JSLibraries", "spt_script_editor"): div.add_behavior({ 'type': 'load', 'cbjs_action': my.get_onload_js() }) # create the insert button help_button_wdg = DivWdg() div.add(help_button_wdg) help_button_wdg.add_style("float: right") help_button = ActionButtonWdg(title="?", tip="Script Editor Help", size='s') help_button_wdg.add(help_button) help_button.add_behavior({ 'type': 'click_up', 'cbjs_action': '''spt.help.load_alias("tactic-script-editor")''' }) # create the insert button add_button_wdg = DivWdg() add_button_wdg.add_style("float: right") add_button = ActionButtonWdg(title="Manage") add_button.add_behavior({ 'type': 'click_up', 'cbfn_action': 'spt.popup.get_widget', 'options': { 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'title': 'Manage: [%s]' % my.search_type }, 'args': { 'search_type': my.search_type, 'view': 'table' }, }) add_button_wdg.add(add_button) div.add(add_button_wdg) button_div = editor.get_buttons_wdg() div.add(button_div) """ button_div = DivWdg() #div.add(button_div) button_div.add_style("text-align: left") button = ActionButtonWdg(title="Run") button.add_style("float: left") button.add_style("margin: 0 10 3") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' //var editor = $('shelf_script'); var value = editAreaLoader.getValue('shelf_script') eval( value ) ''' } ) button_div.add(button) button = ActionButtonWdg(title="Save") button.add_style("float: left") button.add_style("margin: 0 10 3") #button = ProdIconButtonWdg("Save") #button.add_style("margin: 5 10") behavior = { 'type': 'click_up', 'cbfn_action': 'spt.script_editor.save_script_cbk' } button.add_behavior(behavior) button_div.add(button) button = ActionButtonWdg(title="Clear") button.add_style("float: left") button.add_style("margin: 0 10 3") #button = ProdIconButtonWdg("Clear") #button.add_style("margin: 5 10") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.api.Utility.clear_inputs( bvr.src_el.getParent('.spt_js_editor') ); editAreaLoader.setValue('shelf_script', ''); ''' } ) button_div.add(button) """ div.add("<br clear='all'/><br/>") save_wdg = DivWdg() div.add(save_wdg) save_wdg.add_style("padding: 2px 5px 6px 5px") #save_wdg.add_color("background", "background", -5) # script code save_span = Table() save_wdg.add(save_span) save_span.add_row() code_span = SpanWdg() code_span.add("<b>Code: </b>") save_span.add_cell(code_span) code_text = TextInputWdg(name="shelf_code") code_text.add_style("display: inline") code_text.add_style("width: 100px") code_text.set_value(script_code) code_text.add_attr("readonly", "true") code_text.set_id("shelf_code") code_text.add_class("spt_code") td = save_span.add_cell(code_text) td.add_style("padding-top: 10px") save_span.add_cell(" ") # script name (path??) save_span.add_cell("<b>Script Path: </b>") save_text = TextInputWdg(name="shelf_folder") save_text.add_style("width: 120px") save_text.add_attr("size", "40") save_text.set_id("shelf_folder") save_text.add_class("spt_folder") save_text.set_value(script_folder) td = save_span.add_cell(save_text) td.add_style("padding-top: 10px") save_span.add_cell(" / ") save_text = TextInputWdg(name="shelf_title") save_text.add_style("width: 350px") save_text.add_attr("size", "40") save_text.set_id("shelf_title") save_text.add_class("spt_title") save_text.set_value(script_name) td = save_span.add_cell(save_text) td.add_style("padding-top: 10px") from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() table.add_row() td = table.add_cell(resize=False) td.add_style("vertical-align: top") td.add(editor) text = TextAreaWdg("shelf_script") #text.add_behavior( { # 'type': 'double_click', # 'cbjs_action': ''' # var text = $('shelf_script'); # editor(text) # ''' # } ) """ text.set_id("shelf_script") text.add_style("width: 550px") text.add_style("height: 300px") text.add_class("codepress") text.add_class("html") text.add_behavior( { 'type': 'load', 'cbjs_action': ''' editAreaLoader.init({ id: "shelf_script", // id of the textarea to transform start_highlight: true, // if start with highlight allow_resize: "both", allow_toggle: true, word_wrap: true, language: "en", syntax: "js", // need to make this setable replace_tab_by_spaces: "4", font_size: "8", toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, highlight", syntax_selection_allow: "js,python" }); ''' } ) text.add_style("margin-top: 5px") text.add_style("font-family: courier new") text.add_style("font-size: 11px") text.set_id("shelf_script") #text.add_attr("cols", "80") #text.add_attr("rows", "20") text.add_style("min-height", "400px") text.add_style("height", "400px") text.add_style("width", "600px") text.set_value(script_value) td.add(text) """ td = table.add_cell() td.add_style('vertical-align: top') td.add(my.get_script_wdg()) table.add_row(resize=False) div.add(table) if my.kwargs.get("is_refresh"): return div else: return top
def get_total_program_runtime_widget(outer_div): total_program_runtime_input = TextInputWdg() total_program_runtime_input.set_name('total_program_runtime') outer_div.add(get_label_widget('Total Program Runtime')) outer_div.add(total_program_runtime_input)
def get_display(self): search_type = self.kwargs.get("search_type") div = self.top div.add("List of Saved Searches: ") div.add(HtmlElement.br(2)) div.add_style("margin: 20px") div.add_style("width: 400px") div.add_class("spt_saved_search_top") try: search = Search("config/widget_config") search.add_op("begin") search.add_filter("view", 'saved_search:%', op="like") search.add_filter("category", 'search_filter') search.add_op("or") search.add_op("begin") search.add_user_filter() search.add_filter("login", "NULL", op="is", quoted=False) search.add_op("or") search.add_filter("search_type", search_type) configs = search.get_sobjects() except SearchException as e: print("WARNING: ", e) configs = [] except: SearchWdg.clear_search_data(search_type) raise """ from tactic.ui.panel import TableLayoutWdg element_names = ['view','name','description','delete'] table = TableLayoutWdg( search_type=search_type, element_names=element_names, search=search, show_shelf=False, show_border=False, show_search_limit=False, height="auto", ) div.add(table) """ values = [x.get("view") for x in configs] labels = [x.get("title") or x.get("view") for x in configs] select = SelectWdg("saved_search") div.add(select) select.set_id("saved_search") select.add_class("spt_saved_search_input") select.add_empty_option("-- Select --") select.set_option("values", values) select.set_option("labels", labels) retrieve_button = ActionButtonWdg(title="Load") behavior = { 'type': 'click', #'cbjs_action': 'spt.dg_table.retrieve_search_cbk(evt, bvr);' 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_saved_search_top") var input = top.getElement(".spt_saved_search_input"); var value = input.value; if (!value) { spt.alert("Please select a saved search to load."); return; } var popup = bvr.src_el.getParent(".spt_popup"); var activator = popup.activator; var layout = activator.getElement(".spt_layout"); spt.table.set_layout(layout); spt.table.load_search(value); ''' } retrieve_button.add_behavior( behavior ) retrieve_button.add_style("display: inline-block") remove_button = ActionButtonWdg(title="Remove") remove_button.add_behavior( { 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_saved_search_top") var input = top.getElement(".spt_saved_search_input"); var value = input.value; if (!value) { spt.alert("Please select a saved search to remove."); return; } spt.alert("Remove: " + value); ''' } ) remove_button.add_style("display: inline-block") cancel_button = ActionButtonWdg(title="Cancel") cancel_button.add_behavior( { 'cbjs_action': ''' var popup = bvr.src_el.getParent(".spt_popup"); spt.popup.close(popup); ''' } ) cancel_button.add_style("display: inline-block") div.add("<br/>") button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(retrieve_button) button_div.add(" ") button_div.add(remove_button) button_div.add(" ") button_div.add(cancel_button) div.add(button_div) div.add("<hr/>") save_div = DivWdg() div.add(save_div) save_div.add("Save Current Search") save_div.add("<br/>") save_div.add("<br/>") text = TextInputWdg(name="new_search_name") save_div.add(text) text.add_class("spt_new_search_name") save_div.add("<br/>") save_button = ActionButtonWdg(title="Save Search", width="200") save_div.add(save_button) save_button.add_behavior( { 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_saved_search_top"); var input = top.getElement(".spt_new_search_name"); var value = input.value; if (!value) { spt.alert("No view name specified"); return; } spt.table.save_search(value, {personal: true}); spt.notify.show_message("Search saved"); var popup = bvr.src_el.getParent(".spt_popup"); spt.popup.close(popup); ''' } ) save_button.add_style("display: inline-block") return div
def common_wdg(my,vendor): div = DivWdg() div.add_class("spt_db_options") div.add_style("margin: 20px") if vendor !='MySQL': div.add_attr("spt_vendor", "Other") table = Table() div.add(table) table.add_color("color", "color") table.add_row() table.add_cell("Server: ") text = TextInputWdg(name="server") text.set_value("localhost") table.add_cell(text) server = Config.get_value("database", "server") if server: text.set_value(server) table.add_row() table.add_cell("Port: ") text = TextInputWdg(name="port") table.add_cell(text) port = Config.get_value("database", "port") if port: text.set_value(port) table.add_row() table.add_cell("Login: "******"user") table.add_cell(text) user = Config.get_value("database", "user") if user: text.set_value(user) table.add_row() text = PasswordInputWdg(name="password") table.add_cell("Password: "******"database", "password") if password: text.set_value(password) if vendor == 'MySQL': div.add_attr("spt_vendor", "MySQL") table.add_row() text = TextInputWdg(name="encoding") table.add_cell("Encoding: ") table.add_cell(text) encoding = Config.get_value("database", "encoding") if encoding: text.set_value(encoding) table.add_row() text = TextInputWdg(name="charset") table.add_cell("Charset: ") table.add_cell(text) charset = Config.get_value("database", "charset") if charset: text.set_value(charset) #from pyasm.search import Sql #sql.connect() return div
def get_display(my): top = my.top top.add_class("spt_script_editor_top") """ top.add_class("SPT_CHANGE") top.add_behavior( { 'type': 'load', 'cbjs_action': ''' register_change = function(bvr) { var change_top = bvr.src_el.getParent(".SPT_CHANGE"); change_top.addClass("SPT_HAS_CHANGES"); change_top.update_change(change_top, bvr); } has_changes = function(bvr) { var change_top = bvr.src_el.getParent(".SPT_CHANGE"); return change_top.hasClass("SPT_HAS_CHANGES"); } bvr.src_el.update_change = function(top, bvr) { change_el = top.getElement(".spt_change_element"); change_el.setStyle("display", ""); } ''' } ) """ change_div = DivWdg() top.add(change_div) #change_div.add("CHANGES!!!") change_div.add_style("display: none") change_div.add_class("spt_change_element"); top.add_class("spt_panel") top.add_class("spt_js_editor") top.add_attr("spt_class_name", Common.get_full_class_name(my) ) top.add_color("background", "background") top.add_style("padding", "10px") div = DivWdg() top.add(div) # if script_path script_path = my.kwargs.get("script_path") search_key = my.kwargs.get("search_key") if script_path: search = Search("config/custom_script") dirname = os.path.dirname(script_path) basename = os.path.basename(script_path) search.add_filter("folder", dirname) search.add_filter("title", basename) script_sobj = search.get_sobject() elif search_key: script_sobj = Search.get_by_search_key(search_key) else: script_sobj = None if script_sobj: script_code = script_sobj.get_value("code") script_folder = script_sobj.get_value("folder") script_name = script_sobj.get_value("title") script_value = script_sobj.get_value("script") script_language = script_sobj.get_value("langauge") else: script_code = '' script_folder = '' script_name = '' script_value = '' editor = AceEditorWdg(custom_script=script_sobj) my.editor_id = editor.get_editor_id() if not Container.get_dict("JSLibraries", "spt_script_editor"): div.add_behavior( { 'type': 'load', 'cbjs_action': my.get_onload_js() } ) # create the insert button help_button_wdg = DivWdg() div.add(help_button_wdg) help_button_wdg.add_style("float: right") help_button = ActionButtonWdg(title="?", tip="Script Editor Help", size='s') help_button_wdg.add(help_button) help_button.add_behavior( { 'type': 'click_up', 'cbjs_action': '''spt.help.load_alias("tactic-script-editor")''' } ) # create the insert button add_button_wdg = DivWdg() add_button_wdg.add_style("float: right") add_button = ActionButtonWdg(title="Manage") add_button.add_behavior( { 'type': 'click_up', 'cbfn_action': 'spt.popup.get_widget', 'options': { 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'title': 'Manage: [%s]' % my.search_type }, 'args': { 'search_type': my.search_type, 'view': 'table' }, } ) add_button_wdg.add(add_button) div.add(add_button_wdg) button_div = editor.get_buttons_wdg() div.add(button_div) """ button_div = DivWdg() #div.add(button_div) button_div.add_style("text-align: left") button = ActionButtonWdg(title="Run") button.add_style("float: left") button.add_style("margin: 0 10 3") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' //var editor = $('shelf_script'); var value = editAreaLoader.getValue('shelf_script') eval( value ) ''' } ) button_div.add(button) button = ActionButtonWdg(title="Save") button.add_style("float: left") button.add_style("margin: 0 10 3") #button = ProdIconButtonWdg("Save") #button.add_style("margin: 5 10") behavior = { 'type': 'click_up', 'cbfn_action': 'spt.script_editor.save_script_cbk' } button.add_behavior(behavior) button_div.add(button) button = ActionButtonWdg(title="Clear") button.add_style("float: left") button.add_style("margin: 0 10 3") #button = ProdIconButtonWdg("Clear") #button.add_style("margin: 5 10") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.api.Utility.clear_inputs( bvr.src_el.getParent('.spt_js_editor') ); editAreaLoader.setValue('shelf_script', ''); ''' } ) button_div.add(button) """ div.add( "<br clear='all'/><br/>") save_wdg = DivWdg() div.add(save_wdg) save_wdg.add_style("padding: 2px 5px 6px 5px") #save_wdg.add_color("background", "background", -5) # script code save_span = Table() save_wdg.add(save_span) save_span.add_row() code_span = SpanWdg() code_span.add("<b>Code: </b>") save_span.add_cell(code_span) code_text = TextInputWdg(name="shelf_code") code_text.add_style("display: inline") code_text.add_style("width: 100px") code_text.set_value(script_code) code_text.add_attr("readonly", "true") code_text.set_id("shelf_code") code_text.add_class("spt_code") td = save_span.add_cell(code_text) td.add_style("padding-top: 10px") save_span.add_cell(" ") # script name (path??) save_span.add_cell("<b>Script Path: </b>") save_text = TextInputWdg(name="shelf_folder") save_text.add_style("width: 120px") save_text.add_attr("size", "40") save_text.set_id("shelf_folder") save_text.add_class("spt_folder") save_text.set_value(script_folder) td = save_span.add_cell(save_text) td.add_style("padding-top: 10px") save_span.add_cell(" / ") save_text = TextInputWdg(name="shelf_title") save_text.add_style("width: 350px") save_text.add_attr("size", "40") save_text.set_id("shelf_title") save_text.add_class("spt_title") save_text.set_value(script_name) td = save_span.add_cell(save_text) td.add_style("padding-top: 10px") from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() table.add_row() td = table.add_cell(resize=False) td.add_style("vertical-align: top") td.add(editor) text = TextAreaWdg("shelf_script") #text.add_behavior( { # 'type': 'double_click', # 'cbjs_action': ''' # var text = $('shelf_script'); # editor(text) # ''' # } ) """ text.set_id("shelf_script") text.add_style("width: 550px") text.add_style("height: 300px") text.add_class("codepress") text.add_class("html") text.add_behavior( { 'type': 'load', 'cbjs_action': ''' editAreaLoader.init({ id: "shelf_script", // id of the textarea to transform start_highlight: true, // if start with highlight allow_resize: "both", allow_toggle: true, word_wrap: true, language: "en", syntax: "js", // need to make this setable replace_tab_by_spaces: "4", font_size: "8", toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, highlight", syntax_selection_allow: "js,python" }); ''' } ) text.add_style("margin-top: 5px") text.add_style("font-family: courier new") text.add_style("font-size: 11px") text.set_id("shelf_script") #text.add_attr("cols", "80") #text.add_attr("rows", "20") text.add_style("min-height", "400px") text.add_style("height", "400px") text.add_style("width", "600px") text.set_value(script_value) td.add(text) """ td = table.add_cell() td.add_style('vertical-align: top') td.add(my.get_script_wdg()) table.add_row(resize=False) div.add(table) if my.kwargs.get("is_refresh"): return div else: return top
def get_display(self): top = self.top top.add_color("background", "background") top.add_class("spt_pipelines_top") self.set_as_panel(top) inner = DivWdg() top.add(inner) search_type = self.kwargs.get("search_type") pipeline_code = self.kwargs.get("pipeline_code") if search_type: search = Search("sthpw/pipeline") search.add_filter("search_type", search_type) pipelines = search.get_sobjects() else: pipeline = Pipeline.get_by_code(pipeline_code) if pipeline: pipelines = [pipeline] else: pipelines = [] if not pipelines: div = DivWdg() inner.add(div) inner.add_style("padding: 50px") div.add_border() div.add_color("color", "color3") div.add_color("background", "background3") div.add_style("width: 400px") div.add_style("height: 100px") div.add_style("padding: 30px") icon = IconWdg("WARNING", IconWdg.WARNING) div.add(icon) div.add("<b>This Searchable Type does not have pipelines defined.</b>") div.add("<br/>"*2) div.add("<b style='padding-left: 35px'>Click Create to add one...</b>") div.add("<br/>"*2) button_div = DivWdg() div.add(button_div) button = ActionButtonWdg(title="Create", tip="Create pipeline") button_div.add(button) button.add_style("margin: auto") button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'cbjs_action': ''' var server = TacticServerStub.get(); var cmd = 'tactic.ui.startup.PipelineCreateCbk'; var kwargs = { search_type: bvr.search_type } server.execute_cmd(cmd, kwargs) var top = bvr.src_el.getParent(".spt_pipelines_top"); spt.panel.refresh(top); ''' } ) return top # get the defalt task statuses task_pipeline = Pipeline.get_by_code("task") if task_pipeline: statuses = task_pipeline.get_process_names() else: statuses = ['Pending', 'In Progress', 'Complete'] statuses_str = ",".join(statuses) pipelines_div = DivWdg() inner.add( pipelines_div ) pipelines_div.add_style("font-size: 12px") pipelines_div.add_style("padding: 10px") buttons_div = DivWdg() pipelines_div.add(buttons_div) #button = SingleButtonWdg( title="Save Pipelines", icon=IconWdg.SAVE ) button = ActionButtonWdg( title="Save" ) buttons_div.add(button) button.add_behavior( { 'type': 'click_up', 'default_statuses': statuses_str, 'cbjs_action': ''' spt.app_busy.show("Saving Pipeline...") setTimeout(function() { try { var top = bvr.src_el.getParent(".spt_pipelines_top"); // get all the pipeline divs var pipeline_els = top.getElements(".spt_pipeline_top"); var data = {}; for ( var i = 0; i < pipeline_els.length; i++) { var pipeline_code = pipeline_els[i].getAttribute("spt_pipeline_code"); var values = spt.api.Utility.get_input_values(pipeline_els[i]); data[pipeline_code] = values; } var class_name = 'tactic.ui.startup.PipelineEditCbk'; var kwargs = { data: data } var server = TacticServerStub.get(); server.execute_cmd(class_name, kwargs); } catch(e) { spt.alert(spt.exception.handler(e)); } spt.app_busy.hide(); } , 100); ''' } ) buttons_div.add("<br clear='all'/>") buttons_div.add_style("margin-bottom: 5px") for pipeline in pipelines: pipeline_div = DivWdg() pipelines_div.add(pipeline_div) pipeline_div.add_class("spt_pipeline_top") code = pipeline.get_code() label = '%s (%s)' %(pipeline.get('name'), code) pipeline_div.add_attr("spt_pipeline_code", code) title = DivWdg() pipeline_div.add(title) title.add("Pipeline: ") title.add(label) title.add_style("padding: 8px 10px") title.add_color("background", "background3") title.add_style("font-weight: bold") title.add_style("margin: -10 -10 5 -10") header_wdg = DivWdg() pipeline_div.add(header_wdg) header_wdg.add_color("background", "background", -5) headers = ['Process', 'Description', 'Task Status'] widths = ['100px', '180px', '210px'] for header, width in zip(headers,widths): th = DivWdg() header_wdg.add(th) th.add("<b>%s</b>" % header) th.add_style("float: left") th.add_style("width: %s" % width) th.add_style("padding: 8px 3px") header_wdg.add("<br clear='all'/>") # get all of the process sobjects from this pipeline pipeline_code = pipeline.get_code() search = Search("config/process") search.add_filter("pipeline_code", pipeline.get_code() ) process_sobjs = search.get_sobjects() process_sobj_dict = {} for process_sobj in process_sobjs: process = process_sobj.get_value("process") process_sobj_dict[process] = process_sobj from tactic.ui.container import DynamicListWdg dyn_list = DynamicListWdg() pipeline_div.add(dyn_list) pipeline_div.add_style("width: 725px") processes = pipeline.get_process_names() if not processes: processes.append("") processes.append("") processes.append("") processes.insert(0, "") for i, process in enumerate(processes): if process == '': process_name = '' description = '' else: process_sobj = process_sobj_dict.get(process) if process_sobj: process_name = process_sobj.get_value("process") description = process_sobj.get_value("description") else: if isinstance(process,basestring): process_name = process else: process_name = process.get_name() deccription = '' process_type = 'manual' process_xpos = '' process_ypos = '' # get the task pipeline for this process if process_name: process = pipeline.get_process(process_name) process_type = process.get_type() process_xpos = process.get_attribute('xpos') process_ypos = process.get_attribute('ypos') task_pipeline_code = process.get_task_pipeline() if task_pipeline_code != "task": task_pipeline = Search.get_by_code("sthpw/pipeline", task_pipeline_code) else: task_pipeline = None else: task_pipeline_code = "task" task_pipeline = None process_div = DivWdg() process_div.add_style("float: left") process_div.add_class("spt_process_top") if i == 0: dyn_list.add_template(process_div) else: dyn_list.add_item(process_div) #process_div.add_style("padding-left: 10px") #process_div.add_style("margin: 5px") table = Table() process_div.add(table) table.add_row() text = TextInputWdg(name="process") process_cell = table.add_cell(text) text.add_style("width: 95px") text.add_style("margin: 5px") text.set_value(process_name) text.add_class("spt_process") # the template has a border if i == 0: text.add_style("border: solid 1px #AAA") hidden = HiddenWdg(name='process_type') hidden.set_value(process_type) process_cell.add(hidden) hidden = HiddenWdg(name='process_xpos') hidden.set_value(process_xpos) process_cell.add(hidden) hidden = HiddenWdg(name='process_ypos') hidden.set_value(process_ypos) process_cell.add(hidden) text = TextInputWdg(name="description") table.add_cell(text) text.add_style("width: 175px") text.add_style("margin: 5px") text.set_value(description) # the template has a border if i == 0: text.add_style("border: solid 1px #AAA") if process_type in ['manual','approval']: read_only = False else: read_only = True text = TextInputWdg(name="task_status", read_only=read_only) table.add_cell(text) text.add_style("width: 325px") text.add_style("margin: 5px") #text.set_value(statuses_str) #text.add_style("opacity: 0.5") text.add_style("border-style: none") if process_type in ['manual','approval']: if task_pipeline: statuses = task_pipeline.get_process_names() text.set_value(",".join(statuses)) else: text.set_value("(default)") text.add_behavior( { 'type': 'click_up', 'statuses': statuses_str, 'cbjs_action': ''' if (bvr.src_el.value == '(default)') { bvr.src_el.value = bvr.statuses; } ''' } ) table.add_cell(" "*2) button = IconButtonWdg(tip="Trigger", icon=IconWdg.ARROW_OUT) table.add_cell(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'pipeline_code': pipeline_code, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_process_top"); var process_el = top.getElement(".spt_process"); var process = process_el.value; if (process == "") { alert("Process value is empty"); return; } var class_name = 'tactic.ui.tools.TriggerToolWdg'; var kwargs = { mode: "pipeline", process: process, pipeline_code: bvr.pipeline_code }; spt.panel.load_popup("Trigger", class_name, kwargs); ''' } ) """ button = IconButtonWdg(tip="Edit", icon=IconWdg.EDIT) table.add_cell(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'pipeline_code': pipeline_code, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_process_top"); var process_el = top.getElement(".spt_process"); var process = process_el.value; if (process == "") { alert("Process value is empty"); return; } var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { expression: "@SOBJECT(config/process['process','"+process+"'])" } spt.panel.load_popup("Trigger", class_name, kwargs); ''' } ) """ table.add_cell(" "*3) pipeline_div.add("<br clear='all'/>") pipeline_div.add("<br clear='all'/>") if self.kwargs.get("is_refresh"): return inner else: return top
def get_process_widget(outer_div): process_input = TextInputWdg() process_input.set_name('process') outer_div.add(get_label_widget('Process')) outer_div.add(process_input)
def get_display(my): top = my.top top.add_class("spt_script_editor_top") """ top.add_class("SPT_CHANGE") top.add_behavior( { 'type': 'load', 'cbjs_action': ''' register_change = function(bvr) { var change_top = bvr.src_el.getParent(".SPT_CHANGE"); change_top.addClass("SPT_HAS_CHANGES"); change_top.update_change(change_top, bvr); } has_changes = function(bvr) { var change_top = bvr.src_el.getParent(".SPT_CHANGE"); return change_top.hasClass("SPT_HAS_CHANGES"); } bvr.src_el.update_change = function(top, bvr) { change_el = top.getElement(".spt_change_element"); change_el.setStyle("display", ""); } ''' } ) """ change_div = DivWdg() top.add(change_div) #change_div.add("CHANGES!!!") change_div.add_style("display: none") change_div.add_class("spt_change_element"); top.add_class("spt_panel") top.add_class("spt_js_editor") top.add_attr("spt_class_name", Common.get_full_class_name(my) ) top.add_color("background", "background") top.add_style("padding", "10px") div = DivWdg() top.add(div) # if script_path script_path = my.kwargs.get("script_path") search_key = my.kwargs.get("search_key") if script_path: search = Search("config/custom_script") dirname = os.path.dirname(script_path) basename = os.path.basename(script_path) search.add_filter("folder", dirname) search.add_filter("title", basename) script_sobj = search.get_sobject() elif search_key: script_sobj = Search.get_by_search_key(search_key) else: script_sobj = None if script_sobj: script_code = script_sobj.get_value("code") script_folder = script_sobj.get_value("folder") script_name = script_sobj.get_value("title") script_value = script_sobj.get_value("script") script_language = script_sobj.get_value("language") else: script_code = '' script_folder = '' script_name = '' script_value = '' editor = AceEditorWdg(custom_script=script_sobj) my.editor_id = editor.get_editor_id() if not Container.get_dict("JSLibraries", "spt_script_editor"): div.add_behavior( { 'type': 'load', 'cbjs_action': my.get_onload_js() } ) # create the insert button help_button_wdg = DivWdg() div.add(help_button_wdg) help_button_wdg.add_style("float: right") help_button = ActionButtonWdg(title="?", tip="Script Editor Help", size='s') help_button_wdg.add(help_button) help_button.add_behavior( { 'type': 'click_up', 'cbjs_action': '''spt.help.load_alias("tactic-script-editor")''' } ) # create the insert button add_button_wdg = DivWdg() add_button_wdg.add_style("float: right") add_button = ActionButtonWdg(title="Manage") add_button.add_behavior( { 'type': 'click_up', 'cbfn_action': 'spt.popup.get_widget', 'options': { 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'title': 'Manage: [%s]' % my.search_type }, 'args': { 'search_type': my.search_type, 'view': 'table', 'show_shelf': False, 'element_names': ['folder', 'title', 'description', 'language'], }, } ) add_button_wdg.add(add_button) div.add(add_button_wdg) button_div = editor.get_buttons_wdg() div.add(button_div) """ button_div = DivWdg() #div.add(button_div) button_div.add_style("text-align: left") button = ActionButtonWdg(title="Run") button.add_style("float: left") button.add_style("margin: 0 10 3") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' //var editor = $('shelf_script'); var value = editAreaLoader.getValue('shelf_script') eval( value ) ''' } ) button_div.add(button) button = ActionButtonWdg(title="Save") button.add_style("float: left") button.add_style("margin: 0 10 3") #button = ProdIconButtonWdg("Save") #button.add_style("margin: 5 10") behavior = { 'type': 'click_up', 'cbfn_action': 'spt.script_editor.save_script_cbk' } button.add_behavior(behavior) button_div.add(button) button = ActionButtonWdg(title="Clear") button.add_style("float: left") button.add_style("margin: 0 10 3") #button = ProdIconButtonWdg("Clear") #button.add_style("margin: 5 10") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.api.Utility.clear_inputs( bvr.src_el.getParent('.spt_js_editor') ); editAreaLoader.setValue('shelf_script', ''); ''' } ) button_div.add(button) """ div.add( "<br clear='all'/><br/>") save_wdg = DivWdg() div.add(save_wdg) save_wdg.add_style("padding: 2px 5px 6px 5px") #save_wdg.add_color("background", "background", -5) # script code save_span = Table() save_wdg.add(save_span) save_span.add_row() code_span = SpanWdg() code_span.add("<b>Code: </b>") td = save_span.add_cell(code_span) td.add_style("display: none") code_text = TextInputWdg(name="shelf_code") code_text.add_style("display: inline") code_text.add_style("width: 100px") code_text.set_value(script_code) code_text.add_attr("readonly", "true") code_text.set_id("shelf_code") code_text.add_class("spt_code") td = save_span.add_cell(code_text) td.add_style("padding-top: 10px") td.add_style("display: none") save_span.add_cell(" ") # script name (path??) td = save_span.add_cell("<b>Script Path: </b>") td.add_style("padding-top: 10px") save_text = TextInputWdg(name="shelf_folder") save_text.add_style("width: 250px") save_text.set_id("shelf_folder") save_text.add_class("spt_folder") save_text.set_value(script_folder) td = save_span.add_cell(save_text) td.add_style("padding-top: 10px") td = save_span.add_cell(" / ") td.add_style("padding-top: 10px") td.add_style("font-size: 1.5em") save_text = TextInputWdg(name="shelf_title") save_text.add_style("width: 350px") save_text.add_attr("size", "40") save_text.set_id("shelf_title") save_text.add_class("spt_title") save_text.set_value(script_name) td = save_span.add_cell(save_text) td.add_style("padding-top: 10px") from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() table.add_row() td = table.add_cell(resize=False) td.add_style("vertical-align: top") td.add(editor) text = TextAreaWdg("shelf_script") td = table.add_cell() td.add_style('vertical-align: top') td.add(my.get_script_wdg()) table.add_row(resize=False) div.add(table) if my.kwargs.get("is_refresh"): return div else: return top
def get_display(self): top = self.top self.set_as_panel(top) top.add_class("spt_ingestion_top") top.add_color("background", "background", -5) self.data = {} rules_div = DivWdg() top.add(rules_div) rules_div.add_style("padding: 10px") rules_div.add("Rules: ") rules_select = SelectWdg("rule_code") rule_code = self.get_value('rule_code') if rule_code: rules_select.set_value(rule_code) rules_select.set_option("query", "config/ingest_rule|code|title") rules_select.add_empty_option("-- New --") rules_div.add(rules_select) rules_select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var class_name = 'tactic.ui.tools.IngestionToolWdg'; spt.panel.load(top, class_name, {rule_code: value} ); ''' } ) rules_div.add("<hr/>") # read from the database if rule_code: search = Search("config/ingest_rule") search.add_filter("code", rule_code) sobject = search.get_sobject() else: sobject = None if sobject: self.data = sobject.get_value("data") if self.data: self.data = jsonloads(self.data) session_code = self.kwargs.get("session_code") if session_code: session = Search.get_by_code("config/ingest_session", session_code) else: if sobject: session = sobject.get_related_sobject("config/ingest_session") print("sobject: ", sobject.get_code(), sobject.get_value("spt_ingest_session_code")) print("parent: ", session) else: session = None if not session: #session = SearchType.create("config/ingest_session") #session.set_value("code", "session101") #session.set_value("location", "local") ##session.set_value("base_dir", "C:") top.add("No session defined!!!") return top rule = "" filter = "" ignore = "" # get the base path if sobject: base_dir = sobject.get_value("base_dir") else: base_dir = '' #else: # base_dir = self.get_value("base_dir") #if not base_dir: # base_dir = '' if sobject: title = sobject.get_value("title") else: title = '' if sobject: code = sobject.get_value("code") else: code = '' file_list = self.get_value("file_list") scan_type = self.get_value("scan_type") action_type = self.get_value("action_type") rule = self.get_value("rule") if not rule: rule = base_dir # get the rule for this path checkin_mode = "dir" depth = 0 table = Table() rules_div.add(table) table.add_color("color", "color") from tactic.ui.input.text_input_wdg import TextInputWdg # add the title table.add_row() td = table.add_cell() td.add("Title: ") td = table.add_cell() text = TextInputWdg(name="title") td.add(text) if title: text.set_value(title) text.add_class("spt_title") text.add_style("width: 400px") #text.add_color("background", "background", -10) # add the optional code table.add_row() td = table.add_cell() td.add("Code (optional): ") td = table.add_cell() text = TextInputWdg(name="code") td.add(text) if code: text.set_value(code) text.set_readonly() text.add_color("background", "background", -10) text.add_class("spt_code") text.add_style("width: 400px") table.add_row() td = table.add_cell() td.add_style("height: 10px") td.add("<hr/>") table.add_row() td = table.add_cell() td.add("<b>Scan:</b><br/>") td.add("The following information will be used to find the paths that will be operated on by the ingestion process<br/><br/>") # add a scan type table.add_row() td = table.add_cell() td.add("Type: ") select = SelectWdg("scan_type") select.add_class("spt_scan_type") td = table.add_cell() td.add(select) select.set_value( self.get_value("action") ) labels = ['Simple List', 'Rule', 'Script'] values = ['list', 'rule', 'script'] select.set_option("values", values) select.set_option("labels", labels) if scan_type: select.set_value(scan_type) table.add_row() table.add_cell(" ") select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var elements = top.getElements(".spt_scan_list"); for (var i = 0; i < elements.length; i++) { if (value == 'list') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_scan_rule"); for (var i = 0; i < elements.length; i++) { if (value == 'rule') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_scan_script"); for (var i = 0; i < elements.length; i++) { if (value == 'script') spt.show(elements[i]); else spt.hide(elements[i]); } ''' } ) # add in a list of stuff tbody = table.add_tbody() tbody.add_class("spt_scan_list") if scan_type != 'list': tbody.add_style("display: none") tr = table.add_row() td = table.add_cell() td.add("List of files: ") td = table.add_cell() text = TextAreaWdg(name="file_list") td.add(text) text.add_style("width: 400px") #text.set_readonly() #text.add_color("background", "background", -10) text.set_value(file_list) table.close_tbody() # add rule scan mode tbody = table.add_tbody() tbody.add_class("spt_scan_rule") if scan_type != 'rule': tbody.add_style("display: none") # add the path tr = table.add_row() td = table.add_cell() td.add("Starting Path: ") td = table.add_cell() hidden = HiddenWdg("session_code", session.get_code() ) td.add(hidden) text = TextInputWdg(name="base_dir") td.add(text) text.set_value(base_dir) text.add_style("width: 400px") #text.set_readonly() #text.add_color("background", "background", -10) text.set_value(base_dir) # add rule tr = table.add_row() td = table.add_cell() td.add("Tag Rule: ") td = table.add_cell() text = TextInputWdg(name="rule") td.add(text) text.add_style("width: 400px") text.set_value(rule) tr = table.add_row() td = table.add_cell() td.add("Filter: ") td = table.add_cell() text = TextWdg("filter") td.add(text) text.set_value( self.get_value("filter") ) text.add_style("width: 400px") text.add_style("padding: 2px") text.add_style("-moz-border-radius: 5px") tr = table.add_row() td = table.add_cell() td.add("Ignore: ") td = table.add_cell() text = TextWdg("ignore") td.add(text) text.set_value( self.get_value("ignore") ) text.set_value(ignore) text.add_style("width: 400px") text.add_style("padding: 2px") text.add_style("-moz-border-radius: 5px") table.add_row() td = table.add_cell() td.add("Validation script: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextInputWdg(name="validation_script") text.set_value( self.get_value("validation_script") ) text.add_style("width: 400px") td.add(text) icon = IconButtonWdg(title='Edit Validation Script', icon=IconWdg.EDIT) icon.add_style("float: right") td.add(icon) icon.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_script_editor"); var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); var kwargs = { script_path: values.validation_script } setTimeout( function() { spt.js_edit.display_script_cbk(evt, kwargs) }, 500 ); ''' } ) table.close_tbody() # add the script path tbody = table.add_tbody() tbody.add_class("spt_scan_script") if scan_type != 'script': tbody.add_style("display: none") tr = table.add_row() td = table.add_cell() td.add("Script Path: ") td = table.add_cell() text = TextInputWdg(name="script_path") td.add(text) text.add_style("width: 400px") table.close_tbody() table.add_row() td = table.add_cell("<hr/>") table.add_row() td = table.add_cell() td.add("<b>Action</b><br/>") td.add("The following information define the actions that will be used on each matched path<br/><br/>") # pick the type of action table.add_row() td = table.add_cell() td.add("Type: ") select = SelectWdg("action_type") td = table.add_cell() td.add(select) labels = ['Checkin', 'Ignore'] values = ['checkin', 'ignore'] select.set_option("values", values) select.set_option("labels", labels) select.add_empty_option("-- Select --") if action_type: select.set_value(action_type) select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var elements = top.getElements(".spt_action_ignore"); for (var i = 0; i < elements.length; i++) { if (value == 'ignore') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_action_checkin"); for (var i = 0; i < elements.length; i++) { if (value == 'checkin') spt.show(elements[i]); else spt.hide(elements[i]); } ''' } ) table.add_row() td = table.add_cell("<br/>") # add the script path tbody = table.add_tbody() tbody.add_class("spt_action_checkin") if action_type != 'checkin': tbody.add_style("display: none") # add the checkin type table.add_row() td = table.add_cell() td.add("Action: ") select = SelectWdg("action") td = table.add_cell() td.add(select) select.set_value( self.get_value("action") ) labels = ['File Checkin', 'Directory Checkin', 'Sequence Checkin'] values = ['file', 'directory', 'sequence', 'ignore'] select.set_option("values", values) select.set_option("labels", labels) table.add_row() td = table.add_cell() td.add("Mode: ") select = SelectWdg("mode") td = table.add_cell() td.add(select) labels = ['Copy', 'Move', 'In Place'] values = ['copy', 'move', 'inplace'] select.set_option("values", values) select.set_option("labels", labels) # add the search_type table.add_row() td = table.add_cell() td.add("sType: ") td = table.add_cell() select = SelectWdg("search_type") td.add(select) search_types = Project.get().get_search_types() values = [x.get_value("search_type") for x in search_types] select.set_option("values", values) search_type = self.kwargs.get("search_type") if search_type: select.set_value(search_type) # add the search_type table.add_row() td = table.add_cell() td.add("Context: ") td = table.add_cell() select = SelectWdg("context") td.add(select) select.set_option("values", ['publish', 'by rule', 'custom']) # add extra values extra_div = DivWdg() text = TextWdg("extra_name") text.add_attr("spt_is_multiple", "true") extra_div.add(text) extra_div.add(" = ") text = TextWdg("extra_value") extra_div.add(text) text.add_attr("spt_is_multiple", "true") template_div = DivWdg() text = TextWdg("extra_name") text.add_attr("spt_is_multiple", "true") template_div.add(text) template_div.add(" = ") text = TextWdg("extra_value") template_div.add(text) text.add_attr("spt_is_multiple", "true") table.close_tbody() table.add_row() td = table.add_cell("<br/>") table.add_row() td = table.add_cell() td.add("Extra Keywords: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("keywords") text.add_style("width: 300px") td.add(text) table.add_row() td = table.add_cell() td.add("Extra Values: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() extra_list = DynamicListWdg() td.add(extra_list) extra_list.add_item(extra_div) extra_list.add_template(template_div) table.add_row() table.add_cell(" ") table.add_row() td = table.add_cell() td.add("Process script: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("process_script") text.add_style("width: 300px") td.add(text) text.set_value( self.get_value("process_script") ) icon = IconButtonWdg(title='Edit Process Script', icon=IconWdg.EDIT) icon.add_style("float: right") td.add(icon) icon.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_script_editor"); var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); var kwargs = { script_path: values.process_script } // need to wait for this setTimeout( function() { spt.js_edit.display_script_cbk(evt, kwargs) }, 500 ); ''' } ) table.add_row() td = table.add_cell() td.add("Custom Naming: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("naming") text.add_style("width: 300px") td.add(text) table.add_row() td = table.add_cell() #td.add("<br clear='all'/>") td.add("<hr/>") behavior = { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); spt.app_busy.show("Scanning ...", values.base_dir); var class_name = 'tactic.ui.tools.IngestionProcessWdg'; var server = TacticServerStub.get(); values.mode = bvr.mode; values.is_local = 'true'; // scan client side if (values.is_local == 'true') { var base_dir = values.base_dir; var applet = spt.Applet.get(); var files = applet.list_recursive_dir(base_dir); // turn into a string var files_in_js = []; for (var i = 0; i < files.length; i++) { var file = files[i].replace(/\\\\/g, "/"); files_in_js.push( file ); } values.files = files_in_js; values.base_dir = base_dir; /* var server = TacticServerStub.get(); var handoff_dir = server.get_handoff_dir(); var applet = spt.Applet.get(); for (var i = 0; i < files_in_js.length; i++) { try { var parts = files_in_js[i].split("/"); var filename = parts[parts.length-1]; spt.app_busy.show("Copying files to handoff", filename); applet.copy_file(files_in_js[i], handoff_dir+"/"+filename); } catch(e) { log.error(e); } } */ } var info_el = top.getElement(".spt_info"); spt.panel.load(info_el, class_name, values); spt.app_busy.hide(); ''' } # Save button button = ActionButtonWdg(title="Save", tip="Save Rule") td.add(button) button.add_style("float: right") behavior['mode'] = 'save' button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); spt.app_busy.show("Saving ..."); var class_name = 'tactic.command.CheckinRuleSaveCmd'; var server = TacticServerStub.get(); server.execute_cmd(class_name, values); spt.panel.refresh(top, {}); spt.app_busy.hide(); ''' } ) # Scan button button = ActionButtonWdg(title="Scan", tip="Click to Scan") td.add(button) button.add_style("float: left") # set a limit #limit = TextWdg("limit") #td.add(limit) #text.add_style("float: left") behavior = behavior.copy() behavior['mode'] = 'scan' button.add_behavior(behavior) # Test button button = ActionButtonWdg(title="Test", tip="Do a test of this rule") td.add(button) behavior = behavior.copy() behavior['mode'] = 'test' button.add_behavior(behavior) button.add_style("float: left") # Ingest button button = ActionButtonWdg(title="Ingest", tip="Click to start ingesting") td.add(button) behavior = behavior.copy() behavior['mode'] = 'checkin' button.add_behavior(behavior) table.add_behavior( { 'type': 'listen', 'event_name': 'file_browser|select', 'cbjs_action': ''' var dirname = bvr.firing_data.dirname; var top = bvr.src_el.getParent(".spt_ingestion_top"); var kwargs = { base_dir: dirname }; spt.panel.load(top, top.getAttribute("spt_class_name"), kwargs); ''' }) top.add( self.get_info_wdg() ) return top
def get_display(self): top = self.top top.add_color("background", "background") top.add_class("spt_columns_top") self.set_as_panel(top) top.add_style("padding: 10px") search_type = self.kwargs.get("search_type") search_type_obj = SearchType.get(search_type) inner = DivWdg() top.add(inner) inner.add_style("width: 800px") #text = TextWdg("search_type") text = HiddenWdg("search_type") inner.add(text) text.set_value(search_type) title_wdg = DivWdg() inner.add(title_wdg) title_wdg.add(search_type_obj.get_title()) title_wdg.add(" <i style='font-size: 9px;opacity: 0.5'>(%s)</i>" % search_type) title_wdg.add_style("padding: 5px") title_wdg.add_color("background", "background3") title_wdg.add_color("color", "color3") title_wdg.add_style("margin: -10px -10px 10px -10px") title_wdg.add_style("font-weight: bold") shelf_wdg = DivWdg() inner.add(shelf_wdg) shelf_wdg.add_style("height: 35px") button = ActionButtonWdg(title='Create', color="default", icon="BS_SAVE") shelf_wdg.add(button) shelf_wdg.add_style("float: right") button.add_behavior({ 'type': 'click_up', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ColumnEditCbk'; var top = bvr.src_el.getParent(".spt_columns_top"); var elements = top.getElements(".spt_columns_element"); var values = []; for (var i = 0; i < elements.length; i++ ) { var data = spt.api.Utility.get_input_values(elements[i], null, false); values.push(data) } var kwargs = { search_type: bvr.search_type, values: values } var server = TacticServerStub.get(); try { server.execute_cmd(class_name, kwargs); var names = []; for (var i = 0; i < values.length; i++) { var name = values[i].name; name = name.strip(); if (name == '') { continue; } names.push(name); } // Unless there is a table here, we should not do this. // Better handled with a callback //spt.table.add_columns(names) // prevent grabbing all values, pass in a dummy one spt.panel.refresh(top, {'refresh': true}); } catch(e) { spt.alert(spt.exception.handler(e)); } ''' }) # add the headers table = Table() inner.add(table) table.add_style("width: 100%") tr = table.add_row() tr.add_color("background", "background", -5) th = table.add_header("Column Name") th.add_style("width: 190px") th.add_style("text-align: left") th.add_style("padding: 8px 0px") th = table.add_header("Format") th.add_style("text-align: left") th.add_style("padding: 8px 0px") from tactic.ui.container import DynamicListWdg dyn_list = DynamicListWdg() inner.add(dyn_list) from tactic.ui.manager import FormatDefinitionEditWdg for i in range(0, 4): column_div = DivWdg() column_div.add_class("spt_columns_element") if i == 0: dyn_list.add_template(column_div) else: dyn_list.add_item(column_div) column_div.add_style("padding: 3px") column_div.add_style("float: left") table = Table() column_div.add(table) table.add_row() from tactic.ui.input import TextInputWdg text_wdg = TextInputWdg(name="name", height="30px", width="170px") text_wdg.add_class("form-control") text_wdg.add_class("display: inline-block") td = table.add_cell(text_wdg) text_wdg.add_behavior({ 'type': 'blur', 'cbjs_action': ''' var value = bvr.src_el.value; var code = spt.convert_to_alpha_numeric(value); bvr.src_el.value = code; ''' }) option = { 'name': '_dummy', 'values': 'integer|float|percent|currency|date|time|scientific|boolean|text|timecode', } format_wdg = FormatDefinitionEditWdg(option=option) td = table.add_cell(format_wdg) td.add_style("width: 550px") td.add_style("padding-left: 10px") # show the current columns title_wdg = DivWdg() inner.add(title_wdg) title_wdg.add_style("margin-top: 25px") title_wdg.add("<b>Existing Columns</b>") title_wdg.add_style("padding: 5px") title_wdg.add_style("margin: 20px -10px 10px -10px") inner.add("<hr/>") config = WidgetConfigView.get_by_search_type(search_type, "definition") element_names = config.get_element_names() table = Table() inner.add(table) table.add_style("width: 100%") tr = table.add_row() tr.add_color("background", "background", -5) th = table.add_header("Column") th.add_style("text-align: left") th.add_style("padding: 5px 0px") th = table.add_header("Data Type") th.add_style("text-align: left") th.add_style("padding: 5px 0px") th = table.add_header("Format") th.add_style("text-align: left") th.add_style("padding: 5px 0px") th = table.add_header("Edit") th.add_style("text-align: left") th.add_style("padding: 5px 0px") count = 0 for element_name in element_names: display_class = config.get_display_handler(element_name) if display_class != 'tactic.ui.table.FormatElementWdg': continue table.add_row() display_options = config.get_display_options(element_name) format = display_options.get("format") if not format: format = '<i>text</i>' data_type = display_options.get("type") table.add_cell(element_name) table.add_cell(data_type) table.add_cell(format) td = table.add_cell() button = IconButtonWdg(title="Edit Definition", icon="BS_EDIT") td.add(button) button.add_behavior({ 'type': 'click_up', 'search_type': search_type, 'element_name': element_name, 'cbjs_action': ''' var class_name = 'tactic.ui.manager.ElementDefinitionWdg'; var kwargs = { search_type: bvr.search_type, view: 'definition', element_name: bvr.element_name }; spt.panel.load_popup("Element Definition", class_name, kwargs); ''' }) count += 1 if not count: table.add_row() td = table.add_cell() td.add_style("height: 80px") td.add("No existing columns found") td.add_style("text-align: center") td.add_color("background", "background", -2) if self.kwargs.get("is_refresh"): return inner else: return top
def get_otherdb_wdg(my): div = DivWdg() div.add_class("spt_db_options") div.add_attr("spt_vendor", "Other") div.add_style("margin: 20px") table = Table() div.add(table) table.add_color("color", "color") table.add_row() table.add_cell("Server: ") text = TextInputWdg(name="server") text.set_value("localhost") table.add_cell(text) server = Config.get_value("database", "server") if server: text.set_value(server) table.add_row() table.add_cell("Port: ") text = TextInputWdg(name="port") table.add_cell(text) port = Config.get_value("database", "port") if port: text.set_value(port) table.add_row() table.add_cell("Login: "******"user") table.add_cell(text) user = Config.get_value("database", "user") if user: text.set_value(user) table.add_row() text = PasswordInputWdg(name="password") table.add_cell("Password: "******"database", "password") if password: text.set_value(password) #from pyasm.search import Sql #sql.connect() return div
def get_display(self): outer_div = DivWdg() outer_div.set_id('new-external-rejection-form') # Set up the <input> widget for 'name' outer_div.add(HtmlElement.label('Name')) name_input = TextInputWdg(name='name') outer_div.add(name_input) root_cause_types = ProdSetting.get_seq_by_key( 'external_rejection_root_cause_types') root_cause_type_wdg = SelectWdg(name='root_cause_type', label='Root Cause Type') root_cause_type_wdg.add_empty_option() for root_cause_type in root_cause_types: root_cause_type_wdg.append_option(root_cause_type, root_cause_type) outer_div.add(root_cause_type_wdg) # TODO: Get this list from the schema, not hard coded video_rejection_reasons = [ ('video_cropping', 'Cropping'), ('video_digital_hits_macroblocking', 'Digital Hits / Macroblocking'), ('video_dropped_frames', 'Dropped Frames'), ('video_dropout', 'Dropout'), ('video_duplicate_frames', 'Duplicate Frames'), ('video_interlacing_on_a_progressive_file', 'Interlacing on a Progressive File'), ('video_motion_image_lag', 'Motion / Image Lag'), ('video_missing_elements', 'Missing Elements'), ('video_corrupt_file', 'Corrupt File'), ('video_incorrect_aspect_ratio', 'Incorrect Aspect Ratio'), ('video_incorrect_resolution', 'Incorrect Resolution'), ('video_incorrect_pixel_aspect_ratio', 'Incorrect Pixel Aspect Ratio'), ('video_incorrect_specifications', 'Incorrect Specifications'), ('video_incorrect_head_tail_format', 'Incorrect Head / Tail Format'), ('video_other', 'Other') ] audio_rejection_reasons = [ ('video_incorrect_audio_mapping', 'Incorrect Audio Mapping'), ('video_missing_audio_channel', 'Missing Audio Channel'), ('video_crackle_hiss_pop_static_ticks', 'Crackle / Hiss / Pop / Static / Ticks'), ('video_distortion', 'Distortion'), ('video_dropouts', 'Dropouts'), ('video_sync_issue', 'Sync Issue'), ('video_missing_elements', 'Missing Elements'), ('video_corrupt_missing_file', 'Corrupt / Missing File'), ('video_incorrect_specifications', 'Incorrect Specifications'), ('video_other', 'Other') ] metadata_rejection_reasons = [ ('metadata_missing_information', 'Missing Information'), ('metadata_incorrect_information', 'Incorrect Information'), ('metadata_incorrect_formatting', 'Incorrect Formatting'), ('metadata_other', 'Other') ] subtitle_rejection_reasons = [ ('subtitle_interlacing_on_subtitles', 'Interlacing on Subtitles'), ('subtitle_incorrect_subtitles', 'Incorrect Subtitles'), ('subtitle_sync_issue', 'Sync Issue'), ('subtitle_overlapping_other_text', 'Overlapping Other Text'), ('subtitle_other', 'Other') ] closed_captions_rejection_reasons = [ ('closed_captions_sync_issue', 'Sync Issue'), ('closed_captions_incorrect_cc', 'Incorrect CC'), ('closed_captions_overlapping_other_text', 'Overlapping Other Text'), ('closed_captions_other', 'Other') ] video_checkbox_table = self.setup_checkboxes_div( 'Video', video_rejection_reasons) audio_checkbox_table = self.setup_checkboxes_div( 'Audio', audio_rejection_reasons) metadata_checkbox_table = self.setup_checkboxes_div( 'MetaData', metadata_rejection_reasons) subtitle_checkbox_table = self.setup_checkboxes_div( 'Subtitles', subtitle_rejection_reasons) closed_captions_checkbox_table = self.setup_checkboxes_div( 'Closed Captions', closed_captions_rejection_reasons) outer_div.add(video_checkbox_table) outer_div.add(audio_checkbox_table) outer_div.add(metadata_checkbox_table) outer_div.add(subtitle_checkbox_table) outer_div.add(closed_captions_checkbox_table) return outer_div