Adding gr.Dropdown for every value

Hi,

Is there a way to add gr.Dropdown for every port on the results on the right? I want to have the ability in case the port is in admin state down\up to select from a dropdown ‘up\down’ and apply it

I tried to put a function within the with gr.Blocks() but didn’t manage to succeed.

Is there anyway to achieve it?

The UI:

with gr.Blocks(title = 'Switcher') as switches_ver:
    gr.Markdown('Welcome to Switcher')
    with gr.Row():      
        with gr.Column():
            switch_box = gr.Textbox(label = 'Switches', lines = 10, placeholder=('1. This script works only for HP Aruba switches.\n'
                                                                                '2. Switches will be upgrade at the same time.\n' 
                                                                                '3. You can press Stop Code! button to abort the script in case of an emergency.\n'
                                                                                '4. You have to confirm the check box in order to start the upgrade proccess.'))
            with gr.Accordion('Show commands', open=False):                                                                    
                show_ver = gr.Button('Show current switches version')
                ping_btn = gr.Button('Ping')

            with gr.Accordion('Port information', open=False):
                get_port_btn = gr.Button('Get port information')
            with gr.Accordion('Switch upgrade', open=False):
                version_selection_dropdown = gr.Dropdown(['YA_16_10_0021.swi', 'YA_16_10_0002.swi'], label = 'Choose a version:')
                image_selection_dropdown = gr.Dropdown(['PRIMARY_IMAGE', 'SECONDARY_IMAGE'], label = 'Choose Image:', value = '')
                version_selection_chk = gr.Checkbox(label = 'Confirm')
                upgrade_ver = gr.Button('Upgrade selected switches')

        with gr.Column():
            output_textbox = gr.Textbox(label='Results',lines = 10, max_lines=10)
            output_ping = gr.Textbox(label='Ping', lines = 5)
            output_file = gr.File(['switches_success_results.txt', 'switches_failed_results.txt'])
            ping_event = ping_btn.click(fn=pinger, inputs = switch_box, outputs=output_ping, every=1)
            upgrade_event = upgrade_ver.click(fn=switch_upgrade, inputs = [switch_box, version_selection_dropdown, version_selection_chk, image_selection_dropdown], outputs=[output_textbox, output_file])
            show_ver.click(fn=switch_ver, inputs = switch_box, outputs = [output_textbox, output_file, output_ping], cancels=[ping_event])


            get_port_btn.click(fn=get_port, inputs=[switch_box], outputs=[output_textbox, output_file], scroll_to_output=True)

The function:

def get_port(ip):
    port_brief_response = []
    global ip_cookie
    ip_addr = ip.split()
    for i in ip_addr:
        try:
            ipaddress.ip_network(i)
            if ip_cookie.get(i):
                get_port_brief = requests.get('http://'+i+':80/rest/v7/ports', cookies=ip_cookie.get(i)).json()
                for d in get_port_brief['port_element']:
                    (port_brief_response.append('Port '+(d.get('id')+' is')))
                    [port_brief_response.append(' UP\n') if d.get('is_port_up') else port_brief_response.append(' DOWN\n')]



            else:
                ipaddress.ip_network(i)
                auth_payload = {"userName":"admin","password":"kawasaki"}             
                login = requests.Session()
                login = login.post('http://'+i+':80/rest/v7/login-sessions', data = json.dumps(auth_payload))
                ip_cookie[i] = login.cookies
                get_port_brief = requests.get('http://'+i+':80/rest/v7/ports', cookies=ip_cookie.get(i)).json()
                for d in get_port_brief['port_element']:
                    (port_brief_response.append('Port '+(d.get('id')+' is')))
                    [port_brief_response.append(' UP\n') if d.get('is_port_up') else port_brief_response.append(' DOWN\n')]

        except:
            pass
    return ''.join(port_brief_response), ['switches_success_results.txt', 'switches_failed_results.txt']

Thank you very much!