Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use App\Models\User;
use App\Models\SystemPlatform;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
Expand All @@ -23,7 +25,7 @@ class AppUserActivationCrudController extends CrudController
}


/**
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
Expand All @@ -45,74 +47,116 @@ protected function setupListOperation()
{
$this->crud->setColumns([
[
'label' => 'User',
'type' => 'select',
'name' => 'user_id',
'attribute' => 'name',
'key' => 'user_name',
'label' => 'Device',
'type' => 'custom_html',
'name' => 'device',
'value' => function ($entry) {
$friendlyName = $entry->friendly_name ?: '-';
$deviceId = $entry->device_id ?: '-';
return '<div>' . e($friendlyName) . '</div><div class="text-muted small">' . e($deviceId) . '</div>';
},
'escaped' => false,
'priority' => 1
],
[
'label' => 'E-Mail',
'type' => 'select',
'label' => 'User',
'type' => 'custom_html',
'name' => 'user_id',
'attribute' => 'email',
'key' => 'user_email',
'priority' => 2
],
[
'label' => 'Device ID',
'type' => 'text',
'name' => 'device_id',
'priority' => 1
],
[
'label' => 'IP Address',
'type' => 'text',
'name' => 'ip_address',
'value' => function ($entry) {
$user = $entry->user;
if (!$user) {
return '-';
}
return '<div>' . e($user->name) . '</div><div class="text-muted small">' . e($user->email) . '</div>';
},
'escaped' => false,
'priority' => 1
],
[
'label' => 'Bypass',
'type' => 'text',
'name' => 'bypass_formatted',
'label' => 'Group',
'type' => 'select',
'name' => 'group_id',
'attribute' => 'name',
'entity' => 'group',
'key' => 'group_name',
'priority' => 1
],
[
'label' => 'Version',
'type' => 'text',
'name' => 'app_version',
'priority' => 1
],
[
'label' => 'Updated at',
'type' => 'datetime',
'name' => 'updated_at',
'priority' => 1
],
[
'label' => 'OS',
'type' => 'text',
'name' => 'os_formatted',
'type' => 'custom_html',
'name' => 'version',
'value' => function ($entry) {
$appVersion = $entry->app_version ?: '-';
$osFormatted = $entry->os_formatted ?: '-';
return '<div>' . e($appVersion) . '</div><div class="text-muted small">' . e($osFormatted) . '</div>';
},
'escaped' => false,
'priority' => 1,
'orderable' => true,
'orderable' => true,
'orderLogic' => function ($query, $column, $columnDirection) {
return $query->orderBy('platform_name', $columnDirection);
}
],
[
'label' => 'Friendly Name',
'type' => 'text',
'name' => 'friendly_name',
'priority' => 2
],
[
'label' => 'Identifier',
'type' => 'hidden',
'name' => 'identifier',
'searchLogic' => 'text'
]
]);

// Platform filter
CRUD::filter('platform_name')
->type('dropdown')
->label('Platform')
->values([
SystemPlatform::PLATFORM_WIN => 'Windows',
SystemPlatform::PLATFORM_OSX => 'macOS',
])
->whenActive(function ($value) {
CRUD::addClause('where', 'platform_name', $value);
});

// App Version filter
CRUD::filter('app_version')
->type('text')
->label('App Version')
->whenActive(function ($value) {
CRUD::addClause('where', 'app_version', 'LIKE', "%{$value}%");
});

// User filter
CRUD::filter('user_id')
->type('select2')
->label('User')
->values(function () {
return User::all()->pluck('name', 'id')->toArray();
})
->whenActive(function ($value) {
CRUD::addClause('where', 'user_id', $value);
});

// Last Sync Time filter
CRUD::filter('last_sync_time')
->type('date_range')
->label('Last Sync Time')
->whenActive(function ($value) {
$dates = json_decode($value);
if ($dates->from) {
CRUD::addClause('where', 'last_sync_time', '>=', $dates->from);
}
if ($dates->to) {
CRUD::addClause('where', 'last_sync_time', '<=', $dates->to . ' 23:59:59');
}
});

// OS Version filter
CRUD::filter('os_version')
->type('text')
->label('OS Version')
->whenActive(function ($value) {
CRUD::addClause('where', 'os_version', 'LIKE', "%{$value}%");
});
}

/**
Expand All @@ -123,10 +167,10 @@ protected function setupListOperation()
*/
protected function setupCreateOperation()
{
CRUD::setValidation([
]);
CRUD::setValidation([]);

$this->crud->addFields([
$this->crud->addFields(
[
[
'label' => 'User Name',
'type' => 'select',
Expand Down
74 changes: 37 additions & 37 deletions CloudVeilManager/app/Http/Controllers/Admin/UserCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ protected function setupListOperation()
],
[
'label' => 'License Used',
'type' => 'datetime',
'name' => 'updated_at'
'type' => 'text',
'name' => 'license_used',
'value' => function ($entry) {
$used = $entry->activations_used ?? 0;
$allowed = $entry->activations_allowed ?? 0;
return $used . ' of ' . $allowed;
}
],
[
'label' => 'Active',
Expand Down Expand Up @@ -106,67 +111,53 @@ protected function setupFields($fromEdit = true)
}
CRUD::setValidation($validationRules);

$this->crud->addFields([
$this->crud->addFields(
[
[
'type' => 'custom_html',
'name' => 'activations',
'value' => '
<a href="javascript:void(0)" onclick="window.open(\''. backpack_url("app-user-activation") .'?q=\' + encodeURIComponent(crud.field(\'email\').value))">Show Activations</a>
<a href="javascript:void(0)" onclick="window.open(\'' . backpack_url("app-user-activation") . '?q=\' + encodeURIComponent(crud.field(\'email\').value))">Show Activations</a>
',
'tab' => 'Information',
],
[
'label' => 'User Full Name',
'type' => 'text',
'name' => 'name',
'tab' => 'Information'
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-5'],
],
[
'label' => 'User E-Mail',
'type' => 'text',
'name' => 'email',
'tab' => 'Information'
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-5'],
],
[
'label' => 'Enabled',
'type' => 'switch',
'name' => 'is_enabled',
'tab' => 'Information'
],
[
'label' => 'Customer ID',
'type' => 'number',
'name' => 'customer_id',
'tab' => 'Information'
],
[
'label' => 'Password',
'type' => 'password',
'name' => 'password',
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-6'],
'wrapper' => ['class' => 'form-group col-md-2 d-flex pt-3'],
],
[
'label' => 'Password Confirm',
'type' => 'password',
'name' => 'password_verify',
'label' => 'Group',
'type' => 'select2',
'entity' => 'group',
'model' => 'App\Models\Group',
'name' => 'group',
'attribute' => 'name',
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-6'],
],
[
'label' => 'Activations Allowed',
'type' => 'number',
'name' => 'activations_allowed',
'tab' => 'Information'
],
[
'label' => 'Group',
'type' => 'select2',
'entity' => 'group',
'model' => 'App\Models\Group',
'name' => 'group',
'attribute' => 'name',
'tab' => 'Information'
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-6'],
],
[
'label' => 'Roles',
Expand All @@ -175,21 +166,29 @@ protected function setupFields($fromEdit = true)
'model' => 'App\Models\Role',
'attribute' => 'display_name',
'name' => 'roles',
'tab' => 'Information'
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-6'],
],
[
'label' => 'Relaxed Policy Passcode',
'label' => 'Password',
'type' => 'password',
'name' => 'password',
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-6'],
],
[
'label' => 'Relaxed Policy Passcode',
'type' => 'password_revealable',
'name' => 'relaxed_policy_passcode',
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-8'],
'wrapper' => ['class' => 'form-group col-md-6'],
],
[
'label' => 'Enable Relaxed Policy Passcode',
'type' => 'switch',
'name' => 'enable_relaxed_policy_passcode',
'tab' => 'Information',
'wrapper' => ['class' => 'form-group col-md-2 d-flex pt-3'],
'wrapper' => ['class' => 'form-group col-md-6 d-flex pt-3'],
],
[
'name' => 'BypassesPermitted',
Expand Down Expand Up @@ -334,7 +333,8 @@ protected function setupUpdateOperation()
$this->setupFields(true);
}

protected function setupCreateOperation() {
protected function setupCreateOperation()
{
$this->setupFields(false);
}

Expand Down
2 changes: 2 additions & 0 deletions CloudVeilManager/config/backpack/ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@

// JS files that are loaded in all pages, using Laravel's asset() helper
'scripts' => [
// Bootstrap 5 JavaScript - required for dropdowns and collapses
'https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js',
// 'js/example.js',
// 'https://cdn.jsdelivr.net/npm/vue@2.4.4/dist/vue.min.js',
// 'https://cdn.jsdelivr.net/npm/react@16/umd/react.production.min.js',
Expand Down
4 changes: 3 additions & 1 deletion CloudVeilManager/resources/js/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'bootstrap';
// Bootstrap is loaded via CDN in config/backpack/ui.php
// This ensures window.bootstrap is available globally for Backpack's JavaScript
// import 'bootstrap';

/**
* We'll load the axios HTTP library which allows us to easily issue requests
Expand Down
Loading