From 0500d84e743df0b8d19032768a885acda43d2b23 Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Mon, 12 Apr 2021 06:24:59 +0200 Subject: [PATCH] #1953 Disable confim buttons in import dialogs --- .../admin/attack/AttackPatternListCtrl.js | 36 +++++++------ .../admin/taxonomy/TaxonomyListCtrl.js | 52 +++++++++++-------- .../views/partials/admin/attack/import.html | 7 ++- .../views/partials/admin/taxonomy/import.html | 10 ++-- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/frontend/app/scripts/controllers/admin/attack/AttackPatternListCtrl.js b/frontend/app/scripts/controllers/admin/attack/AttackPatternListCtrl.js index 80604099a3..84eccdb2e7 100644 --- a/frontend/app/scripts/controllers/admin/attack/AttackPatternListCtrl.js +++ b/frontend/app/scripts/controllers/admin/attack/AttackPatternListCtrl.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; angular.module('theHiveControllers') @@ -11,7 +11,7 @@ this.appConfig = appConfig; - self.load = function() { + self.load = function () { this.loading = true; this.list = new PaginatedQuerySrv({ @@ -26,19 +26,19 @@ filter: this.filtering.buildQuery(), baseFilter: { _field: 'patternType', - _value:'attack-pattern' + _value: 'attack-pattern' }, operations: [ - {'_name': 'listPattern'} + { '_name': 'listPattern' } ], extraData: ['enabled', 'parent'], - onUpdate: function() { + onUpdate: function () { self.loading = false; } }); }; - self.show = function(patternId) { + self.show = function (patternId) { $uibModal.open({ animation: true, templateUrl: 'views/partials/admin/attack/view.html', @@ -46,7 +46,7 @@ controllerAs: '$modal', size: 'max', resolve: { - pattern: function() { + pattern: function () { return AttackPatternSrv.get(patternId); } } @@ -67,11 +67,11 @@ }); modalInstance.result - .then(function() { + .then(function () { self.load(); }) - .catch(function(err){ - if(err && !_.isString(err)) { + .catch(function (err) { + if (err && !_.isString(err)) { NotificationSrv.error('Pattern import', err.data, err.status); } }); @@ -104,7 +104,7 @@ this.search(); }; - self.$onInit = function() { + self.$onInit = function () { self.filtering = new FilteringSrv('pattern', 'attack-pattern.list', { version: 'v1', defaults: { @@ -117,7 +117,7 @@ }); self.filtering.initContext('list') - .then(function() { + .then(function () { self.load(); $scope.$watch('$vm.list.pageSize', function (newValue) { @@ -138,7 +138,7 @@ $uibModalInstance.dismiss('cancel'); }; - this.$onInit = function() { + this.$onInit = function () { if (this.pattern.extraData.parent) { this.pattern.isSubTechnique = true; this.pattern.parentId = this.pattern.extraData.parent.patternId; @@ -152,13 +152,19 @@ function AttackPatternImportCtrl($uibModalInstance, AttackPatternSrv, NotificationSrv, appConfig) { this.appConfig = appConfig; this.formData = {}; + this.loading = false; this.ok = function () { + this.loading = true; AttackPatternSrv.import(this.formData) - .then(function() { + .then(function () { $uibModalInstance.close(); - }, function(response) { + }) + .catch(function (response) { NotificationSrv.error('AttackPatternImportCtrl', response.data, response.status); + }) + .fincally(function () { + this.loading = false; }); }; diff --git a/frontend/app/scripts/controllers/admin/taxonomy/TaxonomyListCtrl.js b/frontend/app/scripts/controllers/admin/taxonomy/TaxonomyListCtrl.js index 78a1d5c29b..9ff31b9ae4 100644 --- a/frontend/app/scripts/controllers/admin/taxonomy/TaxonomyListCtrl.js +++ b/frontend/app/scripts/controllers/admin/taxonomy/TaxonomyListCtrl.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; angular.module('theHiveControllers') @@ -11,7 +11,7 @@ this.appConfig = appConfig; - self.load = function() { + self.load = function () { this.loading = true; this.list = new PaginatedQuerySrv({ @@ -25,16 +25,16 @@ pageSize: self.filtering.context.pageSize, filter: this.filtering.buildQuery(), operations: [ - {'_name': 'listTaxonomy'} + { '_name': 'listTaxonomy' } ], extraData: ['enabled'], - onUpdate: function() { + onUpdate: function () { self.loading = false; } }); }; - self.show = function(taxonomy) { + self.show = function (taxonomy) { // var modalInstance = $uibModal.open({ $uibModal.open({ @@ -73,52 +73,52 @@ }); modalInstance.result - .then(function() { + .then(function () { self.load(); }) - .catch(function(err){ - if(err && !_.isString(err)) { + .catch(function (err) { + if (err && !_.isString(err)) { NotificationSrv.error('Taxonomies import', err.data, err.status); } }); }; - this.toggleActive = function(taxonomy) { + this.toggleActive = function (taxonomy) { var active = !taxonomy.extraData.enabled; TaxonomySrv.toggleActive(taxonomy._id, active) - .then(function() { + .then(function () { NotificationSrv.log(['Taxonomy [', taxonomy.namespace, '] has been successfully', (active ? 'activated' : 'deactivated')].join(' '), 'success'); self.load(); }) - .catch(function(err){ - if(err && !_.isString(err)) { + .catch(function (err) { + if (err && !_.isString(err)) { NotificationSrv.error('Taxonomies ' + active ? 'activation' : 'deactivation', err.data, err.status); } }); }; - self.remove = function(taxonomy) { + self.remove = function (taxonomy) { var modalInstance = ModalSrv.confirm( 'Remove taxonomy', 'Are you sure you want to remove the selected taxonomy?', { - flavor: 'danger', - okText: 'Yes, remove it' - } + flavor: 'danger', + okText: 'Yes, remove it' + } ); modalInstance.result - .then(function() { + .then(function () { return TaxonomySrv.remove(taxonomy._id); }) - .then(function( /*response*/ ) { + .then(function ( /*response*/) { self.load(); NotificationSrv.success( 'Taxonomy ' + taxonomy.namespace + ' has been successfully removed.' ); }) - .catch(function(err) { + .catch(function (err) { if (err && !_.isString(err)) { NotificationSrv.error('TaxonomyListCtrl', err.data, err.status); } @@ -152,7 +152,7 @@ this.search(); }; - self.$onInit = function() { + self.$onInit = function () { self.filtering = new FilteringSrv('taxonomy', 'taxonomy.list', { version: 'v1', defaults: { @@ -165,7 +165,7 @@ }); self.filtering.initContext('list') - .then(function() { + .then(function () { self.load(); $scope.$watch('$vm.list.pageSize', function (newValue) { @@ -190,13 +190,19 @@ function TaxonomyImportCtrl($uibModalInstance, TaxonomySrv, NotificationSrv, appConfig) { this.appConfig = appConfig; this.formData = {}; + this.loading = false; this.ok = function () { + this.loading = true; TaxonomySrv.import(this.formData) - .then(function() { + .then(function () { $uibModalInstance.close(); - }, function(response) { + }) + .catch(function (response) { NotificationSrv.error('TaxonomyImportCtrl', response.data, response.status); + }) + .finally(function () { + this.loading = false; }); }; diff --git a/frontend/app/views/partials/admin/attack/import.html b/frontend/app/views/partials/admin/attack/import.html index 0a8fbc0786..7d3bfcd02f 100644 --- a/frontend/app/views/partials/admin/attack/import.html +++ b/frontend/app/views/partials/admin/attack/import.html @@ -6,7 +6,9 @@

Download the official MITRE ATT&CK library

-

You can download the latest archive of the official MITRE ATT&CK patterns from here

+

You can download the latest archive of the official MITRE ATT&CK patterns from + here

@@ -17,6 +19,7 @@

Download the official MITRE ATT&CK library

diff --git a/frontend/app/views/partials/admin/taxonomy/import.html b/frontend/app/views/partials/admin/taxonomy/import.html index 634dce0d94..a163857568 100644 --- a/frontend/app/views/partials/admin/taxonomy/import.html +++ b/frontend/app/views/partials/admin/taxonomy/import.html @@ -6,7 +6,9 @@

Download the official MISP taxonomies archive

-

You can download the latest archive of the official MISP Taxonomies from here

+

You can download the latest archive of the official MISP Taxonomies from + here

@@ -15,12 +17,14 @@

Download the official MISP taxonomies archive

- The taxonomies archive must be a valid ZIP file containing at least one file names machinetag.json + The taxonomies archive must be a valid ZIP file containing at least one file names + machinetag.json