From f3bb70efc9c7b68954a2b2695b393a0ea0340ef2 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Sat, 25 May 2024 12:23:33 +0200 Subject: [PATCH] Add support for the log_level option in services and jobs (not sync) --- src/components/CustomProcessPanel.vue | 2 +- src/components/FieldMixin.js | 55 +++++++++++++++++++++++ src/components/FilePanel.vue | 4 +- src/components/JobPanel.vue | 58 +++++++----------------- src/components/ServicePanel.vue | 61 ++++++++------------------ src/components/datatypes/SelectBox.vue | 2 +- src/store/storeFactory.js | 2 +- 7 files changed, 95 insertions(+), 89 deletions(-) create mode 100644 src/components/FieldMixin.js diff --git a/src/components/CustomProcessPanel.vue b/src/components/CustomProcessPanel.vue index 836dc239b..05445c730 100644 --- a/src/components/CustomProcessPanel.vue +++ b/src/components/CustomProcessPanel.vue @@ -106,7 +106,7 @@ export default { ); }, addProcess(process) { - this.create({parameters: [process.id, process]}) + this.create([process.id, process]) .catch(error => Utils.exception(this, error, 'Store Process Error' + (process.id ? `: ${process.id}` : ''))); }, processInfo(process) { diff --git a/src/components/FieldMixin.js b/src/components/FieldMixin.js new file mode 100644 index 000000000..d8da3de9e --- /dev/null +++ b/src/components/FieldMixin.js @@ -0,0 +1,55 @@ +export default { + methods: { + getTitleField(value = null) { + return { + name: 'title', + label: 'Title', + schema: {type: 'string'}, + default: null, + value: value, + optional: true + }; + }, + getDescriptionField(value = null) { + return { + name: 'description', + label: 'Description', + schema: {type: 'string', subtype: 'commonmark'}, + default: null, + value: value, + description: 'CommonMark (Markdown) is allowed.', + optional: true + }; + }, + getLogLevelField(value = undefined) { + return { + name: 'log_level', + label: 'Log level', + schema: {type: 'string', enum: ['debug', 'info', 'warning', 'error']}, + default: 'info', + value: value, + description: 'The minimum severity level for log entries that the back-end stores for the processing request.\n\ndebug (all logs) > info > warning > error (only errors)', + optional: true + }; + }, + getBillingPlanField(value = undefined) { + return { + name: 'plan', + label: 'Billing plan', + schema: {type: 'string', subtype: 'billing-plan'}, + value: value, + optional: true + }; + }, + getBudgetField(value = null) { + return { + name: 'budget', + label: 'Budget limit', + schema: {type: 'number', subtype: 'budget'}, + default: null, + value: value, + optional: true + }; + } + } +}; \ No newline at end of file diff --git a/src/components/FilePanel.vue b/src/components/FilePanel.vue index 12619517d..ded1d5264 100644 --- a/src/components/FilePanel.vue +++ b/src/components/FilePanel.vue @@ -115,11 +115,11 @@ export default { } try { - await this.create({parameters: [ + await this.create([ file, null, percent => this.$set(this.uploadProgressPerFile, i, percent) - ]}); + ]); this.$set(this.uploadProgressPerFile, i, 100); Utils.ok(this, 'File upload completed.', file.name); } catch (error) { diff --git a/src/components/JobPanel.vue b/src/components/JobPanel.vue index 0233a5ffa..7ef02054b 100644 --- a/src/components/JobPanel.vue +++ b/src/components/JobPanel.vue @@ -28,12 +28,17 @@ import SyncButton from './SyncButton.vue'; import Utils from '../utils.js'; import { Job } from '@openeo/js-client'; import { cancellableRequest, showCancellableRequestError, CancellableRequestError } from './cancellableRequest'; +import FieldMixin from './FieldMixin'; const WorkPanelMixinInstance = WorkPanelMixin('jobs', 'batch job', 'batch jobs'); export default { name: 'JobPanel', - mixins: [WorkPanelMixinInstance, EventBusMixin], + mixins: [ + WorkPanelMixinInstance, + EventBusMixin, + FieldMixin + ], components: { SyncButton }, @@ -174,46 +179,6 @@ export default { } Utils.confirm(this, 'Job "' + Utils.getResourceTitle(job) + '" created!', buttons); }, - getTitleField(value = null) { - return { - name: 'title', - label: 'Title', - schema: {type: 'string'}, - default: null, - value: value, - optional: true - }; - }, - getDescriptionField(value = null) { - return { - name: 'description', - label: 'Description', - schema: {type: 'string', subtype: 'commonmark'}, - default: null, - value: value, - description: 'CommonMark (Markdown) is allowed.', - optional: true - }; - }, - getBillingPlanField(value = undefined) { - return { - name: 'plan', - label: 'Billing plan', - schema: {type: 'string', subtype: 'billing-plan'}, - value: value, - optional: true - }; - }, - getBudgetField(value = null) { - return { - name: 'budget', - label: 'Budget limit', - schema: {type: 'number', subtype: 'budget'}, - default: null, - value: value, - optional: true - }; - }, normalizeToDefaultData(data) { if (typeof data.title !== 'undefined' && (typeof data.title !== 'string' || data.title.length === 0)) { data.title = null; @@ -232,7 +197,14 @@ export default { async createJob(process, data) { try { data = this.normalizeToDefaultData(data); - let job = await this.create({parameters: [process, data.title, data.description, data.plan, data.budget]}); + let job = await this.create([ + process, + data.title, + data.description, + data.plan, + data.budget, + {log_level: data.log_level} + ]); this.jobCreated(job); return job; } catch (error) { @@ -244,6 +216,7 @@ export default { var fields = [ this.getTitleField(), this.getDescriptionField(), + this.getLogLevelField(), this.supportsBillingPlans ? this.getBillingPlanField() : null, this.supportsBilling ? this.getBudgetField() : null ]; @@ -322,6 +295,7 @@ export default { var fields = [ this.getTitleField(job.title), this.getDescriptionField(job.description), + this.getLogLevelField(job.log_level), this.supportsBillingPlans ? this.getBillingPlanField(job.plan) : null, this.supportsBilling ? this.getBudgetField(job.budget) : null ]; diff --git a/src/components/ServicePanel.vue b/src/components/ServicePanel.vue index b6915a828..e9ea08562 100644 --- a/src/components/ServicePanel.vue +++ b/src/components/ServicePanel.vue @@ -20,6 +20,7 @@