Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand Down
32 changes: 32 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ function buildDocsPage() {
<a href="#automations" class="nav-link"><span class="nav-method method-POST">POST</span>Automations</a>
<a href="#formula-trackers" class="nav-link"><span class="nav-method method-POST">POST</span>Formula Trackers</a>
<a href="#filtered-metrics" class="nav-link"><span class="nav-method method-POST">POST</span>Filtered Metrics</a>
<a href="#maps" class="nav-link"><span class="nav-method method-PUT">PUT</span>Maps</a>
</div>
<div class="nav-section">
<div class="nav-section-label">Events</div>
Expand Down Expand Up @@ -4543,6 +4544,37 @@ function buildDocsPage() {
</div>
</section>

<!-- Maps -->
<section class="section" id="maps">
<div class="section-eyebrow">Impact framework</div>
<h2 class="section-title">Maps</h2>
<div class="section-desc">
<p>A progress map (My Apps &gt; 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 <code>404</code>.</p>
<p>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.</p>
</div>
<div class="endpoint-list">
${endpointCard("GET", "/maps/settings", "Get a metric's progress map colours and aggregation level", true, [
{ name: "project_id", type: "integer", required: false, desc: "The Project the map is drawn from (or album_id)" },
{ name: "album_id", type: "integer", required: false, desc: "The Album the map is drawn from (or project_id)" },
{ name: "metric_type", type: "string", required: true, desc: "<code>Indicator</code> or <code>Change</code>" },
{ name: "metric_id", type: "integer", required: true, desc: "The metric" }
], [
{ code: "200", cls: "response-2xx", desc: "<code>colours</code>, <code>thresholds</code> [{from, to, colour}], <code>aggregation_level</code>, <code>aggregation_levels</code>, <code>boundary_colour</code>" },
{ 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: "<code>default</code> switches back to the default bands; <code>custom</code> 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: "<code>{errors}</code>, e.g. a gap or overlap between bands, or a colour too dark" }
])}
</div>
</section>

<!-- Events -->
<section class="section" id="events">
<div class="section-eyebrow">Events</div>
Expand Down
Loading