diff --git a/openapi.yaml b/openapi.yaml index cc8732a..709f91d 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -369,6 +369,11 @@ tags: Indicator (Choice, Achievement or Numerical tracker) counted again for only some responses and Contacts, e.g. "Session attendances — Female, under 21". Each has its own row, name, column and targets on a Project's or Album's Results Canvas. + - name: Maps + description: | + Progress maps (My Apps > Maps): a metric's totals shown by area, each area filled with the colour + of the threshold band its total falls in. The colours and the aggregation level the map opens at + belong to the metric and apply to its map wherever it is shown. - name: Add Metric To description: | The Add metric to popup: the places a metric (a Change, Outcome or Indicator) can be added @@ -19871,6 +19876,98 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /maps/settings: + parameters: + - name: project_id + in: query + description: The Project the map is drawn from. Give this or album_id. + schema: {type: integer} + - name: album_id + in: query + description: The Album (Bundle) the map is drawn from. Give this or project_id. + schema: {type: integer} + - name: metric_type + in: query + required: true + description: "`Indicator` (a Progress Tracker) or `Change` (an Engagement)" + schema: {type: string, enum: [Indicator, Change]} + - name: metric_id + in: query + required: true + description: The metric, which must have results on the Project's or Album's updates + schema: {type: integer} + get: + tags: [Maps] + summary: Get a metric's progress map colours and aggregation level + description: | + How the metric's progress map is coloured and the aggregation level it opens at, as the + Metric Map Colours popup on the Maps page shows them. Anyone who can see the Project's or + Album's results can read them. A metric whose map has never been set up shows the default + colours. + operationId: getMapSettings + security: [{tokenAuth: []}] + responses: + "200": + description: The map settings + content: + application/json: + schema: + $ref: '#/components/schemas/MapSettings' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + put: + tags: [Maps] + summary: Set a metric's progress map colours and aggregation level + description: | + Saves what the Metric Map Colours popup saves. `thresholds` replaces the custom bands and + switches the map to them. The bands must follow on from each other with no gaps or overlaps + (whole numbers, at most 20), and every colour needs at least 3:1 contrast with the map's black + boundary lines. `colours: default` switches back to the default bands and keeps the custom + ones. Anything left out is unchanged. The change applies to the metric's map everywhere in the + organisation. Editors and reporters of the organisation, or of a Project the map is drawn + from, can change it. + operationId: updateMapSettings + security: [{tokenAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + colours: {type: string, enum: [default, custom]} + thresholds: + type: array + maxItems: 20 + items: + $ref: '#/components/schemas/MapThreshold' + aggregation_level: + type: string + enum: [Wards, Districts, Counties, Regions, Countries, Continents] + example: + thresholds: + - {from: 0, to: 9, colour: "#ffffff"} + - {from: 10, to: 99, colour: "#ffa300"} + - {from: 100, to: 999, colour: "#3596d6"} + aggregation_level: Regions + responses: + "200": + description: The saved map settings + content: + application/json: + schema: + $ref: '#/components/schemas/MapSettings' + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/Forbidden' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /media_items: get: tags: [Media Gallery] @@ -32249,6 +32346,33 @@ components: type: object contact_criteria: type: object + MapThreshold: + type: object + required: [from, to, colour] + properties: + from: {type: integer} + to: {type: integer} + colour: {type: string, description: "Hex, e.g. #ffa300", example: "#ffa300"} + MapSettings: + type: object + properties: + metric_type: {type: string, enum: [Indicator, Change]} + metric_id: {type: integer} + metric_name: {type: string} + colours: {type: string, enum: [default, custom]} + thresholds: + type: array + description: The bands the map is coloured with, in order + items: + $ref: '#/components/schemas/MapThreshold' + aggregation_level: + type: string + nullable: true + description: The level the map opens at; null opens it at Wards, or at the shape type of the updates + aggregation_levels: + type: array + items: {type: string} + boundary_colour: {type: string, example: "#000000"} FilteredMetricResult: type: object properties: diff --git a/server.js b/server.js index a41ce86..9645528 100644 --- a/server.js +++ b/server.js @@ -973,6 +973,7 @@ function buildDocsPage() { Automations Formula Trackers Filtered Metrics + Maps
+ +A progress map (My Apps > Maps) shows a metric's totals by area, filling each area with the colour of the threshold band its total falls in. The colours and the aggregation level the map opens at belong to the metric (an Indicator, i.e. a Progress Tracker, or a Change, i.e. an Engagement) and apply to its map wherever it is shown. Name the map as the Maps page does: a Project or Album, and a metric with results on its updates. A Project or Album you can't see, or a metric not on it, returns 404.
Bands are whole numbers and must follow on from each other with no gaps or overlaps, e.g. 0–9, 10–99, 100–999 (at most 20). Each colour needs at least 3:1 contrast with the map's black boundary lines, so very dark colours are refused.
+Indicator or Change" },
+ { name: "metric_id", type: "integer", required: true, desc: "The metric" }
+ ], [
+ { code: "200", cls: "response-2xx", desc: "colours, thresholds [{from, to, colour}], aggregation_level, aggregation_levels, boundary_colour" },
+ { code: "404", cls: "response-4xx", desc: "Project, Album or metric not found, or not visible to you" }
+ ])}
+ ${endpointCard("PUT", "/maps/settings", "Set a metric's progress map colours and aggregation level", true, [
+ { name: "project_id / album_id, metric_type, metric_id", type: "", required: true, in: "body", desc: "As for GET" },
+ { name: "thresholds", type: "array", required: false, in: "body", desc: "Replaces the custom bands and switches the map to them: [{from, to, colour}]" },
+ { name: "colours", type: "string", required: false, in: "body", desc: "default switches back to the default bands; custom to the saved custom ones" },
+ { name: "aggregation_level", type: "string", required: false, in: "body", desc: "Wards, Districts, Counties, Regions, Countries or Continents" }
+ ], [
+ { code: "200", cls: "response-2xx", desc: "The saved settings, as GET returns them" },
+ { code: "403", cls: "response-4xx", desc: "You can see the map but aren't an editor or reporter of the organisation or Project" },
+ { code: "422", cls: "response-4xx", desc: "{errors}, e.g. a gap or overlap between bands, or a colour too dark" }
+ ])}
+