Introduction
...
Each of the above elements - metrics and graphs are considered as dashlets. These dashlets can either be created using query interface or REST API. For more details on creating dashlets using query interface, refer to <>.
Create dashlet via API
URL: http[s]:<host>:<port>/openspecimen/rest/ng/dashlet-configs
URL | http://<host>:<port>/ openspecimen/rest/ng/dashlet-configs |
Method | POST |
Request | application/json |
Example json for Metric | Dashlet to include metric : Count of completed visits Code Block |
---|
| {
"name":"visit_count",
"title":"Visits",
"type":"COUNTER",
"dataSource":{
"options":{
"criteria":" SpecimenCollectionGroup.activityStatus = \"Active\" and SpecimenCollectionGroup.collectionStatus = \"Complete\" and Specimen.collectionStatus = \"Collected\" ",
"metric":{
"expr":"count(distinct SpecimenCollectionGroup.name)",
"title":"Visits"
}
},
"type":"AQL"
},
"chartOpts":{},
"activityStatus":"Active"
} |
|
Example json for graph | Dashlet to include graph : Available aliquots by type Code Block |
---|
| {
"name": "dash_1_20161215_0251537",
"title": "Available aliquots by type",
"type": "CHART",
"dataSource": {
"options": {
"criteria": " Specimen.collectionStatus = \"Collected\" and Specimen.lineage = \"Aliquot\" and Specimen.specimenPosition.containerName exists ",
"metric": {
"expr": "count(distinct Specimen.id)",
"title": "Aliquots"
},
"category": {
"expr": "Specimen.type",
"title": "Type"
}
},
"type": "AQL"
},
"chartOpts": {
"type": "Pie"
},
"activityStatus": "Active"
} |
|
Configuring dashboards to CP
...
Step 2: Use above API response to obtain dashboard ID, add make required changes.
URL | http://<host>:<port>/ openspecimen/rest/ng/dashboards/{dashboardId} |
Method | PUT |
Request | application/json |
Example json | Code Block |
---|
| {
"view": "CollectionProtocol",
"viewParams": {
"cpId": "-1"
},
"dashlets": [
{
"config": {
"name": "dash-sys-participants"
},
"sortOrder": 1
},
{
"config": {
"name": "visit_count"
},
"sortOrder": 2
},
{
"config": {
"name": "dash_1_20161214_0406950"
},
"sortOrder": 3
},
{
"config": {
"name": "dash_1_20161214_0357273"
},
"sortOrder": 4
},
{
"config": {
"name": "dash_1_20161215_0251537"
},
"sortOrder": 5
},
{
"config": {
"name": "dash-spmns-by-anatomic"
},
"sortOrder": 6
},
{
"config": {
"name": "dash-sys-coll-dist"
},
"sortOrder": 7
},
{
"config": {
"name": "dash-sys-coll-dist-yr"
},
"sortOrder": 8
},
{
"config": {
"name": "dash-spmns-by-path"
},
"sortOrder": 9
}
],
"activityStatus": "Active"
} |
|
Configuring dashboards to SpecimenCatalog
...