Skip to content

Commit

Permalink
jobs: sorted the schedule fields
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 committed Jun 13, 2024
1 parent ecb3834 commit 4b41080
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 37 deletions.
1 change: 0 additions & 1 deletion invenio_jobs/administration/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class JobsListView(JobsAdminMixin, AdminResourceListView):
category = "System"
icon = "settings"
template = "invenio_jobs/system/jobs/jobs-search.html"
display_edit = True
create_view_name = "jobs-create"

item_field_list = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class ScheduleJobModal extends React.Component {

this.cancellableAction = withCancel(http.put(apiUrl, payload));
try {
await this.cancellableAction.promise;
this.setState({ loading: false });
addNotification({
title: i18next.t("Success"),
Expand Down Expand Up @@ -119,30 +120,38 @@ export class ScheduleJobModal extends React.Component {
<>
{Object.keys(
payloadSchema[values.selectedOption].properties
).map((property) => (
<Field
key={property}
name={property}
render={({ field }) => (
<Input
{...field}
label={
payloadSchema[values.selectedOption].properties[
property
].metadata?.title
}
className="m-5"
type={
payloadSchema[values.selectedOption].properties[
property
].type === "string"
? "text"
: "number"
}
/>
)}
/>
))}
)
.sort(
(a, b) =>
payloadSchema[values.selectedOption].properties[a]
.metadata.order -
payloadSchema[values.selectedOption].properties[b]
.metadata.order
)
.map((property) => (
<Field
key={property}
name={property}
render={({ field }) => (
<Input
{...field}
label={
payloadSchema[values.selectedOption].properties[
property
].metadata?.title
}
className="m-5"
type={
payloadSchema[values.selectedOption].properties[
property
].type === "string"
? "text"
: "number"
}
/>
)}
/>
))}
</>
)}
</Modal.Content>
Expand Down
24 changes: 12 additions & 12 deletions invenio_jobs/services/ui_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
class IntervalScheduleUISchema(Schema):
"""Schema for an interval schedule based on ``datetime.timedelta``."""

weeks = fields.Integer(metadata={"title": "Weeks"})
days = fields.Integer(metadata={"title": "Days"})
hours = fields.Integer(metadata={"title": "Hours"})
minutes = fields.Integer(metadata={"title": "Minutes"})
seconds = fields.Integer(metadata={"title": "Seconds"})
milliseconds = fields.Integer(metadata={"title": "Milliseconds"})
microseconds = fields.Integer(metadata={"title": "Microseconds"})
microseconds = fields.Integer(metadata={"title": "Microseconds", "order": 1})
milliseconds = fields.Integer(metadata={"title": "Milliseconds", "order": 2})
seconds = fields.Integer(metadata={"title": "Seconds", "order": 3})
minutes = fields.Integer(metadata={"title": "Minutes", "order": 4})
hours = fields.Integer(metadata={"title": "Hours", "order": 5})
days = fields.Integer(metadata={"title": "Days", "order": 6})
weeks = fields.Integer(metadata={"title": "Weeks", "order": 7})


class CrontabScheduleUISchema(Schema):
"""Schema for a crontab schedule."""

month_of_year = fields.String(load_default="*", metadata={"title": "Month of Year"})
day_of_month = fields.String(load_default="*", metadata={"title": "Day of Month"})
day_of_week = fields.String(load_default="*", metadata={"title": "Day of Week"})
hour = fields.String(load_default="*", metadata={"title": "Hour"})
minute = fields.String(load_default="*", metadata={"title": "Minute"})
minute = fields.String(load_default="*", metadata={"title": "Minute", "order": 1})
hour = fields.String(load_default="*", metadata={"title": "Hour", "order": 2})
day_of_week = fields.String(load_default="*", metadata={"title": "Day of Week", "order": 3})
day_of_month = fields.String(load_default="*", metadata={"title": "Day of Month", "order": 4})
month_of_year = fields.String(load_default="*", metadata={"title": "Month of Year", "order": 5})


class ScheduleUISchema(OneOfSchema):
Expand Down

0 comments on commit 4b41080

Please sign in to comment.