Commit 1013ff59 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Update device list and status information in camogmgui

parent 75cce656
......@@ -7,7 +7,7 @@ CONFIGS = qt_source
IMAGES = $(GUIDIR)/images/filebrowser-01.gif $(GUIDIR)/images/filebrowser-bottom-01.gif $(GUIDIR)/images/png_white_30.png \
$(GUIDIR)/images/record.gif $(GUIDIR)/images/reload.png $(GUIDIR)/images/stop.gif $(GUIDIR)/images/create_folder.png \
$(GUIDIR)/images/divider.png $(GUIDIR)/images/folder.gif $(GUIDIR)/images/help.png $(GUIDIR)/images/quicktime.png \
$(GUIDIR)/images/rec_folder.png $(GUIDIR)/images/up_folder.gif $(GUIDIR)/images/play_audio.png
$(GUIDIR)/images/rec_folder.png $(GUIDIR)/images/up_folder.gif $(GUIDIR)/images/play_audio.png $(GUIDIR)/images/hdd.png
SRCS = camogm.c camogm_ogm.c camogm_jpeg.c camogm_mov.c camogm_kml.c camogm_read.c index_list.c
......
......@@ -124,7 +124,7 @@ else if ($cmd == "status")
header("Content-Type: text/xml");
header("Content-Length: ".strlen($status)."\n");
header("Pragma: no-cache\n");
printf($status);
printf("%s", $status);
}
else if ($cmd == "run_status")
{
......@@ -151,7 +151,7 @@ else if ($cmd == "run_status")
header("Content-Type: text/xml");
header("Content-Length: ".strlen($status)."\n");
header("Pragma: no-cache\n");
printf($status);
printf("%s", $status);
}
else if ($cmd=="get_hdd_space"){
if (isset($_GET['mountpoint']))
......@@ -188,7 +188,7 @@ else if ($cmd=="mount") { // mount media like HDD
echo "</".$cmd.">";
xml_footer();
}
else if ($cmd=="unmount") { // unmount media like HDD
else if (($cmd=="umount") || ($cmd=="unmount")) { // unmount media like HDD
$message = "";
if (isset($_GET['mountpoint'])) {
$mountpoint = $_GET['mountpoint'];
......@@ -348,29 +348,36 @@ else
case "listdevices":
exec ("cat /proc/partitions", $arr1);
exec ("cat /proc/mounts", $arr2);
$j = 0;
// first two lines are header and empty line separator, skip them
$i = 2;
while($i < count($arr1)) {
if(!strpos($arr1[$i], "mtdblock")) {
// skip flash and RAM disk partitions
if(!strpos($arr1[$i], "mtdblock") && !strpos($arr1[$i], "ram")) {
$temp = $arr1[$i];
while(strstr($temp, " ")) {
$temp = str_replace(chr(9), " ", $temp);
$temp = str_replace(" ", " ", $temp);
}
//echo $temp;
preg_match_all('/[a-z]{3,3}[0-9]{1,1}/', $temp, $available_partitons);
//preg_match_all('/[a-z]{3,3}/', $temp, $available_devices);
if (preg_match_all('/ +[a-z]{3,3}[0-9]{1,1}$/', $temp, $available_partitons) > 0) {
// remove leading spaces
$partitions[$j] = preg_replace("/^ +/", "", $available_partitons[0][0]);
$parts = explode(" ", $temp);
$size = $parts[3];
$size[$j] = $parts[3];
$j++;
}
}
$i++;
}
foreach ($available_partitons as $device) {
$j = 0;
foreach ($partitions as $partition) {
echo "<item>";
echo "<partition>/dev/".$device[0]."</partition>";
echo "<size>".round($size/1024/1024, 2) ." GB</size>";
$i = 2;
echo "<partition>/dev/".$partition."</partition>";
echo "<size>".round($size[$j]/1024/1024, 2) ." GB</size>";
$j++;
$i = 0;
while($i < count($arr2)) {
if(strpos($arr2[$i], $device[0]))
if(strpos($arr2[$i], $partition))
{
$parts = explode(" ", $arr2[$i]);
$mountpoint = $parts[1];
......@@ -378,18 +385,21 @@ else
}
$i++;
}
if ($mountpoint != "")
if ($mountpoint != "") {
echo "<mountpoint>".$mountpoint."</mountpoint>";
else
$mountpoint = "";
} else {
echo "<mountpoint>none</mountpoint>";
if ($filesystem != "")
}
if ($filesystem != "") {
echo "<filesystem>".$filesystem."</filesystem>";
else
$filesystem = "";
} else {
echo "<filesystem>none</filesystem>";
}
echo "</item>";
}
break;
case "mkdir":
$dir_name = $_GET['name'];
......
......@@ -75,7 +75,7 @@ function scan_devices() {
function process_scan_devices(xmldoc) {
if (xmldoc.getElementsByTagName('listdevices').length > 0) {
var content = "";
content += "<table cellpadding='10' cellspacing='0' cellmargin='0'>";
content += "<table cellpadding='5' cellspacing='0' cellmargin='0'>";
content += "<tr><td></td><td><b>Partition</b></td><td><b>Mountpoint</b></td><td><b>Size</b></td><td><b>Filesystem</b></td><td></td></tr>";
for (var i=0; i < xmldoc.getElementsByTagName('item').length; i++) {
if (xmldoc.getElementsByTagName('item')[i].firstChild.firstChild.data != null) {
......@@ -85,7 +85,7 @@ function process_scan_devices(xmldoc) {
content += " value='/var/hdd'";
content += "></td><td>" + xmldoc.getElementsByTagName('size')[i].firstChild.data + "</td><td>" + '</td><td><a href="#" onClick="mount_custom_partition(\'' + xmldoc.getElementsByTagName('partition')[i].firstChild.data + '\');">mount</a></td></tr>';
} else {
content += "<tr><td><img alt=\"HDD\" src=\"../camerasetup/images/hdd.png\"></td><td>" + xmldoc.getElementsByTagName('partition')[i].firstChild.data;
content += "<tr><td><img alt=\"HDD\" src=\"images/hdd.png\"></td><td>" + xmldoc.getElementsByTagName('partition')[i].firstChild.data;
content += "</td><td>" + xmldoc.getElementsByTagName('mountpoint')[i].firstChild.data + "</td><td>";
content += xmldoc.getElementsByTagName('size')[i].firstChild.data + "</td><td>" + xmldoc.getElementsByTagName('filesystem')[i].firstChild.data;
content += '</td><td><a href="#" onClick="unmount_custom_partition(\' ' + xmldoc.getElementsByTagName('mountpoint')[i].firstChild.data + '\');">unmount</a></td></tr>';
......@@ -272,9 +272,11 @@ function makeRequest(url, parameters) {
function process_request() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
console.log("process_request");
if(http_request.responseXML != null) {
var xmldoc = http_request.responseXML;
if (xmldoc.getElementsByTagName('camogm_state').length > 0) {
console.log(xmldoc.getElementsByTagName('state')[0].firstChild.data);
process_recording(xmldoc);
}
if (xmldoc.getElementsByTagName('command').length > 0) {
......@@ -320,6 +322,9 @@ function process_recording(xmldoc) {
var file_length = xmldoc.getElementsByTagName('file_length')[0].firstChild.data;
var file_name = xmldoc.getElementsByTagName('file_name')[0].firstChild.data;
if (state=='"stopped"'){
clearInterval(update_intvl);
}
//Update HTML
document.getElementById('ajax_state').innerHTML = state.substring(1, state.length-1);
document.getElementById('ajax_file_duration').innerHTML = Math.round(file_duration*100)/100 + " seconds / " + frame_number + " frames";
......@@ -345,11 +350,14 @@ function process_recording(xmldoc) {
}
recording = false;
function update_state() {
if (recording) {
//if (recording) {
makeRequest('camogm_interface.php', '?cmd=status');
setTimeout('update_state()', 200);
}
//setTimeout('update_state()', 200);
//}
}
var update_intvl;
function toggle_recording() {
if (recording) // Stop it
{
......@@ -376,7 +384,7 @@ function toggle_recording() {
setTimeout('list_files(getCookie("current_dir"))', 300);
setTimeout('get_hdd_space()', 600);
setTimeout("makeRequest('camogm_interface.php', '?cmd=status')", 900);
//setTimeout(last_update, 900);
}
else // Start it
{
......@@ -390,8 +398,11 @@ function toggle_recording() {
// show we are recording
document.getElementById('record_text').innerHTML = "<img src=\"images/stop.gif\" style=\"position:relative; bottom:-5px;\"> STOP";
document.getElementById('sitecoloumn').style.backgroundColor = "#AF2020";
clearInterval(update_intvl);
update_intvl = setInterval(update_state,1000);
}
update_state();
//update_state();
}
function rename_file(oldname, newname) {
makeRequest('camogm_interface.php', '?cmd=file_rename&file_old=' + oldname + '&file_new=' + newname);
......
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