Fix bug with interaction of log filter and automatic refresh, a=chris
Fix bug with interaction of log filter and automatic refresh, a=chris
diff --git a/src/controllers/components/SystemComponent.php b/src/controllers/components/SystemComponent.php
index 342eac6b9..5978b28e4 100755
--- a/src/controllers/components/SystemComponent.php
+++ b/src/controllers/components/SystemComponent.php
@@ -269,6 +269,10 @@ class SystemComponent extends Component
if ($r["type"] == "fetcher") {
$data["LOG_TYPE"] .= " ". $r['id'];
}
+ $data['LOG_NAME'] = $r['name'];
+ $data['LOG_ID'] = $r['id'];
+ $data['LOG_CHANNEL'] = $r['LOG_CHANNEL'] ?? 0;
+ $data['LOG_MACHINE_TYPE'] = $r["type"];
$data["REFRESH_LOG"] .= "&arg=log&name=".$r['name'].
"&id=" . $r['id'] . "&type=" . $r["type"] .
"&channel=" . $r['channel'];
diff --git a/src/library/PackedTableTools.php b/src/library/PackedTableTools.php
index 3851eae7c..320b645b7 100644
--- a/src/library/PackedTableTools.php
+++ b/src/library/PackedTableTools.php
@@ -184,8 +184,26 @@ class PackedTableTools
}
}
/**
+ * Adds ($key, $table_row) as an entry into $table
+ * using the adding and replace methods specified
*
- * //cannot use compression with
+ * @param mixed &$table either an associative array of key =>value
+ * pairs where the keys are strings of length matching this
+ * PackedTableTools sginature and the values have been packed according to
+ * this signature, or the file name of a file containing a serialized
+ * version of such a table, or a file handle to the end of such a file
+ * @param string $key a key string of length given by the signature of this
+ * PackedTableTools
+ * @param string $table_row a record packed according tot the signature
+ * of this PackedTableTools
+ * @param int $add_method one of self::ADD_MEM_TABLE, self::ADD_FILE_HANDLE,
+ * self::ADD_FILE_PATH indicating which of the three possibilities
+ * for $table we have
+ * @param int $mode either self::APPEND_MODE or self::REPLACE_MODE
+ * If the former the table_row data will be appended to any data
+ * currently associated with the key, if the latter it will replace
+ * such data
+ * @return bool whether or not adding was successful
*/
public function add(&$table, $key, $table_row,
$add_method = self::ADD_MEM_TABLE, $mode = self::REPLACE_MODE)
@@ -239,7 +257,13 @@ class PackedTableTools
substr($row_values2, $row_values2_pos);
}
/**
+ * Removes $key and any records associated with it from $table
*
+ * @param array& $table array of key => records pairs where the
+ * key is a string of length given by this PackedTableTool's signature
+ * and the records are packed according this PackedTableTool's signature
+ * @param string $key to remove records for
+ * @return bool success or failure of removal
*/
public function delete(&$table, $key)
{
@@ -250,7 +274,14 @@ class PackedTableTools
return false;
}
/**
+ * Return any records in $table associated with $key
*
+ * @param array $table array of key => records pairs where the
+ * key is a string of length given by this PackedTableTool's signature
+ * and the records are packed according this PackedTableTool's signature
+ * @param string $key to return records for
+ * @return array of records that have been packed according to this
+ * PackedTableTool's signature
*/
public function find($table, $key)
{
diff --git a/src/views/elements/MachinelogElement.php b/src/views/elements/MachinelogElement.php
index fbea67b33..55864fd0c 100644
--- a/src/views/elements/MachinelogElement.php
+++ b/src/views/elements/MachinelogElement.php
@@ -56,10 +56,28 @@ class MachinelogElement extends Element
[<a href="<?=$admin_url ?>a=manageMachines&<?=
C\CSRF_TOKEN . "=" . $data[C\CSRF_TOKEN] ?>" >X</a>]
</div>
- <form method="get" action="javascript:logUpdate();" >
+ <form method="get" >
<div class="clear top-space">
<div class="filter-container">
- <input type="search" class="narrow-field" name='group_filter'
+ <input type="hidden" name="<?=C\CSRF_TOKEN ?>"
+ value="<?=$data[C\CSRF_TOKEN] ?>" />
+ <input type="hidden" name="c" value="admin" />
+ <input type="hidden" name="a" value="manageMachines" />
+ <input type="hidden" name="arg" value="log" />
+ <input type="hidden" name="time" value="<?=$data['time'] ?>" />
+ <input type="hidden" name="name" value="<?=
+ $data['LOG_NAME'] ?>" />
+ <input type="hidden" name="id" value="<?=
+ $data['LOG_ID'] ?? "" ?>" />
+ <input type="hidden" name="channel" value="<?=
+ $data['LOG_CHANNEL'] ?? 0 ?>" />
+ <input type="hidden" name="type" value="<?=
+ $data['LOG_MACHINE_TYPE'] ?>" />
+ <?php
+ if (!empty($data['NO_REFRESH'])) { ?>
+ <input type="hidden" name="NO_REFRESH" value="true" /><?php
+ }?>
+ <input type="search" class="narrow-field" name='f'
placeholder="<?=tl('machinelog_element_filter_log') ?>"
id='set-filter' value="<?=$data['filter']?>" />
</div>
@@ -74,11 +92,13 @@ class MachinelogElement extends Element
<?php if (!$data['NO_REFRESH']) {?>
<p>[<a href="<?=$admin_url .
C\CSRF_TOKEN."=".$data[C\CSRF_TOKEN]?>&a=manageMachines<?=
- $data['REFRESH_LOG'] ?>&NO_REFRESH=true" ><?=
+ $data['REFRESH_LOG'] ?>&NO_REFRESH=true&f=<?=
+ $data['filter'] ?>" ><?=
tl('machinelog_element_refresh_off') ?></a>]</p>
<?php } else { ?>
<p>[<a href="<?=$admin_url . C\CSRF_TOKEN . "=" . $data[C\CSRF_TOKEN]
- ?>&a=manageMachines<?=$data['REFRESH_LOG'] ?>"><?=
+ ?>&a=manageMachines<?=$data['REFRESH_LOG'] ?>&f=<?=
+ $data['filter'] ?>"><?=
tl('machinelog_element_refresh_on') ?></a>]</p>
<?php } ?>
<pre><?=htmlentities(wordwrap($data["LOG_FILE_DATA"], 60, "\n", true))