OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
69
app/Domain/Reports/Controllers/Project.php
Normal file
69
app/Domain/Reports/Controllers/Project.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Leantime\Domain\Reports\Controllers;
|
||||
|
||||
use Leantime\Core\Auth\Permissions\RequiresPermission;
|
||||
use Leantime\Core\Controller\Controller;
|
||||
use Leantime\Core\Controller\Frontcontroller;
|
||||
use Leantime\Domain\Projects\Services\Projects as ProjectService;
|
||||
use Leantime\Domain\Reports\Models\ReportPeriod;
|
||||
use Leantime\Domain\Reports\Permissions\ReportsPermissions;
|
||||
use Leantime\Domain\Reports\Services\ReportEngine;
|
||||
|
||||
/**
|
||||
* Project status report: period-filtered milestones (accomplished / in flight / coming up),
|
||||
* outcome narratives, goals, effort and status updates for the current project. The sibling
|
||||
* /reports/show screen keeps the sprint delivery metrics (burndown, cumulative flow).
|
||||
*/
|
||||
class Project extends Controller
|
||||
{
|
||||
private ReportEngine $reportEngine;
|
||||
|
||||
private ProjectService $projectService;
|
||||
|
||||
public function init(ReportEngine $reportEngine, ProjectService $projectService): void
|
||||
{
|
||||
$this->reportEngine = $reportEngine;
|
||||
$this->projectService = $projectService;
|
||||
|
||||
session(['lastPage' => BASE_URL.'/reports/project']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the project status report for the requested period (default: this quarter).
|
||||
*
|
||||
* @param array<string, mixed> $params
|
||||
*/
|
||||
#[RequiresPermission(ReportsPermissions::VIEW)]
|
||||
public function get(array $params): \Symfony\Component\HttpFoundation\Response
|
||||
{
|
||||
// Drill-down links from plan/strategy rollups target a specific project; switch the
|
||||
// session project when the user has access (mirrors EditMilestone's behavior).
|
||||
// `id` is the Frontcontroller's path-segment param, so /reports/project/123 works too.
|
||||
$requestedProjectId = (int) ($params['projectId'] ?? $params['id'] ?? 0);
|
||||
if (
|
||||
$requestedProjectId > 0
|
||||
&& $requestedProjectId !== (int) session('currentProject')
|
||||
&& $this->projectService->isUserAssignedToProject((int) session('userdata.id'), $requestedProjectId)
|
||||
) {
|
||||
$this->projectService->changeCurrentSessionProject($requestedProjectId);
|
||||
}
|
||||
|
||||
$projectId = (int) session('currentProject');
|
||||
|
||||
if ($projectId === 0) {
|
||||
return Frontcontroller::redirect(BASE_URL.'/dashboard/home');
|
||||
}
|
||||
|
||||
$period = ReportPeriod::fromRequest($params);
|
||||
$report = $this->reportEngine->buildReport([$projectId], $period);
|
||||
|
||||
$this->tpl->assign('projectId', $projectId);
|
||||
$this->tpl->assign('period', $period);
|
||||
$this->tpl->assign('report', $report);
|
||||
|
||||
return $this->tpl->display('reports.project');
|
||||
}
|
||||
}
|
||||
97
app/Domain/Reports/Controllers/Show.php
Normal file
97
app/Domain/Reports/Controllers/Show.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Reports\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Leantime\Core\Auth\Permissions\RequiresPermission;
|
||||
use Leantime\Core\Controller\Controller;
|
||||
use Leantime\Core\Controller\Frontcontroller;
|
||||
use Leantime\Domain\Projects\Services\Projects as ProjectService;
|
||||
use Leantime\Domain\Reports\Permissions\ReportsPermissions;
|
||||
use Leantime\Domain\Reports\Services\Reports as ReportService;
|
||||
use Leantime\Domain\Sprints\Services\Sprints as SprintService;
|
||||
use Leantime\Domain\Tickets\Services\Tickets as TicketService;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class Show extends Controller
|
||||
{
|
||||
private ProjectService $projectService;
|
||||
|
||||
private SprintService $sprintService;
|
||||
|
||||
private TicketService $ticketService;
|
||||
|
||||
private ReportService $reportService;
|
||||
|
||||
/**
|
||||
* @throws BindingResolutionException
|
||||
*/
|
||||
public function init(
|
||||
ProjectService $projectService,
|
||||
SprintService $sprintService,
|
||||
TicketService $ticketService,
|
||||
ReportService $reportService
|
||||
): void {
|
||||
// Authorization lives on the action attributes (reports.view, session project) — the
|
||||
// Frontcontroller enforces them BEFORE the controller is instantiated, so init() (and the
|
||||
// dailyIngestion() it triggers) never runs for a denied user. Replaces the legacy
|
||||
// editor+ authOrRedirect (maintainer-approved readonly+ loosening: the page only
|
||||
// aggregates data readonly members already see item-by-item).
|
||||
$this->projectService = $projectService;
|
||||
$this->sprintService = $sprintService;
|
||||
$this->ticketService = $ticketService;
|
||||
|
||||
session(['lastPage' => BASE_URL.'/reports/show']);
|
||||
|
||||
$this->reportService = $reportService;
|
||||
$this->reportService->dailyIngestion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BindingResolutionException
|
||||
*/
|
||||
#[RequiresPermission(ReportsPermissions::VIEW)]
|
||||
public function get(array $params): Response
|
||||
{
|
||||
$currentProject = (int) session('currentProject');
|
||||
|
||||
// Project Progress
|
||||
$this->tpl->assign('projectProgress', $this->projectService->getProjectProgress($currentProject));
|
||||
$this->tpl->assign('currentProjectName', $this->projectService->getProjectName($currentProject));
|
||||
|
||||
// Sprint Burndown
|
||||
$requestedSprintId = isset($params['sprint']) ? (int) $params['sprint'] : null;
|
||||
$allSprints = $this->sprintService->getAllSprints($currentProject);
|
||||
|
||||
$sprintBurndown = $this->reportService->getSprintBurndownForReport($currentProject, $requestedSprintId);
|
||||
|
||||
$this->tpl->assign('sprintBurndown', $sprintBurndown['chart']);
|
||||
|
||||
if ($allSprints !== false && count($allSprints) > 0) {
|
||||
$this->tpl->assign('currentSprint', $sprintBurndown['currentSprintId']);
|
||||
}
|
||||
|
||||
$this->tpl->assign('backlogBurndown', $this->sprintService->getCummulativeReport($currentProject));
|
||||
$this->tpl->assign('allSprints', $allSprints);
|
||||
|
||||
$this->tpl->assign('fullReport', $this->reportService->getFullReport($currentProject));
|
||||
$this->tpl->assign('fullReportLatest', $this->reportService->getRealtimeReport($currentProject, ''));
|
||||
|
||||
$this->tpl->assign('states', $this->ticketService->getStatusLabels());
|
||||
|
||||
// Milestones. getAllMilestones no longer computes percentDone in the query, so backfill each
|
||||
// milestone's completion the same way the Roadmap/timeline does — otherwise the report shows
|
||||
// every milestone at 0% (#3624).
|
||||
$allProjectMilestones = $this->ticketService->getAllMilestones(['sprint' => '', 'type' => 'milestone', 'currentProject' => $currentProject]);
|
||||
$allProjectMilestones = $this->ticketService->getBulkMilestoneProgress($allProjectMilestones);
|
||||
$this->tpl->assign('milestones', $allProjectMilestones);
|
||||
|
||||
return $this->tpl->display('reports.show');
|
||||
}
|
||||
|
||||
#[RequiresPermission(ReportsPermissions::VIEW)]
|
||||
public function post($params): Response
|
||||
{
|
||||
return Frontcontroller::redirect(BASE_URL.'/dashboard/show');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user