-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#76 add stats section to case listing page
- Loading branch information
Showing
5 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Controller for About The Hive modal page | ||
*/ | ||
(function() { | ||
'use strict'; | ||
|
||
angular.module('theHiveControllers').controller('CaseStatsCtrl', | ||
function($rootScope, $stateParams, $timeout, StatSrv, StreamStatSrv, CasesUISrv) { | ||
var self = this; | ||
|
||
this.uiSrv = CasesUISrv; | ||
|
||
this.byResolution = {}; | ||
this.byStatus = {}; | ||
this.byTags = {}; | ||
|
||
// Get stats by tags | ||
StreamStatSrv({ | ||
rootId: 'any', | ||
query: {}, | ||
objectType: 'case', | ||
field: 'tags', | ||
sort: ['-count'], | ||
limit: 5, | ||
result: {}, | ||
success: function(data){ | ||
self.byTags = self.prepareResult(data); | ||
} | ||
}); | ||
|
||
// Get stats by type | ||
StreamStatSrv({ | ||
rootId: 'any', | ||
query: {}, | ||
objectType: 'case', | ||
field: 'status', | ||
result: {}, | ||
success: function(data){ | ||
self.byStatus = self.prepareResult(data); | ||
} | ||
}); | ||
|
||
// Get stats by ioc | ||
StreamStatSrv({ | ||
rootId: 'any', | ||
query: {}, | ||
objectType: 'case', | ||
field: 'resolutionStatus', | ||
result: {}, | ||
success: function(data){ | ||
self.byResolution = self.prepareResult(data); | ||
} | ||
}); | ||
|
||
this.prepareResult = function(rawStats) { | ||
var total = rawStats.count; | ||
|
||
var keys = _.without(_.keys(rawStats), 'count'); | ||
var columns = keys.map(function(key) { | ||
return { | ||
key: key, | ||
count: rawStats[key].count | ||
}; | ||
}).sort(function(a, b) { | ||
return a.count <= b.count; | ||
}); | ||
|
||
return { | ||
total: total, | ||
details: columns | ||
}; | ||
}; | ||
|
||
this.filterBy = function(field, value) { | ||
this.uiSrv.addFilter(field, value); | ||
}; | ||
} | ||
); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters