Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

Commit

Permalink
refactor sports panel to symfony world
Browse files Browse the repository at this point in the history
  • Loading branch information
laufhannes authored and mipapo committed May 15, 2017
1 parent a5cc995 commit 1943655
Show file tree
Hide file tree
Showing 17 changed files with 545 additions and 326 deletions.
36 changes: 36 additions & 0 deletions app/DoctrineMigrations/Version20170430165000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Runalyze\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Version20170430165000 extends AbstractMigration implements ContainerAwareInterface
{
/** @var ContainerInterface|null */
private $container;

public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}

/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$prefix = $this->container->getParameter('database_prefix');

$this->addSql('DELETE FROM `'.$prefix.'plugin_conf` WHERE `config`="show_as_table"');
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}
2 changes: 1 addition & 1 deletion app/Resources/views/_macro/utilities.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% macro boxedValue(value, unit, label, width, icon) %}
<div class="boxed-value-outer"{% if width %} style="width:{{ width }};"{% endif %}>
<div class="boxed-value-container{% if icon %} with-icon{% endif %}">
{% if icon %}<i class="fa fa-fw {{ icon }}"></i>{% endif %}
{% if 'icons8' == icon|slice(0, 6) %}<i class="{{ icon }}"></i>{% elseif icon %}<i class="fa fa-fw {{ icon }}"></i>{% endif %}
<div class="boxed-value">
{{ value|raw }}
<div class="boxed-value-unit">{{ unit|raw }}</div>
Expand Down
25 changes: 25 additions & 0 deletions app/Resources/views/my/panels/base.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

<div class="panel-heading">
<div class="panel-menu">
{% block panelHeadingMenu %}
{% endblock %}
</div>

<h1 class="link clap" rel="{{ pluginId }}">{% block pluginTitle %}{% endblock %}</h1>

<div class="hover-icons">
{% block panelHeadingIcons %}
{% spaceless %}
<a data-size="small" class="window" href="{{ url('plugin-config', {'id': pluginId}) }}"><i class="fa fa-fw fa-cog"></i></a>
<span class="link up" rel="{{ pluginId }}"><i class="fa fa-fw fa-arrow-up"></i></span>
<span class="link down" rel="{{ pluginId }}"><i class="fa fa-fw fa-arrow-down"></i></span>
<span class="link" onclick="Runalyze.reloadPlugin('{{ pluginId }}');"><i class="fa fa-fw fa-refresh"></i></span>
{% endspaceless %}
{% endblock %}
</div>
</div>

<div class="panel-content{% if panelContentNoPadding|default(false) %} nopadding{% endif %}">
{% block panelContent %}
{% endblock %}
</div>
47 changes: 47 additions & 0 deletions app/Resources/views/my/panels/sports/base.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends 'my/panels/base.html.twig' %}

{% from '_macro/utilities.html.twig' import boxedValue, boxedValueFor %}

{% set panelContentNoPadding = true %}

{% block pluginTitle %}
{{ 'Sports'|trans }}
{% endblock %}

{% block panelHeadingMenu %}
<ul>
<li class="with-submenu">
<span class="link">{{ 'Month'|trans }}</span>
<ul class="submenu">
<li><a class="change" target="sports" href="#sports_0">{{ 'Week'|trans }}</a></li>
<li class="triggered"><a class="triggered change" target="sports" href="#sports_1">{{ 'Month'|trans }}</a></li>
<li><a class="change" target="sports" href="#sports_2">{{ 'Year'|trans }}</a></li>
<li><a class="change" target="sports" href="#sports_3">{{ 'Total'|trans }}</a></li>
</ul>
</li>
</ul>
{% endblock %}

{% block panelContent %}
<div id="sports">
{% for stats in [weekStatistics, monthStatistics, yearStatistics, totalStatistics] %}
{# @var stats \Runalyze\Bundle\CoreBundle\Model\Sport\SportStatistics #}
<div id="sports_{{ loop.index0 }}" class="change"{% if loop.index0 != 1 %} style="display:none;"{% endif %}>
{% if stats.count %}
<div class="boxed-values at-bottom">
{% for stat in stats.statistics %}
{# @var stat \Runalyze\Bundle\CoreBundle\Model\Sport\SportStatistic #}
{% if stat.sport.distances and stat.areMostActivitiesWithDistance %}
{{ boxedValueFor(distance(stat.totalDistance), stat.sport.name, '50%', stat.sport.img) }}
{% else %}
{{ boxedValue(stat.totalDuration|duration, '', stat.sport.name, '50%', stat.sport.img) }}
{% endif %}
{% endfor %}
</div>
{% else %}
<div class="panel-content"><p><em>{{ 'No data available since %date%.'|trans({'%date%': stats.startDate.format('d.m.Y')}) }}</em></p></div>
{% endif %}
</div>
{% endfor %}
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</div>

<div id="panels">
<?php $Frontend->displayPanels(); ?>
<?php echo $panelsContent; ?>
</div>
</div>
<?php
Expand Down
13 changes: 0 additions & 13 deletions inc/class.Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,4 @@ public function displayFooter() {

Error::getInstance()->footer_sent = true;
}

/**
* Display panels
*/
public function displayPanels() {
$Factory = new PluginFactory();
$Panels = $Factory->enabledPanels();

foreach ($Panels as $key) {
$Panel = $Factory->newInstance($key);
$Panel->display();
}
}
}
12 changes: 0 additions & 12 deletions inc/tpl/tpl.adminFooter.php

This file was deleted.

36 changes: 0 additions & 36 deletions inc/tpl/tpl.adminHeader.php

This file was deleted.

Loading

0 comments on commit 1943655

Please sign in to comment.