Skip to content

Commit

Permalink
#449 Allow TheHive admin to disable creating an empty case from heade…
Browse files Browse the repository at this point in the history
…r or alert
  • Loading branch information
nadouani committed Feb 20, 2019
1 parent 27db888 commit afab711
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 36 deletions.
5 changes: 4 additions & 1 deletion ui/app/scripts/controllers/RootCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,16 @@ angular.module('theHiveControllers').controller('RootCtrl',
resolve: {
templates: function(){
return $scope.templates;
},
uiSettings: function(UiSettingsSrv) {
return UiSettingsSrv.all();
}
}
});

modal.result.then(function(template) {
$scope.createNewCase(template);
})
});
};

$scope.aboutTheHive = function() {
Expand Down
3 changes: 3 additions & 0 deletions ui/app/scripts/controllers/alert/AlertListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@
resolve: {
templates: function(){
return templates;
},
uiSettings: function(UiSettingsSrv) {
return UiSettingsSrv.all();
}
}
});
Expand Down
8 changes: 5 additions & 3 deletions ui/app/scripts/controllers/case/CaseTemplatesDialogCtrl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
(function() {
'use strict';
angular.module('theHiveControllers').controller('CaseTemplatesDialogCtrl',
function($scope, $uibModalInstance, templates) {
function($scope, $uibModalInstance, UiSettingsSrv, templates, uiSettings) {
this.templates = templates;
this.uiSettings = uiSettings;
this.state = {
filter: null,
selected: null
selected: null,
hideEmptyCaseButton: UiSettingsSrv.hideEmptyCaseButton()
};

this.selectTemplate = function(template) {
Expand All @@ -18,7 +20,7 @@

this.next = function(template) {
$uibModalInstance.close(template);
}
};

this.cancel = function() {
$uibModalInstance.dismiss();
Expand Down
20 changes: 14 additions & 6 deletions ui/app/scripts/services/UiSettingsSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

var settings = null;

return {
keys: [
'hideEmptyCaseButton',
'hideMyTasks',
'hideWaitingTasks'
],
var keys = [
'hideEmptyCaseButton'
];

var factory = {
keys: keys,
clearCache: function() {
settings = null;
},
Expand Down Expand Up @@ -63,5 +63,13 @@
return deferred.promise;
}
};

keys.forEach(function(key) {
factory[key] = function() {
return (settings[key] || {}).value;
};
});

return factory;
});
})();
22 changes: 0 additions & 22 deletions ui/app/views/partials/admin/ui-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,6 @@ <h3 class="box-title">UI Settings</h3>
</div>
</div>

<div class="form-group">
<label class="col-md-3 control-label">Hide <em>My Tasks</em> menu</label>
<div class="col-md-9">
<div class="checkbox">
<label>
<input name="hideMyTasks" type="checkbox" ng-model="$vm.configs.hideMyTasks"> Check this to hide the <em>My Tasks</em> menu from the header
</label>
</div>
</div>
</div>

<div class="form-group">
<label class="col-md-3 control-label">Hide <em>Waiting Task</em> menu</label>
<div class="col-md-9">
<div class="checkbox">
<label>
<input name="hideWaitingTasks" type="checkbox" ng-model="$vm.configs.hideWaitingTasks"> Check this to hide the <em>Waiting Tasks</em> menu from the header
</label>
</div>
</div>
</div>

<div class="mt-s">
<button class="btn btn-primary pull-right" ng-disabled="settingsForm.$invalid" type="submit">Save</button>
</div>
Expand Down
8 changes: 4 additions & 4 deletions ui/app/views/partials/case/case.templates.selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<h3 class="modal-title">Create new Case</h3>
</div>
<div class="modal-body">
<div class="mv-xs">
<div class="mv-xs" ng-if="!!!dialog.state.hideEmptyCaseButton">
<button class="btn btn-block btn-primary btn-lg" ng-click="dialog.next()">
Empty Case
</button>
</div>

<p class="mv-m text-separator text-muted">OR</p>
<p class="mv-m text-separator text-muted">OR</p>
</div>

<div class="box box-primary">
<div class="box box-default">
<div class="box-header">
<h3 class="box-title">Select a template</h3>
<div class="box-tools pull-right">
Expand Down

0 comments on commit afab711

Please sign in to comment.