Skip to content

Commit

Permalink
Merge pull request #40 from RUGSoftEng/release
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
martinavagyan authored May 19, 2017
2 parents 4a10d5c + 54ba65b commit a53bf8c
Show file tree
Hide file tree
Showing 44 changed files with 4,102 additions and 940 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
.DS_Store
npm-debug.log
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ Running project: [VIEW](https://medid.herokuapp.com/)

Client-side documentation: [VIEW](https://htmlpreview.github.io/?https://raw.githubusercontent.com/RUGSoftEng/2017-Medical-ID/develop/doc/index.html)

**Install and run instructions:**
Ensure you have Python2.7 and NodeJS installed on your machine.

In forgot.js, there are two sections as such:

'''sh
auth: {
user: '[email protected]',
pass: 'enterpasswordhere'
}
'''

Here, you should enter the username and password of the account you would like to send the password reset emails.

Once the above has been done, run the following commands from the terminal:

```sh
$ npm install
```

```sh
$ npm start
```


### cmd Reminders ###

**Obtaining files:**
Expand All @@ -27,12 +52,3 @@ git push --follow-tags
**Delete tag:**
git tag -d tagName
git push --delete origin tagName

**Install and run instructions:**
```sh
$ npm install
```

```sh
$ npm start
```
17 changes: 13 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var mongo = require('mongodb');
var mongoose = require('mongoose');
var serverSettings = require('./serverSettings.js');
var forceHttps = require('express-force-https');

mongoose.connect('mongodb://root:[email protected]:27017,med-shard-00-01-mgwxu.mongodb.net:27017,med-shard-00-02-mgwxu.mongodb.net:27017/loginapp?ssl=true&replicaSet=med-shard-0&authSource=admin');
mongoose.connect(serverSettings.parameters.db || 'mongodb://root:[email protected]:27017,med-shard-00-01-mgwxu.mongodb.net:27017,med-shard-00-02-mgwxu.mongodb.net:27017/loginapp?ssl=true&replicaSet=med-shard-0&authSource=admin');
if (serverSettings.parameters.db) {
console.log("Connected to custom database '" + serverSettings.parameters.db + "'.");
}

//mongoose.connect('mongodb://localhost/loginapp');
var db = mongoose.connection;

Expand Down Expand Up @@ -47,8 +52,12 @@ app.use(session({
resave: true
}));

// Force HTTPS when not running on localhost
app.use(forceHttps);
// Force HTTPS when not connecting to localhost
if (!serverSettings.parameters.http) {
app.use(forceHttps);
} else {
console.log("Warning: running in (unsecure) HTTP mode.");
}

// Passport init
app.use(passport.initialize());
Expand Down Expand Up @@ -98,5 +107,5 @@ app.use('/forgot', forgot);
app.set('port', (process.env.PORT || 3000));

app.listen(app.get('port'), function(){
console.log('Server started on port '+app.get('port'));
console.log("Server started on port " + app.get('port') + ".");
});
103 changes: 56 additions & 47 deletions doc/card.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ <h1 class="page-title">Source: card.js</h1>

<section>
<article>
<pre class="prettyprint source linenums"><code>define(['medid/creator', 'jspdf', 'medid/res'], function(Creator, jsPDF) {
<pre class="prettyprint source linenums"><code>define(['jspdf', 'jquery', 'medid/res'], function(jsPDF, $) {

/**
* The card module implements card creation functionality upon the creator.js module.
* Its main functionality lies in the createPDF method, which generates the Medical ID card PDF.
*
* @exports MIDcard
* @requires creator
* @requires jquery
* @requires jsPDF
* @required res
*/
var MIDcard = {};

Expand All @@ -61,11 +61,12 @@ <h1 class="page-title">Source: card.js</h1>
/**
* Method to generate the Medical ID card PDF.
* Uses the fields() method of the creator module as input data.
* @return {jsPDF} The document object of the generated card.
* @param {Creator} creator - The creator object calling the method, needed for input.
* @param {method} callback - Callback to return the jsPDF document object.
*/
MIDcard.createPDF = function () {
MIDcard.createPDF = function (creator, callback) {

var fields = Creator.fields();
var fields = creator.fields();
var doc = new jsPDF();

doc.setFont('helvetica');
Expand All @@ -76,51 +77,42 @@ <h1 class="page-title">Source: card.js</h1>
//Labels
doc.setFontSize(9);

var image;
var leftCounter = 0, rightCounter = 0;
var leftStartPos = [12,55], rightStartPos = [38,30];
var lineHeight = 5, leftLabelWidth = 19, rightLabelWidth = 21;
for (i = 0; i &lt; fields.length; i++) {
if (fields[i].label == "Image") {
image = fields[i].field;
} else {
fields[i].label = fields[i].label.substring(0, 13);
fields[i].field = fields[i].field.substring(0, 19);
if (fields[i].label == 'Donor' || fields[i].label == 'Blood type') {
// We place the short fields 'donor' and 'blood type' in the corner
if (leftCounter &lt; 2) { // Max capacity
doc.setFontStyle("bold");
doc.text(leftStartPos[0], leftStartPos[1] + lineHeight * leftCounter, fields[i].label + ": ");
doc.setFontStyle("normal");
doc.text(leftStartPos[0] + leftLabelWidth, leftStartPos[1] + lineHeight * leftCounter, fields[i].field);
}
leftCounter++;
for (i = 0; i &lt; fields.length &amp;&amp; i &lt; creator.cardNum; i++) {
fields[i].label = fields[i].label.substring(0, 13);
fields[i].field = fields[i].field.substring(0, 19);
if (fields[i].label == 'Donor' || fields[i].label == 'Blood type') {
// We place the short fields 'donor' and 'blood type' in the corner
if (leftCounter &lt; 2) { // Max capacity
doc.setFontStyle("bold");
doc.text(leftStartPos[0], leftStartPos[1] + lineHeight * leftCounter, fields[i].label + ": ");
doc.setFontStyle("normal");
doc.text(leftStartPos[0] + leftLabelWidth, leftStartPos[1] + lineHeight * leftCounter, fields[i].field);
}
else {
// Place remaining lines on the main part of the card
if (rightCounter &lt; 7) { // Max capacity
doc.setFontStyle("bold");
doc.text(rightStartPos[0], rightStartPos[1] + lineHeight * rightCounter, fields[i].label + ": ");
doc.setFontStyle("normal");
doc.text(rightStartPos[0] + rightLabelWidth, rightStartPos[1] + lineHeight * rightCounter, fields[i].field);
}
rightCounter++;
leftCounter++;
}
else {
// Place remaining lines on the main part of the card
if (rightCounter &lt; 7) { // Max capacity
doc.setFontStyle("bold");
doc.text(rightStartPos[0], rightStartPos[1] + lineHeight * rightCounter, fields[i].label + ": ");
doc.setFontStyle("normal");
doc.text(rightStartPos[0] + rightLabelWidth, rightStartPos[1] + lineHeight * rightCounter, fields[i].field);
}
rightCounter++;
}
}

if (image) {
doc.addImage(image , 13, 28, Creator.imageWidth/4.5, Creator.imageHeight/4.5);
if (creator.image) {
doc.addImage(creator.image , 13, 28, creator.imageWidth/4.5, creator.imageHeight/4.5);
} else {
doc.addImage(Resources.placeholder , 11, 26, 23, 23);
}

// Back side
MIDcard.drawCard(doc, 100, 10, 15);
doc.setFontStyle('normal');
doc.text(110, 40, "This is an example card.");
doc.text(110, 44, "The functional version of this card is reserved");
doc.text(110, 48, "for registered users.");

// Header bars
doc.addImage(Resources.redLogo,'JPEG', 12,12,12,12);
Expand All @@ -130,17 +122,34 @@ <h1 class="page-title">Source: card.js</h1>
doc.setFontSize(14);
doc.text(104, 19, "SCAN FOR MORE INFORMATION");

return doc;
// Retrieving QR code from server
$.get('/save/qr', function(qrcode) {
doc.addImage(qrcode, 'JPEG', 123, 25, 38, 38);
callback(doc);
})
}

/**
* Wrapper method to simply get the card PDF as base64.
* @param {Creator} creator - The creator object to use.
* @param {method} callback - Callback method to return the PDF data.
*/
MIDcard.get = function (creator, callback) {
MIDcard.createPDF(creator, function(doc) {
callback(doc.output('datauristring'));
});
}

Creator.getMethod(function (callback) {
callback(MIDcard.createPDF().output('datauristring')); //getDataUrl(callback);
});
Creator.downloadMethod(function (name) {
MIDcard.createPDF().save(name);
});
Creator.saveEndpoint = '/save/card';
Creator.init();
/**
* Wrapper method to instruct the browser to download the generated card PDF.
* @param {Creator} creator - The creator object to use.
* @param {String} name - The document name for the card PDF.
*/
MIDcard.download = function (creator, name) {
MIDcard.createPDF(creator, function(doc) {
doc.save(name);
});
}

return MIDcard;

Expand All @@ -155,13 +164,13 @@ <h1 class="page-title">Source: card.js</h1>
</div>

<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-creator.html">creator</a></li><li><a href="module-MIDcard.html">MIDcard</a></li><li><a href="module-MIDdocument.html">MIDdocument</a></li><li><a href="module-util.html">util</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-creator.html">creator</a></li><li><a href="module-hyphenator.html">hyphenator</a></li><li><a href="module-MIDcard.html">MIDcard</a></li><li><a href="module-MIDdocument.html">MIDdocument</a></li><li><a href="module-settings.html">settings</a></li><li><a href="module-util.html">util</a></li></ul>
</nav>

<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Wed Apr 05 2017 16:49:56 GMT+0200 (CEST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Thu May 04 2017 10:05:08 GMT+0200 (CEST)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading

0 comments on commit a53bf8c

Please sign in to comment.