Skip to content

Commit

Permalink
🚧 wip admin
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Jul 18, 2024
1 parent de54456 commit 64e3497
Show file tree
Hide file tree
Showing 7 changed files with 693 additions and 459 deletions.
61 changes: 31 additions & 30 deletions adminSiteClient/ChartEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,21 @@ export interface DimensionErrorMessage {
export interface ChartEditorManager {
admin: Admin
grapher: Grapher
database: EditorDatabase
// database: EditorDatabase
baseGrapherConfig: GrapherInterface
logs: Log[]
references: References | undefined
redirects: ChartRedirect[]
pageviews?: RawPageview
allTopics: Topic[]
details: DetailDictionary
invalidDetailReferences: DetailReferences
errorMessages: Partial<Record<FieldWithDetailReferences, string>>
errorMessagesForDimensions: Record<
DimensionProperty,
DimensionErrorMessage[]
>
// allTopics: Topic[]
// details: DetailDictionary
// TODO
// invalidDetailReferences: DetailReferences
// errorMessages: Partial<Record<FieldWithDetailReferences, string>>
// errorMessagesForDimensions: Record<
// DimensionProperty,
// DimensionErrorMessage[]
// >
}

interface VariableIdUsageRecord {

Check warning on line 120 in adminSiteClient/ChartEditor.ts

View workflow job for this annotation

GitHub Actions / eslint

'VariableIdUsageRecord' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 120 in adminSiteClient/ChartEditor.ts

View workflow job for this annotation

GitHub Actions / eslint

'VariableIdUsageRecord' is defined but never used. Allowed unused vars must match /^_/u
Expand Down Expand Up @@ -168,9 +169,9 @@ export class ChartEditor {
return this.manager.grapher
}

@computed get database() {
return this.manager.database
}
// @computed get database() {
// return this.manager.database
// }

@computed get logs() {
return this.manager.logs
Expand All @@ -188,13 +189,13 @@ export class ChartEditor {
return this.manager.pageviews
}

@computed get allTopics() {
return this.manager.allTopics
}
// @computed get allTopics() {
// return this.manager.allTopics
// }

@computed get details() {
return this.manager.details
}
// @computed get details() {
// return this.manager.details
// }

@computed get availableTabs(): EditorTab[] {
const tabs: EditorTab[] = ["basic", "data", "text", "customize"]
Expand All @@ -215,18 +216,18 @@ export class ChartEditor {
return new EditorFeatures(this)
}

async loadVariableUsageCounts(): Promise<void> {
const data = (await this.manager.admin.getJSON(
`/api/variables.usages.json`
)) as VariableIdUsageRecord[]
const finalData = new Map(
data.map(({ variableId, usageCount }: VariableIdUsageRecord) => [
variableId,
+usageCount,
])
)
runInAction(() => (this.database.variableUsageCounts = finalData))
}
// async loadVariableUsageCounts(): Promise<void> {
// const data = (await this.manager.admin.getJSON(
// `/api/variables.usages.json`
// )) as VariableIdUsageRecord[]
// const finalData = new Map(
// data.map(({ variableId, usageCount }: VariableIdUsageRecord) => [
// variableId,
// +usageCount,
// ])
// )
// runInAction(() => (this.database.variableUsageCounts = finalData))
// }

async saveGrapher({
onError,
Expand Down
Loading

0 comments on commit 64e3497

Please sign in to comment.