From 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 9 Jan 2020 10:55:03 +0100 Subject: phpmyadmin working --- .../structure/action_row_in_structure_table.twig | 31 ++ .../table/structure/display_partitions.twig | 145 ++++++ .../table/structure/display_structure.twig | 516 +++++++++++++++++++++ .../table/structure/display_table_stats.twig | 169 +++++++ .../table/structure/partition_definition_form.twig | 14 + 5 files changed, 875 insertions(+) create mode 100644 srcs/phpmyadmin/templates/table/structure/action_row_in_structure_table.twig create mode 100644 srcs/phpmyadmin/templates/table/structure/display_partitions.twig create mode 100644 srcs/phpmyadmin/templates/table/structure/display_structure.twig create mode 100644 srcs/phpmyadmin/templates/table/structure/display_table_stats.twig create mode 100644 srcs/phpmyadmin/templates/table/structure/partition_definition_form.twig (limited to 'srcs/phpmyadmin/templates/table/structure') diff --git a/srcs/phpmyadmin/templates/table/structure/action_row_in_structure_table.twig b/srcs/phpmyadmin/templates/table/structure/action_row_in_structure_table.twig new file mode 100644 index 0000000..d9c629c --- /dev/null +++ b/srcs/phpmyadmin/templates/table/structure/action_row_in_structure_table.twig @@ -0,0 +1,31 @@ +
  • +{% if type == 'text' + or type == 'blob' + or tbl_storage_engine == 'ARCHIVE' + or has_field %} + {{ titles['No' ~ action]|raw }} +{% else %} + + {{ titles[action]|raw }} + +{% endif %} +
  • diff --git a/srcs/phpmyadmin/templates/table/structure/display_partitions.twig b/srcs/phpmyadmin/templates/table/structure/display_partitions.twig new file mode 100644 index 0000000..b10a0bc --- /dev/null +++ b/srcs/phpmyadmin/templates/table/structure/display_partitions.twig @@ -0,0 +1,145 @@ +
    +
    + + {% trans 'Partitions' %} + {{ show_mysql_docu('partitioning') }} + + {% if partitions is empty %} + {{ 'No partitioning defined!'|trans|notice }} + {% else %} +

    + {% trans 'Partitioned by:' %} + {{ partition_method }}({{ partition_expression }}) +

    + {% if has_sub_partitions %} +

    + {% trans 'Sub partitioned by:' %} + {{ sub_partition_method }}({{ sub_partition_expression }}) +

    + {% endif %} + + + + + + {% if has_description %} + + {% endif %} + + + + + + + + + {% for partition in partitions %} + + {% if has_sub_partitions %} + + + {% else %} + + {% endif %} + + {% if has_description %} + + {% endif %} + + + + + {% for action, icon in action_icons %} + + {% endfor %} + + {% if has_sub_partitions %} + {% for sub_partition in partition.getSubPartitions() %} + + + + + {% if has_description %} + + {% endif %} + + + + + + + {% endfor %} + {% endif %} + + {% endfor %} + +
    #{% trans 'Partition' %}{% trans 'Expression' %}{% trans 'Rows' %}{% trans 'Data length' %}{% trans 'Index length' %}{% trans 'Comment' %} + {% trans 'Action' %} +
    {{ partition.getOrdinal() }}{{ partition.getOrdinal() }}{{ partition.getName() }} + + {{- partition.getExpression() -}} + {{- partition.getMethod() == 'LIST' ? ' IN (' : ' < ' -}} + {{- partition.getDescription() -}} + {{- partition.getMethod() == 'LIST' ? ')' -}} + + {{ partition.getRows() }} + {% set data_length = format_byte_down( + partition.getDataLength(), + 3, + 1 + ) %} + {{ data_length[0] }} + {{ data_length[1] }} + + {% set index_length = format_byte_down( + partition.getIndexLength(), + 3, + 1 + ) %} + {{ index_length[0] }} + {{ index_length[1] }} + {{ partition.getComment() }} + + {{ icon|raw }} + +
    {{ sub_partition.getOrdinal() }}{{ sub_partition.getName() }}{{ sub_partition.getRows() }} + {% set data_length = format_byte_down( + sub_partition.getDataLength(), + 3, + 1 + ) %} + {{ data_length[0] }} + {{ data_length[1] }} + + {% set index_length = format_byte_down( + sub_partition.getIndexLength(), + 3, + 1 + ) %} + {{ index_length[0] }} + {{ index_length[1] }} + {{ sub_partition.getComment() }}
    + {% endif %} +

    + +
    diff --git a/srcs/phpmyadmin/templates/table/structure/display_structure.twig b/srcs/phpmyadmin/templates/table/structure/display_structure.twig new file mode 100644 index 0000000..16e11db --- /dev/null +++ b/srcs/phpmyadmin/templates/table/structure/display_structure.twig @@ -0,0 +1,516 @@ +{% extends 'table/page_with_secondary_tabs.twig' %} +{% block content %} +
    + {{ get_hidden_inputs(db, table) }} + +
    + + {# Table header #} + + + + + + + + + + + {% if show_column_comments -%} + + {%- endif %} + + {# @see table/structure.js, function moreOptsMenuResize() #} + {% if not db_is_system_schema and not tbl_is_view %} + + {% endif %} + + + + {# Table body #} + {% set rownum = 0 %} + {% for row in fields %} + {% set rownum = rownum + 1 %} + + {% set extracted_columnspec = extracted_columnspecs[rownum] %} + {% set field_name = row['Field']|e %} + {# For column comments #} + {% set comments = row_comments[rownum] %} + {# Underline commented fields and display a hover-title (CSS only) #} + + + + + + + + {{ extracted_columnspec['displayed_type']|raw }} + {% if relation_commwork and relation_mimework and browse_mime + and mime_map[row['Field']]['mimetype'] is defined %} +
    {% trans 'Media (MIME) type:' %} {{ mime_map[row['Field']]['mimetype']|replace({'_': '/'})|lower }} + {% endif %} +
    + +
    + + + + {% if show_column_comments %} + + {% endif %} + + {% if not tbl_is_view and not db_is_system_schema %} + + + {% endif %} + + {% if not tbl_is_view and not db_is_system_schema %} + {% set type = extracted_columnspec['print_type'] is not empty ? extracted_columnspec['print_type'] %} + + {% endif %} + + {% endfor %} + +
    #{% trans 'Name' %}{% trans 'Type' %}{% trans 'Collation' %}{% trans 'Attributes' %}{% trans 'Null' %}{% trans 'Default' %}{% trans 'Comments' %}{% trans 'Extra' %}{% trans 'Action' %}
    {{ rownum }} + + + {% if row['Collation'] is not empty %} + {{ collations[row['Collation']].name }} + {% endif %} + {{ attributes[rownum] }}{{ row['Null'] == 'YES' ? 'Yes'|trans : 'No'|trans }} + {% if row['Default'] is not null %} + {% if extracted_columnspec['type'] == 'bit' %} + {{ row['Default']|convert_bit_default_value }} + {% else %} + {{ row['Default'] }} + {% endif %} + {% elseif row['Null'] == 'YES' %} + NULL + {% else %} + {% trans %}None{% context %}None for default{% endtrans %} + {% endif %} + + {{ comments }} + {{ row['Extra']|upper }}
    +
    + +
    + +
    +

    {% trans 'Move the columns by dragging them up and down.' %}

    +
    +
    + {{ get_hidden_inputs(db, table) }} +
      +
      +
      +
      +{# Work on the table #} + +{% if not tbl_is_view and not db_is_system_schema %} +
      + {{ get_hidden_inputs(db, table) }} + {% if show_icons('ActionLinksMode') %} + {{ get_image('b_insrow', 'Add column'|trans) }}  + {% endif %} + {% set num_fields -%} + + {%- endset %} + {{ 'Add %s column(s)'|trans|format(num_fields)|raw }} +   + {# I tried displaying the drop-down inside the label but with Firefox the drop-down was blinking #} + + +
      +{% endif %} + +{# Displays indexes #} +{% if not tbl_is_view and not db_is_system_schema + and 'ARCHIVE' != tbl_storage_engine %} + {{ displayIndexesHtml|raw }} +{% endif %} + +{# Display partition details #} +{% if have_partitioning %} + {# Detect partitioning #} + {% if partition_names is not empty and partition_names[0] is not null %} + {% set first_partition = partitions[0] %} + {% set range_or_list = first_partition.getMethod() == 'RANGE' + or first_partition.getMethod() == 'RANGE COLUMNS' + or first_partition.getMethod() == 'LIST' + or first_partition.getMethod() == 'LIST COLUMNS' %} + {% set sub_partitions = first_partition.getSubPartitions() %} + {% set has_sub_partitions = first_partition.hasSubPartitions() %} + {% if has_sub_partitions %} + {% set first_sub_partition = sub_partitions[0] %} + {% endif %} + + {% set action_icons = { + 'ANALYZE': get_icon('b_search', 'Analyze'|trans), + 'CHECK': get_icon('eye', 'Check'|trans), + 'OPTIMIZE': get_icon('normalize', 'Optimize'|trans), + 'REBUILD': get_icon('s_tbl', 'Rebuild'|trans), + 'REPAIR': get_icon('b_tblops', 'Repair'|trans), + 'TRUNCATE': get_icon('b_empty', 'Truncate'|trans), + } %} + {% if range_or_list %} + {% set action_icons = action_icons|merge({'DROP': get_icon('b_drop', 'Drop'|trans)}) %} + {% endif %} + + {# open Slider Effect div #} + {% include 'div_for_slider_effect.twig' with { + 'id': 'partitions-2', + 'message': 'Partitions'|trans, + 'initial_sliders_state': default_sliders_state + } only %} + + {% set remove_sql = 'ALTER TABLE ' ~ backquote(table) ~ ' REMOVE PARTITIONING' %} + {% set remove_url = 'sql.php' ~ url_query ~ '&sql_query=' ~ remove_sql|url_encode %} + + {% include 'table/structure/display_partitions.twig' with { + 'db': db, + 'table': table, + 'url_query': url_query, + 'partitions': partitions, + 'partition_method': first_partition.getMethod(), + 'partition_expression': first_partition.getExpression(), + 'has_description': first_partition.getDescription() is not empty, + 'has_sub_partitions': has_sub_partitions, + 'sub_partition_method': has_sub_partitions ? first_sub_partition.getMethod(), + 'sub_partition_expression': has_sub_partitions ? first_sub_partition.getExpression(), + 'action_icons': action_icons, + 'range_or_list': range_or_list, + 'remove_url': remove_url + } only %} + {% else %} + {% include 'table/structure/display_partitions.twig' with { + 'db': db, + 'table': table + } only %} + {% endif %} + {# For closing Slider effect div #} + +{% endif %} + +{# Displays Space usage and row statistics #} +{% if show_stats %} + {{ table_stats|raw }} +{% endif %} +
      +{% endblock %} diff --git a/srcs/phpmyadmin/templates/table/structure/display_table_stats.twig b/srcs/phpmyadmin/templates/table/structure/display_table_stats.twig new file mode 100644 index 0000000..01c74ae --- /dev/null +++ b/srcs/phpmyadmin/templates/table/structure/display_table_stats.twig @@ -0,0 +1,169 @@ +
      +
      + {% trans 'Information' %} + {% if showtable['TABLE_COMMENT'] %} +

      + {% trans 'Table comments:' %} + {{ showtable['TABLE_COMMENT'] }} +

      + {% endif %} + + + {% if not tbl_is_view and not db_is_system_schema %} + + + + + + + + + + {% if index_size is defined %} + + + + + + {% endif %} + + {% if free_size is defined %} + + + + + + + + + + + {% endif %} + + {% if tot_size is defined and mergetable == false %} + + + + + + {% endif %} + + {# Optimize link if overhead #} + {% if free_size is defined + and (tbl_storage_engine == 'MYISAM' + or tbl_storage_engine == 'ARIA' + or tbl_storage_engine == 'MARIA' + or tbl_storage_engine == 'BDB') + or (tbl_storage_engine == 'INNODB' and innodb_file_per_table == true) %} + + + + {% endif %} + +
      {% trans 'Space usage' %}
      {% trans 'Data' %}{{ data_size }}{{ data_unit }}
      {% trans 'Index' %}{{ index_size }}{{ index_unit }}
      {% trans 'Overhead' %}{{ free_size }}{{ free_unit }}
      {% trans 'Effective' %}{{ effect_size }}{{ effect_unit }}
      {% trans 'Total' %}{{ tot_size }}{{ tot_unit }}
      + {% endif %} + + {% set avg_size = avg_size is defined ? avg_size : null %} + {% set avg_unit = avg_unit is defined ? avg_unit : null %} + + + + {% if showtable['Row_format'] is defined %} + + + {% if showtable['Row_format'] == 'Fixed' %} + + {% elseif showtable['Row_format'] == 'Dynamic' %} + + {% else %} + + {% endif %} + + {% endif %} + + {% if showtable['Create_options'] is not empty %} + + + {% if showtable['Create_options'] == 'partitioned' %} + + {% else %} + + {% endif %} + + {% endif %} + + {% if table_collation is not empty %} + + + + + {% endif %} + + {% if not is_innodb and showtable['Rows'] is defined %} + + + + + {% endif %} + + {% if not is_innodb + and showtable['Avg_row_length'] is defined + and showtable['Avg_row_length'] > 0 %} + + + {% set avg_row_length = format_byte_down(showtable['Avg_row_length'], 6, 1) %} + + + {% endif %} + + {% if not is_innodb + and showtable['Data_length'] is defined + and showtable['Rows'] is defined + and showtable['Rows'] > 0 + and mergetable == false %} + + + + + {% endif %} + + {% if showtable['Auto_increment'] is defined %} + + + + + {% endif %} + + {% if showtable['Create_time'] is defined %} + + + + + {% endif %} + + {% if showtable['Update_time'] is defined %} + + + + + {% endif %} + + {% if showtable['Check_time'] is defined %} + + + + + {% endif %} + +
      {% trans 'Row statistics' %}
      {% trans 'Format' %}{% trans 'static' %}{% trans 'dynamic' %}{{ showtable['Row_format'] }}
      {% trans 'Options' %}{% trans 'partitioned' %}{{ showtable['Create_options'] }}
      {% trans 'Collation' %} + + {{ table_collation.name }} + +
      {% trans 'Rows' %}{{ format_number(showtable['Rows'], 0) }}
      {% trans 'Row length' %}{{ avg_row_length[0] }} {{ avg_row_length[1] }}
      {% trans 'Row size' %}{{ avg_size }} {{ avg_unit }}
      {% trans 'Next autoindex' %}{{ format_number(showtable['Auto_increment'], 0) }}
      {% trans 'Creation' %}{{ localised_date(showtable['Create_time']|date('U')) }}
      {% trans 'Last update' %}{{ localised_date(showtable['Update_time']|date('U')) }}
      {% trans 'Last check' %}{{ localised_date(showtable['Check_time']|date('U')) }}
      +
      +
      diff --git a/srcs/phpmyadmin/templates/table/structure/partition_definition_form.twig b/srcs/phpmyadmin/templates/table/structure/partition_definition_form.twig new file mode 100644 index 0000000..7cf5e8d --- /dev/null +++ b/srcs/phpmyadmin/templates/table/structure/partition_definition_form.twig @@ -0,0 +1,14 @@ +
      + {{ get_hidden_inputs(db, table) }} + + +
      + {% trans 'Edit partitioning' %} + {% include 'columns_definitions/partitions.twig' with { + 'partition_details': partition_details + } only %} +
      +
      + +
      +
      -- cgit