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

Commit aab7808

Browse files
committed
Changing how we use jquery to select the options
1 parent 95c69b2 commit aab7808

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

Controller/PushAdminController.php

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,9 @@ public function pushMessagesAction() {
258258
* description="Gets the data to be converted for the graph",
259259
* section="DABSquared Push Notifications (Dashboard Data)"
260260
* )
261-
*
261+
* @Rest\View()
262262
* @Route("push/data/app_open_graph", defaults={"_format": "json"}, name="dabsquared_push_notifications_data_app_open_graph")
263263
* @Method("POST")
264-
* @Rest\View(serializerGroups={"app_event"})
265264
* @RequestParam(name="device_state", description="What device state to grab", strict=true)
266265
* @RequestParam(name="internal_app_ids", description="The vendor device identifier of the Android device.", strict=true, array=true)
267266
*/
@@ -270,10 +269,40 @@ public function getAppOpenGraphDataAction(ParamFetcher $paramFetcher) {
270269
$internalAppIds = $paramFetcher->get('internal_app_ids');
271270

272271
$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'));
272+
$appEventDayCounts = array();
273273

274+
/** @var $appEvent \DABSquared\PushNotificationsBundle\Model\AppEventInterface */
275+
foreach($appEvents as $appEvent) {
276+
$day = $appEvent->getCreatedAt()->format('Y-m-d');
277+
$appId = $appEvent->getDevice()->getAppId();
274278

279+
if(!isset($appEventDayCounts[$day])) {
280+
$appEventDayCounts[$day] = array();
281+
}
282+
283+
if(!isset($appEventDayCounts[$day][$appId])) {
284+
$appEventDayCounts[$day][$appId] = 0;
285+
}
286+
287+
$appEventDayCounts[$day][$appId] = $appEventDayCounts[$day][$appId] + 1;
288+
}
289+
290+
ksort($appEventDayCounts);
291+
292+
$appEventCounts = array();
293+
294+
foreach($appEventDayCounts as $key => $val) {
295+
$tempPointArray = array();
296+
$tempPointArray['day'] = $key;
297+
298+
foreach($appEventDayCounts[$key] as $key1 => $val1) {
299+
$tempPointArray[$key1] = $val1;
300+
}
301+
302+
$appEventCounts[] = $tempPointArray;
303+
}
275304

276-
return $appEvents;
305+
return $appEventCounts;
277306
}
278307

279308

Resources/doc/2-mapping_orm.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ namespace MyProject\MyBundle\Entity;
199199
use Doctrine\ORM\Mapping as ORM;
200200
use Symfony\Component\Validator\Constraints as Assert;
201201
use DABSquared\PushNotificationsBundle\Entity\AppEvent as BaseAppEvent;
202-
use JMS\Serializer\Annotation as Serializer;
203202

204203
/**
205204
* @ORM\Entity
@@ -210,7 +209,6 @@ class AppEvent extends BaseAppEvent {
210209

211210
/**
212211
* @ORM\ManyToOne(targetEntity="MyProject\MyBundle\Entity\Device", inversedBy="appEvents")
213-
* @Serializer\Groups({"app_event"})
214212
*/
215213
protected $device;
216214

Resources/views/Dashboard/dashboard.html.twig

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,21 @@
4343
});
4444
4545
function loadGraphData() {
46+
var deviceState = $("input:radio[name=device_state]:checked").val();
47+
var internal_app_ids = Array();
48+
49+
$('input[name="internal_app_ids"]:checked').each(function() {
50+
internal_app_ids.push(this.value);
51+
});
52+
4653
$.ajax ({
47-
url: "{{ path('dabsquared_push_notifications_data_app_open_graph')}}",
54+
url: "{{ create_proper_route('dabsquared_push_notifications_data_app_open_graph')}}",
4855
type: "POST",
49-
data: JSON.stringify({internal_app_ids: ["0000001"], device_state: 0 }),
56+
data: JSON.stringify({internal_app_ids: internal_app_ids, device_state: deviceState }),
5057
dataType: "json",
5158
contentType: "application/json; charset=utf-8",
5259
success: function(data){
60+
window.graph.setData(data);
5361
}
5462
});
5563
@@ -67,17 +75,11 @@
6775
element: 'appOpensChart',
6876
// Chart data records -- each entry in this array corresponds to a point on
6977
// the chart.
70-
data: [
71-
{ day: '2008', value: 20 },
72-
{ day: '2009', value: 10 },
73-
{ day: '2010', value: 5 },
74-
{ day: '2011', value: 5 },
75-
{ day: '2012', value: 20 }
76-
],
78+
data: [],
7779
// The name of the data record attribute that contains x-values.
7880
xkey: 'day',
7981
// A list of names of data record attributes that contain y-values.
80-
ykeys: ['value'],
82+
ykeys: [{% for app in apps %} '{{ app.internal_app_id }}', {% endfor %}],
8183
// Labels for the ykeys -- will be displayed when you hover over the
8284
// chart.
8385
labels: yLabels

0 commit comments

Comments
 (0)