Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gammamatrix committed Dec 22, 2024
1 parent cf3c245 commit 777be76
Show file tree
Hide file tree
Showing 24 changed files with 677 additions and 38 deletions.
4 changes: 4 additions & 0 deletions config/playground-matrix-resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@
|
| By default, translations and views are loaded.
|
| For a faster load time on /resource/matrix, disable PLAYGROUND_MATRIX_RESOURCE_LOAD_MATRIX
| from loading the model counts in the database.
|
*/

'load' => [
'matrix' => (bool) env('PLAYGROUND_MATRIX_RESOURCE_LOAD_MATRIX', true),
'policies' => (bool) env('PLAYGROUND_MATRIX_RESOURCE_LOAD_POLICIES', true),
'routes' => (bool) env('PLAYGROUND_MATRIX_RESOURCE_LOAD_ROUTES', true),
'translations' => (bool) env('PLAYGROUND_MATRIX_RESOURCE_LOAD_TRANSLATIONS', true),
Expand Down
294 changes: 276 additions & 18 deletions resources/views/index.blade.php

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions resources/views/sitemap.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@
<div class="col-sm-6 mb-3">
<div class="card">
<div class="card-header">
Matrix Index
<small class="text-muted">backlogs, boards, epics, flows, matrices, milestones, notes, projects, releases, roadmaps, sources, sprints, tags, teams, tickets and versions</small>
<small class="text-muted">backlogs, boards, epics, flows, matrices, milestones, notes, projects, releases, roadmaps, sources, sprints, tags, teams, tickets and versions</small>
</div>
<ul class="list-group list-group-flush">

<a href="{{ route('playground.matrix.resource') }}" class="list-group-item list-group-item-action">
Matrix Index
</a>

@if ($viewBacklogs)
<a href="{{ route('playground.matrix.resource.backlogs') }}" class="list-group-item list-group-item-action">
Backlogs
Expand Down
2 changes: 1 addition & 1 deletion routes/backlogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/backlog',
'prefix' => 'resource/matrix/backlog',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/boards.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/board',
'prefix' => 'resource/matrix/board',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/epics.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/epic',
'prefix' => 'resource/matrix/epic',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/flows.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/flow',
'prefix' => 'resource/matrix/flow',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/matrices.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/matrix',
'prefix' => 'resource/matrix/matrix',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/milestones.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/milestone',
'prefix' => 'resource/matrix/milestone',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/notes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/note',
'prefix' => 'resource/matrix/note',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/project',
'prefix' => 'resource/matrix/project',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/releases.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/release',
'prefix' => 'resource/matrix/release',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/roadmaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/roadmap',
'prefix' => 'resource/matrix/roadmap',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/sources.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/source',
'prefix' => 'resource/matrix/source',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/sprints.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/sprint',
'prefix' => 'resource/matrix/sprint',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/tag',
'prefix' => 'resource/matrix/tag',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/team',
'prefix' => 'resource/matrix/team',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/tickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/ticket',
'prefix' => 'resource/matrix/ticket',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
2 changes: 1 addition & 1 deletion routes/versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

Route::group([
'prefix' => 'api/matrix/version',
'prefix' => 'resource/matrix/version',
'middleware' => config('playground-matrix-resource.middleware.default'),
'namespace' => '\Playground\Matrix\Resource\Http\Controllers',
], function () {
Expand Down
136 changes: 136 additions & 0 deletions src/Dashboard/AbstractDashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php
/**
* Playground
*/

declare(strict_types=1);
namespace Playground\Matrix\Resource\Dashboard;

use UnexpectedValueException;

/**
* \Playground\Matrix\AbstractDashboard
*/
class AbstractDashboard
{
/**
* @var array<string, string>
*/
protected array $labels = [];

/**
* @var array<string, array<int, DashboardLink>>
*/
protected array $links = [];

/**
* Counts may be positive or negative and null if untallied or the key does not exist.
*
* @var array<string, int|null>
*/
protected array $counts = [];

public function getCount(string $key): int|null
{
if (empty($key)
|| !array_key_exists($key, $this->counts)
|| !is_int($this->counts[$key])
) {
return null;
}

return $this->counts[$key];
}

public function setCount(string $key, int|null $value): self
{
if (!empty($key) ) {
$this->counts[$key] = $value;
}

return $this;
}

public function decrementCount(string $key, int $value = -1): self
{
if ($value > -1) {
throw new UnexpectedValueException(sprintf(
'Expecting the decrement value to be an integer of -1 or less. Provided: [%d]',
$value
));
}
if (!empty($key) ) {
if (!array_key_exists($key, $this->counts)) {
$this->counts[$key] = 0;
}
$this->counts[$key] -= $value;
}

return $this;
}

public function incrementCount(string $key, int $value = 1): self
{
if ($value < 1) {
throw new UnexpectedValueException(sprintf(
'Expecting the decrement value to be an integer of 1 or more. Provided: [%d]',
$value
));
}
if (!empty($key) ) {
if (!array_key_exists($key, $this->counts)) {
$this->counts[$key] = 0;
}
$this->counts[$key] -= $value;
}

return $this;
}

public function setLabel(string $key, string $label): self
{
if (!empty($key) && !empty($label)) {
$this->labels[$key] = $label;
}

return $this;
}

public function hasLinks(string $key): bool
{
return !empty($key)
&& array_key_exists($key, $this->links)
&& !empty($this->links[$key])
;
}

/**
* @param array<string, mixed> $options
*/
public function addLink(string $key, array $options = []): self
{
if (!empty($key)) {
if (!array_key_exists($key, $this->links)) {
$this->links[$key] = [];
}
$this->links[$key][] = new DashboardLink($options);
}

return $this;
}

/**
* @return array<int, DashboardLink>
*/
public function getLinks(string $key): array
{
if (empty($key)
|| !array_key_exists($key, $this->links)
|| empty($this->links[$key])
) {
return [];
}

return $this->links[$key];
}
}
Loading

0 comments on commit 777be76

Please sign in to comment.