Fix #134 Create an Activity view in the Admin > Accounts panel

This commit is contained in:
Timothée Jaussoin 2023-12-18 10:58:53 +00:00
parent 697f9d148a
commit 245910374a
28 changed files with 207 additions and 95 deletions

View file

@ -13,4 +13,9 @@ abstract class Consommable extends Model
$this->{$this->consommableAttribute} = null;
$this->save();
}
public function consumed(): bool
{
return $this->{$this->consommableAttribute} == null;
}
}

View file

@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Account;
class AccountActivityController extends Controller
{
public function index(Request $request, Account $account)
{
return view(
'admin.account.activity.index',
[
'account' => $account
]
);
}
}

View file

@ -154,11 +154,11 @@ class AccountService
$account->refresh();
$phoneChangeCode->consume();
return $account;
}
$phoneChangeCode->consume();
if ($this->api) {
abort(403);
}
@ -217,7 +217,7 @@ class AccountService
Log::channel('events')->info('Account Service: Account email changed using email', ['id' => $account->identifier]);
$emailChangeCode->delete();
$emailChangeCode->consume();
$account->activated = true;
$account->save();
@ -227,8 +227,6 @@ class AccountService
return $account;
}
$emailChangeCode->consume();
if ($this->api) {
abort(403);
}

40
flexiapi/composer.lock generated
View file

@ -243,16 +243,16 @@
},
{
"name": "carbonphp/carbon-doctrine-types",
"version": "2.0.0",
"version": "2.1.0",
"source": {
"type": "git",
"url": "https://github.com/CarbonPHP/carbon-doctrine-types.git",
"reference": "67a77972b9f398ae7068dabacc39c08aeee170d5"
"reference": "99f76ffa36cce3b70a4a6abce41dba15ca2e84cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/67a77972b9f398ae7068dabacc39c08aeee170d5",
"reference": "67a77972b9f398ae7068dabacc39c08aeee170d5",
"url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/99f76ffa36cce3b70a4a6abce41dba15ca2e84cb",
"reference": "99f76ffa36cce3b70a4a6abce41dba15ca2e84cb",
"shasum": ""
},
"require": {
@ -292,7 +292,7 @@
],
"support": {
"issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues",
"source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/2.0.0"
"source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/2.1.0"
},
"funding": [
{
@ -308,7 +308,7 @@
"type": "tidelift"
}
],
"time": "2023-10-01T14:29:01+00:00"
"time": "2023-12-11T17:09:12+00:00"
},
{
"name": "dasprid/enum",
@ -5052,16 +5052,16 @@
},
{
"name": "react/socket",
"version": "v1.14.0",
"version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/socket.git",
"reference": "21591111d3ea62e31f2254280ca0656bc2b1bda6"
"reference": "216d3aec0b87f04a40ca04f481e6af01bdd1d038"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/socket/zipball/21591111d3ea62e31f2254280ca0656bc2b1bda6",
"reference": "21591111d3ea62e31f2254280ca0656bc2b1bda6",
"url": "https://api.github.com/repos/reactphp/socket/zipball/216d3aec0b87f04a40ca04f481e6af01bdd1d038",
"reference": "216d3aec0b87f04a40ca04f481e6af01bdd1d038",
"shasum": ""
},
"require": {
@ -5073,7 +5073,7 @@
"react/stream": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35",
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
"react/async": "^4 || ^3 || ^2",
"react/promise-stream": "^1.4",
"react/promise-timer": "^1.10"
@ -5081,7 +5081,7 @@
"type": "library",
"autoload": {
"psr-4": {
"React\\Socket\\": "src"
"React\\Socket\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -5120,7 +5120,7 @@
],
"support": {
"issues": "https://github.com/reactphp/socket/issues",
"source": "https://github.com/reactphp/socket/tree/v1.14.0"
"source": "https://github.com/reactphp/socket/tree/v1.15.0"
},
"funding": [
{
@ -5128,7 +5128,7 @@
"type": "open_collective"
}
],
"time": "2023-08-25T13:48:09+00:00"
"time": "2023-12-15T11:02:10+00:00"
},
{
"name": "react/stream",
@ -9445,16 +9445,16 @@
},
{
"name": "pdepend/pdepend",
"version": "2.16.1",
"version": "2.16.2",
"source": {
"type": "git",
"url": "https://github.com/pdepend/pdepend.git",
"reference": "66ceb05eaa8bf358574143c974b04463911bc700"
"reference": "f942b208dc2a0868454d01b29f0c75bbcfc6ed58"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pdepend/pdepend/zipball/66ceb05eaa8bf358574143c974b04463911bc700",
"reference": "66ceb05eaa8bf358574143c974b04463911bc700",
"url": "https://api.github.com/repos/pdepend/pdepend/zipball/f942b208dc2a0868454d01b29f0c75bbcfc6ed58",
"reference": "f942b208dc2a0868454d01b29f0c75bbcfc6ed58",
"shasum": ""
},
"require": {
@ -9496,7 +9496,7 @@
],
"support": {
"issues": "https://github.com/pdepend/pdepend/issues",
"source": "https://github.com/pdepend/pdepend/tree/2.16.1"
"source": "https://github.com/pdepend/pdepend/tree/2.16.2"
},
"funding": [
{
@ -9504,7 +9504,7 @@
"type": "tidelift"
}
],
"time": "2023-12-10T18:38:19+00:00"
"time": "2023-12-17T18:09:59+00:00"
},
{
"name": "phpmd/phpmd",

View file

@ -420,8 +420,6 @@ content > nav a {
align-items: center;
line-height: 5rem;
margin: 1rem 0;
margin-left: 2rem;
padding-right: 2rem;
position: relative;
white-space: nowrap;
}
@ -433,19 +431,6 @@ content > nav a.current {
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.2);
}
content > nav a.current:after {
content: '';
display: block;
width: 1rem;
height: 1rem;
background-color: white;
border-radius: 1rem;
position: absolute;
left: -2rem;
top: calc(50% - 0.5rem);
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.2);
}
content > nav a i {
margin: 0 1rem;
margin-left: 2rem;
@ -658,6 +643,10 @@ table tr.empty td:before {
line-height: 8rem;
}
table.third th {
width: 33.33%;
}
/* Display/hide */
.on_mobile {
@ -768,6 +757,10 @@ select.list_toggle {
pointer-events: none;
}
.crossed {
text-decoration: line-through;
}
.chart {
min-height: 80vh;
}

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.edit', $account->id) }}">{{ $account->identifier }}</a>
</li>

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.edit', $account->id) }}">{{ $account->identifier }}</a>
</li>

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.edit', $action->account) }}">{{ $action->account->identifier }}</a>
</li>

View file

@ -0,0 +1,119 @@
@extends('layouts.main')
@section('breadcrumb')
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.edit', $account) }}">{{ $account->identifier }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Activity</li>
@endsection
@section('content')
<header>
<h1><i class="material-icons-outlined">view_list</i> {{ $account->identifier }}</h1>
</header>
@include('admin.account.parts.tabs')
@if ($account->recoveryCodes->isNotEmpty())
<table class="third">
<thead>
<tr>
<th>Recovery Codes</th>
<th>Created</th>
<th>Used</th>
</tr>
</thead>
<tbody>
@foreach ($account->recoveryCodes as $recoveryCode)
<tr @if ($recoveryCode->consumed()) class="disabled" @endif>
<td @if ($recoveryCode->consumed())class="crossed" @endif>****</td>
<td>
{{ $recoveryCode->created_at }}
</td>
<td>
{{ $recoveryCode->created_at != $recoveryCode->updated_at ? $recoveryCode->updated_at : '-' }}
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
@if ($account->phoneChangeCodes->isNotEmpty())
<table class="third">
<thead>
<tr>
<th>Phone Change requests</th>
<th>Created</th>
<th>Used</th>
</tr>
</thead>
<tbody>
@foreach ($account->phoneChangeCodes as $phoneChangeCode)
<tr @if ($phoneChangeCode->consumed()) class="disabled" @endif>
<td @if ($phoneChangeCode->consumed())class="crossed" @endif>****</td>
<td>
{{ $phoneChangeCode->created_at }}
</td>
<td>
{{ $phoneChangeCode->created_at != $phoneChangeCode->updated_at ? $phoneChangeCode->updated_at : '-' }}
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
@if ($account->emailChangeCodes->isNotEmpty())
<table class="third">
<thead>
<tr>
<th>Email Change requests</th>
<th>Created</th>
<th>Used</th>
</tr>
</thead>
<tbody>
@foreach ($account->emailChangeCodes as $emailChangeCode)
<tr @if ($emailChangeCode->consumed()) class="disabled" @endif>
<td @if ($emailChangeCode->consumed())class="crossed" @endif>****</td>
<td>
{{ $emailChangeCode->created_at }}
</td>
<td>
{{ $emailChangeCode->created_at != $emailChangeCode->updated_at ? $emailChangeCode->updated_at : '-' }}
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
@if ($account->provisioningTokens->isNotEmpty())
<table class="third">
<thead>
<tr>
<th>Provisioning Tokens</th>
<th>Created</th>
<th>Used</th>
</tr>
</thead>
<tbody>
@foreach ($account->provisioningTokens as $provisioningToken)
<tr @if ($provisioningToken->used) class="disabled" @endif>
<td @if ($provisioningToken->used) class="crossed" @endif>{{ $provisioningToken->token }}</td>
<td>
{{ $provisioningToken->created_at }}
</td>
<td>
{{ $provisioningToken->updated_at }}
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
@endsection

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item active" aria-current="page">Add Contact</li>
@endsection

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item"'>
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.edit', $account) }}">{{ $account->identifier }}</a>
</li>

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item active" aria-current="page">Edit</li>
@endsection
@ -203,7 +201,7 @@
<h2>Actions</h2>
@if ($account->dtmf_protocol)
<table class="table">
<table>
<tbody>
@foreach ($account->actions as $action)
<tr>
@ -227,7 +225,7 @@
<h2>Types</h2>
<table class="table">
<table>
<tbody>
@foreach ($account->types as $type)
<tr>

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item active" aria-current="page">Delete</li>
@endsection

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.edit', $account) }}">{{ $account->identifier }}</a>
</li>
@ -19,7 +17,7 @@
@include('admin.account.parts.tabs')
<table class="table">
<table>
<thead>
<tr>
<th>User Agent</th>

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item active" aria-current="page">Import</li>
@endsection

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item active" aria-current="page">Import</li>
@endsection

View file

@ -73,7 +73,7 @@
</form>
</div>
<table class="table">
<table>
<thead>
<tr>
@include('parts.column_sort', ['key' => 'username', 'title' => 'Identifier'])

View file

@ -4,5 +4,6 @@
route('admin.account.statistics.show_call_logs', $account->id) => 'Call Logs',
route('admin.account.device.index', $account->id) => 'Devices',
route('admin.account.statistics.show', $account->id) => 'Statistics',
route('admin.account.activity.index', $account->id) => 'Activity',
],
])

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.edit', $account) }}">{{ $account->identifier }}</a>
</li>

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item active" aria-current="page">Call Logs</li>
@endsection

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.type.index') }}">Types</a>
</li>

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.type.index') }}">Types</a>
</li>

View file

@ -1,9 +1,7 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
@include('admin.account.parts.breadcrumb_accounts_index')
<li class="breadcrumb-item" aria-current="page">
<a href="{{ route('admin.account.type.index') }}">Types</a>
</li>
@ -18,7 +16,7 @@
</a>
</header>
<table class="table">
<table>
<thead>
<tr>
<th>Key</th>

View file

@ -63,7 +63,7 @@
</form>
</div>
<table class="table">
<table>
<thead>
<tr>
<th width="1%">

View file

@ -16,7 +16,7 @@
</a>
</header>
<table class="table">
<table>
<thead>
<tr>
@include('parts.column_sort', ['key' => 'title', 'title' => 'Name'])

View file

@ -1,4 +1,4 @@
<table class="table">
<table>
<thead>
<tr>
<th>From</th>

View file

@ -1,3 +1,3 @@
<div class="table">
<div>
{{ Illuminate\Mail\Markdown::parse($slot) }}
</div>

View file

@ -27,11 +27,12 @@ use App\Http\Controllers\Account\ProvisioningController;
use App\Http\Controllers\Account\RecoveryController;
use App\Http\Controllers\Admin\AccountAccountTypeController;
use App\Http\Controllers\Admin\AccountActionController;
use App\Http\Controllers\Admin\AccountActivityController;
use App\Http\Controllers\Admin\AccountContactController;
use App\Http\Controllers\Admin\AccountDeviceController;
use App\Http\Controllers\Admin\AccountImportController;
use App\Http\Controllers\Admin\AccountTypeController;
use App\Http\Controllers\Admin\AccountController as AdminAccountController;
use App\Http\Controllers\Admin\AccountImportController;
use App\Http\Controllers\Admin\AccountStatisticsController;
use App\Http\Controllers\Admin\ContactsListController;
use App\Http\Controllers\Admin\ContactsListContactController;
@ -208,6 +209,10 @@ if (config('app.web_panel')) {
Route::delete('/', 'destroy')->name('destroy');
});
Route::name('activity.')->prefix('{account}/activity')->controller(AccountActivityController::class)->group(function () {
Route::get('/', 'index')->name('index');
});
Route::name('statistics.')->prefix('{account}/statistics')->controller(AccountStatisticsController::class)->group(function () {
Route::get('/', 'show')->name('show');
Route::post('call_logs', 'editCallLogs')->name('edit_call_logs');