def view_proto_table():
    value_types = EnvUtil.get_all_schemas(
        pslx_frontend_ui_app.config['schemas'])
    if request.method == 'POST':
        try:
            proto_table_path = request.form['proto_table_path'].strip()
            selected_value_type = request.form['value_type'].strip()
            modules = selected_value_type.split('.')
            module, value_type = '.'.join(modules[:-1]), modules[-1]
            pslx_frontend_logger.info("Proto table viewer input path [" +
                                      proto_table_path +
                                      '] with value type [' + value_type +
                                      '] in module name [' + module + '].')
            result = FileUtil.read_proto_from_file(proto_type=ProtoTable,
                                                   file_name=proto_table_path)
            value_type = ProtoUtil.infer_message_type_from_str(
                message_type_str=value_type, modules=module)
            proto_contents = []
            result_content = dict(result.data)
            for key in sorted(result_content.keys()):
                proto_val = ProtoUtil.any_to_message(
                    message_type=value_type, any_message=result_content[key])
                try:
                    proto_contents.append({
                        'key':
                        key,
                        'val':
                        ProtoUtil.message_to_text(proto_message=proto_val),
                    })
                except Exception as err:
                    pslx_frontend_logger.error(
                        "Proto table viewer Parsing proto with error " +
                        str(err) + '.')
                    proto_contents.append({
                        'key': key,
                        'val': str(proto_val),
                    })
            value_types.remove(selected_value_type)
            return render_template('proto_table_viewer.html',
                                   proto_contents=proto_contents,
                                   value_types=value_types,
                                   selected_value_type=selected_value_type)
        except Exception as err:
            pslx_frontend_logger.error(
                "Got error rendering proto_table_viewer.html: " + str(err) +
                '.')
            return render_template('proto_table_viewer.html',
                                   proto_contents=[],
                                   value_types=value_types,
                                   selected_value_type='')
    else:
        return render_template('proto_table_viewer.html',
                               proto_contents=[],
                               value_types=value_types,
                               selected_value_type='')
def view_proto():
    value_types = EnvUtil.get_all_schemas(pslx_frontend_ui_app.config['schemas'])
    if request.method == 'POST':
        try:
            proto_file_path = request.form['proto_file_path'].strip()
            selected_value_type = request.form['value_type'].strip()
            modules = selected_value_type.split('.')
            module, message_type_str = '.'.join(modules[:-1]), modules[-1]
            pslx_frontend_logger.info("Proto viewer input path [" + proto_file_path + '] with message type [' +
                                      message_type_str + '] in module name [' + module + '].')
            message_type = ProtoUtil.infer_message_type_from_str(
                message_type_str=message_type_str,
                modules=module
            )
            proto_message = FileUtil.read_proto_from_file(
                proto_type=message_type, file_name=proto_file_path)

            result_ui = ProtoUtil.message_to_text(proto_message=proto_message)

            return render_template(
                'proto_viewer.html',
                proto_content=result_ui,
                value_types=value_types,
                selected_value_type=selected_value_type
            )
        except Exception as err:
            pslx_frontend_logger.error("Got error rendering proto_viewer.html: " + str(err) + '.')
            return render_template(
                'proto_viewer.html',
                proto_content="Got error rendering proto_viewer.html: " + str(err) + '.',
                value_types=value_types,
                selected_value_type=''
            )
    else:
        return render_template(
            'proto_viewer.html',
            proto_content="",
            value_types=value_types,
            selected_value_type=''
        )