diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties deleted file mode 100644 index e7efbfa..0000000 --- a/nbproject/private/private.properties +++ /dev/null @@ -1,5 +0,0 @@ -copy.src.files=false -copy.src.target=/var/www/kanbanise -index.file= -run.as=LOCAL -url=http://localhost/kanbanise/ diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml deleted file mode 100644 index c1f155a..0000000 --- a/nbproject/private/private.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 94429c9..0000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,7 +0,0 @@ -include.path=${php.global.include.path} -php.version=PHP_53 -source.encoding=UTF-8 -src.dir=. -tags.asp=false -tags.short=true -web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 195d23f..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - org.netbeans.modules.php.project - - - kanbanise - - - diff --git a/src/kanbanise.js b/src/kanbanise.js index 140092b..6e4c0ac 100644 --- a/src/kanbanise.js +++ b/src/kanbanise.js @@ -1,11 +1,19 @@ /*global console, alert, jasmine*/ +/* Default : "/" */ +var redmineSubURI = "/redmine/"; +var redmineRoot = window.location.protocol + "//" + window.location.host + redmineSubURI; +var VERSION = '0.13'; +var API_KEY = null; +var ISSUES_STATUSES = null; + + function Kanbanise() {} Kanbanise.prototype.templateTicket = '
  • \n' + ' \n' + ' ${storyPoints}\n' - + '

    ${subject}

    \n' + + '

    ${subject}

    \n' + ' ${assignedTo}\n' + '
  • \n'; @@ -61,11 +69,6 @@ Kanbanise.prototype.init = function() { var msgWin = null; var self = this; var $ = jQuery; - var VERSION = '0.13'; - var API_KEY = null; - // note: redmineRoot will not work if it's installed anywhere other than /, so - // foo.com/redmine will not work - var redmineRoot = window.location.protocol + "//" + window.location.host + "/"; if($('body.action-index') == null || $('body.action-index').length === 0) { alert("This page doesn't look like a Redmine issues list! Please find some issues"); @@ -88,13 +91,15 @@ Kanbanise.prototype.init = function() { */ function resizeColumns() { var maxH = 0; - for(var i = 1; i <= 4; i++) { - $('#col' + i).height('auto'); - if($('#col' + i).height() > maxH) { - maxH = $('#col' + i).height(); + for(var i = 0; i < ISSUES_STATUSES.length; i++) { + $('#col' + ISSUES_STATUSES[i].id).height('auto'); + if($('#col' + ISSUES_STATUSES[i].id).height() > maxH) { + maxH = $('#col' + ISSUES_STATUSES[i].id).height(); } } $('.sortable').height(maxH); + $('.sortable').css('min-height', maxH); + $('.sortable').css('height','100%'); } /** @@ -107,20 +112,20 @@ Kanbanise.prototype.init = function() { receive: function(event, ui) { resizeColumns(); var newStatus = $(ui.item).parent().parent().find('h1').text(); - var newStatusId = 1; - switch(newStatus.toLowerCase()) { - case "backlog": - newStatusId = 1; break; - case "in progress": - newStatusId = 2; break; - case "resolved/with qa": - newStatusId = 3; break; - case "done": - newStatusId = 5; break; - default: - return; // no action if unrecognised + var newStatusId = -1; + + for(var i = 0; i < ISSUES_STATUSES.length; i ++) { + if(ISSUES_STATUSES[i].name == newStatus) { + newStatusId = ISSUES_STATUSES[i].id; + break; + } } + if(newStatusId == -1) { + alert('No action :('); + return; // no action if unrecognised + } + if (API_KEY === null) { alert("No API key was set. Are you definitely logged in?"); } @@ -150,50 +155,36 @@ Kanbanise.prototype.init = function() { * Make a request to the account page and extract the API access key * User has to be logged in for this to work */ - function loadApiKey(issues) { + function loadApiKey() { showMessage("Loading API key..."); - jQuery.ajax(redmineRoot + 'my/account', {complete: function(jqHRX, text) { - var responseText = jqHRX.responseText; - var start = responseText.indexOf("id='api-access-key'"); - var hunk = responseText.substring(start, start+100); - var startKey = hunk.indexOf('>') + 1; - API_KEY = hunk.substring(startKey, startKey + 40); - - setUpSorting(); - $("").appendTo("head"); - showMessage("Loaded API key"); - - $(msgWin).delay(3000).fadeOut('slow'); - }}); + jQuery.ajax( + redmineRoot + 'my/account', + { + async: false, + complete: function(jqHRX, text) { + var responseText = jqHRX.responseText; + var start = responseText.indexOf("id='api-access-key'"); + var hunk = responseText.substring(start, start+100); + var startKey = hunk.indexOf('>') + 1; + API_KEY = hunk.substring(startKey, startKey + 40); + } + }); } /** * Scrape a screenful of issues in Redmine */ function getIssues() { - var issues = { - 'backlog': [], - 'inProgress': [], - 'resolved': [], - 'done': [] - }; + + var issues = {}; + + for(i = 0; i < ISSUES_STATUSES.length; i++) { + issues[ISSUES_STATUSES[i].name] = []; + } var rows = $('table.issues tr.issue'); rows.each(function(index, value) { - var category = 'backlog'; - - switch(jQuery(value).children('.status')[0].innerHTML) { - case 'Closed': - category = 'done'; - break; - case 'In Progress': - category = 'inProgress'; - break; - case 'Resolved': - case 'Ready for QA': - category = 'resolved'; - break; - } + var category = jQuery(value).children('.status')[0].innerHTML; var storyPoints = ''; var assignedTo = ''; @@ -269,15 +260,14 @@ Kanbanise.prototype.init = function() { function drawBoard(issues) { var div = $('div#kanban'); - var col1Content = self.applyTemplateTicket(issues['backlog']); - var col2Content = self.applyTemplateTicket(issues['inProgress']); - var col3Content = self.applyTemplateTicket(issues['resolved']); - var col4Content = self.applyTemplateTicket(issues['done']); + for(i = 0; i < ISSUES_STATUSES.length; i++) { + $(div).append(self.applyTemplateCol( + ISSUES_STATUSES[i].name, + 'col' + ISSUES_STATUSES[i].id, + self.applyTemplateTicket(issues[ISSUES_STATUSES[i].name]) + )); + } - $(div).append(self.applyTemplateCol('Backlog', 'col1', col1Content)); - $(div).append(self.applyTemplateCol('In progress', 'col2', col2Content)); - $(div).append(self.applyTemplateCol('Resolved/with QA', 'col3', col3Content)); - $(div).append(self.applyTemplateCol('Done', 'col4', col4Content)); $(div).append($('
    Kanbanise ' + VERSION + ' - brought to you by Box UK' @@ -340,16 +330,47 @@ Kanbanise.prototype.init = function() { + "").appendTo("head"); } + function loadData() { + var issues_status = null; + + jQuery.ajax(redmineRoot + 'issue_statuses.json', { + headers: { + 'X-Redmine-API-Key': API_KEY, + 'Content-Type': 'application/json' + }, + processData: false, + dataType: 'json', + data: JSON.stringify(), + type: 'GET', + async: false + }).done(function(response) { + ISSUES_STATUSES = response.issue_statuses; + }); + + } + + // main addStyling(); + loadApiKey(); + loadData(); var issues = getIssues(); var div = createBoard(); $('body').append(div); drawBoard(issues); - loadApiKey(issues); + setUpSorting(); + $("").appendTo("head"); + showMessage("Loaded API key"); + $(msgWin).delay(3000).fadeOut('slow'); resizeColumns(); + + // Redefine column size + var size = parseInt(100 / $('.columnWrapper').length); + $('.columnWrapper').css('width', size + '%'); + }; + (function () { "use strict"; var MIN_JQUERY_VERSION = '1.8.1'; diff --git a/src/minifiy.sh b/src/minifiy.sh new file mode 100644 index 0000000..b300326 --- /dev/null +++ b/src/minifiy.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo -n 'javascript:(function(){'; yui-compressor kanbanise.js; echo "})();"