Skip to content

Commit

Permalink
updated main admin
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorTkachenko81 committed Jan 16, 2016
1 parent 6d33725 commit 82247e2
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 33 deletions.
16 changes: 15 additions & 1 deletion src/AppBundle/Controller/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,21 @@ class AdminController extends Controller
*/
public function indexAction()
{
return [];
$em = $this->getDoctrine()->getManager();
$countArticles = $em->getRepository("AppBundle:Article")
->getCountArticles();

$countComments = $em->getRepository("AppBundle:Comment")
->getCountComments();

$countUsers = $em->getRepository("AppBundle:User")
->getCountUsers();

return [
'countArticles' => $countArticles['countArticles'],
'countComments' => $countComments['countComments'],
'countUsers' => $countUsers['countUsers'],
];
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/AppBundle/Repository/ArticleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,12 @@ public function getRecentArticles($max = 5)
->getQuery()
->getResult();
}

public function getCountArticles()
{
return $this->createQueryBuilder('a')
->select('count(a.id) as countArticles')
->getQuery()
->getSingleResult();
}
}
8 changes: 8 additions & 0 deletions src/AppBundle/Repository/CommentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ public function getArticleComment($slug, $page = 1, $max = 5)

return new PaginatorWithPages($query, $fetchJoinCollection = true);
}

public function getCountComments()
{
return $this->createQueryBuilder('c')
->select('count(c.id) as countComments')
->getQuery()
->getSingleResult();
}
}
10 changes: 9 additions & 1 deletion src/AppBundle/Repository/UserRepository.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<?php

namespace AppBundle\Repository;
use Doctrine\ORM\EntityRepository;

/**
* UserRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class UserRepository extends \Doctrine\ORM\EntityRepository
class UserRepository extends EntityRepository
{
public function getCountUsers()
{
return $this->createQueryBuilder('u')
->select('count(u.id) as countUsers')
->getQuery()
->getSingleResult();
}
}
2 changes: 1 addition & 1 deletion src/AppBundle/Resources/views/admin/articles.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<th>Comments</th>
<th>Created</th>
<th>Edit</th>
<th>Remove</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
Expand Down
39 changes: 10 additions & 29 deletions src/AppBundle/Resources/views/admin/main.html.twig
Original file line number Diff line number Diff line change
@@ -1,49 +1,30 @@
{% extends 'AppBundle:admin:admin.html.twig' %}

{% block content %}
<div class="row">
<div class="col-sm-4 text-center">
<div class="number-info info-big vertical">
<p>153<span>PROJECTS</span></p>
</div>
</div>
<div class="col-sm-4 text-center">
<div class="number-info info-big vertical">
<p>#1<span>TOP PROVIDER</span></p>
</div>
</div>
<div class="col-sm-4 text-center">
<div class="number-info info-big vertical">
<p>132<span>CLIENTS</span></p>
</div>
</div>
</div>


<h2 class="section-heading">Charts</h2>
<h2 class="section-heading">Statistic</h2>
<div class="row">
<div class="col-md-4">
<div class="info-chart">
<div class="pie-chart" data-percent="92">
<span class="percent">92%</span>
<div class="pie-chart" data-percent="100">
<span class="percent">{{ countArticles }}</span>
<canvas height="180" width="180"></canvas></div>
<span class="chart-title">Web Design</span>
<span class="chart-title">ARTICLES</span>
</div>
</div>
<div class="col-md-4">
<div class="info-chart">
<div class="pie-chart" data-percent="85">
<span class="percent">85%</span>
<div class="pie-chart" data-percent="100">
<span class="percent">{{ countComments }}</span>
<canvas height="180" width="180"></canvas></div>
<span class="chart-title">WordPress</span>
<span class="chart-title">COMMENTS</span>
</div>
</div>
<div class="col-md-4">
<div class="info-chart">
<div class="pie-chart" data-percent="78">
<span class="percent">78%</span>
<div class="pie-chart" data-percent="100">
<span class="percent">{{ countUsers }}</span>
<canvas height="180" width="180"></canvas></div>
<span class="chart-title">PHP</span>
<span class="chart-title">USERS</span>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/AppBundle/Resources/views/admin/roles.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<th>#</th>
<th>Name</th>
<th>Edit</th>
<th style="width: 30px; text-align: center;">Remove</th>
<th style="width: 30px; text-align: center;">Delete</th>
</tr>
</thead>
<tbody>
Expand Down

0 comments on commit 82247e2

Please sign in to comment.