Skip to content

Commit

Permalink
Merge pull request #382 from salimkanoun/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
salimkanoun authored Oct 9, 2020
2 parents d941421 + 94b02e0 commit 35ac52e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
5 changes: 3 additions & 2 deletions BackEnd/controllers/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authentication = async function (req, res) {
try {
const userObject = new Users(body.username)
await userObject.checkPassword(body.password, async function(reponse) {
console.log(reponse)

if (reponse) {
let user = new Users(body.username)

Expand All @@ -29,7 +29,8 @@ authentication = async function (req, res) {

var TOKEN = jwt.sign(payload, process.env.TOKEN_SECRET, { expiresIn: '1h' });

res.json(TOKEN);
res.cookie("tokenOrthancJs", TOKEN, {httpOnly: true})
res.json(true)
})
} else {
res.status(401).send('Wrong Credential')
Expand Down
3 changes: 2 additions & 1 deletion BackEnd/controllers/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var updateRobotOptions = async function(req, res){
body.burner_monitoring_level,
body.burner_support_type,
body.burner_delete_study_after_sent,
body.burner_transfer_syntax
body.burner_transfer_syntax,
body.date_format
)
res.json(true)
}
Expand Down
3 changes: 2 additions & 1 deletion BackEnd/model/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Options = {
},

setBurnerOptions : async (burner_monitored_path, burner_viewer_path, burner_label_path, burner_manifacturer, burner_monitoring_level,
burner_support_type, burner_delete_study_after_sent, burner_transfer_syntax ) => {
burner_support_type, burner_delete_study_after_sent, burner_transfer_syntax, date_format ) => {

const option = await db.Option.findOne(({ where: { id: 1 } }))

Expand All @@ -36,6 +36,7 @@ const Options = {
option.burner_support_type = burner_support_type
option.burner_delete_study_after_sent = burner_delete_study_after_sent
option.burner_transfer_syntax = burner_transfer_syntax
option.date_format = date_format

await option.save()

Expand Down
2 changes: 1 addition & 1 deletion BackEnd/model/monitoring/cdburner/CdBurner.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CdBurner {
this.dateOptions = { month: 'numeric', day: 'numeric', year : 'numeric' } //precision of the date

const options = await Options.getCdBurnerOptions()

//format of date (using contry convention)
if (options.date_format === "fr") {
this.format = "DD/MM/YYYY"
Expand Down
9 changes: 9 additions & 0 deletions FrontEnd/src/components/Admin/CDBurner/BurnerOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class BurnerOptions extends Component{
burner_manifacturer : '',
burner_monitoring_level : '',
burner_support_type : '',
date_format: '',
burner_delete_study_after_sent : false,
burner_transfer_syntax : null

Expand All @@ -40,6 +41,11 @@ export default class BurnerOptions extends Component{
{value : 'DVD', label : 'DVD'}
]

dateFormatOptions = [
{value: 'uk', label : 'MMDDYYYY'},
{value: 'fr', label : "DDMMYYYY"}
]

transferSyntaxOptions = [
{value: 'None', label: 'None (Original TS)'},
{value: '1.2.840.10008.1.2', label: 'Implicit VR Endian'},
Expand Down Expand Up @@ -111,6 +117,7 @@ export default class BurnerOptions extends Component{

render(){
return (
//date_format
<div>
<h2 className="card-title">CD/DVD Burner Options</h2>
<label htmlFor="burner_monitored_path">Monitored Folder : </label>
Expand All @@ -125,6 +132,8 @@ export default class BurnerOptions extends Component{
<Select single options={this.manufacturerOptions} value={this.getSelectedObject(this.manufacturerOptions, this.state.burner_manifacturer)} onChange={this.handleChangeSelect} name="burner_manifacturer"/>
<label htmlFor="burner_monitoring_level">Monitoring Level : </label>
<Select options={this.levelOptions} value={this.getSelectedObject(this.levelOptions ,this.state.burner_monitoring_level)} onChange={this.handleChangeSelect} name = "burner_monitoring_level" />
<label htmlFor="date_format">Date Format : </label>
<Select options={this.dateFormatOptions} value={this.getSelectedObject(this.dateFormatOptions ,this.state.date_format)} onChange={this.handleChangeSelect} name = "date_format" />
<label htmlFor="burner_support_type">Support Type : </label>
<Select single options={this.supportType} value={this.getSelectedObject(this.supportType, this.state.burner_support_type)} onChange={this.handleChangeSelect} name = "burner_support_type" />
<div className ="mt-3" >
Expand Down
14 changes: 2 additions & 12 deletions FrontEnd/src/components/Authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,10 @@ export default class Authentication extends Component {

await apis.authentication.logIn(postData).then((answer)=>{

// get token from fetch request
const token = answer;

//cookie's options
var d = new Date();
d.setTime(d.getTime() + (7*24*60*60*1000)); // cookie expire in 7 days
var expires = d.toUTCString();

// set token in cookie
document.cookie = `tokenOrthancJs=${token}; expires=${expires}`
document.cookie = `tokenOrthancJs=${token}; expires=${expires};HttpOnly`
console.log(answer)

newState = {
accessCheck : answer
accessCheck : true
}

}).catch( async (error) => {
Expand Down
1 change: 0 additions & 1 deletion FrontEnd/src/components/CDBurner/CDBurner.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export default class CDBurner extends Component {
};

render(){
console.log(this.state.burnerJobs)
return (

<div className='jumbotron'>
Expand Down
2 changes: 1 addition & 1 deletion FrontEnd/src/components/Main/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class Footer extends Component {
render () {
return (
<Fragment>
<div className="footer-copyright text-center">Orthanc Tools JS: 0.4.4
<div className="footer-copyright text-center">Orthanc Tools JS: 0.4.5

<button type="button" className='link-button ml-3' onClick={() => this.setState(prevState => ({show: !prevState.show}))}>About</button>
</div>
Expand Down

0 comments on commit 35ac52e

Please sign in to comment.