From 2df92a3b7fc96c79905ac9d673542564d23d5fe1 Mon Sep 17 00:00:00 2001 From: afornerot Date: Wed, 21 Feb 2024 20:58:38 +0100 Subject: [PATCH] detail issue --- composer.json | 8 +- config/routes.yaml | 4 + src/Controller/ScrumController.php | 192 +---------------------- src/Controller/ScrumissueController.php | 63 ++++++++ templates/Report/list.html.twig | 4 +- templates/Scrum/issue.html.twig | 196 ++++++++++++++++++++++++ templates/Scrum/view.html.twig | 28 +++- 7 files changed, 297 insertions(+), 198 deletions(-) create mode 100644 templates/Scrum/issue.html.twig diff --git a/composer.json b/composer.json index 4f54326..9030b36 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "symfony/web-link": "5.1.*", "symfony/webpack-encore-bundle": "^1.7", "symfony/yaml": "5.1.*", - "tetranz/select2entity-bundle": "^3.0" + "tetranz/select2entity-bundle": "^3.0", }, "require-dev": { "symfony/debug-pack": "*", @@ -53,7 +53,11 @@ "preferred-install": { "*": "dist" }, - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "ocramius/package-versions": true, + "symfony/flex": true + } }, "autoload": { "psr-4": { diff --git a/config/routes.yaml b/config/routes.yaml index 14491a3..ac6b046 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -341,3 +341,7 @@ app_scrumissue_update: app_scrumissue_ctrlchange: path: /user/scrumissue/ctrlchange defaults: { _controller: App\Controller\ScrumissueController:ctrlchange } + +app_scrumissue_view: + path: /user/scrumissue/view/{id} + defaults: { _controller: App\Controller\ScrumissueController:view } diff --git a/src/Controller/ScrumController.php b/src/Controller/ScrumController.php index 3fdeb30..1cb7f33 100755 --- a/src/Controller/ScrumController.php +++ b/src/Controller/ScrumController.php @@ -216,7 +216,7 @@ class ScrumController extends AbstractController // Idgiteas $gicol=$issue->getScrumcolumn()->getGiteaid(); - $gijal=$issue->getGiteaMilestone(); + $gijal=($issue->getGiteaMilestone()?$issue->getGiteaMilestone():-100); // Liste des colonnes/jalons/sprint avec des issues if(!in_array($idcol,$tbcols)) array_push($tbcols,$idcol); @@ -719,196 +719,6 @@ class ScrumController extends AbstractController return new JsonResponse($output); } - - private function consolidateScrum($scrum,$giteamilestones,&$tbissues,&$tbestim) { - $em = $this->getDoctrine()->getManager(); - $issues=$scrum->getScrumissues(); - - $tbissues=[]; - $tbestim=[]; - - $tbcols=[]; - $tbjals=[]; - $tbsprs=[]; - - - $viewclosed = $this->get('session')->get("viewclosed"); - foreach($issues as $issue) { - // bypass closed - if($viewclosed=="false"&&$issue->getGiteastate()=="closed") continue; - - // Ids - $idcol=$issue->getScrumcolumn()->getId(); - $idjal=($issue->getGiteamilestone()?$issue->getGiteamilestone():-100); - $idspr=($issue->getScrumsprint()?$issue->getScrumsprint()->getId():-100); - - // Roworders - $rowcol=$issue->getScrumcolumn()->getRowid(); - $rowjal=($issue->getGiteaMilestonename()?$issue->getGiteaMilestonename():-100); - $rowspr=($issue->getScrumsprint()?$issue->getScrumsprint()->getRowid():-100); - - // Names - $nmcol=$issue->getScrumcolumn()->getName(); - $nmjal=($issue->getGiteaMilestonename()?$issue->getGiteaMilestonename():"Aucun"); - $nmspr=($issue->getScrumsprint()?$issue->getScrumsprint()->getName():"Aucun"); - - // Idgiteas - $gicol=$issue->getScrumcolumn()->getGiteaid(); - $gijal=$issue->getGiteaMilestone(); - - // Liste des colonnes/jalons/sprint avec des issues - if(!in_array($idcol,$tbcols)) array_push($tbcols,$idcol); - if(!in_array($idcol."|".$idjal,$tbjals)) array_push($tbjals,$idcol."|".$idjal); - if(!in_array($idcol."|".$idjal."|".$idspr,$tbsprs)) array_push($tbsprs,$idcol."|".$idjal."|".$idspr); - - // Initialisation du tableau des estimations - if(!array_key_exists($idjal,$tbestim)) { - $tbestim[$idjal] = [ - "rowjal" => $rowjal, - "idjal" => $idjal, - "nmjal" => $nmjal, - "gijal" => $gijal, - "nbjrs" => 0, - "sprints" => [] - ]; - } - - if(!array_key_exists($idspr,$tbestim[$idjal]["sprints"])) { - $tbestim[$idjal]["sprints"][$idspr] = [ - "rowspr" => $rowspr, - "idspr" => $idspr, - "nmspr" => $nmspr, - "nbjrs" => 0, - ]; - } - - // Initialisation du tableau des colonnes - if(!array_key_exists($idcol,$tbissues)) { - $tbissues[$idcol]=[ - "rowcol" => $rowcol, - "idcol" => $idcol, - "nmcol" => $nmcol, - "gicol" => $gicol, - "nbjrs" => 0, - "jalons" => [], - ]; - } - - // Initialisation du tableau des jalons de la colonne encours - if(!array_key_exists($idjal,$tbissues[$idcol]["jalons"])) { - $tbissues[$idcol]["jalons"][$idjal] = [ - "rowjal" => $rowjal, - "idjal" => $idjal, - "nmjal" => $nmjal, - "gijal" => $gijal, - "nbjrs" => 0, - "sprints" => [], - ]; - } - - // Initialisation du tableau des sprint de la colonne/jalon encours - if(!array_key_exists($idspr,$tbissues[$idcol]["jalons"][$idjal]["sprints"])) { - $tbissues[$idcol]["jalons"][$idjal]["sprints"][$idspr] = [ - "rowspr" => $rowspr, - "idspr" => $idspr, - "nmspr" => $nmspr, - "nbjrs" => 0, - "issues" => [], - ]; - } - - // On cumule les estimations - $tbissues[$idcol]["nbjrs"]+=$issue->getWeight(); - $tbissues[$idcol]["jalons"][$idjal]["nbjrs"]+=$issue->getWeight(); - $tbissues[$idcol]["jalons"][$idjal]["sprints"][$idspr]["nbjrs"]+=$issue->getWeight(); - $tbestim[$idjal]["nbjrs"]+=$issue->getWeight(); - $tbestim[$idjal]["sprints"][$idspr]["nbjrs"]+=$issue->getWeight(); - - // On sauvegarde l'issue - array_push($tbissues[$idcol]["jalons"][$idjal]["sprints"][$idspr]["issues"],$issue); - } - - // On ajoute les colonnes sans issues - $columns=$scrum->getScrumcolumns(); - foreach($columns as $column) { - if(!in_array($column->getId(),$tbcols)) { - $tbissues[$column->getId()] = [ - "rowcol" => $column->getRowid(), - "idcol" => $column->getId(), - "nmcol" => $column->getName(), - "gicol" => $column->getGiteaid(), - "nbjrs" => 0, - "jalons" => [], - ]; - } - - // On ajoute les jalons sans issues - foreach($giteamilestones as $milestone) { - if(!in_array($column->getId()."|".$milestone->id,$tbjals)) { - $tbissues[$column->getId()]["jalons"][$milestone->id] = [ - "rowjal" => $milestone->title, - "idjal" => $milestone->id, - "nmjal" => $milestone->title, - "gijal" => $milestone->id, - "nbjrs" => 0, - "sprints" => [], - ]; - } - } - - // On ajoute le jalon aucun si sans issue - if(!in_array($column->getId()."|-100",$tbjals)) { - $tbissues[$column->getId()]["jalons"][-100] = [ - "rowjal" => -100, - "idjal" => -100, - "nmjal" => "Aucun", - "gijal" => null, - "nbjrs" => 0, - "sprints" => [], - ]; - } - - // On ajoutes les sprints sans issues - foreach($tbissues[$column->getId()]["jalons"] as $jalon) { - $sprints=$em->getRepository("App:Scrumsprint")->findBy(["scrum"=>$scrum,"giteamilestone"=>$jalon["idjal"]]); - foreach($sprints as $sprint) { - if(!in_array($column->getId()."|".$jalon["idjal"]."|".$sprint->getId(),$tbsprs)) { - $tbissues[$column->getId()]["jalons"][$jalon["idjal"]]["sprints"][$sprint->getId()] = [ - "rowspr" => $sprint->getRowid(), - "idspr" => $sprint->getId(), - "nmspr" => $sprint->getName(), - "nbjrs" => 0, - "issues" => [], - ]; - } - } - - // On ajoute les sprint aucun sans issue - if(!in_array($column->getId()."|".$jalon["idjal"]."|-100",$tbsprs)) { - $tbissues[$column->getId()]["jalons"][$jalon["idjal"]]["sprints"][-100] = [ - "rowspr" => -100, - "idspr" => -100, - "nmspr" => "Aucun", - "nbjrs" => 0, - "issues" => [], - ]; - } - } - } - - // Tri des issues par colonne/jalon/sprint/issue - $rowcol = array_column($tbissues, 'rowcol'); - array_multisort($rowcol, SORT_ASC, $tbissues); - foreach($tbissues as $keycol=>$column) { - $rowjal = array_column($tbissues[$keycol]["jalons"], 'rowjal'); - array_multisort($rowjal, SORT_DESC, $tbissues[$keycol]["jalons"]); - foreach($tbissues[$keycol]["jalons"] as $keyjal=>$jalon) { - $rowspr = array_column($tbissues[$keycol]["jalons"][$keyjal]["sprints"], 'rowspr'); - array_multisort($rowspr, SORT_DESC, $tbissues[$keycol]["jalons"][$keyjal]["sprints"]); - } - } - } - protected function getErrorForm($id,$form,$request,$data,$mode) { if ($form->get('submit')->isClicked()&&$mode=="delete") { } diff --git a/src/Controller/ScrumissueController.php b/src/Controller/ScrumissueController.php index ec70304..25da7db 100755 --- a/src/Controller/ScrumissueController.php +++ b/src/Controller/ScrumissueController.php @@ -12,6 +12,7 @@ use App\Entity\Scrumissue as Entity; use App\Form\ScrumissueType as Form; use App\Service\giteaService; +use stdClass; class ScrumissueController extends AbstractController { @@ -141,6 +142,68 @@ class ScrumissueController extends AbstractController return new JsonResponse($output); } + public function view($id, Request $request) { + $em = $this->getDoctrine()->getManager(); + $issue=$em->getRepository("App:Scrumissue")->find($id); + $scrum = $issue->getScrum(); + + $repoid = $scrum->getGiteaid(); + $repoowner = $scrum->getGiteajson()["owner"]["login"]; + $reponame = $scrum->getGiteajson()["name"]; + + $repo=$this->giteaservice->getRepo($repoid); + $giteaissue=$this->giteaservice->getIssue($repoowner,$reponame,$issue->getGiteanumber()); + + $giteaissue->body = $this->giteaservice->markdown("/".$scrum->getGiteajson()["full_name"],"comment",$giteaissue->body); + $giteaissue->comments=$this->giteaservice->getIssueComments($repoowner,$reponame,$giteaissue->number); + + $giteaissue->statuslife=$issue->getScrumcolumn()->getName(); + $giteaissue->sprint=($issue->getScrumsprint()?$issue->getScrumsprint()->getName():null); + foreach($giteaissue->comments as $keycomment => $comment) { + $giteaissue->comments[$keycomment]->body=$this->giteaservice->markdown("/".$scrum->getGiteajson()["full_name"],"comment",$giteaissue->comments[$keycomment]->body); + } + + $giteaissue->timelines=$this->giteaservice->getIssueTimelines($repoowner,$reponame,$giteaissue->number); + + $giteaissue->labelhistos=[]; + $giteaissue->refs=[]; + foreach($giteaissue->timelines as $key => $timeline) { + if($timeline->type == "label"){ + $tmp=new stdClass(); + $tmp->label=($timeline->body==1?"Ajout Label":"Suppression Label")." ".$timeline->label->name.""; + $tmp->user=$timeline->user; + $tmp->created_at=$timeline->created_at; + array_push($giteaissue->labelhistos,$tmp); + unset($giteaissue->timelines[$key]); + } + elseif($timeline->type == "comment_ref" || $timeline->type == "pull_ref" || $timeline->type == "issue_ref"){ + $tmp=new stdClass(); + $tmp->label =""; + $tmp->label.=($timeline->type=="pull_ref"?"Request":"Issue")." = "; + $tmp->label.="#".$timeline->ref_issue->number." = ".$timeline->ref_issue->title.""; + $tmp->user=$timeline->user; + $tmp->created_at=$timeline->created_at; + array_push($giteaissue->refs,$tmp); + unset($giteaissue->timelines[$key]); + } + } + + + + + // Affichage du formulaire + return $this->render('Scrum/issue.html.twig', [ + 'useheader' => false, + 'usesidebar' => false, + 'maxwidth' => true, + 'repo' => $repo, + 'issue' => $giteaissue, + ]); + + + + } + public function update(Request $request) { $em = $this->getDoctrine()->getManager(); diff --git a/templates/Report/list.html.twig b/templates/Report/list.html.twig index c164478..9084e91 100644 --- a/templates/Report/list.html.twig +++ b/templates/Report/list.html.twig @@ -45,7 +45,7 @@ {% for comment in issue.comments %}

{{comment.user.login}} le {{comment.created_at|date("d/m/Y H:i")}}

- {{comment.body|markdown_to_html}} + {{comment.body|raw}}
{% endfor %} {% endif %} @@ -86,7 +86,7 @@
{% for timeline in issue.timelines %} - {% if timeline.type!="comment" and timeline.type!="project" and timeline.type!="added_deadline" and timeline.type!="modified_deadline"%} + {% if timeline.type!="comment" and timeline.type!="project" and timeline.type!="added_deadline" and timeline.type!="modified_deadline" and timeline.type!="label" %}
  • {{timeline.user.login}} le {{timeline.created_at|date("d/m/Y H:i")}}
    {% if timeline.type == "change_title" %} diff --git a/templates/Scrum/issue.html.twig b/templates/Scrum/issue.html.twig new file mode 100644 index 0000000..8677f47 --- /dev/null +++ b/templates/Scrum/issue.html.twig @@ -0,0 +1,196 @@ +{% extends "base.html.twig" %} + +{% block localstyle %} + .issuecontent { + width:75%; + } + .issuedetail { + width:25%; + padding-right: 10px; + zoom:80%; + } + + .text-small { + font-size:80%; + } + + .card-header, .card-body { + padding:10px; + background-color: var(--colorbgbodylight-darker); + } + + .issue-body { + zoom: 80%; + } + + .badge { + color: white; + zoom:120%; + } + + +{% endblock %} + +{% block body %} + +

    #{{issue.number}} = {{issue.title}}

    + +
    +
    +
    +
    +
    {{issue.user.login}}
    +
    le {{issue.created_at|date("d/m/Y H:i")}}
    +
    +
    + {{issue.body|raw}} +
    +
    + + {% if issue.comments %} + {% for comment in issue.comments %} +
    +
    +
    {{comment.user.login}}
    +
    le {{comment.created_at|date("d/m/Y H:i")}}
    +
    + +
    + {{comment.body|raw}} +
    +
    + {% endfor %} + {% endif %} +
    + +
    + Modifier dans Gitea +
    +
    Statut
    +
    + {% if issue.closed_at %} + Clos le {{issue.closed_at|date("d/m/Y H:i")}} + {% else %} + {{issue.statuslife}} + {% endif %} +
    +
    + +
    +
    Jalon
    +
    + {% if issue.milestone %} + {{ issue.milestone.title|raw }} + {% else %} + Backlog + {% endif %} +
    +
    + + {% if issue.sprint %} +
    +
    Sprint
    +
    + {{ issue.sprint }} +
    +
    + {% endif %} + + {% if issue.refs %} +
    +
    Références
    +
    + {% for histo in issue.refs %} +
    + {{histo.label|raw}} +
    + {% endfor %} +
    +
    + {% endif %} + + {% if issue.labels %} +
    +
    Labels
    +
    + {% for label in issue.labels %} + {{label.name}} + {% endfor %} + + {% for histo in issue.labelhistos %} +
    + {{histo.user.login}} le {{histo.created_at|date("d/m/Y H:i")}}
    + {{histo.label|raw}} +
    + {% endfor %} +
    +
    + {% endif %} + + {% if issue.timelines %} +
    +
    Historique
    +
    + {% for timeline in issue.timelines %} + {% if timeline.type!="label" and timeline.type!="comment" and timeline.type!="project" and timeline.type!="added_deadline" and timeline.type!="modified_deadline"%} +
  • {{timeline.user.login}} le {{timeline.created_at|date("d/m/Y H:i")}}
    + + {% if timeline.type == "change_title" %} +
    Modification titre de {{timeline.old_title}} à {{timeline.new_title}}
    + + {% elseif timeline.type == "milestone" %} + {% if timeline.milestone %} +
    Affectation au Jalon {{timeline.milestone.title}}
    + {% else %} +
    Suppression du Jalon
    + {% endif %} + + {% elseif timeline.type == "comment_ref" or timeline.type == "pull_ref" or timeline.type == "issue_ref" %} +
    Référencé le ticket #{{timeline.ref_issue.number}} - {{timeline.ref_issue.title}}
    + + {% elseif timeline.type == "add_dependency" %} +
    Ajouté dépendance au ticket #{{timeline.dependent_issue.number}} - {{timeline.dependent_issue.title}}
    + + {% elseif timeline.type == "remove_dependency" %} +
    Supprimé dépendance au ticket #{{timeline.dependent_issue.number}} - {{timeline.dependent_issue.title}}
    + + {% elseif timeline.type == "pull_push" %} +
    Ajout révision
    + + {% elseif timeline.type == "assignees" %} +
    Affecté intervenant {{timeline.assignee.login}}
    + + {% elseif timeline.type == "commit_ref" %} +
    Référencé depuis commit #{{timeline.body|replace({'href="/':'target="_blank" href="'~giteaUrl~'/'})|raw}}
    + + {% elseif timeline.type == "merge_pull" %} +
    Révision fusionnée
    + + {% elseif timeline.type == "delete_branch" %} +
    Suppression branche {{timeline.old_ref|raw}}
    + + {% elseif timeline.type == "close" %} +
    Clos Fermeture du ticket
    + + {% elseif timeline.type == "review" %} +
    Revue acceptée
    + + {% elseif timeline.type == "review_request" %} +
    Demande de révision
    + + {% elseif timeline.type == "reopen" %} +
    Réouverture du ticket
    + + {% else %} + {{ dump(timeline) }} + {%endif%} + {% endif %} + {% endfor %} +
  • + + {% endif %} + + + +{% endblock %} + diff --git a/templates/Scrum/view.html.twig b/templates/Scrum/view.html.twig index 5fbf543..a9196e0 100644 --- a/templates/Scrum/view.html.twig +++ b/templates/Scrum/view.html.twig @@ -220,7 +220,7 @@