Skip to content

Commit

Permalink
#831 Fix the observable tags input
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Feb 19, 2019
1 parent 3dce91a commit 0644bc1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
14 changes: 14 additions & 0 deletions ui/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,20 @@ angular.module('thehive', ['ngAnimate', 'ngMessages', 'ngSanitize', 'ui.bootstra
resolve: {
appConfig: function(VersionSrv) {
return VersionSrv.get();
},
artifact: function($q, $stateParams, CaseArtifactSrv, NotificationSrv) {
var deferred = $q.defer();

CaseArtifactSrv.api().get({
'artifactId': $stateParams.itemId
}).$promise.then(function(data) {
deferred.resolve(data);
}).catch(function(response) {
deferred.reject(response);
NotificationSrv.error('Observable Details', response.data, response.status);
});

return deferred.promise;
}
}
})
Expand Down
51 changes: 20 additions & 31 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, TagSrv, appConfig) {
function ($scope, $state, $stateParams, $q, $filter, $timeout, $document, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, NotificationSrv, VersionSrv, TagSrv, appConfig, artifact) {
var observableId = $stateParams.itemId,
observableName = 'observable-' + observableId;

Expand All @@ -18,7 +18,7 @@
'logMissing': ''
};

$scope.artifact = {};
$scope.artifact = artifact;
$scope.artifact.tlp = $scope.artifact.tlp || -1;
$scope.analysisEnabled = VersionSrv.hasCortex();
$scope.cortexServers = $scope.analysisEnabled && appConfig.connectors.cortex.servers;
Expand All @@ -32,37 +32,23 @@
mode: 'vb'
};

CaseArtifactSrv.api().get({
'artifactId': observableId
}, function (observable) {

// Add tab
CaseTabsSrv.addTab(observableName, {
name: observableName,
label: observable.data || observable.attachment.name,
closable: true,
state: 'app.case.observables-item',
params: {
itemId: observable.id
}
});

// Select tab
$timeout(function() {
CaseTabsSrv.activateTab(observableName);
}, 0);


// Prepare the scope data
$scope.initScope(observable);

}, function (response) {
NotificationSrv.error('ObservableDetails', response.data, response.status);
CaseTabsSrv.activateTab('observables');
// Add tab
CaseTabsSrv.addTab(observableName, {
name: observableName,
label: artifact.data || artifact.attachment.name,
closable: true,
state: 'app.case.observables-item',
params: {
itemId: artifact.id
}
});

$scope.initScope = function (artifact) {
$scope.artifact = artifact;
// Select tab
$timeout(function() {
CaseTabsSrv.activateTab(observableName);
}, 0);

$scope.initScope = function (artifact) {

// Get analyzers available for the observable's datatype
AnalyzerSrv.forDataType(artifact.dataType)
Expand Down Expand Up @@ -101,6 +87,9 @@
});
};

// Prepare the scope data
$scope.initScope(artifact);

$scope.onJobsChange = function (updates) {
$scope.analyzerJobs = {};

Expand Down

0 comments on commit 0644bc1

Please sign in to comment.