Skip to content

Commit

Permalink
#831 Add auto complete to case and observable tags in details page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Feb 13, 2019
1 parent 510d89e commit 69c7473
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
12 changes: 8 additions & 4 deletions ui/app/scripts/controllers/case/CaseDetailsCtrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
'use strict';

angular.module('theHiveControllers').controller('CaseDetailsCtrl', function($scope, $state, $uibModal, CaseTabsSrv, UserInfoSrv, PSearchSrv) {
angular.module('theHiveControllers').controller('CaseDetailsCtrl', function($scope, $state, $uibModal, CaseTabsSrv, UserInfoSrv, TagSrv, PSearchSrv) {

CaseTabsSrv.activateTab($state.current.data.tab);

Expand Down Expand Up @@ -98,6 +98,10 @@
itemId: attachment.case_task.id
});
};

$scope.getCaseTags = function(query) {
return TagSrv.fromCases(query);
};
});

angular.module('theHiveControllers').controller('CaseCustomFieldsCtrl', function($scope, $uibModal, CustomFieldsCacheSrv) {
Expand All @@ -108,13 +112,13 @@
return {
name: name,
order: definition.order
}
};
}), function(item){
return item.order;
}), 'name');

return result;
}
};

$scope.getCustomFieldName = function(fieldDef) {
return 'customFields.' + fieldDef.reference + '.' + fieldDef.type;
Expand Down Expand Up @@ -178,4 +182,4 @@
};
});

})();
})();
19 changes: 12 additions & 7 deletions ui/app/scripts/controllers/case/CaseObservablesItemCtrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('theHiveControllers').controller('CaseObservablesItemCtrl',
function ($scope, $state, $stateParams, $q, $filter, $timeout, $document, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, NotificationSrv, VersionSrv, appConfig) {
function ($scope, $state, $stateParams, $q, $filter, $timeout, $document, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, NotificationSrv, VersionSrv, TagSrv, appConfig) {
var observableId = $stateParams.itemId,
observableName = 'observable-' + observableId;

Expand Down Expand Up @@ -57,7 +57,7 @@
$scope.initScope(observable);

}, function (response) {
NotificationSrv.error('artifactDetails', response.data, response.status);
NotificationSrv.error('ObservableDetails', response.data, response.status);
CaseTabsSrv.activateTab('observables');
});

Expand Down Expand Up @@ -129,7 +129,7 @@
}, function (observable) {
$scope.artifact = observable;
}, function (response) {
NotificationSrv.error('artifactDetails', response.data, response.status);
NotificationSrv.error('ObservableDetails', response.data, response.status);
CaseTabsSrv.activateTab('observables');
});
}
Expand Down Expand Up @@ -195,8 +195,9 @@
artifactId: $scope.artifact.id
}, field, function (response) {
$scope.artifact = response.toJSON();
NotificationSrv.log('Observable has been updated', 'success');
}, function (response) {
NotificationSrv.error('artifactDetails', response.data, response.status);
NotificationSrv.error('ObservableDetails', response.data, response.status);
});
};

Expand All @@ -211,7 +212,7 @@
$scope.runAnalyzer = function (analyzerName, serverId) {
var artifactName = $scope.artifact.data || $scope.artifact.attachment.name;

var promise = serverId ? $q.resolve(serverId) : CortexSrv.getServers([analyzerName])
var promise = serverId ? $q.resolve(serverId) : CortexSrv.getServers([analyzerName]);

promise.then(function (serverId) {
return $scope._runAnalyzer(serverId, analyzerName, $scope.artifact.id);
Expand Down Expand Up @@ -254,8 +255,8 @@
$scope.obsResponders = responders;
})
.catch(function(err) {
NotificationSrv.error('observablesList', response.data, response.status);
})
NotificationSrv.error('observablesList', err.data, err.status);
});
};

$scope.runResponder = function(responderId, responderName, artifact) {
Expand All @@ -271,6 +272,10 @@
});
};

$scope.getTags = function(query) {
return TagSrv.fromObservables(query);
};

}
);

Expand Down
3 changes: 2 additions & 1 deletion ui/app/scripts/directives/updatableTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
'scope': {
'value': '=?',
'onUpdate': '&',
'active': '=?'
'active': '=?',
'source': '='
}
};
});
Expand Down
1 change: 1 addition & 0 deletions ui/app/views/directives/updatable-tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<span ng-show="updatable.updating">
<div class="form-group">
<tags-input class="ti-input-sm" min-length="2" ng-model="value" placeholder="Add labels" replace-spaces-with-dashes="false">
<auto-complete ng-if="source" min-length="1" debounceDelay="400" source="source($query)"></auto-complete>
</tags-input>
</div>
<div class="form-group">
Expand Down
4 changes: 2 additions & 2 deletions ui/app/views/partials/case/case.details.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ <h4 class="vpad10 text-primary">Summary</h4>
</dd>
</dl>

<dl class="dl-horizontal clear">
<dl class="dl-horizontal">
<dt class="pull-left">Tags</dt>
<dd>
<updatable-tags on-update="updateField('tags', getTags(newValue))" value="caze.tags"></updatable-tags>
<updatable-tags on-update="updateField('tags', getTags(newValue))" value="caze.tags" source="getCaseTags"></updatable-tags>
</dd>
</dl>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ <h4 class="vpad10 text-primary">
</dd>
</dl>

<dl class="dl-horizontal clear">
<dt class="pull-left">Labels</dt>
<dl class="dl-horizontal">
<dt class="pull-left">Tags</dt>
<dd>
<updatable-tags value="artifact.tags" on-update="updateField('tags', getLabels(newValue))"></updatable-tags>
<updatable-tags value="artifact.tags" on-update="updateField('tags', getLabels(newValue))" source="getTags"></updatable-tags>
</dd>
</dl>

Expand Down

0 comments on commit 69c7473

Please sign in to comment.