예제 #1
0
class GenericFormTemplate(GatewayForm):
    workflow_name = 'manage_service_requests'
    workflow_permission = 'manage_service_requests_page'

    report_div = PlainHTML(
        '<div id="report_div"><a href="/manage_service_requests/generate_service_requests_report" target="_blank">Export Service Requests report as CSV</a> - This report will generate a CSV with a list of all the service requests(open and closed) and match the information within BlueCat to give the most up-to-date information<br>'
        '</div><br>')

    ticket_table = TableField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        data_function=raw_table_data,
        table_features={
            'searching': True,
            'paging': True,
            'ordering': True,
            'info': True,
            'lengthChange': True,
            'scrollX': True,
            'pageLength': 10,
            'columnDefs': [{
                'targets': [5],
                'render': ''
            }],
            'language': {
                "lengthMenu":
                'Display Entries<select>' + '<option value="10">10</option>' +
                '<option value="25">25</option>' +
                '<option value="100">100</option>' + '</select>'
            },
        },
    )
class GenericFormTemplate(GatewayForm):
    """ Form to generate HTML and Javascript for the update_ip4_address_example workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'update_ip4_address_example'
    workflow_permission = 'update_ip4_address_example_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        enable_dependencies={'on_complete': ['ip4_address']},
        disable_dependencies={'on_change': ['ip4_address']},
        clear_dependencies={'on_change': ['ip4_address']})

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Address',
        required=True,
        clear_below_on_change=False,
        inputs={
            'configuration': 'configuration',
            'address': 'ip4_address'
        },
        server_outputs={
            'on_validate': {
                'state': 'address_state',
                'mac_address': 'mac_address',
                'name': 'description'
            }
        },
        server_side_output_method=get_ip4_address_endpoint,
        result_decorator=filter_allocated,
        should_cascade_clear_on_change=True,
        should_cascade_disable_on_change=True,
        enable_dependencies={
            'on_complete':
            ['address_state', 'mac_address', 'description', 'submit']
        },
        disable_dependencies={
            'on_change':
            ['address_state', 'mac_address', 'description', 'submit']
        })

    line_break = PlainHTML('<hr>')

    address_state = CustomStringField(label='Address State', readonly=True)

    mac_address = CustomStringField(label='MAC Address')

    description = CustomStringField(label='Description')

    submit = SubmitField(label='Update')
class GenericFormTemplate(GatewayForm):
    """Form to generate HTML and Javascript for the delete_ip4_address workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """

    workflow_name = "delete_ip4_address"
    workflow_permission = "delete_ip4_address_page"
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Configuration",
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        enable_dependencies={"on_complete": ["ip4_address"]},
        disable_dependencies={"on_change": ["ip4_address"]},
        clear_dependencies={"on_change": ["ip4_address"]},
    )

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Address",
        required=True,
        inputs={"configuration": "configuration", "address": "ip4_address"},
        server_outputs={
            "on_change": {
                "state": "address_state",
                "mac_address": "mac_address",
                "name": "description",
            }
        },
        server_side_output_method=get_ip4_address_endpoint,
        result_decorator=filter_allocated,
        clear_below_on_change=False,
        should_cascade_disable_on_change=True,
        enable_dependencies={"on_complete": ["submit"]},
        disable_dependencies={
            "on_change": ["address_state", "mac_address", "description", "submit"]
        },
    )

    line_break = PlainHTML("<hr>")

    address_state = CustomStringField(label="Address State", readonly=True)

    mac_address = CustomStringField(label="MAC Address", readonly=True)

    description = CustomStringField(label="Description", readonly=True)

    submit = SubmitField(label="Delete")
예제 #4
0
class GenericFormTemplate(GatewayForm):
    # When updating the form, remember to make the corresponding changes to the workflow pages
    workflow_name = 'update_ip4_address_example'
    workflow_permission = 'update_ip4_address_example_page'
    configuration = Configuration(workflow_name=workflow_name,
                                  permissions=workflow_permission,
                                  label='Configuration',
                                  required=True,
                                  coerce=int,
                                  validators=[],
                                  is_disabled_on_start=False,
                                  enable_on_complete=['ip4_address'])

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Address',
        required=True,
        inputs={
            'configuration': 'configuration',
            'address': 'ip4_address'
        },
        on_change=['server_output_ip4_address'],
        server_outputs={
            'state': 'address_state',
            'mac_address': 'mac_address',
            'name': 'description'
        },
        server_side_output_method=get_ip4_address_endpoint,
        result_decorator=filter_allocated,
        enable_on_complete=[
            'address_state', 'mac_address', 'description', 'submit'
        ])

    line_break = PlainHTML('<hr>')

    address_state = CustomStringField(label='Address State', readonly=True)

    mac_address = CustomStringField(label='MAC Address')

    description = CustomStringField(label='Description')

    submit = SubmitField(label='Update')
예제 #5
0
class GenericFormTemplate(GatewayForm):
    workflow_name = 'cache_example'
    workflow_permission = 'cache_example_page'
    configuration = Configuration(workflow_name=workflow_name,
                                  permissions=workflow_permission,
                                  label='Configuration',
                                  required=True,
                                  coerce=int,
                                  validators=[],
                                  is_disabled_on_start=False,
                                  enable_on_complete=['ip_network', 'submit'],
                                  clear_below_on_change=False)

    ip_network = CustomStringField(label='Network',
                                   validators=[DataRequired()])

    display = PlainHTML("<div id='data_display' />")

    submit = SubmitField(label='Submit')
class GenericFormTemplate(GatewayForm):
    # When updating the form, remember to make the corresponding changes to the workflow pages
    workflow_name = 'update_host_record_example'
    workflow_permission = 'update_host_record_example_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        validators=[],
        is_disabled_on_start=False,
        on_complete=['call_view'],
        enable_on_complete=['view']
    )

    view = View(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='View',
        required=True,
        one_off=True,
        on_complete=[],
        enable_on_complete=['parent_zone']
    )

    parent_zone = Zone(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Zone',
        required=True,
        start_initialized=True,
        inputs={'zone': 'parent_zone', 'configuration': 'configuration', 'view': 'view'},
        enable_on_complete=['host_record']
    )

    host_record = HostRecord(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Host Record',
        required=True,
        inputs={
            'configuration': 'configuration',
            'view': 'view',
            'parent_zone': 'parent_zone',
            'host_record': 'host_record'
        },
        on_complete=['server_output_host_record'],
        server_outputs={'name': 'name', 'addresses': 'ip4_address'},
        server_side_output_method=get_host_records_endpoint,
        enable_on_complete=['submit', 'name', 'ip4_address']
    )

    seperator = PlainHTML('<hr>')

    name = CustomStringField(
        label='New Host Name',
        required=True
    )

    ip4_address = CustomStringField(
        label='IP4 Address (multiple IP4 addresses must be seperated by a comma)',
        required=True
    )

    submit = SubmitField(label='Update')
예제 #7
0
class GenericFormTemplate(GatewayForm):
    """ Form to generate HTML and Javascript for the update_text_record workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'update_text_record'
    workflow_permission = 'update_text_record_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        on_complete=['call_view'],
        enable_dependencies={'on_complete': ['view']},
        disable_dependencies={'on_change': ['view']},
        clear_dependencies={'on_change': ['view']})

    view = View(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='View',
                required=True,
                one_off=True,
                clear_below_on_change=False,
                display_message=True,
                enable_dependencies={'on_complete': ['parent_zone']},
                disable_dependencies={'on_change': ['parent_zone']},
                clear_dependencies={'on_change': ['parent_zone']},
                should_cascade_disable_on_change=True,
                should_cascade_clear_on_change=True)

    parent_zone = Zone(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Zone',
        required=True,
        start_initialized=True,
        display_message=True,
        inputs={
            'zone': 'parent_zone',
            'configuration': 'configuration',
            'view': 'view'
        },
        clear_below_on_change=False,
        enable_dependencies={'on_complete': ['text_record', 'search']},
        disable_dependencies={'on_change': ['text_record', 'search']},
        clear_dependencies={'on_change': ['text_record', 'search']},
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True)

    text_record = CustomStringField(label='Text Record')

    search = CustomSearchButtonField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        default='Search',
        inputs={
            'configuration': 'configuration',
            'view': 'view',
            'parent_zone': 'parent_zone',
            'name': 'text_record'
        },
        server_side_method=get_text_records_endpoint,
        display_message=True,
        on_complete=['call_txt_list'],
        enable_dependencies={'on_complete': ['txt_filter', 'txt_list']},
        disable_dependencies={
            'on_change': ['txt_filter', 'txt_list'],
            'on_click': ['txt_filter', 'txt_list']
        },
        clear_dependencies={
            'on_change': ['txt_filter', 'txt_list'],
            'on_click': ['txt_filter', 'txt_list']
        },
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True)

    txt_filter = CustomStringField(label='Filter', is_disabled_on_error=True)

    txt_list = FilteredSelectField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Text',
        size=12,
        filter_field='txt_filter',
        choices=[(0, '')],
        coerce=int,
        is_disabled_on_error=True,
        on_complete=['call_name_js', 'call_text'],
        inputs={
            'configuration': 'configuration',
            'view': 'view',
            'parent_zone': 'parent_zone',
            'name': 'text_record'
        },
        clear_dependencies={'on_change': ['name', 'text']},
        server_side_method=get_text_records_endpoint,
        enable_dependencies={'on_complete': ['name', 'text', 'submit']},
        disable_dependencies={'on_change': ['name', 'text', 'submit']},
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True)

    plain_1 = PlainHTML('<hr>')

    name = CustomStringField(label='New Name', is_disabled_on_error=True)

    text = CustomStringField(label='New Text',
                             inputs={'text': 'txt_list'},
                             is_disabled_on_error=True)

    submit = CustomSubmitField(label='Update')
class GenericFormTemplate(GatewayForm):
    """ Form to generate HTML and Javascript for the update_host_record workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'update_host_record'
    workflow_permission = 'update_host_record_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        on_complete=['call_view'],
        enable_dependencies={'on_complete': ['view']},
        disable_dependencies={'on_change': ['view']},
        clear_dependencies={'on_change': ['view']})

    view = View(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='View',
                required=True,
                one_off=True,
                clear_below_on_change=False,
                enable_dependencies={'on_complete': ['parent_zone']},
                disable_dependencies={'on_change': ['parent_zone']},
                clear_dependencies={'on_change': ['parent_zone']},
                should_cascade_disable_on_change=True,
                should_cascade_clear_on_change=True)

    parent_zone = Zone(workflow_name=workflow_name,
                       permissions=workflow_permission,
                       label='Zone',
                       required=True,
                       start_initialized=True,
                       inputs={
                           'zone': 'parent_zone',
                           'configuration': 'configuration',
                           'view': 'view'
                       },
                       clear_below_on_change=False,
                       enable_dependencies={'on_complete': ['host_record']},
                       disable_dependencies={'on_change': ['host_record']},
                       clear_dependencies={
                           'on_change': ['host_record', 'name', 'ip4_address']
                       },
                       should_cascade_disable_on_change=True,
                       should_cascade_clear_on_change=True)

    host_record = HostRecord(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Host Record',
        required=True,
        inputs={
            'configuration': 'configuration',
            'view': 'view',
            'parent_zone': 'parent_zone',
            'host_record': 'host_record'
        },
        server_outputs={
            'on_complete': {
                'name': 'name',
                'addresses': 'ip4_address'
            }
        },
        server_side_output_method=get_host_records_endpoint,
        clear_below_on_change=False,
        enable_dependencies={
            'on_complete': ['submit', 'name', 'ip4_address', 'deploy_now']
        },
        disable_dependencies={
            'on_change': ['submit', 'name', 'ip4_address', 'deploy_now']
        },
        should_cascade_disable_on_change=True,
    )

    seperator = PlainHTML('<hr>')

    name = CustomStringField(label='New Host Name', required=True)

    ip4_address = CustomStringField(
        label=
        'IPv4 Address (multiple IPv4 addresses must be seperated by a comma)',
        required=True)

    deploy_now = CustomBooleanField(label='Deploy Now')

    submit = SubmitField(label='Update')
class GenericFormTemplate(GatewayForm):
    """Form to generate HTML and Javascript for the delete_host_record workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """

    workflow_name = "delete_host_record"
    workflow_permission = "delete_host_record_page"
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Configuration",
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        on_complete=["call_view"],
        enable_dependencies={"on_complete": ["view"]},
        disable_dependencies={"on_change": ["view"]},
        clear_dependencies={"on_change": ["view"]},
    )

    view = View(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="View",
        required=True,
        one_off=True,
        clear_below_on_change=False,
        enable_dependencies={"on_complete": ["parent_zone"]},
        disable_dependencies={"on_change": ["parent_zone"]},
        clear_dependencies={"on_change": ["parent_zone"]},
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True,
    )

    parent_zone = Zone(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Zone",
        required=True,
        start_initialized=True,
        inputs={
            "zone": "parent_zone",
            "configuration": "configuration",
            "view": "view"
        },
        clear_below_on_change=False,
        enable_dependencies={"on_complete": ["host_record"]},
        disable_dependencies={"on_change": ["host_record"]},
        clear_dependencies={
            "on_change": ["host_record", "name", "ip4_address"]
        },
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True,
    )

    host_record = HostRecord(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Host Record",
        required=True,
        inputs={
            "configuration": "configuration",
            "view": "view",
            "parent_zone": "parent_zone",
            "host_record": "host_record",
        },
        server_outputs={
            "on_complete": {
                "name": "name",
                "addresses": "ip4_address"
            }
        },
        server_side_output_method=get_host_records_endpoint,
        clear_below_on_change=False,
        enable_dependencies={
            "on_complete": ["submit", "name", "ip4_address", "deploy_now"]
        },
        disable_dependencies={
            "on_change": ["submit", "name", "ip4_address", "deploy_now"]
        },
    )

    separator = PlainHTML("<hr>")

    name = CustomStringField(label="Name", readonly=True)

    ip4_address = CustomStringField(label="IPv4 Address", readonly=True)

    deploy_now = CustomBooleanField(label="Deploy Now")

    submit = SubmitField(label="Delete")
class GenericFormTemplate(GatewayForm):
    """ Form to generate HTML and Javascript for the snow_add_host_record_example workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'service_request_host'
    workflow_permission = 'service_request_host_page'

    zone = CustomZone(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Zone',
        required=True,
        is_disabled_on_start=False
    )

    input_x1_button_x1_aligned_open_1 = PlainHTML('<div class="input_x1_button_x1_aligned">')

    input_x1_aligned_open_1 = PlainHTML('<div class="input_x1_aligned">')

    ip4_network = IP4Network(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Network (Optional)',
        required=False,
        one_off=False,
        is_disabled_on_start=False
    )

    input_x1_aligned_close_1 = PlainHTML('</div>')

    get_next_available_ip4 = CustomSearchButtonField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Get Next IPv4',
        server_side_method=get_next_ip4_address_endpoint,
        on_complete=['populate_ip4_address'],
        is_disabled_on_start=False,
    )

    input_x1_button_x1_aligned_close_1 = PlainHTML('</div>')

    clearfix_2 = PlainHTML('<div class="clearfix"> </div>')

    ip4_address = CustomIP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='IP Address',
        required=True,
        inputs={'address': 'ip4_address'},
        result_decorator=filter_reserved,
        should_cascade_disable_on_change=True,
        is_disabled_on_start=False
    )

    hostname = CustomStringField(
        label='Hostname',
        required=True,
        is_disabled_on_start=False
    )

    deploy_now = CustomBooleanField(
        label='Deploy Now',
        is_disabled_on_start=False
    )

    submit = CustomSubmitField(
        label='Submit',
        is_disabled_on_start=False
    )
예제 #11
0
class GenericFormTemplate(GatewayForm):
    # When updating the form, remember to make the corresponding changes to the workflow pages
    workflow_name = 'update_text_record_example'
    workflow_permission = 'update_text_record_example_page'
    configuration = Configuration(workflow_name=workflow_name,
                                  permissions=workflow_permission,
                                  label='Configuration',
                                  required=True,
                                  coerce=int,
                                  validators=[],
                                  is_disabled_on_start=False,
                                  on_complete=['call_view'],
                                  enable_on_complete=['view'])

    view = View(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='View',
                required=True,
                one_off=True,
                on_complete=[],
                enable_on_complete=['parent_zone'])

    parent_zone = Zone(workflow_name=workflow_name,
                       permissions=workflow_permission,
                       label='Zone',
                       required=True,
                       start_initialized=True,
                       inputs={
                           'zone': 'parent_zone',
                           'configuration': 'configuration',
                           'view': 'view'
                       },
                       enable_on_complete=['text_record', 'search'])

    text_record = CustomStringField(label='Text Record')

    search = CustomSearchButtonField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        default='Search',
        inputs={
            'configuration': 'configuration',
            'view': 'view',
            'parent_zone': 'parent_zone',
            'name': 'text_record'
        },
        server_side_method=get_text_records_endpoint,
        message_field='search_message',
        on_click=['populate_txt_list'],
        enable_on_complete=['txt_filter', 'txt_list'])

    plain_0 = PlainHTML('<div id="search_message"></div>')

    txt_filter = CustomStringField(label='Filter', is_disabled_on_error=True)

    txt_list = FilteredSelectField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Text',
        size=12,
        filter_field='txt_filter',
        choices=[(0, '')],
        coerce=int,
        is_disabled_on_error=True,
        on_complete=['call_name_js', 'call_text'],
        enable_on_complete=['name', 'text', 'submit'])

    plain_1 = PlainHTML('<hr>')

    name = CustomStringField(label='New Name', is_disabled_on_error=True)

    text = CustomStringField(label='New Text',
                             inputs={'text': 'txt_list'},
                             is_disabled_on_error=True)

    submit = SubmitField(label='Update', render_kw={'disabled': True})
예제 #12
0
class GenericFormTemplate(GatewayForm):
    """
    Cisco ACI form

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'cisco_aci'
    workflow_permission = 'cisco_aci_page'

    apic_ip = CustomStringField(
        label='APIC IP',
        required=True,
        default='',
        validators=[DataRequired()],
        is_disabled_on_start=False,
    )

    apic_username = CustomStringField(
        label='APIC USERNAME',
        default='',
        required=True,
        validators=[DataRequired()],
        is_disabled_on_start=False,
    )

    apic_password = CustomPasswordField(
        label='APIC PASSWORD',
        default='abc',
        validators=[DataRequired()],
        is_disabled_on_start=False,
    )

    optional = PlainHTML(
        '<hr/><h4>OPTIONAL</h4><p>Import ACI Fabric only if you wish to import APIC, SPINE, and'
        ' LEAF devices to the selected BAM configuration.</p><br/>')

    import_devices_checkbox = CustomBooleanField(
        label='Import ACI Fabric Devices to',
        on_checked=['enable_configuration'],
        on_unchecked=['disable_configuration', 'disable_import_fabric'],
        is_disabled_on_start=False,
    )

    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        coerce=int,
        label='',
        validators=[],
        enable_dependencies={'on_complete': ['import_fabric']},
        disable_dependencies={'on_change': ['import_fabric']},
        clear_below_on_change=False,
    )

    import_fabric = CustomSearchButtonField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='IMPORT FABRIC',
        default='IMPORT',
        server_side_method=add_fabric,
        display_message=True,
    )

    html = PlainHTML('<br/><br/><hr/>')

    discover = CustomSearchButtonField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='DISCOVER TENANTS',
        is_disabled_on_start=False,
        default='Search',
        on_complete=[
            'call_output_table', 'add_checkall_button',
            'add_on_page_change_listener'
        ],
        server_side_method=get_tenants,
        display_message=True,
    )

    output_table = TableField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='',
        data_function=raw_table_data,
        is_disabled_on_start=False,
    )

    import_tenants = SimpleButtonField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='IMPORT INFRASTRUCTURE',
        is_disabled_on_start=False,
        default='Search',
    )
class GenericFormTemplate(GatewayForm):
    """
    Generic form Template

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'add_next_available_dual_stack_host'
    workflow_permission = 'add_next_available_dual_stack_host_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        validators=[],
        is_disabled_on_start=False,
        on_complete=['call_view'],
        enable_on_complete=['view'],
        clear_below_on_change=False
    )

    view = View(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='View',
        required=True,
        one_off=True,
        on_complete=['call_zone'],
        clear_below_on_change=False,
        enable_dependencies={'on_complete': ['zone']},
        disable_dependencies={'on_change': ['zone']},
        clear_dependencies={'on_change': ['zone']},
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True
    )

    zone = Zone(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Zone',
        required=True,
        clear_below_on_change=False,
        enable_dependencies={'on_complete': ['hostname', 'ip4_network', 'ip6_network']},
        disable_dependencies={'on_change': ['hostname', 'ip4_network', 'ip6_network']},
        clear_dependencies={'on_change': ['hostname', 'ip4_network', 'ip6_network']},
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True
    )

    hostname = CustomStringField(
        label='Hostname',
        required=True
    )

    ip4_network = IP4Network(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='IPv4 Network',
        required=True,
        one_off=False,
        is_disabled_on_start=False
    )

    ip6_network = IP6Network(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='IPv6 Network',
        required=True,
        one_off=False,
        enable_dependencies={'on_complete': ['submit']},
        disable_dependencies={'on_change': ['submit']},
        is_disabled_on_start=False
    )

    add_device = CustomBooleanField(
        label='Add Device',
        is_disabled_on_start=False
    )

    submit = SubmitField(label='Submit')

    # Button with JS to clear the form
    clear_button = PlainHTML('<button type="button" onclick="clearForm();" class="clearForm">Clear Form</button>')
예제 #14
0
class GenericFormTemplate(GatewayForm):
    """Form to generate HTML and Javascript for the update_text_record workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """

    workflow_name = "update_text_record"
    workflow_permission = "update_text_record_page"
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Configuration",
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        on_complete=["call_view"],
        enable_dependencies={"on_complete": ["view"]},
        disable_dependencies={"on_change": ["view"]},
        clear_dependencies={"on_change": ["view"]},
    )

    view = View(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="View",
        required=True,
        one_off=True,
        clear_below_on_change=False,
        display_message=True,
        enable_dependencies={"on_complete": ["parent_zone"]},
        disable_dependencies={"on_change": ["parent_zone"]},
        clear_dependencies={"on_change": ["parent_zone"]},
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True,
    )

    parent_zone = Zone(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Zone",
        required=True,
        start_initialized=True,
        display_message=True,
        inputs={"zone": "parent_zone", "configuration": "configuration", "view": "view"},
        clear_below_on_change=False,
        enable_dependencies={"on_complete": ["text_record", "search"]},
        disable_dependencies={"on_change": ["text_record", "search"]},
        clear_dependencies={"on_change": ["text_record", "search"]},
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True,
    )

    text_record = CustomStringField(label="Text Record")

    search = CustomSearchButtonField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        default="Search",
        inputs={
            "configuration": "configuration",
            "view": "view",
            "parent_zone": "parent_zone",
            "name": "text_record",
        },
        server_side_method=get_text_records_endpoint,
        display_message=True,
        on_complete=["call_txt_list"],
        enable_dependencies={"on_complete": ["txt_filter", "txt_list"]},
        disable_dependencies={
            "on_change": ["txt_filter", "txt_list"],
            "on_click": ["txt_filter", "txt_list"],
        },
        clear_dependencies={
            "on_change": ["txt_filter", "txt_list"],
            "on_click": ["txt_filter", "txt_list"],
        },
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True,
    )

    txt_filter = CustomStringField(label="Filter", is_disabled_on_error=True)

    txt_list = FilteredSelectField(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Text",
        size=12,
        filter_field="txt_filter",
        choices=[(0, "")],
        coerce=int,
        is_disabled_on_error=True,
        on_complete=["call_name_js", "call_text"],
        inputs={
            "configuration": "configuration",
            "view": "view",
            "parent_zone": "parent_zone",
            "name": "text_record",
        },
        clear_dependencies={"on_change": ["name", "text"]},
        server_side_method=get_text_records_endpoint,
        enable_dependencies={"on_complete": ["name", "text", "submit"]},
        disable_dependencies={"on_change": ["name", "text", "submit"]},
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True,
    )

    plain_1 = PlainHTML("<hr>")

    name = CustomStringField(label="New Name", is_disabled_on_error=True)

    text = CustomStringField(
        label="New Text", inputs={"text": "txt_list"}, is_disabled_on_error=True
    )

    submit = CustomSubmitField(label="Update")