Skip to content

Commit

Permalink
#1541 Use API v1 in case merge dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Oct 19, 2020
1 parent 4904265 commit 48d0fb9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions frontend/app/scripts/controllers/case/CaseMergeModalCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
angular.module('theHiveControllers')
.controller('CaseMergeModalCtrl', CaseMergeModalCtrl);

function CaseMergeModalCtrl($state, $uibModalInstance, $q, SearchSrv, CaseSrv, UserSrv, NotificationSrv, source, title, prompt) {
function CaseMergeModalCtrl($state, $uibModalInstance, $q, QuerySrv, SearchSrv, CaseSrv, UserSrv, NotificationSrv, source, title, prompt) {
var me = this;

this.source = source;
Expand All @@ -13,32 +13,41 @@
this.prompt = prompt;
this.search = {
type: 'title',
placeholder: 'Search by case title',
placeholder: 'Search by case title. "Ex: Malware*"',
minInputLength: 1,
input: null,
cases: []
};
this.getUserInfo = UserSrv.getCache;

this.getCaseByTitle = function(type, input) {
this.getCaseList = function(type, input) {
var defer = $q.defer();

var query = (type === 'title') ? {
_like: {title: input}
var filter = (type === 'title') ? {
_like: {
title: input
}
} : {
caseId: Number.parseInt(input)
_field: 'number',
_value: Number.parseInt(input)
};

SearchSrv(function(data /*, total*/ ) {
QuerySrv.call('v1',
[{_name: 'listCase'}],
{
filter:filter,
name: 'get-case-for-merge'
}
).then(function(data) {
defer.resolve(data);
}, query, 'case', 'all');
});

return defer.promise;
};

this.format = function(caze) {
if (caze) {
return '#' + caze.caseId + ' - ' + caze.title;
return '#' + caze.number + ' - ' + caze.title;
}
return null;
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/partials/case/case.merge.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h3 class="modal-title">{{dialog.title | ellipsis:50}}</h3>
<input type="{{dialog.search.type === 'number' ? 'number' : 'text'}}"
placeholder="{{dialog.search.placeholder}}"
ng-model="dialog.search.input"
uib-typeahead="caze as dialog.format(caze) for caze in dialog.getCaseByTitle(dialog.search.type, $viewValue)"
uib-typeahead="caze as dialog.format(caze) for caze in dialog.getCaseList(dialog.search.type, $viewValue)"
typeahead-wait-ms="500"
typeahead-min-length="dialog.search.minInputLength"
typeahead-on-select="dialog.onSelect($item)"
Expand Down

0 comments on commit 48d0fb9

Please sign in to comment.