-
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.
- Loading branch information
Showing
30 changed files
with
882 additions
and
91 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
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
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,151 @@ | ||
(function() { | ||
'use strict'; | ||
angular.module('theHiveControllers') | ||
.controller('CaseListCtrl', CaseListCtrl); | ||
|
||
function CaseListCtrl($scope, $q, CasesUISrv, StreamStatSrv, PSearchSrv, EntitySrv, UserInfoSrv, TagSrv) { | ||
var self = this; | ||
|
||
this.showFlow = true; | ||
this.openEntity = EntitySrv.open; | ||
this.getUserInfo = UserInfoSrv; | ||
|
||
this.uiSrv = CasesUISrv; | ||
this.uiSrv.initContext('list'); | ||
this.searchForm = { | ||
searchQuery: this.uiSrv.buildQuery() || '' | ||
}; | ||
|
||
this.list = PSearchSrv(undefined, 'case', { | ||
filter: self.searchForm.searchQuery !== '' ? { | ||
_string: self.searchForm.searchQuery | ||
} : '', | ||
loadAll: false, | ||
sort: self.uiSrv.context.sort, | ||
pageSize: self.uiSrv.context.pageSize, | ||
nstats: true | ||
}); | ||
|
||
this.caseStats = StreamStatSrv({ | ||
rootId: 'any', | ||
query: {}, | ||
result: {}, | ||
objectType: 'case', | ||
field: 'status' | ||
}); | ||
|
||
|
||
$scope.$watch('$vm.list.pageSize', function (newValue) { | ||
self.uiSrv.setPageSize(newValue); | ||
}); | ||
|
||
this.toggleStats = function () { | ||
this.uiSrv.toggleStats(); | ||
}; | ||
|
||
this.toggleFilters = function () { | ||
this.uiSrv.toggleFilters(); | ||
}; | ||
|
||
this.filter = function () { | ||
this.uiSrv.filter().then(this.applyFilters); | ||
}; | ||
|
||
this.applyFilters = function () { | ||
self.searchForm.searchQuery = self.uiSrv.buildQuery(); | ||
self.search(); | ||
}; | ||
|
||
this.clearFilters = function () { | ||
this.uiSrv.clearFilters().then(this.applyFilters); | ||
}; | ||
|
||
this.addFilter = function (field, value) { | ||
this.uiSrv.addFilter(field, value).then(this.applyFilters); | ||
}; | ||
|
||
this.removeFilter = function (field) { | ||
this.uiSrv.removeFilter(field).then(this.applyFilters); | ||
}; | ||
|
||
this.search = function () { | ||
this.list.filter = { | ||
_string: this.searchForm.searchQuery | ||
}; | ||
|
||
this.list.update(); | ||
}; | ||
this.addFilterValue = function (field, value) { | ||
var filterDef = this.uiSrv.filterDefs[field]; | ||
var filter = this.uiSrv.activeFilters[field]; | ||
var date; | ||
|
||
if (filter && filter.value) { | ||
if (filterDef.type === 'list') { | ||
if (_.pluck(filter.value, 'text').indexOf(value) === -1) { | ||
filter.value.push({ | ||
text: value | ||
}); | ||
} | ||
} else if (filterDef.type === 'date') { | ||
date = moment(value, ['YYYYMMDDTHHmmZZ', 'DD-MM-YYYY HH:mm']); | ||
this.uiSrv.activeFilters[field] = { | ||
value: { | ||
from: date.hour(0).minutes(0).seconds(0).toDate(), | ||
to: date.hour(23).minutes(59).seconds(59).toDate() | ||
} | ||
}; | ||
} else { | ||
filter.value = value; | ||
} | ||
} else { | ||
if (filterDef.type === 'list') { | ||
this.uiSrv.activeFilters[field] = { | ||
value: [{ | ||
text: value | ||
}] | ||
}; | ||
} else if (filterDef.type === 'date') { | ||
date = moment(value, ['YYYYMMDDTHHmmZZ', 'DD-MM-YYYY HH:mm']); | ||
this.uiSrv.activeFilters[field] = { | ||
value: { | ||
from: date.hour(0).minutes(0).seconds(0).toDate(), | ||
to: date.hour(23).minutes(59).seconds(59).toDate() | ||
} | ||
}; | ||
} else { | ||
this.uiSrv.activeFilters[field] = { | ||
value: value | ||
}; | ||
} | ||
} | ||
|
||
this.filter(); | ||
}; | ||
|
||
this.getStatuses = function() { | ||
return $q.resolve([ | ||
{text: 'Open'}, | ||
{text: 'Resolved'} | ||
]); | ||
}; | ||
|
||
this.getTags = function(query) { | ||
return TagSrv.fromCases(query); | ||
}; | ||
|
||
this.filterByStatus = function(status) { | ||
this.uiSrv.clearFilters() | ||
.then(function(){ | ||
self.addFilterValue('status', status); | ||
}); | ||
}; | ||
|
||
this.sortBy = function(sort) { | ||
this.list.sort = sort; | ||
this.list.update(); | ||
this.uiSrv.setSort(sort); | ||
}; | ||
|
||
} | ||
})(); |
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
Oops, something went wrong.