indexes.twig 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <fieldset class="index_info">
  2. <legend id="index_header">
  3. {% trans 'Indexes' %}
  4. {{ show_mysql_docu('optimizing-database-structure') }}
  5. </legend>
  6. {% if indexes is not empty %}
  7. {{ indexes_duplicates|raw }}
  8. <div class="table-responsive jsresponsive">
  9. <table class="table table-light table-striped table-hover table-sm w-auto" id="table_index">
  10. <thead class="thead-light">
  11. <tr>
  12. <th colspan="3" class="print_ignore">{% trans 'Action' %}</th>
  13. <th>{% trans 'Keyname' %}</th>
  14. <th>{% trans 'Type' %}</th>
  15. <th>{% trans 'Unique' %}</th>
  16. <th>{% trans 'Packed' %}</th>
  17. <th>{% trans 'Column' %}</th>
  18. <th>{% trans 'Cardinality' %}</th>
  19. <th>{% trans 'Collation' %}</th>
  20. <th>{% trans 'Null' %}</th>
  21. <th>{% trans 'Comment' %}</th>
  22. </tr>
  23. </thead>
  24. {% for index in indexes %}
  25. <tbody class="row_span">
  26. {% set columns_count = index.getColumnCount() %}
  27. <tr class="noclick">
  28. <td rowspan="{{ columns_count }}" class="edit_index print_ignore ajax">
  29. <a class="ajax" href="{{ url('/table/indexes') }}" data-post="{{ get_common(url_params|merge({'index': index.getName()}), '') }}">
  30. {{ get_icon('b_edit', 'Edit'|trans) }}
  31. </a>
  32. </td>
  33. <td rowspan="{{ columns_count }}" class="rename_index print_ignore ajax" >
  34. <a class="ajax" href="{{ url('/table/indexes/rename') }}" data-post="{{ get_common(url_params|merge({'index': index.getName()}), '') }}">
  35. {{ get_icon('b_rename', 'Rename'|trans) }}
  36. </a>
  37. </td>
  38. <td rowspan="{{ columns_count }}" class="print_ignore">
  39. {% if index.getName() == 'PRIMARY' %}
  40. {% set index_params = {
  41. 'sql_query': 'ALTER TABLE ' ~ backquote(table) ~ ' DROP PRIMARY KEY;',
  42. 'message_to_show': 'The primary key has been dropped.'|trans
  43. } %}
  44. {% else %}
  45. {% set index_params = {
  46. 'sql_query': 'ALTER TABLE ' ~ backquote(table) ~ ' DROP INDEX ' ~ backquote(index.getName()) ~ ';',
  47. 'message_to_show': 'Index %s has been dropped.'|trans|format(index.getName())
  48. } %}
  49. {% endif %}
  50. <input type="hidden" class="drop_primary_key_index_msg" value="{{ index_params.sql_query|js_format(false) }}">
  51. {{ link_or_button(
  52. url('/sql', url_params|merge(index_params)),
  53. get_icon('b_drop', 'Drop'|trans),
  54. {'class': 'drop_primary_key_index_anchor ajax'}
  55. ) }}
  56. </td>
  57. <th rowspan="{{ columns_count }}">{{ index.getName() }}</th>
  58. <td rowspan="{{ columns_count }}">{{ index.getType()|default(index.getChoice()) }}</td>
  59. <td rowspan="{{ columns_count }}">{{ index.isUnique() ? 'Yes'|trans : 'No'|trans }}</td>
  60. <td rowspan="{{ columns_count }}">{{ index.isPacked()|raw }}</td>
  61. {% for column in index.getColumns() %}
  62. {% if column.getSeqInIndex() > 1 %}
  63. <tr class="noclick">
  64. {% endif %}
  65. <td>
  66. {{ column.getName() }}
  67. {% if column.getSubPart() is not empty %}
  68. ({{ column.getSubPart() }})
  69. {% endif %}
  70. </td>
  71. <td>{{ column.getCardinality() }}</td>
  72. <td>{{ column.getCollation() }}</td>
  73. <td>{{ column.getNull(true) }}</td>
  74. {% if column.getSeqInIndex() == 1 %}
  75. <td rowspan="{{ columns_count }}">{{ index.getComments() }}</td>
  76. {% endif %}
  77. </tr>
  78. {% endfor %}
  79. </tbody>
  80. {% endfor %}
  81. </table>
  82. </div>
  83. {% else %}
  84. <div class="no_indexes_defined">{{ 'No index defined!'|trans|notice }}</div>
  85. {% endif %}
  86. </fieldset>