HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
db.php
Go to the documentation of this file.
1 <?php
2 /* @var Yii2DbPanel $this */
3 /* @var array $queries */
4 /* @var int $queriesCount */
5 /* @var array $resume */
6 /* @var int $resumeCount */
7 /* @var array $connections */
8 /* @var int $connectionsCount */
9 ?>
10 <ul class="nav nav-tabs">
11  <li class="active">
12  <a href="#queries" data-toggle="tab">
13  Queries
14  <span class="badge badge-info"><?php echo $queriesCount; ?></span>
15  </a>
16  </li>
17  <li>
18  <a href="#resume" data-toggle="tab">
19  Resume
20  <?php if ($queriesCount > $resumeCount): ?>
21  <span class="badge badge-warning" title="Repeated queries: <?php echo $queriesCount - $resumeCount; ?>">
22  <?php echo $resumeCount; ?>
23  </span>
24  <?php else: ?>
25  <span class="badge badge-info">
26  <?php echo $resumeCount; ?>
27  </span>
28  <?php endif; ?>
29  </a>
30  </li>
31  <li>
32  <a href="#connections" data-toggle="tab">
33  Connections
34  <span class="badge badge-info"><?php echo $connectionsCount; ?></span>
35  </a>
36  </li>
37 </ul>
38 <div class="tab-content">
39  <div id="queries" class="tab-pane active">
40  <table class="table table-condensed table-bordered table-filtered" style="table-layout:fixed">
41  <thead>
42  <tr>
43  <th style="width:100px">Time</th>
44  <th style="width:80px">Duration</th>
45  <th>Query</th>
46  </tr>
47  </thead>
48  <tbody>
49  <?php foreach ($queries as $num => $query): ?>
50  <tr>
51  <td style="width:100px"><?php echo $query['time']; ?></td>
52  <td style="width:80px"><?php echo $query['duration']; ?></td>
53  <td>
54  <?php echo $this->highlightCode ? $this->highlightSql($query['procedure']) : CHtml::encode($query['procedure']); ?>
55  <?php if ($this->canExplain && count($explainConnections = $this->getExplainConnections($query['procedure'])) > 0): ?>
56  <div class="pull-right">
57  <?php if (count($explainConnections) > 1): ?>
58  <div class="btn-group">
59  <button class="btn btn-link btn-small" data-toggle="dropdown">
60  Explain <span class="caret"></span>
61  </button>
62  <ul class="dropdown-menu pull-right">
63  <?php foreach ($explainConnections as $name => $info): ?>
64  <li>
65  <?php echo CHtml::link("$name - $info[driver]", array(
66  'explain',
67  'tag' => $this->tag,
68  'num' => $num,
69  'connection' => $name,
70  ), array('class' => 'explain')); ?>
71  </li>
72  <?php endforeach; ?>
73  </ul>
74  </div>
75  <?php else: ?>
76  <?php foreach ($explainConnections as $name => $info): ?>
77  <?php echo CHtml::link('Explain', array(
78  'explain',
79  'tag' => $this->tag,
80  'num' => $num,
81  'connection' => $name,
82  ), array('class' => 'explain btn btn-link btn-small')); ?>
83  <?php endforeach; ?>
84  <?php endif; ?>
85  </div>
86  <?php endif; ?>
87  </td>
88  </tr>
89  <?php endforeach; ?>
90  </tbody>
91  </table>
92  </div><!-- queries -->
93  <div id="resume" class="tab-pane">
94  <table class="table table-condensed table-bordered table-striped table-hover table-filtered" style="table-layout:fixed">
95  <thead>
96  <tr>
97  <th style="width:30px;">#</th>
98  <th>Query</th>
99  <th style="width:50px;">Count</th>
100  <th style="width:70px;">Total</th>
101  <th style="width:70px;">Avg</th>
102  <th style="width:70px;">Min</th>
103  <th style="width:70px;">Max</th>
104  </tr>
105  </thead>
106  <tbody>
107  <?php foreach ($resume as $num => $query): ?>
108  <tr>
109  <td style="width:30px;"><?php echo $num + 1; ?></td>
110  <td>
111  <?php echo $this->highlightCode ? $this->highlightSql($query['procedure']) : CHtml::encode($query['procedure']); ?>
112  </td>
113  <td style="width:50px;"><?php echo $query['count']; ?></td>
114  <td style="width:70px;"><?php echo $query['total']; ?></td>
115  <td style="width:70px;"><?php echo $query['avg']; ?></td>
116  <td style="width:70px;"><?php echo $query['min']; ?></td>
117  <td style="width:70px;"><?php echo $query['max']; ?></td>
118  </tr>
119  <?php endforeach; ?>
120  </tbody>
121  </table>
122  </div><!-- resume -->
123  <div id="connections" class="tab-pane">
124  <?php
125  foreach ($connections as $id => $info) {
126  $caption = 'Component: ';
127  if ($this->owner->showConfig) {
128  $caption .= CHtml::link($id, array('config', '#' => 'components-' . $id));
129  } else {
130  $caption .= $id;
131  }
132  $caption .= ' (' . $info['class'] . ')';
133  unset($info['class']);
134  echo $this->render(dirname(__FILE__) . '/_detail.php', array(
135  'caption' => $caption,
136  'values' => $info,
137  ));
138  }
139  ?>
140  </div><!-- connections -->
141 </div>
142 <?php
143 Yii::app()->getClientScript()->registerScript(__CLASS__ . '#explain', <<<JS
144 $('a.explain').click(function(e){
145  if (e.altKey || e.ctrlKey || e.shiftKey) return;
146  e.preventDefault();
147  var block = $(this).data('explain-block');
148  if (!block) {
149  block = $('<tr>').insertAfter($(this).parents('tr').get(0));
150  var div = $('<div class="explain">').appendTo($('<td colspan="3">').appendTo(block));
151  div.text('Loading...');
152  div.load($(this).attr('href'), function(response, status, xhr){
153  if (status == "error") {
154  div.text(xhr.status + ': ' + xhr.statusText);
155  block.addClass('error');
156  }
157  });
158  $(this).data('explain-block', block);
159  } else {
160  block.toggle();
161  }
162 });
163 JS
164 );
165 ?>