Skip to content

Commit

Permalink
initialize options,
Browse files Browse the repository at this point in the history
removing unused routes which dont map to real functions
fixing indenting issues
prepare module includes comment structure
super -> super()
fixing winston
memory store
jquery file upload #TODO: fixing unlink async aguidrevitch/jquery-file-upload-middleware#85
  • Loading branch information
brianbolt committed Dec 6, 2020
1 parent a2f8b38 commit e1a1998
Show file tree
Hide file tree
Showing 32 changed files with 543 additions and 515 deletions.
3 changes: 1 addition & 2 deletions app_api_template.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ startApp = ->
console.error 'Caught api exception: ' + err.stack
return

###TO_BE_REPLACED_BY_PREPAREMODULEINCLUDES###

#TO_BE_REPLACED_BY_PREPAREMODULEINCLUDES

http.createServer(app).listen(app.get('port'), ->
console.log("ACAS API server listening on port " + app.get('port'))
Expand Down
26 changes: 20 additions & 6 deletions app_template.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ startApp = ->
logger = require('morgan')
methodOverride = require('method-override')
session = require('express-session')
MemoryStore = require('memorystore')(session)
bodyParser = require('body-parser')
# multer = require('multer')
errorHandler = require('errorhandler')
Expand Down Expand Up @@ -71,7 +72,7 @@ startApp = ->
# next()

loginRoutes = require './routes/loginRoutes'

sessionStore = new MemoryStore();
global.app = express()
app.set 'port', config.all.client.port
app.set 'views', __dirname + '/views'
Expand All @@ -85,10 +86,12 @@ startApp = ->
app.use session
secret: 'acas needs login'
cookie: maxAge: 365 * 24 * 60 * 60 * 1000
store: sessionStore # MemoryStore is used automatically if no "store" field is set, but we need a handle on the sessionStore object for Socket.IO, so we'll manually create the store so we have a handle on the object

app.use flash()
app.use passport.initialize()
app.use passport.session pauseStream: true
# app.use express.bodyParser()
# app.use express.bodyParser()
app.use(bodyParser.json({limit: '100mb'}))
app.use(bodyParser.urlencoded({limit: '100mb', extended: true,parameterLimit: 1000000}))
# app.use(multer())
Expand All @@ -102,8 +105,8 @@ startApp = ->


if not config.all.client.use.ssl
http.createServer(app).listen(app.get('port'), ->
console.log("Express server listening on port " + app.get('port'))
httpServer = http.createServer(app).listen(app.get('port'), ->
console.log("ACAS server listening on port " + app.get('port'))
)
else
console.log "------ Starting in SSL Mode"
Expand All @@ -115,12 +118,23 @@ startApp = ->
ca: fs.readFileSync config.all.server.ssl.cert.authority.file.path
passphrase: config.all.server.ssl.cert.passphrase
https.createServer(sslOptions, app).listen(app.get('port'), ->
console.log("Express server listening on port " + app.get('port'))
console.log("ACAS server listening on port " + app.get('port'))
)
#TODO hack to prevent bug: https://github.com/mikeal/request/issues/418
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"

###TO_BE_REPLACED_BY_PREPAREMODULEINCLUDES###
io = require('socket.io')(httpServer)
passportSocketIo = require('passport.socketio')
cookieParser = require('cookie-parser')

io.use(passportSocketIo.authorize({
key: 'connect.sid',
secret: 'acas needs login',
store: sessionStore,
passport: passport,
cookieParser: cookieParser
}))
#TO_BE_REPLACED_BY_PREPAREMODULEINCLUDES

options = if stubsMode then ["stubsMode"] else []
options.push ['--color']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ class window.ACASLabelSequenceController extends AbstractFormController
"click .bv_save": "handleSaveClicked"
"click .bv_cancel": "handleCancelClicked"

initialize: ->
initialize: (options) ->
@options = options
if @model?
@completeInitialization()
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
exports.setupAPIRoutes = (app) ->
app.get '/api/labelSequences', exports.getAllLabelSequences
app.get '/api/labelSequences/reagents/codename', exports.getReagentByCodename
app.post '/api/labelSequences/jsonArray', exports.saveLabelSequenceArray

exports.setupRoutes = (app, loginRoutes) ->
Expand Down
10 changes: 5 additions & 5 deletions modules/AdminPanel/src/client/AdminPanel.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class window.AdminPanelController extends AbstractFormController
recursivelyIterateAndDisplayValues = (dict) ->
keys = Object.keys dict
_.each(keys, (key) ->
if isObject dict[key]
recursivelyIterateAndDisplayValues dict[key]
else
unless typeof dict[key] is "object"
@$('.bv_configProperties').append("<b>" + key + ":</b> " + dict[key] + "<br />")
if isObject dict[key]
recursivelyIterateAndDisplayValues dict[key]
else
unless typeof dict[key] is "object"
@$('.bv_configProperties').append("<b>" + key + ":</b> " + dict[key] + "<br />")
)
#TODO add full paths - Matt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ prepRouteIncludes = (apiMode) ->
routeLines

routeLines = prepRouteIncludes(false)
insertToLayoutTemplate " /*TO_BE_REPLACED_BY_PREPAREMODULEINCLUDES */", routeLines, "#{ACAS_HOME}/app_template.js", "#{ACAS_HOME}/app.js"
insertToLayoutTemplate "//TO_BE_REPLACED_BY_PREPAREMODULEINCLUDES", routeLines, "#{ACAS_HOME}/app_template.js", "#{ACAS_HOME}/app.js"
routeLines = prepRouteIncludes(true)
insertToLayoutTemplate " /*TO_BE_REPLACED_BY_PREPAREMODULEINCLUDES */", routeLines, "#{ACAS_HOME}/app_api_template.js", "#{ACAS_HOME}/app_api.js"
insertToLayoutTemplate "//TO_BE_REPLACED_BY_PREPAREMODULEINCLUDES", routeLines, "#{ACAS_HOME}/app_api_template.js", "#{ACAS_HOME}/app_api.js"
1 change: 0 additions & 1 deletion modules/CmpdReg/src/server/routes/CmpdRegRoutes.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
exports.setupAPIRoutes = (app) ->
app.post '/api/cmpdReg', exports.postAssignedProperties
app.get '/cmpdReg/scientists', exports.getScientists
app.get '/cmpdReg/metalots/corpName/[\\S]*', exports.getMetaLot
app.post '/cmpdReg/metalots', exports.metaLots
Expand Down
3 changes: 2 additions & 1 deletion modules/CmpdRegAdmin/src/client/AbstractCmpdRegAdmin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class window.AbstractCmpdRegAdminController extends AbstractFormController
"click .bv_cancelClear": "handleCancelClearClicked"
"click .bv_confirmClear": "handleConfirmClearClicked"

initialize: ->
initialize: (options) ->
@options = options
console.log "initializing Abstract Controller"
if @model?
@completeInitialization()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class window.CmpdRegAdminSimpleSearchController extends AbstractFormController
Instantiating controller must provide urlRoot and toDisplay in options
###

initialize: ->
initialize: (options) ->
@options = options
@searchUrl = ""
@searchUrl = @options.urlRoot + '/search/'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
path = require 'path'

exports.setupAPIRoutes = (app) ->
app.post '/api/cmpdRegBulkLoader', exports.postAssignedProperties
exports.setupAPIRoutes = (app, loginRoutes) ->
app.post '/api/cmpdRegBulkLoader/registerCmpds', exports.registerCmpds
app.post '/api/cmpdRegBulkLoader/validateCmpds', exports.validateCmpds
app.post '/api/cmpdRegBulkLoader/validationProperties', exports.validationProperties
Expand All @@ -17,7 +16,6 @@ exports.setupRoutes = (app, loginRoutes) ->
app.post '/api/cmpdRegBulkLoader/saveTemplate', loginRoutes.ensureAuthenticated, exports.saveTemplate
app.post '/api/cmpdRegBulkLoader/registerCmpds', loginRoutes.ensureAuthenticated, exports.registerCmpds
app.post '/api/cmpdRegBulkLoader/validateCmpds', loginRoutes.ensureAuthenticated, exports.validateCmpds
app.post '/api/cmpdRegBulkLoader', loginRoutes.ensureAuthenticated, exports.postAssignedProperties
app.post '/api/cmpdRegBulkLoader/checkFileDependencies', loginRoutes.ensureAuthenticated, exports.checkFileDependencies
app.post '/api/cmpdRegBulkLoader/purgeFile', loginRoutes.ensureAuthenticated, exports.purgeFile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class window.AbstractCodeTablesAdminController extends AbstractFormController
"click .bv_cancelClear": "handleCancelClearClicked"
"click .bv_confirmClear": "handleConfirmClearClicked"

initialize: ->
initialize: (options) ->
@options = options
console.log "initializing Abstract Controller"
if @model?
@completeInitialization()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class window.CodeTablesAdminSimpleSearchController extends AbstractFormControlle
Instantiating controller must provide urlRoot and toDisplay in options
###

initialize: ->
initialize: (options) ->
@options = options
@searchUrl = ""
@searchUrl = @options.urlRoot + '/search/'

Expand Down Expand Up @@ -111,7 +112,8 @@ class window.CodeTablesAdminRowSummaryController extends Backbone.View

############################################################################
class window.CodeTablesAdminSummaryTableController extends Backbone.View
initialize: ->
initialize: (options) ->
@options = options
if @options.showIgnore?
@showIgnore = @options.showIgnore
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class window.ACASFormChemicalStructureController extends Backbone.View
tagName: "DIV"
template: _.template($("#ACASFormChemicalStructureControllerView").html())

initialize: (options) ->
@options = options

render: =>
$(@el).empty()
$(@el).html @template()
Expand Down
13 changes: 8 additions & 5 deletions modules/Components/src/client/ACASFormFields.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class window.ACASFormAbstractFieldController extends Backbone.View
"mouseover .label-tooltip": "handleToolTipMouseover"
"mouseoff .label-tooltip": "handleToolTipMouseoff"

initialize: ->
initialize: (options) ->
@options = options
@modelKey = @options.modelKey
@thingRef = @options.thingRef
@errorSet = false
Expand Down Expand Up @@ -331,7 +332,7 @@ class window.ACASFormLSCodeValueFieldController extends ACASFormAbstractFieldCon
Do whatever else is required or optional in ACASFormAbstractFieldController
###
events: ->
_.extend {}, super,
_.extend {}, super(),
"change select": "handleInputChanged"

template: _.template($("#ACASFormLSCodeValueFieldView").html())
Expand Down Expand Up @@ -437,9 +438,11 @@ class window.ACASFormLSThingInteractionFieldController extends ACASFormAbstractF
Do whatever else is required or optional in ACASFormAbstractFieldController
###
events: ->
_.extend {}, super,
_.extend {}, super(),
"change select": "handleInputChanged"

initialize: (options) ->
@options = options
template: _.template($("#ACASFormLSThingInteractionFieldView").html())

applyOptions: ->
Expand Down Expand Up @@ -642,7 +645,7 @@ class window.ACASFormLSDateValueFieldController extends ACASFormAbstractFieldCon

template: _.template($("#ACASFormLSDateValueFieldView").html())
events: ->
_.extend {}, super,
_.extend {}, super(),
"change input": "handleInputChanged"
"click .bv_dateIcon": "handleDateIconClicked"

Expand Down Expand Up @@ -693,7 +696,7 @@ class window.ACASFormLSFileValueFieldController extends ACASFormAbstractFieldCon

template: _.template($("#ACASFormLSFileValueFieldView").html())
events: ->
_.extend {}, super,
_.extend {}, super(),
"click .bv_deleteSavedFile": "handleDeleteSavedFile"

applyOptions: ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class window.ACASFormCodeValueCheckboxController extends ACASFormAbstractFieldCo
events: ->
"change input": "handleInputChanged"

initialize: ->
initialize: (options) ->
@options = options
@stateRef = @options.stateRef
@thingRef = @options.thingRef
@keyBase = @options.keyBase
Expand Down
18 changes: 16 additions & 2 deletions modules/Components/src/client/ACASFormStateDisplayUpdate.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
class window.ACASFormStateDisplayUpdateHeaderRowController extends Backbone.View
tagName: 'tr'

initialize: (options) ->
@options = options

render: =>
for val in @options.tableDef.values
displayName = val.fieldSettings.formLabel
Expand All @@ -23,6 +26,9 @@ class window.ACASFormStateDisplayUpdateCellController extends Backbone.View
events: ->
"click": "handleCellClicked"

initialize: (options) ->
@options = options

render: =>
$(@el).empty()
if @collection.length == 0
Expand Down Expand Up @@ -52,6 +58,9 @@ class window.ACASFormStateDisplayUpdateCellController extends Backbone.View
class window.ACASFormStateDisplayUpdateRowController extends Backbone.View
tagName: 'tr'

initialize: (options) ->
@options = options

render: =>
for valDef in @options.tableDef.values
vals = @collection.where lsKind: valDef.modelDefaults.kind
Expand All @@ -69,7 +78,8 @@ class window.ACASFormStateDisplayUpdateController extends Backbone.View
rowNumberKind: 'row number'
template: _.template($("#ACASFormStateDisplayUpdateView").html())

initialize: ->
initialize: (options) ->
@options = options
@thingRef = @options.thingRef
@tableDef = @options.tableDef
@tableSetupComplete = false
Expand Down Expand Up @@ -218,6 +228,9 @@ class window.ACASFormStateDisplayOldValueController extends Backbone.View
tagName: 'tr'
template: _.template($("#ACASFormStateDisplayOldValueView").html())

initialize: (options) ->
@options = options

render: =>
value = @model.get(@model.get('lsType'))
if @options.valueDef.displayOverride?
Expand Down Expand Up @@ -258,7 +271,8 @@ class window.ACASFormStateDisplayValueEditController extends Backbone.View
"click .bv_cancelBtn": "handleCancelClicked"
"click .bv_saveBtn": "handleSaveClicked"

initialize: ->
initialize: (options) ->
@options = options
@tableDef = @options.tableDef
for valDef in @tableDef.values
if valDef.modelDefaults.kind == @collection.at(0).get('lsKind')
Expand Down
2 changes: 1 addition & 1 deletion modules/Components/src/client/ACASFormStateTable.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class window.ACASFormStateTableController extends Backbone.View
columns: @colDefs
search: @tableDef.search
currentRowClassName: 'bv_stateDisplayCurrentRow',
currentColClassName: 'bv_stateDisplayCurrentColumn'
currentColClassName: 'bv_stateDisplayCurrentColumn'
cells: (row, col, prop) =>
cellProperties = {}
if @tableReadOnly
Expand Down
15 changes: 10 additions & 5 deletions modules/Components/src/client/LSErrorNotification.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class window.LSAbstractNotificationCounterController extends Backbone.View
container: null
notificationsList: null

initialize: ->
initialize: (options) ->
@options = options
_.bindAll(@,
'render')
@notificationsList = @.options.notificationsList
Expand Down Expand Up @@ -66,7 +67,8 @@ class window.LSErrorController extends Backbone.View
notificationsList: null
badgeEl: null

initialize: ->
initialize: (options) ->
@options = options
_.bindAll(@,
'render')
@notificationsList = @.options.notificationsList
Expand All @@ -88,7 +90,8 @@ class window.LSWarningController extends Backbone.View
notificationsList: null
badgeEl: null

initialize: ->
initialize: (options) ->
@options = options
_.bindAll(@,
'render')
@notificationsList = @.options.notificationsList
Expand All @@ -110,7 +113,8 @@ class window.LSInfoController extends Backbone.View
notificationsList: null
badgeEl: null

initialize: ->
initialize: (options) ->
@options = options
_.bindAll(@,
'render')
@notificationsList = @.options.notificationsList
Expand Down Expand Up @@ -139,7 +143,8 @@ class window.LSNotificationController extends Backbone.View
events:
'click .bv_notificationCountContainer': 'toggleShowNotificationMessages'

initialize: ->
initialize: (options) ->
@options = options
_.bindAll(@,
'render',
'addError',
Expand Down
3 changes: 2 additions & 1 deletion modules/Components/src/client/LSFileChooser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class window.LSFileChooserController extends Backbone.View
requiresValidation: true
hideDelete: false #for hiding delete button after successful file upload

initialize: ->
initialize: (options) ->
@options = options
_.bindAll(@,
'render',
'handleDragOverDocument',
Expand Down
Loading

0 comments on commit e1a1998

Please sign in to comment.