Compare commits
1 Commits
master
...
fixed-audi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8450d1931d |
@@ -51,14 +51,21 @@ class UploadedFilesController extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
if (($request->filled('action_type') && ($request->input('action_type') == 'audit'))) {
|
||||||
|
$uploads = self::$map_object_type[$object_type]::withTrashed()->find($id)->audits()
|
||||||
|
->with('adminuser');
|
||||||
|
} else {
|
||||||
$uploads = self::$map_object_type[$object_type]::withTrashed()->find($id)->uploads()
|
$uploads = self::$map_object_type[$object_type]::withTrashed()->find($id)->uploads()
|
||||||
->with('adminuser');
|
->with('adminuser');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$offset = ($request->input('offset') > $uploads->count()) ? $uploads->count() : abs($request->input('offset'));
|
$offset = ($request->input('offset') > $uploads->count()) ? $uploads->count() : abs($request->input('offset'));
|
||||||
$limit = app('api_limit_value');
|
$limit = app('api_limit_value');
|
||||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||||
|
|
||||||
|
|
||||||
// Text search on action_logs fields
|
// Text search on action_logs fields
|
||||||
// We could use the normal Actionlogs text scope, but it's a very heavy query since it's searching across all relations
|
// We could use the normal Actionlogs text scope, but it's a very heavy query since it's searching across all relations
|
||||||
// and we generally won't need that here
|
// and we generally won't need that here
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ abstract class Controller extends BaseController
|
|||||||
'accessories' => Accessory::class,
|
'accessories' => Accessory::class,
|
||||||
'maintenances' => Maintenance::class,
|
'maintenances' => Maintenance::class,
|
||||||
'assets' => Asset::class,
|
'assets' => Asset::class,
|
||||||
|
'audits' => Asset::class,
|
||||||
'components' => Component::class,
|
'components' => Component::class,
|
||||||
'consumables' => Consumable::class,
|
'consumables' => Consumable::class,
|
||||||
'hardware' => Asset::class,
|
'hardware' => Asset::class,
|
||||||
@@ -58,6 +59,7 @@ abstract class Controller extends BaseController
|
|||||||
'accessories' => 'private_uploads/accessories/',
|
'accessories' => 'private_uploads/accessories/',
|
||||||
'maintenances' => 'private_uploads/maintenances/',
|
'maintenances' => 'private_uploads/maintenances/',
|
||||||
'assets' => 'private_uploads/assets/',
|
'assets' => 'private_uploads/assets/',
|
||||||
|
'audits' => 'private_uploads/audits/',
|
||||||
'components' => 'private_uploads/components/',
|
'components' => 'private_uploads/components/',
|
||||||
'consumables' => 'private_uploads/consumables/',
|
'consumables' => 'private_uploads/consumables/',
|
||||||
'hardware' => 'private_uploads/assets/',
|
'hardware' => 'private_uploads/assets/',
|
||||||
@@ -71,6 +73,7 @@ abstract class Controller extends BaseController
|
|||||||
'accessories' => 'accessory',
|
'accessories' => 'accessory',
|
||||||
'maintenances' => 'maintenance',
|
'maintenances' => 'maintenance',
|
||||||
'assets' => 'asset',
|
'assets' => 'asset',
|
||||||
|
'audits' => 'audit',
|
||||||
'components' => 'component',
|
'components' => 'component',
|
||||||
'consumables' => 'consumable',
|
'consumables' => 'consumable',
|
||||||
'hardware' => 'asset',
|
'hardware' => 'asset',
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ class ActionlogsTransformer
|
|||||||
'filename' => $actionlog->filename,
|
'filename' => $actionlog->filename,
|
||||||
'inlineable' => StorageHelper::allowSafeInline($actionlog->uploads_file_path()),
|
'inlineable' => StorageHelper::allowSafeInline($actionlog->uploads_file_path()),
|
||||||
'exists_on_disk' => Storage::exists($actionlog->uploads_file_path()) ? true : false,
|
'exists_on_disk' => Storage::exists($actionlog->uploads_file_path()) ? true : false,
|
||||||
|
'mediatype' => StorageHelper::getMediaType($actionlog->uploads_file_path()),
|
||||||
] : null,
|
] : null,
|
||||||
|
|
||||||
'item' => ($actionlog->item) ? [
|
'item' => ($actionlog->item) ? [
|
||||||
|
|||||||
@@ -466,8 +466,6 @@ class Actionlog extends SnipeModel
|
|||||||
public function uploads_file_url()
|
public function uploads_file_url()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (($this->action_type == 'accepted') || ($this->action_type == 'declined')) {
|
if (($this->action_type == 'accepted') || ($this->action_type == 'declined')) {
|
||||||
return route('log.storedeula.download', ['filename' => $this->filename]);
|
return route('log.storedeula.download', ['filename' => $this->filename]);
|
||||||
}
|
}
|
||||||
@@ -478,6 +476,11 @@ class Actionlog extends SnipeModel
|
|||||||
$object = 'models';
|
$object = 'models';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo - remove audit special case when audits have their own file handling route
|
||||||
|
if ($this->action_type == 'audit') {
|
||||||
|
$object = 'audits';
|
||||||
|
}
|
||||||
|
|
||||||
return route('ui.files.show', [
|
return route('ui.files.show', [
|
||||||
'object_type' => $object,
|
'object_type' => $object,
|
||||||
'id' => $this->item_id,
|
'id' => $this->item_id,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class UploadedFilesPresenter extends Presenter
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function dataTableLayout()
|
public static function dataTableLayout($allow_deletes = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
$layout = [
|
$layout = [
|
||||||
@@ -84,7 +84,11 @@ class UploadedFilesPresenter extends Presenter
|
|||||||
'title' => trans('general.created_at'),
|
'title' => trans('general.created_at'),
|
||||||
'visible' => true,
|
'visible' => true,
|
||||||
'formatter' => 'dateDisplayFormatter',
|
'formatter' => 'dateDisplayFormatter',
|
||||||
], [
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($allow_deletes == 'true') {
|
||||||
|
$layout[] = [
|
||||||
'field' => 'available_actions',
|
'field' => 'available_actions',
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
'sortable' => false,
|
'sortable' => false,
|
||||||
@@ -92,8 +96,8 @@ class UploadedFilesPresenter extends Presenter
|
|||||||
'title' => trans('table.actions'),
|
'title' => trans('table.actions'),
|
||||||
'visible' => true,
|
'visible' => true,
|
||||||
'formatter' => 'deleteUploadFormatter',
|
'formatter' => 'deleteUploadFormatter',
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return json_encode($layout);
|
return json_encode($layout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
@props([
|
@props([
|
||||||
'object',
|
'object',
|
||||||
'object_type' => '',
|
'object_type' => '',
|
||||||
|
'action_type' => null,
|
||||||
|
'allow_deletes' => true,
|
||||||
])
|
])
|
||||||
|
|
||||||
<!-- begin non-ajaxed file listing table -->
|
<!-- begin non-ajaxed file listing table -->
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table
|
<table
|
||||||
data-columns="{{ \App\Presenters\UploadedFilesPresenter::dataTableLayout() }}"
|
data-columns="{{ \App\Presenters\UploadedFilesPresenter::dataTableLayout($allow_deletes) }}"
|
||||||
data-cookie-id-table="{{ $object_type }}-FileUploadsTable"
|
data-cookie-id-table="{{ $object_type }}-FileUploadsTable"
|
||||||
data-id-table="{{ $object_type }}-FileUploadsTable"
|
data-id-table="{{ $object_type }}-FileUploadsTable"
|
||||||
id="{{ $object_type }}-FileUploadsTable"
|
id="{{ $object_type }}-FileUploadsTable"
|
||||||
@@ -18,7 +20,11 @@
|
|||||||
data-show-custom-view="true"
|
data-show-custom-view="true"
|
||||||
data-custom-view="customViewFormatter"
|
data-custom-view="customViewFormatter"
|
||||||
data-show-custom-view-button="true"
|
data-show-custom-view-button="true"
|
||||||
data-url="{{ route('api.files.index', ['object_type' => $object_type, 'id' => $object->id]) }}"
|
data-url="{{ route('api.files.index', [
|
||||||
|
'object_type' => $object_type,
|
||||||
|
'id' => $object->id,
|
||||||
|
'action_type' => $action_type]
|
||||||
|
) }}"
|
||||||
class="table table-striped snipe-table"
|
class="table table-striped snipe-table"
|
||||||
data-export-options='{
|
data-export-options='{
|
||||||
"fileName": "export-uploads-{{ str_slug($object->name) }}-{{ date('Y-m-d') }}",
|
"fileName": "export-uploads-{{ str_slug($object->name) }}-{{ date('Y-m-d') }}",
|
||||||
|
|||||||
@@ -1372,35 +1372,11 @@
|
|||||||
<!-- checked out assets table -->
|
<!-- checked out assets table -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<table
|
<x-filestable
|
||||||
class="table table-striped snipe-table"
|
object_type="assets"
|
||||||
id="assetAuditHistory"
|
action_type="audit"
|
||||||
data-id-table="assetAuditHistory"
|
allow_deletes="false"
|
||||||
data-side-pagination="server"
|
:object="$asset" />
|
||||||
data-sort-order="desc"
|
|
||||||
data-sort-name="created_at"
|
|
||||||
data-export-options='{
|
|
||||||
"fileName": "export-asset-{{ $asset->id }}-audits",
|
|
||||||
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
|
|
||||||
}'
|
|
||||||
data-url="{{ route('api.activity.index', ['item_id' => $asset->id, 'item_type' => 'asset', 'action_type' => 'audit']) }}"
|
|
||||||
data-cookie-id-table="assetHistory"
|
|
||||||
data-cookie="true">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-visible="true" data-field="icon" style="width: 40px;" class="hidden-xs" data-formatter="iconFormatter">{{ trans('admin/hardware/table.icon') }}</th>
|
|
||||||
<th data-visible="true" data-field="created_at" data-sortable="true" data-formatter="dateDisplayFormatter">{{ trans('general.date') }}</th>
|
|
||||||
<th data-visible="true" data-field="admin" data-formatter="usersLinkObjFormatter">{{ trans('general.created_by') }}</th>
|
|
||||||
<th class="col-sm-2" data-field="file" data-sortable="true" data-visible="false" data-formatter="fileNameFormatter">{{ trans('general.file_name') }}</th>
|
|
||||||
<th data-field="note">{{ trans('general.notes') }}</th>
|
|
||||||
<th data-visible="false" data-field="file" data-visible="false" data-formatter="fileDownloadButtonsFormatter">{{ trans('general.download') }}</th>
|
|
||||||
<th data-field="log_meta" data-visible="true" data-formatter="changeLogFormatter">{{ trans('admin/hardware/table.changed')}}</th>
|
|
||||||
<th data-field="remote_ip" data-visible="false" data-sortable="true">{{ trans('admin/settings/general.login_ip') }}</th>
|
|
||||||
<th data-field="user_agent" data-visible="false" data-sortable="true">{{ trans('admin/settings/general.login_user_agent') }}</th>
|
|
||||||
<th data-field="action_source" data-visible="false" data-sortable="true">{{ trans('general.action_source') }}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- /.row -->
|
</div> <!-- /.row -->
|
||||||
</div> <!-- /.tab-pane history -->
|
</div> <!-- /.tab-pane history -->
|
||||||
|
|||||||
@@ -1348,7 +1348,7 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'api-throttle:api']], fu
|
|||||||
'index'
|
'index'
|
||||||
]
|
]
|
||||||
)->name('api.files.index')
|
)->name('api.files.index')
|
||||||
->where(['object_type' => 'accessories|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
->where(['object_type' => 'accessories|audits|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
||||||
|
|
||||||
// Get a file
|
// Get a file
|
||||||
Route::get('{object_type}/{id}/files/{file_id}',
|
Route::get('{object_type}/{id}/files/{file_id}',
|
||||||
@@ -1357,7 +1357,7 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'api-throttle:api']], fu
|
|||||||
'show'
|
'show'
|
||||||
]
|
]
|
||||||
)->name('api.files.show')
|
)->name('api.files.show')
|
||||||
->where(['object_type' => 'accessories|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
->where(['object_type' => 'accessories|audits|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
||||||
|
|
||||||
// Upload files(s)
|
// Upload files(s)
|
||||||
Route::post('{object_type}/{id}/files',
|
Route::post('{object_type}/{id}/files',
|
||||||
@@ -1366,7 +1366,7 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'api-throttle:api']], fu
|
|||||||
'store'
|
'store'
|
||||||
]
|
]
|
||||||
)->name('api.files.store')
|
)->name('api.files.store')
|
||||||
->where(['object_type' => 'accessories|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
->where(['object_type' => 'accessories|audits|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
||||||
|
|
||||||
// Delete files(s)
|
// Delete files(s)
|
||||||
Route::delete('{object_type}/{id}/files/{file_id}/delete',
|
Route::delete('{object_type}/{id}/files/{file_id}/delete',
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ Route::group(['middleware' => 'web'], function () {
|
|||||||
'show'
|
'show'
|
||||||
]
|
]
|
||||||
)->name('ui.files.show')
|
)->name('ui.files.show')
|
||||||
->where(['object_type' => 'assets|maintenances|hardware|models|users|locations|accessories|consumables|licenses|components']);
|
->where(['object_type' => 'accessories|audits|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
||||||
|
|
||||||
// Upload files(s)
|
// Upload files(s)
|
||||||
Route::post('{object_type}/{id}/files',
|
Route::post('{object_type}/{id}/files',
|
||||||
@@ -725,7 +725,7 @@ Route::group(['middleware' => 'web'], function () {
|
|||||||
'store'
|
'store'
|
||||||
]
|
]
|
||||||
)->name('ui.files.store')
|
)->name('ui.files.store')
|
||||||
->where(['object_type' => 'assets|maintenances|hardware|models|users|locations|accessories|consumables|licenses|components']);
|
->where(['object_type' => 'accessories|audits|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
||||||
|
|
||||||
// Delete files(s)
|
// Delete files(s)
|
||||||
Route::delete('{object_type}/{id}/files/{file_id}/delete',
|
Route::delete('{object_type}/{id}/files/{file_id}/delete',
|
||||||
@@ -734,7 +734,7 @@ Route::group(['middleware' => 'web'], function () {
|
|||||||
'destroy'
|
'destroy'
|
||||||
]
|
]
|
||||||
)->name('ui.files.destroy')
|
)->name('ui.files.destroy')
|
||||||
->where(['object_type' => 'assets|maintenances|hardware|models|users|locations|accessories|consumables|licenses|components']);
|
->where(['object_type' => 'accessories|assets|components|consumables|hardware|licenses|locations|maintenances|models|users']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user