implement pivotal tracker
This commit is contained in:
parent
647b9d6420
commit
d40fd629c8
131
bookmarklet.js
131
bookmarklet.js
@ -1,5 +1,5 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var version = "3.2.3";
|
var version = "3.4.0";
|
||||||
console.log("Version: " + version);
|
console.log("Version: " + version);
|
||||||
|
|
||||||
var isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
|
var isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
|
||||||
@ -56,6 +56,14 @@
|
|||||||
|
|
||||||
resourceOrigin = hostOrigin+ "resources/";
|
resourceOrigin = hostOrigin+ "resources/";
|
||||||
|
|
||||||
|
JIRA='JIRA'
|
||||||
|
PIVOTAL_TRACKER='PIVOTAL_TRACKER'
|
||||||
|
issueTracker = 'UNKNOWN'
|
||||||
|
if( jQuery("meta[name='application-name'][ content='JIRA']").length > 0){
|
||||||
|
issueTracker = JIRA
|
||||||
|
} else if( /.*\pivotaltracker.com\/.*/g.test(document.URL)){
|
||||||
|
issueTracker = PIVOTAL_TRACKER
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function main(){
|
function main(){
|
||||||
@ -106,8 +114,7 @@
|
|||||||
var lineClamp = Math.floor(height / lineHeight);
|
var lineClamp = Math.floor(height / lineHeight);
|
||||||
jQuery(page).find(".description").css("-webkit-line-clamp", lineClamp+"");
|
jQuery(page).find(".description").css("-webkit-line-clamp", lineClamp+"");
|
||||||
|
|
||||||
jQuery(page).width("40%");
|
//jQuery(page).scc("float","left");
|
||||||
jQuery(page).scc("float","left");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
printWindow.print();
|
printWindow.print();
|
||||||
@ -190,16 +197,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedIssueKeyList() {
|
function getSelectedIssueKeyList() {
|
||||||
// jira
|
switch(issueTracker) {
|
||||||
if( true){
|
case JIRA:
|
||||||
return getSelectedJiraIssueKeyList();
|
return getSelectedIssueKeyListJira();
|
||||||
|
case PIVOTAL_TRACKER:
|
||||||
|
return getSelectedIssueKeyListPivotalTracker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedJiraIssueKeyList() {
|
function getSelectedIssueKeyListJira() {
|
||||||
|
|
||||||
//JIRA
|
|
||||||
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
|
|
||||||
//Browse
|
//Browse
|
||||||
if (/.*\/browse\/.*/g.test(document.URL)) {
|
if (/.*\/browse\/.*/g.test(document.URL)) {
|
||||||
return jQuery("a[data-issue-key][id='key-val']").map(function() {
|
return jQuery("a[data-issue-key][id='key-val']").map(function() {
|
||||||
@ -213,21 +220,41 @@
|
|||||||
return jQuery(this).attr('data-issue-key');
|
return jQuery(this).attr('data-issue-key');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelectedIssueKeyListPivotalTracker() {
|
||||||
|
|
||||||
|
//Single Story
|
||||||
|
if (/.*\/n\/projects\/.*\/stories\/.*/g.test(document.URL)) {
|
||||||
|
return jQuery('.story[data-id]').map(function() {
|
||||||
|
return jQuery(this).attr('data-id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Board
|
||||||
|
if (/.*\/n\/projects\/.*/g.test(document.URL)) {
|
||||||
|
return jQuery('.story[data-id]:has(.selected)').map(function() {
|
||||||
|
return jQuery(this).attr('data-id');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCardData(issueKey, callback){
|
function getCardData(issueKey, callback){
|
||||||
//Jira
|
switch(issueTracker) {
|
||||||
if(true){
|
case JIRA:
|
||||||
getJiraCardData(issueKey, callback);
|
return getCardDataJira(issueKey, callback);
|
||||||
|
case PIVOTAL_TRACKER:
|
||||||
|
return getCardDataPivotalTracker(issueKey, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getJiraCardData(issueKey, callback) {
|
function getCardDataJira(issueKey, callback) {
|
||||||
getJiraIssueData(issueKey,function(data){
|
getIssueDataJira(issueKey,function(data){
|
||||||
|
|
||||||
var issueData = {};
|
var issueData = {};
|
||||||
|
|
||||||
@ -252,17 +279,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
issueData.hasAttachment = data.fields.attachment.length > 0;
|
issueData.hasAttachment = data.fields.attachment.length > 0;
|
||||||
|
if(issueData.description){
|
||||||
var printScope = issueData.description.indexOf(printScopeDeviderToken);
|
var printScope = issueData.description.indexOf(printScopeDeviderToken);
|
||||||
if (printScope >= 0) {
|
if (printScope >= 0) {
|
||||||
issueData.description = issueData.description.substring(0, printScope);
|
issueData.description = issueData.description.substring(0, printScope);
|
||||||
issueData.hasAttachment = true;
|
issueData.hasAttachment = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
issueData.storyPoints = data.fields.storyPoints;
|
issueData.storyPoints = data.fields.storyPoints;
|
||||||
|
|
||||||
issueData.epicKey = data.fields.epicLink;
|
issueData.epicKey = data.fields.epicLink;
|
||||||
if ( issueData.epicKey ) {
|
if ( issueData.epicKey ) {
|
||||||
getJiraIssueData(issueData.epicKey , function(data) {
|
getIssueDataJira(issueData.epicKey , function(data) {
|
||||||
issueData.epicName = data.fields.epicName;
|
issueData.epicName = data.fields.epicName;
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
@ -282,11 +311,60 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getJiraIssueData(issueKey, callback, async) {
|
function getCardDataPivotalTracker(issueKey, callback) {
|
||||||
|
getIssueDataPivotalTracker(issueKey,function(data){
|
||||||
|
|
||||||
|
var issueData = {};
|
||||||
|
|
||||||
|
issueData.key = data.id;
|
||||||
|
|
||||||
|
issueData.type = data.kind.toLowerCase();
|
||||||
|
|
||||||
|
issueData.summary = data.name;
|
||||||
|
|
||||||
|
issueData.description = data.description;
|
||||||
|
if(issueData.description){
|
||||||
|
issueData.description = "<p>"+issueData.description
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( data.owned_by && data.owned_by.length > 0 ) {
|
||||||
|
issueData.assignee = data.owner_ids[0].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( data.deadline ) {
|
||||||
|
issueData.dueDate = new Date(data.deadline).format('D d.m.');
|
||||||
|
}
|
||||||
|
|
||||||
|
issueData.hasAttachment = false;
|
||||||
|
if(issueData.description){
|
||||||
|
var printScope = issueData.description.indexOf(printScopeDeviderToken);
|
||||||
|
if (printScope >= 0) {
|
||||||
|
issueData.description = issueData.description.substring(0, printScope);
|
||||||
|
issueData.hasAttachment = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issueData.storyPoints = data.estimate;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// issueData.epicKey = data.fields.epicLink;
|
||||||
|
// if ( issueData.epicKey ) {
|
||||||
|
// getIssueDataPivotalTracker(issueData.epicKey , function(data) {
|
||||||
|
// issueData.epicName = data.fields.epicName;
|
||||||
|
// }, false);
|
||||||
|
// }
|
||||||
|
|
||||||
|
issueData.url = data.url;
|
||||||
|
|
||||||
|
callback(issueData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIssueDataJira(issueKey, callback, async) {
|
||||||
async = typeof async !== 'undefined' ? async : true;
|
async = typeof async !== 'undefined' ? async : true;
|
||||||
//https://docs.atlassian.com/jira/REST/latest/
|
//https://docs.atlassian.com/jira/REST/latest/
|
||||||
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
|
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
|
||||||
console.logDebug("IssueUrl: " + window.location.hostname + url);
|
console.logDebug("IssueUrl: " + url);
|
||||||
console.logDebug("Issue: " + issueKey + " Loading...");
|
console.logDebug("Issue: " + issueKey + " Loading...");
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
@ -309,6 +387,25 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getIssueDataPivotalTracker(issueKey, callback, async) {
|
||||||
|
async = typeof async !== 'undefined' ? async : true;
|
||||||
|
//http://www.pivotaltracker.com/help/api
|
||||||
|
var url = 'https://www.pivotaltracker.com/services/v5/stories/' + issueKey + "?fields=name,kind,description,story_type,owned_by(name),comments(file_attachments(kind)),estimate,deadline";
|
||||||
|
console.logDebug("IssueUrl: " + url);
|
||||||
|
console.logDebug("Issue: " + issueKey + " Loading...");
|
||||||
|
jQuery.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: url,
|
||||||
|
data: {},
|
||||||
|
dataType: 'json',
|
||||||
|
async: async,
|
||||||
|
success: function(responseData){
|
||||||
|
console.logDebug("Issue: " + issueKey + " Loaded!");
|
||||||
|
callback(responseData);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function fillCard(card, data) {
|
function fillCard(card, data) {
|
||||||
//Key
|
//Key
|
||||||
card.find('.key').text(data.key);
|
card.find('.key').text(data.key);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user