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

Add a list of raw devices to camogmgui

parent 1e062fa5
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -403,8 +403,11 @@ else
			break;
		case "list_raw_devices":
			$devices = get_raw_dev();
			foreach ($devices as $device) {
			foreach ($devices as $device => $size) {
				echo "<item>";
				echo "<raw_device>" . $device . "</raw_device>";
				echo "<size>" . round($size / 1048576, 2) . "</size>";
				echo "</item>";
			}
			break;
		case "mkdir":
@@ -628,7 +631,7 @@ function get_mnt_dev()
function get_raw_dev()
{
	$j = 0;
	$regexp = '/sd[a-z0-9]+$/';
	$regexp = '/([0-9]+) +(sd[a-z0-9]+$)/';
	$names = array();
	$ret = get_mnt_dev();
	$devices = $ret["devices"]; 
@@ -640,7 +643,7 @@ function get_raw_dev()
	for ($i = 2; $i < count($partitions); $i++) {
		// select SATA devices only
		if (preg_match($regexp, $partitions[$i], $name) == 1) {
			$names[$j] = $name[0];
			$names[$name[2]] = $name[1];
			$j++;
		}
	}
@@ -648,7 +651,7 @@ function get_raw_dev()
	// filter out partitions with file system 
	$i = 0;
	$raw_devices = array();
	foreach ($names as $name) {
	foreach ($names as $name => $size) {
		$found = false;
		foreach ($devices as $device) {
			if (strpos($device, $name) !== false)
@@ -656,7 +659,7 @@ function get_raw_dev()
		}
		if ($found === false) {
			// 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++;
		}
	}
+4 −0
Original line number Diff line number Diff line
@@ -257,3 +257,7 @@ table.state_table td {
	margin: 0px;
	padding: 0px;
}

.radio_class {
	margin-top: 1px;
}
 No newline at end of file
+63 −4
Original line number Diff line number Diff line
@@ -384,6 +384,8 @@ function process_request(xmldoc) {
            case "listdevices":
                    process_scan_devices(xmldoc);
                    break;
            case "list_raw_devices":
            		process_raw_dev_list(xmldoc);
            default:
                    break;
        }
@@ -535,7 +537,9 @@ function help(caller) {
		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).")
			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) {
@@ -747,13 +751,68 @@ function toggle_buffer() {
	}
}

// enable fast recording through disk driver
function fast_rec_changed(parent)
/** Enable or disable page controls in accordance to new state which cat be one of 'fast_rec' or 'standart_rec' */
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('directory').disabled = true;
	} else {
		radios_disable = 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
+2 −2
Original line number Diff line number Diff line
@@ -573,7 +573,7 @@
                    else
                    	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 />
                    <br />
                    
@@ -594,7 +594,7 @@
				  </select> 
                  <a href="#" onClick="help('debug');"><img src="images/help.png"></a><br />
                    <br />
                  <input name="settings_format" type="submit" value="OK">
                  <input id="submit_button" name="settings_format" type="submit" value="OK">
				</form>
            </div>
            <div class="TabbedPanelsContent">