angular.module("solJIRAApp") .factory("SolJIRAService", function($http, $filter, $templateCache, $log, config) { var jiraURL = 'api/2/'; var serviceDeskURL = 'servicedeskapi/'; var softwareURI = 'agile/1.0/'; return { doRequest: function(type, uri, action, data) { var requestConfig = { url: config.jiraAPIService, method: type, params: { action: action, uri: uri }, data: data }; return $http(requestConfig); }, findWorklogs: function(filters, callback) { var uri = jiraURL + 'search?startAt=0&maxResults=1000&fields=worklog,customfield_11000,customfield_11100,customfield_11401,status,timeoriginalestimate,summary,project&jql='; var jql = 'project=SOLSF'; // if (filters.assignee && filters.assignee != 'allUsers') { // jql += encodeURI(' AND assignee=') + filters.assignee.replace('@', '\\u0040'); // } if (filters.worklogStartDate && filters.worklogEndDate) { jql += encodeURI(' AND worklogDate>=' + filters.worklogStartDate + ' AND worklogDate<=' + filters.worklogEndDate); } uri += jql; console.log('URI', uri); var data = null; var error = false; $http.get(config.jiraAPIService, {params: {type: 'GET', uri: uri}}).success(function(response) { data = angular.fromJson(response.data); }).error(function(response) { data = response; error = true; }).finally(function() { callback(data, error); }); }, getIssuesForBoard: function(callback) { // var uri = softwareURI + 'board/114/issue?startAt=0&maxResults=1000&fields=summary,project,issuetype,timeoriginalestimate,timespent,assignee,status,customfield_11100,customfield_11401'; // var uri = softwareURI + 'board/114/issue?startAt=0&maxResults=1000&fields=project,summary,description,status,issuetype,timeoriginalestimate,timespent,assignee,customfield_11100,customfield_11401'; // var uri = softwareURI + 'board/114/issue?startAt=0&maxResults=1000&fields=summary'; // var uri = softwareURI + 'board/114/issue?startAt=0&maxResults=1000&fields=project,summary,description,status,issuetype,timeoriginalestimate,timespent,assignee,customfield_11100,customfield_11401,comment&jql=project=TLVIN'; var uri = jiraURL + 'search?startAt=0&maxResults=1000&fields=project,summary,description,status,issuetype,timeoriginalestimate,timespent,assignee,customfield_11100,customfield_11401,comment&jql='; uri += 'project=TLVIN%20AND%20statusCategory%3DDone'; var data = null; var error = false; $http.get(config.jiraAPIService, {params: {type: 'GET', uri: uri}}).success(function(response) { console.log('What'); console.log(response); data = angular.fromJson(response.data); }).error(function(response) { data = response; error = true; }).finally(function() { callback(data, error); }); }, loadUsers: function(callback) { var uri = jiraURL + 'user/search?startAt=0&maxResults=1000&username=%'; var data = null; var error = false; $http.get(config.jiraAPIService, {params: {type: 'GET', uri: uri}}).success(function(response) { data = angular.fromJson(response.data); }).error(function(response) { data = response; error = true; }).finally(function() { callback(data, error); }); }, getOrganizations: function(callback) { var uri = serviceDeskURL + 'organization'; var data = null; var error = false; $http.get(config.jiraAPIService, {params: {type: 'GET', uri: uri}}).success(function(response) { data = angular.fromJson(response.data); }).error(function(response) { data = response; error = true; }).finally(function() { callback(data, error); }); } }; }).factory('Excel',function($window) { var uri='data:application/vnd.ms-excel;base64,', template='{table}
', base64=function(s){return $window.btoa(unescape(encodeURIComponent(s)));}, format=function(s,c){return s.replace(/{(\w+)}/g,function(m,p){return c[p];})}; return { tableToExcel:function(tableId,worksheetName) { var table=$(tableId), ctx={worksheet:worksheetName,table:table.html()}, href=uri+base64(format(template,ctx)); return href; } }; });