Commit 9138bfe3 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Modification des Logs affichés (Ajout des liens Projet)

 - Intégration du module d'affichage des Logs dans la fiche Projet
 - Fix : Affiche des personnes en double dans la gestion des rôles des personnes en mode édition
 - Compilation JS
parent 12251645
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan
            $error = "Le moteur de recherche est introuvable";
        } catch (\Exception $exception) {
            $this->getLoggerService()->error($exception->getMessage());
            return $this->jsonError("Quelquechose c'est mal passé...");
            return $this->jsonError("Quelquechose c'est mal passé... : " . $exception->getMessage());
        }

        if ($this->getRequest()->isXmlHttpRequest() || $this->params()->fromQuery('f') === 'json') {
+24 −3
Original line number Diff line number Diff line
@@ -199,7 +199,29 @@ class ProjectController extends AbstractOscarController
            $entity = $this->getProjectService()->getProject($id, true);
            $this->getOscarUserContextService()->check(Privileges::PROJECT_SHOW, $entity);

            if ($this->getRequest()->isXmlHttpRequest()) {
            $format = $this->params()->fromQuery('f', null);
            if ($this->getRequest()->isXmlHttpRequest() || $format === 'json') {
                $perimeter = $this->params()->fromQuery('p', null);
                if( $perimeter ){
                    if( $perimeter == 'logs' ){
                        $this->getOscarUserContextService()->check(Privileges::MAINTENANCE_MENU_ADMIN);
                        try {
                            $datas = $this->getProjectService()->api(
                                $entity->getId(),
                                $this->url(),
                                $this->getOscarUserContextService(),
                                'logs'
                            );
                            return $this->jsonOutput($datas);
                        } catch (\Exception $e) {
                            return $this->jsonError($e->getMessage());
                        }
                    } else {
                        throw new OscarException("Périmètre inconnu");
                    }
                }


                return $this->htmlProjectDetail($entity);
            }

@@ -235,8 +257,7 @@ class ProjectController extends AbstractOscarController
                'documents'          => $documents,
                'rolesOrganizations' => $rolesOrganizations,
                'rolesPersons'       => $rolesPersons,
                'logs'               => $this->getActivityLogService()->projectActivities($entity->getId())->getQuery(
                )->getResult()
                'logs_url'           => $this->url()->fromRoute('project/show', ['id' => $entity->getId()]).'?f=json&p=logs'
            );
        } catch (UnAuthorizedException $e) {
            throw $e;
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ use Doctrine\ORM\Mapping as ORM;

/**
 * Class Project
 * @ORM\Entity(repositoryClass="ActivityLogRepository")
 * @ORM\Entity(repositoryClass="LogActivityRepository")
 */
class LogActivity
{
+21 −0
Original line number Diff line number Diff line
@@ -13,5 +13,26 @@ use Doctrine\ORM\EntityRepository;

class LogActivityRepository extends EntityRepository
{
    public function getLogsProject(int $projectId):array {
        // ID des activités du projet
        $idsActivity = array_map('current', $this->getEntityManager()->createQueryBuilder()
            ->select('a.id')
            ->from(Activity::class, 'a')
            ->where('a.project = :project')
            ->setParameter('project', $projectId)
            ->getQuery()
            ->getResult());

        $qb = $this->getEntityManager()->createQueryBuilder()
            ->select('a')
            ->from(LogActivity::class, 'a')
            ->where('a.type NOT IN(\'debug\')')
            ->andWhere("(a.contextId = :id AND a.context LIKE 'Project%') OR (a.contextId IN(:ids) AND a.context LIKE 'Activity%')")
            ->orderBy('a.dateCreated', 'DESC')
            ->setParameters([
                                'ids' => $idsActivity,
                                'id' => $projectId,
                            ]);
        return $qb->getQuery()->getArrayResult();
    }
}
 No newline at end of file
+30 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ use Oscar\Entity\Activity;
use Oscar\Entity\ActivityOrganization;
use Oscar\Entity\ActivityPerson;
use Oscar\Entity\ContractDocument;
use Oscar\Entity\LogActivity;
use Oscar\Entity\Organization;
use Oscar\Entity\OrganizationRole;
use Oscar\Entity\Person;
@@ -102,7 +103,36 @@ class ProjectService implements UseServiceContainer
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public function api(
        int $projectId,
        ?Url $urlPlugin = null,
        ?OscarUserContext $oscarUserContext = null,
        ?string $perimeters = null
    ){

        $output = [];
        try {
            $project = $this->getProjectRepository()->find($projectId);

        } catch (\Exception $exception) {
            throw new OscarException($exception->getMessage());
        }


        if( $perimeters === 'logs' ){
            $output = $this->getEntityManager()->getRepository(LogActivity::class)->getLogsProject($project->getId());
        }

        $out = [
            'date'        => date('Y-m-d H:i:s'),
            'error'       => null,
            'warnings'    => null,
            'perimeter'   => $perimeters,
            'credentials' => null,
            'traces'       => $output
        ];
        return $out;
    }
    public function fixMovePartnersToActivities(
        Project $project,
        $flush =
Loading