Skip to content

Commit

Permalink
LIMS-1563 - Remove touchscreen app (#867)
Browse files Browse the repository at this point in the history
* Remove touchscreen app

* Remove redundant comment

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

---------

Co-authored-by: Mark W <[email protected]>
  • Loading branch information
gfrn and ndg63276 authored Dec 16, 2024
1 parent 506408e commit 1ca2c9c
Show file tree
Hide file tree
Showing 43 changed files with 3 additions and 29,151 deletions.
12 changes: 0 additions & 12 deletions api/config_sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,6 @@
$in_contacts = array('Ind Contact' => '[email protected]'
);


# Beamline Sample Registration Machines
# - Used for touchscreen application (unauthenticated)
$blsr = array('1.2.3.4', # my touchscreen computer
);

# Beamline Sample Registration IP -> Beamline mapping
# - Third part of ip is used to identify beamline
#  x.x.103.x => i03
$ip2bl = array(103 => 'i03',
);

# Barcode readers
# - These clients use the android app (unauthenticated)
$bcr = array('1.2.3.4', # my android device
Expand Down
26 changes: 1 addition & 25 deletions api/src/Controllers/AssignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AssignController extends Page

public static $arg_list = array('visit' => '\w+\d+-\d+', 'cid' => '\d+', 'did' => '\d+', 'pos' => '\d+', 'bl' => '[\w\-]+');

public static $dispatch = array(array('/visits(/:visit)', 'get', 'getBeamlineVisits'),
public static $dispatch = array(
array('/assign', 'get', 'assignContainer'),
array('/unassign', 'get', 'unassignContainer'),
array('/deact', 'get', 'deactivateDewar'),
Expand Down Expand Up @@ -74,30 +74,6 @@ function deactivateDewar()
}
}


# ------------------------------------------------------------------------
# Return visits for beamline
function getBeamlineVisits($visit = null)
{
$visits = $this->blsr_visits();

if ($visit)
{
foreach ($visits as $i => $v)
{
if ($v['VISIT'] == $visit)
{
$this->_output($v);
return;
}
}
$this->_error('No such visit');
}
else
$this->_output($visits);
}


# ------------------------------------------------------------------------
# Puck names from puck scanner
# BL03I-MO-ROBOT-01:PUCK_01_NAME
Expand Down
11 changes: 1 addition & 10 deletions api/src/Controllers/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function check()

private function checkAuthRequiredForSpecificSituations($parts): bool
{
global $blsr, $bcr, $img, $auto;
global $bcr, $img, $auto;

$need_auth = true;
# Work around to allow beamline sample registration without CAS authentication
Expand All @@ -102,10 +102,6 @@ private function checkAuthRequiredForSpecificSituations($parts): bool
# Allow formulatrix machines unauthorised access to inspections, certain IPs only
($parts[0] == 'imaging' && $parts[1] == 'inspection' && in_array($_SERVER["REMOTE_ADDR"], $img)) ||

# For use on the touchscreen computers in the hutch.
# Handles api calls: /assign/visits/<vist> e.g./assign/visits/mx1234-1
($parts[0] == 'assign' && $parts[1] == 'visits' && in_array($_SERVER["REMOTE_ADDR"], $blsr)) ||

# Allow barcode reader ips unauthorised access to add history
($parts[0] == 'shipment' && $parts[1] == 'dewars' && $parts[2] == 'history' && in_array($_SERVER["REMOTE_ADDR"], $bcr)) ||

Expand All @@ -129,11 +125,6 @@ private function checkAuthRequiredForSpecificSituations($parts): bool
else if (sizeof($parts) >= 2)
{
if (
# For use on the touchscreen computers in the hutch
# Handles api calls: /assign/assign, /assign/unassign, /assign/deact, /assign/visits
(($parts[0] == 'assign') && in_array($_SERVER["REMOTE_ADDR"], $blsr)) ||
(($parts[0] == 'shipment' && $parts[1] == 'containers') && in_array($_SERVER["REMOTE_ADDR"], $blsr)) ||

# Allow barcode reader unauthorised access, same as above, certain IPs only
($parts[0] == 'shipment' && $parts[1] == 'dewars' && in_array($_SERVER["REMOTE_ADDR"], $bcr)) ||

Expand Down
59 changes: 1 addition & 58 deletions api/src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,29 +222,8 @@ function auth($require_staff)
{
$auth = $this->staff;

// Beamline Sample Registration
}
else if ($this->blsr() && !$this->user->loginId)
{
$auth = false;

if ($this->has_arg('visit'))
{
$blsr_visits = array();
foreach ($this->blsr_visits() as $v)
array_push($blsr_visits, $v['VISIT']);

if (in_array($this->arg('visit'), $blsr_visits))
$auth = True;

}
else
{
$auth = true;
}

// Barcode Scanners
}
// Barcode Scanners
else if ($this->bcr() && !$this->user->loginId)
{
$auth = true;
Expand Down Expand Up @@ -761,42 +740,6 @@ function pro()
}


# ------------------------------------------------------------------------
# Beamline sample registration: Get Beamline from IP
function ip2bl()
{
global $ip2bl;
$parts = explode('.', $_SERVER['REMOTE_ADDR']);

if ($parts && sizeof($parts) > 1 && array_key_exists($parts[2], $ip2bl))
{
return $ip2bl[$parts[2]];
}
}


# Return visit list for blsr;
function blsr_visits()
{
$b = $this->ip2bl();

if (!$b)
return array();

$visits = $this->db->pq("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE TIMESTAMPDIFF('DAY', s.startdate, CURRENT_TIMESTAMP) < 1 AND TIMESTAMPDIFF('DAY', CURRENT_TIMESTAMP, s.enddate) < 2 AND s.beamlinename LIKE :1 ORDER BY s.startdate", array($b));
$v = $this->db->paginate("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE p.proposalcode LIKE 'cm' AND s.beamlinename LIKE :1 AND s.enddate <= CURRENT_TIMESTAMP ORDER BY s.startdate DESC", array($b, 0, 1));
$visits = array_merge($visits, $v);
return $visits;
}

# Beamline Sample Registration Machine
function blsr()
{
global $blsr;

return in_array($_SERVER['REMOTE_ADDR'], $blsr);
}

# Barcode Scanner Machines
function bcr()
{
Expand Down
50 changes: 0 additions & 50 deletions api/tests/Controllers/AssignControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ protected function setUp(): void
$this->assignController->shouldReceive('_setup_routes')->times(1)->andReturn(Mockery::self());
$this->assignController->__construct($this->slimStub, $this->dbStub, $this->user, $this->dataLayerStub);

global $ip2bl;
$ip2bl = array(103 => 'i03');

global $bl_puck_names;
$bl_puck_names = array(
'i03' => "BL03I-MO-ROBOT-01:PUCK_%'02d_NAME",
Expand Down Expand Up @@ -146,53 +143,6 @@ public function testDeactivateDewarReturnsOneWhenDewarFound(): void
$this->assertEquals(1, $response->getBody());
}

public function testGetBeamlineVisitsWithInvalidNoConfigReturnsNothing(): void
{
$response = $this->setUpCommonResponse();
$_SERVER['REMOTE_ADDR'] = '';

$this->assignController->getBeamlineVisits();
$this->assertEquals('[]', $response->getBody());
}

public function testGetBeamlineVisitsWithValidConfigReturnsNothing(): void
{
$response = $this->setUpCommonResponse();
$_SERVER['REMOTE_ADDR'] = 'www.diamond.103.com';
$this->dbStub->expects($this->exactly(1))->method('pq')->with("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE TIMESTAMPDIFF('DAY', s.startdate, CURRENT_TIMESTAMP) < 1 AND TIMESTAMPDIFF('DAY', CURRENT_TIMESTAMP, s.enddate) < 2 AND s.beamlinename LIKE :1 ORDER BY s.startdate", array('i03'))->willReturn(array());
$this->dbStub->expects($this->exactly(1))->method('paginate')->with("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE p.proposalcode LIKE 'cm' AND s.beamlinename LIKE :1 AND s.enddate <= CURRENT_TIMESTAMP ORDER BY s.startdate DESC", array('i03', 0, 1))->willReturn(array());

$this->assignController->getBeamlineVisits();
$this->assertEquals('[]', $response->getBody());
}

public function testGetBeamlineVisitsWithValidConfigAndVisitReturnsData(): void
{
$visitId = 123;
$response = $this->setUpCommonResponse();
$_SERVER['REMOTE_ADDR'] = 'www.diamond.103.com';
$result = ['VISIT' => $visitId, 'BL' => 'test03'];
$this->dbStub->expects($this->exactly(1))->method('pq')->with("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE TIMESTAMPDIFF('DAY', s.startdate, CURRENT_TIMESTAMP) < 1 AND TIMESTAMPDIFF('DAY', CURRENT_TIMESTAMP, s.enddate) < 2 AND s.beamlinename LIKE :1 ORDER BY s.startdate", array('i03'))->willReturn(array($result));
$this->dbStub->expects($this->exactly(1))->method('paginate')->with("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE p.proposalcode LIKE 'cm' AND s.beamlinename LIKE :1 AND s.enddate <= CURRENT_TIMESTAMP ORDER BY s.startdate DESC", array('i03', 0, 1))->willReturn(array());

$this->assignController->getBeamlineVisits($visitId);
$this->assertEquals('{"VISIT":123,"BL":"test03"}', $response->getBody());
}

public function testGetBeamlineVisitsWithValidConfigAndInvalidVisitReturnsError(): void
{
$visitId = 123;
$_SERVER['REMOTE_ADDR'] = 'www.diamond.103.com';
$result = ['VISIT' => 1230, 'BL' => 'test03'];
$this->dbStub->expects($this->exactly(1))->method('pq')->with("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE TIMESTAMPDIFF('DAY', s.startdate, CURRENT_TIMESTAMP) < 1 AND TIMESTAMPDIFF('DAY', CURRENT_TIMESTAMP, s.enddate) < 2 AND s.beamlinename LIKE :1 ORDER BY s.startdate", array('i03'))->willReturn(array($result));
$this->dbStub->expects($this->exactly(1))->method('paginate')->with("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE p.proposalcode LIKE 'cm' AND s.beamlinename LIKE :1 AND s.enddate <= CURRENT_TIMESTAMP ORDER BY s.startdate DESC", array('i03', 0, 1))->willReturn(array());

$this->slimStub->shouldReceive('halt')->times(1)->with(400, '{"status":400,"message":"No such visit"}')->andThrow(new \Exception);
$this->expectException(\Exception::class);

$this->assignController->getBeamlineVisits($visitId);
}

public function testGetPuckNamesWithoutPropThrowsError(): void
{
$this->slimStub->shouldReceive('halt')->times(1)->with(400, '{"status":400,"message":"No proposal specified"}')->andThrow(new \Exception);
Expand Down
Binary file removed client/touchscreen/images/ajax-loader.gif
Binary file not shown.
Binary file removed client/touchscreen/images/icons-18-black.png
Binary file not shown.
Binary file removed client/touchscreen/images/icons-18-white.png
Binary file not shown.
Binary file removed client/touchscreen/images/icons-36-black.png
Binary file not shown.
Binary file removed client/touchscreen/images/icons-36-white.png
Binary file not shown.
18 changes: 0 additions & 18 deletions client/touchscreen/index.html

This file was deleted.

18 changes: 0 additions & 18 deletions client/touchscreen/index.php

This file was deleted.

Loading

0 comments on commit 1ca2c9c

Please sign in to comment.