From dd0ce986f65610842712401e71b93d478be83fd6 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Thu, 19 Sep 2024 13:51:49 +0200 Subject: [PATCH] new configuration parameter custom_workflow_default to set the default value for the switch in the UI --- client/src/components/WebinputCSV.vue | 8 +++++++- client/src/store/index.js | 13 +++++++++++++ docs/user-guide.rst | 2 ++ intelmq_webinput_csv/serve.py | 10 ++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/client/src/components/WebinputCSV.vue b/client/src/components/WebinputCSV.vue index 3ca4558..84d1c62 100644 --- a/client/src/components/WebinputCSV.vue +++ b/client/src/components/WebinputCSV.vue @@ -867,7 +867,7 @@ export default ({ // returns only the names of assigned columns return this.tableHeader.slice(1).map(header => header.field).filter(entry => entry) }, - ...mapState(['user', 'loggedIn', 'hasAuth', 'classificationTypes', 'harmonizationFields', 'customFieldsMapping', 'requiredFields', 'mailgenAvailable', 'botsAvailable', 'mailgenAvailableTargetGroups', 'mailgenAvailableTargetGroupsStatus', 'backendVersion', 'mailgenTemplatesServer', 'mailgenTemplates', 'mailgenMultiTemplatesEnabled', 'mailgenTemplateDefaultTemplateName']), + ...mapState(['user', 'loggedIn', 'hasAuth', 'classificationTypes', 'harmonizationFields', 'customFieldsMapping', 'requiredFields', 'mailgenAvailable', 'botsAvailable', 'mailgenAvailableTargetGroups', 'mailgenAvailableTargetGroupsStatus', 'backendVersion', 'mailgenTemplatesServer', 'mailgenTemplates', 'mailgenMultiTemplatesEnabled', 'mailgenTemplateDefaultTemplateName', 'customWorkflowDefault']), }, mounted() { this.$store.dispatch("fetchBackendVersion"); @@ -894,6 +894,11 @@ export default ({ this.timezones[j] = this.timezones[j] + ':00'; } }, + watch: { + customWorkflowDefault: function (newCustomWorkflowDefault) { + this.customWorkflow = newCustomWorkflowDefault; + } + }, methods: { csvToArray(maxRows=null) { /** @@ -1108,6 +1113,7 @@ export default ({ this.$store.dispatch("fetchBotsAvailable"); this.$store.dispatch("fetchMailgenAvailableTargetGroups"); this.$store.dispatch("fetchMailgenTemplates"); + this.$store.dispatch("fetchSettings"); }, (response) => { if (response.status !== 200) { this.loginErrorText = "Server not reachable."; diff --git a/client/src/store/index.js b/client/src/store/index.js index de9e6b3..f627cfb 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -26,6 +26,7 @@ export default new Vuex.Store({ mailgenTemplatesServer: [], mailgenMultiTemplatesEnabled: false, mailgenTemplateDefaultTemplateName: null, + customWorkflowDefault: false, }, mutations: { SET_USER (state, user) { @@ -83,6 +84,9 @@ export default new Vuex.Store({ }, SET_MAILGEN_DEFAULT_TEMPLATE_NAME(state, data) { state.mailgenTemplateDefaultTemplateName = data; + }, + SET_SETTNGS(state, data) { + state.customWorkflowDefault = data['custom_workflow_default']; } }, actions: { @@ -248,6 +252,15 @@ export default new Vuex.Store({ context.commit("SET_MAILGEN_DEFAULT_TEMPLATE_NAME", data['default_template_name']); }) ); + }, + fetchSettings(context) { + Vue.http.get('api/settings').then( + response => { + response.json().then(data => { + context.commit("SET_SETTNGS", data) + }) + } + ) } }, modules: { diff --git a/docs/user-guide.rst b/docs/user-guide.rst index 8c78c6d..1f975e9 100644 --- a/docs/user-guide.rst +++ b/docs/user-guide.rst @@ -88,6 +88,8 @@ Usual configuration parameters allowed for user input. If left empty, all fields are allowed (default). The check is applied in the frontend (field selection for columns) and backend. The check does **not** apply to constant fields and custom input fields! +- ``custom_workflow_default``: If true (default: false), then the switch "Use custom workflow" + in the "Data validation and submission" section is enabled by default. Mailgen configuration parameters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/intelmq_webinput_csv/serve.py b/intelmq_webinput_csv/serve.py index 6e336d2..fe04a65 100644 --- a/intelmq_webinput_csv/serve.py +++ b/intelmq_webinput_csv/serve.py @@ -437,6 +437,16 @@ def mailgen_settings(): } +@hug.get(ENDPOINT_PREFIX + '/api/settings', requires=session.token_authentication) +def settings(): + """ + Returns some configuration options + """ + return { + 'custom_workflow_default': CONFIG.get('custom_workflow_default', False) + } + + @hug.post(ENDPOINT_PREFIX + '/api/mailgen/run', requires=session.token_authentication) def mailgen_run(body, request, response): """