Skip to content

Commit

Permalink
#26 Refresh template menu after creation/update/delete of a template
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Nov 30, 2016
1 parent b862f87 commit 49c03d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ui/app/scripts/controllers/RootCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ angular.module('theHiveControllers').controller('RootCtrl',
AlertSrv.error('RootCtrl', data, status);
});

$scope.$on('templates:refresh', function(){
$scope.templates = TemplateSrv.query();
});

$scope.$on('metrics:refresh', function() {
// Get metrics cache
MetricsCacheSrv.all().then(function(list) {
Expand Down
9 changes: 9 additions & 0 deletions ui/app/scripts/controllers/admin/AdminTemplatesCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
console.log("Create Template: " + $scope.template.name);
return TemplateSrv.save($scope.template, function() {
$scope.getList(0);

$scope.$emit('templates:refresh');

AlertSrv.log('The template [' + $scope.template.name + '] has been successfuly created', 'success');
}, function(response) {
AlertSrv.error('TemplateCtrl', response.data, response.status);
Expand All @@ -139,6 +142,9 @@
templateId: $scope.template.id
}, _.omit($scope.template, ['id', 'user', 'type']), function() {
$scope.getList($scope.templateIndex);

$scope.$emit('templates:refresh');

AlertSrv.log('The template [' + $scope.template.name + '] has been successfuly updated', 'success');
}, function(response) {
AlertSrv.error('TemplateCtrl', response.data, response.status);
Expand Down Expand Up @@ -172,6 +178,9 @@
templateId: $scope.template.id
}, function() {
$scope.getList(0);

$scope.$emit('templates:refresh');

$modalInstance.dismiss();
});
};
Expand Down

0 comments on commit 49c03d9

Please sign in to comment.