Skip to content

Commit

Permalink
api & ui: show iface label in WAN rules
Browse files Browse the repository at this point in the history
  • Loading branch information
andre8244 committed Jun 3, 2020
1 parent 4226b21 commit 54358cf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
13 changes: 11 additions & 2 deletions api/wan/read
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if($cmd eq 'providers') {
"provider" => $p,
'FwInBandwidth' => $_->prop('FwInBandwidth') || 0,
'FwOutBandwidth' => $_->prop('FwOutBandwidth') || 0,
'nslabel' => $_->prop('nslabel') || '',
'nslabel' => $_->prop('type') eq 'xdsl' ? 'PPPoE' : ($_->prop('nslabel') || ''),
'cidr' => $addr->{'cidr'},
'ipaddr' => $addr->{'ipaddr'},
'gateway' => $addr->{'gateway'}
Expand Down Expand Up @@ -128,8 +128,17 @@ if($cmd eq 'providers') {
print encode_json($ret);

} elsif ($cmd eq 'rules') {
my $tc_rules = list_tc_rules($input->{'expand'} || 0, 'provider');
my $ndb = esmith::NetworksDB->open_ro();
my $rules = $tc_rules->{'rules'};

print encode_json(list_tc_rules($input->{'expand'} || 0, 'provider'));
foreach (@$rules) {
my ($provider, $red) = split(";", $_->{'Action'});
my $interface = $ndb->get_prop($red, 'interface');
my $nslabel = $ndb->get_prop($interface, 'type') eq 'xdsl' ? 'PPPoE' : $ndb->get_prop($interface, 'nslabel');
$_->{'Label'} = $nslabel;
}
print encode_json($tc_rules);

} else {
error()
Expand Down
24 changes: 20 additions & 4 deletions ui/src/views/WAN.vue
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,9 @@
v-for="(r,k) in rules"
v-bind:key="k"
>
<div class="drag-size">
<span class="gray mg-right-5">{{r.Action.split(';')[1] | uppercase}}</span>
<div class="drag-size width-fixed">
<span v-if="r.Label" class="gray mg-right-5">{{ r.Label }}</span>
<span v-else class="gray mg-right-5">{{ r.Action.split(';')[1] | uppercase }}</span>
</div>
<div class="list-view-pf-checkbox drag-here">
<span class="fa fa-bars"></span>
Expand Down Expand Up @@ -412,7 +413,7 @@
</div>
<div class="list-view-pf-body">
<div class="list-view-pf-description rules-src-dst">
<div class="list-group-item-heading">
<div class="list-group-item-heading narrow">
<span
data-toggle="tooltip"
data-placement="top"
Expand All @@ -436,7 +437,7 @@
</span>
</span>
</div>
<div class="list-group-item-text">
<div class="list-group-item-text narrow">
<span :class="[mapArrow(r.Action), 'mg-right-10 big-icon']"></span>
<span
data-toggle="tooltip"
Expand Down Expand Up @@ -2760,4 +2761,19 @@ export default {
.small-font {
font-size: 12px;
}
.drag-size.width-fixed {
width: 5%;
overflow: hidden;
text-overflow: ellipsis;
padding-right: 3px;
}
.list-group-item-heading.narrow {
width: calc(40% - 20px) !important;
}
.list-group-item-text.narrow {
width: calc(40% - 20px) !important;
}
</style>

0 comments on commit 54358cf

Please sign in to comment.