dashboard-cards
v1.0.0
Published
Module for grouping Flow activities into the proper format for clients to render the dashboard.
Readme
Browser Card grouping
Module for grouping Flow activities into the proper format for clients to render the dashboard.
Developing in this repo
To set up:
$ npm installTo compile src into dist:
$ gruntTo run tests:
$ grunt testTo run linter
$ npm lint
$ npm lint:testsUsage
Example input
Input is expected to be JSON that matches the response from the API for a /activities endpoint
"activities" : [
{
"read" : true,
"account_id" : 167448,
"payload" : {
"comment" : {
"content_html" : "<p><strong name=\"\" class=\"comment-author\"></strong> – this should now be available in staging</p>",
"deleted" : false,
"mime_type" : "text/html",
"content" : "<p>this should now be available in staging</p>"
}
},
"action" : "add_comment",
"created_at" : "2016-06-23T23:40:48-07:00",
"target_id" : 5663955,
"workspace_id" : 1,
"updated_at" : "2016-06-23T23:40:48-07:00",
"id" : 23901879,
"recipient_ids" : [
167330,
167324,
104009,
22345,
8
],
"subscriber_ids" : [
167448,
167330,
167324,
104009,
22345,
8
],
"target_type" : "Task"
}
]Example Output
Different dashboard cards are grouped in different ways - mentions and comments are grouped by task (target_id). Likes are groupedd by activity (target_id). Completion activities are grouped by task owner (account_id). Due changes are always their own card. Assign activities are one single group for the current account.
{
"assign": [
{
"activities" : [2,3,4]
}
],
"conversation": [
{
"target_id": 444,
"activities": [183,213,333,422]
},
{
"target_id": 574,
"activities": [22,44,2]
}
],
"mention": [
{
"target_id": 66,
"activities": [12]
}
],
"complete": [
{
"account_id": 9,
"activities": [12,3,5,7]
}
],
"like": [
{
"target_id": 9,
"activities": [4]
},
{
"target_id": 10,
"activities": [2,6,7]
}
],
}