Revert "deduping type_where code, adding manual types to graph widgets "

This commit is contained in:
Neil Lathwood
2016-06-07 09:15:04 +01:00
parent db6ccf1404
commit 5cb9d751c3
5 changed files with 59 additions and 76 deletions

View File

@@ -74,7 +74,6 @@ if( defined('show_settings') || empty($widget_settings) ) {
<option value="peering"'.($widget_settings['graph_type'] == 'peering' ? ' selected' : '').'>&nbsp;&nbsp;&nbsp;Peering</option>
<option value="core"'.($widget_settings['graph_type'] == 'core' ? ' selected' : '').'>&nbsp;&nbsp;&nbsp;Core</option>
<option value="custom"'.($widget_settings['graph_type'] == 'custom' ? ' selected' : '').'>&nbsp;&nbsp;&nbsp;Custom Descr</option>
<option value="manual"'.($widget_settings['graph_type'] == 'manual' ? ' selected' : '').'>&nbsp;&nbsp;&nbsp;Manual Descr</option>
<option disabled></option>
<option value="bill_bits"'.($widget_settings['graph_type'] == 'bill_bits' ? ' selected' : '').'>Bill</option>
</select>
@@ -151,14 +150,6 @@ if( defined('show_settings') || empty($widget_settings) ) {
$common_output[] = ' </select>
</div>
</div>
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_manual">
<div class="col-sm-2">
<label for="graph_manual" class="control-label">Manual Port-Desc: </label>
</div>
<div class="col-sm-10">
<input type="text" class="form-control input_'.$unique_id.'_manual" name="graph_manual" placeholder="Descr String" value="'.htmlspecialchars($widget_settings['graph_manual']).'">';
$common_output[] = ' </div>
</div>
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_bill">
<div class="col-sm-2">
<label for="graph_bill" class="control-label">Bill: </label>
@@ -402,20 +393,39 @@ else {
elseif ($type == 'munin') {
$param = 'device='.$widget_settings['graph_'.$type]['device_id'].'&plugin='.$widget_settings['graph_'.$type]['name'];
}
elseif ($type == 'transit' || $type == 'peering' || $type == 'core' || $type == 'custom' || $type == 'manual') {
if ( $type == 'custom' || $type == 'manual') {
$type = $widget_settings['graph_'.$type];
$type = explode(',', $type);
elseif ($type == 'transit' || $type == 'peering' || $type == 'core') {
$type_where = ' (';
if (is_array($config[$type.'_descr']) === false) {
$config[$type.'_descr'] = array($config[$type.'_descr']);
}
$ports = get_ports_from_type($type);
foreach ($ports as $port) {
foreach ($config[$type.'_descr'] as $additional_type) {
if (!empty($additional_type)) {
$type_where .= " $or `port_descr_type` = ?";
$or = 'OR';
$type_param[] = $additional_type;
}
}
$type_where .= " $or `port_descr_type` = ?";
$or = 'OR';
$type_param[] = $type;
$type_where .= ') ';
foreach (dbFetchRows("SELECT port_id FROM `ports` WHERE $type_where ORDER BY ifAlias", $type_param) as $port) {
$tmp[] = $port['port_id'];
}
$param = 'id='.implode(',',$tmp);
$widget_settings['graph_type'] = 'multiport_bits_separate';
if (empty($widget_settings['title'])) {
$widget_settings['title'] = 'Overall '.ucfirst(htmlspecialchars($type)).' Bits ('.$widget_settings['graph_range'].')';
$widget_settings['title'] = 'Overall '.ucfirst($type).' Bits ('.$widget_settings['graph_range'].')';
}
}
elseif ($type == 'custom') {
foreach (dbFetchRows("SELECT port_id FROM `ports` WHERE `port_descr_type` = ? ORDER BY ifAlias", array($widget_settings['graph_custom'])) as $port) {
$tmp[] = $port['port_id'];
}
$param = 'id='.implode(',',$tmp);
$widget_settings['graph_type'] = 'multiport_bits_separate';
if (empty($widget_settings['title'])) {
$widget_settings['title'] = 'Overall '.ucfirst(htmlspecialchars($widget_settings['graph_custom'])).' Bits ('.$widget_settings['graph_range'].')';
}
}
else {