Commit 0faa9606 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Add a list of raw devices to camogmgui

parent 1e062fa5
...@@ -403,8 +403,11 @@ else ...@@ -403,8 +403,11 @@ else
break; break;
case "list_raw_devices": case "list_raw_devices":
$devices = get_raw_dev(); $devices = get_raw_dev();
foreach ($devices as $device) { foreach ($devices as $device => $size) {
echo "<item>";
echo "<raw_device>" . $device . "</raw_device>"; echo "<raw_device>" . $device . "</raw_device>";
echo "<size>" . round($size / 1048576, 2) . "</size>";
echo "</item>";
} }
break; break;
case "mkdir": case "mkdir":
...@@ -628,7 +631,7 @@ function get_mnt_dev() ...@@ -628,7 +631,7 @@ function get_mnt_dev()
function get_raw_dev() function get_raw_dev()
{ {
$j = 0; $j = 0;
$regexp = '/sd[a-z0-9]+$/'; $regexp = '/([0-9]+) +(sd[a-z0-9]+$)/';
$names = array(); $names = array();
$ret = get_mnt_dev(); $ret = get_mnt_dev();
$devices = $ret["devices"]; $devices = $ret["devices"];
...@@ -640,7 +643,7 @@ function get_raw_dev() ...@@ -640,7 +643,7 @@ function get_raw_dev()
for ($i = 2; $i < count($partitions); $i++) { for ($i = 2; $i < count($partitions); $i++) {
// select SATA devices only // select SATA devices only
if (preg_match($regexp, $partitions[$i], $name) == 1) { if (preg_match($regexp, $partitions[$i], $name) == 1) {
$names[$j] = $name[0]; $names[$name[2]] = $name[1];
$j++; $j++;
} }
} }
...@@ -648,7 +651,7 @@ function get_raw_dev() ...@@ -648,7 +651,7 @@ function get_raw_dev()
// filter out partitions with file system // filter out partitions with file system
$i = 0; $i = 0;
$raw_devices = array(); $raw_devices = array();
foreach ($names as $name) { foreach ($names as $name => $size) {
$found = false; $found = false;
foreach ($devices as $device) { foreach ($devices as $device) {
if (strpos($device, $name) !== false) if (strpos($device, $name) !== false)
...@@ -656,7 +659,7 @@ function get_raw_dev() ...@@ -656,7 +659,7 @@ function get_raw_dev()
} }
if ($found === false) { if ($found === false) {
// current partition is not found in the blkid list, add it to raw devices // current partition is not found in the blkid list, add it to raw devices
$raw_devices[$i] = "/dev/" . $name; $raw_devices["/dev/" . $name] = $size;
$i++; $i++;
} }
} }
......
...@@ -257,3 +257,7 @@ table.state_table td { ...@@ -257,3 +257,7 @@ table.state_table td {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
} }
.radio_class {
margin-top: 1px;
}
\ No newline at end of file
...@@ -384,6 +384,8 @@ function process_request(xmldoc) { ...@@ -384,6 +384,8 @@ function process_request(xmldoc) {
case "listdevices": case "listdevices":
process_scan_devices(xmldoc); process_scan_devices(xmldoc);
break; break;
case "list_raw_devices":
process_raw_dev_list(xmldoc);
default: default:
break; break;
} }
...@@ -535,7 +537,9 @@ function help(caller) { ...@@ -535,7 +537,9 @@ function help(caller) {
case 'debug': case 'debug':
alert("The higher the debug-level the more information is written to the debug file (it may slow down camogm and cause it to drop frames even if it could handle it with no/lower debug-level output).") alert("The higher the debug-level the more information is written to the debug file (it may slow down camogm and cause it to drop frames even if it could handle it with no/lower debug-level output).")
break; break;
case 'fast_rec':
alert("Enable or disable fast recoding feature. The disk drive should have at least one partition without file system or" +
"any data on it to enable this feature.");
} }
} }
function format_changed(parent) { function format_changed(parent) {
...@@ -747,13 +751,68 @@ function toggle_buffer() { ...@@ -747,13 +751,68 @@ function toggle_buffer() {
} }
} }
// enable fast recording through disk driver /** Enable or disable page controls in accordance to new state which cat be one of 'fast_rec' or 'standart_rec' */
function fast_rec_changed(parent) function set_controls_state(new_state)
{ {
if (parent.checked) { var radios = document.getElementsByName('container');
if (new_state == 'fast_rec') {
radios_disable = true;
document.getElementById('radioJpg').checked = true; document.getElementById('radioJpg').checked = true;
document.getElementById('directory').disabled = true; document.getElementById('directory').disabled = true;
} else { } else {
radios_disable = false;
document.getElementById('directory').disabled = false; document.getElementById('directory').disabled = false;
if (document.getElementById('submit_button').disabled == true)
document.getElementById('submit_button').disabled = false;
}
for (var i = 0; i < radios.length; i++) {
radios[i].disabled = radios_disable;
}
}
/** Enable fast recording through disk driver */
function fast_rec_changed(parent)
{
if (parent.checked) {
makeRequest('camogm_interface.php', '?cmd=list_raw_devices');
} else {
scan_devices("is_mounted(selected_device)");
set_controls_state('standart_rec');
} }
} }
/** Show raw devices table and change the state of controls */
function process_raw_dev_list(xmldoc)
{
var content = "";
var items = xmldoc.getElementsByTagName('item');
content += "";
if (items.length > 0) {
set_controls_state('fast_rec');
content += "<table cellpadding='5' cellspacing='0' cellmargin='0'>";
content += "<tr><td></td><td><b>Partition</b></td><td><b></b></td><td><b>Size</b></td><td><b></b></td><td></td></tr>";
for (var i = 0; i < items.length; i++) {
var partition = items[i].childNodes[0];
var size = items[i].childNodes[1];
content += "<tr><td><input type=\"radio\" id=\"radio_dev_" + i + "\" class=\"radio_class\" name=\"rawdev_path\" value=\"" +
partition.firstChild.nodeValue + "\" ";
if (i == 0) {
content += "checked ";
}
content += "/></td>" +
"<td>" + partition.firstChild.nodeValue + "</td>" +
"<td></td><td>" + size.firstChild.nodeValue + " GB" + "</td>" +
"<td></td><td></td></tr>";
}
content += "</table>";
} else {
content += "<p class=\"alert\">Device partitions without file system are not found. Fast recording can not be started. " +
"Create a partition without file system on it and try again.</p>";
document.getElementById('submit_button').disabled = true;
}
document.getElementById('ajax_devices').innerHTML = content;
}
\ No newline at end of file
...@@ -573,7 +573,7 @@ ...@@ -573,7 +573,7 @@
else else
echo "<input type=\"radio\" id=\"radioJpg\" style=\"top:3px; position:relative;\" name=\"container\" value=\"jpg\" onChange=\"format_changed(this);\"> JPEG Sequence<br />"; echo "<input type=\"radio\" id=\"radioJpg\" style=\"top:3px; position:relative;\" name=\"container\" value=\"jpg\" onChange=\"format_changed(this);\"> JPEG Sequence<br />";
?> ?>
<input id="fast_rec" type="checkbox" style="left:1px; top:3px; position:relative;" name="" value="" onChange="fast_rec_changed(this)"> Use fast recording <input id="fast_rec" type="checkbox" style="left:1px; top:3px; position:relative;" name="fastrec_checkbox" value="checked" onChange="fast_rec_changed(this)"> Use fast recording
<a href="#" onClick="help('fast_rec');"><img src="images/help.png"></a><br /> <a href="#" onClick="help('fast_rec');"><img src="images/help.png"></a><br />
<br /> <br />
...@@ -594,7 +594,7 @@ ...@@ -594,7 +594,7 @@
</select> </select>
<a href="#" onClick="help('debug');"><img src="images/help.png"></a><br /> <a href="#" onClick="help('debug');"><img src="images/help.png"></a><br />
<br /> <br />
<input name="settings_format" type="submit" value="OK"> <input id="submit_button" name="settings_format" type="submit" value="OK">
</form> </form>
</div> </div>
<div class="TabbedPanelsContent"> <div class="TabbedPanelsContent">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment