Skip to content

Commit

Permalink
Merge pull request #320 from salimkanoun/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
salimkanoun authored Jul 10, 2020
2 parents bc93b79 + 6d4b582 commit 7e6942c
Show file tree
Hide file tree
Showing 38 changed files with 664 additions and 322 deletions.
13 changes: 12 additions & 1 deletion BackEnd/controllers/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,15 @@ var setOrthancServer = function (req, res) {
res.end()
}

module.exports = { changeSchedule, getSchedule, getOrthancServer, setOrthancServer }
var getMode = async function(req, res) {
const mode = await Options.getMode()
res.json(mode)
}

var changeMode = async function(req, res) {
const mode = await req.body.mode
Options.changeMode(mode)
res.json(true)
}

module.exports = { changeSchedule, getSchedule, getOrthancServer, setOrthancServer, getMode, changeMode }
2 changes: 0 additions & 2 deletions BackEnd/database/models/role.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const Users = require("../../model/Users");

module.exports = (sequelize, DataTypes) => {
const Role = sequelize.define('Role', {
import: DataTypes.BOOLEAN,
Expand Down
4 changes: 1 addition & 3 deletions BackEnd/midelwares/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ function decode (req, res) {
}

const userAuthMidelware = function (req, res, next) {

let decoded;

try {
decoded = decode(req, res);
decode(req, res);
}
catch(err) { return }

Expand Down
25 changes: 25 additions & 0 deletions BackEnd/model/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ const Options = {
}

return Options.configSettings
},

getMode: async () => {
let mode
try {
mode = await db.Option.findOne()

} catch (err) {
console.log(err)
}

return mode.ldap
},

changeMode: async (mode) => {

try {
await db.Option.upsert({
id:1,
ldap: mode
})

} catch (err) {
console.log(err)
}
}

}
Expand Down
11 changes: 8 additions & 3 deletions BackEnd/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require('express-async-errors')

const { authentication, logOut } = require('../controllers/authentication')
const { getRobotDetails, getAllRobotDetails, addRobotJob, validateRobotJob, deleteRobotJob, removeQueryFromJob, addAnonJob, getAnonJob, getDeleteJob, addDeleteJob } = require('../controllers/Robot2')
const { changeSchedule, getSchedule, getOrthancServer, setOrthancServer } = require('../controllers/options')
const { changeSchedule, getSchedule, getOrthancServer, setOrthancServer, getMode, changeMode } = require('../controllers/options')
const { getParsedAnswer } = require('../controllers/query')
const { reverseProxyGet, reverseProxyPost, reverseProxyPostUploadDicom, reverseProxyPut, reverseProxyPutPlainText, reverseProxyDelete } = require('../controllers/reverseProxy')
const { getRoles, createRole, modifyRole, deleteRole, getPermission, getRoleFromToken } = require('../controllers/role')
Expand Down Expand Up @@ -104,8 +104,9 @@ router.get('/queries/:orthancIdQuery/parsedAnswers', queryMidelware, getParsedAn
router.post('/instances', importMidelware, reverseProxyPostUploadDicom)

// Orthanc DicomWebRoutes
router.get('/dicom-web/*', contentMidelware, reverseProxyGet)
router.get('/wado/*', contentMidelware, reverseProxyGet)
//SK ICI AJOUTER CONTENT MIDDELWARE QUAND OHIF POURRA INJECTER LE JWT DANS TOUTES LES REQUETES
router.get('/dicom-web/*', reverseProxyGet)
router.get('/wado/*', reverseProxyGet)

//Orthanc export routes
router.post('/tools/create-archive', exportLocalMidelware , reverseProxyPost )
Expand Down Expand Up @@ -153,4 +154,8 @@ router.delete('/roles', userAdminMidelware, deleteRole)
//token
router.get('/token', userAuthMidelware, getRoleFromToken)

//Mode
router.get('/mode', userAdminMidelware, getMode)
router.put('/changeMode', userAdminMidelware, changeMode)

module.exports = router
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component, Fragment } from 'react'
import Select from 'react-select'
import apis from '../../services/aets'
import apis from '../../../services/aets'

/**
* Form to declare or modify an AET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react'
import Aets from './AetsListTable'
import AetForm from './AetForm'
import apis from '../../services/apis'
import apis from '../../../services/apis'

/**
* Root Panel of AETs options
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component, Fragment } from 'react'
import BootstrapTable from 'react-bootstrap-table-next';
import apis from '../../services/apis';
import apis from '../../../services/apis';

/**
* Table with known AETs details with Echo and Remove button
Expand Down
10 changes: 5 additions & 5 deletions FrontEnd/src/components/Admin/AdminRootPanel.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState } from 'react'
import OrthancSettings from './OrthancSettings'
import AetRootPanel from './AetRootPanel'
import AutoRetrieveRootPanel from './AutoRetrieveRootPanel'
import PeerRootPanel from './PeerRootPanel'
import JobsRootPanel from './JobsRootPanel'
import OrthancSettings from './OrthancSettings/OrthancSettings'
import AetRootPanel from './AET/AetRootPanel'
import AutoRetrieveRootPanel from './Robots/AutoRetrieveRootPanel'
import PeerRootPanel from './Peers/PeerRootPanel'
import JobsRootPanel from './Jobs/JobsRootPanel'
import Plugins from './Plugins'
import UserManagement from './UserManagement/UserManagement'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { Component, Fragment } from "react";
import BootstrapTable from "react-bootstrap-table-next";
import paginationFactory from "react-bootstrap-table2-paginator";
import Dropdown from "react-bootstrap/Dropdown";
import Modal from "react-bootstrap/Modal";

import apis from "../../services/apis";
import apis from "../../../services/apis";
import ModalDetails from './ModalDetails'

class JobsRootPanel extends Component {

Expand Down Expand Up @@ -65,39 +65,6 @@ class JobsRootPanel extends Component {
)
}

columnDetails = [
{
dataField: 'ID',
hidden: true
}, {
dataField: 'ErrorCode',
text: 'Error Code'
},
{
dataField: 'ErrorDescription',
text: 'Error Description'
}, {
dataField: 'Priority',
text: 'Priority'
}, {
dataField: 'Type',
text: 'Type'
}, {
dataField: 'EffectiveRuntime',
text: 'Effective Runtime'
}, {
dataField: 'Content',
text: 'Details',
formatter: (cell, row, index) => {
return (
<pre>
{JSON.stringify(row.Content , null, 2)}
</pre>
)
}
}
]

column = [
{
dataField: 'ID',
Expand Down Expand Up @@ -130,27 +97,7 @@ class JobsRootPanel extends Component {
return (
<Fragment>
<h2 className="card-title">Jobs</h2>
<Modal show={this.state.showDetail} onHide={() => this.setState({showDetail: false})} size='xl'>
<Modal.Header closeButton>
<Modal.Title>Job Details</Modal.Title>
</Modal.Header>
<Modal.Body>
<BootstrapTable
keyField='ID'
data={[this.state.rows[this.state.currentRowIndex]]}
columns={this.columnDetails}
striped={true}
wrapperClasses="table-responsive"
/>
</Modal.Body>
<Modal.Footer>
<button type='button'
className='btn btn-primary'
onClick={()=>this.setState({showDetail: false})}>
Close
</button>
</Modal.Footer>
</Modal>
<ModalDetails show={this.state.showDetail} onHide={() => this.setState({showDetail: false})} data={[this.state.rows[this.state.currentRowIndex]]} />
<BootstrapTable
keyField='ID'
striped={true}
Expand Down
67 changes: 67 additions & 0 deletions FrontEnd/src/components/Admin/Jobs/ModalDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { Component } from 'react'
import Modal from "react-bootstrap/Modal";
import BootstrapTable from "react-bootstrap-table-next";

class ModalDetails extends Component {

columnDetails = [
{
dataField: 'ID',
hidden: true
}, {
dataField: 'ErrorCode',
text: 'Error Code'
},
{
dataField: 'ErrorDescription',
text: 'Error Description'
}, {
dataField: 'Priority',
text: 'Priority'
}, {
dataField: 'Type',
text: 'Type'
}, {
dataField: 'EffectiveRuntime',
text: 'Effective Runtime'
}, {
dataField: 'Content',
text: 'Details',
formatter: (cell, row, index) => {
return (
<pre>
{JSON.stringify(row.Content , null, 2)}
</pre>
)
}
}
]

render() {
return (
<Modal show={this.props.show} onHide={this.props.onHide} size='xl'>
<Modal.Header closeButton>
<Modal.Title>Job Details</Modal.Title>
</Modal.Header>
<Modal.Body>
<BootstrapTable
keyField='ID'
data={this.props.data}
columns={this.columnDetails}
striped={true}
wrapperClasses="table-responsive"
/>
</Modal.Body>
<Modal.Footer>
<button type='button'
className='btn btn-primary'
onClick={this.props.onHide}>
Close
</button>
</Modal.Footer>
</Modal>
);
}
}

export default ModalDetails;
34 changes: 34 additions & 0 deletions FrontEnd/src/components/Admin/OrthancSettings/ModalRestart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { Component } from 'react'
import Modal from 'react-bootstrap/Modal'

import apis from '../../../services/apis'

class ModalRestart extends Component {

constructor(props){
super(props)
this.reset = this.reset.bind(this)
}

reset(){
apis.options.resetOrthanc()
this.props.onHide()
}

render() {
return (
<Modal show={this.props.show} onHide={this.props.onHide}>
<Modal.Header closeButton>
<Modal.Title>Confirm restart</Modal.Title>
</Modal.Header>
<Modal.Body>Are you sure to restart Orthanc system ?</Modal.Body>
<Modal.Footer>
<input type='button' className='btn btn-secondary' onClick={this.props.onHide} value="Close" />
<input type='button' className='btn btn-warning' onClick={this.reset} value="Restart" />
</Modal.Footer>
</Modal>
);
}
}

export default ModalRestart;
34 changes: 34 additions & 0 deletions FrontEnd/src/components/Admin/OrthancSettings/ModalShutdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { Component } from 'react'
import Modal from 'react-bootstrap/Modal'

import apis from '../../../services/apis'

class ModalShutdown extends Component {

constructor(props) {
super(props)
this.shutdown = this.shutdown.bind(this)
}

shutdown(){
apis.options.shutdownOrthanc()
this.props.onHide()
}

render() {
return (
<Modal show={this.props.show} onHide={this.props.onHide}>
<Modal.Header closeButton>
<Modal.Title>Confirm Shutdown</Modal.Title>
</Modal.Header>
<Modal.Body>Are you sure to shutdown Orthanc system ?</Modal.Body>
<Modal.Footer>
<input type='button' className='btn btn-secondary' onClick={this.props.onHide} value="Close" />
<input type='button' className='btn btn-danger' onClick={this.shutdown} value="Shutdown" />
</Modal.Footer>
</Modal>
);
}
}

export default ModalShutdown;
Loading

0 comments on commit 7e6942c

Please sign in to comment.