mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
Partial fix for better UI on deleting files
Still needs Vue stuff
This commit is contained in:
parent
b2c99c88bb
commit
3f394f42c7
|
@ -114,7 +114,7 @@ class ImportController extends Controller
|
||||||
/**
|
/**
|
||||||
* Processes the specified Import.
|
* Processes the specified Import.
|
||||||
*
|
*
|
||||||
* @param \App\Import $import
|
* @param int $import_id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function process(ItemImportRequest $request, $import_id)
|
public function process(ItemImportRequest $request, $import_id)
|
||||||
|
@ -157,19 +157,25 @@ class ImportController extends Controller
|
||||||
/**
|
/**
|
||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param \App\Import $import
|
* @param int $import_id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function destroy($import_id)
|
public function destroy($import_id)
|
||||||
{
|
{
|
||||||
$this->authorize('create', Asset::class);
|
$this->authorize('create', Asset::class);
|
||||||
$import = Import::find($import_id);
|
$import = Import::find($import_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Try to delete the file
|
||||||
unlink(config('app.private_uploads').'/imports/'.$import->file_path);
|
unlink(config('app.private_uploads').'/imports/'.$import->file_path);
|
||||||
$import->delete();
|
$import->delete();
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/hardware/message.import.file_delete_success')));
|
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/hardware/message.import.file_delete_success')));
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.import.file_delete_error')), 500);
|
// If the file delete didn't work, remove it from the database anyway and return a warning
|
||||||
|
$import->delete();
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('warn', null, trans('admin/hardware/message.import.file_not_deleted_warning')), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,12 @@ return array(
|
||||||
),
|
),
|
||||||
|
|
||||||
'import' => array(
|
'import' => array(
|
||||||
'error' => 'Some items did not import correctly.',
|
'error' => 'Some items did not import correctly.',
|
||||||
'errorDetail' => 'The following Items were not imported because of errors.',
|
'errorDetail' => 'The following Items were not imported because of errors.',
|
||||||
'success' => "Your file has been imported",
|
'success' => "Your file has been imported",
|
||||||
'file_delete_success' => "Your file has been been successfully deleted",
|
'file_delete_success' => "Your file has been been successfully deleted",
|
||||||
'file_delete_error' => "The file was unable to be deleted",
|
'file_delete_error' => "The file was unable to be deleted",
|
||||||
|
'file_not_deleted_warning' => 'The import record was deleted, however the file was unable to be deleted. Check that the file exists in storage/private_uploads/imports/ and manually delete it.',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue