Comparing version 0.0.1 to 0.0.2
23
index.js
@@ -8,11 +8,24 @@ var path = require('path'); | ||
options || (options = {}); | ||
if (typeof options.poll === 'undefined') options.poll = 1000; | ||
if (typeof options.poll === 'undefined') { | ||
options.POLL_INTERVAL = 1000; | ||
} else { | ||
options.POLL_INTERVAL = options.poll; | ||
} | ||
var app = express(); | ||
var indexHTML = path.join(__dirname, 'app', 'index.html'); | ||
var indexHTML = path.join(__dirname, 'lib', 'index.html'); | ||
var router = express.Router(); | ||
router.get('/', function (req, res) { | ||
router.get('/:definitionId?', function (req, res) { | ||
var data = {}; | ||
data.namespace = req.originalUrl.replace(/(^\/|\/$)/g, ''); | ||
options.NAMESPACE = req.originalUrl.replace(/(^\/|\/$)/g, ''); | ||
if(options.ASSET_HOST) { | ||
options.ASSETS_NAMESPACE = options.ASSET_HOST + '/' + options.NAMESPACE; | ||
} else { | ||
options.ASSETS_NAMESPACE = '/' + options.NAMESPACE; | ||
} | ||
data.options = options; | ||
@@ -26,3 +39,3 @@ | ||
app.use('/assets', express.static(path.join(__dirname, 'assets'))); | ||
app.use('/jobs', api(agenda)); | ||
app.use(api(agenda)); | ||
app.use(router); | ||
@@ -29,0 +42,0 @@ |
var express = require('express'); | ||
var slug = require('speakingurl'); | ||
@@ -6,11 +7,51 @@ module.exports = function (agenda) { | ||
router.get('/', function (req, res) { | ||
var find = { nextRunAt: { $gte: new Date() } }; | ||
function definitions () { | ||
return Object.keys(agenda._definitions).map(function (d) { | ||
var id = slug(d); | ||
return { | ||
_id: id | ||
, name: d | ||
}; | ||
}); | ||
} | ||
agenda.jobs(find, function(err, jobs) { | ||
res.json(jobs); | ||
function buildQuery (queryParams) { | ||
var query = {}; | ||
var filter = queryParams.filter; | ||
var name = queryParams.name; | ||
if (!filter || 'future' === filter) { | ||
query.nextRunAt = { $gte: new Date() }; | ||
} else if ('completed' === filter) { | ||
query.lastFinishedAt = { $exists: true }; | ||
query.type = 'normal'; | ||
} else if ('failed' === filter) { | ||
query.failedAt = { $exists: true }; | ||
} | ||
if (name) { | ||
query.name = name; | ||
} | ||
return query; | ||
} | ||
router.get('/jobs', function (req, res) { | ||
var query = buildQuery(req.query); | ||
agenda.jobs(query, function(err, jobs) { | ||
res.json({ | ||
jobs: jobs | ||
, definitions: definitions() | ||
}); | ||
}); | ||
}); | ||
router.get('/definitions', function (req, res) { | ||
res.json({ | ||
definitions: definitions() | ||
}); | ||
}); | ||
return router; | ||
}; |
{ | ||
"name": "agenda-ui", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "UI for Agenda", | ||
@@ -8,4 +8,4 @@ "main": "index.js", | ||
"test": "mocha", | ||
"dev": "nodemon --ignore tmp/ --ignore node_modules/ dev.js", | ||
"prepublish": "rm -rf ./assets && BROCCOLI_ENV=production broccoli build assets" | ||
"dev": "nodemon --ignore tmp/ --ignore app/ --ignore node_modules/ dev.js", | ||
"prepublish": "./scripts/build" | ||
}, | ||
@@ -40,4 +40,5 @@ "keywords": [ | ||
"ejs": "^1.0.0", | ||
"express": "^4.3.2" | ||
"express": "^4.3.2", | ||
"speakingurl": "^0.9.1" | ||
} | ||
} |
# Agenda UI | ||
A UI to view [Agneda](https://github.com/rschmukler/agenda) jobs. | ||
A UI to view [Agenda](https://github.com/rschmukler/agenda) jobs. | ||
@@ -15,3 +15,3 @@ ### This is still very much a work in progress | ||
The Agenda UI is middleware you can mount at a path in your express app. | ||
``` | ||
```js | ||
var express = require('express'); | ||
@@ -45,2 +45,2 @@ var Agenda = require('agenda'); | ||
### Developing | ||
This is an Ember app that gets built on `prepublish`. To try it out locally with some sample jobs run `npm run dev` and go to [http://localhost:3022/agenda-ui](http://localhost:3022/agenda-ui). | ||
This is an Ember app that gets built on `prepublish`. To try it out locally with some sample jobs run `npm run dev` and `ember serve` in the `/app` directory. Then go to [http://localhost:3022/](http://localhost:3022/agenda-ui). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
535862
3
8
2054
3
5
1
+ Addedspeakingurl@^0.9.1
+ Addedspeakingurl@0.9.1(transitive)