本文整理汇总了Python中tactic.ui.widget.ActionButtonWdg.add_style方法的典型用法代码示例。如果您正苦于以下问题:Python ActionButtonWdg.add_style方法的具体用法?Python ActionButtonWdg.add_style怎么用?Python ActionButtonWdg.add_style使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tactic.ui.widget.ActionButtonWdg
的用法示例。
在下文中一共展示了ActionButtonWdg.add_style方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_checkin
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_checkin(my):
'''the button which initiates the checkin'''
# create the button with the javascript function
widget = Widget()
#button = TextBtnWdg(label=my.PUBLISH_BUTTON, size='large', width='100', side_padding='20', vert_offset='-5')
#button.get_top_el().add_class('smaller')
button = ActionButtonWdg(title=my.PUBLISH_BUTTON, tip='Publish the selected assets')
button.add_style('margin-bottom: 10px')
#button.add_color("background", "background")
hidden = HiddenWdg(my.PUBLISH_BUTTON, '')
button.add( hidden )
'''
status_sel = SelectWdg('checkin_status', label='Status: ')
status_sel.set_option('setting', 'checkin_status')
status_sel.set_persist_on_submit()
status_sel.add_empty_option('-- Checkin Status --')
widget.add(status_sel)
'''
widget.add(button)
# custom defined
server_cbk = "pyasm.prod.web.AssetCheckinCbk"
#TODO: make other Publish Buttons call their own handle_input function
exec( Common.get_import_from_class_path(server_cbk) )
exec( "%s.handle_input(button, my.search_type, my.texture_search_type)" % server_cbk)
return widget
示例2: get_save_button
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_save_button(my,checkin_keys):
save_button = ActionButtonWdg(title="Save >>", tip="Save configuration and start using TACTIC")
save_button.add_style("float: right")
save_button.add_behavior( {
'type': 'click_up',
'os' : os.name,
'checkin_options':checkin_keys,
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_db_config_top");
var failed_els = top.getElements('.spt_input_validation_failed')
if (failed_els.length > 0){
spt.alert('One of the fields fail validation. Please correct it before saving')
return;
}
spt.app_busy.show("Saving configuration. Please wait...")
var values = spt.api.Utility.get_input_values(top, null, false);
var class_name = 'tactic.ui.startup.DbConfigSaveCbk';
var server = TacticServerStub.get();
var kwargs = {checkin_options:bvr.checkin_options};
try {
var ret_val = server.execute_cmd(class_name, kwargs, values);
var info = ret_val.info;
}
catch(e) {
log.critical(spt.exception.handler(e));
//FIXME: recognize it's a 502 which is normal and pass , otherwise throw the error
//spt.error(spt.exception.handler(e));
//spt.app_busy.hide();
//return;
}
// This means TACTIC was restarted
if (typeof(info) == 'undefined' || bvr.os == 'nt' ) {
spt.app_busy.show("Restarting TACTIC ...");
var id = setInterval( function() {
var ping_rtn = server.ping();
if (ping_rtn) {
window.location = '/tactic';
clearInterval(id);
}
}, 5000 );
}
else if (info.error) {
spt.alert(info.error);
spt.app_busy.hide();
}
else {
window.location = '/tactic';
}
'''
} )
return save_button
示例3: handle_python_script_test
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def handle_python_script_test(self, top):
top.add(DivWdg('Python Script Test', css='spt_info_title'))
table = Table(css='script')
table.add_color("color", "color")
table.add_style("margin: 10px")
table.add_style("width: 100%")
top.add(table)
table.add_row()
td = table.add_cell("Script Path: ")
td.add_style("width: 150px")
text = TextWdg('script_path')
td = table.add_cell(text)
button = ActionButtonWdg(title='Run')
table.add_cell(button)
button.add_style("float: right")
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var s = TacticServerStub.get();
try {
var path = bvr.src_el.getParent('.script').getElement('.spt_input').value;
if (! path)
throw('Please enter a valid script path');
s.execute_cmd('tactic.command.PythonCmd', {script_path: path});
} catch(e) {
spt.alert(spt.exception.handler(e));
}
'''
})
示例4: get_error_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_error_wdg(my):
div = DivWdg()
error_div = DivWdg()
error_div.add("Error %s" % my.status)
div.add(error_div)
error_div.add_style("font-size: 16px")
error_div.add_style("font-weight: bold")
error_div.add_style("width: 97%")
error_div.add_gradient("background", "background")
error_div.add_border()
error_div.add_style("margin-left: 5px")
error_div.add_style("margin-top: -10px")
div.add("<br/>")
span = DivWdg()
# span.add_color("color", "color")
span.add_style("color", "#FFF")
if my.status == 404:
span.add(HtmlElement.b("You have tried to access a url that is not recognized."))
else:
span.add(HtmlElement.b(my.message))
span.add(HtmlElement.br(2))
web = WebContainer.get_web()
root = web.get_site_root()
if my.message.startswith("No project ["):
label = "You may need to correct the default_project setting in the TACTIC config."
else:
label = "Go to the Main page for a list of valid projects"
span.add(label)
div.add(span)
div.add(HtmlElement.br())
from tactic.ui.widget import ActionButtonWdg
button = ActionButtonWdg(title="Go to Main", tip="Click to go to main page")
div.add(button)
button.add_behavior(
{
"type": "click_up",
"cbjs_action": """
document.location = '/tactic';
""",
}
)
button.add_event("onmouseup", "document.location='/tactic'")
button.add_style("margin-left: auto")
button.add_style("margin-right: auto")
return div
示例5: get_search_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_search_wdg(my):
filter_div = DivWdg()
filter_div.add_style("width: 200px")
search_button = ActionButtonWdg(title='Search', tip='Run search with this criteria')
if my.run_search_bvr:
run_search_bvr = my.run_search_bvr
else:
# cbjs works better than cbfn here
run_search_bvr = {
'type': 'click_up',
'new_search': True,
'cbjs_action': 'spt.dg_table.search_cbk(evt, bvr)',
'panel_id': my.prefix,
}
search_button.add_behavior( run_search_bvr )
# add a listener for other widgets to call Run Search
listen_bvr = run_search_bvr.copy()
listen_bvr['type'] = 'listen'
listen_bvr['event_name'] = 'search_%s' %my.search_type
# needed for CgApp loader
search_button.add_behavior( listen_bvr )
clear_button = ActionButtonWdg(title='Clear', tip='Clear all search criteria')
clear_button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.api.Utility.clear_inputs(bvr.src_el.getParent(".spt_search"), '.spt_input:not(select.spt_search_filter_mode)');
'''
} )
# {'label': 'Clear', 'tip': 'Clear all search criteria', 'width': 45,
# 'bvr': {'cbjs_action': 'spt.api.Utility.clear_inputs(bvr.src_el.getParent(".spt_search"))'} }
#]
#txt_btn_set = TextBtnSetWdg(buttons=buttons_list, spacing=6, size='small', side_padding=4 )
filter_div.add(search_button)
search_button.add_style("float: left")
filter_div.add(clear_button)
clear_button.add_style("float: left")
filter_div.add("<br clear='all'/>")
return filter_div
示例6: get_error_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_error_wdg(my):
div = DivWdg()
error_div = DivWdg()
error_div.add("Error %s" % my.status)
div.add(error_div)
error_div.add_style("font-size: 16px")
error_div.add_style("font-weight: bold")
error_div.add_style("width: 97%")
error_div.add_gradient("background", "background")
error_div.add_border()
error_div.add_style("margin-left: 5px")
error_div.add_style("margin-top: -10px")
div.add("<br/>")
span = DivWdg()
#span.add_color("color", "color")
span.add_style("color", "#FFF")
if my.status == 404:
span.add(HtmlElement.b("You have tried to access a url that is not recognized."))
else:
span.add(HtmlElement.b(my.message))
span.add(HtmlElement.br(2))
web = WebContainer.get_web()
root = web.get_site_root()
span.add("Go back to the Main page for a list of valid projects")
div.add(span)
div.add(HtmlElement.br())
from tactic.ui.widget import ActionButtonWdg
button = ActionButtonWdg(title="Go to Main", tip='Click to go to main page')
div.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
document.location = '/tactic';
'''
} )
button.add_event("onmouseup", "document.location='/tactic'")
button.add_style("margin-left: auto")
button.add_style("margin-right: auto")
return div
示例7: get_page_four
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_page_four(my):
last_page = DivWdg()
last_page.add_style("padding-top: 80px")
last_page.add_style("padding-left: 30px")
cb = CheckboxWdg('jump_to_tab', label='Jump to Tab')
cb.set_checked()
last_page.add(cb)
last_page.add(HtmlElement.br(5))
button_div = DivWdg()
create_button = ActionButtonWdg(title="Create >>", tip="Create new project")
my.wizard.add_submit_button(create_button)
create_button.add_style("float: right")
create_button.add_behavior({
'type': "click_up",
'cbjs_action': '''
spt.alert('perform action here');
'''
})
# you can even pass in a custom cacel_script like
# spt.info("You have cancelled")
cancel_script = my.kwargs.get("cancel_script")
if cancel_script:
cancel_button = ActionButtonWdg(title="Cancel")
cancel_button.add_style("float: left")
cancel_button.add_behavior({
'type': "click_up",
'cbjs_action': cancel_script
})
button_div.add(cancel_button)
create_button.add_style("margin-right: 15px")
create_button.add_style("margin-left: 75px")
button_div.add("<br clear='all'/>")
last_page.add(button_div)
return last_page
示例8: get_save_button
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_save_button(my,checkin_keys):
save_button = ActionButtonWdg(title="Save >>", tip="Save configuration and start using TACTIC")
save_button.add_style("float: right")
save_button.add_behavior( {
'type': 'click_up',
'os' : os.name,
'checkin_options':checkin_keys,
'cbjs_action': '''
spt.app_busy.show("Saving configuration. Please wait...")
var top = bvr.src_el.getParent(".spt_db_config_top");
var values = spt.api.Utility.get_input_values(top, null, false);
var class_name = 'tactic.ui.startup.DbConfigSaveCbk';
var server = TacticServerStub.get();
var kwargs = {checkin_options:bvr.checkin_options};
var ret_val = server.execute_cmd(class_name, kwargs, values);
var info = ret_val.info;
// This means TACTIC was restarted
if (typeof(info) == 'undefined' || bvr.os == 'nt' ) {
spt.app_busy.show("Restarting TACTIC ...");
var id = setInterval( function() {
var ping_rtn = server.ping();
if (ping_rtn) {
window.location = '/tactic';
clearInterval(id);
}
}, 5000 );
}
else if (info.error) {
spt.alert(info.error);
}
else {
window.location = '/tactic';
}
'''
} )
return save_button
示例9: get_display
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_display(my):
top = DivWdg()
top.add_style("width: 100%")
top.add_color("background", "background", -10)
top.add_style("padding-top: 30px")
top.add_style("padding-bottom: 50px")
top.add_class("twog_wizard_top")
inner = DivWdg()
top.add(inner)
# set the width and height here
inner.add_style("width: 800px")
inner.add_style("min-height: 600px")
inner.add_style("float: center")
inner.add_border()
inner.center()
inner.add_style("padding: 20px")
inner.add_color("background", "background")
from tactic.ui.container import WizardWdg
title = DivWdg()
title.add("Step 1")
wizard = WizardWdg(title=title)
my.wizard = wizard
inner.add(wizard)
help_button = ActionButtonWdg(title="?", tip="Step 1 Help", size='s')
title.add(help_button)
help_button.add_style("float: right")
help_button.add_style("margin-top: -20px")
help_button.add_style("margin-right: -10px")
help_button.add_behavior({
'type': 'click_up',
'cbjs_action': '''
spt.help.set_top();
spt.help.load_alias("order_wdg");
'''
})
page_one = my.get_page_one()
wizard.add(page_one, 'Step 1')
page_two = my.get_page_two()
wizard.add(page_two, 'Step 2')
page_three = my.get_page_three()
wizard.add(page_three, 'Step 3')
page_four = my.get_page_four()
wizard.add(page_four, 'Step 4')
return top
示例10: get_display
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_display(my):
alias = my.kwargs.get("alias")
div = DivWdg()
div.add_style("padding: 15px")
div.add_style("margin: 10px")
div.add_border()
div.add_color("background", "background", -5)
div.add_style("text-align: center")
div.add_style("font-weight: bold")
icon = IconWdg("WARNING", IconWdg.HELP_MISSING)
div.add(icon)
div.add("Add custom documentation page by clicking the Create button")
from tactic.ui.widget import ActionButtonWdg
button = ActionButtonWdg(title="Create", tip="Create docs for this view")
div.add(button)
button.add_style("margin-right: auto")
button.add_style("margin-left: auto")
button.add_style("margin-top: 15px")
button.add_style("margin-bottom: 15px")
# FIXME: copied code from above
button.add_behavior(
{
"type": "click_up",
"cbjs_action": """
spt.tab.set_main_body_tab();
var class_name = 'tactic.ui.app.HelpEditWdg';
var element_name = spt.help.get_view();
if (!element_name) {
element_name = "default";
}
var kwargs = {
view: element_name
}
spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs);
""",
}
)
return div
示例11: get_bottom_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_bottom_wdg(my):
from tactic.ui.widget import ActionButtonWdg
div = DivWdg()
back = ActionButtonWdg(title="< Back", tip="Go back to last page")
div.add(back)
back.add_class("spt_wizard_back")
back.add_style("float: left")
# FIXME: need to do this because set_style is not the same element as
# add class
back.add_behavior( {
'type': 'load',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_wizard_top");
var back = top.getElement(".spt_wizard_back");
back.setStyle("display", "none");
'''
} )
back.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_wizard_top");
var pages = top.getElements(".spt_wizard_page");
var on_dots = top.getElements(".spt_wizard_on_dot");
var off_dots = top.getElements(".spt_wizard_off_dot");
// check boundary
if (pages[0].hasClass("spt_wizard_selected")) {
return;
}
var selected_index = 0;
for (var i = 0; i < pages.length; i++) {
var page = pages[i];
var on_dot = on_dots[i];
var off_dot = off_dots[i];
if (page.hasClass("spt_wizard_selected")) {
page.removeClass("spt_wizard_selected");
selected_index = i;
}
page.setStyle("display", "none");
on_dot.setStyle("display", "none");
off_dot.setStyle("display", "");
}
if (selected_index == 1) {
var back = top.getElement(".spt_wizard_back");
back.setStyle("display", "none");
}
if (selected_index == pages.length-1) {
var next = top.getElement(".spt_wizard_next");
next.setStyle("display", "");
}
var page = pages[selected_index-1];
page.setStyle("display", "");
page.addClass("spt_wizard_selected");
var on_dot = on_dots[selected_index-1];
var off_dot = off_dots[selected_index-1];
on_dot.setStyle("display", "");
off_dot.setStyle("display", "none");
'''
} )
if my.submit_button:
submit = my.submit_button
else:
command = my.kwargs.get("command")
submit_title = my.kwargs.get("submit_title")
if not submit_title:
submit_title = "Submit"
submit = ActionButtonWdg(title="%s >>" % submit_title, tip=submit_title)
submit.add_behavior( {
'type': 'click_up',
'command': command,
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_wizard_top");
var values = spt.api.Utility.get_input_values(top);
spt.app_busy.show("Executing ...", "");
var server = TacticServerStub.get();
try {
server.execute_cmd(bvr.command, values);
}
catch(e) {
var xml = spt.parse_xml(e);
var node = xml.getElementsByTagName("string")[0];
var error = node.textContent;
spt.error("Error: " + error);
spt.app_busy.hide();
throw(e);
}
#.........这里部分代码省略.........
示例12: get_display
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_display(my):
top = my.top
my.set_as_panel(top)
top.add_class("spt_delete_top")
top.add_color("background", "background")
top.add_color("color", "color")
top.add_border()
top.add_style("width: 300px")
top.add_border()
search_key = my.kwargs.get("search_key")
search_keys = my.kwargs.get("search_keys")
if search_key:
sobject = Search.get_by_search_key(search_key)
sobjects = [sobject]
search_keys = [search_key]
elif search_keys:
sobjects = Search.get_by_search_keys(search_keys)
sobject = sobjects[0]
if not sobjects:
msg = "%s not found" %search_key
return msg
search_type = sobject.get_base_search_type()
if search_type in ['sthpw/project', 'sthpw/search_object']:
msg = 'You cannot delete these items with this tool'
return msg
my.search_keys = search_keys
title = DivWdg()
top.add(title)
title.add_color("background", "background", -10)
if my.search_keys:
title.add("Delete %s Items" % len(my.search_keys))
else:
title.add("Delete Item [%s]" % (sobject.get_code()))
title.add_style("font-size: 14px")
title.add_style("font-weight: bold")
title.add_style("padding: 10px")
content = DivWdg()
top.add(content)
content.add_style("padding: 10px")
content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading')
# find all the relationships
schema = Schema.get()
related_types = schema.get_related_search_types(search_type, direction="children")
parent_type = schema.get_parent_type(search_type)
child_types = schema.get_child_types(search_type)
# some special considerations
# FIXME: this needs to be more automatic. Should only be
# deletable children (however, that will be defined)
if search_type in ['sthpw/task','sthpw/note', 'sthpw/snapshot']:
if "sthpw/project" in related_types:
related_types.remove("sthpw/project")
if "sthpw/login" in related_types:
related_types.remove("sthpw/login")
if "config/process" in related_types:
related_types.remove("config/process")
if parent_type in related_types:
related_types.remove(parent_type)
related_types.append('sthpw/note')
related_types.append('sthpw/task')
related_types.append('sthpw/snapshot')
if 'sthpw/work_hour' not in related_types:
related_types.append('sthpw/work_hour')
items_div = DivWdg()
content.add( items_div )
items_div.add_style("padding: 10px")
valid_related_ctr = 0
for related_type in related_types:
if related_type == "*":
print "WARNING: related_type is *"
continue
if related_type == search_type:
continue
if related_type in ['sthpw/search_object','sthpw/search_type']:
continue
item_div = my.get_item_div(sobjects, related_type)
if item_div:
items_div.add(item_div)
valid_related_ctr += 1
#.........这里部分代码省略.........
示例13: get_gear_menu
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_gear_menu(my):
top = DivWdg()
# FIXME: the gear menu widget should be here
from tactic.ui.container import GearMenuWdg, Menu, MenuItem
menu = Menu(width=180)
menu_item = MenuItem(type="title", label="Actions")
menu.add(menu_item)
# create a new element
menu_item = MenuItem(type="action", label="New Element")
behavior = {
"options": {"is_insert": "true", "search_type": my.search_type, "view": my.view},
"cbjs_action": """
var activator = spt.smenu.get_activator(bvr);
var top = activator.getParent(".spt_view_manager_top");
var detail_panel = top.getElement(".spt_view_manager_detail");
var class_name = 'tactic.ui.manager.ElementDefinitionWdg';
var options = bvr.options
var values = {};
spt.panel.load(detail_panel, class_name, options, values, false);
""",
}
menu_item.add_behavior(behavior)
menu.add(menu_item)
menu_item = MenuItem(type="separator")
menu.add(menu_item)
# Show preview of the view
menu_item = MenuItem(type="action", label="Show Preview")
behavior = {
"search_type": my.search_type,
"view": my.view,
"cbjs_action": """
var kwargs = {
search_type: bvr.search_type,
view: bvr.view
};
var title = "Search Type: [" + bvr.search_type + "], View [" + bvr.view + "]";
spt.panel.load_popup(title, 'tactic.ui.panel.ViewPanelWdg', kwargs);
""",
}
menu_item.add_behavior(behavior)
menu.add(menu_item)
# Show preview of the view
menu_item = MenuItem(type="action", label="Show Full XML Config")
behavior = {
"search_type": my.search_type,
"view": my.view,
"cbjs_action": """
var kwargs = {
search_type: 'config/widget_config',
view: 'table',
expression: "@SOBJECT(config/widget_config['search_type','"+bvr.search_type+"']['view','"+bvr.view+"'])",
filter: [{}]
};
var title = "Widget Config - ["+bvr.search_type+"] ["+bvr.view+"]";
spt.panel.load_popup(title, 'tactic.ui.panel.ViewPanelWdg', kwargs);
""",
}
menu_item.add_behavior(behavior)
menu.add(menu_item)
menu_item = MenuItem(type="separator")
menu.add(menu_item)
# New view popup
new_view_wdg = DivWdg()
new_view_wdg.add_class("spt_new_view")
new_view_wdg.add_style("display: none")
new_view_wdg.add_style("position: absolute")
new_view_wdg.add_color("background", "background")
new_view_wdg.add_style("z-index: 100")
new_view_wdg.add_border()
new_view_wdg.set_round_corners()
new_view_wdg.set_box_shadow()
new_view_wdg.add_style("padding: 30px")
new_view_wdg.add("New View Name: ")
new_view_text = TextWdg("new_view")
new_view_text.add_class("spt_new_view_text")
new_view_wdg.add(new_view_text)
new_view_wdg.add(HtmlElement.br(2))
# new_view_button = ProdIconButtonWdg('Save New View')
new_view_button = ActionButtonWdg(title="Save", tip="Save New View")
new_view_button.add_style("float: left")
new_view_wdg.add(new_view_button)
new_view_button.add_behavior(
{
"type": "click_up",
"search_type": my.search_type,
"cbjs_action": """
var top = bvr.src_el.getParent(".spt_view_manager_top");
#.........这里部分代码省略.........
示例14: get_display
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
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:
#.........这里部分代码省略.........
示例15: get_group_wdg
# 需要导入模块: from tactic.ui.widget import ActionButtonWdg [as 别名]
# 或者: from tactic.ui.widget.ActionButtonWdg import add_style [as 别名]
def get_group_wdg(self, prev_sobj):
if not self.is_preprocessed:
self.preprocess()
sobject = self.get_current_sobject()
ref_sobj = self.get_ref_obj(sobject)
self.current_ref_sobj = ref_sobj
if not ref_sobj:
return "Undetermined parent: [%s]" % SearchKey.get_by_sobject(sobject)
widget = DivWdg()
# add add button
#from tactic.ui.widget import TextBtnWdg, TextBtnSetWdg
#buttons_list = []
#buttons_list.append( {
# 'label': '+', 'tip': 'Add Another Item',
# 'bvr': { 'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)" }
#} )
#add_btn = TextBtnSetWdg( float="right", buttons=buttons_list,
# spacing=6, size='small', side_padding=0 )
#widget.add(add_btn)
from tactic.ui.widget import ActionButtonWdg
button = ActionButtonWdg(title='+', tip='Add Another Item', size='small')
widget.add(button)
button.add_style("float: right")
button.add_behavior( {
'type': 'click_up',
'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)"
} )
label = "Attach"
label_option = self.get_option("label")
if label_option:
label = label_option
table = Table()
table.add_color("color", "color")
table.add_row()
search_key = sobject.get_search_key()
# add a thumbe widget
thumb = ThumbWdg()
thumb.set_icon_size(40)
thumb.set_sobject(ref_sobj)
thumb.set_option('latest_icon', 'true')
table.add_cell(thumb)
# add the text description
name_span = DivWdg(ref_sobj.get_code())
name_span.add_style('margin-left: 20px')
table.add_cell(name_span)
if ref_sobj.has_value("name"):
name_span.add( " - " )
name_span.add( ref_sobj.get_value("name") )
#status = ref_sobj.get_value("status", no_exception=True)
#if status:
# span = SpanWdg("(status:%s)" % ref_sobj.get_value("status"))
# table.add_cell(span)
if ref_sobj.has_value("description"):
description_wdg = ExpandableTextWdg("description")
description_wdg.set_max_length(200)
description_wdg.set_sobject(ref_sobj)
td = table.add_cell( description_wdg )
td.add_style("padding-left: 15px")
# FIXME: not sure about the layout here
#if ref_sobj.has_value("pipeline_code"):
# pipeline_code = ref_sobj.get_value("pipeline_code")
# span = SpanWdg("(pipeline:%s)" % pipeline_code )
# td = table.add_cell(span)
# td.add_style("padding-left: 15px")
widget.add(table)
return widget