Fix #126 Move all the intercome related features under a toggle

This commit is contained in:
Timothée Jaussoin 2023-10-05 17:02:08 +02:00
parent ab6aa88b3c
commit c477973d84
14 changed files with 124 additions and 114 deletions

View file

@ -41,7 +41,8 @@ WEB_PANEL=true # Fully enable/disable the web panels
NEWSLETTER_REGISTRATION_ADDRESS= # Address to contact when a user wants to register to the newsletter
PUBLIC_REGISTRATION=true # Toggle to enable/disable the public registration forms
PHONE_AUTHENTICATION=true # Toggle to enable/disable the SMS support, requires public registration
DEVICES_MANAGEMENT=false # Toggle to enable/disable the devices management support
DEVICES_MANAGEMENT=false # Toggle to enable/disable the devices management supporttrue
INTERCOM_FEATURES=false # Toggle to enable/disable the intercom related features
TERMS_OF_USE_URL= # A URL pointing to the Terms of Use
PRIVACY_POLICY_URL= # A URL pointing to the Privacy Policy

View file

@ -51,8 +51,6 @@ class AccountTypeController extends Controller
$accountType->key = $request->get('key');
$accountType->save();
$request->session()->flash('success', 'Type successfully created');
return redirect()->route('admin.account.type.index');
}
@ -78,8 +76,6 @@ class AccountTypeController extends Controller
$accountType->key = $request->get('key');
$accountType->save();
$request->session()->flash('success', 'Type successfully updated');
return redirect()->route('admin.account.type.index');
}
@ -95,8 +91,6 @@ class AccountTypeController extends Controller
$type = AccountType::findOrFail($typeId);
$type->delete();
$request->session()->flash('success', 'Type successfully destroyed');
Log::channel('events')->info('Web Admin: Account type deleted', ['type' => $type->key]);
return redirect()->route('admin.account.type.index');

View file

@ -22,6 +22,7 @@ return [
'newsletter_registration_address' => env('NEWSLETTER_REGISTRATION_ADDRESS', ''),
'phone_authentication' => env('PHONE_AUTHENTICATION', true),
'public_registration' => env('PUBLIC_REGISTRATION', true),
'intercom_features' => env('INTERCOM_FEATURES', false),
'devices_management' => env('DEVICES_MANAGEMENT', false),
'web_panel' => env('WEB_PANEL', true),

View file

@ -113,6 +113,10 @@ pre {
color: var(--second-7);
}
em {
font-style: italic;
}
pre {
overflow: auto;
background-color: var(--second-8);

View file

@ -1,9 +1,12 @@
@extends('layouts.main', ['grid' => true])
@section('breadcrumb')
<li class="breadcrumb-item active" aria-current="page">
API Key
</li>
@endsection
@section('content')
<header>
<h1><i class="material-icons-outlined">dashboard</i> Dashboard</h1>
</header>
<div class="large">
<h2><i class="material-icons-outlined">key</i>API Key</h2>

View file

@ -102,6 +102,10 @@ The deletion of an account is definitive, all the database related data (passwor
### Create, edit and delete account types
@if (config('app.intercom_features') == false)
*The feature is not enabled on this instance.*
@endif
An adminisator can create, edit and delete account types. Those can be used to categorize accounts in clients, they are often used for Internet of Things related devices.
## Statistics

View file

@ -20,7 +20,7 @@
@endif
<form method="POST"
action="{{ $action->id ? route('admin.account.acton.update', [$action->account->id, $action->id]) : route('admin.account.action.store') }}"
action="{{ $action->id ? route('admin.account.acton.update', [$action->account->id, $action->id]) : route('admin.account.action.store', $account->id) }}"
accept-charset="UTF-8">
@method($action->id ? 'put' : 'post')
@csrf

View file

@ -203,53 +203,55 @@
</p>
@endif
<h2>Actions</h2>
@if(config('app.intercom_features'))
<h2>Actions</h2>
@if ($account->dtmf_protocol)
<table class="table">
<tbody>
@foreach ($account->actions as $action)
<tr>
<th scope="row">{{ $action->key }}</th>
<td>{{ $action->code }}</td>
<td>
<a class="btn"
href="{{ route('admin.account.action.edit', [$account, $action->id]) }}">Edit</a>
<a class="btn"
href="{{ route('admin.account.action.delete', [$account, $action->id]) }}">Delete</a>
</td>
</tr>
@endforeach
</tbody>
</table>
<a class="btn" href="{{ route('admin.account.action.create', $account) }}">Add</a>
@else
<p>To manage actions, you must configure the DTMF protocol in the account settings.</p>
@endif
<h2>Types</h2>
@if ($account->dtmf_protocol)
<table class="table">
<tbody>
@foreach ($account->actions as $action)
@foreach ($account->types as $type)
<tr>
<th scope="row">{{ $action->key }}</th>
<td>{{ $action->code }}</td>
<th scope="row">{{ $type->key }}</th>
<td>
<a class="btn"
href="{{ route('admin.account.action.edit', [$account, $action->id]) }}">Edit</a>
<a class="btn"
href="{{ route('admin.account.action.delete', [$account, $action->id]) }}">Delete</a>
<form method="POST"
action="{{ route('admin.account.account_type.destroy', [$account, $type->id]) }}"
accept-charset="UTF-8">
@csrf
@method('delete')
<input class="btn" type="submit" value="Delete">
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
<a class="btn" href="{{ route('admin.account.action.create', $account) }}">Add</a>
@else
<p>To manage actions, you must configure the DTMF protocol in the account settings.</p>
<a class="btn" href="{{ route('admin.account.account_type.create', $account) }}">Add</a>
@endif
<h2>Types</h2>
<table class="table">
<tbody>
@foreach ($account->types as $type)
<tr>
<th scope="row">{{ $type->key }}</th>
<td>
<form method="POST"
action="{{ route('admin.account.account_type.destroy', [$account, $type->id]) }}"
accept-charset="UTF-8">
@csrf
@method('delete')
<input class="btn" type="submit" value="Delete">
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
<a class="btn" href="{{ route('admin.account.account_type.create', $account) }}">Add</a>
@endif
@endsection

View file

@ -13,6 +13,12 @@
<i class="material-icons-outlined">publish</i>
Import Accounts
</a>
@if(config('app.intercom_features'))
<a class="btn btn-secondary" href="{{ route('admin.account.type.index') }}">
<i class="material-icons-outlined">category</i>
Types
</a>
@endif
<a class="btn" href="{{ route('admin.account.create') }}">
<i class="material-icons-outlined">add_circle</i>
New Account

View file

@ -4,9 +4,12 @@
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
<li class="breadcrumb-item">
<a href="{{ route('admin.account.type.index') }}">Types</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
@if ($type->id)Edit @else Create @endif
</li>
@endsection
@section('content')

View file

@ -1,44 +1,42 @@
@extends('layouts.main')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
<li class="breadcrumb-item" aria-current="page">
<a href="{{ route('admin.account.type.index') }}">Types</a>
</li>
<li class="breadcrumb-item">
<a href="{{ route('admin.account.index') }}">Accounts</a>
</li>
<li class="breadcrumb-item" aria-current="page">
<a href="{{ route('admin.account.type.index') }}">Types</a>
</li>
@endsection
@section('content')
<header>
<h1><i class="material-icons-outlined">category</i> Types</h1>
<a class="btn oppose" href="{{ route('admin.account.type.create') }}">
<i class="material-icons-outlined">add</i>
New Type
</a>
</header>
<div class="row mb-2">
<div class="col-sm">
<a class="btn btn-success float-right" href="{{ route('admin.account.type.create') }}">Create</a>
<h2>Types</h2>
</div>
</div>
<table class="table">
<thead>
<tr>
<th>Key</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach ($types as $type)
<table class="table">
<thead>
<tr>
<td>
{{ $type->key }}
</td>
<td>
<a class="btn" href="{{ route('admin.account.type.edit', [$type->id]) }}">Edit</a>
<a class="btn" href="{{ route('admin.account.type.delete', [$type->id]) }}">Delete</a>
</td>
<th>Key</th>
<th></th>
</tr>
@endforeach
</tbody>
</table>
@endsection
</thead>
<tbody>
@foreach ($types as $type)
<tr>
<td>
{{ $type->key }}
</td>
<td>
<a class="btn" href="{{ route('admin.account.type.edit', [$type->id]) }}">Edit</a>
<a class="btn btn-secondary" href="{{ route('admin.account.type.delete', [$type->id]) }}">Delete</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@endsection

View file

@ -59,7 +59,7 @@
@hasSection('breadcrumb')
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('account.dashboard') }}">Home</a></li>
<li class="breadcrumb-item"><a href="{{ route('account.dashboard') }}">Dashboard</a></li>
@yield('breadcrumb')
</ol>
</nav>

View file

@ -1,8 +0,0 @@
@hasSection('breadcrumb')
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('account.dashboard') }}">Home</a></li>
@yield('breadcrumb')
</ol>
</nav>
@endif

View file

@ -166,21 +166,32 @@ if (config('app.web_panel')) {
Route::post('handle', 'handle')->name('handle');
});
Route::name('type.')->prefix('types')->controller(AccountTypeController::class)->group(function () {
Route::get('/', 'index')->name('index');
Route::get('create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::get('{type_id}/edit', 'edit')->name('edit');
Route::put('{type_id}', 'update')->name('update');
Route::get('{type_id}/delete', 'delete')->name('delete');
Route::delete('{type_id}', 'destroy')->name('destroy');
});
if (config('app.intercom_features')) {
Route::name('type.')->prefix('types')->controller(AccountTypeController::class)->group(function () {
Route::get('/', 'index')->name('index');
Route::get('create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::get('{type_id}/edit', 'edit')->name('edit');
Route::put('{type_id}', 'update')->name('update');
Route::get('{type_id}/delete', 'delete')->name('delete');
Route::delete('{type_id}', 'destroy')->name('destroy');
});
Route::name('account_type.')->prefix('{account}/types')->controller(AccountAccountTypeController::class)->group(function () {
Route::get('create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::delete('{type_id}', 'destroy')->name('destroy');
});
Route::name('account_type.')->prefix('{account}/types')->controller(AccountAccountTypeController::class)->group(function () {
Route::get('create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::delete('{type_id}', 'destroy')->name('destroy');
});
Route::name('action.')->prefix('{account}/actions')->controller(AccountActionController::class)->group(function () {
Route::get('create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::get('{action_id}/edit', 'edit')->name('edit');
Route::put('{action_id}', 'update')->name('update');
Route::get('{action_id}/delete', 'delete')->name('delete');
Route::delete('{action_id}', 'destroy')->name('destroy');
});
}
Route::name('contact.')->prefix('{account}/contacts')->controller(AccountContactController::class)->group(function () {
Route::get('create', 'create')->name('create');
@ -199,15 +210,6 @@ if (config('app.web_panel')) {
Route::get('/', 'show')->name('show');
Route::post('/', 'edit')->name('edit');
});
Route::name('action.')->prefix('{account}/actions')->controller(AccountActionController::class)->group(function () {
Route::get('create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::get('{action_id}/edit', 'edit')->name('edit');
Route::put('{action_id}', 'update')->name('update');
Route::get('{action_id}/delete', 'delete')->name('delete');
Route::delete('{action_id}', 'destroy')->name('destroy');
});
});
Route::name('contacts_lists.')->prefix('contacts_lists')->controller(ContactsListController::class)->group(function () {