Skip to content

Commit

Permalink
Merge pull request #301 from DiamondLightSource/pre-release/2022-R3
Browse files Browse the repository at this point in the history
Release 2022-R3.1
  • Loading branch information
vonvick authored Jun 23, 2022
2 parents 5a76519 + 7be79a5 commit dab1ae9
Show file tree
Hide file tree
Showing 64 changed files with 1,981 additions and 662 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,3 @@ client/index.html

api/config.php
api/vendor
api/src/MockUAS.php

./idea
2 changes: 1 addition & 1 deletion api/src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ function pv($pvs, $full=false, $string=false) {
exec($bl_pv_prog . ($string ? ' -S' : '') .' ' . implode(' ', $pvs) . ' 2>/dev/null', $ret);
$output = array();
foreach ($ret as $i => $v) {
$lis = preg_split('/\s+/', $v);
$lis = preg_split('/\s+/', $v, 2);
$output[$lis[0]] = sizeof($lis) > 1 ? ($full ? array_slice($lis,1) : $lis[1]) : '';
}

Expand Down
91 changes: 53 additions & 38 deletions api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class Shipment extends Page
'NEWFACILITYCODE' => '([\w-])+',
'TRACKINGNUMBERTOSYNCHROTRON' => '\w+',
'TRACKINGNUMBERFROMSYNCHROTRON' => '\w+',
'FIRSTEXPERIMENTID' => '\d+',
'FIRSTEXPERIMENTID' => '\d+|^(?![\s\S])',
'SHIPPINGID' => '\d+',

'DEWARREGISTRYID' => '\d+',

'BARCODE' => '([\w-])+',
'LOCATION' => '[\w|\s|-]+',
'NEXTLOCATION' => '[\w|\s|-]+',
'NEXTLOCATION' => '\w+|^(?![\s\S])',
'STATUS' => '[\w|\s|-]+',

'PURCHASEDATE' => '\d+-\d+-\d+',
Expand All @@ -61,10 +61,10 @@ class Shipment extends Page
'GIVENNAME' => '.*',
'LABNAME' => '.*',
'LOCALCONTACT' => '[\w|\s+|-]+',
'NEXTLOCALCONTACT' => '[\w|\s+|-]+',
'NEXTLOCALCONTACT' => '\w+|^(?![\s\S])',
'PHONENUMBER' => '.*',
'VISIT' => '\w+\d+-\d+',
'NEXTVISIT' => '\w+\d+-\d+',
'NEXTVISIT' => '\w+\d+-\d+|^(?![\s\S])',
'AWBNUMBER' => '\w+',
'WEIGHT' => '\d+',

Expand Down Expand Up @@ -337,7 +337,7 @@ function _get_history() {
array_push($args, $start);
array_push($args, $end);

$rows = $this->db->paginate("SELECT s.shippingid, s.shippingname as shipment, CONCAT(CONCAT(CONCAT(p.proposalcode, p.proposalnumber), '-'), b.visit_number) as visit, b.beamlinename as bl, b.beamlineoperator as localcontact, h.dewarid, h.dewarstatus,h.storagelocation,TO_CHAR(h.arrivaldate, 'DD-MM-YYYY HH24:MI') as arrival
$rows = $this->db->paginate("SELECT s.shippingid, s.shippingname as shipment, CONCAT(CONCAT(CONCAT(p.proposalcode, p.proposalnumber), '-'), b.visit_number) as visit, b.beamlinename as bl, b.beamlineoperator as localcontact, h.dewarid, h.dewarstatus,h.storagelocation,TO_CHAR(h.arrivaldate, 'DD-MM-YYYY HH24:MI') as arrival, d.comments
FROM dewartransporthistory h
INNER JOIN dewar d ON d.dewarid = h.dewarid
INNER JOIN shipping s ON d.shippingid = s.shippingid
Expand Down Expand Up @@ -747,18 +747,18 @@ function _transfer_dewar() {
global $transfer_email;
if (!$this->has_arg('DEWARID')) $this->_error('No dewar specified');

$dew = $this->db->pq("SELECT d.dewarid,s.shippingid
FROM dewar d
INNER JOIN shipping s ON s.shippingid = d.shippingid
$dew = $this->db->pq("SELECT d.dewarid,s.shippingid
FROM dewar d
INNER JOIN shipping s ON s.shippingid = d.shippingid
INNER JOIN proposal p ON p.proposalid = s.proposalid
WHERE d.dewarid=:1 and p.proposalid=:2", array($this->arg('DEWARID'), $this->proposalid));

if (!sizeof($dew)) $this->_error('No such dewar');
else $dew = $dew[0];


$this->db->pq("INSERT INTO dewartransporthistory (dewartransporthistoryid,dewarid,dewarstatus,storagelocation,arrivaldate)
VALUES (s_dewartransporthistory.nextval,:1,'transfer-requested',:2,CURRENT_TIMESTAMP) RETURNING dewartransporthistoryid INTO :id",
VALUES (s_dewartransporthistory.nextval,:1,'transfer-requested',:2,CURRENT_TIMESTAMP) RETURNING dewartransporthistoryid INTO :id",
array($dew['DEWARID'], $this->arg('LOCATION')));

// Update dewar status to transfer-requested to keep consistent with history
Expand All @@ -768,23 +768,28 @@ function _transfer_dewar() {
$sessions = $this->db->pq("SELECT s.sessionid
FROM blsession s
INNER JOIN proposal p ON p.proposalid = s.proposalid
WHERE p.proposalid=:1 AND CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) LIKE :2",
WHERE p.proposalid=:1 AND CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) LIKE :2",
array($this->proposalid, $this->arg('NEXTVISIT')));

if (sizeof($sessions)) {
$this->db->pq("UPDATE dewar SET firstexperimentid=:1 WHERE dewarid=:2",
array($sessions[0]['SESSIONID'], $dew['DEWARID']));
}
$sessionId = !empty($sessions) ? $sessions[0]['SESSIONID'] : NULL;

$this->db->pq("UPDATE dewar SET firstexperimentid=:1 WHERE dewarid=:2", array($sessionId, $dew['DEWARID']));
}


$email = new Email('dewar-transfer', '*** Dewar ready for internal transfer ***');

$nextLocalContact = $this->arg('NEXTLOCALCONTACT');
$newContact = !empty($nextLocalContact) ? $nextLocalContact : $this->arg('LOCALCONTACT');
$nextLocation = $this->arg('NEXTLOCATION');

$this->args['LCEMAIL'] = $this->_get_email_fn($this->arg('LOCALCONTACT'));
$this->args['LCNEXTEMAIL'] = $this->_get_email_fn($this->arg('NEXTLOCALCONTACT'));
$this->args['LCNEXTEMAIL'] = $this->_get_email_fn($newContact);
$this->args['NEXTLOCATION'] = !empty($nextLocation) ? $nextLocation : $this->arg('LOCATION');

$data = $this->args;
if (!array_key_exists('FACILITYCODE', $data)) $data['FACILITYCODE'] = '';
$email->data = $data;
$email->data = $data;

$recpts = $transfer_email.', '.$this->arg('EMAILADDRESS');
if ($this->args['LCEMAIL']) $recpts .= ', '.$this->arg('LCEMAIL');
Expand Down Expand Up @@ -1074,8 +1079,12 @@ function _add_dewar() {
$from = $this->has_arg('TRACKINGNUMBERFROMSYNCHROTRON') ? $this->arg('TRACKINGNUMBERFROMSYNCHROTRON') : '';
$fc = $this->has_arg('FACILITYCODE') ? $this->arg('FACILITYCODE') : '';
$wg = $this->has_arg('WEIGHT') ? $this->arg('WEIGHT') : $dewar_weight;

$exp = $this->has_arg('FIRSTEXPERIMENTID') ? $this->arg('FIRSTEXPERIMENTID') : null;
$exp = null;

if ($this->has_arg('FIRSTEXPERIMENTID')) {
$experimentId = $this->arg('FIRSTEXPERIMENTID');
$exp = !empty($experimentId) ? $this->arg('FIRSTEXPERIMENTID') : NULL;
}

$this->db->pq("INSERT INTO dewar (dewarid,code,trackingnumbertosynchrotron,trackingnumberfromsynchrotron,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,weight)
VALUES (s_dewar.nextval,:1,:2,:3,:4,CURRENT_TIMESTAMP,'opened',:5,:6,:7) RETURNING dewarid INTO :id",
Expand Down Expand Up @@ -1136,40 +1145,46 @@ function _update_shipment() {
function _update_dewar() {
if (!$this->has_arg('prop')) $this->_error('No proposal specified');
if (!$this->has_arg('did')) $this->_error('No dewar id specified');
$dewar = $this->db->pq("SELECT d.dewarid,d.shippingid FROM dewar d
INNER JOIN shipping s ON d.shippingid = s.shippingid

$dewar = $this->db->pq("SELECT d.dewarid,d.shippingid FROM dewar d
INNER JOIN shipping s ON d.shippingid = s.shippingid
WHERE s.proposalid = :1 AND d.dewarid = :2", array($this->proposalid,$this->arg('did')));

if (!sizeof($dewar)) $this->_error('No such dewar');

if ($this->has_arg('FIRSTEXPERIMENTID')) {
$chk = $this->db->pq("SELECT 1
FROM shippinghassession
WHERE shippingid=:1 AND sessionid=:2", array($dewar[0]['SHIPPINGID'], $this->arg('FIRSTEXPERIMENTID')));
$experimentId = $this->arg('FIRSTEXPERIMENTID');
$sessionId = !empty($experimentId) ? $this->arg('FIRSTEXPERIMENTID') : NULL;
$chk = $this->db->pq("SELECT 1 FROM shippinghassession WHERE shippingid=:1 AND sessionid=:2", array($dewar[0]['SHIPPINGID'], $this->arg('FIRSTEXPERIMENTID')));

if (!sizeof($chk)) {
$this->db->pq("INSERT INTO shippinghassession (shippingid, sessionid)
VALUES (:1,:2)", array($dewar[0]['SHIPPINGID'], $this->arg('FIRSTEXPERIMENTID')));
if (!sizeof($chk) && !is_null($sessionId)) {
$this->db->pq("INSERT INTO shippinghassession (shippingid, sessionid) VALUES (:1,:2)", array($dewar[0]['SHIPPINGID'], $this->arg('FIRSTEXPERIMENTID')));
}
}

$fields = array('CODE', 'TRACKINGNUMBERTOSYNCHROTRON', 'TRACKINGNUMBERFROMSYNCHROTRON', 'FIRSTEXPERIMENTID', 'FACILITYCODE', 'WEIGHT');
foreach ($fields as $f) {
if ($this->has_arg($f)) {
$this->db->pq("UPDATE dewar SET $f=:1 WHERE dewarid=:2", array($this->arg($f), $this->arg('did')));
if ($f === 'FIRSTEXPERIMENTID') {
$experimentId = $this->arg('FIRSTEXPERIMENTID');
$sessionId = !empty($experimentId) ? $this->arg('FIRSTEXPERIMENTID') : NULL;
$this->db->pq("UPDATE dewar SET $f=:1 WHERE dewarid=:2", array($sessionId, $this->arg('did')));

if ($f == 'FIRSTEXPERIMENTID') {
$visit = $this->db->pq("SELECT CONCAT(CONCAT(CONCAT(p.proposalcode, p.proposalnumber), '-'), s.visit_number) as visit
FROM blsession s
INNER JOIN proposal p ON p.proposalid = s.proposalid
WHERE s.sessionid=:1", array($this->arg($f)));
$visit = $this->db->pq("SELECT CONCAT(CONCAT(CONCAT(p.proposalcode, p.proposalnumber), '-'), s.visit_number) as visit
FROM blsession s
INNER JOIN proposal p ON p.proposalid = s.proposalid
WHERE s.sessionid=:1", array($sessionId));

if (sizeof($visit)) {
$this->_output(array($f => $this->arg($f), 'EXP' => $visit[0]['VISIT']));
$this->_output(array($f => $sessionId, 'EXP' => $visit[0]['VISIT']));
} else {
$this->_output(1);
}
} else {
$this->db->pq("UPDATE dewar SET $f=:1 WHERE dewarid=:2", array($this->arg($f), $this->arg('did')));
$this->_output(array($f => $this->arg($f)));
}

} else $this->_output(array($f => $this->arg($f)));
}
}
}
Expand Down
43 changes: 29 additions & 14 deletions api/src/Page/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Status extends Page
'st' => '\d\d-\d\d-\d\d\d\d',
'en' => '\d\d-\d\d-\d\d\d\d',
'c' => '\d+',
'mmsg' => '\d+', // Used for fetching only the Machine Status Message for Beamline PVs
);

public static $dispatch = array(array('/pvs/:bl', 'get', '_get_pvs'),
Expand Down Expand Up @@ -42,24 +43,38 @@ function _get_pvs() {

if (!$this->has_arg('bl')) $this->_error('No beamline specified');

$ring_pvs = array('Ring Current' => 'SR-DI-DCCT-01:SIGNAL',
//'Ring State' => 'CS-CS-MSTAT-01:MODE',
'Refill' => 'SR-CS-FILL-01:COUNTDOWN'
);

$ring_pvs = array(
'Ring Current' => 'SR-DI-DCCT-01:SIGNAL',
//'Ring State' => 'CS-CS-MSTAT-01:MODE',
'Refill' => 'SR-CS-FILL-01:COUNTDOWN',
);

$messages_pvs = array(
'Machine Status 1' => 'CS-CS-MSTAT-01:MESS01',
'Machine Status 2' => 'CS-CS-MSTAT-01:MESS02',
);

if (!array_key_exists($this->arg('bl'), $bl_pvs)) $this->_error('No such beamline');

$pvs = array_merge($ring_pvs, $bl_pvs[$this->arg('bl')]);
$vals = $this->pv(array_values($pvs));


$return = array();
foreach ($pvs as $k => $pv) {
if ($k == 'Hutch') $return[$k] = $vals[$pv] == 7 ? 'Open' : 'Locked';
else $return[$k] = $vals[$pv];

if ($this->has_arg('mmsg')) {
$messages_val = $this->pv(array_values($messages_pvs), false, true);

foreach ($messages_pvs as $k => $v) {
$return[$k] = $messages_val[$v];
}
} else {
$pvs = array_merge($ring_pvs, $bl_pvs[$this->arg('bl')]);
$vals = $this->pv(array_values($pvs), false, false);

foreach ($pvs as $k => $pv) {
if ($k == 'Hutch') $return[$k] = $vals[$pv] == 7 ? 'Open' : 'Locked';
else $return[$k] = $vals[$pv];
}
}

$this->_output($return);

}


Expand Down
49 changes: 15 additions & 34 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions client/src/css/partials/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,18 @@ div.status.oavs {
}
}

.streamed-pvs {
.pv {
&.on {
background: $content-active;
}

&.off {
background: $content-inactive;
}
}
}


.log.gda ul {
height: 250px;
Expand Down
48 changes: 48 additions & 0 deletions client/src/js/app/components/filter-pills.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<template>
<div class="tw-flex tw-w-full">
<div
class="tw-rounded tw-p-2 tw-mx-1"
v-for="(filter, filterIndex) in filterData"
:key="filterIndex"
:class="{
'tw-bg-content-filter-background': selected !== retrieveFilterValue(filter),
'tw-bg-content-filter-current-background': selected === retrieveFilterValue(filter) ,
'tw-cursor-pointer': selected !== retrieveFilterValue(filter)
}"
@click="onSelect(valueField ? filter[valueField] : filter)">
{{ textField ? filter[textField] : filter }}
</div>
</div>
</template>
<script>
export default {
name: 'filter-pills',
props: {
filterData: {
type: Array,
required: true
},
textField: {
type: String,
},
valueField: {
type: String,
},
selected: {
type: [Object, Number, String],
required: true
}
},
methods: {
onSelect(value) {
if (value !== this.selected) {
this.$emit('filter-selected', value)
}
},
retrieveFilterValue(filter) {
return this.valueField ? filter[this.valueField] : filters
}
}
}
</script>
Loading

0 comments on commit dab1ae9

Please sign in to comment.