Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1408

Přidáno uživatelem Michal Kliment před více než 12 roky(ů)

Upravy:
- dalsi pokracovani praci na #185 - opraveno zobrazeni zarizeni (jeste zbyva doladit)

Zobrazit rozdíly:

freenetis/branches/network/application/helpers/callback.php
*/
public function port_mode_field($item, $name)
{
echo Port_Model::get_port_mode($item->mode);
echo Iface_Model::get_port_mode($item->port_mode);
}
/**
freenetis/branches/network/application/models/iface.php
* @param int $device_id
* @return Mysql_Result object
*/
public function get_all_ifaces_of_device($device_id, $duplicates = FALSE)
public function get_all_ifaces_of_device($device_id, $duplicates = FALSE, $type = NULL)
{
$group_by = '';
......
if (!$duplicates)
$group_by = 'GROUP BY i.id';
$where = '';
if ($type)
$where = 'AND i.type = '.intval($type);
return $this->db->query("
SELECT i.id, i.id AS iface_id, i.segment_id, sg.name AS segment_name,
SELECT i.id, i.id AS iface_id, i.link_id, l.name AS link_name,
i.mac, i.name, i.comment, ip.subnet_id, sb.name as subnet_name,
ip.id AS ip_address_id, ip.ip_address,
32-log2((~INET_ATON(sb.netmask) & 0xffffffff) + 1) AS subnet_range,
i.type
i.type, number, port_mode, bitrate
FROM ifaces i
LEFT JOIN ip_addresses ip ON ip.iface_id = i.id
LEFT JOIN segments sg ON i.segment_id = sg.id
LEFT JOIN links l ON i.link_id = l.id
LEFT JOIN subnets sb ON ip.subnet_id = sb.id
WHERE i.device_id = ?
WHERE i.device_id = ? $where
$group_by
ORDER BY i.name
ORDER BY i.number, i.type, i.name
", array($device_id));
}
/**
* Returns all VLAN ifaces of device
*
* @author Michal Kliment
* @param type $device_id
* @return type
*/
public function get_all_vlan_ifaces_of_device($device_id)
{
return $this->db->query("
SELECT
vi.id, vi.name, i.id AS iface_id, i.name AS iface_name,
v.id AS vlan_id, v.name AS vlan_name, tag_802_1q
FROM ifaces vi
JOIN ifaces_relationships ir ON ir.iface_id = vi.id
JOIN ifaces i ON ir.parent_iface_id = i.id
JOIN ifaces_vlans iv ON iv.iface_id = vi.id
JOIN vlans v ON iv.vlan_id = v.id
WHERE vi.device_id = ? AND vi.type = ?
ORDER BY tag_802_1q
", array($device_id, Iface_Model::TYPE_VLAN));
}
/**
* Returns all ifaces of device with IP address as gateway
freenetis/branches/network/application/models/ip_address.php
s.name AS subnet_name,
32-log2((~inet_aton(netmask) & 0xffffffff) + 1) AS subnet_range,
s.network_address AS subnet_network,
i1.name AS iface_name,
vi.id AS vlan_iface_id,
vi.name AS vlan_iface_name
i.name AS iface_name
FROM ip_addresses ip
LEFT JOIN subnets s ON s.id = ip.subnet_id
LEFT JOIN ifaces i1 ON i1.id = ip.iface_id
LEFT JOIN vlan_ifaces vi ON vi.id = ip.vlan_iface_id
LEFT JOIN ifaces i2 ON i2.id = vi.iface_id
WHERE IFNULL(i1.device_id, i2.device_id) = ?
JOIN ifaces i ON i.id = ip.iface_id
WHERE i.device_id = ?
ORDER BY INET_ATON(ip_address)
", $device_id);
}
freenetis/branches/network/application/controllers/devices.php
$grid_ifaces->field('name')
->label(__('name'));
$grid_ifaces->field('mac')
->label(__('MAC'));
/*$grid_ifaces->field('mac')
->label(__('MAC'));*/
$grid_ifaces->link_field('segment_id')
->link('segments/show', 'segment_name')
->label('Segment');
/*$grid_ifaces->link_field('link_id')
->link('links/show', 'link_name')
->label('Link');*/
$actions = $grid_ifaces->grouped_action_field();
......
$grid_ifaces->datasource($ifaces);
// vlans
$vlan_iface_model = new Vlan_iface_Model();
$vlan_ifaces = $vlan_iface_model->get_all_vlan_ifaces_by_device_id($device->id);
$vlan_ifaces = $iface_model->get_all_vlan_ifaces_of_device($device->id);
$grid_vlan_ifaces = new Grid(url_lang::base().'devices', null, array
(
......
);
}
$grid_vlan_ifaces->field('vlan_iface_name')
$grid_vlan_ifaces->field('name')
->label(__('Name'));
$grid_vlan_ifaces->link_field('vlan_id')
->link('vlans/show', 'vlan_name')
$grid_vlan_ifaces->link_field('id')
->link('ifaces/show', 'name')
->label('VLAN name');
$grid_vlan_ifaces->field('tag_802_1q')
->label(__('tag_802_1q'))
->class('center');
$grid_vlan_ifaces->field('iface_name')
$grid_vlan_ifaces->link_field('iface_id')
->link('ifaces/show', 'iface_name')
->label(__('Interface'));
$actions = $grid_vlan_ifaces->grouped_action_field();
if ($this->acl_check_view(get_class($this),'vlan_iface',$member_id))
{
$actions->add_action('vlan_iface_id')
$actions->add_action('id')
->icon_action('show')
->url('vlan_ifaces/show')
->url('ifaces/show')
->class('popup_link');
}
if ($this->acl_check_edit(get_class($this),'vlan_iface',$member_id))
{
$actions->add_action('vlan_iface_id')
$actions->add_action('id')
->icon_action('edit')
->url('vlan_ifaces/edit');
->url('ifaces/edit');
}
if ($this->acl_check_delete(get_class($this),'vlan_iface',$member_id))
{
$actions->add_action('vlan_iface_id')
$actions->add_action('id')
->icon_action('delete')
->url('vlan_ifaces/delete')
->url('ifaces/delete')
->class('delete_link');
}
......
$grid_ips->datasource($ips);
// ports of device
$port_model = new Port_Model();
$ports = $port_model->get_ports_of_device($device_id);
$ports = $iface_model->get_all_ifaces_of_device($device->id, FALSE, Iface_Model::TYPE_PORT);
$grid_ports = new Grid('devices', null, array
(
......
);
}
$grid_ports->field('port_nr')
->label('Port number')
$grid_ports->field('number')
->label('Number')
->class('center');
$grid_ports->field('name')
......
->callback('callback::bitrate_field', FALSE)
->class('center');
$grid_ports->link_field('segment_id')
->link('segments/show', 'segment_name')
->label('Segment');
$grid_ports->link_field('link_id')
->link('links/show', 'link_name')
->label('Link');
$grid_ports->field('vlan_count')
/*$grid_ports->field('vlan_count')
->label('Vlans')
->class('center');
->class('center');*/
$actions = $grid_ports->grouped_action_field();
......
$view->content->ip_iface = $ip_iface;
$view->content->table_device_engineers = $grid_device_engineers;
$view->content->table_device_admins = $grid_device_admins;
$view->content->table_ifaces = $grid_ifaces;
$view->content->table_vlan_ifaces = $grid_vlan_ifaces;
$view->content->table_ports = $grid_ports;
$view->content->ifaces = $grid_ifaces;
$view->content->vlan_ifaces = $grid_vlan_ifaces;
$view->content->port_ifaces = (count($ports)) ? $grid_ports : '';
$view->content->table_ip_addresses = $grid_ips;
$view->content->table_wireless_ifaces = ''; ////// FIX ME !!!!!!!!!!!!!
$view->content->wireless_ifaces = ''; ////// FIX ME !!!!!!!!!!!!!
$view->content->ethernet_ifaces = '';
$view->content->bridge_ifaces = '';
$view->content->gps = $gps;
$view->content->gpsx = !empty($gps) ? $gps_result->gpsx : '';
$view->content->gpsy = !empty($gps) ? $gps_result->gpsy : '';
freenetis/branches/network/application/views/devices/show.php
<div id="tabs">
<ul class="tabs" style="font-size: 12px;">
<li class="ui-corner-all"><?php echo html::anchor('devices/show/'.$device->id.'#interfaces', __('Interfaces')) ?></li>
<li class="ui-corner-all"><?php echo html::anchor('devices/show/'.$device->id.'#wireless_interfaces', __('Wireless interfaces')) ?></li>
<!-- <li class="ui-corner-all"><?php //echo html::anchor('devices/show/'.$device->id.'#ethernet_interfaces', __('Ethernet interfaces')) ?></li> -->
<!-- <li class="ui-corner-all"><?php //echo html::anchor('devices/show/'.$device->id.'#vlan_interfaces', __('Vlan interfaces')) ?></li> -->
<!-- <li class="ui-corner-all"><?php //echo html::anchor('devices/show/'.$device->id.'#bridges', __('Bridges')) ?></li> -->
<li class="ui-corner-all"><a href="#interfaces"><?php echo __('Interfaces') ?></a></li>
<?php if ($wireless_ifaces != ''): ?>
<li class="ui-corner-all"><a href="#wireless_interfaces"><?php echo __('Wireless interfaces') ?></a></li>
<?php endif ?>
<?php if ($ethernet_ifaces != ''): ?>
<li class="ui-corner-all"><a href="#ethernet_interfaces"><?php echo __('Ethernet interfaces') ?></a></li>
<?php endif ?>
<?php if ($vlan_ifaces != ''): ?>
<li class="ui-corner-all"><a href="#vlan_interfaces"><?php echo __('Vlan interfaces') ?></a></li>
<?php endif ?>
<?php if ($bridge_ifaces != ''): ?>
<li class="ui-corner-all"><a href="#bridges"><?php echo __('Bridges') ?></a></li>
<?php endif ?>
<?php if ($port_ifaces != ''): ?>
<li class="ui-corner-all"><a href="#ports"><?php echo __('Ports') ?></a></li>
<?php endif ?>
</ul>
<!-- interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<div id="interfaces">
<?php echo $table_ifaces ?>
<?php echo $ifaces ?>
</div>
<?php } ?>
<!-- wireless interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<div id="wireless_interfaces">
<?php echo $table_wireless_ifaces ?>
<?php echo $wireless_ifaces ?>
</div>
<?php } ?>
<!-- ethernet interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<div id="ethernet_interfaces">
</div>
<?php } ?>
<!-- vlan interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<div id="vlan_interfaces">
<?php echo $vlan_ifaces ?>
</div>
<?php } ?>
<!-- bridge interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<div id="bridge_interfaces">
</div>
<?php } ?>
<!-- ports -->
<?php if ($this->acl_check_view(get_class($this),'port',$device->user->member_id)) { ?>
<div id="ports">
<?php echo $port_ifaces ?>
</div>
<?php } ?>
</div>
<br />
<!-- vlan interfaces -->
<?php if ($this->acl_check_view(get_class($this),'vlan_iface',$device->user->member_id)) { ?>
<h3><a id="device_vlan_ifaces_link" name="vlan_interfaces"><?php echo __('VLAN interfaces') ?>
<img src="<?php echo url::base() ?>media/images/icons/ico_<?php echo ($count_vlan_ifaces == 0) ? 'add' : 'minus' ?>.gif" id="device_vlan_ifaces_button"></a></h3>
<div id="device_vlan_ifaces" class="<?php echo ($count_vlan_ifaces == 0) ? 'dispNone' : '' ?>">
<?php echo $table_vlan_ifaces ?><br />
</div><br />
<?php } ?>
<!-- ip addresses -->
<?php if ($this->acl_check_view(get_class($this),'ip_address',$device->user->member_id)) { ?>
<h3><a id="device_ip_addresses_link" name="ip_addresses"><?php echo __('IP addresses') ?>
......
</div><br />
<?php } ?>
<!-- ports -->
<?php if ($this->acl_check_view(get_class($this),'port',$device->user->member_id)) { ?>
<h3><a id="device_ports_link" name="ports"><?php echo __('Ports') ?>
<img src="<?php echo url::base() ?>media/images/icons/ico_<?php echo ($count_ports == 0) ? 'add' : 'minus' ?>.gif" id="device_ports_button"></a></h3>
<div id="device_ports" class="<?php echo ($count_ports == 0) ? 'dispNone' : '' ?>">
<?php echo $table_ports ?><br />
</div><br />
<?php } ?>
<br class="clear" />
<br />

Také k dispozici: Unified diff