-
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.
#53 Update the analyzer service to use the cortex connector apis
- Loading branch information
Showing
12 changed files
with
255 additions
and
136 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 |
---|---|---|
@@ -1,16 +1,86 @@ | ||
(function() { | ||
(function () { | ||
'use strict'; | ||
angular.module('theHiveServices') | ||
.factory('AnalyzerSrv', function($resource) { | ||
return $resource('/api/connector/cortex/analyzer/:analyzerId', {}, { | ||
query: { | ||
method: 'GET', | ||
url: '/api/connector/cortex/analyzer', | ||
isArray: true | ||
.factory('AnalyzerSrv', function ($resource, $q) { | ||
var analyzers = null, | ||
resource = $resource('/api/connector/cortex/analyzer/:analyzerId', {}, { | ||
query: { | ||
method: 'GET', | ||
url: '/api/connector/cortex/analyzer', | ||
isArray: true | ||
}, | ||
get: { | ||
isArray: true | ||
}, | ||
update: { | ||
method: 'PATCH' | ||
} | ||
}); | ||
|
||
var factory = { | ||
clearCache: function () { | ||
analyzers = null; | ||
}, | ||
update: { | ||
method: 'PATCH' | ||
query: function () { | ||
var deferred = $q.defer(); | ||
|
||
if (analyzers === null) { | ||
|
||
resource.query({ | ||
range: 'all' | ||
}, {}, function (response) { | ||
analyzers = _.indexBy(response, 'id'); | ||
|
||
deferred.resolve(analyzers); | ||
}, function (rejection) { | ||
deferred.reject(rejection); | ||
}) | ||
|
||
} else { | ||
deferred.resolve(analyzers); | ||
} | ||
|
||
return deferred.promise; | ||
}, | ||
|
||
get: function(analyzerId) { | ||
var deferred = $q.defer(); | ||
|
||
if(analyzers !== null && analyzers[analyzerId]) { | ||
deferred.resolve(analyzers[analyzerId]); | ||
} else { | ||
resource.get({ | ||
'analyzerId': analyzerId | ||
}, function (data) { | ||
deferred.resolve(data); | ||
}, function (rejection) { | ||
deferred.reject(rejection); | ||
}); | ||
} | ||
|
||
return deferred.promise; | ||
}, | ||
|
||
forDataType: function(dataType) { | ||
var deferred = $q.defer(); | ||
|
||
factory.query() | ||
.then(function(all) { | ||
var filtered = {}; | ||
_.each(all, function(value, key) { | ||
if(value.dataTypeList && value.dataTypeList.indexOf(dataType) !== -1) { | ||
filtered[key] = angular.copy(value); | ||
filtered[key].active = true; | ||
} | ||
}); | ||
|
||
deferred.resolve(filtered); | ||
}); | ||
|
||
return deferred.promise; | ||
} | ||
}); | ||
}; | ||
|
||
return factory; | ||
}); | ||
})(); |
Oops, something went wrong.