Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1208

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

Vylepsena drobeckova navigace u VLAN rozhrani a portu. Vylepsen detail segmentu.

Zobrazit rozdíly:

freenetis/branches/testing/application/vendors/unit_tester/unit_testing_config.xml
<input></input>
</values>
</method>
<method name="get_items" autogenerate="on">
<attributes>
<attribute name="segment_id" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
</model>
<model name="sms_message"></model>
<model name="street">
......
<input></input>
</values>
</method>
<method name="select_list" autogenerate="on">
<attributes>
<attribute name="key" default_value="" />
<attribute name="val" default_value="" />
<attribute name="order_val" default_value="TRUE" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
<input>
<param value="" />
<param value="" />
</input>
<input>
<param value="" />
<param value="" />
<param value="TRUE" />
</input>
</values>
</method>
</model>
<model name="vlan_iface">
<method name="count_all_vlan_ifaces" autogenerate="on">
......
</attributes>
<values>
</values>
</method>
<method name="segment_item_field" autogenerate="off">
<attributes>
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
</values>
</method>
<method name="segment_item_type_field" autogenerate="off">
<attributes>
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
</values>
</method></helper>
<helper name="cookie">
<method name="set" autogenerate="on">
freenetis/branches/testing/application/helpers/callback.php
else
echo '<span style="color: red">'.__('No').'</span>';
}
/**
* Callback function to print name of segment's item
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function segment_item_field ($item, $name)
{
switch ($item->type)
{
// interface
case Segment_Model::IFACE:
echo html::anchor(
url_lang::base().'ifaces/show/'.$item->id, $item->name
);
break;
// port
case Segment_Model::PORT:
echo html::anchor(
url_lang::base().'ports/show/'.$item->id, $item->name
);
break;
default:
echo __('Unknown type');
break;
}
}
/**
* Callback function to print type of segment's item
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function segment_item_type_field ($item, $name)
{
switch ($item->type)
{
// interface
case Segment_Model::IFACE:
echo __('Interface');
break;
// port
case Segment_Model::PORT:
echo __('Port');
break;
default:
echo __('Unknown type');
break;
}
}
}
freenetis/branches/testing/application/models/vlan.php
* @author Michal Kliment
* @return array
*/
public function select_list()
public function select_list($key = NULL, $val = NULL, $order_val = TRUE)
{
$arr_vlans = array();
freenetis/branches/testing/application/models/segment.php
self::SINGLE_FIBER => 'single-mode optical fiber',
self::MULTI_FIBER => 'multi-mode optical fiber'
);
const IFACE = 1;
const PORT = 2;
/**
* Counts all segments
......
return $medium_types;
}
/**
* Returns all items (interfaces and ports) which belong to given segment
*
* @author Michal Kliment
* @param integer $segment_id
* @return MySQL iterator
*/
public function get_items ($segment_id = NULL)
{
if (!$segment_id)
$segment_id = $this->id;
return $this->db->query("
SELECT q.*, d.name AS device_name, m.name AS member_name,
m.id AS member_id
FROM
(
SELECT id, device_id, mac, name, ? AS type
FROM ifaces i
WHERE i.segment_id = ?
UNION
SELECT id, device_id, NULL AS mac, name, ? AS type
FROM ports p
WHERE p.segment_id = ?
) AS q
JOIN devices d ON q.device_id = d.id
JOIN users u ON d.user_id = u.id
JOIN members m ON u.member_id = m.id
", self::IFACE, $segment_id, self::PORT, $segment_id);
}
}
freenetis/branches/testing/application/controllers/ports.php
->link('devices/show_by_user/' . $port->device->user->id, 'Devices',
$this->acl_check_view('Devices_Controller', 'devices', $port->device->user->member_id))
->disable_translation()
->link('devices/show/' . $port->device->id . '#device_' . $port->device_id . '_link',
->link('devices/show/' . $port->device->id . '#device_ports_link',
!empty($port->device->name) ? $port->device->name : $device_type,
$this->acl_check_edit('Devices_Controller', 'devices', $port->device->user->member_id))
->enable_translation();
......
Controller::error(ACCESS);
$form = new Forge(
url_lang::base()."ports/add/", '',
url_lang::base()."ports/add/".$device_id, '',
'POST', array('id' => 'article_form')
);
......
$form->dropdown('segment_id')
->label(__('Segment name'))
->options($arr_segments)
->rules('required');
->rules('required')
->add_button('segments');
$form->dropdown('vlan_id[]')
->label(__('Vlan name'))
......
if ($saved)
{
status::success('Port has successfully saved.');
url::redirect(url_lang::base() . 'ports/show/' . $port->id);
exit;
status::success('Port has been successfully saved.');
if ($device_id && $device->id)
url::redirect(url_lang::base() . 'devices/show_port/' . $port->id);
else
url::redirect(url_lang::base() . 'ports/show/' . $port->id);
}
}
......
->link('devices/show_by_user/' . $device->user->id, 'Devices',
$this->acl_check_view('Devices_Controller', 'devices', $device->user->member_id))
->disable_translation()
->link('devices/show/' . $device->id . '#device_' . $device_id . '_link',
->link('devices/show/' . $device->id . '#device_ports_link',
$device->name,
$this->acl_check_edit('Devices_Controller', 'devices', $device->user->member_id))
->enable_translation();
......
if ($saved)
{
status::success('Port has successfully updated.');
url::redirect(url_lang::base() . 'ports/show/' . $port->id);
status::success('Port has been successfully updated.');
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
url::redirect(url_lang::base() . 'devices/show_port/' . $port->id);
else
url::redirect(url_lang::base() . 'ports/show/' . $port->id);
exit;
}
}
......
->link('devices/show_by_user/' . $port->device->user->id, 'Devices',
$this->acl_check_view('Devices_Controller', 'devices', $port->device->user->member_id))
->disable_translation()
->link('devices/show/' . $port->device->id . '#device_' . $port->device_id . '_link',
->link('devices/show/' . $port->device->id . '#device_ports_link',
$port->device->name,
$this->acl_check_edit('Devices_Controller', 'devices', $port->device->user->member_id))
->link('ports/show/' . $port->id, $port->name,
freenetis/branches/testing/application/controllers/vlan_ifaces.php
else
$name = $iface->mac;
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
if (Path::instance()->previous()->uri()->current(0,1) != 'devices')
{
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link(
'ifaces/show_all',
'Interfaces',
......
)
)
->text('Add new VLAN interface to interface');
}
else
{
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link(
'members/show_all',
'Members',
$this->acl_check_view('Members_Controller','members')
)
->link(
'members/show/'.$iface->device->user->member_id,
'ID '.$iface->device->user->member->id.
' - '.$iface->device->user->member->name,
$this->acl_check_view(
'Members_Controller',
'members',
$iface->device->user->member_id
)
)
->link(
'users/show_by_member/'.$iface->device->user->member_id,
"Users",
$this->acl_check_view(
'Users_Controller',
'users',$iface->device->user->member_id
)
)
->link(
'users/show/'.$iface->device->user_id,
$iface->device->user->name.' '.$iface->device->user->surname.
' ('.$iface->device->user->login.')',
$this->acl_check_view(
'Users_Controller',
'users',
$iface->device->user->member_id
)
)
->link(
'devices/show_by_user/'.$iface->device->user_id,
'Devices',
$this->acl_check_view(
'Devices_Controller',
'devices',
$iface->device->user->member_id
)
)
->link(
'devices/show/'.$iface->device_id . '#vlan_interfaces',
$iface->device->name,
$this->acl_check_view(
'Devices_Controller',
'devices',
$iface->device->user->member_id
)
)
->link(
'devices/show_iface/'.$iface->id,
$name,
$this->acl_check_view(
'Devices_Controller',
'iface',
$iface->device->user->member->id
)
)
->text('Add new VLAN interface to interface');
}
}
else if ($device_id)
{
......
if ($vlan_iface->save())
{
status::success('VLAN interface has been successfully saved.');
url::redirect(
url_lang::base() . 'vlan_ifaces/show/' . $vlan_iface->id
);
if (Path::instance()->previous()->uri()->current(0,1) == 'devices')
url::redirect(url_lang::base().'devices/show_vlan_iface/'.$vlan_iface->id);
else
url::redirect(url_lang::base().'vlan_ifaces/show/'.$vlan_iface->id);
exit;
}
}
freenetis/branches/testing/application/controllers/segments.php
// segment media
$medium = Segment_Model::get_medium_type($segment->medium_id);
// interfaces of segment
$iface_model = new Iface_Model();
$ifaces = $iface_model->get_ifaces_of_segment($segment_id);
$grid = new Grid(
url_lang::base().'subnets/show/'.$segment_id,
__('Interfaces'), array
__('Interfaces').' / '.__('Ports'), array
(
'use_paginator' => false,
'use_selector' => false
......
$grid->field('id')
->label(__('ID'));
$grid->callback_field('name')
->label(__('Name'))
->callback('callback::segment_item_field');
$grid->callback_field('type')
->label(__('Type'))
->callback('callback::segment_item_type_field');
$grid->field('mac')
->label(__('MAC'));
$grid->callback_field('device_id')
->label(__('Device name'))
->callback('callback::device_field');
$grid->field('mac')
->label(__('MAC'));
$grid->callback_field('member_id')
->label(__('member'))
->callback('callback::member_field');
$grid->grouped_action_field()
->add_action()
->icon_action('interface')
->url('ifaces/show')
->label('Show interface');
$grid->datasource($ifaces);
$grid->datasource($segment->get_items());
$breadcrumbs = breadcrumbs::add()
->link('segments/show_all', 'Segments',
......
$form->input('name')
->label(__('name').':')
->rules('required');
->rules('required')
->style('width: 600px');;
$form->dropdown('medium_id')
->label(__('Medium').':')
freenetis/branches/testing/application/controllers/devices.php
$grid_ports->field('name')
->label(__('Port name'));
$grid_ports->field('segment_name')
->label(__('Segment name'));
$grid_ports->callback_field('segment_id')
->label(__('Segment name'))
->callback('callback::segment_field');
$grid_ports->field('vlan_count')
->label(__('Vlans'))

Také k dispozici: Unified diff