Skip to content

Commit

Permalink
improvement: allow to filter by major technology of existing node
Browse files Browse the repository at this point in the history
  • Loading branch information
interduo committed Aug 14, 2023
1 parent 58e1898 commit 30e53ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/netranges.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,13 @@ function getBuildings(array $filter)
) : '')
);
}
$majortechs = isset($filter['majortechs']) && is_array($filter['majortechs']) ?
Utils::filterIntegers(array_values($filter['majortechs'])) : array();

if (empty($buildings)) {
$buildings = array();
} else {
foreach ($buildings as &$building) {
foreach ($buildings as $key => &$building) {
$city_id = intval($building['city_id']);
$street_id = intval($building['street_id']);
$street_ident = intval($building['street_ident']);
Expand All @@ -457,6 +460,12 @@ function getBuildings(array $filter)
$building['customers'] = array();
$building['existing'] = 0;
}
if (!empty($majortechs)
&& isset($nodes[$city_id][$street_ident][$building_num])
&& !array_intersect($majortechs,
array_keys($nodes[$city_id][$street_ident][$building_num]['linktechnologies']))) {
unset($buildings[$key]);
}
}
unset($building);
if (!empty($existing)) {
Expand Down Expand Up @@ -828,6 +837,7 @@ function getBuildings(array $filter)
$SMARTY->assign(array(
'filter' => $filter,
'linktechnologies' => $SIDUSIS_LINKTECHNOLOGIES,
'linktechnologiesall' => $LINKTECHNOLOGIES,
'linkspeeds' => $linkspeeds,
'range'=> $range,
'unique_total' => $unique_total,
Expand Down
13 changes: 13 additions & 0 deletions templates/default/net/netranges.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,19 @@ <h1>{$layout.pagetitle}</h1>
<option value="2"{if $filter.type == 2} selected{/if}>{trans("<!netrange>theoretical")}</option>
</select>
</label>
<label class="filter-item">
{trans("<!netrange>Major technology")}
<select name="filter[majortechs][]" form="netranges" class="filter-element lms-ui-multiselect"
multiple data-default-value='{trans("— ignore —")}'>
{foreach $linktechnologiesall as $key => $type}
<option disabled>{$_LINKTYPES[$key]}</option>
{foreach $type as $key => $link}
<option value="{$key}" {if is_array($filter.majortechs)
&& in_array($key, $filter.majortechs)} selected{/if}>{$link}</option>
{/foreach}
{/foreach}
</select>
</label>
<span class="filter-item">
<span>
{trans("<!netrange>Services")}
Expand Down

0 comments on commit 30e53ed

Please sign in to comment.