diff --git a/flexiapi/app/Account.php b/flexiapi/app/Account.php index e41e7ec..5fed7e4 100644 --- a/flexiapi/app/Account.php +++ b/flexiapi/app/Account.php @@ -28,9 +28,6 @@ use Illuminate\Support\Str; use Carbon\Carbon; use Awobaz\Compoships\Compoships; - -use App\ApiKey; -use App\Password; use App\Http\Controllers\Account\AuthenticateController as WebAuthenticateController; class Account extends Authenticatable @@ -38,9 +35,9 @@ class Account extends Authenticatable use HasFactory; use Compoships; - protected $with = ['passwords', 'admin', 'alias', 'activationExpiration', 'emailChangeCode', 'types', 'actions']; - protected $hidden = ['alias', 'expire_time', 'confirmation_key', 'pivot', 'currentProvisioningToken', 'currentRecoveryCode']; - protected $appends = ['realm', 'phone', 'confirmation_key_expires', 'provisioning_token']; + protected $with = ['passwords', 'admin', 'alias', 'activationExpiration', 'emailChangeCode', 'types', 'actions', 'dictionaryEntries']; + protected $hidden = ['alias', 'expire_time', 'confirmation_key', 'pivot', 'currentProvisioningToken', 'currentRecoveryCode', 'dictionaryEntries']; + protected $appends = ['realm', 'phone', 'confirmation_key_expires', 'provisioning_token', 'dictionary']; protected $casts = [ 'activated' => 'boolean', ]; @@ -148,6 +145,18 @@ class Account extends Authenticatable return $this->belongsToMany(ContactsList::class, 'account_contacts_list', 'account_id', 'contacts_list_id'); } + public function dictionaryEntries() + { + return $this->hasMany(AccountDictionaryEntry::class); + } + + public function getDictionaryAttribute() + { + return $this->dictionaryEntries->keyBy('key')->map(function ($entry) { + return $entry->value; + }); + } + public function nonces() { return $this->hasMany(DigestNonce::class); diff --git a/flexiapi/app/AccountDictionaryEntry.php b/flexiapi/app/AccountDictionaryEntry.php new file mode 100644 index 0000000..ad3b422 --- /dev/null +++ b/flexiapi/app/AccountDictionaryEntry.php @@ -0,0 +1,18 @@ +belongsTo(Account::class); + } +} diff --git a/flexiapi/app/Admin.php b/flexiapi/app/Admin.php index ab2f04f..fb8d845 100644 --- a/flexiapi/app/Admin.php +++ b/flexiapi/app/Admin.php @@ -31,6 +31,6 @@ class Admin extends Model public function account() { - return $this->belongsTo('App\Account'); + return $this->belongsTo(Account::class); } } diff --git a/flexiapi/app/Alias.php b/flexiapi/app/Alias.php index 99c238d..4b5f071 100644 --- a/flexiapi/app/Alias.php +++ b/flexiapi/app/Alias.php @@ -28,7 +28,7 @@ class Alias extends Model public function account() { - return $this->belongsTo('App\Account'); + return $this->belongsTo(Account::class); } public function scopeSip($query, string $sip) diff --git a/flexiapi/app/ApiKey.php b/flexiapi/app/ApiKey.php index 601c8c3..8bb3045 100644 --- a/flexiapi/app/ApiKey.php +++ b/flexiapi/app/ApiKey.php @@ -30,6 +30,6 @@ class ApiKey extends Model public function account() { - return $this->belongsTo('App\Account'); + return $this->belongsTo(Account::class); } } diff --git a/flexiapi/app/AuthToken.php b/flexiapi/app/AuthToken.php index fc2bc70..c5a0ada 100644 --- a/flexiapi/app/AuthToken.php +++ b/flexiapi/app/AuthToken.php @@ -14,7 +14,7 @@ class AuthToken extends Model public function account() { - return $this->belongsTo('App\Account'); + return $this->belongsTo(Account::class); } public function scopeValid($query) diff --git a/flexiapi/app/DigestNonce.php b/flexiapi/app/DigestNonce.php index 2e29bf5..005685b 100644 --- a/flexiapi/app/DigestNonce.php +++ b/flexiapi/app/DigestNonce.php @@ -27,6 +27,6 @@ class DigestNonce extends Model public function account() { - return $this->belongsTo('App\Account'); + return $this->belongsTo(Account::class); } } diff --git a/flexiapi/app/EmailChangeCode.php b/flexiapi/app/EmailChangeCode.php index 21be5bc..198e613 100644 --- a/flexiapi/app/EmailChangeCode.php +++ b/flexiapi/app/EmailChangeCode.php @@ -29,7 +29,7 @@ class EmailChangeCode extends Consommable public function account() { - return $this->belongsTo('App\Account'); + return $this->belongsTo(Account::class); } public function validate(int $code): bool diff --git a/flexiapi/app/Http/Controllers/Account/AuthTokenController.php b/flexiapi/app/Http/Controllers/Account/AuthTokenController.php index 36c48da..e2f4980 100644 --- a/flexiapi/app/Http/Controllers/Account/AuthTokenController.php +++ b/flexiapi/app/Http/Controllers/Account/AuthTokenController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Account; diff --git a/flexiapi/app/Http/Controllers/Account/CreationRequestTokenController.php b/flexiapi/app/Http/Controllers/Account/CreationRequestTokenController.php index 5e865eb..1011c20 100644 --- a/flexiapi/app/Http/Controllers/Account/CreationRequestTokenController.php +++ b/flexiapi/app/Http/Controllers/Account/CreationRequestTokenController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Account; diff --git a/flexiapi/app/Http/Controllers/Account/RecoveryController.php b/flexiapi/app/Http/Controllers/Account/RecoveryController.php index 7e59235..9605011 100644 --- a/flexiapi/app/Http/Controllers/Account/RecoveryController.php +++ b/flexiapi/app/Http/Controllers/Account/RecoveryController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Account; diff --git a/flexiapi/app/Http/Controllers/Admin/AccountActivityController.php b/flexiapi/app/Http/Controllers/Admin/AccountActivityController.php index 175d625..a0ae08f 100644 --- a/flexiapi/app/Http/Controllers/Admin/AccountActivityController.php +++ b/flexiapi/app/Http/Controllers/Admin/AccountActivityController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Admin; diff --git a/flexiapi/app/Http/Controllers/Admin/AccountDictionaryController.php b/flexiapi/app/Http/Controllers/Admin/AccountDictionaryController.php new file mode 100644 index 0000000..a0b1e17 --- /dev/null +++ b/flexiapi/app/Http/Controllers/Admin/AccountDictionaryController.php @@ -0,0 +1,102 @@ +. +*/ + +namespace App\Http\Controllers\Admin; + +use App\Http\Controllers\Controller; +use Illuminate\Http\Request; + +use App\Account; +use App\AccountDictionaryEntry; + +class AccountDictionaryController extends Controller +{ + public function index(Request $request, Account $account) + { + return view( + 'admin.account.dictionary.index', + [ + 'account' => $account + ] + ); + } + + public function create(Request $request, Account $account) + { + return view('admin.account.dictionary.create_edit', [ + 'account' => $account, + 'entry' => new AccountDictionaryEntry + ]); + } + + public function store(Request $request, Account $account) + { + $request->validate([ + 'key' => 'required', + 'value' => 'required' + ]); + + $entry = new AccountDictionaryEntry; + $entry->account_id = $account->id; + $entry->key = $request->get('key'); + $entry->value = $request->get('value'); + $entry->save(); + + return redirect()->route('admin.account.dictionary.index', $account->id); + } + + public function edit(Account $account, string $key) + { + return view('admin.account.dictionary.create_edit', [ + 'account' => $account, + 'entry' => $account->dictionaryEntries()->where('key', $key)->firstOrFail() + ]); + } + + public function update(Request $request, Account $account, int $entryId) + { + $request->validate([ + 'value' => 'required' + ]); + + $entry = $account->dictionaryEntries()->findOrFail($entryId); + $entry->value = $request->get('value'); + $entry->save(); + + return redirect()->route('admin.account.dictionary.index', $account->id); + } + + public function delete(Request $request, Account $account, string $key) + { + return view( + 'admin.account.dictionary.delete', + [ + 'account' => $account, + 'entry' => $account->dictionaryEntries()->where('key', $key)->firstOrFail() + ] + ); + } + + public function destroy(Request $request, Account $account) + { + $account->dictionaryEntries()->where('key', $request->get('key'))->delete(); + + return redirect()->route('admin.account.dictionary.index', $account); + } +} diff --git a/flexiapi/app/Http/Controllers/Admin/AccountImportController.php b/flexiapi/app/Http/Controllers/Admin/AccountImportController.php index 4530d61..d22d54b 100644 --- a/flexiapi/app/Http/Controllers/Admin/AccountImportController.php +++ b/flexiapi/app/Http/Controllers/Admin/AccountImportController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Admin; diff --git a/flexiapi/app/Http/Controllers/Admin/AccountStatisticsController.php b/flexiapi/app/Http/Controllers/Admin/AccountStatisticsController.php index c961147..98d6808 100644 --- a/flexiapi/app/Http/Controllers/Admin/AccountStatisticsController.php +++ b/flexiapi/app/Http/Controllers/Admin/AccountStatisticsController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Admin; diff --git a/flexiapi/app/Http/Controllers/Api/Account/ApiKeyController.php b/flexiapi/app/Http/Controllers/Api/Account/ApiKeyController.php index 7d121f9..f4406d0 100644 --- a/flexiapi/app/Http/Controllers/Api/Account/ApiKeyController.php +++ b/flexiapi/app/Http/Controllers/Api/Account/ApiKeyController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Api\Account; diff --git a/flexiapi/app/Http/Controllers/Api/Account/AuthTokenController.php b/flexiapi/app/Http/Controllers/Api/Account/AuthTokenController.php index a26f82b..1cf8415 100644 --- a/flexiapi/app/Http/Controllers/Api/Account/AuthTokenController.php +++ b/flexiapi/app/Http/Controllers/Api/Account/AuthTokenController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Api\Account; diff --git a/flexiapi/app/Http/Controllers/Api/Account/CreationRequestToken.php b/flexiapi/app/Http/Controllers/Api/Account/CreationRequestToken.php index f346748..eca80d9 100644 --- a/flexiapi/app/Http/Controllers/Api/Account/CreationRequestToken.php +++ b/flexiapi/app/Http/Controllers/Api/Account/CreationRequestToken.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Api\Account; diff --git a/flexiapi/app/Http/Controllers/Api/Admin/AccountDictionaryController.php b/flexiapi/app/Http/Controllers/Api/Admin/AccountDictionaryController.php new file mode 100644 index 0000000..d1808f0 --- /dev/null +++ b/flexiapi/app/Http/Controllers/Api/Admin/AccountDictionaryController.php @@ -0,0 +1,64 @@ +. +*/ + +namespace App\Http\Controllers\Api\Admin; + +use App\Http\Controllers\Controller; +use App\Account; +use App\AccountDictionaryEntry; + +use Illuminate\Http\Request; + +class AccountDictionaryController extends Controller +{ + public function index(Request $request, int $accountId) + { + return Account::findOrFail($accountId)->dictionary; + } + + public function show(Request $request, int $accountId, string $key) + { + return Account::findOrFail($accountId)->dictionaryEntries()->where('key', $key)->first(); + } + + public function set(Request $request, int $accountId, string $key) + { + $request->validate([ + 'value' => 'required' + ]); + + $entry = Account::findOrFail($accountId)->dictionaryEntries()->where('key', $key)->first(); + + if (!$entry) { + $entry = new AccountDictionaryEntry; + } + + $entry->account_id = $accountId; + $entry->key = $key; + $entry->value = $request->get('value'); + $entry->save(); + + return $entry; + } + + public function destroy(Request $request, int $accountId, string $key) + { + return Account::findOrFail($accountId)->dictionaryEntries()->where('key', $key)->delete(); + } +} diff --git a/flexiapi/app/Http/Controllers/Api/Admin/ContactsListController.php b/flexiapi/app/Http/Controllers/Api/Admin/ContactsListController.php index 2f95749..4d83b9b 100644 --- a/flexiapi/app/Http/Controllers/Api/Admin/ContactsListController.php +++ b/flexiapi/app/Http/Controllers/Api/Admin/ContactsListController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Api\Admin; diff --git a/flexiapi/app/Http/Controllers/Api/Admin/MessageController.php b/flexiapi/app/Http/Controllers/Api/Admin/MessageController.php index fbeaa43..4b213e4 100644 --- a/flexiapi/app/Http/Controllers/Api/Admin/MessageController.php +++ b/flexiapi/app/Http/Controllers/Api/Admin/MessageController.php @@ -1,4 +1,21 @@ . +*/ namespace App\Http\Controllers\Api\Admin; diff --git a/flexiapi/app/Password.php b/flexiapi/app/Password.php index 5e0223c..6bb0142 100644 --- a/flexiapi/app/Password.php +++ b/flexiapi/app/Password.php @@ -32,6 +32,6 @@ class Password extends Model public function account() { - return $this->belongsTo('App\Account'); + return $this->belongsTo(Account::class); } } diff --git a/flexiapi/app/PhoneChangeCode.php b/flexiapi/app/PhoneChangeCode.php index 5914c0b..dec68bf 100644 --- a/flexiapi/app/PhoneChangeCode.php +++ b/flexiapi/app/PhoneChangeCode.php @@ -29,6 +29,6 @@ class PhoneChangeCode extends Consommable public function account() { - return $this->belongsTo('App\Account'); + return $this->belongsTo(Account::class); } } diff --git a/flexiapi/database/migrations/2023_12_20_142159_create_account_dictionary_entries_table.php b/flexiapi/database/migrations/2023_12_20_142159_create_account_dictionary_entries_table.php new file mode 100644 index 0000000..306859f --- /dev/null +++ b/flexiapi/database/migrations/2023_12_20_142159_create_account_dictionary_entries_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('key')->index(); + $table->string('value')->index(); + + $table->integer('account_id')->unsigned(); + $table->foreign('account_id')->references('id') + ->on('accounts')->onDelete('cascade'); + $table->unique(['account_id', 'key']); + + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('account_dictionary_entries'); + } +}; diff --git a/flexiapi/public/css/style.css b/flexiapi/public/css/style.css index 6792aa7..97d2dec 100644 --- a/flexiapi/public/css/style.css +++ b/flexiapi/public/css/style.css @@ -174,7 +174,7 @@ code { } p>a:not(.btn), -table tr td a:hover, +table tr td a:not(.btn):hover, label>a { text-decoration: underline; color: var(--main-5); @@ -658,7 +658,7 @@ table tr.empty td:before { color: var(--second-4); display: block; text-align: center; - margin: 12rem; + margin: 9rem; margin-bottom: 1rem; line-height: 8rem; } diff --git a/flexiapi/resources/views/admin/account/account_type/create.blade.php b/flexiapi/resources/views/admin/account/account_type/create.blade.php index 1fb055f..1589050 100644 --- a/flexiapi/resources/views/admin/account/account_type/create.blade.php +++ b/flexiapi/resources/views/admin/account/account_type/create.blade.php @@ -2,9 +2,7 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') - + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) diff --git a/flexiapi/resources/views/admin/account/action/create_edit.blade.php b/flexiapi/resources/views/admin/account/action/create_edit.blade.php index 4fc5f11..45cd350 100644 --- a/flexiapi/resources/views/admin/account/action/create_edit.blade.php +++ b/flexiapi/resources/views/admin/account/action/create_edit.blade.php @@ -2,9 +2,7 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') - + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) @@ -18,7 +16,7 @@ @endif
@method($action->id ? 'put' : 'post') @csrf diff --git a/flexiapi/resources/views/admin/account/action/delete.blade.php b/flexiapi/resources/views/admin/account/action/delete.blade.php index b103f24..b484193 100644 --- a/flexiapi/resources/views/admin/account/action/delete.blade.php +++ b/flexiapi/resources/views/admin/account/action/delete.blade.php @@ -2,9 +2,7 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') - + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) diff --git a/flexiapi/resources/views/admin/account/activity/index.blade.php b/flexiapi/resources/views/admin/account/activity/index.blade.php index 5090193..6101e8a 100644 --- a/flexiapi/resources/views/admin/account/activity/index.blade.php +++ b/flexiapi/resources/views/admin/account/activity/index.blade.php @@ -2,9 +2,7 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') - + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) @endsection diff --git a/flexiapi/resources/views/admin/account/contact/create.blade.php b/flexiapi/resources/views/admin/account/contact/create.blade.php index d247668..da532b7 100644 --- a/flexiapi/resources/views/admin/account/contact/create.blade.php +++ b/flexiapi/resources/views/admin/account/contact/create.blade.php @@ -2,6 +2,7 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) @endsection diff --git a/flexiapi/resources/views/admin/account/contact/delete.blade.php b/flexiapi/resources/views/admin/account/contact/delete.blade.php index 853966f..eaa7d2d 100644 --- a/flexiapi/resources/views/admin/account/contact/delete.blade.php +++ b/flexiapi/resources/views/admin/account/contact/delete.blade.php @@ -2,9 +2,7 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') - + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) diff --git a/flexiapi/resources/views/admin/account/create_edit.blade.php b/flexiapi/resources/views/admin/account/create_edit.blade.php index 85ab7cd..d97544f 100644 --- a/flexiapi/resources/views/admin/account/create_edit.blade.php +++ b/flexiapi/resources/views/admin/account/create_edit.blade.php @@ -2,6 +2,7 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) @endsection @@ -188,13 +189,8 @@ The current one will be unavailable
-

-

@else -

- Generate a provision - link -

+ Generate a provision link @endif @if (config('app.intercom_features')) diff --git a/flexiapi/resources/views/admin/account/delete.blade.php b/flexiapi/resources/views/admin/account/delete.blade.php index 79a2646..4060fc5 100644 --- a/flexiapi/resources/views/admin/account/delete.blade.php +++ b/flexiapi/resources/views/admin/account/delete.blade.php @@ -2,6 +2,7 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) @endsection diff --git a/flexiapi/resources/views/admin/account/device/delete.blade.php b/flexiapi/resources/views/admin/account/device/delete.blade.php index 8e67f9b..65cd9c1 100644 --- a/flexiapi/resources/views/admin/account/device/delete.blade.php +++ b/flexiapi/resources/views/admin/account/device/delete.blade.php @@ -1,6 +1,8 @@ @extends('layouts.main') @section('breadcrumb') + @include('admin.account.parts.breadcrumb_accounts_index') + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) diff --git a/flexiapi/resources/views/admin/account/device/index.blade.php b/flexiapi/resources/views/admin/account/device/index.blade.php index 3cc3060..ad6bb36 100644 --- a/flexiapi/resources/views/admin/account/device/index.blade.php +++ b/flexiapi/resources/views/admin/account/device/index.blade.php @@ -2,10 +2,8 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') - - + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) + @endsection @section('content') diff --git a/flexiapi/resources/views/admin/account/dictionary/create_edit.blade.php b/flexiapi/resources/views/admin/account/dictionary/create_edit.blade.php new file mode 100644 index 0000000..5ce8614 --- /dev/null +++ b/flexiapi/resources/views/admin/account/dictionary/create_edit.blade.php @@ -0,0 +1,38 @@ +@extends('layouts.main') + +@section('breadcrumb') + @include('admin.account.parts.breadcrumb_accounts_index') + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) + + +@endsection + +@section('content') + @if ($entry->id) +

Edit an Entry

+ @else +

Create an Entry

+ @endif + +
+ @method($entry->id ? 'put' : 'post') + @csrf +
+ id)disabled @endif> + + @include('parts.errors', ['name' => 'key']) +
+
+ + + @include('parts.errors', ['name' => 'value']) +
+
+ +
+
+@endsection diff --git a/flexiapi/resources/views/admin/account/dictionary/delete.blade.php b/flexiapi/resources/views/admin/account/dictionary/delete.blade.php new file mode 100644 index 0000000..1fed8cb --- /dev/null +++ b/flexiapi/resources/views/admin/account/dictionary/delete.blade.php @@ -0,0 +1,31 @@ +@extends('layouts.main') + +@section('breadcrumb') + @include('admin.account.parts.breadcrumb_accounts_index') + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) + + +@endsection + +@section('content') +

Dictionary entry deletion

+ +
+

Are you sure you want to delete the following dictionary entry?

+

+ {{ $entry->key }}: {{ $entry->value }} +

+
+ +
+ @method('delete') + @csrf + +
+ +
+ +
+@endsection diff --git a/flexiapi/resources/views/admin/account/dictionary/index.blade.php b/flexiapi/resources/views/admin/account/dictionary/index.blade.php new file mode 100644 index 0000000..c46c68a --- /dev/null +++ b/flexiapi/resources/views/admin/account/dictionary/index.blade.php @@ -0,0 +1,57 @@ +@extends('layouts.main') + +@section('breadcrumb') + @include('admin.account.parts.breadcrumb_accounts_index') + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) + +@endsection + +@section('content') + +
+

people {{ $account->identifier }}

+ Cancel + + add_circle + New Entry + +
+ +@include('admin.account.parts.tabs') + + + + + + + + + + + @if ($account->dictionaryEntries->isEmpty()) + + + + @endif + @foreach ($account->dictionaryEntries as $dictionaryEntry) + + + + + + @endforeach + +
KeyValue
No entries
{{ $dictionaryEntry->key }}{{ $dictionaryEntry->value }} + + Edit + + + Delete + +
+ +@endsection \ No newline at end of file diff --git a/flexiapi/resources/views/admin/account/parts/breadcrumb_accounts_edit.blade.php b/flexiapi/resources/views/admin/account/parts/breadcrumb_accounts_edit.blade.php new file mode 100644 index 0000000..2f316c0 --- /dev/null +++ b/flexiapi/resources/views/admin/account/parts/breadcrumb_accounts_edit.blade.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/flexiapi/resources/views/admin/account/parts/tabs.blade.php b/flexiapi/resources/views/admin/account/parts/tabs.blade.php index 87556ad..6ce971b 100644 --- a/flexiapi/resources/views/admin/account/parts/tabs.blade.php +++ b/flexiapi/resources/views/admin/account/parts/tabs.blade.php @@ -5,5 +5,6 @@ route('admin.account.device.index', $account->id) => 'Devices', route('admin.account.statistics.show', $account->id) => 'Statistics', route('admin.account.activity.index', $account->id) => 'Activity', + route('admin.account.dictionary.index', $account->id) => 'Dictionary', ], ]) \ No newline at end of file diff --git a/flexiapi/resources/views/admin/account/statistics/show.blade.php b/flexiapi/resources/views/admin/account/statistics/show.blade.php index 6463706..3f5ea86 100644 --- a/flexiapi/resources/views/admin/account/statistics/show.blade.php +++ b/flexiapi/resources/views/admin/account/statistics/show.blade.php @@ -2,10 +2,8 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') - - + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) + @endsection @section('content') diff --git a/flexiapi/resources/views/admin/account/statistics/show_call_logs.blade.php b/flexiapi/resources/views/admin/account/statistics/show_call_logs.blade.php index 4263b78..8de29a5 100644 --- a/flexiapi/resources/views/admin/account/statistics/show_call_logs.blade.php +++ b/flexiapi/resources/views/admin/account/statistics/show_call_logs.blade.php @@ -2,12 +2,13 @@ @section('breadcrumb') @include('admin.account.parts.breadcrumb_accounts_index') - + @include('admin.account.parts.breadcrumb_accounts_edit', ['account' => $account]) + @endsection @section('content')
-

list Call Logs

+

people {{ $account->identifier }}

@include('admin.account.parts.tabs') diff --git a/flexiapi/resources/views/api/documentation_markdown.blade.php b/flexiapi/resources/views/api/documentation_markdown.blade.php index 365f92a..02143df 100644 --- a/flexiapi/resources/views/api/documentation_markdown.blade.php +++ b/flexiapi/resources/views/api/documentation_markdown.blade.php @@ -442,7 +442,7 @@ Return the user registered devices. Remove one of the user registered devices. -## Accounts contacts +## Account contacts ### `GET /accounts/me/contacts` @@ -476,6 +476,30 @@ Add a contact to the list. Remove a contact from the list. +## Dictionary + +### `GET /accounts/{id}/dictionary` + +Admin + +Get all the account dictionary entries. + +### `POST /accounts/{id}/dictionary/{key}` + +Admin + +Add or update a new entry to the dictionary + +JSON parameters: + +* `value` required, the entry value + +### `DELETE /accounts/{id}/dictionary/{key}` + +Admin + +Remove an entry from the dictionary. + ## Account Actions The following endpoints will return `403 Forbidden` if the requested account doesn't have a DTMF protocol configured. diff --git a/flexiapi/routes/api.php b/flexiapi/routes/api.php index 82605a9..3c6dee9 100644 --- a/flexiapi/routes/api.php +++ b/flexiapi/routes/api.php @@ -20,6 +20,7 @@ use App\Http\Controllers\Api\Admin\AccountActionController; use App\Http\Controllers\Api\Admin\AccountContactController; use App\Http\Controllers\Api\Admin\AccountController as AdminAccountController; +use App\Http\Controllers\Api\Admin\AccountDictionaryController; use App\Http\Controllers\Api\Admin\AccountTypeController; use App\Http\Controllers\Api\Admin\ContactsListController; use App\Http\Controllers\Api\StatisticsMessageController; @@ -125,6 +126,13 @@ Route::group(['middleware' => ['auth.digest_or_key']], function () { Route::delete('{id}/contacts/{contacts_id}', 'contactRemove'); }); + Route::prefix('accounts/{id}/dictionary')->controller(AccountDictionaryController::class)->group(function () { + Route::get('/', 'index'); + Route::get('{key}', 'show'); + Route::post('{key}', 'set'); + Route::delete('{key}', 'destroy'); + }); + Route::prefix('statistics/messages')->controller(StatisticsMessageController::class)->group(function () { Route::post('/', 'store'); Route::patch('{message_id}/to/{to}/devices/{device_id}', 'storeDevice'); diff --git a/flexiapi/routes/web.php b/flexiapi/routes/web.php index 7bc6b53..9771e06 100644 --- a/flexiapi/routes/web.php +++ b/flexiapi/routes/web.php @@ -30,6 +30,7 @@ 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\AccountDictionaryController; use App\Http\Controllers\Admin\AccountImportController; use App\Http\Controllers\Admin\AccountTypeController; use App\Http\Controllers\Admin\AccountController as AdminAccountController; @@ -209,6 +210,16 @@ if (config('app.web_panel')) { Route::delete('/', 'destroy')->name('destroy'); }); + Route::name('dictionary.')->prefix('{account}/dictionary')->controller(AccountDictionaryController::class)->group(function () { + Route::get('/', 'index')->name('index'); + Route::get('create', 'create')->name('create'); + Route::post('/', 'store')->name('store'); + Route::get('{entry}/edit', 'edit')->name('edit'); + Route::put('{entry}', 'update')->name('update'); + Route::get('{key}/delete', 'delete')->name('delete'); + Route::delete('/', 'destroy')->name('destroy'); + }); + Route::name('activity.')->prefix('{account}/activity')->controller(AccountActivityController::class)->group(function () { Route::get('/', 'index')->name('index'); }); diff --git a/flexiapi/tests/Feature/ApiAccountDictionaryTest.php b/flexiapi/tests/Feature/ApiAccountDictionaryTest.php new file mode 100644 index 0000000..7db725b --- /dev/null +++ b/flexiapi/tests/Feature/ApiAccountDictionaryTest.php @@ -0,0 +1,112 @@ +. +*/ + +namespace Tests\Feature; + +use App\Password; +use App\AccountType; +use App\Admin; +use App\ContactsList; +use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Support\Facades\DB; +use Tests\TestCase; + +class ApiAccountDictionaryTest extends TestCase +{ + use RefreshDatabase; + + protected $route = '/api/accounts'; + protected $method = 'POST'; + + public function testCreate() + { + $password = Password::factory()->create(); + $account = $password->account; + + $admin = Admin::factory()->create(); + $admin->account->generateApiKey(); + + $key = 'foo'; + $value = 'bar'; + $newValue = 'yop'; + $secondKey = 'waza'; + + // First key + $this->keyAuthenticated($admin->account) + ->json($this->method, $this->route . '/' . $account->id . ' /dictionary/' . $key , [ + 'value' => $value + ])->assertStatus(201); + + $this->keyAuthenticated($admin->account) + ->get($this->route . '/' . $account->id . ' /dictionary') + ->assertStatus(200) + ->assertJson([ + $key => $value + ]); + + $this->keyAuthenticated($admin->account) + ->get($this->route . '/' . $account->id) + ->assertStatus(200) + ->assertJson([ + 'dictionary' => [ + $key => $value + ] + ]); + + // Update + $this->keyAuthenticated($admin->account) + ->json($this->method, $this->route . '/' . $account->id . ' /dictionary/' . $key , [ + 'value' => $newValue + ])->assertStatus(200); + + $this->keyAuthenticated($admin->account) + ->get($this->route . '/' . $account->id . ' /dictionary') + ->assertStatus(200) + ->assertJson([ + $key => $newValue + ]); + + // Second key + $this->keyAuthenticated($admin->account) + ->json($this->method, $this->route . '/' . $account->id . ' /dictionary/' . $secondKey , [ + 'value' => $newValue + ])->assertStatus(201); + + + $this->keyAuthenticated($admin->account) + ->get($this->route . '/' . $account->id . ' /dictionary') + ->assertStatus(200) + ->assertJson([ + $key => $newValue, + $secondKey => $newValue + ]); + + // Delete + $this->keyAuthenticated($admin->account) + ->delete($this->route . '/' . $account->id . ' /dictionary/' . $key) + ->assertStatus(200); + + $this->keyAuthenticated($admin->account) + ->get($this->route . '/' . $account->id . ' /dictionary') + ->assertStatus(200) + ->assertJson([ + $secondKey => $newValue + ]); + } +}