diff --git a/api/src/Authentication/Type/OIDC.php b/api/src/Authentication/Type/OIDC.php index 9b844a2a9..ecda25e9c 100644 --- a/api/src/Authentication/Type/OIDC.php +++ b/api/src/Authentication/Type/OIDC.php @@ -132,8 +132,13 @@ function authenticateByCode($code) 'samesite' => 'Strict' ); - setcookie($cookie_key, $token, $cookieOpts); - return $this->getUser($token); + $user = $this->getUser($token); + + if ($user) { + setcookie($cookie_key, $token, $cookieOpts); + } + + return $user; } function logout() diff --git a/api/src/Controllers/AuthenticationController.php b/api/src/Controllers/AuthenticationController.php index 82744bec4..f819a4836 100644 --- a/api/src/Controllers/AuthenticationController.php +++ b/api/src/Controllers/AuthenticationController.php @@ -84,6 +84,8 @@ function check() { $this->returnResponse(200, $this->generateJwtToken($userId)); } + } else if ($userId === null) { + $this->returnError(403, 'User not recognised'); } $this->returnError(400, 'No previous session'); } @@ -358,7 +360,7 @@ function authorise() if ($cas_sso) { header('Location: ' . $this->authenticateByType()->authorise()); - $this->returnResponse(302, array('status' => "Redirecting to CAS")); + $this->returnResponse(302, array('status' => "Redirecting to provider")); } else { $this->returnError(501, "SSO not configured"); } @@ -379,7 +381,7 @@ function authenticateByCode() } $this->returnResponse(200, $this->generateJwtToken($fedid)); } else { - $this->returnError(401, 'Invalid Credentials'); + $this->returnError(403, 'User not recognised'); } } diff --git a/api/src/Page/DC.php b/api/src/Page/DC.php index 197782c48..19ad3fcc4 100644 --- a/api/src/Page/DC.php +++ b/api/src/Page/DC.php @@ -1212,24 +1212,6 @@ function _mca($id) $this->db->close(); $data = array(array(), array()); - if (file_exists($info['DAT'])) { - $dat = explode("\n", file_get_contents($info['DAT'])); - - foreach ($dat as $i => $d) { - if ($i > 2 && $d) { - list($e, $v) = preg_split('/\s+/', trim($d)); - if ($i % 2 == 1) { - if (floatval($e) <= $info['ENERGY']) { - if (floatval($e) > ($info['ENERGY'] - 1100)) - array_push($data[1], array(floatval($e), floatval($v))); - else - array_push($data[0], array(floatval($e), floatval($v))); - } - } - } - } - } - # pymca $results = str_replace('.mca', '.results.dat', preg_replace('/(data\/\d\d\d\d\/\w\w\d+-\d+)/', '\1/processed/pymca', $info['DIR'])); @@ -1238,22 +1220,56 @@ function _mca($id) $elements = array(); $el_no_match = array(); $max_counts = 0; + $line_number = 0; + $max_elements = 5; + $compton_cutoff = $info['ENERGY'] - 1100; if (file_exists($results)) { $dat = explode("\n", file_get_contents($results)); - foreach ($dat as $i => $d) { - if ($i < 5) { + foreach ($dat as $d) { + if (empty($d) || strpos($d, '#') === 0) { + if (strpos($d, 'COMPTON_CUTOFF_EV') !== false) { + $parts = explode('COMPTON_CUTOFF_EV', $d); + $compton_cutoff = floatval(trim($parts[1])); + } + continue; + } + if ($line_number < $max_elements) { $l = explode(' ', $d); - if ($i == 0) + if ($line_number == 0) { $max_counts = floatval($l[1]); + } if (array_key_exists($l[0], $el_to_en)) { $els = $el_to_en[$l[0]]; $elements[$l[0]] = array(array_map('floatval', $els), floatval($l[1]), floatval($l[2])); - } else + } else { array_push($el_no_match, $l[0]); + } + $line_number++; + } else { + break; } } } + + if (file_exists($info['DAT'])) { + $dat = explode("\n", file_get_contents($info['DAT'])); + + foreach ($dat as $i => $d) { + if ($i > 2 && $d) { + list($e, $v) = preg_split('/\s+/', trim($d)); + if ($i % 2 == 1) { + if (floatval($e) <= $info['ENERGY']) { + if (floatval($e) > $compton_cutoff) + array_push($data[1], array(floatval($e), floatval($v))); + else + array_push($data[0], array(floatval($e), floatval($v))); + } + } + } + } + } + array_push($data, $elements); array_push($data, $el_no_match); array_push($data, $max_counts); diff --git a/api/src/Page/Process.php b/api/src/Page/Process.php index 317c0b19d..c44c1c18a 100644 --- a/api/src/Page/Process.php +++ b/api/src/Page/Process.php @@ -435,9 +435,15 @@ function _pipelines() { $status = $this->has_arg('pipelinestatus') ? $this->arg('pipelinestatus') : null; $category = $this->has_arg('category') ? $this->arg('category') : null; + // allow more than one status if ($status) { - $where .= ' AND pp.pipelinestatus=:'.(sizeof($args)+1); - array_push($args, $this->arg('pipelinestatus')); + $status_queries = array(); + $status_array = is_array($status) ? $status : array($status); + foreach ($status_array as $s) { + array_push($args, $s); + array_push($status_queries, 'pp.pipelinestatus=:' . count($args)); + } + $where .= ' AND (' . implode(' OR ', $status_queries) . ')'; } if ($category) { $where .= ' AND ppc.name=:'.(sizeof($args)+1); diff --git a/api/src/Page/Processing.php b/api/src/Page/Processing.php index fc22b1651..d03428fd2 100644 --- a/api/src/Page/Processing.php +++ b/api/src/Page/Processing.php @@ -32,7 +32,7 @@ class Processing extends Page { 'n' => '\d+', 'sampleGroupId' => '\d+', 'resultCount' => '\d+', - 'pipeline' => '[\w\s\+]+', + 'pipeline' => '\d+', 'spacegroup' => '(\w|\s|\-|\/)+', 'resolution' => '[\d\.]+', 'completeness' => '[\d\.]+', @@ -403,7 +403,7 @@ function _results_for_visit() { if ($this->has_arg('pipeline')) { $st = sizeof($args); - $where .= " AND app.processingprograms = :" . ($st + 1); + $where .= " AND app.processingpipelineid = :" . ($st + 1); array_push($args, $this->arg('pipeline')); } diff --git a/api/src/Page/Proposal.php b/api/src/Page/Proposal.php index bfe8ed10f..47a32bc5d 100644 --- a/api/src/Page/Proposal.php +++ b/api/src/Page/Proposal.php @@ -156,7 +156,9 @@ function _get_proposals($id = null) array_push($args, $id); } - if ($this->staff) { + if ($this->user->hasPermission('all_dewars')) { + // allow to see shipments on all proposals + } else if ($this->staff) { if (!$this->user->hasPermission('super_admin')) { $bls = array(); foreach ($this->user->perms as $p) { @@ -172,8 +174,6 @@ function _get_proposals($id = null) $where .= " AND (shp.personid=:" . (sizeof($args) + 1) . " OR s.beamlinename in ('" . implode("','", $bls) . "'))"; array_push($args, $this->user->personId); } - } else if ($this->user->hasPermission('all_dewars')) { - // allow to see shipments on all proposals } else { $where = " INNER JOIN session_has_person shp ON shp.sessionid = s.sessionid " . $where; $where .= " AND shp.personid=:" . (sizeof($args) + 1); @@ -919,7 +919,9 @@ function _lookup() $args = array(); - if ($this->staff) { + if ($field == 'SHIPPINGID' && $this->user->hasPermission('all_dewars')) { + // allow to see shipments + } else if ($this->staff) { if (!$this->user->hasPermission('super_admin')) { $bls = array(); foreach ($this->user->perms as $p) { @@ -933,8 +935,6 @@ function _lookup() $where .= " AND ses.beamlinename in ('" . implode("','", $bls) . "')"; } - } else if ($field == 'SHIPPINGID' && $this->user->hasPermission('all_dewars')) { - // allow to see shipments } else { $where = " INNER JOIN session_has_person shp ON shp.sessionid = ses.sessionid " . $where; $where .= " AND shp.personid=:" . (sizeof($args) + 1); diff --git a/api/tests/Controllers/AuthenticationControllerTest.php b/api/tests/Controllers/AuthenticationControllerTest.php index 4ed2089b0..67c7b7061 100644 --- a/api/tests/Controllers/AuthenticationControllerTest.php +++ b/api/tests/Controllers/AuthenticationControllerTest.php @@ -159,7 +159,7 @@ public function testCodeAuthenticationInitiallyFailsWhenAuthenticationTypeReturn }); $this->assertContains('Content-Type: application/json', Output::$headers); - $this->assertContains('X-PHP-Response-Code: 401', Output::$headers); + $this->assertContains('X-PHP-Response-Code: 403', Output::$headers); } public function testCodeAuthenticationWhenGetValidFedIdReturnsSuccess(): void diff --git a/client/src/js/app/store/modules/store.auth.js b/client/src/js/app/store/modules/store.auth.js index 8c141106a..0379b545b 100644 --- a/client/src/js/app/store/modules/store.auth.js +++ b/client/src/js/app/store/modules/store.auth.js @@ -125,7 +125,7 @@ const auth = { }, error: function(req, status, error) { commit('authError') - reject(error) + reject(req) }, complete: function() { commit('loading', false, { root: true }) diff --git a/client/src/js/app/views/login.vue b/client/src/js/app/views/login.vue index a30993499..b43a527a9 100644 --- a/client/src/js/app/views/login.vue +++ b/client/src/js/app/views/login.vue @@ -199,7 +199,7 @@ export default { .dispatch("auth/getToken", token) .then(() => this.$router.push(actualRedirectUrl)) .catch((e) => { - if (e === "Forbidden") { + if (e.status === 403) { this.authError = "not-recognised"; } }); diff --git a/client/src/js/modules/dc/views/dcbase.js b/client/src/js/modules/dc/views/dcbase.js index 72c58aba2..328abe49c 100644 --- a/client/src/js/modules/dc/views/dcbase.js +++ b/client/src/js/modules/dc/views/dcbase.js @@ -87,6 +87,7 @@ define(['marionette', console.log('updateDCC', this.ui.dcglink, this.model) if (this.model.get('DCC') > 1) { this.$el.find('li.group').show() + this.$el.find('.gridsize2').show() this.$el.find('.dcglink').show() this.$el.find('.dclink').hide() this.$el.find('.reprocess').hide() @@ -95,6 +96,7 @@ define(['marionette', } } else { this.$el.find('li.group').hide() + this.$el.find('.gridsize2').hide() this.$el.find('.dcglink').hide() this.$el.find('.dclink').show() this.$el.find('.reprocess').show() diff --git a/client/src/js/modules/dc/views/grid.js b/client/src/js/modules/dc/views/grid.js index e3049c712..a56aed58b 100644 --- a/client/src/js/modules/dc/views/grid.js +++ b/client/src/js/modules/dc/views/grid.js @@ -46,6 +46,7 @@ define(['marionette', xrcholder: '.holder h1.xrc', apholder: '.holder h1.ap', gridsize: '.gridsize', + gridsize2: '.gridsize2', }, toggleZoom: function(e) { @@ -126,9 +127,8 @@ define(['marionette', if (this.ui.bx.text) this.ui.by.text((gi.get('DY_MM')*1000).toFixed(0)) if (gi.get('STEPS_Y') > 10 && this.ui.zoom.show) this.ui.zoom.show() - var gridsize = gi.get('STEPS_X') + ' x ' + gi.get('STEPS_Y') - if (gi.get('STEPS_Z')) { gridsize += ' x ' + gi.get('STEPS_Z') } - this.ui.gridsize.html(gridsize) + this.ui.gridsize.html(gi.get('STEPS_X') + ' x ' + gi.get('STEPS_Y')) + if (gi.get('STEPS_Z')) { this.ui.gridsize2.html(' x ' + gi.get('STEPS_Z')) } }, checkXRCandAP: function() { diff --git a/client/src/js/modules/dc/views/summary.js b/client/src/js/modules/dc/views/summary.js index 00867d6d4..70693afd6 100644 --- a/client/src/js/modules/dc/views/summary.js +++ b/client/src/js/modules/dc/views/summary.js @@ -6,12 +6,14 @@ define(['backbone', 'utils/table', 'utils/kvcollection', 'collections/spacegroups', + 'collections/processingpipelines', 'templates/dc/summary.html'], function(Backbone, Marionette, Backgrid, TableView, utils, table, KVCollection, Spacegroups, + ProcessingPipelines, template) { var Pipelines = Backbone.Collection.extend(_.extend({ @@ -186,19 +188,20 @@ define(['backbone', this.updateData() }, + updatePipelines: function() { + this.ui.pipeline.html(''+this.processing_pipelines.opts()) + }, + onRender: function() { this.showSpaceGroups() - this.pipelines = new Pipelines([ - { NAME: 'Any', VALUE: '' }, - { NAME: 'Xia2 DIALS', VALUE: 'xia2 dials' }, - { NAME: 'Xia2 3dii', VALUE: 'xia2 3dii' }, - { NAME: 'Fast DP', VALUE: 'fast_dp' }, - { NAME: 'autoPROC', VALUE: 'autoPROC' }, - { NAME: 'autoPROC+STARANISO', VALUE: 'autoPROC+STARANISO' }, - ]) - - this.ui.pipeline.html(this.pipelines.opts()) + this.processing_pipelines = new ProcessingPipelines() + this.processing_pipelines.fetch({ + data: { + category: 'processing', + pipelinestatus: ['automatic', 'optional'], + } + }).done(this.updatePipelines.bind(this)); var columns = [ { label: '', cell: table.TemplateCell, editable: false, template: ' View Data Collection' }, diff --git a/client/src/js/modules/shipment/views/shipments.js b/client/src/js/modules/shipment/views/shipments.js index 3693de797..c687e24ba 100644 --- a/client/src/js/modules/shipment/views/shipments.js +++ b/client/src/js/modules/shipment/views/shipments.js @@ -40,10 +40,12 @@ define(['marionette', return Marionette.LayoutView.extend({ className: 'content', - template: '

Shipments

This page shows a list of shipments associated with the currently selected proposal

In order to register your samples you need to create a shipment. Shipments contain dewars, dewars contain containers, and containers individual samples. These can be created sequentially by viewing a particular shipment

Add Shipment
', + template: '

Shipments

eBIC is switching to SCAUP for shipments. Click here to select a session and create a new shipment.

This page shows a list of shipments associated with the currently selected proposal

In order to register your samples you need to create a shipment. Shipments contain dewars, dewars contain containers, and containers individual samples. These can be created sequentially by viewing a particular shipment

Add Shipment
', regions: { 'wrap': '.wrapper' }, ui: { add: 'a.add', + ebicBanner: 'div#ebic-banner', + ebicLink: 'a#ebic-link' }, initialize: function(options) { @@ -71,6 +73,10 @@ define(['marionette', onRender: function() { if (app.proposal && app.proposal.get('ACTIVE') != 1) this.ui.add.hide() + if (app.proposal.get("TYPES").includes("em") && "em" in app.options.get("redirects")) { + this.ui.ebicBanner.show(); + this.ui.ebicLink.prop("href", `${app.options.get("redirects").em }/proposals/${app.proposal.get("PROPOSAL")}`); + } this.wrap.show(this.table) } }) diff --git a/client/src/js/templates/dc/grid.html b/client/src/js/templates/dc/grid.html index fe695c959..3ef68d31c 100644 --- a/client/src/js/templates/dc/grid.html +++ b/client/src/js/templates/dc/grid.html @@ -13,7 +13,7 @@

  • Transmission: <%-TRANSMISSION%>%
  • Beamsize: <%-BSX%>x<%-BSY%>μm
  • Boxsize: xμm
  • -
  • Grid scan size:
  • +
  • Grid scan size:
  • Comment: <%-COMMENTS%>
  • <% if (!STATE) { %>
  • Status: Stopped
  • <% } %>