Last active
December 12, 2015 03:28
-
-
Save Zenithar/4706637 to your computer and use it in GitHub Desktop.
Export task as postIt from IceScrum instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('util'), | |
fs = require('fs'), | |
rest = require('restler'), | |
async = require('async'), | |
_ = require('underscore'), | |
BASEURL = "http://localhost:8080/icescrum/ws/p/", | |
SPRINTID = 1, | |
PRJKEY = "PRJ1"; | |
IceScrum = rest.service(function(u, p) { | |
this.defaults.username = u; | |
this.defaults.password = p; | |
},{ | |
baseURL : BASEURL | |
},{ | |
getAllSprintTasks: function(prjKey, sprId) { | |
return this.get(prjKey + "/" + sprId + "/task.json"); | |
}, | |
getAllStories: function(prjKey, sprId) { | |
return this.get(prjKey + "/story.json"); | |
} | |
}); | |
var client = new IceScrum("toto", "fait du vélo !"), | |
stories = {}, | |
tasks = {}, | |
expandedTasks = {}; | |
var postItTemplate = _.template(fs.readFileSync('postit.tmpl.html', 'utf8')); | |
async.series([ | |
function(next) { | |
console.log("Fetching all stories ..."); | |
client.getAllStories(PRJKEY).on('complete', function(data, response) { | |
if(response.statusCode === 200) { | |
stories = data; | |
console.log(stories.length + " stories fetched ..."); | |
next(); | |
} else { | |
throw new Error("Unable to fetch stories from server, response : " + response.statusCode); | |
} | |
}); | |
}, | |
function(next) { | |
console.log("Fetching all tasks ..."); | |
client.getAllSprintTasks(PRJKEY, SPRINTID).on('complete', function(data, response) { | |
if(response.statusCode === 200) { | |
tasks = data; | |
console.log(tasks.length + " tasks fetched ..."); | |
next(); | |
} else { | |
throw new Error("Unable to fetch tasks from server, response : " + response.statusCode); | |
} | |
}); | |
}, function(next) { | |
console.log("Merging tasks and stories ..."); | |
expandedTasks = _.map(tasks, function(it) { | |
var parentStory = it.parentStory; | |
if(parentStory !== null) { | |
it.parentStory = _.findWhere(stories, {id: parentStory.id}); | |
} | |
return it; | |
}); | |
next(); | |
} | |
], function() { | |
console.log("Generating task output ..."); | |
var postItHtml = postItTemplate({tasks : expandedTasks}); | |
fs.writeFile("tasks.html", postItHtml); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<! DOCTYPE HTML > | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<style> | |
body { | |
width: 210mm; | |
} | |
.tasks { | |
width: 100%; | |
} | |
.task { | |
width: 33%; | |
float: left; | |
border: 1px solid black; | |
height: 30mm; | |
page-break-inside:avoid; | |
page-break-after:auto; | |
} | |
.task .container { | |
width: 90%; | |
padding: 10px; | |
} | |
.task .header { | |
font-style: italic; | |
font-size: 10px; | |
text-align: right; | |
margin-bottom: 25px; | |
} | |
.task .content { | |
text-align: center; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="tasks"> | |
<% _.each(tasks, function(t) { %> | |
<div class="task"> | |
<div class="container"> | |
<div class="header"> | |
<span class="parentName"><% if(t.parentStory !== null) {%><%= t.parentStory.name.trim() %><% } %></span> | |
</div> | |
<div class="content"> | |
<span class="name"><%= t.name %></span> | |
</div> | |
<div class="footer"> | |
</div> | |
</div> | |
</div> | |
<% }) %> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment