Skip to content

Commit

Permalink
Merge pre-release/2024-R4.4 into master (#849)
Browse files Browse the repository at this point in the history
* LIMS-1003: Fix searching of container inspections (#825)

Co-authored-by: Mark Williams <[email protected]>

* LIMS-380: Fix position of autoPROC images (#831)

* LIMS-380: Fix position of autoPROC images

* LIMS-380: Just use iframe size of 98%

* Set width/height to percentage value (#838)

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: Guilherme Francisco <[email protected]>

* LIMS-1430: Fix bugs on prepare for data collection page (#829)

* LIMS-1430: Allow queuing even if no visible samples

* LIMS-1430: Show number of samples to queue

* LIMS-1430: Watch all subsamples for changes

* LIMS-1430: Remove TODO list

* LIMS-1430: Display number is of data collections, not samples

* LIMS-1430: Dont allow queueing if hidden data collections are invalid

* Update client/src/js/modules/imaging/views/queuecontainer.js

Co-authored-by: Guilherme Francisco <[email protected]>

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: Guilherme Francisco <[email protected]>

* LIMS-1390: Fix searching of data collection groups (#833)

Co-authored-by: Mark Williams <[email protected]>

* LIMS-1286: Show ERA status on calendar and visits list (#834)

Co-authored-by: Mark Williams <[email protected]>

* LIMS-1354: Migrate from ActiveMQ to RabbitMQ (#826)

* LIMS-1354: Migrate from ActiveMQ to RabbitMQ

* Unwrap try...catch

* Add routing_key and vhost

* Add polyfill for BCMath as php-bcmath extension is not installed but required by php-amqplib for AMQP

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: Guilherme Francisco <[email protected]>
Co-authored-by: James Hall <[email protected]>
  • Loading branch information
4 people authored Oct 22, 2024
1 parent 087beda commit f7780e9
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 82 deletions.
5 changes: 3 additions & 2 deletions api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
"mpdf/mpdf": "8.1.2",
"ralouphie/getallheaders": "2.0.5",
"slim/slim": "2.6.2",
"stomp-php/stomp-php": "3.0.6",
"php-amqplib/php-amqplib": "^2.0",
"symfony/http-foundation": "^5.4",
"symfony/filesystem": "^5.4",
"mpdf/qrcode": "^1.2",
"mtcmedia/dhl-api": "dev-master#9b4b6315",
"maennchen/zipstream-php": "2.1.0"
"maennchen/zipstream-php": "2.1.0",
"phpseclib/bcmath_compat": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 9 additions & 7 deletions api/src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -1109,14 +1109,16 @@ function _submit_zocalo_recipe($recipe, $parameters, $error_code = 500)
}


function _send_zocalo_message($zocalo_queue, $zocalo_message, $error_code = 500)
function _send_zocalo_message($rabbitmq_zocalo_vhost, $zocalo_message, $error_code = 500)
{
global
$zocalo_server,
$zocalo_username,
$zocalo_password;
$rabbitmq_zocalo_host,
$rabbitmq_zocalo_port,
$rabbitmq_zocalo_username,
$rabbitmq_zocalo_password,
$rabbitmq_zocalo_routing_key;

if (empty($zocalo_server) || empty($zocalo_queue))
if (empty($rabbitmq_zocalo_host) || empty($rabbitmq_zocalo_vhost))
{
$message = 'Zocalo server or queue not specified.';
error_log($message);
Expand All @@ -1129,8 +1131,8 @@ function _send_zocalo_message($zocalo_queue, $zocalo_message, $error_code = 500)
try
{
error_log("Sending message" . var_export($zocalo_message, true));
$queue = new Queue($zocalo_server, $zocalo_username, $zocalo_password);
$queue->send($zocalo_queue, $zocalo_message, true, $this->user->loginId);
$queue = new Queue($rabbitmq_zocalo_host, $rabbitmq_zocalo_port, $rabbitmq_zocalo_username, $rabbitmq_zocalo_password, $rabbitmq_zocalo_vhost);
$queue->send($zocalo_message, $rabbitmq_zocalo_routing_key);
}
catch (Exception $e)
{
Expand Down
13 changes: 7 additions & 6 deletions api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,14 @@ function _data_collections($single = null)
$s = str_replace('_', '$_', $this->arg('s'));

$st = sizeof($args) + 1;
$where .= " AND (lower(dc.filetemplate) LIKE lower(CONCAT(CONCAT('%',:$st),'%')) ESCAPE '$' OR lower(dc.imagedirectory) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 1) . "), '%')) ESCAPE '$' OR lower(smp.name) LIKE lower(CONCAT(CONCAT('%', :" . ($st + 2) . "), '%')) ESCAPE '$')";
$where2 .= " AND (lower(es.comments) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 3) . "), '%')) ESCAPE '$' OR lower(es.element) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 4) . "), '%')) ESCAPE '$' OR lower(smp.name) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 5) . "), '%')) ESCAPE '$')";
$where .= " AND (dc.filetemplate LIKE CONCAT('%',:$st,'%') ESCAPE '$' OR dc.imagedirectory LIKE CONCAT('%',:" . ($st + 1) . ",'%') ESCAPE '$' OR smp.name LIKE CONCAT('%', :" . ($st + 2) . ",'%') ESCAPE '$')";
$where2 .= " AND (es.comments LIKE CONCAT('%',:" . ($st + 3) . ",'%') ESCAPE '$' OR es.element LIKE CONCAT('%',:" . ($st + 4) . ",'%') ESCAPE '$' OR smp.name LIKE CONCAT('%',:" . ($st + 5) . ",'%') ESCAPE '$')";
$where3 .= ' AND r.robotactionid < 0';
$where4 .= " AND (lower(xrf.filename) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 6) . "), '%')) ESCAPE '$' OR lower(smp.name) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 7) . "), '%')) ESCAPE '$')";
$where4 .= " AND (xrf.filename LIKE CONCAT('%',:" . ($st + 6) . ",'%') ESCAPE '$' OR smp.name LIKE CONCAT('%',:" . ($st + 7) . ",'%') ESCAPE '$')";

for ($i = 0; $i < 8; $i++)
array_push($args, $s);

}

# Set Count field
Expand Down Expand Up @@ -511,9 +512,9 @@ function _data_collections($single = null)
// $this->db->set_debug(True);

// will want to support these too at some point
$where2 = ' AND es.energyscanid < 0';
$where3 = ' AND r.robotactionid < 0';
$where4 = ' AND xrf.xfefluorescencespectrumid < 0';
$where2 .= ' AND es.energyscanid < 0';
$where3 .= ' AND r.robotactionid < 0';
$where4 .= ' AND xrf.xfefluorescencespectrumid < 0';

if ($this->has_arg('dcg')) {
$where .= ' AND dc.datacollectiongroupid=:' . (sizeof($args) + 1);
Expand Down
11 changes: 5 additions & 6 deletions api/src/Page/Imaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ function _get_inspections()
$where .= " AND i.state='Completed'";
}

if ($this->has_arg('s')) {
$where .= " AND (CONCAT(p.proposalcode, p.proposalnumber) LIKE CONCAT('%', :" . (sizeof($args) + 1) . ", '%') OR c.code LIKE CONCAT('%', :" . (sizeof($args) + 2) . ", '%'))";
array_push($args, $this->arg('s'), $this->arg('s'));
}

$tot = $this->db->pq("SELECT count(i.containerinspectionid) as tot FROM containerinspection i
INNER JOIN container c ON c.containerid = i.containerid
INNER JOIN dewar d ON d.dewarid = c.dewarid
Expand Down Expand Up @@ -422,12 +427,6 @@ function _get_inspections()
$order = $cols[$this->arg('sort_by')] . ' ' . $dir;
}

if ($this->has_arg('s')) {
$where .= " AND (LOWER(CONCAT(p.proposalcode, p.proposalnumber)) LIKE LOWER(CONCAT(CONCAT('%', :" . (sizeof($args) + 1) . "), '%')) OR LOWER(c.code) LIKE LOWER(CONCAT(CONCAT('%', :" . (sizeof($args) + 2) . "), '%')))";
array_push($args, $this->arg('s'));
array_push($args, $this->arg('s'));
}

if ($this->has_arg('ty')) {
if ($this->arg('ty') == 'COMPLETED')
$where .= " AND i.state = 'Completed' AND i.manual=0";
Expand Down
4 changes: 2 additions & 2 deletions api/src/Page/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function _add_reprocessing_sweep($args) {

function _enqueue()
{
global $zocalo_mx_reprocess_queue;
global $rabbitmq_zocalo_vhost;

if (!$this->has_arg('PROCESSINGJOBID')) $this->_error('No processing job specified');

Expand All @@ -379,7 +379,7 @@ function _enqueue()
'ispyb_process' => intval($this->arg('PROCESSINGJOBID')),
)
);
$this->_send_zocalo_message($zocalo_mx_reprocess_queue, $message);
$this->_send_zocalo_message($rabbitmq_zocalo_vhost, $message);

$this->_output(new \stdClass);
}
Expand Down
1 change: 1 addition & 0 deletions api/src/Page/Proposal.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ function _get_visits($visit = null, $output = true)
s.beamlineoperator AS lc,
s.comments,
s.scheduled,
s.riskrating,
st.typename AS sessiontype,
DATE_FORMAT(s.startdate, '%d-%m-%Y %H:%i') AS startdate,
DATE_FORMAT(s.enddate, '%d-%m-%Y %H:%i') AS enddate,
Expand Down
46 changes: 19 additions & 27 deletions api/src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,34 @@

namespace SynchWeb;

use Stomp\Exception\StompException;
use Stomp\Stomp;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

class Queue
{
private $server, $username, $password;
private $host, $port, $username, $password, $vhost;

function __construct($server, $username, $password)
function __construct($host, $port, $username, $password, $vhost)
{
$this->server = $server;
$this->host = $host;
$this->port = $port;
$this->username = $username;
$this->password = $password;
$this->vhost = $vhost;
}

function send($queue, array $message, $persistent = false, $login = null)
function send(array $message, $routing_key)
{
try {
$connection = new Stomp($this->server);

$connection->connect($this->username, $this->password);

$connection->send(
$queue,
json_encode($message, JSON_UNESCAPED_SLASHES),
array(
'persistent' => ($persistent === true),
'synchweb.host' => gethostname(),
'synchweb.user' => $login,
)
);

$connection->disconnect();
} catch (StompException $e) {
/** @noinspection PhpUnhandledExceptionInspection */

throw $e;
}
$connection = new AMQPStreamConnection($this->host, $this->port, $this->username, $this->password, $this->vhost);
$channel = $connection->channel();

$msg = new AMQPMessage(
json_encode($message, JSON_UNESCAPED_SLASHES)
);

$channel->basic_publish($msg, null, $routing_key);

$channel->close();
$connection->close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
class="tw-no-underline tw-text-content-page-color"
>
{{ session['VISIT'] }}
</router-link> <span> ({{ session['LEN'] }})</span>
</router-link>
<span v-if="session['RISKRATING'] == 'Low'" title="Risk Rating: Low">&#128994;</span>
<span v-else-if="session['RISKRATING'] == 'Medium'" title="Risk Rating: Medium">&#128993;</span>
<span v-else-if="session['RISKRATING'] == 'High'" title="Risk Rating: High">&#128308;</span>
<span v-else title="No approved ERA">&#9899;</span>
<span> ({{ session['LEN'] }})</span>
</p>
<p class="tw-ml-2">
- {{ session['BEAMLINEOPERATOR'] }}
Expand Down Expand Up @@ -105,4 +110,4 @@ export default {
}
}
</script>
<style></style>
<style></style>
Loading

0 comments on commit f7780e9

Please sign in to comment.