svg
This commit is contained in:
52
src/Command/RedmineCommand.php
Normal file
52
src/Command/RedmineCommand.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Entity\Project;
|
||||
use App\Service\RedmineService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'app:redmine',
|
||||
description: 'Refresh Redmine Project',
|
||||
)]
|
||||
class RedmineCommand extends Command
|
||||
{
|
||||
private EntityManagerInterface $em;
|
||||
private ParameterBagInterface $params;
|
||||
private RedmineService $redmineService;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, ParameterBagInterface $params, RedmineService $redmineService)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->params = $params;
|
||||
$this->redmineService = $redmineService;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->title('APP:REDMINE');
|
||||
$io->text('Refresh Redmine Project');
|
||||
$io->text('');
|
||||
|
||||
$projects = $this->em->getRepository(Project::class)->findAll();
|
||||
foreach ($projects as $project) {
|
||||
$io->text('> Project = '.$project->getTitle());
|
||||
$redmine = $this->redmineService->getProject($project->getId(), $this->params->get('redmineApikey'));
|
||||
$project->setRedmine($redmine);
|
||||
$this->em->flush();
|
||||
$this->redmineService->majProjectIssues($project, $this->params->get('redmineApikey'), true);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
@ -116,10 +116,10 @@ class IssueController extends AbstractController
|
||||
$issue = $issueRepository->find($rissue);
|
||||
if ($issue) {
|
||||
$issue->setRowissue($key);
|
||||
}
|
||||
}
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new JsonResponse([
|
||||
'message' => 'Ordre mis à jour',
|
||||
|
@ -5,6 +5,7 @@ namespace App\Controller;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\User;
|
||||
use App\Form\ProjectType;
|
||||
use App\Repository\IssueRepository;
|
||||
use App\Repository\ProjectRepository;
|
||||
use App\Service\RedmineService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -25,7 +26,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/user/project/{id}', name: 'app_project_view')]
|
||||
public function viewProject(int $id, ProjectRepository $projectRepository): Response
|
||||
public function viewProject(int $id, ProjectRepository $projectRepository, IssueRepository $issueRepository): Response
|
||||
{
|
||||
$project = $projectRepository->find($id);
|
||||
if (!$project) {
|
||||
@ -63,6 +64,7 @@ class ProjectController extends AbstractController
|
||||
'usemenu' => true,
|
||||
'usesidebar' => false,
|
||||
'project' => $project,
|
||||
'issues' => $issueRepository->findIssues($project),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,9 @@ class Issue
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?string $color = null;
|
||||
|
||||
#[ORM\Column(nullable: false)]
|
||||
private bool $isClosed = false;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Project::class, inversedBy: 'issues')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private Project $project;
|
||||
@ -130,9 +133,13 @@ class Issue
|
||||
|
||||
public function getColor(): ?string
|
||||
{
|
||||
if($this->color) return $this->color;
|
||||
elseif($this->parent) return $this->parent->getColor();
|
||||
else return null;
|
||||
if ($this->color) {
|
||||
return $this->color;
|
||||
} elseif ($this->parent) {
|
||||
return $this->parent->getColor();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function setColor(?string $color): static
|
||||
@ -142,6 +149,18 @@ class Issue
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isClosed(): bool
|
||||
{
|
||||
return $this->isClosed();
|
||||
}
|
||||
|
||||
public function setIsClosed(bool $isClosed): static
|
||||
{
|
||||
$this->isClosed = $isClosed;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProject(): Project
|
||||
{
|
||||
return $this->project;
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Issue;
|
||||
use App\Entity\Project;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
@ -16,28 +17,19 @@ class IssueRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Issue::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Issue[] Returns an array of Issue objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('c')
|
||||
// ->andWhere('c.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('c.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Issue
|
||||
// {
|
||||
// return $this->createQueryBuilder('c')
|
||||
// ->andWhere('c.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
public function findIssues(Project $project, bool $closed = false): array
|
||||
{
|
||||
$criteria = ['project' => $project];
|
||||
if (!$closed) {
|
||||
$criteria['isClosed'] = false;
|
||||
}
|
||||
|
||||
return $this->findBy($criteria, [
|
||||
'rowstatus' => 'ASC',
|
||||
'rowsprint' => 'DESC',
|
||||
'rowversion' => 'DESC',
|
||||
'rowissue' => 'ASC',
|
||||
'id' => 'DESC',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -186,6 +186,7 @@ class RedmineService
|
||||
}
|
||||
$issue->setRedmine($rissue);
|
||||
$issue->setProject($project);
|
||||
$issue->setIsClosed($rissue['status']['is_closed']);
|
||||
|
||||
// Calcul de la position du status
|
||||
$issueStatusId = $rissue['status']['id'];
|
||||
|
@ -316,7 +316,7 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for issue in project.issues %}
|
||||
{% for issue in issues %}
|
||||
<div class="issueCard {{issue.color}} card tracker{{issue.redmine.tracker.id}} category{{(issue.redmine.category is defined?issue.redmine.category.id:'0') }}" data-status='{{issue.redmine.status.id}}' data-sprint='{{issue.rowsprint}}' data-version='{{(issue.redmine.fixed_version is defined?issue.redmine.fixed_version.id:'')}}' data-id='{{issue.id}}'>
|
||||
<div class='issueHeader'>
|
||||
<div class='issueId'>#{{issue.id}}</div>
|
||||
@ -413,7 +413,7 @@
|
||||
$column.append($(this));
|
||||
}
|
||||
else {
|
||||
console.log ('no ='+id);
|
||||
console.log ('no ='+$(this).data('id'));
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
@ -511,7 +511,6 @@
|
||||
|
||||
url='{{path('app_issue_view',{id:'xxx'})}}';
|
||||
url=url.replace('xxx',issueId);
|
||||
console.log(url);
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
|
Reference in New Issue
Block a user