From dca4a5b204dbcdcb38a53fc9460df3d08115a8d3 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Wed, 15 May 2024 10:31:03 +0200 Subject: [PATCH 01/24] refactor: move search index --- .../administration/details/index.js | 2 +- .../js/invenio_jobs/administration/index.js | 25 +----------- .../administration/search/index.js | 39 ++++++++++++++----- invenio_jobs/webpack.py | 2 +- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/details/index.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/details/index.js index db2c162..60c1a73 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/details/index.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/details/index.js @@ -1,4 +1,4 @@ -// This file is part of InvenioCommunities +// This file is part of Invenio // Copyright (C) 2024 CERN. // // Invenio RDM is free software; you can redistribute it and/or modify it diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/index.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/index.js index 274e8db..60c1a73 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/index.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/index.js @@ -1,28 +1,5 @@ -// This file is part of InvenioCommunities +// This file is part of Invenio // Copyright (C) 2024 CERN. // // Invenio RDM is free software; you can redistribute it and/or modify it // under the terms of the MIT License; see LICENSE file for more details. - -import { initDefaultSearchComponents } from "@js/invenio_administration"; -import { createSearchAppInit } from "@js/invenio_search_ui"; -import { NotificationController } from "@js/invenio_administration"; -import { SearchResultItemLayout, JobSearchLayout } from "./search"; - -const domContainer = document.getElementById("invenio-search-config"); - -const defaultComponents = initDefaultSearchComponents(domContainer); - -const overridenComponents = { - ...defaultComponents, - "InvenioAdministration.SearchResultItem.layout": SearchResultItemLayout, - "SearchApp.layout": JobSearchLayout, -}; - -createSearchAppInit( - overridenComponents, - true, - "invenio-search-config", - false, - NotificationController -); diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/index.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/index.js index f0d09f7..653d2af 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/index.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/index.js @@ -1,10 +1,29 @@ -/* - * This file is part of Invenio. - * Copyright (C) 2024 CERN. - * - * Invenio is free software; you can redistribute it and/or modify it - * under the terms of the MIT License; see LICENSE file for more details. - */ - -export { SearchResultItemLayout } from "./SearchResultItemLayout"; -export { JobSearchLayout } from "./JobSearchLayout.js"; +// This file is part of Invenio +// Copyright (C) 2024 CERN. +// +// Invenio RDM is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import { initDefaultSearchComponents } from "@js/invenio_administration"; +import { createSearchAppInit } from "@js/invenio_search_ui"; +import { NotificationController } from "@js/invenio_administration"; +import { SearchResultItemLayout } from "./SearchResultItemLayout"; +import { JobSearchLayout } from "./JobSearchLayout"; + +const domContainer = document.getElementById("invenio-search-config"); + +const defaultComponents = initDefaultSearchComponents(domContainer); + +const overridenComponents = { + ...defaultComponents, + "InvenioAdministration.SearchResultItem.layout": SearchResultItemLayout, + "SearchApp.layout": JobSearchLayout, +}; + +createSearchAppInit( + overridenComponents, + true, + "invenio-search-config", + false, + NotificationController +); diff --git a/invenio_jobs/webpack.py b/invenio_jobs/webpack.py index 389288c..ec90c34 100644 --- a/invenio_jobs/webpack.py +++ b/invenio_jobs/webpack.py @@ -16,7 +16,7 @@ themes={ "semantic-ui": dict( entry={ - "invenio-jobs-search": "./js/invenio_jobs/administration/index.js", + "invenio-jobs-search": "./js/invenio_jobs/administration/search/index.js", "invenio-jobs-details": "./js/invenio_jobs/administration/details/index.js", }, dependencies={ From d867ef9e4e08f7d29656cbecac02f5636926d7dc Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Fri, 17 May 2024 16:48:27 +0200 Subject: [PATCH 02/24] UI: add MVP for job details view --- invenio_jobs/administration/jobs.py | 44 +++++++--- .../administration/details/index.js | 5 -- .../administration/search/JobRuns.js | 29 +++++++ ...Layout.js => JobSearchResultItemLayout.js} | 6 +- .../search/RunsSearchResultItemLayout.js | 74 +++++++++++++++++ .../administration/search/SystemRunActions.js | 53 ++++++++++++ .../administration/search/index.js | 2 +- invenio_jobs/resources/config.py | 6 ++ .../system/jobs/jobs-details.html | 81 ++++++++++++++++--- .../invenio_jobs/system/jobs/jobs-search.html | 12 +-- invenio_jobs/webpack.py | 2 +- setup.cfg | 2 +- 12 files changed, 278 insertions(+), 38 deletions(-) delete mode 100644 invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/details/index.js create mode 100644 invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRuns.js rename invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/{SearchResultItemLayout.js => JobSearchResultItemLayout.js} (92%) create mode 100644 invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/RunsSearchResultItemLayout.js create mode 100644 invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SystemRunActions.js diff --git a/invenio_jobs/administration/jobs.py b/invenio_jobs/administration/jobs.py index 4f33a6c..c06a8ab 100644 --- a/invenio_jobs/administration/jobs.py +++ b/invenio_jobs/administration/jobs.py @@ -70,27 +70,51 @@ class JobsListView(AdminResourceListView): } -class JobsDetailView(AdminResourceDetailView): - """Configuration for Jobs detail view.""" +class JobsDetailsView(AdminResourceListView): + """Configuration for Jobs detail view which shows runs.""" + api_endpoint = "/jobs//runs" url = "/jobs/" - api_endpoint = "/jobs" search_request_headers = {"Accept": "application/json"} - name = "Job Details" - resource_config = "jobs_resource" + name = "job-details" + resource_config = "runs_resource" title = "Job Details" + disabled = lambda _: True - template = "invenio_administration/details.html" + template = "invenio_jobs/system/jobs/jobs-details.html" display_delete = False display_edit = False display_search = False + display_create = False list_view_name = "jobs" pid_path = "id" item_field_list = { - "run": {"text": _("Runs"), "order": 1}, - "duration": {"text": _("Duration"), "order": 2}, - "message": {"text": _("Message"), "order": 3}, - "user": {"text": _("Started by"), "order": 4}, + "run": {"text": _("Run"), "order": 1, "width": 2}, + "duration": {"text": _("Duration"), "order": 2, "width": 2}, + "message": {"text": _("Message"), "order": 3, "width": 10}, + "user": {"text": _("Started by"), "order": 4, "width": 2}, + } + + search_config_name = "JOBS_SEARCH" + search_sort_config_name = "JOBS_SORT_OPTIONS" + search_facets_config_name = "JOBS_FACETS" + + actions = { + "settings": { + "text": "Settings", + "payload_schema": None, + "order": 1, + }, + "schedule": { + "text": "Schedule", + "payload_schema": None, + "order": 2, + }, + "run": { + "text": "Run Now", + "payload_schema": None, + "order": 2, + }, } diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/details/index.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/details/index.js deleted file mode 100644 index 60c1a73..0000000 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/details/index.js +++ /dev/null @@ -1,5 +0,0 @@ -// This file is part of Invenio -// Copyright (C) 2024 CERN. -// -// Invenio RDM is free software; you can redistribute it and/or modify it -// under the terms of the MIT License; see LICENSE file for more details. diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRuns.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRuns.js new file mode 100644 index 0000000..ee4ddc4 --- /dev/null +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRuns.js @@ -0,0 +1,29 @@ +// This file is part of Invenio +// Copyright (C) 2024 CERN. +// +// Invenio RDM is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import { initDefaultSearchComponents } from "@js/invenio_administration"; +import { createSearchAppInit } from "@js/invenio_search_ui"; +import { NotificationController } from "@js/invenio_administration"; +import { SearchResultItemLayout } from "./RunsSearchResultItemLayout"; +import { JobSearchLayout } from "./JobSearchLayout"; + +const domContainer = document.getElementById("invenio-search-config"); + +const defaultComponents = initDefaultSearchComponents(domContainer); + +const overridenComponents = { + ...defaultComponents, + "InvenioAdministration.SearchResultItem.layout": SearchResultItemLayout, + "SearchApp.layout": JobSearchLayout, +}; + +createSearchAppInit( + overridenComponents, + true, + "invenio-search-config", + false, + NotificationController +); diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SearchResultItemLayout.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js similarity index 92% rename from invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SearchResultItemLayout.js rename to invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js index cada955..71a0583 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SearchResultItemLayout.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js @@ -13,7 +13,7 @@ import React, { Component } from "react"; import { Table } from "semantic-ui-react"; import { withState } from "react-searchkit"; import { i18next } from "@translations/invenio_app_rdm/i18next"; -import { UserListItemCompact } from "react-invenio-forms"; +import { UserListItemCompact, toRelativeTime } from "react-invenio-forms"; class SearchResultItemComponent extends Component { render() { @@ -35,7 +35,7 @@ class SearchResultItemComponent extends Component { collapsing className="" > - {result.last_run_start_time} + {toRelativeTime(result.last_run_start_time, i18next.language)} - {result.next_run} + {toRelativeTime(result.next_run, i18next.language)} diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/RunsSearchResultItemLayout.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/RunsSearchResultItemLayout.js new file mode 100644 index 0000000..594a729 --- /dev/null +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/RunsSearchResultItemLayout.js @@ -0,0 +1,74 @@ +/* + * This file is part of Invenio. + * Copyright (C) 2022-2024 CERN. + * + * Invenio is free software; you can redistribute it and/or modify it + * under the terms of the MIT License; see LICENSE file for more details. + */ + +import { BoolFormatter } from "@js/invenio_administration"; +import { SystemRunActions } from "./SystemRunActions"; +import PropTypes from "prop-types"; +import React, { Component } from "react"; +import { Table } from "semantic-ui-react"; +import { withState } from "react-searchkit"; +import { i18next } from "@translations/invenio_app_rdm/i18next"; +import { UserListItemCompact, toRelativeTime } from "react-invenio-forms"; + +class SearchResultItemComponent extends Component { + render() { + const { result } = this.props; + + return ( + + + {/* status formatter here for the icon */} + {result.start_time} + + + {toRelativeTime(result.start_time, i18next.language)} + + + {result.message} + + + + + + + + + ); + } +} + +SearchResultItemComponent.propTypes = { + result: PropTypes.object.isRequired, +}; + +SearchResultItemComponent.defaultProps = {}; + +export const SearchResultItemLayout = withState(SearchResultItemComponent); diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SystemRunActions.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SystemRunActions.js new file mode 100644 index 0000000..1741028 --- /dev/null +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SystemRunActions.js @@ -0,0 +1,53 @@ +/* + * This file is part of Invenio. + * Copyright (C) 2024 CERN. + * + * Invenio is free software; you can redistribute it and/or modify it + * under the terms of the MIT License; see LICENSE file for more details. + */ + +import React, { Component } from "react"; +import { Button, Icon } from "semantic-ui-react"; +import { i18next } from "@translations/invenio_app_rdm/i18next"; + +export class SystemRunActions extends Component { + handleAction = async (action) => { + const actionConfig = { + deactivate: { + label: i18next.t("Stop"), + icon: "stop", + notificationTitle: i18next.t("Stop"), + }, + }[action]; + + return actionConfig; + }; + + render() { + const actionItems = [{ key: "stop", label: "Stop", icon: "stop" }]; + + const generateActions = () => { + return ( + <> + {actionItems.map((actionItem) => ( + + ))} + + ); + }; + return ( +
+ + {generateActions()} + +
+ ); + } +} + +SystemRunActions.propTypes = {}; + +SystemRunActions.defaultProps = {}; diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/index.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/index.js index 653d2af..0caa63e 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/index.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/index.js @@ -7,7 +7,7 @@ import { initDefaultSearchComponents } from "@js/invenio_administration"; import { createSearchAppInit } from "@js/invenio_search_ui"; import { NotificationController } from "@js/invenio_administration"; -import { SearchResultItemLayout } from "./SearchResultItemLayout"; +import { SearchResultItemLayout } from "./JobSearchResultItemLayout"; import { JobSearchLayout } from "./JobSearchLayout"; const domContainer = document.getElementById("invenio-search-config"); diff --git a/invenio_jobs/resources/config.py b/invenio_jobs/resources/config.py index 12b86e7..55e2666 100644 --- a/invenio_jobs/resources/config.py +++ b/invenio_jobs/resources/config.py @@ -94,6 +94,12 @@ class RunsSearchRequestArgsSchema(SearchRequestArgsSchema): status = ma.fields.Enum(RunStatusEnum) +class JobsSearchRequestArgsSchema(SearchRequestArgsSchema): + """Jobs search request parameters.""" + + status = ma.fields.Boolean() + + class RunsResourceConfig(ResourceConfig, ConfiguratorMixin): """Runs resource config.""" diff --git a/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-details.html b/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-details.html index e528bb8..30a95c7 100644 --- a/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-details.html +++ b/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-details.html @@ -1,12 +1,71 @@ {# - Copyright (C) 2024 CERN. - - Invenio App RDM is free software; you can redistribute it and/or modify it - under the terms of the MIT License; see LICENSE file for more details. - #} - {% extends "invenio_administration/details.html" %} - - {% block javascript %} - {{ super() }} - {{ webpack['invenio-jobs-details.js'] }} - {% endblock %} + Copyright (C) 2024 CERN. + + Invenio App RDM is free software; you can redistribute it and/or modify it + under the terms of the MIT License; see LICENSE file for more details. +#} + +{%- from "invenio_administration/macros.html" import go_back %} + +{% extends "invenio_administration/search.html" %} + +{% block admin_main_column %} +
+ +
+ {{ go_back() }} + + {% block admin_page_content %} + + + {%- block search_app %} +
+
+ {%- endblock search_app %} + {% endblock admin_page_content %} +
+
+{% endblock %} + +{% block javascript %} + {{ super() }} + {{ webpack['invenio-jobs-details.js'] }} +{% endblock %} diff --git a/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-search.html b/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-search.html index 271652f..d0dee4d 100644 --- a/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-search.html +++ b/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-search.html @@ -1,12 +1,12 @@ {# - Copyright (C) 2024 CERN. + Copyright (C) 2024 CERN. - Invenio App RDM is free software; you can redistribute it and/or modify it - under the terms of the MIT License; see LICENSE file for more details. - #} - {% extends "invenio_administration/search.html" %} + Invenio App RDM is free software; you can redistribute it and/or modify it + under the terms of the MIT License; see LICENSE file for more details. +#} +{% extends "invenio_administration/search.html" %} - {% block javascript %} +{% block javascript %} {{ super() }} {{ webpack['invenio-jobs-search.js'] }} {% endblock %} diff --git a/invenio_jobs/webpack.py b/invenio_jobs/webpack.py index ec90c34..5a62d44 100644 --- a/invenio_jobs/webpack.py +++ b/invenio_jobs/webpack.py @@ -17,7 +17,7 @@ "semantic-ui": dict( entry={ "invenio-jobs-search": "./js/invenio_jobs/administration/search/index.js", - "invenio-jobs-details": "./js/invenio_jobs/administration/details/index.js", + "invenio-jobs-details": "./js/invenio_jobs/administration/search/JobRuns.js", }, dependencies={ "react-invenio-forms": "^3.0.0", diff --git a/setup.cfg b/setup.cfg index c148ad4..0cef36b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -60,7 +60,7 @@ invenio_assets.webpack = jobs = invenio_jobs.webpack:administration invenio_administration.views = jobs_list = invenio_jobs.administration.jobs:JobsListView - jobs_details = invenio_jobs.administration.jobs:JobsDetailView + jobs_details = invenio_jobs.administration.jobs:JobsDetailsView invenio_base.api_apps = jobs = invenio_jobs:InvenioJobs invenio_base.api_blueprints = From b745e13a99e4b2faa8b737961abd0dcd405fcb50 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Wed, 22 May 2024 15:59:23 +0200 Subject: [PATCH 03/24] UI: Set title to name of job and move status --- invenio_jobs/administration/jobs.py | 1 + .../js/invenio_jobs/administration/search/JobRuns.js | 5 +++++ .../invenio_jobs/administration/search/JobRunsTitle.js | 10 ++++++++++ .../administration/search/JobSearchResultItemLayout.js | 9 +-------- .../invenio_jobs/system/jobs/jobs-details.html | 1 + 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRunsTitle.js diff --git a/invenio_jobs/administration/jobs.py b/invenio_jobs/administration/jobs.py index c06a8ab..9b76bc2 100644 --- a/invenio_jobs/administration/jobs.py +++ b/invenio_jobs/administration/jobs.py @@ -89,6 +89,7 @@ class JobsDetailsView(AdminResourceListView): list_view_name = "jobs" pid_path = "id" + pid_value = "" item_field_list = { "run": {"text": _("Run"), "order": 1, "width": 2}, diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRuns.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRuns.js index ee4ddc4..823903a 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRuns.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRuns.js @@ -9,6 +9,7 @@ import { createSearchAppInit } from "@js/invenio_search_ui"; import { NotificationController } from "@js/invenio_administration"; import { SearchResultItemLayout } from "./RunsSearchResultItemLayout"; import { JobSearchLayout } from "./JobSearchLayout"; +import { JobRunsTitle } from "./JobRunsTitle"; const domContainer = document.getElementById("invenio-search-config"); @@ -27,3 +28,7 @@ createSearchAppInit( false, NotificationController ); + +const pidValue = domContainer.dataset.pidValue; + +JobRunsTitle(pidValue); diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRunsTitle.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRunsTitle.js new file mode 100644 index 0000000..6e638d4 --- /dev/null +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobRunsTitle.js @@ -0,0 +1,10 @@ +export async function JobRunsTitle(pidValue) { + fetch("/api/jobs/" + pidValue) + .then((response) => response.json()) + .then((data) => { + const titleElem = document.getElementsByTagName("h1")[0]; + if (titleElem && data) { + titleElem.innerHTML = data.name; + } + }); +} diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js index 71a0583..8242c16 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js @@ -34,14 +34,6 @@ class SearchResultItemComponent extends Component { data-label={i18next.t("Last run")} collapsing className="" - > - {toRelativeTime(result.last_run_start_time, i18next.language)} -
- + {toRelativeTime(result.last_run_start_time, i18next.language)} {{ title or name }} data-actions='{{ actions | tojson }}' data-api-endpoint='{{ api_endpoint }}' data-pid-path='{{ pid_path | tojson }}' + data-pid-value='{{ pid_value }}' data-create-endpoint='{{ create_ui_endpoint }}' data-list-endpoint='{{ list_ui_endpoint }}' > From 218198461fddbcae8d0ef6bea0ba86c76370d274 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Fri, 24 May 2024 10:03:33 +0200 Subject: [PATCH 04/24] fix: adapt to actual API --- invenio_jobs/administration/jobs.py | 6 ++--- .../search/JobSearchResultItemLayout.js | 27 ++++++++++++++++--- invenio_jobs/resources/config.py | 17 +++++++++++- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/invenio_jobs/administration/jobs.py b/invenio_jobs/administration/jobs.py index 9b76bc2..93bb2d4 100644 --- a/invenio_jobs/administration/jobs.py +++ b/invenio_jobs/administration/jobs.py @@ -39,9 +39,9 @@ class JobsListView(AdminResourceListView): display_edit = False item_field_list = { - "job": {"text": _("Jobs"), "order": 1, "width": 3}, - "last_run_start_time": {"text": _("Last run"), "order": 2, "width": 3}, - "last_run_status": {"text": _("Status"), "order": 3, "width": 1}, + "active": {"text": _("Active"), "order": 1, "width": 1}, + "job": {"text": _("Jobs"), "order": 2, "width": 3}, + "last_run_start_time": {"text": _("Last run"), "order": 3, "width": 3}, "user": {"text": _("Started by"), "order": 4, "width": 3}, "next_run": {"text": _("Next run"), "order": 5, "width": 3}, } diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js index 8242c16..5811e74 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js @@ -22,12 +22,31 @@ class SearchResultItemComponent extends Component { return ( + + + + - {result.name} + {result.title} - + {/* */} Date: Fri, 24 May 2024 17:22:56 +0200 Subject: [PATCH 05/24] UX: Add run button dropdown --- .../search/JobSearchResultItemLayout.js | 68 ++++++++++++------- .../administration/search/RunButton.js | 49 +++++++++++++ .../search/RunsSearchResultItemLayout.js | 1 - .../administration/search/SystemJobActions.js | 17 ++--- invenio_jobs/resources/config.py | 17 +---- 5 files changed, 103 insertions(+), 49 deletions(-) create mode 100644 invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/RunButton.js diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js index 5811e74..500ade3 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js @@ -46,7 +46,7 @@ class SearchResultItemComponent extends Component { collapsing className="word-break-all" > - {result.title} + {result.title} - - - {toRelativeTime(result.last_run_start_time, i18next.language)} - - - {/* */} + {result.last_run && ( + + )} + {result.last_run && ( + + )} + {result.last_run + ? toRelativeTime(result.last_run.start_time, i18next.language) + : "−"} + {result.last_run ? ( + + + + ) : ( + + System + + )} - {toRelativeTime(result.next_run, i18next.language)} + {toRelativeTime(result.next_run, i18next.language) ?? "−"} - + ); diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/RunButton.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/RunButton.js new file mode 100644 index 0000000..1e1654f --- /dev/null +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/RunButton.js @@ -0,0 +1,49 @@ +// This file is part of InvenioRDM +// Copyright (C) 2024 CERN +// +// Invenio RDM Records is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import { i18next } from "@translations/invenio_app_rdm/i18next"; +import PropTypes from "prop-types"; +import React from "react"; +import { + Button, + Dropdown, + DropdownMenu, + Form, + FormInput, +} from "semantic-ui-react"; + +export const RunButton = ({ config }) => { + return ( + + +
+ {Object.keys(config).map((key) => ( + e.stopPropagation()} + /> + ))} + ))} + ); }; @@ -62,6 +61,8 @@ export class SystemJobActions extends Component { } } -SystemJobActions.propTypes = {}; +SystemJobActions.propTypes = { + runArgs: PropTypes.object.isRequired, +}; SystemJobActions.defaultProps = {}; diff --git a/invenio_jobs/resources/config.py b/invenio_jobs/resources/config.py index 71f95b4..55e2666 100644 --- a/invenio_jobs/resources/config.py +++ b/invenio_jobs/resources/config.py @@ -9,13 +9,7 @@ """Resources config.""" import marshmallow as ma -from flask_resources import ( - HTTPJSONException, - JSONSerializer, - ResourceConfig, - ResponseHandler, - create_error_handler, -) +from flask_resources import HTTPJSONException, ResourceConfig, create_error_handler from invenio_records_resources.resources.errors import ErrorHandlersMixin from invenio_records_resources.resources.records.args import SearchRequestArgsSchema from invenio_records_resources.services.base.config import ConfiguratorMixin @@ -65,10 +59,6 @@ class TasksResourceConfig(ResourceConfig, ConfiguratorMixin): # Response handling response_handlers = response_handlers - response_handlers = { - "application/json": ResponseHandler(JSONSerializer()), - "application/vnd.inveniordm.v1+json": ResponseHandler(JSONSerializer()), - } class JobsSearchRequestArgsSchema(SearchRequestArgsSchema): """Jobs search request parameters.""" @@ -103,11 +93,6 @@ class RunsSearchRequestArgsSchema(SearchRequestArgsSchema): status = ma.fields.Enum(RunStatusEnum) - response_handlers = { - "application/json": ResponseHandler(JSONSerializer()), - "application/vnd.inveniordm.v1+json": ResponseHandler(JSONSerializer()), - } - class JobsSearchRequestArgsSchema(SearchRequestArgsSchema): """Jobs search request parameters.""" From e1f23ffb21911a5e9cbff5aacfd66f491ea01b5b Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Mon, 27 May 2024 14:19:47 +0200 Subject: [PATCH 06/24] UI: remove settings button --- invenio_jobs/administration/jobs.py | 22 +++++++++---------- .../administration/search/SystemJobActions.js | 16 +++++++------- .../system/jobs/jobs-details.html | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/invenio_jobs/administration/jobs.py b/invenio_jobs/administration/jobs.py index 93bb2d4..65cb7e0 100644 --- a/invenio_jobs/administration/jobs.py +++ b/invenio_jobs/administration/jobs.py @@ -51,12 +51,12 @@ class JobsListView(AdminResourceListView): search_facets_config_name = "JOBS_FACETS" actions = { - "settings": { - "text": "Settings", - "payload_schema": None, - "order": 1, - "icon": "star", - }, + # "settings": { + # "text": "Settings", + # "payload_schema": None, + # "order": 1, + # "icon": "star", + # }, "schedule": { "text": "Schedule", "payload_schema": None, @@ -103,11 +103,11 @@ class JobsDetailsView(AdminResourceListView): search_facets_config_name = "JOBS_FACETS" actions = { - "settings": { - "text": "Settings", - "payload_schema": None, - "order": 1, - }, + # "settings": { + # "text": "Settings", + # "payload_schema": None, + # "order": 1, + # }, "schedule": { "text": "Schedule", "payload_schema": None, diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SystemJobActions.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SystemJobActions.js index d046ae5..4ddda11 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SystemJobActions.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/SystemJobActions.js @@ -15,12 +15,12 @@ import { RunButton } from "./RunButton"; export class SystemJobActions extends Component { handleAction = async (action) => { const actionConfig = { - restore: { - label: i18next.t("Settings"), - icon: "cogwheel", - notificationTitle: i18next.t("Settings"), - }, - block: { + // restore: { + // label: i18next.t("Settings"), + // icon: "cogwheel", + // notificationTitle: i18next.t("Settings"), + // }, + schedule: { label: i18next.t("Schedule"), icon: "calendar", notificationTitle: i18next.t("Schedule"), @@ -32,11 +32,11 @@ export class SystemJobActions extends Component { render() { const actionItems = [ - { key: "settings", label: "Settings", icon: "cog" }, + // { key: "settings", label: "Settings", icon: "cog" }, { key: "schedule", label: "Schedule", icon: "calendar" }, ]; - const { runArgs } = this.props.runArgs; + const { runArgs } = this.props; const generateActions = () => { return ( diff --git a/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-details.html b/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-details.html index 6af83a3..944391a 100644 --- a/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-details.html +++ b/invenio_jobs/templates/semantic-ui/invenio_jobs/system/jobs/jobs-details.html @@ -20,11 +20,11 @@

{{ title or name }}

- {{ _("Settings") }} - + -->