Revize 1469
Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)
freenetis/branches/network/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'fill in field' => 'Doplňte pole',
|
||
'filled' => 'Vyplněno',
|
||
'filter' => 'Filtrovat',
|
||
'filter devices' => 'Filtrovat zařízení',
|
||
'filter query has been successfully added' => 'Dotaz filtru byl úspěšně přidán.',
|
||
'filter query has been successfully deleted' => 'Dotaz filtru byl úspěšně smazán.',
|
||
'filter query has been successfully set as default' => 'Dotaz filtru byl úspěšně nastaven jako výchozí.',
|
freenetis/branches/network/application/models/device.php | ||
---|---|---|
const TYPE_DREAMBOX = 101;
|
||
const TYPE_SERVER = 102;
|
||
|
||
protected $has_many = array('ifaces');
|
||
protected $belongs_to = array('address_point', 'user');
|
||
protected $has_and_belongs_to_many = array
|
||
protected $has_many = array
|
||
(
|
||
'device_admins' => 'user',
|
||
'device_engineers' => 'user'
|
||
'ifaces', 'device_admins', 'device_engineers'
|
||
);
|
||
|
||
protected $belongs_to = array('address_point', 'user');
|
||
|
||
public $arr_sql = array
|
||
(
|
||
'id' => 'd.id',
|
||
... | ... | |
public function select_list_device_with_user()
|
||
{
|
||
$devices = $this->db->query("
|
||
SELECT d.id, d.name, CONCAT(u.surname,' ',u.name) AS user_name
|
||
SELECT d.id,
|
||
CONCAT(IF(ISNULL(d.name) OR LENGTH(d.name) = 0,d.id,d.name),
|
||
' (', CONCAT(u.surname,' ',u.name), ')') AS name
|
||
FROM devices d
|
||
JOIN users u ON d.user_id = u.id
|
||
ORDER BY d.name
|
||
ORDER BY IF(ISNULL(d.name) OR LENGTH(d.name) = 0,1,0), d.name, u.id
|
||
");
|
||
|
||
$arr_devices = array();
|
||
|
||
foreach ($devices as $device)
|
||
$arr_devices[$device->id] = "$device->name ($device->user_name)";
|
||
{
|
||
$arr_devices[$device->id] = $device->name;
|
||
}
|
||
|
||
return $arr_devices;
|
||
}
|
||
|
||
/**
|
||
* Select list of user and their devices
|
||
*
|
||
* @return array
|
||
*/
|
||
public function select_list_filtered_device_with_user($filter_sql = '')
|
||
{
|
||
if (empty($filter_sql))
|
||
{
|
||
return $this->select_list_device_with_user();
|
||
}
|
||
else
|
||
{
|
||
$devices = $this->db->query("
|
||
SELECT device_id AS id,
|
||
CONCAT(IF(ISNULL(device_name) OR LENGTH(device_name) = 0,device_id,device_name),
|
||
' (', user_name, ')') AS name
|
||
FROM
|
||
(
|
||
SELECT d.id AS device_id, d.name AS device_name, u.id AS user,
|
||
CONCAT(u.surname,' ',u.name) AS user_name, s.id AS subnet,
|
||
d.type
|
||
FROM devices d
|
||
JOIN users u ON d.user_id = u.id
|
||
LEFT JOIN ifaces i ON i.device_id = d.id
|
||
LEFT JOIN ip_addresses ip ON ip.iface_id = i.id
|
||
JOIN subnets s ON ip.subnet_id = s.id
|
||
) df
|
||
WHERE $filter_sql
|
||
ORDER BY IF(ISNULL(device_name) OR LENGTH(device_name) = 0,1,0), device_name, user
|
||
");
|
||
}
|
||
|
||
$arr_devices = array();
|
||
|
||
foreach ($devices as $device)
|
||
{
|
||
$arr_devices[$device->id] = $device->name;
|
||
}
|
||
|
||
return $arr_devices;
|
||
}
|
||
|
||
/**
|
||
* Returns all devices of link
|
||
*
|
||
* @author Michal Kliment
|
freenetis/branches/network/application/models/iface.php | ||
---|---|---|
* @param integer $user_id User identificator
|
||
* @param integer $type Type of interface for connection
|
||
* @param array $gps location of device - default member AP [optional]
|
||
* @param string $filter_sql Filter SQL
|
||
* @return object Suitable iface or null
|
||
*/
|
||
public function get_iface_for_connecting_to_iface($user_id, $type, $gps = array())
|
||
public function get_iface_for_connecting_to_iface($user_id, $type,
|
||
$gps = array(), $filter_sql = '')
|
||
{
|
||
$can_connect = Iface_Model::get_can_connect_to($type);
|
||
$user = new User_Model($user_id);
|
||
$where = '';
|
||
|
||
if (!empty($filter_sql))
|
||
{
|
||
$where = 'WHERE ' . $filter_sql;
|
||
}
|
||
|
||
if ($user->id && count($can_connect))
|
||
{
|
||
$usearch = array(User_Model::ASSOCIATION, $user->id);
|
||
|
||
// find current user interfaces and select oponent by link
|
||
$from_current = $this->db->query("
|
||
SELECT i2.id AS iface_id, d2.id AS device_id
|
||
FROM devices d
|
||
JOIN ifaces i ON i.device_id = d.id
|
||
JOIN links l ON i.link_id = l.id
|
||
JOIN ifaces i2 ON i2.link_id = l.id AND i2.id <> i.id
|
||
JOIN devices d2 ON i2.device_id = d2.id
|
||
WHERE i.type = ? AND i2.type IN(" . implode(',', $can_connect) . ") AND
|
||
d.user_id = ? AND d2.user_id IN (" . implode(',', $usearch) . ")
|
||
ORDER BY d2.user_id
|
||
SELECT iface_id, device_id
|
||
FROM
|
||
(
|
||
SELECT i2.id AS iface_id, d2.id AS device_id,
|
||
d2.user_id AS user, ip.subnet_id AS subnet, d2.type
|
||
FROM devices d
|
||
JOIN ifaces i ON i.device_id = d.id
|
||
JOIN links l ON i.link_id = l.id
|
||
JOIN ifaces i2 ON i2.link_id = l.id AND i2.id <> i.id
|
||
LEFT JOIN ip_addresses ip ON ip.iface_id = i2.id
|
||
JOIN devices d2 ON i2.device_id = d2.id
|
||
WHERE i.type = ? AND i2.type IN(" . implode(',', $can_connect) . ") AND
|
||
d.user_id = ? AND d2.user_id IN (" . implode(',', $usearch) . ")
|
||
) df
|
||
$where
|
||
ORDER BY user
|
||
LIMIT 1
|
||
", $type, $user->id);
|
||
|
||
... | ... | |
|
||
// find nearest in net (using GPS)
|
||
return $this->db->query("
|
||
SELECT *
|
||
SELECT iface_id, device_id
|
||
FROM ((
|
||
SELECT i2.id AS iface_id, d2.id AS device_id, 2 AS priority
|
||
FROM devices d2
|
||
JOIN ifaces i2 ON i2.device_id = d2.id
|
||
JOIN address_points ap2 ON d2.address_point_id = ap2.id
|
||
WHERE i2.type IN(" . implode(',', $can_connect) . ") AND
|
||
d2.user_id IN (" . implode(',', $usearch) . ") AND
|
||
X(ap2.gps) IS NOT NULL AND Y(ap2.gps) IS NOT NULL
|
||
ORDER BY SQRT(POW(" . $gps['x'] . " - X(ap2.gps), 2) +
|
||
POW(" . $gps['y'] . " - Y(ap2.gps), 2)) ASC,
|
||
d2.user_id DESC
|
||
SELECT iface_id, device_id, priority
|
||
FROM
|
||
(
|
||
SELECT i2.id AS iface_id, d2.id AS device_id, 2 AS priority,
|
||
d2.user_id AS user, ip2.subnet_id AS subnet, d2.type,
|
||
ap2.gps
|
||
FROM devices d2
|
||
JOIN ifaces i2 ON i2.device_id = d2.id
|
||
LEFT JOIN ip_addresses ip2 ON ip2.iface_id = i2.id
|
||
JOIN address_points ap2 ON d2.address_point_id = ap2.id
|
||
WHERE i2.type IN(" . implode(',', $can_connect) . ") AND
|
||
d2.user_id IN (" . implode(',', $usearch) . ") AND
|
||
X(ap2.gps) IS NOT NULL AND Y(ap2.gps) IS NOT NULL
|
||
) df
|
||
$where
|
||
ORDER BY SQRT(POW(" . $gps['x'] . " - X(df.gps), 2) +
|
||
POW(" . $gps['y'] . " - Y(df.gps), 2)) ASC,
|
||
user DESC
|
||
LIMIT 1
|
||
) UNION (
|
||
SELECT i2.id AS iface_id, d2.id AS device_id, 1 AS priority
|
||
FROM devices d2
|
||
JOIN ifaces i2 ON i2.device_id = d2.id
|
||
JOIN address_points ap2 ON d2.address_point_id = ap2.id
|
||
WHERE i2.type IN(" . implode(',', $can_connect) . ") AND
|
||
X(ap2.gps) IS NOT NULL AND Y(ap2.gps) IS NOT NULL
|
||
ORDER BY SQRT(POW(" . $gps['x'] . " - X(ap2.gps), 2) +
|
||
POW(" . $gps['y'] . " - Y(ap2.gps), 2)) ASC,
|
||
d2.user_id ASC
|
||
SELECT iface_id, device_id, priority
|
||
FROM
|
||
(
|
||
SELECT i2.id AS iface_id, d2.id AS device_id, 2 AS priority,
|
||
d2.user_id AS user, ip2.subnet_id AS subnet, d2.type,
|
||
ap2.gps
|
||
FROM devices d2
|
||
JOIN ifaces i2 ON i2.device_id = d2.id
|
||
LEFT JOIN ip_addresses ip2 ON ip2.iface_id = i2.id
|
||
JOIN address_points ap2 ON d2.address_point_id = ap2.id
|
||
WHERE i2.type IN(" . implode(',', $can_connect) . ") AND
|
||
X(ap2.gps) IS NOT NULL AND Y(ap2.gps) IS NOT NULL
|
||
) df
|
||
$where
|
||
ORDER BY SQRT(POW(" . $gps['x'] . " - X(df.gps), 2) +
|
||
POW(" . $gps['y'] . " - Y(df.gps), 2)) ASC,
|
||
user ASC
|
||
LIMIT 1
|
||
)
|
||
) i
|
freenetis/branches/network/application/models/user.php | ||
---|---|---|
protected $has_many = array
|
||
(
|
||
'jobs', 'devices', 'logs', 'phone_invoices_users', 'sms_messages',
|
||
'users' => 'private_phone_contacts', 'users_keys'
|
||
'users' => 'private_phone_contacts', 'users_keys', 'device_admins',
|
||
'device_engineers'
|
||
);
|
||
|
||
protected $has_and_belongs_to_many = array
|
||
(
|
||
'clouds',
|
||
'users_contacts' => 'contacts',
|
||
'device_admins' => 'device',
|
||
'device_engineers' => 'device'
|
||
);
|
||
|
||
/**
|
freenetis/branches/network/application/controllers/json.php | ||
---|---|---|
*/
|
||
class Json_Controller extends Controller
|
||
{
|
||
|
||
/**
|
||
* Send headers for each function
|
||
* Send headers for JSON
|
||
*
|
||
* @author Ondřej Fibich
|
||
*/
|
||
public function __construct()
|
||
public static function send_json_headers()
|
||
{
|
||
parent::__construct();
|
||
|
||
// send headers for JSON
|
||
header('Cache-Control: no-cache, must-revalidate');
|
||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||
header('Content-type: application/json');
|
||
}
|
||
|
||
/**
|
||
* Send headers for each function
|
||
*/
|
||
public function __construct()
|
||
{
|
||
parent::__construct();
|
||
// self::send_json_headers();
|
||
}
|
||
|
||
/**
|
||
* Function to return accounts belong to account type
|
||
*
|
||
* @author Michal Kliment
|
||
... | ... | |
*/
|
||
public function get_suggestion_for_connecting_to()
|
||
{
|
||
// filter
|
||
$filter = new Filter_form();
|
||
$filter->autoload();
|
||
|
||
// vars
|
||
$user_id = $this->input->get('user_id');
|
||
$gpsx = $this->input->get('gpsx');
|
||
$gpsy = $this->input->get('gpsy');
|
||
... | ... | |
echo json_encode(array
|
||
(
|
||
Iface_Model::TYPE_WIRELESS => $im->get_iface_for_connecting_to_iface(
|
||
$user_id, Iface_Model::TYPE_WIRELESS, $gps
|
||
$user_id, Iface_Model::TYPE_WIRELESS, $gps, $filter->as_sql()
|
||
),
|
||
Iface_Model::TYPE_ETHERNET => $im->get_iface_for_connecting_to_iface(
|
||
$user_id, Iface_Model::TYPE_ETHERNET, $gps
|
||
$user_id, Iface_Model::TYPE_ETHERNET, $gps, $filter->as_sql()
|
||
),
|
||
Iface_Model::TYPE_PORT => $im->get_iface_for_connecting_to_iface(
|
||
$user_id, Iface_Model::TYPE_PORT, $gps
|
||
$user_id, Iface_Model::TYPE_PORT, $gps, $filter->as_sql()
|
||
)
|
||
));
|
||
}
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Returns filtered devices in JSON format
|
||
*
|
||
* @author Ondřej Fibich
|
||
* @see Device_Controller#add
|
||
* @see Filter_form
|
||
*/
|
||
public function get_filtered_devices()
|
||
{
|
||
// filter
|
||
$filter = new Filter_form();
|
||
$filter->autoload();
|
||
|
||
// data
|
||
$dm = new Device_Model();
|
||
$devices = $dm->select_list_filtered_device_with_user($filter->as_sql());
|
||
|
||
// output
|
||
echo json_encode($devices);
|
||
}
|
||
|
||
/**
|
||
* Returns all ifaces in in JSON format
|
||
*
|
||
* @author Michal Kliment, Ondrej Fibich
|
freenetis/branches/network/application/controllers/js.php | ||
---|---|---|
|
||
$this->views['devices_add'] = View::factory('js/devices_add');
|
||
$this->views['devices_add']->arr_subnets = $subnet->select_list_by_net();
|
||
$this->views['devices_add']->arr_devices = $device->select_list('id', 'name', 'user_id');
|
||
$this->views['devices_add']->arr_devices = $device->select_list_filtered_device_with_user();
|
||
}
|
||
|
||
private function _js_devices_add_filter()
|
||
{
|
||
$this->views['devices_add'] = View::factory('js/devices_add_filter');
|
||
$this->views['devices_add']->filter_index = $this->input->get('index');
|
||
}
|
||
|
||
private function _js_devices_edit()
|
||
{
|
||
$this->address_point_streets();
|
freenetis/branches/network/application/controllers/devices.php | ||
---|---|---|
->class('delete_link');
|
||
}
|
||
|
||
$grid_device_admins->datasource($da);
|
||
$grid_device_admins->datasource($da);
|
||
|
||
// iface grids
|
||
$grids = $this->create_device_grids($device);
|
||
... | ... | |
|
||
if (!empty($device->address_point->gps))
|
||
{
|
||
$gps_result = ORM::factory('address_point')->get_gps_coordinates(
|
||
$device->address_point->id
|
||
);
|
||
$gps_result = $device->address_point->get_gps_coordinates();
|
||
|
||
if (! empty($gps_result))
|
||
{
|
||
... | ... | |
// submit button
|
||
$form->submit('Confirm');
|
||
|
||
// filter connect devices form
|
||
$filter_form = new Filter_form();
|
||
|
||
$filter_form->add('type')
|
||
->type('select')
|
||
->values(ORM::factory('enum_type')->get_values(Enum_type_model::DEVICE_TYPE_ID));
|
||
|
||
$filter_form->add('user')
|
||
->type('select')
|
||
->values(ORM::factory('user')->select_list(
|
||
'id', 'CONCAT(surname, \' \', name, \' - \', login)',
|
||
'surname'
|
||
));
|
||
|
||
$filter_form->add('subnet')
|
||
->type('select')
|
||
->values(ORM::factory('subnet')->select_list_by_net());
|
||
|
||
// validates form and saves data
|
||
if($form->validate())
|
||
{
|
||
... | ... | |
$view->content->eth_mediums = $eth_mediums;
|
||
$view->content->wl_mediums = $wl_mediums;
|
||
$view->content->port_mediums = $port_mediums;
|
||
$view->content->filter = $filter_form;
|
||
$view->render(TRUE);
|
||
} // end of function add
|
||
|
||
|
||
|
||
/**
|
||
* Function edits device.
|
||
*
|
freenetis/branches/network/application/views/devices/add.php | ||
---|---|---|
</form>
|
||
</div>
|
||
|
||
<div id="dialog_filter_devices" class="dispNone"><?php echo $filter ?></div>
|
freenetis/branches/network/application/views/main.php | ||
---|---|---|
|
||
?>
|
||
<a href="javascript: window.print();"><img src="<?php echo url::base() ?>media/images/layout/print.png" alt="print icon" /></a>
|
||
|
||
<?php
|
||
/* if ($this->session->get('user_id', 0))
|
||
{
|
||
$model_sms_message = new Sms_message_Model();
|
||
// @todo unuset get - replace by count
|
||
$unread_sms = count($model_sms_message->get_unread_messages());
|
||
|
||
if ($unread_sms)
|
||
echo html::anchor(url_lang::base().'sms/show_unread', ($unread_sms != 0 )?'<b class="orange" >SMS('.$unread_sms.')</b>':'SMS()', array('class' => 'orange', 'style' => 'margin-left: 20px;text-decoration: none;', 'title' => __('Show unread messages')));
|
||
}*/
|
||
?>
|
||
<table>
|
||
<tr>
|
||
<td class="orange"><?php echo $this->user_id ? __('Name').':' : '' ?></td>
|
freenetis/branches/network/application/views/js/devices_add.php | ||
---|---|---|
}
|
||
|
||
/**
|
||
* Opens dialog with filter for connected to devices.
|
||
*/
|
||
function filter_devices()
|
||
{
|
||
var $tr = $(this).parent().parent();
|
||
|
||
// dialog button action submit
|
||
$('#filter_form').unbind('submit').submit(function ()
|
||
{
|
||
var $i = $tr.find('input[name^="_device_filter["]');
|
||
$i.val($(this).serialize());
|
||
$('#dialog_filter_devices').dialog('close');
|
||
$i.trigger('change');
|
||
return false;
|
||
});
|
||
|
||
// open dialog
|
||
$('#dialog_filter_devices').dialog({
|
||
title: '<?php echo __('Filter devices') ?>',
|
||
modal: true,
|
||
position: ['center', 100],
|
||
width: 700
|
||
});
|
||
|
||
return false;
|
||
}
|
||
|
||
/**
|
||
* On change of connected to device dropdown, select suitable ifaces
|
||
*
|
||
* @param event Change event
|
||
* @param iface_id Iface Id for selecting loaded dependent fields
|
||
*/
|
||
function change_connected()
|
||
function change_connected(event, iface_id)
|
||
{
|
||
var $eif = $(this).parent().find('select[name^="connected_iface["]');
|
||
var $ety = $(this).parent().parent().find('input[name^="type["]');
|
||
... | ... | |
if (!parseInt($(this).val()))
|
||
{
|
||
$eif.html('');
|
||
$eif.removeClass('required');
|
||
return;
|
||
}
|
||
|
||
if (!$eif.hasClass('required'))
|
||
{
|
||
$eif.addClass('required');
|
||
}
|
||
|
||
// change map button href for prefilled enum type in add form dialog
|
||
var map_a = $(this).parent().find('.device_map');
|
||
|
||
... | ... | |
data: $(this).val(), itype: $ety.val()
|
||
}, function (data)
|
||
{
|
||
var options = [];
|
||
var options = ['<option value="">---- <?php echo __('Select interface') ?> ---</option>'];
|
||
|
||
for (var i in data)
|
||
{
|
||
options.push('<option value="');
|
||
options.push(data[i].id);
|
||
options.push('">');
|
||
options.push('"');
|
||
|
||
if (iface_id == data[i].id)
|
||
{
|
||
options.push(' selected="selected"');
|
||
}
|
||
|
||
options.push('>');
|
||
options.push(data[i].name);
|
||
options.push('</option>');
|
||
}
|
||
... | ... | |
}
|
||
});
|
||
}
|
||
else
|
||
else if ($(this).attr('type') == 'checkbox')
|
||
{
|
||
$(this).parent().parent().find('input, select').removeClass('required').removeClass('error');
|
||
$(this).parent().parent().find('label.error').remove();
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* On change of device filter - change content of form
|
||
*/
|
||
function change_filter_connected()
|
||
{
|
||
var $tr = $(this).parent().parent();
|
||
var $select = $tr.find('select[name^="connected["]');
|
||
|
||
// loader
|
||
$select.html('<option value=""><?php echo __('Loading data, please wait') ?>...</option>');
|
||
|
||
// load filtered content
|
||
$.getJSON('<?php echo url_lang::base() ?>json/get_filtered_devices?' + urldecode($(this).val()), function (options)
|
||
{
|
||
// select suggestion
|
||
var count = 0;
|
||
var reloaded = false;
|
||
var type = $tr.find('input[name^="type["]').val();
|
||
var sug;
|
||
|
||
// get suggestions
|
||
while (count++ <= 1)
|
||
{
|
||
sug = suggest_connected_to[type];
|
||
|
||
if (sug != undefined &&
|
||
sug.device_id != undefined &&
|
||
sug.iface_id != undefined)
|
||
{
|
||
if (options[sug.device_id] != undefined)
|
||
{
|
||
break; // finded => do not reload
|
||
}
|
||
}
|
||
|
||
if (!reloaded)
|
||
{
|
||
reloaded = true;
|
||
// reload suggestions
|
||
reload_suggestions($select, false);
|
||
}
|
||
}
|
||
|
||
// update form
|
||
var options_html = ['<option value="">--- <?php echo __('Select device') ?> ---</option>'];
|
||
|
||
for (var i in options)
|
||
{
|
||
options_html.push('<option value="');
|
||
options_html.push(i);
|
||
options_html.push('"');
|
||
|
||
if (sug != undefined && i == sug.device_id)
|
||
{
|
||
options_html.push(' selected="selected"');
|
||
}
|
||
|
||
options_html.push('>');
|
||
options_html.push(options[i]);
|
||
options_html.push('</option>');
|
||
}
|
||
|
||
var iface_id = (sug.iface_id == undefined) ? undefined : sug.iface_id;
|
||
|
||
$select.html(options_html.join('')).trigger('change', iface_id);
|
||
});
|
||
}
|
||
|
||
/**
|
||
* On change of IP address fields add require option to subnet if value is
|
||
* not empty.
|
||
*/
|
||
function change_ip_address()
|
||
{
|
||
var $subnet = $(this).parent().find('input[name="subnet["]');
|
||
|
||
if ($(this).val().length)
|
||
{
|
||
if (!$subnet.hasClass('required'))
|
||
{
|
||
$subnet.addClass('required');
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$subnet.removeClass('required');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Reloads suggestions stored in suggest_connected_to by values of row of form
|
||
*
|
||
* @param e Element in row
|
||
* @param async Is request to server asynchronious [optional]
|
||
*/
|
||
function reload_suggestions(e, async)
|
||
{
|
||
if (async == undefined)
|
||
{
|
||
async = true;
|
||
}
|
||
|
||
suggest_connected_to = new Array();
|
||
|
||
if (parseInt($('#user_id').val()))
|
||
{
|
||
var qs = [];
|
||
qs.push('user_id=' + $('#user_id').val());
|
||
qs.push('gpsx=' + $('#gpsx').val());
|
||
qs.push('gpsy=' + $('#gpsy').val());
|
||
qs.push($(e).parent().parent().find('input[name^="_device_filter["]').val());
|
||
|
||
$.ajax({
|
||
method: 'get',
|
||
dataType: 'json',
|
||
async: (async == true),
|
||
url: '<?php echo url_lang::base() ?>json/get_suggestion_for_connecting_to?' + qs.join('&'),
|
||
success: function(data)
|
||
{
|
||
suggest_connected_to = data;
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Creates hidden inputs by given array.
|
||
*
|
||
* @param inputs Definition of inputs (key is name and value is value of field)
|
||
... | ... | |
link_hidden_a['wireless_channel[' + i + ']'] = null;
|
||
link_hidden_a['wireless_channel_width[' + i + ']'] = null;
|
||
link_hidden_a['wireless_polarization[' + i + ']'] = null;
|
||
link_hidden_a['_device_filter[' + i + ']'] = null;
|
||
var link_hid = create_hidden_inputs(link_hidden_a);
|
||
}
|
||
|
||
... | ... | |
html_buffer.push('<label class="device_add_label"><?php echo __('Subnet') ?>: </label>');
|
||
html_buffer.push('<select name="subnet[');
|
||
html_buffer.push(i);
|
||
html_buffer.push(']" style="width: 9em" onchange="subnets_options()">');
|
||
html_buffer.push(']" style="width: 11em" onchange="subnets_options()">');
|
||
html_buffer.push(subnets_options);
|
||
html_buffer.push('</select>');
|
||
html_buffer.push('</td>');
|
||
... | ... | |
html_buffer.push('>');
|
||
html_buffer.push(devices_options);
|
||
html_buffer.push('</select>');
|
||
html_buffer.push('<a href="#" class="device_add_detail_button a_filter_devices" title="<?php echo __('Filter devices') ?>">');
|
||
html_buffer.push('<?php echo html::image(array('src' => 'media/images/icons/filter.png')) ?>');
|
||
html_buffer.push('</a>');
|
||
html_buffer.push('<a href="<?php echo url_lang::base() ?>devices/map?action=devices_add&name=connected[');
|
||
html_buffer.push(i);
|
||
html_buffer.push(']" class="device_add_detail_button popup_link device_map" title="<?php echo __('Select device using device map') ?>">');
|
||
... | ... | |
$('.add_detail_to_iface').click(add_detail_to_iface);
|
||
$('.add_detail_to_ip').click(add_detail_to_ip);
|
||
$('.add_detail_to_link').click(add_detail_to_link);
|
||
$('.a_filter_devices').click(filter_devices);
|
||
$('input[name^="use["]').change(change_use);
|
||
$('input[name^="mac["], input[name^="ip["], select[name^="connected["]').change(use_row);
|
||
$('input[name^="ip["]').change(change_ip_address);
|
||
$('select[name^="connected["]').change(change_connected);
|
||
$('select[name^="connected_iface["]').change(change_connected_iface);
|
||
$('input[name^="_device_filter["]').change(change_filter_connected);
|
||
|
||
for (var i in suggest_connected_to)
|
||
{
|
||
... | ... | |
if (sug.device_id != undefined && sug.iface_id != undefined)
|
||
{
|
||
$('.connected_first_' + i + ' option[value="' + sug.device_id + '"]').attr('selected', true);
|
||
$('.connected_first_' + i).trigger('change');
|
||
$('.connected_iface_first_' + i).val(sug.iface_id);
|
||
$('.connected_first_' + i).trigger('change', sug.iface_id);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
// on change of user_id, or gps relocate suggest_connected_to array
|
||
$('#user_id, #gpsx, #gpsy').change(function ()
|
||
{
|
||
suggest_connected_to = new Array();
|
||
|
||
if (parseInt($('#user_id').val()))
|
||
{
|
||
$.getJSON('<?php echo url_lang::base() ?>json/get_suggestion_for_connecting_to', {
|
||
user_id: $('#user_id').val(), gpsx: $('#gpsx').val(), gpsy: $('#gpsy').val()
|
||
}, function(data)
|
||
{
|
||
suggest_connected_to = data;
|
||
});
|
||
}
|
||
reload_suggestions(this);
|
||
});
|
||
|
||
// trigger at start
|
||
// trigger reload_suggestions at start
|
||
$('#user_id').trigger('change');
|
||
|
freenetis/branches/network/application/views/js/base.php | ||
---|---|---|
var html = $(this).parent().html();
|
||
$(this).parent().html("<table style='margin-top: 15px; margin-bottom: 15px;'><tr><td><select id='"+this.id+"_options'></select></td><td><table style='width:100px;text-align:center;'><tr><td><input title='<?php echo __('Remove items') ?>' style='width: 80px' type=button class='dropdown_button right_dropdown_button' id='"+this.id+"_right_button' value='◄ <?php echo __('Remove') ?>'></td></tr><tr><td> </td></tr><tr><td><input title='<?php echo __('Add items') ?>' style='width: 80px' type=button class='dropdown_button left_dropdown_button' id='"+this.id+"_left_button' value='<?php echo __('Add') ?> ►'></td></tr></table></td><td>"+html+"</td></tr><tr><td><input type=text class='dropdown_button_search' id='"+this.id+"_options_button_search'><input type='button' style='width: 30px;' value='X' class='dropdown_button_search_clear' id='"+this.id+"_options_button_search_clear'></td><td> </td><td><input type=text class='dropdown_button_search' id='"+this.id+"_button_search'><input type='button' style='width: 30px;' value='X' class='dropdown_button_search_clear' id='"+this.id+"_button_search_clear'></td></tr></table>");
|
||
|
||
$('#'+this.id).parent().parent().children("th").css('width', '100px');
|
||
$('#'+this.id).parent().parent().children('th').css('width', '100px');
|
||
$('#'+this.id).addClass('right_dropdown')
|
||
$('#'+this.id).removeClass('required')
|
||
$('#'+this.id).css('width', '250px');
|
||
|
||
$('#'+this.id+'_options').css('width', '250px');
|
||
$('#'+this.id+'_options').attr("size", $(this).attr("size"));
|
||
$('#'+this.id+'_options').attr("multiple", "multiple");
|
||
$('#'+this.id+'_options').attr('size', $(this).attr('size'));
|
||
$('#'+this.id+'_options').attr('multiple', 'multiple');
|
||
$('#'+this.id+'_options').addClass('left_dropdown');
|
||
|
||
var options = '';
|
||
$('#'+this.id+" option").not(":selected").each(function ()
|
||
var options = [];
|
||
$('#'+this.id+' option').not(':selected').each(function ()
|
||
{
|
||
options += '<option value="'+$(this).attr('value')+'">'+$(this).text()+'</option>'
|
||
options.push('<option value="'+$(this).attr('value')+'">'+$(this).text()+'</option>');
|
||
$(this).remove();
|
||
});
|
||
$('#'+this.id+'_options').html(options);
|
||
$('#'+this.id+'_options').html(options.join(''));
|
||
|
||
$('#'+this.id+" option").removeAttr("selected");
|
||
$('#'+this.id+' option').removeAttr('selected');
|
||
|
||
select_multiple[id] = new Array();
|
||
select_multiple[id+'_options'] = new Array();
|
||
|
||
$('#'+id+" option").each(function ()
|
||
$('#'+id+' option').each(function ()
|
||
{
|
||
select_multiple[id][select_multiple[id].length] = {'key': $(this).attr('value'), 'value': $(this).html()};
|
||
});
|
||
|
||
$('#'+id+"_options option").each(function ()
|
||
$('#'+id+'_options option').each(function ()
|
||
{
|
||
select_multiple[id+'_options'][select_multiple[id+'_options'].length] = {'key': $(this).attr('value'), 'value': $(this).html()};
|
||
});
|
||
... | ... | |
|
||
}
|
||
|
||
// drigger select multiple
|
||
// trigger select multiple
|
||
update_select_multiple();
|
||
|
||
/**
|
freenetis/branches/network/application/views/filter_form_template.php | ||
---|---|---|
*
|
||
* @author Michal Kliment
|
||
*/
|
||
$(".t").live("change", function (){
|
||
$(".t").die("change").live("change", function (){
|
||
|
||
// remove all items from operation's select
|
||
$(this).next().html("");
|
||
... | ... | |
});
|
||
|
||
// click on expand button
|
||
$(".expand-button").live("click", function (){
|
||
$(".expand-button").die("click").live("click", function (){
|
||
|
||
var is_multiple = ($(this).prev().attr("multiple") == 'multiple');
|
||
|
||
... | ... | |
$(this).attr('title', title);
|
||
});
|
||
|
||
$(".v").live('focus', function (){
|
||
$(".v").die('focus').live('focus', function (){
|
||
var is_multiple = ($(this).attr("multiple") == 'multiple');
|
||
|
||
if (is_multiple)
|
||
$(this).attr("size", Math.min(10, $(this).children("option").length));
|
||
});
|
||
|
||
$(".v").live('blur', function (){
|
||
$(".v").die('blur').live('blur', function (){
|
||
var is_multiple = ($(this).attr("multiple") == 'multiple');
|
||
|
||
var length = $(this).children("option").length;
|
||
... | ... | |
/**
|
||
* Adds new filter
|
||
*/
|
||
$("#add_button").live("click", function (){
|
||
$("#add_button").die("click").live("click", function (){
|
||
|
||
var i = $(".filter_div").length;
|
||
|
||
... | ... | |
return false;
|
||
});
|
||
|
||
$(".filter_div:last").hide();
|
||
if (window['filter_form_template_loaded'] == undefined)
|
||
{
|
||
window['filter_form_template_loaded'] = true;
|
||
|
||
$(".filter_div:last").hide();
|
||
|
||
// add button for adding new filter
|
||
$("<a id='add_button'><img src='<?php echo url::base() ?>media/images/icons/ico_add.gif'> <?php echo __('Add new filter') ?></a>").insertBefore("#filters");
|
||
|
||
// add button for reset filter
|
||
$("<a id='reset_button'><img src='<?php echo url::base() ?>media/images/icons/voip-terminating.png'> <?php echo __('reset_filters') ?></a>").insertBefore("#filters");
|
||
|
||
$(".t").trigger("change");
|
||
|
||
$("#add_button").trigger("click");
|
||
|
||
$(".t, .o, .v").live("change", function (){
|
||
$(this).parent().children(".n").attr("checked", "checked");
|
||
$("filter_div:last .n").removeAttr("checked");
|
||
});
|
||
|
||
for (i in selected_values)
|
||
{
|
||
if (selected_values[i].length > 1)
|
||
$("#filter-div-"+i+" .expand-button").trigger('click');
|
||
|
||
$("#filter-div-"+i+" .v").val(selected_values[i]);
|
||
}
|
||
|
||
for (i in selected_operations)
|
||
$("#filter-div-"+i+" .o").val(selected_operations[i]);
|
||
|
||
$("#filter_form fieldset legend").click(function(){
|
||
$("#filters-div").toggle("fast");
|
||
});
|
||
|
||
$("#filter-query-select").removeAttr('name');
|
||
|
||
$("#filter-query-select").change(function (){
|
||
window.location.href = '<?php echo url::base(TRUE).url::current(FALSE) ?>?query='+$(this).val();
|
||
});
|
||
|
||
// add button for adding new filter
|
||
$("<a id='add_button'><img src='<?php echo url::base() ?>media/images/icons/ico_add.gif'> <?php echo __('Add new filter') ?></a>").insertBefore("#filters");
|
||
|
||
// add button for reset filter
|
||
$("<a id='reset_button'><img src='<?php echo url::base() ?>media/images/icons/voip-terminating.png'> <?php echo __('reset_filters') ?></a>").insertBefore("#filters");
|
||
|
||
$(".t").trigger("change");
|
||
|
||
$("#add_button").trigger("click");
|
||
|
||
$(".t, .o, .v").live("change", function (){
|
||
$(this).parent().children(".n").attr("checked", "checked");
|
||
$("filter_div:last .n").removeAttr("checked");
|
||
});
|
||
|
||
for (i in selected_values)
|
||
{
|
||
if (selected_values[i].length > 1)
|
||
$("#filter-div-"+i+" .expand-button").trigger('click');
|
||
|
||
$("#filter-div-"+i+" .v").val(selected_values[i]);
|
||
}
|
||
|
||
for (i in selected_operations)
|
||
$("#filter-div-"+i+" .o").val(selected_operations[i]);
|
||
|
||
$("#filter_form fieldset legend").click(function(){
|
||
$("#filters-div").toggle("fast");
|
||
});
|
||
|
||
$("#filter-query-select").removeAttr('name');
|
||
|
||
$("#filter-query-select").change(function (){
|
||
window.location.href = '<?php echo url::base(TRUE).url::current(FALSE) ?>?query='+$(this).val();
|
||
});
|
||
});
|
||
</script>
|
||
|
Také k dispozici: Unified diff
Novinky:
- filtrovani zarizeni pro pripojeni k u formulare pro pridani zarizeni
Upravy:
- uprava filtru aby byly pouzitelne v dialogu
Oprava:
- oprava ORM vztahu u device admin a device engeneers - ORM neumi pojmenovany M:N