82 lines
3.6 KiB
JavaScript
82 lines
3.6 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('chartModule')
|
|
.service('chartService', ['$resource', function ($resource) {
|
|
var resource = $resource('', {}, {
|
|
getChartStatisticsData: { url: '/smartit/rest/foundation/stats/get', method: 'POST', isArray: true },
|
|
getChangeData: { url: '/smartit/rest/v2/foundation/mtcstats/get', method: 'POST', isArray: true }
|
|
});
|
|
this.getChartStatisticsData = function (ticketType, chartTypes, companies, supportGroups, days) {
|
|
var params = {
|
|
filterCriteria: {
|
|
companies: companies,
|
|
assignedSupportGroups: supportGroups
|
|
},
|
|
stats: []
|
|
};
|
|
if (chartTypes.indexOf('kpi') !== -1) {
|
|
params.stats.push({
|
|
name: ticketType + '-kpi',
|
|
primaryGroupBy: '',
|
|
secondaryGroupBy: ''
|
|
});
|
|
}
|
|
if (chartTypes.indexOf('stack') !== -1) {
|
|
params.stats.push({
|
|
name: ticketType + '-open',
|
|
primaryGroupBy: 'priority',
|
|
secondaryGroupBy: 'ticketSpecificStatus',
|
|
filterCriteria: { statusMappings: ['open'] }
|
|
});
|
|
}
|
|
if (chartTypes.indexOf('area') !== -1) {
|
|
params.stats.push({
|
|
name: ticketType + '-backlog-all',
|
|
primaryGroupBy: 'createDate',
|
|
secondaryGroupBy: '',
|
|
filterCriteria: {
|
|
statusMappings: ['open'],
|
|
createDateRange: {
|
|
start: moment().subtract(days, 'days').unix() * 1000,
|
|
end: new Date().getTime()
|
|
}
|
|
}
|
|
});
|
|
if (ticketType === EntityVO.TYPE_INCIDENT) {
|
|
params.stats.push({
|
|
name: ticketType + '-backlog-critical',
|
|
primaryGroupBy: 'createDate',
|
|
secondaryGroupBy: '',
|
|
filterCriteria: {
|
|
statusMappings: ['open'],
|
|
priorities: ['Critical'],
|
|
createDateRange: {
|
|
start: moment().subtract(days, 'days').unix() * 1000,
|
|
end: new Date().getTime()
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
return resource.getChartStatisticsData(params).$promise.then(function (result) {
|
|
return result[0].items[0];
|
|
});
|
|
};
|
|
this.getChangeData = function (companies, supportGroups, stats) {
|
|
var filterCriteria = {
|
|
companies: companies,
|
|
assignedSupportGroups: supportGroups,
|
|
ticketTypes: ['change'],
|
|
isCustomDashboardStats: true
|
|
};
|
|
return resource.getChangeData({
|
|
filterCriteria: filterCriteria,
|
|
stats: stats
|
|
}).$promise.then(function (data) {
|
|
return data[0].items[0].objects;
|
|
});
|
|
};
|
|
}]);
|
|
}());
|