Skip to content

Commit

Permalink
Merge pull request #814 from salimkanoun/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
salimkanoun authored May 27, 2023
2 parents 8008cc4 + fe360d0 commit 0374907
Show file tree
Hide file tree
Showing 24 changed files with 280 additions and 398 deletions.
31 changes: 8 additions & 23 deletions BackEnd/adapter/bullAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,51 +155,36 @@ class Queue extends event.EventEmitter {

class Job {
constructor(bullJob) {
this._bullJob = bullJob;
this._bullJob._cachedState = null
this.bullJob = bullJob;
this.data = bullJob.data;
this._bullJob._cacheRes = null;
this._bullJob._cachedProgress = null;
}

async progress() {
if (this._bullJob._cachedProgress !== null) return this._bullJob._cachedProgress;
this._bullJob._cachedProgress = await this._bullJob.progress();
return this._bullJob._cachedProgress;
return await this.bullJob.progress();
}

async getState() {
if (this._bullJob._cachedState !== null) {
return this._bullJob._cachedState;
}
return await this._bullJob.getState().then(state => {
this._bullJob._cachedState = state;
return state;
});
return await this.bullJob.getState();
}

async finished() {
if (this._bullJob._cacheRes !== null) return this._bullJob._cacheRes;
return await this._bullJob.finished().then(res => {
this._bullJob._cacheRes = res;
return res;
});
return await this.bullJob.finished()
}

update(data) {
return this._bullJob.update(data);
return this.bullJob.update(data);
}

remove() {
return this._bullJob.remove()
return this.bullJob.remove()
}

moveToFailed(error) {
return this._bullJob.moveToFailed(error, true);
return this.bullJob.moveToFailed(error, true);
}

retry() {
return this._bullJob.retry();
return this.bullJob.retry();
}
}

Expand Down
2 changes: 0 additions & 2 deletions BackEnd/controllers/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ const getTasksOfType = async (req, res) => {
* @param {*} res request result
*/
const deleteTaskOfUser = async (req, res) => {

await Task.deleteTaskOfUser(req.params.username, req.params.type);
res.sendStatus(200);
}
Expand All @@ -158,7 +157,6 @@ const deleteTaskOfUser = async (req, res) => {
* @param {*} res request result
*/
const deleteTask = async (req, res) => {

await Task.deleteTask(req.params.id);
res.sendStatus(200);
}
Expand Down
5 changes: 3 additions & 2 deletions BackEnd/model/tasks/RetrieveTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ class RetrieveTask {
let validateJobs = await RetrieveTask._getValidationJobs(taskId);
let answerId = itemId.split(':')[1];
let answerNumber = itemId.split(':')[0];
let job = validateJobs.filter(job => job.data.item.AnswerNumber == answerNumber && job.data.item.AnswerId == answerId)[0];
let job = validateJobs.find(job => job.data.item.AnswerNumber == answerNumber && job.data.item.AnswerId == answerId);
if (!job) throw new OTJSNotFoundException("Item not found");
if (await job.getState() !== "failed") throw new OTJSBadRequestException("Can't retry a job that isn't failed");
const state = await job.getState()
if (state !== "failed") throw new OTJSBadRequestException("Can't retry a job that isn't failed");
await job.retry();
}

Expand Down
2 changes: 1 addition & 1 deletion BackEnd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"supertest": "^6.3.3",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^4.6.3",
"webpack": "^5.83.1",
"webpack": "^5.84.1",
"webpack-cli": "^5.1.1"
}
}
28 changes: 14 additions & 14 deletions BackEnd/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1020,10 +1020,10 @@ accepts@~1.3.8:
mime-types "~2.1.34"
negotiator "0.6.3"

acorn-import-assertions@^1.7.6:
version "1.7.6"
resolved "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.7.6.tgz"
integrity sha512-FlVvVFA1TX6l3lp8VjDnYYq7R1nyW6x3svAt4nDgrWQ9SBaSh9CnbwgSUTasgfNfOG5HlM1ehugCvM+hjo56LA==
acorn-import-assertions@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac"
integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==

acorn@^8.5.0, acorn@^8.7.1:
version "8.8.2"
Expand Down Expand Up @@ -2088,10 +2088,10 @@ encodeurl@~1.0.2:
resolved "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz"
integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=

enhanced-resolve@^5.14.0:
version "5.14.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.14.0.tgz#0b6c676c8a3266c99fa281e4433a706f5c0c61c4"
integrity sha512-+DCows0XNwLDcUhbFJPdlQEVnT2zXlCv7hPxemTz86/O+B/hCQ+mb7ydkPKiflpVraqLPCAfu7lDy+hBXueojw==
enhanced-resolve@^5.14.1:
version "5.14.1"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.14.1.tgz#de684b6803724477a4af5d74ccae5de52c25f6b3"
integrity sha512-Vklwq2vDKtl0y/vtwjSesgJ5MYS7Etuk5txS8VdKL4AOS1aUlD96zqIfsOSLQsdv3xgMRbtkWM8eG9XDfKUPow==
dependencies:
graceful-fs "^4.2.4"
tapable "^2.2.0"
Expand Down Expand Up @@ -5872,21 +5872,21 @@ webpack-sources@^3.2.3:
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==

webpack@^5.83.1:
version "5.83.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.83.1.tgz#fcb69864a0669ac3539a471081952c45b15d1c40"
integrity sha512-TNsG9jDScbNuB+Lb/3+vYolPplCS3bbEaJf+Bj0Gw4DhP3ioAflBb1flcRt9zsWITyvOhM96wMQNRWlSX52DgA==
webpack@^5.84.1:
version "5.84.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.84.1.tgz#d4493acdeca46b26ffc99d86d784cabfeb925a15"
integrity sha512-ZP4qaZ7vVn/K8WN/p990SGATmrL1qg4heP/MrVneczYtpDGJWlrgZv55vxaV2ul885Kz+25MP2kSXkPe3LZfmg==
dependencies:
"@types/eslint-scope" "^3.7.3"
"@types/estree" "^1.0.0"
"@webassemblyjs/ast" "^1.11.5"
"@webassemblyjs/wasm-edit" "^1.11.5"
"@webassemblyjs/wasm-parser" "^1.11.5"
acorn "^8.7.1"
acorn-import-assertions "^1.7.6"
acorn-import-assertions "^1.9.0"
browserslist "^4.14.5"
chrome-trace-event "^1.0.2"
enhanced-resolve "^5.14.0"
enhanced-resolve "^5.14.1"
es-module-lexer "^1.2.1"
eslint-scope "5.1.1"
events "^3.2.0"
Expand Down
6 changes: 3 additions & 3 deletions FrontEnd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.11.16",
"@mui/lab": "^5.0.0-alpha.130",
"@mui/material": "^5.13.1",
"@mui/lab": "^5.0.0-alpha.131",
"@mui/material": "^5.13.2",
"@tanstack/react-query": "^4.29.7",
"@tanstack/react-query-devtools": "^4.29.7",
"@tanstack/react-table": "^8.9.1",
Expand All @@ -21,7 +21,7 @@
"react-bootstrap": "^2.7.4",
"react-calendar": "^4.2.1",
"react-circular-progressbar": "^2.1.0",
"react-datepicker": "^4.11.0",
"react-datepicker": "^4.12.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-redux": "^8.0.5",
Expand Down
19 changes: 10 additions & 9 deletions FrontEnd/src/assets/styles/orthancToolsJs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,25 @@ body {
color: #636A6E;
}

.main-enter {
.otjsTransition-enter {
opacity: 0;
transform: scale(0.9);
}

.main-enter-active {
opacity: 0.5;
transition: opacity 1000ms
.otjsTransition-enter-active {
opacity: 1;
transform: translateX(0);
transition: opacity 300ms, transform 300ms;
}

.main-exit {
.otjsTransition-exit {
opacity: 1;
}

.main-exit-active {
.otjsTransition-exit-active {
opacity: 0;
transition: opacity 1500ms
transform: scale(0.9);
transition: opacity 300ms, transform 300ms;
}

.bg-green {
Expand Down Expand Up @@ -217,8 +220,6 @@ body {
padding: 3rem;
border-radius: 8px;
box-shadow: 4px 4px 4px $color-shadow;
transition: 1s;

.content {
h2 {
padding-bottom: 2rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default ({ robotId }) => {
if (isLoading) return <Spinner />

return (
<MyRobotTableStudies robotId={robotId} rows={data} />
<div style={{ overflowX: 'auto' }}>
<MyRobotTableStudies robotId={robotId} rows={data} />
</div>
)
}
10 changes: 6 additions & 4 deletions FrontEnd/src/components/Admin/Robots/RobotStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Spinner from '../../CommonComponents/Spinner';
import RobotTable from '../../CommonComponents/RessourcesDisplay/ReactTableV8/RobotTable';
import { Button, Modal } from 'react-bootstrap';
import AutoRetrieveRobotDetails from './AutoRetrieveRobotDetails';
import { errorMessage } from '../../../tools/toastify';


export default () => {
Expand All @@ -17,7 +18,6 @@ export default () => {
[keys.ROBOTS_KEY],
() => apis.retrieveRobot.getAllRobotsDetails(),
undefined,
undefined,
(answerData) => {
return answerData.map((robotJob) => {
return ({
Expand All @@ -44,7 +44,9 @@ export default () => {

const deleteJobHandler = useCustomMutation(
({ id }) => apis.retrieveRobot.deleteRobot(id),
[[keys.ROBOTS_KEY]]
[[keys.ROBOTS_KEY]],
undefined,
(error) => errorMessage(error?.data?.errorMessage ?? 'Cannot delete robot')
)

const validateJobHandler = useCustomMutation(
Expand All @@ -70,12 +72,12 @@ export default () => {

return (
<>
<Modal size='xl' show={showDetailsRobotId != null} onHide={() => setShowDetailsRobotId(null)}>
<Modal fullscreen show={showDetailsRobotId != null} onHide={() => setShowDetailsRobotId(null)}>
<Modal.Header closeButton>
<Modal.Title>Retrieve Robot Details</Modal.Title>
</Modal.Header>
<Modal.Body>
<AutoRetrieveRobotDetails robotId = {showDetailsRobotId}/>
<AutoRetrieveRobotDetails robotId={showDetailsRobotId} />
</Modal.Body>
</Modal>
<h2 className="card-title mt-4">Retrieve Robots : </h2>
Expand Down
77 changes: 37 additions & 40 deletions FrontEnd/src/components/Authentication.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { useEffect, useState } from 'react'
import { Button, Col, Container, Form, FormGroup, OverlayTrigger, Row, Tooltip } from 'react-bootstrap';
import jwt_decode from "jwt-decode";

import apis from '../services/apis'
import { CSSTransition } from "react-transition-group";

import HelpIcon from '@mui/icons-material/Info';
import { Button, Col, Container, Form, FormGroup, OverlayTrigger, Row, Tooltip } from 'react-bootstrap';
import { errorMessage } from '../tools/toastify';

import apis from '../services/apis'

export default ({ onLogin }) => {

const [state, setState] = useState({
Expand Down Expand Up @@ -65,44 +64,42 @@ export default ({ onLogin }) => {


return (
<CSSTransition in={state.show} timeout={1500} classNames='auth'>
<div className='min-vh-100 bg-authentification d-flex align-items-center'>
<div className='alert alert-danger' style={{ display: state.errorMessage === undefined ? 'none' : '' }}>
{state.errorMessage}
</div>
<Container fluid>
<Row className="shadow block-title block block-400">
<Col >
Orthanc-Tools-JS
<OverlayTrigger
placement="right"
delay={{ show: 250, hide: 400 }}
overlay={renderTooltip}
>
<HelpIcon className="mb-1" data-tip data-for='info1' fontSize="small" />
</OverlayTrigger>
</Col>
</Row>
<Row className='block-content block block-400'>
<Form onKeyPress={handleKeyDown}>
<FormGroup>
<label>Username*</label>
<input className='form-control' type='text' placeholder='username' name='username' value={state.username.value} onChange={handleChange} required />
</FormGroup>
<div className='min-vh-100 bg-authentification d-flex align-items-center'>
<div className='alert alert-danger' style={{ display: state.errorMessage === undefined ? 'none' : '' }}>
{state.errorMessage}
</div>
<Container fluid>
<Row className="shadow block-title block block-400">
<Col >
Orthanc-Tools-JS
<OverlayTrigger
placement="right"
delay={{ show: 250, hide: 400 }}
overlay={renderTooltip}
>
<HelpIcon className="mb-1" data-tip data-for='info1' fontSize="small" />
</OverlayTrigger>
</Col>
</Row>
<Row className='block-content block block-400'>
<Form onKeyPress={handleKeyDown}>
<FormGroup>
<label>Username*</label>
<input className='form-control' type='text' placeholder='username' name='username' value={state.username.value} onChange={handleChange} required />
</FormGroup>

<FormGroup>
<label>Password*</label>
<input className='form-control' type='password' placeholder='password' name='password' value={state.password.value} onChange={handleChange} required />
</FormGroup>
<FormGroup>
<label>Password*</label>
<input className='form-control' type='password' placeholder='password' name='password' value={state.password.value} onChange={handleChange} required />
</FormGroup>

<FormGroup className='d-flex justify-content-center mt-3'>
<Button name='connexion' className='btn btn-dark' onClick={handleClick}> Connect </Button>
</FormGroup>
</Form>
</Row>
</Container>
</div>
</CSSTransition >
<FormGroup className='d-flex justify-content-center mt-3'>
<Button name='connexion' className='btn btn-dark' onClick={handleClick}> Connect </Button>
</FormGroup>
</Form>
</Row>
</Container>
</div>
)
}

Expand Down
Loading

0 comments on commit 0374907

Please sign in to comment.