You are here

database.html.twig in Devel 8

{% block toolbar %}
    {% set icon %}
    <a href="{{ url("webprofiler.dashboard", {profile: token}, {fragment: 'database'}) }}" title="{{ 'Database'|t }}">
        <img width="20" height="28" alt="{{ 'Database'|t }}"
             src="data:image/png;base64,{{ collector.icon }}"/>
        <span class="sf-toolbar-info-piece-additional sf-toolbar-status sf-toolbar-status-{{ collector.colorCode }}">{{ collector.querycount }}</span>
        {% if collector.querycount > 0 %}
            <span class="sf-toolbar-info-piece-additional-detail">in {{ '%0.2f ms'|format(collector.time) }}</span>
        {% endif %}
    </a>
    {% endset %}
    {% set text %}
    <div class="sf-toolbar-info-piece">
        <b>{{ 'DB Queries'|t }}</b>
        <span>{{ collector.querycount }}</span>
    </div>
    <div class="sf-toolbar-info-piece">
        <b>{{ 'Query time'|t }}</b>
        <span>{{ '%0.2f ms'|format(collector.time) }}</span>
    </div>
    <div class="sf-toolbar-info-piece">
        <b>{{ 'Default database'|t }}</b>
        <span>{{ collector.database.driver }}://{{ collector.database.host }}:{{ collector.database.port }}
            /{{ collector.database.database }}</span>
    </div>
    {% endset %}

    <div class="sf-toolbar-block">
        <div class="sf-toolbar-icon">{{ icon|default('') }}</div>
        <div class="sf-toolbar-info">{{ text|default('') }}</div>
    </div>
{% endblock %}

{% block panel %}
    <script id="database" type="text/template">
        <h2 class="panel__title">{{ 'Database'|t }}</h2>

        <form class="panel__toolbar">
            <div class="panel__filter--text">
                <input id="edit-caller" class="js--live-filter" placeholder="{{ 'Caller'|t }}" type="text"/>
                <label for="edit-caller" class="panel__filter-label">{{ 'Caller'|t }}</label>
            </div>
            <div class="panel__filter--select">
                <select id="edit-type" class="js--live-filter">
                    <option value="">{{ 'Any'|t }}</option>
                    <option value="select">Select</option>
                    <option value="insert">Insert</option>
                    <option value="update">Update</option>
                    <option value="create">Create</option>
                    <option value="delete">Delete</option>
                </select>
                <label for="edit-type" class="panel__filter-label">{{ 'Query type'|t }}</label>
            </div>
            <div class="panel__filter--select">
                <select id="edit-hightlighted" class="js--live-filter">
                    <option value="">{{ 'Any'|t }}</option>
                    <option value="1">{{ 'Yes'|t }}</option>
                    <option value="0">{{ 'No'|t }}</option>
                </select>
                <label for="edit-type" class="panel__filter-label">{{ 'Slow queries'|t }}</label>
            </div>
            <div class="panel__filter--select">
                <select id="edit-database" class="js--live-filter">
                    <option value="">{{ 'Any'|t }}</option>
                    <% _.each(data.connections, function( item ){ %>
                        <option value="<%- item %>"><%- item %></option>
                    <% }) %>
                </select>
                <label for="edit-database" class="panel__filter-label">{{ 'Database'|t }}</label>
            </div>

            <div class="button--flat l-right js--code-toggle--global js--placeholder-visible">{{ 'Swap Placeholders'|t }}</div>

        </form>

        <% _.each( data.queries, function( item, key ){ %>
        <div class="panel__container<% if (item.time > data.query_highlight_threshold) { %> is--hightlighted <% } %>"
             data-wp-caller="<%- item.caller.class != null ? item.caller.class.toLowerCase() : '' %>"
             data-wp-database="<%- item.database %>"
             data-wp-type="<%- item.type %>"
             data-wp-hightlighted="<%- (item.time > data.query_highlight_threshold) ? '1' : '0' %>">
            <div class="panel__expand-header ">
                    <pre <% if( item.query_args) { %> class="js--code-target"<% } %> >
                        <code class="sql js--placeholder-query">
                            <%- item.query %>
                        </code>
                        <% if( item.query_args) { %>
                        <code class="sql js--clipboard-target is--hidden js--original-query">
                            <%- item.query_args %>
                        </code>
                        <% } %>
                    </pre>
                <ul class="list--inline">
                    <li><b>{{ 'Time'|t }}</b>: <%- Drupal.webprofiler.helpers.printTime(item.time) %></li>
                    <li><b>{{ 'Caller'|t }}</b>: <%= Drupal.webprofiler.helpers.classLink({"file" : item.caller.file,
                        "class" : item.caller.class, "line" : item.caller.line, "method" : item.caller.function}) %>
                    </li>
                    <li><b>{{ 'Database'|t }}</b>: <%- item.database %></li>
                    <li><b>{{ 'Target'|t }}</b>: <%- item.target %></li>
                </ul>

                <% if(item.query_args){ %>
                <div class="button--flat l-right js--code-toggle">{{ 'Swap Placeholders'|t }}</div>
                <% } %>
                <% if(item.args){ %>
                <div class="button--flat l-right js--panel-toggle">{{ 'Info'|t }}</div>
                <% } %>
                <!--div class="button--flat l-right js--clipboard-trigger">{{ 'Copy Query'|t }}</div-->
                <% if(item.explain){ %>
                <div class="button--flat l-right js--explain-trigger"
                     data-wp-queryPosition="<%- key %>"
                        >{{ 'Explain'|t }}</div>
                <% } %>
            </div>

            <% if(item.explain){ %>
            <div class="loader--linear js--loader" style="display: none">
                <div class="loader__bar"></div>
                <div class="loader__bar"></div>
                <div class="loader__bar"></div>
            </div>
            <div class="panel__expand-content js--explain-target"></div>
            <% } %>

            <% if(item.args){ %>
            <div class="panel__expand-content">
                <div class="wp-query-arguments">
                    <table class="table--duo">
                        <thead>
                        <tr>
                            <th>{{ 'placeholder'|t }}</th>
                            <th>{{ 'value'|t }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        <% _.each( item.args, function( item, key ){ %>
                        <tr>
                            <td><%- key %></td>
                            <td><%= Drupal.webprofiler.helpers.frm(item) %></td>
                        </tr>
                        <% }); %>
                        </tbody>
                    </table>
                </div>
            </div>
            <% } %>
        </div>
        <% }); %>
    </script>
    <script id="wp-query-explain-template" type="text/template">
        <table class="table--compact">
            <thead>
            <tr>
                <% _.each(rc.data[1], function(value, key, list) { %>
                <th><%= key %></th>
                <% }); %>
            </tr>
            </thead>
            <% _.each(rc.data, function(value) { %>
            <tr>
                <% _.each(value, function(value2, key, list) { %>
                <td><%= value2 %></td>
                <% }); %>
            </tr>
            <% }); %>
        </table>
    </script>
{% endblock %}

File

webprofiler/templates/Collector/database.html.twig
View source
  1. {% block toolbar %}
  2. {% set icon %}
  3. <a href="{{ url("webprofiler.dashboard", {profile: token}, {fragment: 'database'}) }}" title="{{ 'Database'|t }}">
  4. <img width="20" height="28" alt="{{ 'Database'|t }}"
  5. src="data:image/png;base64,{{ collector.icon }}"/>
  6. <span class="sf-toolbar-info-piece-additional sf-toolbar-status sf-toolbar-status-{{ collector.colorCode }}">{{ collector.querycount }}</span>
  7. {% if collector.querycount > 0 %}
  8. <span class="sf-toolbar-info-piece-additional-detail">in {{ '%0.2f ms'|format(collector.time) }}</span>
  9. {% endif %}
  10. </a>
  11. {% endset %}
  12. {% set text %}
  13. <div class="sf-toolbar-info-piece">
  14. <b>{{ 'DB Queries'|t }}</b>
  15. <span>{{ collector.querycount }}</span>
  16. </div>
  17. <div class="sf-toolbar-info-piece">
  18. <b>{{ 'Query time'|t }}</b>
  19. <span>{{ '%0.2f ms'|format(collector.time) }}</span>
  20. </div>
  21. <div class="sf-toolbar-info-piece">
  22. <b>{{ 'Default database'|t }}</b>
  23. <span>{{ collector.database.driver }}://{{ collector.database.host }}:{{ collector.database.port }}
  24. /{{ collector.database.database }}</span>
  25. </div>
  26. {% endset %}
  27. <div class="sf-toolbar-block">
  28. <div class="sf-toolbar-icon">{{ icon|default('') }}</div>
  29. <div class="sf-toolbar-info">{{ text|default('') }}</div>
  30. </div>
  31. {% endblock %}
  32. {% block panel %}
  33. <script id="database" type="text/template">
  34. <h2 class="panel__title">{{ 'Database'|t }}</h2>
  35. <form class="panel__toolbar">
  36. <div class="panel__filter--text">
  37. <input id="edit-caller" class="js--live-filter" placeholder="{{ 'Caller'|t }}" type="text"/>
  38. <label for="edit-caller" class="panel__filter-label">{{ 'Caller'|t }}</label>
  39. </div>
  40. <div class="panel__filter--select">
  41. <select id="edit-type" class="js--live-filter">
  42. <option value="">{{ 'Any'|t }}</option>
  43. <option value="select">Select</option>
  44. <option value="insert">Insert</option>
  45. <option value="update">Update</option>
  46. <option value="create">Create</option>
  47. <option value="delete">Delete</option>
  48. </select>
  49. <label for="edit-type" class="panel__filter-label">{{ 'Query type'|t }}</label>
  50. </div>
  51. <div class="panel__filter--select">
  52. <select id="edit-hightlighted" class="js--live-filter">
  53. <option value="">{{ 'Any'|t }}</option>
  54. <option value="1">{{ 'Yes'|t }}</option>
  55. <option value="0">{{ 'No'|t }}</option>
  56. </select>
  57. <label for="edit-type" class="panel__filter-label">{{ 'Slow queries'|t }}</label>
  58. </div>
  59. <div class="panel__filter--select">
  60. <select id="edit-database" class="js--live-filter">
  61. <option value="">{{ 'Any'|t }}</option>
  62. <% _.each(data.connections, function( item ){ %>
  63. <option value="<%- item %>"><%- item %></option>
  64. <% }) %>
  65. </select>
  66. <label for="edit-database" class="panel__filter-label">{{ 'Database'|t }}</label>
  67. </div>
  68. <div class="button--flat l-right js--code-toggle--global js--placeholder-visible">{{ 'Swap Placeholders'|t }}</div>
  69. </form>
  70. <% _.each( data.queries, function( item, key ){ %>
  71. <div class="panel__container<% if (item.time > data.query_highlight_threshold) { %> is--hightlighted <% } %>"
  72. data-wp-caller="<%- item.caller.class != null ? item.caller.class.toLowerCase() : '' %>"
  73. data-wp-database="<%- item.database %>"
  74. data-wp-type="<%- item.type %>"
  75. data-wp-hightlighted="<%- (item.time > data.query_highlight_threshold) ? '1' : '0' %>">
  76. <div class="panel__expand-header ">
  77. <pre <% if( item.query_args) { %> class="js--code-target"<% } %> >
  78. <code class="sql js--placeholder-query">
  79. <%- item.query %>
  80. </code>
  81. <% if( item.query_args) { %>
  82. <code class="sql js--clipboard-target is--hidden js--original-query">
  83. <%- item.query_args %>
  84. </code>
  85. <% } %>
  86. </pre>
  87. <ul class="list--inline">
  88. <li><b>{{ 'Time'|t }}</b>: <%- Drupal.webprofiler.helpers.printTime(item.time) %></li>
  89. <li><b>{{ 'Caller'|t }}</b>: <%= Drupal.webprofiler.helpers.classLink({"file" : item.caller.file,
  90. "class" : item.caller.class, "line" : item.caller.line, "method" : item.caller.function}) %>
  91. </li>
  92. <li><b>{{ 'Database'|t }}</b>: <%- item.database %></li>
  93. <li><b>{{ 'Target'|t }}</b>: <%- item.target %></li>
  94. </ul>
  95. <% if(item.query_args){ %>
  96. <div class="button--flat l-right js--code-toggle">{{ 'Swap Placeholders'|t }}</div>
  97. <% } %>
  98. <% if(item.args){ %>
  99. <div class="button--flat l-right js--panel-toggle">{{ 'Info'|t }}</div>
  100. <% } %>
  101. <!--div class="button--flat l-right js--clipboard-trigger">{{ 'Copy Query'|t }}</div-->
  102. <% if(item.explain){ %>
  103. <div class="button--flat l-right js--explain-trigger"
  104. data-wp-queryPosition="<%- key %>"
  105. >{{ 'Explain'|t }}</div>
  106. <% } %>
  107. </div>
  108. <% if(item.explain){ %>
  109. <div class="loader--linear js--loader" style="display: none">
  110. <div class="loader__bar"></div>
  111. <div class="loader__bar"></div>
  112. <div class="loader__bar"></div>
  113. </div>
  114. <div class="panel__expand-content js--explain-target"></div>
  115. <% } %>
  116. <% if(item.args){ %>
  117. <div class="panel__expand-content">
  118. <div class="wp-query-arguments">
  119. <table class="table--duo">
  120. <thead>
  121. <tr>
  122. <th>{{ 'placeholder'|t }}</th>
  123. <th>{{ 'value'|t }}</th>
  124. </tr>
  125. </thead>
  126. <tbody>
  127. <% _.each( item.args, function( item, key ){ %>
  128. <tr>
  129. <td><%- key %></td>
  130. <td><%= Drupal.webprofiler.helpers.frm(item) %></td>
  131. </tr>
  132. <% }); %>
  133. </tbody>
  134. </table>
  135. </div>
  136. </div>
  137. <% } %>
  138. </div>
  139. <% }); %>
  140. </script>
  141. <script id="wp-query-explain-template" type="text/template">
  142. <table class="table--compact">
  143. <thead>
  144. <tr>
  145. <% _.each(rc.data[1], function(value, key, list) { %>
  146. <th><%= key %></th>
  147. <% }); %>
  148. </tr>
  149. </thead>
  150. <% _.each(rc.data, function(value) { %>
  151. <tr>
  152. <% _.each(value, function(value2, key, list) { %>
  153. <td><%= value2 %></td>
  154. <% }); %>
  155. </tr>
  156. <% }); %>
  157. </table>
  158. </script>
  159. {% endblock %}