-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdashboard.ts
65 lines (55 loc) · 1.92 KB
/
dashboard.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
import { DataSource } from '../data/data-source/data-source';
import { TimeRange } from '../data/time-range/time-range';
import { Constructable } from '../util/constructable';
/**
* Represents an instantiated dashboard
*/
// tslint:disable-next-line: no-any want any data source to be assignable here, caller should be more specific
export interface Dashboard<TRoot extends object = object> {
/**
* The root model of the dashboard
*/
readonly root: TRoot;
/**
* Sets a variable scoped to the entire dashboard (the root)
*/
setVariable(variableName: string, value: unknown): this;
/**
* Sets root time range for entire dashboard
*/
setTimeRange(timeRange: TimeRange): this;
/**
* Returns a serialized form of this dashboard. Note this does not
* affect the dashboard in any way, it must be explicitly destroyed
* if it is no longer in use.
*/
serialize(): object;
/**
* Destroys the dashboard, removing internal references from memory
*/
destroy(): void;
/**
* Refreshes the dashboard, broadcasting an event indicating data should be refetched
*/
refresh(): this;
/**
* Sets the root data source of the dashboard
*/
setRootDataSource<T>(dataSource: DataSource<T>): this;
/**
* Creates the provided model class and sets it as the root data source of the dashboard. The
* model will be attached to the model tree as a child of root, and will be destroyed when
* the root is destroyed.
*/
createAndSetRootDataFromModelClass<T>(dataSourceModelClass: Constructable<DataSource<T>>): this;
/**
* Returns the root data source of the dashboard, if set
*/
// tslint:disable-next-line: no-any
getRootDataSource<T extends DataSource<any>>(): T | undefined;
/**
* Returns a shallow copy array of model instances within a dashboard that match the
* argument model class
*/
getModelInstances<T extends object>(modelClass: Constructable<T>): object[];
}