Merge branch 'master' of bitbucket.org:skobkin/point-tools
This commit is contained in:
commit
4887516525
|
@ -18,6 +18,7 @@ class AppKernel extends Kernel
|
||||||
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
|
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
|
||||||
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
|
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
|
||||||
new Misd\GuzzleBundle\MisdGuzzleBundle(),
|
new Misd\GuzzleBundle\MisdGuzzleBundle(),
|
||||||
|
new Ob\HighchartsBundle\ObHighchartsBundle(),
|
||||||
new Skobkin\Bundle\PointToolsBundle\SkobkinPointToolsBundle(),
|
new Skobkin\Bundle\PointToolsBundle\SkobkinPointToolsBundle(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
"incenteev/composer-parameter-handler": "~2.0",
|
"incenteev/composer-parameter-handler": "~2.0",
|
||||||
"misd/guzzle-bundle": "~1.0",
|
"misd/guzzle-bundle": "~1.0",
|
||||||
"doctrine/migrations": "1.0.*@dev",
|
"doctrine/migrations": "1.0.*@dev",
|
||||||
"doctrine/doctrine-migrations-bundle": "2.1.*@dev"
|
"doctrine/doctrine-migrations-bundle": "2.1.*@dev",
|
||||||
|
"ob/highcharts-bundle": "^1.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"sensio/generator-bundle": "~2.3"
|
"sensio/generator-bundle": "~2.3"
|
||||||
|
|
172
composer.lock
generated
172
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "6f8a78a0b471fceb335f2e83e43985ef",
|
"hash": "bfe197a5b9e16d562aba89cb97f380bf",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "doctrine/annotations",
|
"name": "doctrine/annotations",
|
||||||
|
@ -519,7 +519,7 @@
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/1e8cd4415bd2f893eb828216b529a75e8b61d579",
|
"url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/861d3564c03b3867845ffd87d9b19f49dc673c69",
|
||||||
"reference": "1e8cd4415bd2f893eb828216b529a75e8b61d579",
|
"reference": "1e8cd4415bd2f893eb828216b529a75e8b61d579",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
|
@ -698,7 +698,7 @@
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/doctrine/migrations/zipball/abb87d84ed21fd30c27bd3b52252a495a36d32fb",
|
"url": "https://api.github.com/repos/doctrine/migrations/zipball/43619782df4e9ae6be6b24557f0429471eeee848",
|
||||||
"reference": "abb87d84ed21fd30c27bd3b52252a495a36d32fb",
|
"reference": "abb87d84ed21fd30c27bd3b52252a495a36d32fb",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
|
@ -1242,6 +1242,61 @@
|
||||||
],
|
],
|
||||||
"time": "2015-03-09 09:58:04"
|
"time": "2015-03-09 09:58:04"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ob/highcharts-bundle",
|
||||||
|
"version": "1.2",
|
||||||
|
"target-dir": "Ob/HighchartsBundle",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/marcaube/ObHighchartsBundle.git",
|
||||||
|
"reference": "cce67aa209f2a8b14db520c8e50a15cd5f5c23d0"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/marcaube/ObHighchartsBundle/zipball/cce67aa209f2a8b14db520c8e50a15cd5f5c23d0",
|
||||||
|
"reference": "cce67aa209f2a8b14db520c8e50a15cd5f5c23d0",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0",
|
||||||
|
"symfony/symfony": "~2.3",
|
||||||
|
"zendframework/zend-json": "2.3.0"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.2.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Ob\\HighchartsBundle": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Marc Aubé"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony2 Bundle that ease the use of highcharts to display rich graph and charts in your app",
|
||||||
|
"homepage": "https://github.com/marcaube/ObHighchartsBundle",
|
||||||
|
"keywords": [
|
||||||
|
"Symfony2",
|
||||||
|
"chart",
|
||||||
|
"charting",
|
||||||
|
"charts",
|
||||||
|
"graph",
|
||||||
|
"graphs",
|
||||||
|
"highcharts",
|
||||||
|
"marcaube",
|
||||||
|
"ob"
|
||||||
|
],
|
||||||
|
"time": "2014-08-04 23:56:54"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/log",
|
"name": "psr/log",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
@ -1683,7 +1738,7 @@
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/symfony/zipball/7493c2bef54fb818c5304bdd9d2194890b839422",
|
"url": "https://api.github.com/repos/symfony/symfony/zipball/a0af4ef1bfe8788288a2e5f95635134cba3ea842",
|
||||||
"reference": "7493c2bef54fb818c5304bdd9d2194890b839422",
|
"reference": "7493c2bef54fb818c5304bdd9d2194890b839422",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
|
@ -1903,6 +1958,115 @@
|
||||||
"templating"
|
"templating"
|
||||||
],
|
],
|
||||||
"time": "2015-04-19 08:30:27"
|
"time": "2015-04-19 08:30:27"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "zendframework/zend-json",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/zendframework/zend-json.git",
|
||||||
|
"reference": "cf8e594a8a6516d06c25a3dc07e3be462fbea84d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/zendframework/zend-json/zipball/cf8e594a8a6516d06c25a3dc07e3be462fbea84d",
|
||||||
|
"reference": "cf8e594a8a6516d06c25a3dc07e3be462fbea84d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.23",
|
||||||
|
"zendframework/zend-stdlib": "self.version"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fabpot/php-cs-fixer": "1.7.*",
|
||||||
|
"phpunit/phpunit": "~4.0",
|
||||||
|
"satooshi/php-coveralls": "dev-master",
|
||||||
|
"zendframework/zend-http": "self.version",
|
||||||
|
"zendframework/zend-server": "self.version"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"zendframework/zend-http": "Zend\\Http component",
|
||||||
|
"zendframework/zend-server": "Zend\\Server component",
|
||||||
|
"zendframework/zendxml": "To support Zend\\Json\\Json::fromXml() usage"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.2-dev",
|
||||||
|
"dev-develop": "2.3-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Zend\\Json\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP",
|
||||||
|
"homepage": "https://github.com/zendframework/zend-json",
|
||||||
|
"keywords": [
|
||||||
|
"json",
|
||||||
|
"zf2"
|
||||||
|
],
|
||||||
|
"time": "2014-03-12 16:10:15"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "zendframework/zend-stdlib",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/zendframework/zend-stdlib.git",
|
||||||
|
"reference": "426b5396e89e7da2db9678bc9a0b57865f84fe0f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/426b5396e89e7da2db9678bc9a0b57865f84fe0f",
|
||||||
|
"reference": "426b5396e89e7da2db9678bc9a0b57865f84fe0f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.23"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fabpot/php-cs-fixer": "1.7.*",
|
||||||
|
"phpunit/phpunit": "~4.0",
|
||||||
|
"satooshi/php-coveralls": "dev-master",
|
||||||
|
"zendframework/zend-eventmanager": "self.version",
|
||||||
|
"zendframework/zend-filter": "self.version",
|
||||||
|
"zendframework/zend-serializer": "self.version",
|
||||||
|
"zendframework/zend-servicemanager": "self.version"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"zendframework/zend-eventmanager": "To support aggregate hydrator usage",
|
||||||
|
"zendframework/zend-filter": "To support naming strategy hydrator usage",
|
||||||
|
"zendframework/zend-serializer": "Zend\\Serializer component",
|
||||||
|
"zendframework/zend-servicemanager": "To support hydrator plugin manager usage"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.2-dev",
|
||||||
|
"dev-develop": "2.3-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Zend\\Stdlib\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/zendframework/zend-stdlib",
|
||||||
|
"keywords": [
|
||||||
|
"stdlib",
|
||||||
|
"zf2"
|
||||||
|
],
|
||||||
|
"time": "2014-03-12 16:10:15"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
namespace Skobkin\Bundle\PointToolsBundle\Controller;
|
namespace Skobkin\Bundle\PointToolsBundle\Controller;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Skobkin\Bundle\PointToolsBundle\Entity\TopUserDTO;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Service\UserApi;
|
use Skobkin\Bundle\PointToolsBundle\Service\UserApi;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Ob\HighchartsBundle\Highcharts\Highchart;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
|
@ -37,8 +39,13 @@ class UserController extends Controller
|
||||||
|
|
||||||
public function topAction()
|
public function topAction()
|
||||||
{
|
{
|
||||||
|
$topUsers = $this->getDoctrine()->getManager()->getRepository('SkobkinPointToolsBundle:User')->getTopUsers();
|
||||||
|
|
||||||
|
$topChart = $this->createTopUsersGraph($topUsers);
|
||||||
|
|
||||||
return $this->render('@SkobkinPointTools/User/top.html.twig', [
|
return $this->render('@SkobkinPointTools/User/top.html.twig', [
|
||||||
'top_users' => $this->getDoctrine()->getManager()->getRepository('SkobkinPointToolsBundle:User')->getTopUsers(),
|
'top_users' => $topUsers,
|
||||||
|
'top_chart' => $topChart,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,4 +61,47 @@ class UserController extends Controller
|
||||||
}
|
}
|
||||||
return $this->redirectToRoute('user_show', ['login' => $login]);
|
return $this->redirectToRoute('user_show', ['login' => $login]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TopUserDTO[] $topUsers
|
||||||
|
* @return Highchart
|
||||||
|
*/
|
||||||
|
private function createTopUsersGraph(array $topUsers = [])
|
||||||
|
{
|
||||||
|
$translator = $this->container->get('translator');
|
||||||
|
|
||||||
|
$chartData = [
|
||||||
|
'titles' => [],
|
||||||
|
'subscribers' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Preparing chart data
|
||||||
|
foreach ($topUsers as $user) {
|
||||||
|
$chartData['titles'][] = $user->login;
|
||||||
|
$chartData['subscribers'][] = $user->subscribersCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chart
|
||||||
|
$series = [[
|
||||||
|
'name' => $translator->trans('Subscribers'),
|
||||||
|
'data' => $chartData['subscribers'],
|
||||||
|
]];
|
||||||
|
|
||||||
|
// Initializing chart
|
||||||
|
$ob = new Highchart();
|
||||||
|
$ob->chart->renderTo('top-chart');
|
||||||
|
$ob->chart->type('bar');
|
||||||
|
$ob->title->text($translator->trans('Top users'));
|
||||||
|
$ob->xAxis->title(['text' => null]);
|
||||||
|
$ob->xAxis->categories($chartData['titles']);
|
||||||
|
$ob->yAxis->title(['text' => $translator->trans('amount')]);
|
||||||
|
$ob->plotOptions->bar([
|
||||||
|
'dataLabels' => [
|
||||||
|
'enabled' => true
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$ob->series($series);
|
||||||
|
|
||||||
|
return $ob;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,3 +34,4 @@ No log data found: Лог отсутствует
|
||||||
# Топ пользователей
|
# Топ пользователей
|
||||||
Top users: Популярные пользователи
|
Top users: Популярные пользователи
|
||||||
Subscribers count: Подписчиков
|
Subscribers count: Подписчиков
|
||||||
|
amount: Количество
|
|
@ -2,25 +2,17 @@
|
||||||
|
|
||||||
{% block header_title %}Top @ Point Tools{% endblock %}
|
{% block header_title %}Top @ Point Tools{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block head_js %}
|
||||||
<h1>{{ 'Top users'|trans }}</h1>
|
{{ parent() }}
|
||||||
|
<script src="//yastatic.net/jquery/2.1.4/jquery.min.js"></script>
|
||||||
<table class="table table-striped">
|
<script src="//code.highcharts.com/4.0.1/highcharts.js"></script>
|
||||||
<thead>
|
<script src="//code.highcharts.com/4.0.1/modules/exporting.js"></script>
|
||||||
<tr>
|
{% endblock %}
|
||||||
<td>#</td>
|
|
||||||
<td>{{ 'User'|trans }}</td>
|
{% block content %}
|
||||||
<td>{{ 'Subscribers count'|trans }}</td>
|
<script type="text/javascript">
|
||||||
</tr>
|
{{ chart(top_chart) }}
|
||||||
</thead>
|
</script>
|
||||||
<tbody>
|
|
||||||
{% for user in top_users %}
|
<div id="top-chart" style="min-width: 400px; height: 600px; margin: 0 auto;"></div>
|
||||||
<tr>
|
|
||||||
<td>{{ loop.index }}</td>
|
|
||||||
<td><a href="{{ url('user_show', {login: user.login}) }}">@{{ user.login }}</a></td>
|
|
||||||
<td>{{ user.subscribersCount }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue