Skip to content

Commit

Permalink
#1242 Check that cortex is available before calling related APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed May 3, 2020
1 parent 0c0e310 commit 18820ca
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 72 deletions.
50 changes: 27 additions & 23 deletions frontend/app/scripts/controllers/case/CaseDetailsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,34 @@
nparent: 1
});

$scope.actions = PSearchSrv(null, 'connector/cortex/action', {
scope: $scope,
streamObjectType: 'action',
filter: {
_and: [
{
_not: {
status: 'Deleted'

var connectors = $scope.appConfig.connectors;
if(connectors.cortex && connectors.cortex.enabled) {
$scope.actions = PSearchSrv(null, 'connector/cortex/action', {
scope: $scope,
streamObjectType: 'action',
filter: {
_and: [
{
_not: {
status: 'Deleted'
}
}, {
objectType: 'case'
}, {
objectId: $scope.caseId
}
}, {
objectType: 'case'
}, {
objectId: $scope.caseId
}
]
},
sort: ['-startDate'],
pageSize: 100,
guard: function(updates) {
return _.find(updates, function(item) {
return (item.base.object.objectType === 'case') && (item.base.object.objectId === $scope.caseId);
}) !== undefined;
}
});
]
},
sort: ['-startDate'],
pageSize: 100,
guard: function(updates) {
return _.find(updates, function(item) {
return (item.base.object.objectType === 'case') && (item.base.object.objectId === $scope.caseId);
}) !== undefined;
}
});
}

$scope.openAttachment = function(attachment) {
$state.go('app.case.tasks-item', {
Expand Down
55 changes: 30 additions & 25 deletions frontend/app/scripts/controllers/case/CaseObservablesItemCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$scope.obsResponders = null;
$scope.analyzers = {};
$scope.analyzerJobs = {};
$scope.jobs = {};
//$scope.jobs = {};
$scope.state = {
'editing': false,
'isCollapsed': false,
Expand Down Expand Up @@ -61,33 +61,38 @@
$scope.analyzers = [];
})
.finally(function () {
$scope.jobs = CortexSrv.list($scope, $scope.caseId, observableId, $scope.onJobsChange);
if($scope.analysisEnabled) {
$scope.jobs = CortexSrv.list($scope, $scope.caseId, observableId, $scope.onJobsChange);
}
});

$scope.actions = PSearchSrv(null, 'connector/cortex/action', {
scope: $scope,
streamObjectType: 'action',
filter: {
_and: [
{
_not: {
status: 'Deleted'
var connectors = $scope.appConfig.connectors;
if(connectors.cortex && connectors.cortex.enabled) {
$scope.actions = PSearchSrv(null, 'connector/cortex/action', {
scope: $scope,
streamObjectType: 'action',
filter: {
_and: [
{
_not: {
status: 'Deleted'
}
}, {
objectType: 'case_artifact'
}, {
objectId: artifact.id
}
}, {
objectType: 'case_artifact'
}, {
objectId: artifact.id
}
]
},
sort: ['-startDate'],
pageSize: 100,
guard: function(updates) {
return _.find(updates, function(item) {
return (item.base.object.objectType === 'case_artifact') && (item.base.object.objectId === artifact.id);
}) !== undefined;
}
});
]
},
sort: ['-startDate'],
pageSize: 100,
guard: function(updates) {
return _.find(updates, function(item) {
return (item.base.object.objectType === 'case_artifact') && (item.base.object.objectId === artifact.id);
}) !== undefined;
}
});
}
};

// Prepare the scope data
Expand Down
49 changes: 26 additions & 23 deletions frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,33 @@
}
});

$scope.actions = PSearchSrv(null, 'connector/cortex/action', {
scope: $scope,
streamObjectType: 'action',
filter: {
_and: [
{
_not: {
status: 'Deleted'
var connectors = $scope.appConfig.connectors;
if(connectors.cortex && connectors.cortex.enabled) {
$scope.actions = PSearchSrv(null, 'connector/cortex/action', {
scope: $scope,
streamObjectType: 'action',
filter: {
_and: [
{
_not: {
status: 'Deleted'
}
}, {
objectType: 'case_task'
}, {
objectId: taskId
}
}, {
objectType: 'case_task'
}, {
objectId: taskId
}
]
},
sort: ['-startDate'],
pageSize: 100,
guard: function(updates) {
return _.find(updates, function(item) {
return (item.base.object.objectType === 'case_task') && (item.base.object.objectId === taskId);
}) !== undefined;
}
});
]
},
sort: ['-startDate'],
pageSize: 100,
guard: function(updates) {
return _.find(updates, function(item) {
return (item.base.object.objectType === 'case_task') && (item.base.object.objectId === taskId);
}) !== undefined;
}
});
}
};

$scope.switchFlag = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ <h4 class="pv-xxs pr-xxs text-primary">
<small><a href class="text-primary" ng-click="runAll()">Run all</a></small>
</span>
</h4>
<table class="table table-striped">

<div ng-if="!jobs || !analyzers || analyzers.length === 0">
<div class="empty-message">No records</div>
</div>

<table class="table table-striped" ng-if="jobs || analyzers.length > 0">
<thead>
<th>Analyzer</th>
<th width="450">Last analysis</th>
Expand Down

0 comments on commit 18820ca

Please sign in to comment.