ADD YouTrack support
This commit is contained in:
parent
7d0aeb7951
commit
d6cd954b0f
106
bookmarklet.js
106
bookmarklet.js
@ -42,6 +42,9 @@
|
|||||||
} else if (/.*trello.com\/.*/g.test(document.URL)) {
|
} else if (/.*trello.com\/.*/g.test(document.URL)) {
|
||||||
console.log("App: " + "Trello");
|
console.log("App: " + "Trello");
|
||||||
global.appFunctions = trelloFunctions;
|
global.appFunctions = trelloFunctions;
|
||||||
|
} else if (/.*\/youtrack\/.*/g.test(document.URL)) {
|
||||||
|
console.log("App: " + "YouTrack");
|
||||||
|
global.appFunctions = youTrackFunctions;
|
||||||
} else {
|
} else {
|
||||||
alert("Unsupported app.Please create an issue at https://github.com/qoomon/Jira-Issue-Card-Printer");
|
alert("Unsupported app.Please create an issue at https://github.com/qoomon/Jira-Issue-Card-Printer");
|
||||||
return;
|
return;
|
||||||
@ -1224,9 +1227,7 @@
|
|||||||
module.getSelectedIssueKeyList = function() {
|
module.getSelectedIssueKeyList = function() {
|
||||||
//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 [document.URL.replace(/.*\/browse\/([^?]*).*/, '$1')];
|
||||||
return jQuery(this).attr('data-issue-key');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RapidBoard
|
// RapidBoard
|
||||||
@ -1306,9 +1307,9 @@
|
|||||||
// add custom fields with field names
|
// add custom fields with field names
|
||||||
jQuery.each(responseData.names, function(key, value) {
|
jQuery.each(responseData.names, function(key, value) {
|
||||||
if (key.startsWith("customfield_")) {
|
if (key.startsWith("customfield_")) {
|
||||||
var newFieldId = value.toCamelCase();
|
var fieldName = value.toCamelCase();
|
||||||
//console.log("add new field: " + newFieldId + " with value from " + key);
|
//console.log("add new field: " + fieldName + " with value from " + key);
|
||||||
responseData.fields[value.toCamelCase()] = responseData.fields[key];
|
responseData.fields[fieldName] = responseData.fields[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
callback(responseData);
|
callback(responseData);
|
||||||
@ -1319,12 +1320,103 @@
|
|||||||
return module;
|
return module;
|
||||||
}({}));
|
}({}));
|
||||||
|
|
||||||
|
var youTrackFunctions = (function (module) {
|
||||||
|
|
||||||
|
module.getSelectedIssueKeyList = function() {
|
||||||
|
//Detail View
|
||||||
|
if (/.*\/issue\/.*/g.test(document.URL)) {
|
||||||
|
return [document.URL.replace(/.*\/issue\/([^?]*).*/, '$1')];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Agile Board
|
||||||
|
if (/.*\/rest\/agile.*/g.test(document.URL)) {
|
||||||
|
return jQuery('div.sb-task-focused').map(function() {
|
||||||
|
return jQuery(this).attr('id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
module.getCardData= function(issueKey, callback) {
|
||||||
|
module.getIssueData(issueKey, function(data) {
|
||||||
|
|
||||||
|
var issueData = {};
|
||||||
|
|
||||||
|
issueData.key = data.id;
|
||||||
|
|
||||||
|
issueData.type = data.field.type[0];
|
||||||
|
|
||||||
|
issueData.summary = data.field.summary;
|
||||||
|
|
||||||
|
issueData.description = data.field.description;
|
||||||
|
|
||||||
|
if (data.field.assignee) {
|
||||||
|
issueData.assignee = data.field.assignee[0].fullName;
|
||||||
|
// var avatarUrl = data.fields.assignee.avatarUrls['48x48'];
|
||||||
|
// if (avatarUrl.indexOf("ownerId=") >= 0) {
|
||||||
|
// issueData.avatarUrl = avatarUrl;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// if (data.fields.duedate) {
|
||||||
|
// issueData.dueDate = new Date(data.fields.duedate).format('D d.m.');
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
if (data.field.attachments) {
|
||||||
|
issueData.hasAttachment = data.field.attachments.length > 0;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// issueData.storyPoints = data.fields.storyPoints;
|
||||||
|
//
|
||||||
|
// issueData.epicKey = data.fields.epicLink;
|
||||||
|
// if (issueData.epicKey) {
|
||||||
|
// jiraFunctions.getIssueData(issueData.epicKey, function(data) {
|
||||||
|
// issueData.epicName = data.fields.epicName;
|
||||||
|
// }, false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
issueData.url = window.location.origin + "/youtrack/issue/" + issueData.key;
|
||||||
|
|
||||||
|
callback(issueData);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.getIssueData = function(issueKey, callback, async) {
|
||||||
|
async = typeof async !== 'undefined' ? async : true;
|
||||||
|
//https://docs.atlassian.com/jira/REST/latest/
|
||||||
|
var url = '/youtrack/rest/issue/' + issueKey + '?';
|
||||||
|
console.log("IssueUrl: " + url);
|
||||||
|
//console.log("Issue: " + issueKey + " Loading...");
|
||||||
|
jQuery.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: url,
|
||||||
|
data: {},
|
||||||
|
dataType: 'json',
|
||||||
|
async: async,
|
||||||
|
success: function(responseData) {
|
||||||
|
//console.log("Issue: " + issueKey + " Loaded!");
|
||||||
|
jQuery.each(responseData.field, function(key, value) {
|
||||||
|
// add fields with field names
|
||||||
|
var fieldName = value.name.toCamelCase();
|
||||||
|
//console.log("add new field: " + newFieldId + " with value from " + fieldName);
|
||||||
|
responseData.field[fieldName] = value.value;
|
||||||
|
|
||||||
|
});
|
||||||
|
callback(responseData);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return module;
|
||||||
|
}({}));
|
||||||
|
|
||||||
var pivotalTrackerFunctions = (function (module) {
|
var pivotalTrackerFunctions = (function (module) {
|
||||||
|
|
||||||
module.getSelectedIssueKeyList = function() {
|
module.getSelectedIssueKeyList = function() {
|
||||||
//Single Story
|
//Single Story
|
||||||
if (/.*\/stories\/.*/g.test(document.URL)) {
|
if (/.*\/stories\/.*/g.test(document.URL)) {
|
||||||
return [document.URL.replace(/.*\/stories\/([^?]*).*/, '$1')]; // TODO
|
return [document.URL.replace(/.*\/stories\/([^?]*).*/, '$1')];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Board
|
// Board
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user