-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
241 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import { RDBType, Relationship, SchemaDef } from 'reactivedb/interface' | ||
import { schemas } from '../SDK' | ||
|
||
import { | ||
UserId, | ||
TapChartId, | ||
TapDashboardId, | ||
ExecutorOrCreator, | ||
TapGenericFilterRequest as FilterRequest, | ||
TapGenericFilterResponse as FilterResponse | ||
} from 'teambition-types' | ||
|
||
export type TapChartType = 'bar' | 'line' | ||
|
||
// tapGraph definition | ||
export type TapGraphColType = 'type/DateTime' | 'type/Integer' | 'type/String' | ||
|
||
export interface TapGraphCol { | ||
name: string | ||
baseType: TapGraphColType | ||
} | ||
|
||
export type TapGraphData = { | ||
cols: TapGraphCol[], | ||
rows: any[][] | ||
} | ||
|
||
export type TapGraphLineDisplay = { | ||
showPointMarker: boolean, | ||
stack: false | 'stack' | ||
} | ||
|
||
export type TapGraphBarDisplay = { | ||
stack: false | 'stack' | ||
} | ||
|
||
export type TapGraphVisualizationSettings = { | ||
type: TapChartType | ||
dimension: number // key of cols in data | ||
display: TapGraphLineDisplay | TapGraphBarDisplay | ||
axes: { | ||
x: { | ||
visible: boolean | ||
label: string | null | ||
scale: 'timeseries' | 'ordinal' | ||
}, | ||
y: { | ||
visible: boolean | ||
scale: 'linear' | ||
label: string | null | ||
range: 'auto' | ||
} | ||
} | ||
} | ||
|
||
// tapChart definition | ||
export interface TapChartSchema<T extends FilterRequest | FilterResponse> { | ||
_id: TapChartId | ||
|
||
_creatorId: UserId | ||
creator?: ExecutorOrCreator | ||
|
||
_tapdashboardId: TapDashboardId | ||
tapdashboard?: { | ||
_id: TapDashboardId, | ||
name: string | ||
} | ||
|
||
name: string | ||
desc: string | ||
|
||
created: string | ||
updated: string | ||
|
||
filter: T | ||
filterList: FilterResponse | ||
|
||
graphData: TapGraphData | ||
visualizationSettings: TapGraphVisualizationSettings | ||
} | ||
|
||
const schema: SchemaDef<TapChartSchema<FilterRequest | FilterResponse>> = { | ||
_id: { | ||
type: RDBType.STRING, | ||
primaryKey: true | ||
}, | ||
|
||
_creatorId: { | ||
type: RDBType.STRING | ||
}, | ||
creator: { | ||
type: Relationship.oneToOne, | ||
virtual: { | ||
name: 'Member', | ||
where: (memberTable: any) => ({ | ||
_creatorId: memberTable._id | ||
}) | ||
} | ||
}, | ||
|
||
_tapdashboardId: { | ||
type: RDBType.STRING | ||
}, | ||
tapdashboard: { | ||
type: Relationship.oneToOne, | ||
virtual: { | ||
name: 'TapDashboard', | ||
where: (dashboardTable: any) => ({ | ||
_tapdashboardId: dashboardTable._id | ||
}) | ||
} | ||
}, | ||
|
||
name: { | ||
type: RDBType.STRING | ||
}, | ||
desc: { | ||
type: RDBType.STRING | ||
}, | ||
|
||
created: { | ||
type: RDBType.DATE_TIME | ||
}, | ||
updated: { | ||
type: RDBType.DATE_TIME | ||
}, | ||
|
||
filter: { | ||
type: RDBType.OBJECT | ||
}, | ||
filterList: { | ||
type: RDBType.OBJECT | ||
}, | ||
|
||
graphData: { | ||
type: RDBType.OBJECT | ||
}, | ||
visualizationSettings: { | ||
type: RDBType.OBJECT | ||
} | ||
} | ||
|
||
schemas.push({ schema, name: 'TapChart' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { RDBType, Relationship, SchemaDef } from 'reactivedb/interface' | ||
import { schemas } from '../SDK' | ||
|
||
import { | ||
UserId, | ||
ProjectId, | ||
TapDashboardId, | ||
ExecutorOrCreator, | ||
TapGenericFilterRequest as FilterRequest, | ||
TapGenericFilterResponse as FilterResponse | ||
} from 'teambition-types' | ||
|
||
import { | ||
TapChartType, | ||
TapChartSchema | ||
} from './TapChart' | ||
|
||
export interface TapDashboardSchema<T extends FilterRequest | FilterResponse> { | ||
_id: TapDashboardId | ||
|
||
_projectId: ProjectId | ||
|
||
_creatorId: UserId | ||
creator?: ExecutorOrCreator | ||
|
||
name: string | ||
cover: TapChartType | ||
|
||
filter: T | ||
tapcharts: TapChartSchema<T>[] | ||
} | ||
|
||
const schema: SchemaDef<TapDashboardSchema<FilterRequest | FilterResponse>> = { | ||
_id: { | ||
type: RDBType.STRING, | ||
primaryKey: true | ||
}, | ||
|
||
_projectId: { | ||
type: RDBType.STRING | ||
}, | ||
|
||
_creatorId: { | ||
type: RDBType.STRING | ||
}, | ||
creator: { | ||
type: Relationship.oneToOne, | ||
virtual: { | ||
name: 'Member', | ||
where: (memberTable: any) => ({ | ||
_creatorId: memberTable._id | ||
}) | ||
} | ||
}, | ||
|
||
name: { | ||
type: RDBType.STRING | ||
}, | ||
cover: { | ||
type: RDBType.STRING | ||
}, | ||
|
||
filter: { | ||
type: RDBType.OBJECT | ||
}, | ||
tapcharts: { | ||
type: Relationship.oneToMany, | ||
virtual: { | ||
name: 'TapChart', | ||
where: (tapChartTable: any) => ({ | ||
_id: tapChartTable._tapdashboardId | ||
}) | ||
} | ||
} | ||
} | ||
|
||
schemas.push({ schema, name: 'TapDashboard' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { TapChartType } from './TapChart' | ||
import { TapGenericFilterResponse } from 'teambition-types' | ||
|
||
export interface QuestionId extends String { | ||
kind?: 'QuestionId' | ||
} | ||
|
||
export interface QuestionSchema { | ||
_id: QuestionId | ||
type: TapChartType | ||
|
||
name: string | ||
desc: string | ||
|
||
filter: TapGenericFilterResponse | ||
|
||
[index: string]: any | ||
} |