Skip to content
This repository was archived by the owner on Jan 10, 2020. It is now read-only.

Commit 87b90d6

Browse files
committed
Adding date filters and all the dashboard options. Adding images to the read me.
1 parent aab7808 commit 87b90d6

25 files changed

+415
-54
lines changed

Controller/PushAdminController.php

Lines changed: 168 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,107 @@ public function pushMessagesAction() {
262262
* @Route("push/data/app_open_graph", defaults={"_format": "json"}, name="dabsquared_push_notifications_data_app_open_graph")
263263
* @Method("POST")
264264
* @RequestParam(name="device_state", description="What device state to grab", strict=true)
265-
* @RequestParam(name="internal_app_ids", description="The vendor device identifier of the Android device.", strict=true, array=true)
265+
* @RequestParam(name="internal_app_ids", description="The internal app ids to see information for.", strict=true, array=true)
266+
* @RequestParam(name="device_types", description="The device types to show data for", strict=true, array=true)
267+
* @RequestParam(name="start_date", description="Start date", strict=false)
268+
* @RequestParam(name="end_date", description="End date", strict=false)
266269
*/
267270
public function getAppOpenGraphDataAction(ParamFetcher $paramFetcher) {
268271
$deviceState = $paramFetcher->get('device_state');
269272
$internalAppIds = $paramFetcher->get('internal_app_ids');
273+
$deviceTypes = $paramFetcher->get('device_types');
274+
$startDate = $paramFetcher->get('start_date');
275+
$endDate = $paramFetcher->get('end_date');
276+
277+
if(is_null($startDate)) {
278+
$date = new \DateTime('NOW');
279+
$date->modify('-1 week');
280+
$startDate = $date;
281+
} else {
282+
$startDate = new \DateTime($startDate);
283+
}
284+
285+
if(is_null($endDate)) {
286+
$endDate = new \DateTime('NOW');
287+
}else {
288+
$endDate = new \DateTime($endDate);
289+
}
290+
291+
292+
$appEvents = $this->appEventManager->getAppEvents(array(AppEventInterface::APP_OPEN), $deviceTypes, $internalAppIds, $deviceState, $startDate, $endDate);
293+
$appEventDayCounts = array();
294+
295+
/** @var $appEvent \DABSquared\PushNotificationsBundle\Model\AppEventInterface */
296+
foreach($appEvents as $appEvent) {
297+
$day = $appEvent->getCreatedAt()->format('Y-m-d');
298+
$appId = $appEvent->getDevice()->getAppId();
299+
300+
if(!isset($appEventDayCounts[$day])) {
301+
$appEventDayCounts[$day] = array();
302+
}
303+
304+
if(!isset($appEventDayCounts[$day][$appId])) {
305+
$appEventDayCounts[$day][$appId] = 0;
306+
}
307+
308+
$appEventDayCounts[$day][$appId] = $appEventDayCounts[$day][$appId] + 1;
309+
}
310+
311+
ksort($appEventDayCounts);
312+
313+
$appEventCounts = array();
314+
315+
foreach($appEventDayCounts as $key => $val) {
316+
$tempPointArray = array();
317+
$tempPointArray['day'] = $key;
318+
319+
foreach($appEventDayCounts[$key] as $key1 => $val1) {
320+
$tempPointArray[$key1] = $val1;
321+
}
322+
323+
$appEventCounts[] = $tempPointArray;
324+
}
325+
326+
return $appEventCounts;
327+
}
328+
329+
/**
330+
* @ApiDoc(
331+
* description="Gets the data to be converted for the graph",
332+
* section="DABSquared Push Notifications (Dashboard Data)"
333+
* )
334+
* @Rest\View()
335+
* @Route("push/data/app_terminated_graph", defaults={"_format": "json"}, name="dabsquared_push_notifications_data_app_terminated_graph")
336+
* @Method("POST")
337+
* @RequestParam(name="device_state", description="What device state to grab", strict=true)
338+
* @RequestParam(name="internal_app_ids", description="The internal app ids to see information for.", strict=true, array=true)
339+
* @RequestParam(name="device_types", description="The device types to show data for", strict=true, array=true)
340+
* @RequestParam(name="start_date", description="Start date", strict=false)
341+
* @RequestParam(name="end_date", description="End date", strict=false)
342+
*/
343+
public function getAppTerminatedGraphDataAction(ParamFetcher $paramFetcher) {
344+
$deviceState = $paramFetcher->get('device_state');
345+
$internalAppIds = $paramFetcher->get('internal_app_ids');
346+
$deviceTypes = $paramFetcher->get('device_types');
347+
$startDate = $paramFetcher->get('start_date');
348+
$endDate = $paramFetcher->get('end_date');
349+
350+
if(is_null($startDate)) {
351+
$date = new \DateTime('NOW');
352+
$date->modify('-1 week');
353+
$startDate = $date;
354+
} else {
355+
$startDate = new \DateTime($startDate);
356+
}
270357

271-
$appEvents = $this->appEventManager->getAppEvents(array(AppEventInterface::APP_OPEN), array(Types::OS_IOS), $internalAppIds, $deviceState, new \DateTime('2005-08-15T15:52:01+00:00'), new \DateTime('2015-08-15T15:52:01+00:00'));
358+
if(is_null($endDate)) {
359+
$endDate = new \DateTime('NOW');
360+
}else {
361+
$endDate = new \DateTime($endDate);
362+
}
363+
364+
365+
$appEvents = $this->appEventManager->getAppEvents(array(AppEventInterface::APP_TERMINATED), $deviceTypes, $internalAppIds, $deviceState, $startDate, $endDate);
272366
$appEventDayCounts = array();
273367

274368
/** @var $appEvent \DABSquared\PushNotificationsBundle\Model\AppEventInterface */
@@ -305,6 +399,78 @@ public function getAppOpenGraphDataAction(ParamFetcher $paramFetcher) {
305399
return $appEventCounts;
306400
}
307401

402+
/**
403+
* @ApiDoc(
404+
* description="Gets the data to be converted for the graph",
405+
* section="DABSquared Push Notifications (Dashboard Data)"
406+
* )
407+
* @Rest\View()
408+
* @Route("push/data/app_backgrounded_graph", defaults={"_format": "json"}, name="dabsquared_push_notifications_data_app_backgrounded_graph")
409+
* @Method("POST")
410+
* @RequestParam(name="device_state", description="What device state to grab", strict=true)
411+
* @RequestParam(name="internal_app_ids", description="The internal app ids to see information for.", strict=true, array=true)
412+
* @RequestParam(name="device_types", description="The device types to show data for", strict=true, array=true)
413+
* @RequestParam(name="start_date", description="Start date", strict=false)
414+
* @RequestParam(name="end_date", description="End date", strict=false)
415+
*/
416+
public function getAppBackgroundedGraphDataAction(ParamFetcher $paramFetcher) {
417+
$deviceState = $paramFetcher->get('device_state');
418+
$internalAppIds = $paramFetcher->get('internal_app_ids');
419+
$deviceTypes = $paramFetcher->get('device_types');
420+
$startDate = $paramFetcher->get('start_date');
421+
$endDate = $paramFetcher->get('end_date');
422+
423+
if(is_null($startDate)) {
424+
$date = new \DateTime('NOW');
425+
$date->modify('-1 week');
426+
$startDate = $date;
427+
} else {
428+
$startDate = new \DateTime($startDate);
429+
}
430+
431+
if(is_null($endDate)) {
432+
$endDate = new \DateTime('NOW');
433+
}else {
434+
$endDate = new \DateTime($endDate);
435+
}
436+
437+
438+
$appEvents = $this->appEventManager->getAppEvents(array(AppEventInterface::APP_BACKGROUNDED), $deviceTypes, $internalAppIds, $deviceState, $startDate, $endDate);
439+
$appEventDayCounts = array();
440+
441+
/** @var $appEvent \DABSquared\PushNotificationsBundle\Model\AppEventInterface */
442+
foreach($appEvents as $appEvent) {
443+
$day = $appEvent->getCreatedAt()->format('Y-m-d');
444+
$appId = $appEvent->getDevice()->getAppId();
445+
446+
if(!isset($appEventDayCounts[$day])) {
447+
$appEventDayCounts[$day] = array();
448+
}
449+
450+
if(!isset($appEventDayCounts[$day][$appId])) {
451+
$appEventDayCounts[$day][$appId] = 0;
452+
}
453+
454+
$appEventDayCounts[$day][$appId] = $appEventDayCounts[$day][$appId] + 1;
455+
}
456+
457+
ksort($appEventDayCounts);
458+
459+
$appEventCounts = array();
460+
461+
foreach($appEventDayCounts as $key => $val) {
462+
$tempPointArray = array();
463+
$tempPointArray['day'] = $key;
464+
465+
foreach($appEventDayCounts[$key] as $key1 => $val1) {
466+
$tempPointArray[$key1] = $val1;
467+
}
468+
469+
$appEventCounts[] = $tempPointArray;
470+
}
471+
472+
return $appEventCounts;
473+
}
308474

309475

310476
}

README.md

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,51 +34,13 @@ This bundle is under the MIT license. See the complete license in the bundle:
3434

3535
Resources/meta/LICENSE
3636

37+
## Admin Web Interface
3738

38-
Configuration
39-
-------
40-
41-
Below you'll find all configuration options; just use what you need:
42-
43-
``` yaml
44-
dab_push_notifications:
45-
android:
46-
c2dm:
47-
username: <string_android_c2dm_username>
48-
password: <string_android_c2dm_password>
49-
source: <string_android_c2dm_source>
50-
gcm:
51-
api_key: <string_android_gcm_api_key>
52-
ios:
53-
certificates: #replace these certs with your own as well as app ids. The bundle will loop through all certs displayed here when sending a push based on the sandbox param. You can add as many certificates as you need. Also note that the bundle will send using certificates that match the internal_app_ids of the registered devices.
54-
dev_prem: { sandbox: true, pem: %kernel.root_dir%/../pushcerts/premium/dev/certificate.pem, passphrase: ~, internal_app_id: 0000001}
55-
dev_lite: { sandbox: true, pem: %kernel.root_dir%/../pushcerts/lite/dev/certificate.pem, passphrase: ~, internal_app_id: 0000002}
56-
prod_prem: { sandbox: false, pem: %kernel.root_dir%/../pushcerts/premium/prod/certificate.pem, passphrase: ~, internal_app_id: 0000001}
57-
prod_lite: { sandbox: false, pem: %kernel.root_dir%/../pushcerts/lite/prod/certificate.pem, passphrase: ~,internal_app_id: 0000002}
58-
blackberry:
59-
evaluation: <bool_bb_evaluation_mode>
60-
app_id: <string_bb_app_id>
61-
password: <string_bb_password>
62-
safari:
63-
pem: %kernel.root_dir%/../pushcerts/safari/safari_push.pem
64-
pk12: %kernel.root_dir%/../pushcerts/safari/Certificates.p12
65-
passphrase: ~
66-
website_push_id: web.com.demo
67-
icon16x16: %kernel.root_dir%/../pushcerts/safari/icon_16x16.png
68-
icon16x16@2x: %kernel.root_dir%/../pushcerts/safari/[email protected]
69-
icon32x32: %kernel.root_dir%/../pushcerts/safari/icon_32x32.png
70-
icon32x32@2x: %kernel.root_dir%/../pushcerts/safari/[email protected]
71-
icon128x128: %kernel.root_dir%/../pushcerts/safari/icon_128x128.png
72-
icon128x128@2x: %kernel.root_dir%/../pushcerts/safari/[email protected]
73-
websiteName: Demo Site
74-
allowedDomains: ["https://demo.com","https://www.demo.com"]
75-
urlFormatString: http://www.demo.com/%@
76-
webServiceURL: https://www.demo.com
77-
```
78-
79-
39+
![](Resources/doc/images/dashboard.png)
40+
![](Resources/doc/images/devices.png)
41+
![](Resources/doc/images/create_message.png)
8042

81-
## DABSquared New Usage
43+
## Sending Messages
8244

8345
Send to a User:
8446

32.7 KB
Loading

Resources/doc/images/dashboard.png

75.2 KB
Loading

Resources/doc/images/devices.png

103 KB
Loading

Resources/public/css/jquery-ui-1.10.4.custom.min.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.7 KB
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)