forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExplorerConstants.ts
77 lines (60 loc) · 2.2 KB
/
ExplorerConstants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { ColumnSlug, SerializedGridProgram } from "../clientUtils/owidTypes"
import { SortOrder } from "../coreTable/CoreTableConstants"
import { GrapherQueryParams } from "../grapher/core/GrapherInterface"
export enum ExplorerControlType {
Radio = "Radio",
Checkbox = "Checkbox",
Dropdown = "Dropdown",
}
export const DefaultNewExplorerSlug = "new"
export const ExplorerControlTypeRegex = new RegExp(
" (" + Object.values(ExplorerControlType).join("|") + ")$"
)
export interface ExplorerChoice {
title: string
displayTitle?: string
options: ExplorerChoiceOption[]
value: string
type: ExplorerControlType
}
export interface ExplorerChoiceOption {
label: string
available: boolean
value: string
checked?: boolean
}
export type ChoiceName = string
export type ChoiceValue = string
export interface ExplorerChoiceParams {
[choiceName: string]: ChoiceValue
}
export interface ChoiceMap {
[choiceName: string]: ChoiceValue[]
}
/** Query params available in all explorers */
export interface ExplorerStandardQueryParams extends GrapherQueryParams {
pickerSort?: SortOrder
pickerMetric?: ColumnSlug
hideControls?: string
}
export type ExplorerFullQueryParams = ExplorerStandardQueryParams &
ExplorerChoiceParams
export const UNSAVED_EXPLORER_DRAFT = "UNSAVED_EXPLORER_DRAFT"
export const UNSAVED_EXPLORER_PREVIEW_QUERYPARAMS =
"UNSAVED_EXPLORER_PREVIEW_QUERYPARAMS"
export const EMBEDDED_EXPLORER_DELIMITER = "\n//EMBEDDED_EXPLORER\n"
export const EMBEDDED_EXPLORER_GRAPHER_CONFIGS =
"\n//EMBEDDED_EXPLORER_GRAPHER_CONFIGS\n"
export const EXPLORER_EMBEDDED_FIGURE_SELECTOR = "data-explorer-src"
export const ExplorerContainerId = "ExplorerContainer"
export const GetAllExplorersRoute = "allExplorers.json"
export const EXPLORERS_ROUTE_FOLDER = "explorers" // Url path: http://owid.org/{explorers}
export const EXPLORERS_GIT_CMS_FOLDER = "explorers" // Disk path: /home/owid/git-content/{explorers}
export const EXPLORERS_PREVIEW_ROUTE = `${EXPLORERS_ROUTE_FOLDER}/preview`
export interface ExplorersRouteResponse {
success: boolean
errorMessage?: string
needsPull: boolean
gitCmsBranchName: string
explorers: SerializedGridProgram[]
}