Skip to content

Commit

Permalink
LIMS-898: Fix callouts in visit stats (#633)
Browse files Browse the repository at this point in the history
* LIMS-898: Put callouts and elog entries into correct classes

* LIMS-898: Use config vars for elog URLs

* Hide blank columns from callouts

* LIMS-898: Add config vars for sample config

---------

Co-authored-by: Mark Williams <[email protected]>
  • Loading branch information
ndg63276 and Mark Williams authored Nov 15, 2023
1 parent 89b4028 commit 434281e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 25 deletions.
9 changes: 8 additions & 1 deletion api/config_sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
# URL to access the PV archiver
$archive_url = '';

# URL to access elog logbook
$elog_base_url = '';
$elog_callouts_page = '';
$elog_ehc_page = '';


# Valid Components
# Denotes that only staff may create proteins, otherwise they must come from replication
# with a valid `externalid`, users may still clone proteins
Expand Down Expand Up @@ -307,7 +313,8 @@
array(
'name' => 'i03',
'group' => 'mx',
'archived' => False
'archived' => False,
'logbook' => 'BLI03'
),
array(
'name' => 'i04',
Expand Down
67 changes: 52 additions & 15 deletions api/src/Page/Vstat.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,15 +687,15 @@ function _error_log()
function _ehc_log()
{
$info = $this->_check_visit();
$elog_url = $this->_construct_elog_url($info, false);

$en = strtotime($info['EN']);
$ehc_tmp = $this->_get_remote_xml('https://rdb.pri.diamond.ac.uk/php/elog/cs_logwscontentinfo.php?startdate=' . date('d/m/Y', $en));
if (!$ehc_tmp)
if ($elog_url)
$ehc_tmp = $this->_get_remote_xml($elog_url);
if (!$elog_url || !$ehc_tmp)
$ehc_tmp = array();

$ehcs = array();
foreach ($ehc_tmp as $e) {
//if (strpos($e->title, 'shift') !== False)
array_push($ehcs, $e);
}

Expand All @@ -706,24 +706,61 @@ function _ehc_log()
function _callouts()
{
$info = $this->_check_visit();
$elog_url = $this->_construct_elog_url($info, true);
if ($elog_url)
$calls_tmp = $this->_get_remote_xml($elog_url);

if (!$elog_url || !$calls_tmp)
$calls_tmp = array();

$calls = array();
foreach ($calls_tmp as $e) {
array_push($calls, $e);
}
$this->_output($calls);
}


function _construct_elog_url($info, $callouts)
{
global $elog_base_url, $elog_callouts_page, $elog_ehc_page;
if (!$elog_base_url) {
return '';
}
$st = strtotime($info['ST']);
$en = strtotime($info['EN']);
if ($callouts) {
$page = $elog_callouts_page;
$parameters = array(
'startdate' => date('d/m/Y', $st),
'enddate' => date('d/m/Y', $en),
'selgroupid' => $this->_get_logbook_from_beamline($info['BL']),
);
} else {
$page = $elog_ehc_page;
$parameters = array('startdate' => date('d/m/Y', $en));
}

$bls = array(
'i02' => 'BLI02', 'i03' => 'BLI03', 'i04' => 'BLI04', 'i04-1' => 'BLI04J', 'i24' => 'BLI24', 'i23' => 'BLI23',
'i11-1' => 'BLI11',
'b21' => 'BLB21',
'i12' => 'BLI12', 'i13' => 'BLI13', 'i13-1' => 'BLI13J',
);
$calls = $this->_get_remote_xml('https://rdb.pri.diamond.ac.uk/php/elog/cs_logwscalloutinfo.php?startdate=' . date('d/m/Y', $st) . '&enddate=' . date('d/m/Y', $en) . 'selgroupid=' . $bls[$info['BL']]);
if (!$calls)
$calls = array();

$this->_output($calls);
$url_query = http_build_query($parameters);
$elog_url = $elog_base_url . $page . "?" . $url_query;
return $elog_url;
}


function _get_logbook_from_beamline($bl)
{
global $bl_types;
$logbook = null;
foreach ($bl_types as $type)
{
if ($type['name'] == $bl)
{
$logbook = $type['logbook'];
break;
}
}
return $logbook;
}


function _check_visit()
Expand Down
6 changes: 2 additions & 4 deletions client/src/js/modules/stats/views/callout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ define(['marionette', 'modules/stats/collections/callouts', 'views/table'], func
initialize: function(options) {
var columns = [
{ name: 'username', label: 'User', cell: 'string', editable: false },
{ name: 'logcontent', label: 'Description', cell: 'string', editable: false },
{ name: 'intime', label: 'In Time', cell: 'string', editable: false },
{ name: 'hometime', label: 'Out Time', cell: 'string', editable: false },
{ name: 'hometime', label: 'Time', cell: 'string', editable: false },
]

this.collection = new Callouts(null, { visit: options.visit })
Expand All @@ -27,4 +25,4 @@ define(['marionette', 'modules/stats/collections/callouts', 'views/table'], func
},
})

})
})
6 changes: 3 additions & 3 deletions client/src/js/modules/stats/views/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ define(['marionette',
this.bd.show(new BreakdownView({ model: this.getOption('breakdown'), params: this.getOption('params') }))
this.det.show(new DetailsView({ model: this.getOption('breakdown') }))
this.hrs.show(new HourliesView({ visit: this.model.get('VISIT') }))
if (app.staff) this.call.show(new EHCLogView({ visit: this.model.get('VISIT') }))
if (app.staff) this.ehc.show(new CalloutView({ visit: this.model.get('VISIT') }))
if (app.staff) this.ehc.show(new EHCLogView({ visit: this.model.get('VISIT') }))
if (app.staff) this.call.show(new CalloutView({ visit: this.model.get('VISIT') }))

this.pie = new PieView({ visit: this.model.get('VISIT'), el: this.$el.find('#visit_pie') })

Expand All @@ -57,4 +57,4 @@ define(['marionette',
},
})

})
})
4 changes: 2 additions & 2 deletions client/src/js/templates/stats/visit.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ <h1>Robot Dewar Usage</h1>
<div class="roboterrors"></div>
<div class="faults"></div>


<div class="callouts"></div>
<div class="ehclogs"></div>
<div class="callouts"></div>

0 comments on commit 434281e

Please sign in to comment.