diff --git a/dispatcher/backend/docs/openapi_v1.yaml b/dispatcher/backend/docs/openapi_v1.yaml index 01f671583..984a475ea 100644 --- a/dispatcher/backend/docs/openapi_v1.yaml +++ b/dispatcher/backend/docs/openapi_v1.yaml @@ -1033,62 +1033,69 @@ paths: content: application/json: schema: - type: array - items: - type: object - additionalProperties: true - required: - - key - - type - - label - - required - properties: - key: - type: string - example: username - description: ID/name of the field - type: - type: string - enum: - - text - - hex-color - - url - - email - - integer - - float - - boolean - - string-enum - - list-of-string-enum - description: the type of the field - example: url - label: - type: string - example: Content URL - description: Human representation of the key/name - required: - type: boolean - example: true - description: whether this field's value is required - description: - type: string - example: URL of some information - description: Description to help fill the field - placeholder: - type: string - description: the field's placeholder - example: http://somecontent.tld/here - choices: - description: list of choices to choose a value from - type: array - items: - type: string - example: - - some-value - - another-value - data_key: - type: string - description: actual param name (for when key cant be named the same) - example: api-key + type: object + properties: + help: + type: string + example: https://github.com/openzim/ted/wiki/Frequently-Asked-Questions + description: URL where help to configure offliner can be found + flags: + type: array + items: + type: object + additionalProperties: true + required: + - key + - type + - label + - required + properties: + key: + type: string + example: username + description: ID/name of the field + type: + type: string + enum: + - text + - hex-color + - url + - email + - integer + - float + - boolean + - string-enum + - list-of-string-enum + description: the type of the field + example: url + label: + type: string + example: Content URL + description: Human representation of the key/name + required: + type: boolean + example: true + description: whether this field's value is required + description: + type: string + example: URL of some information + description: Description to help fill the field + placeholder: + type: string + description: the field's placeholder + example: http://somecontent.tld/here + choices: + description: list of choices to choose a value from + type: array + items: + type: string + example: + - some-value + - another-value + data_key: + type: string + description: actual param name (for when key cant be named the same) + example: api-key 404: description: Not Found content: diff --git a/dispatcher/backend/src/routes/offliners/offliner.py b/dispatcher/backend/src/routes/offliners/offliner.py index 5ca7b699e..1e4ba0c94 100644 --- a/dispatcher/backend/src/routes/offliners/offliner.py +++ b/dispatcher/backend/src/routes/offliners/offliner.py @@ -35,4 +35,12 @@ def get(self, offliner: str, *args, **kwargs): schema = ScheduleConfigSchema.get_offliner_schema(offliner)() - return jsonify(schema.to_desc()) + return jsonify( + { + "flags": schema.to_desc(), + "help": ( # dynamic + sourced from backend because it might be custom + f"https://github.com/openzim/{offliner}/wiki" + "/Frequently-Asked-Questions" + ), + } + ) diff --git a/dispatcher/backend/src/tests/integration/routes/offliners/test_offliners_routes.py b/dispatcher/backend/src/tests/integration/routes/offliners/test_offliners_routes.py new file mode 100644 index 000000000..c836abd6d --- /dev/null +++ b/dispatcher/backend/src/tests/integration/routes/offliners/test_offliners_routes.py @@ -0,0 +1,28 @@ +import pytest + +from common.enum import Offliner + + +def test_list_offliners(client): + url = "/offliners/" + response = client.get(url) + assert response.status_code == 200 + response_json = response.get_json() + assert "items" in response_json + assert "meta" in response_json + assert "count" in response_json["meta"] + assert len(response_json["items"]) == response_json["meta"]["count"] + + +@pytest.mark.parametrize("offliner", Offliner.all()) +def test_get_offliner(client, offliner): + url = f"/offliners/{offliner}" + response = client.get(url) + assert response.status_code == 200 + response_json = response.get_json() + assert "flags" in response_json + assert "help" in response_json + assert ( + response_json["help"] + == f"https://github.com/openzim/{offliner}/wiki/Frequently-Asked-Questions" + ) diff --git a/dispatcher/frontend-ui/src/components/ScheduleEditor.vue b/dispatcher/frontend-ui/src/components/ScheduleEditor.vue index 83292d496..6353f02f1 100644 --- a/dispatcher/frontend-ui/src/components/ScheduleEditor.vue +++ b/dispatcher/frontend-ui/src/components/ScheduleEditor.vue @@ -15,6 +15,19 @@ +
+ + +

Content settings

+ + Help + + +
+ -
+
+ + +

Task settings

+ + Help + + +
@@ -206,7 +230,16 @@
-

{{ edit_task_name}} command flags

+ +

Scraper settings: {{ edit_task_name}} command flags

+ + Help + + +
@@ -290,7 +323,9 @@ schedule() { return this.$store.getters.schedule || null; }, editorReady() { return this.schedule && this.edit_schedule && this.flags_definition !== null; }, edit_task_name() { return this.edit_schedule.config.task_name || this.schedule.config.task_name; }, - flags_definition() { return this.$store.getters.offliners_defs[this.edit_task_name] || null }, + offliner_definition() { return this.$store.getters.offliners_defs[this.edit_task_name] || null }, + flags_definition() { return this.offliner_definition ? this.offliner_definition.flags : null }, + help() { return this.offliner_definition ? this.offliner_definition.help : null }, edit_flags_fields() { let fields = []; for (var i=0;i