Skip to content

Commit

Permalink
Merge pull request #18 from Kunstmaan/bugfix/segment-issues
Browse files Browse the repository at this point in the history
Bugfix/segment issues
  • Loading branch information
Roderik van der Veer committed May 15, 2014
2 parents 61c48a8 + 0998b8a commit 5ace4e2
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Command/GoogleAnalyticsDataCollectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ public function updateData($overviews)

$this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->setUpdated($overview->getConfig()->getId());
} catch (\Google_ServiceException $e) {
$this->output->writeln("\t" . '<fg=red>Invalid segment</fg=red>');
$error = explode(')', $e->getMessage())[1];
$this->output->writeln("\t" . '<fg=red>Invalid segment: </fg=red>' .$error);
$this->errors += 1;
}
}
Expand Down
2 changes: 2 additions & 0 deletions Command/Helper/Analytics/GoalCommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ private function parseGoals(&$overview, $goalCollection)
$goals = $overview->getGoals();
$goals[] = $goal;

$this->em->persist($goal);

$this->output->writeln("\t\t" . 'Fetched goal ' . $goal->getPosition() . ': "' . $goal->getName() . '" @ ' . $totalVisits);
}
}
Expand Down
9 changes: 9 additions & 0 deletions Controller/GoogleAnalyticsAJAXController.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ public function saveConfigAction(Request $request) {
$em->persist($config);
$em->flush();

// set the config name
$configHelper = $this->container->get('kunstmaan_dashboard.helper.google.analytics.config');
$configHelper->init($config->getId());
$profile = $configHelper->getActiveProfile();
$config->setName($profile['profileName']);

$em->persist($config);
$em->flush();

$this->get('session')->getFlashBag()->add(
'success',
'Succesfully saved!'
Expand Down
2 changes: 2 additions & 0 deletions Controller/GoogleAnalyticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public function configAction(Request $request)
$config = $em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->findFirst();

$params['accountId'] = $config->getAccountId();
$params['propertyId'] = 0;
$params['profileId'] = 0;

if ($params['accountId']) {
$params['propertyId'] = $config->getPropertyId();
Expand Down
4 changes: 4 additions & 0 deletions Helper/Google/Analytics/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ public function getActiveProfile() {
$profiles = $this->getProfiles();
$profileId = $this->getProfileId();

if (!is_array($profiles)) {
throw new \Exception('<fg=red>The config is invalid</fg=red>');
}

foreach ($profiles as $profile) {
if ($profile['profileId'] == $profileId) {
return $profile;
Expand Down
1 change: 1 addition & 0 deletions Resources/public/js/analytics/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ $(function () {
$("#segment-menu select").chosen(
{'search_contains' : true}
);

$("#segment-menu select").change(function() {
var segmentId = $(this).find('option:selected').attr('data-segment-id');
var configId = $(this).find('option:selected').attr('data-config-id');
Expand Down
6 changes: 3 additions & 3 deletions Resources/public/js/setup/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$(function () {
var accountId = 0;
var propertyId = 0;
var profileId = 0;
var accountId = $('#account_id').attr('data-id');
var propertyId = $('#property_id').attr('data-id');
var profileId = $('#profile_id').attr('data-id');

$('#submit_save').click(function() {
// get the option data
Expand Down
2 changes: 1 addition & 1 deletion Resources/public/scss/_dashboard-tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@include clearfix;
margin: 40px 0 0;
list-style: none;
width: 50%;
width: 75%;
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
Expand Down
3 changes: 3 additions & 0 deletions Resources/views/GoogleAnalytics/setup.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
<input type="hidden" id="path_segment_delete" data-url="{{ path('kunstmaan_dashboard_ajax_segment_delete') }}" />
<input type="hidden" id="path_segment_edit" data-url="{{ path('kunstmaan_dashboard_ajax_segment_edit') }}" />
<input type="hidden" id="path_config_save" data-url="{{ path('kunstmaan_dashboard_ajax_config_save') }}" />
<input type="hidden" id="account_id" data-id="{{accountId}}" />
<input type="hidden" id="property_id" data-id="{{propertyId}}" />
<input type="hidden" id="profile_id" data-id="{{profileId}}" />
{% endblock %}

{% block extrajavascript %}
Expand Down
6 changes: 2 additions & 4 deletions Resources/views/GoogleAnalytics/widget.html.twig
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{% if token %}
<div class="dashboard">

{% if segments | length > 0 %}
<nav id="segment-menu">
<select>
<option>Choose a segment..</option>
<option data-segment-id="#" data-config-id="{% if configId is defined %}{{configId}}{% endif %}">
<option data-segment-id="#" data-config-id="{% if configId is defined %}{{configId}}{% endif %}" {% if segmentId is null %}selected{% endif %} >
Default
</option>
{% for segment in segments %}
<option data-segment-id="{{segment.id}}" data-config-id="{{segment.config.id}}">
<option data-segment-id="{{segment.id}}" data-config-id="{{segment.config.id}}" {% if segment.id == segmentId %}selected{% endif %} >
{{segment.name}}
</option>
{% endfor %}
Expand Down

0 comments on commit 5ace4e2

Please sign in to comment.