Add email connections to ticketing settings
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Dashboard\Ticketing\Http\Controllers;
|
namespace Dashboard\Ticketing\Http\Controllers;
|
||||||
|
|
||||||
|
use Dashboard\Ticketing\Models\EmailConnection;
|
||||||
use Dashboard\Ticketing\Models\PriorityLevel;
|
use Dashboard\Ticketing\Models\PriorityLevel;
|
||||||
use Dashboard\Ticketing\Models\TicketingAgentAccess;
|
use Dashboard\Ticketing\Models\TicketingAgentAccess;
|
||||||
use Dashboard\Ticketing\Models\TicketingGroup;
|
use Dashboard\Ticketing\Models\TicketingGroup;
|
||||||
@@ -95,11 +96,16 @@ class TicketingSettingsController extends Controller
|
|||||||
->orderBy('name')
|
->orderBy('name')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
$emailConnections = $isBootstrap
|
||||||
|
? collect()
|
||||||
|
: EmailConnection::whereIn('group_id', $myGroupIds)->get();
|
||||||
|
|
||||||
return Inertia::render('Ticketing/Settings', [
|
return Inertia::render('Ticketing/Settings', [
|
||||||
'groups' => $groups,
|
'groups' => $groups,
|
||||||
'agents' => $agents,
|
'agents' => $agents,
|
||||||
'priorities' => $priorities,
|
'priorities' => $priorities,
|
||||||
'projects' => $projects,
|
'projects' => $projects,
|
||||||
|
'emailConnections' => $emailConnections,
|
||||||
'myGroupIds' => $myGroupIds,
|
'myGroupIds' => $myGroupIds,
|
||||||
'isBootstrap' => $isBootstrap,
|
'isBootstrap' => $isBootstrap,
|
||||||
'isSiteAdmin' => $this->isSiteAdmin(),
|
'isSiteAdmin' => $this->isSiteAdmin(),
|
||||||
@@ -323,4 +329,65 @@ class TicketingSettingsController extends Controller
|
|||||||
|
|
||||||
return back()->with('success', 'Project removed.');
|
return back()->with('success', 'Project removed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function storeEmailConnection(Request $request)
|
||||||
|
{
|
||||||
|
$this->requireAgentAccess();
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'group_id' => 'required|exists:ticketing_groups,id',
|
||||||
|
'type' => 'required|in:gmail,imap',
|
||||||
|
'active' => 'boolean',
|
||||||
|
'config.host' => 'nullable|string|max:255',
|
||||||
|
'config.port' => 'nullable|integer',
|
||||||
|
'config.username' => 'nullable|string|max:255',
|
||||||
|
'config.password' => 'nullable|string|max:500',
|
||||||
|
'config.encryption' => 'nullable|in:ssl,tls,none',
|
||||||
|
'config.mailbox' => 'nullable|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->requireManagerAccess($validated['group_id']);
|
||||||
|
|
||||||
|
EmailConnection::create([
|
||||||
|
'group_id' => $validated['group_id'],
|
||||||
|
'type' => $validated['type'],
|
||||||
|
'active' => $request->boolean('active', true),
|
||||||
|
'config' => $request->input('config', []),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', 'Email connection saved.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateEmailConnection(Request $request, EmailConnection $connection)
|
||||||
|
{
|
||||||
|
$this->requireAgentAccess();
|
||||||
|
$this->requireManagerAccess($connection->group_id);
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'type' => 'required|in:gmail,imap',
|
||||||
|
'active' => 'boolean',
|
||||||
|
'config.host' => 'nullable|string|max:255',
|
||||||
|
'config.port' => 'nullable|integer',
|
||||||
|
'config.username' => 'nullable|string|max:255',
|
||||||
|
'config.password' => 'nullable|string|max:500',
|
||||||
|
'config.encryption' => 'nullable|in:ssl,tls,none',
|
||||||
|
'config.mailbox' => 'nullable|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$connection->update([
|
||||||
|
'type' => $request->type,
|
||||||
|
'active' => $request->boolean('active', true),
|
||||||
|
'config' => $request->input('config', $connection->config),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', 'Email connection updated.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroyEmailConnection(EmailConnection $connection)
|
||||||
|
{
|
||||||
|
$this->requireAgentAccess();
|
||||||
|
$this->requireManagerAccess($connection->group_id);
|
||||||
|
$connection->delete();
|
||||||
|
return back()->with('success', 'Email connection removed.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ Route::middleware(['web', 'auth', 'app.access:ticketing'])->prefix('app/ticketin
|
|||||||
Route::post('/settings/projects', [TicketingSettingsController::class, 'storeProject'])->name('settings.projects.store');
|
Route::post('/settings/projects', [TicketingSettingsController::class, 'storeProject'])->name('settings.projects.store');
|
||||||
Route::put('/settings/projects/{project}', [TicketingSettingsController::class, 'updateProject'])->name('settings.projects.update');
|
Route::put('/settings/projects/{project}', [TicketingSettingsController::class, 'updateProject'])->name('settings.projects.update');
|
||||||
Route::delete('/settings/projects/{project}', [TicketingSettingsController::class, 'destroyProject'])->name('settings.projects.destroy');
|
Route::delete('/settings/projects/{project}', [TicketingSettingsController::class, 'destroyProject'])->name('settings.projects.destroy');
|
||||||
|
Route::post('/settings/email', [TicketingSettingsController::class, 'storeEmailConnection'])->name('settings.email.store');
|
||||||
|
Route::put('/settings/email/{connection}', [TicketingSettingsController::class, 'updateEmailConnection'])->name('settings.email.update');
|
||||||
|
Route::delete('/settings/email/{connection}', [TicketingSettingsController::class, 'destroyEmailConnection'])->name('settings.email.destroy');
|
||||||
|
|
||||||
// Ticket routes
|
// Ticket routes
|
||||||
Route::get('/', [TicketController::class, 'index'])->name('index');
|
Route::get('/', [TicketController::class, 'index'])->name('index');
|
||||||
|
|||||||
Reference in New Issue
Block a user