Commit 83943f6e authored by Leo Iannacone's avatar Leo Iannacone

add packages history page

parent 11007a6c
......@@ -42,6 +42,10 @@ if config.routes.preferences
if config.routes.commands
app.get(config.routes.commands, routes.commands)
# history page
if config.routes.history
app.get(config.routes.history, routes.history)
# debomatic static page
if config.routes.debomatic
chroot_forbidden = (res) ->
......
......@@ -98,6 +98,7 @@ config.routes.debomatic = "/debomatic"
config.routes.distribution = "/distribution"
config.routes.preferences = "/preferences"
config.routes.commands = "/commands"
config.routes.history = "/history"
###
The events
......
"use strict"
glob = require("glob")
config = require("../lib/config")
fs = require("fs")
exports.index = (req, res) ->
res.render "index", config
return
......@@ -15,3 +17,20 @@ exports.preferences = (req, res) ->
exports.commands = (req, res) ->
res.render "commands", config
return
exports.history = (req, res) ->
glob "#{config.debomatic.path}/*/pool/*/*.json", {}, (err, files) ->
get_info = (json_path) ->
json = JSON.parse(fs.readFileSync(json_path, 'utf8'))
delete json.files
return json
compare = (a,b) ->
if a.end < b.end
return -1
if a.end > b.end
return 1
return 0
config.history = (get_info(f) for f in files)
config.history.sort(compare)
res.render "history", config
......@@ -22,6 +22,9 @@
</div>
<div id="pages">
<ul class="nav navbar-nav pull-right">
<% if (web.paths.history) { %>
<li><a href="<%= web.paths.history %>">History</a></li>
<% } %>
<% if (web.paths.commands) { %>
<li><a href="<%= web.paths.commands %>">Commands</a></li>
<% } %>
......
<% include header.ejs %>
<article class="page">
<header><h2>History</h2></header>
<p class="lead text-muted">
The log of packages
</p>
<table class="table table-bordered table-striped">
<% console.log(history) %>
<thead>
<tr>
<th>Distribution</th>
<th>Package</th>
<th>Uploader</th>
<th>Start</th>
<th>End</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<% for (var i=0; i < history.length; i++) { %>
<tr>
<td><%= history[i].distribution %> </td>
<td><%= history[i].package %></td>
<td><%= history[i].ploader %></td>
<td><%= history[i].start %></td>
<td><%= history[i].end %></td>
<td><%= history[i].success %></td>
</tr>
<% } %>
</tbody>
</table>
</article>
<% include footer.ejs %>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment