Skip to content

Commit

Permalink
#113 Refresh the report templates list on add/remove template
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Feb 9, 2017
1 parent 70c4769 commit 93641cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 11 additions & 2 deletions ui/app/scripts/controllers/admin/AdminReportTemplatesCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@
self.templates = response[0].data;
self.analyzers = response[1];

var cleared = _.mapObject(self.analyzers, function(val) {
delete val.shortReport;
delete val.longReport;

return val;
});

self.analyzers = cleared;

return $q.resolve(self.analyzers);
}).then(function (analyzersMap) {
if(_.isEmpty(analyzersMap)) {
_.each(_.pluck(self.templates, 'analyzers'), function(item) {
_.each(_.pluck(self.templates, 'analyzerId'), function(item) {
analyzersMap[item] = {
id: item
};
Expand All @@ -37,7 +46,7 @@
_.each(self.templates, function (tpl) {
if(analyzersMap[tpl.analyzerId]) {
analyzersMap[tpl.analyzerId][tpl.reportType + 'Report'] = tpl;
}
}
});

self.analyzerCount = _.keys(analyzersMap).length;
Expand Down
5 changes: 4 additions & 1 deletion ui/app/scripts/services/AnalyzerSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
resource.query({
range: 'all'
}, {}, function (response) {
analyzers = _.indexBy(response, 'id');

analyzers = _.indexBy(_.map(response, function(item) {
return item.toJSON();
}), 'id');

deferred.resolve(analyzers);
}, function (/*rejection*/) {
Expand Down

0 comments on commit 93641cd

Please sign in to comment.