Tripal Plant PopGen Submit
logs.php
Go to the documentation of this file.
1 <?php
21 function tpps_admin_panel_logs(array $form, array &$form_state, $job_log_file = NULL) {
22  // if (empty($accession)) {
23  // tpps_admin_panel_top($form);
24  // }
25  // else {
26  // tpps_manage_submission_form($form, $form_state, $accession);
27  // }
28 
29  drupal_add_js(drupal_get_path('module', 'tpps') . TPPS_JS_PATH);
30  drupal_add_css(drupal_get_path('module', 'tpps') . TPPS_CSS_PATH);
31 
32  $job_log_file_parts = explode('_', $job_log_file);
33  $accession = $job_log_file_parts[0];
34  $job_id = $job_log_file_parts[1];
35  $job_log_file = $job_log_file . '.txt';
36 
37  $markup = "";
38  $markup .= "<a href='/tpps-admin-panel/$accession'>Return to TPPS Admin Panel - $accession</a><br />";
39  $markup .= "<a target='_blank' href='/admin/tripal/tripal_jobs/view/$job_id'>View Tripal Job ID: $job_id</a><br />";
40  $markup .= "This page refreshes every 10 seconds.<br />";
41  $markup .= "<iframe id='iframe_log' height='400px;' width='100%' src='/sites/default/files/tpps_job_logs/" . $job_log_file . "'></iframe>";
42  $markup .= '<script type="text/javascript">';
43  $markup .= "jQuery(document).ready(function() {";
44  $markup .= " setInterval(function() {";
45  $markup .= " var url='/sites/default/files/tpps_job_logs/$job_log_file';";
46  $markup .= " var nocache=Math.floor(Date.now() / 1000);";
47  $markup .= " jQuery('#iframe_log').attr('src', url + '?nocache=' + nocache);";
48  $markup .= " }, 10000);";
49  $markup .= " jQuery('#iframe_log').on('load', function() {";
50  // $markup .= " console.log('iframe reloaded'); console.log(jQuery('#iframe_log').height());";
51  $markup .= " jQuery('#iframe_log').contents().scrollTop(jQuery('#iframe_log').contents().height());";
52  $markup .= " });";
53  $markup .= "});";
54  $markup .= '</script>';
55 
56  $form['markup'] = array(
57  '#type' => 'markup',
58  '#markup' => $markup
59  );
60 
61  return $form;
62 }
tpps_admin_panel_logs(array $form, array &$form_state, $job_log_file=NULL)
Definition: logs.php:21
const TPPS_CSS_PATH
Definition: tpps.module:11
const TPPS_JS_PATH
Definition: tpps.module:10