本文整理汇总了Python中steelscript.appfwk.apps.datasource.models.TableField类的典型用法代码示例。如果您正苦于以下问题:Python TableField类的具体用法?Python TableField怎么用?Python TableField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TableField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_process_table
def post_process_table(self, field_options):
super(NetProfilerTrafficTimeSeriesTable, self).post_process_table(
field_options)
if self.options.top_n is None:
# If not top-n, the criteria field 'query_columns' must
# either be a string or an array of column definitions
# (a string is simply parsed as json to the latter).
#
# This criteria field must resolve to an array of
# field definitions, one per column to be queried
#
# An array of column defintions looks like the following:
# [ {'name': <name>, 'label': <name>, 'json': <json>},
# {'name': <name>, 'label': <name>, 'json': <json>},
# ... ]
#
# Each element corresponds to a column requested. <name> is
# used as the Column.name, <label> is for the Column.label
# and json is what is passed on to NetProfiler in the POST
# to create the report
#
TableField.create(keyword='query_columns',
label='Query columns',
obj=self)
示例2: fields_add_filemgr_selection
def fields_add_filemgr_selection(obj,
keyword='filemgrfile',
label='FileMgrFile'):
field = TableField(keyword=keyword, label=label,
field_cls=IntegerIDChoiceField,
pre_process_func=Function(file_selection_preprocess))
field.save()
obj.fields.add(field)
示例3: add_netprofiler_application_field
def add_netprofiler_application_field(report, section, app=None):
""" Attach fields for dynamic Application dropdowns to add as filter
expressions to the report.
This can be added for each section in a report where the added filter
expression is desired.
The optional ``app`` argument can be either a single string or a list
of strings for each HostGroupType. If a single string, the
'Application' field will be hidden and automatically filter Applications
to the given App. If a list, the elements of the App
list will be fixed to those in the list.
"""
# add default filter expr to extend against
filterexpr = TableField.create(keyword='netprofiler_filterexpr')
section.fields.add(filterexpr)
if app is None:
# use all available apps
field = TableField.create(
keyword='application',
label='Application',
obj=report,
field_cls=forms.ChoiceField,
field_kwargs={'widget_attrs': {'class': 'form-control'}},
parent_keywords=['netprofiler_device'],
dynamic=True,
pre_process_func=Function(netprofiler_application_choices)
)
section.fields.add(field)
elif type(app) in (list, tuple):
# add apps field that uses given list
field = TableField.create(
keyword='application',
label='Application',
obj=report,
field_cls=forms.ChoiceField,
field_kwargs={'choices': zip(app, app),
'widget_attrs': {'class': 'form-control'}},
parent_keywords=['netprofiler_device'],
)
section.fields.add(field)
else:
# no app, so no field just hardcode the filter
NetProfilerTable.extend_filterexpr(
section, keyword='application',
template='app {}'.format(app)
)
# we're done here
return
NetProfilerTable.extend_filterexpr(
section, keyword='hg_filterexpr',
template='app {application}'
)
示例4: fields_add_stock_symbol
def fields_add_stock_symbol(self, help_text, keyword='stock_symbol',
initial=None):
field = TableField(keyword=keyword,
label='Stock Symbol',
help_text=(help_text),
initial=initial,
required=True)
field.save()
self.fields.add(field)
示例5: fields_add_filterexpr
def fields_add_filterexpr(self, keyword='netshark_filterexpr', initial=None):
field = TableField(keyword=keyword,
label='NetShark Filter Expression',
help_text='Traffic expression using '
'NetShark filter syntax',
initial=initial,
required=False)
field.save()
self.fields.add(field)
示例6: fields_add_filterexpr
def fields_add_filterexpr(self, keyword='netprofiler_filterexpr',
initial=None):
field = TableField(keyword=keyword,
label='NetProfiler Filter Expression',
help_text=('Traffic expression using NetProfiler '
'Advanced Traffic Expression syntax'),
initial=initial,
required=False)
field.save()
self.fields.add(field)
示例7: fields_add_device_selection
def fields_add_device_selection(obj, keyword='device',
label='Device',
module=None, enabled=None):
field = TableField(keyword=keyword, label=label,
field_cls=IntegerIDChoiceField,
pre_process_func=Function(device_selection_preprocess,
{'module': module,
'enabled': enabled}))
field.save()
obj.fields.add(field)
示例8: post_process_table
def post_process_table(self, field_options):
super(SCCThroughputTable, self).post_process_table(field_options)
# Add device ID field
field = TableField(keyword='device',
label='Device Serial ID',
required=True)
field.save()
self.fields.add(field)
# Add port field
field = TableField(keyword='port',
label='Port',
required=False)
field.save()
self.fields.add(field)
# Add traffic_type field
traffic_types = ('peak', 'p95')
field = TableField(keyword='traffic_type',
label='Traffic Type',
field_cls=forms.ChoiceField,
field_kwargs={'choices':
zip(traffic_types, traffic_types)})
field.save()
self.fields.add(field)
示例9: fields_add_time_selection
def fields_add_time_selection(obj, show_duration=True, initial_duration=None,
durations=None,
show_start=False,
initial_start_time='now-1h',
initial_start_date='now-1h',
show_end=True,
initial_end_time='now-0',
initial_end_date='now-0',
round_initial=0, # seconds to round initial time
special_values=None):
if show_start:
field = TableField(keyword='starttime',
label='Start Time',
field_cls=DateTimeField,
field_kwargs={
'widget': ReportSplitDateTimeWidget,
'widget_attrs': {
'initial_time': initial_start_time,
'initial_date': initial_start_date,
'round_initial': round_initial
}
},
required=False)
field.save()
obj.fields.add(field)
if show_end:
field = TableField(keyword='endtime',
label='End Time',
field_cls=DateTimeField,
field_kwargs={
'widget': ReportSplitDateTimeWidget,
'widget_attrs': {
'initial_time': initial_end_time,
'initial_date': initial_end_date,
'round_initial': round_initial
}
},
required=False)
field.save()
obj.fields.add(field)
if show_duration:
if durations is None:
durations = DURATIONS
field = TableField(keyword='duration',
label='Duration',
initial=initial_duration,
field_cls=DurationField,
field_kwargs={'choices': durations,
'special_values': special_values},
required=False)
field.save()
obj.fields.add(field)
示例10: fields_add_end_date
def fields_add_end_date(self, initial_end_date='now-0'):
# Add a date field
# the front javascript code will determine the default date
# according to initial_end_date, so if initial_end_date is
# 'now-0', today will be the default end date
field = TableField(keyword='end_date',
label='End Date',
field_cls=DateTimeField,
field_kwargs={'widget': ReportSplitDateWidget,
'widget_attrs': {'initial_date':
initial_end_date}},
required=False)
field.save()
self.fields.add(field)
示例11: extend_filterexpr
def extend_filterexpr(cls, obj, keyword, template):
field = obj.fields.get(keyword='netprofiler_filterexpr')
field.post_process_func = Function(
function=_post_process_combine_filterexprs
)
TableField.create(
keyword=keyword, obj=obj, hidden=True,
post_process_template=template)
parent_keywords = set(field.parent_keywords or [])
parent_keywords.add(keyword)
field.parent_keywords = list(parent_keywords)
field.save()
示例12: fields_add_resolution
def fields_add_resolution(obj, initial=None,
resolutions=None,
special_values=None):
if resolutions is None:
resolutions = ('1m', '15m', '1h', '6h')
field = TableField(keyword='resolution',
label='Data Resolution',
field_cls=DurationField,
field_kwargs={'choices': resolutions,
'special_values': special_values},
initial=initial)
field.save()
obj.fields.add(field)
示例13: __init__
def __init__(self, *args, **kwargs):
fields = {}
res = TableField.objects.filter(keyword='batch_file')
if not res:
file_upload = TableField(keyword='batch_file',
label='Batch File',
field_cls=FileSelectField,
field_kwargs=dict(widget=FileInput),
required=True)
file_upload.save()
else:
file_upload = res[0]
fields['batch_file'] = file_upload
super(DeviceBatchForm, self).__init__(fields, *args, **kwargs)
示例14: post_process_table
def post_process_table(self, field_options):
#
# Add criteria fields that are required by this table
#
TableField.create(keyword='entire_pcap', obj=self,
field_cls=forms.BooleanField,
label='Entire PCAP',
initial=True,
required=False)
fields_add_time_selection(self, show_start=True, show_end=True,
show_duration=False)
fields_add_resolution(obj=self,
initial=field_options['resolution'],
resolutions=field_options['resolutions'])
fields_add_pcapfile(
obj=self, astextfield=field_options['pcapfile_astextfield'])
fields_add_filterexpr(obj=self)
示例15: fields_add_pcapfile
def fields_add_pcapfile(obj, keyword='pcapfilename',
label='PCAP File', initial=None,
astextfield=False):
"""Add a PCAP file selection field.
:param bool astextfield: If True, use a text field instead of a
file selection field. The text value is interpreted as
a file on the server.
"""
kwargs = {}
if not astextfield:
kwargs['field_cls'] = FileSelectField
kwargs['field_kwargs'] = {'widget': FileInput}
field = TableField(keyword=keyword,
label=label,
**kwargs)
field.save()
obj.fields.add(field)