Skip to content

Commit

Permalink
Add support for the log_level option in services and jobs (not sync)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed May 25, 2024
1 parent 827868d commit f3bb70e
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 89 deletions.
2 changes: 1 addition & 1 deletion src/components/CustomProcessPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
55 changes: 55 additions & 0 deletions src/components/FieldMixin.js
Original file line number Diff line number Diff line change
@@ -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
};
}
}
};
4 changes: 2 additions & 2 deletions src/components/FilePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
58 changes: 16 additions & 42 deletions src/components/JobPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -244,6 +216,7 @@ export default {
var fields = [
this.getTitleField(),
this.getDescriptionField(),
this.getLogLevelField(),
this.supportsBillingPlans ? this.getBillingPlanField() : null,
this.supportsBilling ? this.getBudgetField() : null
];
Expand Down Expand Up @@ -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
];
Expand Down
61 changes: 19 additions & 42 deletions src/components/ServicePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@
<script>
import EventBusMixin from './EventBusMixin';
import WorkPanelMixin from './WorkPanelMixin';
import FieldMixin from './FieldMixin';
import SyncButton from './SyncButton.vue';
import Utils from '../utils';
import { Service } from '@openeo/js-client';
import { mapMutations } from 'vuex';
export default {
name: 'ServicePanel',
mixins: [WorkPanelMixin('services', 'web service', 'web services'), EventBusMixin],
mixins: [
WorkPanelMixin('services', 'web service', 'web services'),
EventBusMixin,
FieldMixin
],
components: {
SyncButton
},
Expand Down Expand Up @@ -138,27 +143,6 @@ export default {
}
Utils.confirm(this, 'Web Service 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
};
},
getServiceTypeField(value = undefined) {
return {
name: 'type',
Expand All @@ -167,25 +151,6 @@ export default {
value: value
};
},
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
};
},
getEnabledField(value = true) {
return {
name: 'enabled',
Expand Down Expand Up @@ -229,7 +194,17 @@ export default {
async createService(script, data, quiet = false) {
data = this.normalizeToDefaultData(data);
try {
let service = await this.create({parameters: [script, data.type, data.title, data.description, data.enabled, data.configuration, data.plan, data.budget]});
let service = await this.create([
script,
data.type,
data.title,
data.description,
data.enabled,
data.configuration,
data.plan,
data.budget,
{log_level: data.log_level}
]);
if (!quiet) {
this.serviceCreated(service);
}
Expand All @@ -245,6 +220,7 @@ export default {
this.getDescriptionField(),
this.getServiceTypeField(),
this.getEnabledField(),
this.getLogLevelField(),
this.supportsBillingPlans ? this.getBillingPlanField() : null,
this.supportsBilling ? this.getBudgetField() : null,
this.getConfigField()
Expand Down Expand Up @@ -273,6 +249,7 @@ export default {
this.getTitleField(service.title),
this.getDescriptionField(service.description),
this.getEnabledField(service.enabled),
this.getLogLevelField(service.log_level),
this.supportsBillingPlans ? this.getBillingPlanField(service.plan) : null,
this.supportsBilling ? this.getBudgetField(service.budget) : null,
this.getConfigField(service.configuration)
Expand Down
2 changes: 1 addition & 1 deletion src/components/datatypes/SelectBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export default {
}
},
initSelection() {
let value = this.value;
let value = typeof this.value === 'undefined' ? this.schema.default() : this.value;
if (this.multiple && Array.isArray(value)) {
this.selected = this.selectOptions.filter(o => value.includes(o.id));
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/storeFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default ({namespace, listFn, createFn, updateFn, deleteFn, readFn, readFn
}
},
actions: {
async create(cx, {parameters}) {
async create(cx, parameters) {
if (cx.getters.supportsCreate) {
let connection = cx.rootState.connection;
let data = await connection[createFn].apply(connection, parameters);
Expand Down

0 comments on commit f3bb70e

Please sign in to comment.