Skip to content
This repository was archived by the owner on Apr 20, 2020. It is now read-only.

Commit ec12627

Browse files
author
mrcrankhank
committed
Fix iet overview table
1 parent 9671bcd commit ec12627

File tree

4 files changed

+51
-38
lines changed

4 files changed

+51
-38
lines changed

app/controllers/Overview.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public function iet($param) {
4646
if ($view['data'] !== false) {
4747
if ($param == 'session') {
4848
$view['type'] = 'session';
49-
$this->view('targets/iettable', $view);
49+
$this->view('ietOverviewTable', $view);
5050
} else if ($param == 'volume') {
5151
$view['type'] = 'volume';
52-
$this->view('targets/iettable', $view);
52+
$this->view('ietOverviewTable', $view);
5353
} else {
5454
$this->view('message', array('message' => 'Invalid url', 'type' => 'warning'));
5555
}

app/views/targets/iettable.php renamed to app/views/ietOverviewTable.php

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<table class="table">
1111
<thead>
1212
<tr>
13-
<th class="col-md-1"><?php if ($data['type'] == 'volume') echo 'Lun'; else if ($data['type'] == 'session') echo 'Session' ?></th>
13+
<th class="col-md-1">Expand</th>
1414
<th class="col-md-2">tid</th>
1515
<th class="col-md-2">iqn</th>
1616
<th class="col-md-1"></th>
@@ -20,15 +20,10 @@
2020
</tr>
2121
</thead>
2222
<tbody>
23-
<?php foreach (array_reverse($data['data']) as $key => $row) { ?>
24-
<tr class="clickable active" data-toggle="collapse" id="row<?php echo htmlspecialchars($key) ?>"
25-
data-target=".row<?php echo htmlspecialchars($key) ?>">
26-
<?php if ($data['type'] == 'volume') { ?>
27-
<td class="col-md-1"><?php if (isset($row['lun'])) echo '<a href="#" class="expandrow"><span class="glyphicon glyphicon-15 glyphicon-plus"></span></a>' ?></td>
28-
<?php } else if ($data['type'] == 'session') { ?>
29-
<td class="col-md-1"><?php if (isset($row['session'])) echo '<a href="#" class="expandrow"><span class="glyphicon glyphicon-15 glyphicon-plus"></span></a>' ?></td>
30-
<?php } ?>
31-
<td class="col-md-2"><?php echo $row['tid'] ?></td>
23+
<?php foreach ($data['data'] as $key => $row) { ?>
24+
<tr class="clickable active" data-toggle="collapse" id="row<?php echo htmlspecialchars($key) ?>" data-target=".row<?php echo htmlspecialchars($key) ?>">
25+
<td class="col-md-1"><?php if (($data['type'] === 'volume' && isset($row['lun'])) || ($data['type'] === 'session' && isset($row['session']))) echo '<button class="btn btn-primary btn-xs expandRow"><span class="glyphicon glyphicon-15 glyphicon-plus"></span> <span>Show</span></button>' ?></td>
26+
<td class="col-md-2"><?php echo htmlspecialchars($row['tid']) ?></td>
3227
<td class="col-md-2"><a target='_blank' href='/phpietadmin/targets/configure/<?php echo htmlspecialchars($row['iqn']) ?>'><?php echo htmlspecialchars($row['iqn']) ?></a></td>
3328
<td class="col-md-1"></td>
3429
<td class="col-md-1"></td>
@@ -46,15 +41,15 @@
4641
<th class="col-md-1">Blocksize</th>
4742
<th class="col-md-4">Path</th>
4843
</tr>
49-
<?php foreach (array_reverse($row['lun']) as $lun) { ?>
44+
<?php foreach ($row['lun'] as $lun) { ?>
5045
<tr class="collapse row<?php echo htmlspecialchars($key) ?>">
51-
<td class="col-md-1"><?php echo $lun['id'] ?></td>
52-
<td class="col-md-1"><?php echo $lun['state'] ?></td>
53-
<td class="col-md-1"><?php echo $lun['iotype'] ?></td>
54-
<td class="col-md-2"><?php echo $lun['iomode'] ?></td>
55-
<td class="col-md-1"><?php echo $lun['blocks'] ?></td>
56-
<td class="col-md-1"><?php echo $lun['blocksize'] ?></td>
57-
<td class="col-md-4"><?php echo $lun['path'] ?></td>
46+
<td class="col-md-1"><?php echo htmlspecialchars($lun['id']) ?></td>
47+
<td class="col-md-1"><?php echo htmlspecialchars($lun['state']) ?></td>
48+
<td class="col-md-1"><?php echo htmlspecialchars($lun['iotype']) ?></td>
49+
<td class="col-md-2"><?php echo htmlspecialchars($lun['iomode']) ?></td>
50+
<td class="col-md-1"><?php echo htmlspecialchars($lun['blocks']) ?></td>
51+
<td class="col-md-1"><?php echo htmlspecialchars($lun['blocksize']) ?></td>
52+
<td class="col-md-4"><?php echo htmlspecialchars($lun['path']) ?></td>
5853
</tr>
5954
<?php } ?>
6055
<?php } ?>
@@ -69,7 +64,7 @@
6964
<th class="col-md-1">HD</th>
7065
<th class="col-md-1">DD</th>
7166
</tr>
72-
<?php foreach (array_reverse($row['session']) as $session) { ?>
67+
<?php foreach ($row['session'] as $session) { ?>
7368
<tr class="collapse row<?php echo htmlspecialchars($key) ?>">
7469
<td class="col-md-1"><?php echo htmlspecialchars($session['sid']) ?></td>
7570
<td class="col-md-2"><?php echo htmlspecialchars($session['cid']) ?></td>
@@ -91,9 +86,9 @@
9186
</div>
9287
<script>
9388
require(['common'], function () {
94-
require(['pages/iettable', 'domReady'], function (methods, domReady) {
89+
require(['pages/ietOverviewTable', 'domReady'], function (methods, domReady) {
9590
domReady(function () {
96-
methods.change_expand_row_button();
91+
methods.expandRow();
9792
});
9893
});
9994
});

public/js/pages/ietOverviewTable.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
define(['jquery'], function($) {
2+
return {
3+
expandRow: function() {
4+
var $workspace = $('.workspace');
5+
6+
$workspace.once('hidden.bs.collapse', function (e) {
7+
var $row = $(e.target),
8+
$button = $row.prev('tr').find('.expandRow'),
9+
$span = $button.children('span'),
10+
$icon = $span.first(),
11+
$text = $span.last();
12+
13+
if ($icon.hasClass('glyphicon-minus')) {
14+
$icon.removeClass('glyphicon-minus').addClass('glyphicon-plus');
15+
$text.html('Show')
16+
}
17+
});
18+
19+
$workspace.once('show.bs.collapse', function (e) {
20+
var $row = $(e.target),
21+
$button = $row.prev('tr').find('.expandRow'),
22+
$span = $button.children('span'),
23+
$icon = $span.first(),
24+
$text = $span.last();
25+
26+
if ($icon.hasClass('glyphicon-plus')) {
27+
$icon.removeClass('glyphicon-plus').addClass('glyphicon-minus');
28+
$text.html('Hide')
29+
}
30+
});
31+
}
32+
}
33+
});

public/js/pages/iettable.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)