From df80aae060733d994fa5b7960f2512710dd3a098 Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Fri, 6 Apr 2018 11:30:16 +0200 Subject: [PATCH] #81 Add Apply defaults buttons to analyzer config dialog --- .../analyzer-config-form.controller.js | 20 ++++++- .../components/analyzer-config-form.html | 50 +++++++++++------ .../components/analyzer.edit.controller.js | 4 ++ .../components/analyzer.edit.modal.html | 6 +- .../components/analyzers-list.controller.js | 56 ++++++++++--------- .../organizations/organizations.module.js | 5 +- .../app/pages/analyzers/analyzers.service.js | 15 +++++ 7 files changed, 110 insertions(+), 46 deletions(-) diff --git a/www/src/app/pages/admin/organizations/components/analyzer-config-form.controller.js b/www/src/app/pages/admin/organizations/components/analyzer-config-form.controller.js index 995368b92..445f71ac5 100644 --- a/www/src/app/pages/admin/organizations/components/analyzer-config-form.controller.js +++ b/www/src/app/pages/admin/organizations/components/analyzer-config-form.controller.js @@ -1,10 +1,28 @@ 'use strict'; +import _ from 'lodash/core'; + export default class AnalyzerConfigFormController { - constructor(Tlps) { + constructor($log, Tlps, AnalyzerService) { 'ngInject'; + this.AnalyzerService = AnalyzerService; this.Tlps = Tlps; this.rateUnits = ['Day', 'Month']; } + + applyConfig(config) { + _.forEach( + _.keys(config), + k => (this.analyzer.configuration[k] = config[k]) + ); + } + + applyGlobalConfig() { + this.applyConfig(this.globalConfig.config); + } + + applyBaseConfig() { + this.applyConfig(this.baseConfig.config); + } } diff --git a/www/src/app/pages/admin/organizations/components/analyzer-config-form.html b/www/src/app/pages/admin/organizations/components/analyzer-config-form.html index 2640cd8f7..ec89c439a 100644 --- a/www/src/app/pages/admin/organizations/components/analyzer-config-form.html +++ b/www/src/app/pages/admin/organizations/components/analyzer-config-form.html @@ -10,12 +10,28 @@

Base details

-

Configuration

+

+ Configuration + +

-

Options

+

+ Options + +

@@ -30,20 +46,6 @@

Options

-
- -
- -
-
- -
-
-

Define the maximum number of requests and the associated unit if applicable.

-
-
@@ -65,7 +67,21 @@

Options

-

Set to True to enable automatic observables extraction from analysis reports

+

Set to True to enable automatic observables extraction from analysis reports.

+
+ +
+ +
+
+
+ +
+
+

Define the maximum number of requests and the associated unit if applicable.

+
\ No newline at end of file diff --git a/www/src/app/pages/admin/organizations/components/analyzer.edit.controller.js b/www/src/app/pages/admin/organizations/components/analyzer.edit.controller.js index 2b33b2ecc..060c97043 100644 --- a/www/src/app/pages/admin/organizations/components/analyzer.edit.controller.js +++ b/www/src/app/pages/admin/organizations/components/analyzer.edit.controller.js @@ -7,6 +7,8 @@ export default class AnalyzerEditController { $log, $uibModalInstance, definition, + globalConfig, + baseConfig, configuration, analyzer, mode @@ -17,6 +19,8 @@ export default class AnalyzerEditController { this.$uibModalInstance = $uibModalInstance; this.mode = mode; this.definition = definition; + this.globalConfig = globalConfig; + this.baseConfig = baseConfig; this.configuration = configuration; this.analyzer = analyzer; } diff --git a/www/src/app/pages/admin/organizations/components/analyzer.edit.modal.html b/www/src/app/pages/admin/organizations/components/analyzer.edit.modal.html index baa3277b4..c65f05f27 100644 --- a/www/src/app/pages/admin/organizations/components/analyzer.edit.modal.html +++ b/www/src/app/pages/admin/organizations/components/analyzer.edit.modal.html @@ -3,7 +3,11 @@