-
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.
#2045 Fix TTP modal's form validation
- Loading branch information
Showing
2 changed files
with
99 additions
and
78 deletions.
There are no files selected for viewing
114 changes: 57 additions & 57 deletions
114
frontend/app/scripts/controllers/case/procedure/AddProcedureModalCtrl.js
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,77 +1,77 @@ | ||
/** | ||
* Controller for About TheHive modal page | ||
*/ | ||
(function() { | ||
(function () { | ||
'use strict'; | ||
|
||
angular.module('theHiveControllers').controller('AddProcedureModalCtrl', function($rootScope, $scope, $uibModalInstance, NotificationSrv, ProcedureSrv, AttackPatternSrv, caseId) { | ||
var self = this; | ||
angular.module('theHiveControllers').controller('AddProcedureModalCtrl', function ($rootScope, $scope, $uibModalInstance, NotificationSrv, ProcedureSrv, AttackPatternSrv, caseId) { | ||
var self = this; | ||
|
||
this.caseId = caseId; | ||
this.caseId = caseId; | ||
|
||
this.close = function() { | ||
$uibModalInstance.close(); | ||
}; | ||
|
||
this.cancel = function() { | ||
if($rootScope.markdownEditorObjects.procedure) { | ||
$rootScope.markdownEditorObjects.procedure.hidePreview(); | ||
} | ||
this.close = function () { | ||
$uibModalInstance.close(); | ||
}; | ||
|
||
$uibModalInstance.dismiss(); | ||
}; | ||
this.cancel = function () { | ||
if ($rootScope.markdownEditorObjects && $rootScope.markdownEditorObjects.procedure) { | ||
$rootScope.markdownEditorObjects.procedure.hidePreview(); | ||
} | ||
|
||
this.addProcedure = function() { | ||
self.state.loading = true; | ||
$uibModalInstance.dismiss(); | ||
}; | ||
|
||
ProcedureSrv.create({ | ||
caseId: self.caseId, | ||
tactic: self.procedure.tactic, | ||
description: self.procedure.description, | ||
patternId: self.procedure.patternId, | ||
occurDate: self.procedure.occurDate | ||
}).then(function(/*response*/) { | ||
self.state.loading = false; | ||
$uibModalInstance.close(); | ||
NotificationSrv.log('Tactic, Technique and Procedure added successfully', 'success'); | ||
}).catch(function(err) { | ||
NotificationSrv.error('Add TTP', err.data, err.status); | ||
self.state.loading = false; | ||
}); | ||
}; | ||
this.addProcedure = function () { | ||
self.state.loading = true; | ||
|
||
this.showTechniques = function() { | ||
AttackPatternSrv.getByTactic(self.procedure.tactic) | ||
.then(function(techniques) { | ||
self.state.techniques = techniques; | ||
ProcedureSrv.create({ | ||
caseId: self.caseId, | ||
tactic: self.procedure.tactic, | ||
description: self.procedure.description, | ||
patternId: self.procedure.patternId, | ||
occurDate: self.procedure.occurDate | ||
}).then(function (/*response*/) { | ||
self.state.loading = false; | ||
$uibModalInstance.close(); | ||
NotificationSrv.log('Tactic, Technique and Procedure added successfully', 'success'); | ||
}).catch(function (err) { | ||
NotificationSrv.error('Add TTP', err.data, err.status); | ||
self.state.loading = false; | ||
}); | ||
}; | ||
|
||
self.procedure.patternId = null; | ||
}); | ||
}; | ||
this.showTechniques = function () { | ||
AttackPatternSrv.getByTactic(self.procedure.tactic) | ||
.then(function (techniques) { | ||
self.state.techniques = techniques; | ||
|
||
this.$onInit = function() { | ||
this.markdownEditorOptions = { | ||
iconlibrary: 'fa', | ||
addExtraButtons: true, | ||
resize: 'vertical' | ||
}; | ||
self.procedure.patternId = null; | ||
}); | ||
}; | ||
|
||
this.procedure = { | ||
tactic: null, | ||
description: null, | ||
patternId: null | ||
}; | ||
this.$onInit = function () { | ||
this.markdownEditorOptions = { | ||
iconlibrary: 'fa', | ||
addExtraButtons: true, | ||
resize: 'vertical' | ||
}; | ||
|
||
this.tactics = AttackPatternSrv.tactics; | ||
this.procedure = { | ||
tactic: null, | ||
description: null, | ||
patternId: null | ||
}; | ||
|
||
this.state = { | ||
loading: false, | ||
selectedTactic: null, | ||
techniques: null | ||
}; | ||
this.tactics = AttackPatternSrv.tactics; | ||
|
||
$scope.$broadcast('beforeProcedureModalShow'); | ||
this.state = { | ||
loading: false, | ||
selectedTactic: null, | ||
techniques: null | ||
}; | ||
} | ||
|
||
$scope.$broadcast('beforeProcedureModalShow'); | ||
}; | ||
} | ||
); | ||
})(); |
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