Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc 254 #272

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ node_modules/
*.sublime-workspace
*.idea

# vscode
.vscode

# system related #
.DS_Store

Expand Down
Binary file added public/images/template-life.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/template-type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/traveler-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 38 additions & 10 deletions public/javascripts/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,19 @@ $(function() {
bAutoWidth: false,
bProcessing: true,
iDisplayLength: 10,
aLengthMenu: [[10, 50, 100, -1], [10, 50, 100, 'All']],
aLengthMenu: [
[10, 50, 100, -1],
[10, 50, 100, 'All'],
],
oLanguage: {
sLoadingRecords: 'Please wait - loading data from the server ...',
},
bDeferRender: true,
aoColumns: formAoColumns,
aaSorting: [[11, 'desc'], [10, 'desc']],
aaSorting: [
[11, 'desc'],
[10, 'desc'],
],
sDom: sDomNoTools,
});
fnAddFilterFoot('#form-table', formAoColumns);
Expand Down Expand Up @@ -187,13 +193,19 @@ $(function() {
bAutoWidth: false,
bProcessing: true,
iDisplayLength: 10,
aLengthMenu: [[10, 50, 100, -1], [10, 50, 100, 'All']],
aLengthMenu: [
[10, 50, 100, -1],
[10, 50, 100, 'All'],
],
oLanguage: {
sLoadingRecords: 'Please wait - loading data from the server ...',
},
bDeferRender: true,
aoColumns: transferredFormAoColumns,
aaSorting: [[11, 'desc'], [12, 'desc']],
aaSorting: [
[11, 'desc'],
[12, 'desc'],
],
sDom: sDomNoTools,
});
fnAddFilterFoot('#transferred-form-table', transferredFormAoColumns);
Expand Down Expand Up @@ -226,7 +238,10 @@ $(function() {
bAutoWidth: false,
bProcessing: true,
iDisplayLength: 10,
aLengthMenu: [[10, 50, 100, -1], [10, 50, 100, 'All']],
aLengthMenu: [
[10, 50, 100, -1],
[10, 50, 100, 'All'],
],
oLanguage: {
sLoadingRecords: 'Please wait - loading data from the server ...',
},
Expand All @@ -251,7 +266,10 @@ $(function() {
bAutoWidth: false,
bProcessing: true,
iDisplayLength: 10,
aLengthMenu: [[10, 50, 100, -1], [10, 50, 100, 'All']],
aLengthMenu: [
[10, 50, 100, -1],
[10, 50, 100, 'All'],
],
oLanguage: {
sLoadingRecords: 'Please wait - loading data from the server ...',
},
Expand All @@ -275,7 +293,7 @@ $(function() {
releasedByColumn,
releasedOnColumn,
];
$('#released-form-table').dataTable({
var releasedFormTable = $('#released-form-table').dataTable({
sAjaxSource: '/released-forms/json',
sAjaxDataProp: '',
fnDrawCallback: function() {
Expand All @@ -286,7 +304,10 @@ $(function() {
bAutoWidth: false,
bProcessing: true,
iDisplayLength: 10,
aLengthMenu: [[10, 50, 100, -1], [10, 50, 100, 'All']],
aLengthMenu: [
[10, 50, 100, -1],
[10, 50, 100, 'All'],
],
oLanguage: {
sLoadingRecords: 'Please wait - loading data from the server ...',
},
Expand Down Expand Up @@ -321,7 +342,10 @@ $(function() {
bAutoWidth: false,
bProcessing: true,
iDisplayLength: 10,
aLengthMenu: [[10, 50, 100, -1], [10, 50, 100, 'All']],
aLengthMenu: [
[10, 50, 100, -1],
[10, 50, 100, 'All'],
],
oLanguage: {
sLoadingRecords: 'Please wait - loading data from the server ...',
},
Expand Down Expand Up @@ -354,7 +378,10 @@ $(function() {
bAutoWidth: false,
bProcessing: true,
iDisplayLength: 10,
aLengthMenu: [[10, 50, 100, -1], [10, 50, 100, 'All']],
aLengthMenu: [
[10, 50, 100, -1],
[10, 50, 100, 'All'],
],
oLanguage: {
sLoadingRecords: 'Please wait - loading data from the server ...',
},
Expand Down Expand Up @@ -492,6 +519,7 @@ $(function() {
transferredFormTable.fnReloadAjax();
sharedFormTable.fnReloadAjax();
groupSharedFormTable.fnReloadAjax();
releasedFormTable.fnReloadAjax();
archivedFormTable.fnReloadAjax();
archivedReleasedFormTable.fnReloadAjax();
});
Expand Down
6 changes: 3 additions & 3 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ module.exports = function(app) {
/**
* get the latest value for the given name from the data list
* @param {String} name input name
* @param {Array} data an arrya of TravelerData
* @param {Array} data an array of TravelerData
* @return {Number|String|null} the value for the given name
*/
function dataForName(name, data) {
Expand Down Expand Up @@ -368,7 +368,7 @@ module.exports = function(app) {
* @param {Function} cb callback function
* @return {Object} the json representation
*/
function retrieveKeyLableValue(traveler, props, cb) {
function retrieveKeyLabelValue(traveler, props, cb) {
var output = {};
props.forEach(function(p) {
output[p] = traveler[p];
Expand Down Expand Up @@ -416,7 +416,7 @@ module.exports = function(app) {

app.get('/apis/travelers/:id/keylabelvalue/', function(req, res) {
Traveler.findById(req.params.id, function(travelerErr, traveler) {
retrieveKeyLableValue(
retrieveKeyLabelValue(
traveler,
['id', 'title', 'status', 'tags', 'devices'],
function(err, output) {
Expand Down
2 changes: 2 additions & 0 deletions routes/form-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const mongoose = require('mongoose');
const routesUtilities = require('../utilities/routes.js');
const Form = mongoose.model('Form');
const ReleasedForm = mongoose.model('ReleasedForm');
const { statusMap } = require('../model/released-form');
const reqUtils = require('../lib/req-utils');
const logger = require('../lib/loggers').getLogger();
const config = require('../config/config.js');
Expand Down Expand Up @@ -84,6 +85,7 @@ module.exports = function(app) {
title: releasedForm.title,
formType: releasedForm.formType,
status: releasedForm.status,
statusText: statusMap['' + releasedForm.status],
ver: releasedForm.ver,
base: releasedForm.base,
discrepancy: releasedForm.discrepancy,
Expand Down
24 changes: 13 additions & 11 deletions routes/traveler.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,7 @@ module.exports = function(app) {
return res
.status(400)
.send(
`cannot find the released ${
config.viewConfig.terminology.form
} with id ${req.body.form}`
`cannot find the released ${config.viewConfig.terminology.form} with id ${req.body.form}`
);
}
});
Expand Down Expand Up @@ -639,7 +637,7 @@ module.exports = function(app) {
* @param {Function} cb callback function
* @return {Object} the json representation
*/
function retrieveKeyLableValue(traveler, props, cb) {
function retrieveKeyLabelValue(traveler, props, cb) {
var output = {};
props.forEach(function(p) {
output[p] = traveler[p];
Expand Down Expand Up @@ -736,7 +734,7 @@ module.exports = function(app) {
reqUtils.exist('id', Traveler),
reqUtils.canReadMw('id'),
function(req, res) {
retrieveKeyLableValue(
retrieveKeyLabelValue(
req[req.params.id],
['id', 'title', 'status', 'tags', 'devices'],
function(err, output) {
Expand Down Expand Up @@ -938,7 +936,10 @@ module.exports = function(app) {
reqUtils.archived('id', false),
function(req, res) {
var doc = req[req.params.id];
if (reqUtils.isOwner(req, doc) || routesUtilities.checkUserRole(req, 'admin')) {
if (
reqUtils.isOwner(req, doc) ||
routesUtilities.checkUserRole(req, 'admin')
) {
return res.render(
'traveler-config',
routesUtilities.getRenderObject(req, {
Expand All @@ -947,9 +948,7 @@ module.exports = function(app) {
})
);
} else {
res
.status(403)
.send('you are not authorized to access this resource');
res.status(403).send('you are not authorized to access this resource');
}
}
);
Expand All @@ -964,7 +963,10 @@ module.exports = function(app) {
reqUtils.sanitize('body', ['title', 'description', 'deadline']),
function(req, res) {
var doc = req[req.params.id];
if (reqUtils.isOwner(req, doc) || routesUtilities.checkUserRole(req, 'admin')) {
if (
reqUtils.isOwner(req, doc) ||
routesUtilities.checkUserRole(req, 'admin')
) {
var k;
for (k in req.body) {
if (req.body.hasOwnProperty(k) && req.body[k] !== null) {
Expand All @@ -973,7 +975,7 @@ module.exports = function(app) {
}
doc.updatedBy = req.session.userid;
doc.updatedOn = Date.now();
doc.save(function (saveErr, newDoc) {
doc.save(function(saveErr, newDoc) {
if (saveErr) {
logger.error(saveErr);
return res.status(500).send(saveErr.message);
Expand Down
12 changes: 6 additions & 6 deletions views/doc-in-one.jade
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends layout

block head
title #{orgName} Traveler - documentation
title #{orgName} Traveler - user manual
meta(name='viewport', content='width=device-width, initial-scale=1.0')
link(rel='stylesheet', href='#{prefix}/bootstrap/css/bootstrap.css')
link(rel='stylesheet', href='#{prefix}/bootstrap/css/bootstrap-responsive.css')
Expand All @@ -19,13 +19,13 @@ block content
.span9
section#how-to-use
h2 How to use this document
p There is an Audience statement on the top of each section. If you are not the target audience, then you can skip the section.
p There is an Audience statement at the top of each section. If you are not the target audience, please feel free to skip that section.
section#basics
include ./docs/basics.jade
section#templates
include ./docs/templates.jade
section#travelers
include ./docs/travelers.jade
section#forms
include ./docs/forms.jade
section#binders
include ./docs/binders.jade
section#api
Expand All @@ -40,9 +40,9 @@ block content
li
a(href='#basics') Basics
li
a(href='#travelers') Travelers
a(href='#templates') Templates
li
a(href='#forms') Forms
a(href='#travelers') Travelers
li
a(href='#binders') Binders
li
Expand Down
12 changes: 6 additions & 6 deletions views/docs/api.jade
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
article
header
include:marked api.md
include:marked api/header.md
section#api-auth
include:marked api-auth.md
include:marked api/auth.md
section#api-travelers
include:marked api-travelers.md
include:marked api/travelers.md
section#api-traveler
include:marked api-traveler.md
include:marked api/traveler.md
section#data
include:marked api-data.md
include:marked api/data.md
section#notes
include:marked api-notes.md
include:marked api/notes.md
5 changes: 0 additions & 5 deletions views/docs/api.md

This file was deleted.

1 change: 1 addition & 0 deletions views/docs/api-auth.md → views/docs/api/auth.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
### API authentication

The API's are protected by basic authentication. If a client gets 401 response with "api" realm challenge, then the client either did not present the credential in the request or the presented credential was not right. Please contact the application operator for available credentials.
7 changes: 5 additions & 2 deletions views/docs/api-data.md → views/docs/api/data.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### Data collected in a traveler

- Method: GET
- URL: https://hostname:port/apis/travelers/:id/data/
where :id is the id of the traveler whose data is retrieved
where :id is the id of the traveler whose data is retrieved
- Sample response:

```json
Expand Down Expand Up @@ -29,7 +30,9 @@
Each data item in the list contains the input name in the form, the input type and the value. Besides, it also records who input the value at what time, by which the input history can be generated. For file input, the value is the file's original name when it was uploaded. In order to retrieve the content of the file, the following file API can be used.

#### File uploaded in a traveler

Files are special data collected, and they can be retrieved by

- Method: GET
- URL: https://hostname:port/apis/data/:id/
where :id is the id of the data whose type is file.
where :id is the id of the data whose type is file.
9 changes: 9 additions & 0 deletions views/docs/api/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Application programming interface

**Audience: developers**

The traveler application provides a limited API (application programming
interface) besides the Web interface. The API is designed in a
[RESTful](https://en.wikipedia.org/wiki/Representational_state_transfer) style.
Currently, other applications can read the information of travelers through the
API.
3 changes: 2 additions & 1 deletion views/docs/api-notes.md → views/docs/api/notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### Notes in a traveler

- Method: GET
- URL: https://hostname:port/apis/travelers/:id/notes/
where :id is the id of the traveler whose notes are retrieved
where :id is the id of the traveler whose notes are retrieved
- Sample response:

```json
Expand Down
3 changes: 2 additions & 1 deletion views/docs/api-traveler.md → views/docs/api/traveler.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### The details of a traveler

- Method: GET
- URL: https://hostname:port/apis/travelers/:id/
where :id is the id of the traveler to be retrieved
where :id is the id of the traveler to be retrieved
- Sample response:

```json
Expand Down
6 changes: 4 additions & 2 deletions views/docs/api-travelers.md → views/docs/api/travelers.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### The list of travelers

- Method: GET
- URL: https://hostname:port/apis/travelers/
- Sample response:
Expand Down Expand Up @@ -46,6 +47,7 @@
The response will be a JSON array containing the list of travelers. Each traveler in the list is represented by a JSON object with traveler id, title, status, devices, createdBy, clonedBy, createdOn, deadline, updatedBy, updatedOn, sharedWith, finishedInput, and totalInput information. The traveler id can be used to retrieve more details of a traveler, https://hostname:port/apis/travelers/:id/ for the JSON representation and http://hostname:port/travelers/:id/ for the HTML representation.

The travler list can also be retrieved by a device name.

- URL: https://hostname:port/apis/travelers/?device=:devicename
where :devicename is the name of device that was assigned to the travelers.
section#traveler
where :devicename is the name of device that was assigned to the travelers.
section#traveler
Loading