diff --git a/FIXME.txt b/FIXME.txt new file mode 100644 index 0000000000..8f95bcb814 --- /dev/null +++ b/FIXME.txt @@ -0,0 +1,11 @@ +remove Ziggy +and ziggy-js too +And what is /public/js/snipeit.js ? That looks like a generated file + +The 'flash' (forced refresh/fake refresh) on uploads is dumb +I'm not sure if the order on the uploaded files is right? +The Livewire.first() thing is still dumb (but Id o'nt know that we can fix it). + +Deletes need to work (I got this working before using $.ajax; it's not even hard) + +Then mapping and so on. \ No newline at end of file diff --git a/app/Http/Controllers/ImportsController.php b/app/Http/Controllers/ImportsController.php index 5c2ca6175b..342203846b 100644 --- a/app/Http/Controllers/ImportsController.php +++ b/app/Http/Controllers/ImportsController.php @@ -15,8 +15,8 @@ class ImportsController extends Controller public function index() { $this->authorize('import'); - $imports = (new ImportsTransformer)->transformImports(Import::latest()->get()); + // $imports = (new ImportsTransformer)->transformImports(Import::latest()->get()); - return view('importer/import')->with('imports', $imports); + return view('importer/import'); //->with('imports', $imports); } } diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php new file mode 100644 index 0000000000..1bcd501ba1 --- /dev/null +++ b/app/Http/Livewire/Importer.php @@ -0,0 +1,45 @@ + 'required|string', + 'files.*.created_at' => 'required|string', + 'files.*.filesize' => 'required|integer' + ]; + + public function mount() + { + //$this->files = Import::all(); // this *SHOULD* be how it works, but...it doesn't? + $this->forcerefresh = 0; + } + + public function test() + { + Log::error("Test Button Clicked!!!!"); + } + + public function toggleEvent($id) + { + Log::error("toggled on: ".$id); + $this->processDetails = Import::find($id); + } + + public function render() + { + $this->files = Import::all(); //HACK - slows down renders. + return view('livewire.importer'); + } +} diff --git a/app/Http/Livewire/ImporterFile.php b/app/Http/Livewire/ImporterFile.php new file mode 100644 index 0000000000..552db98371 --- /dev/null +++ b/app/Http/Livewire/ImporterFile.php @@ -0,0 +1,151 @@ + 'Category', + 'company' => 'Company', + 'email' => 'Email', + 'item_name' => 'Item Name', + 'location' => 'Location', + 'maintained' => 'Maintained', + 'manufacturer' => 'Manufacturer', + 'notes' => 'Notes', + 'order_number' => 'Order Number', + 'purchase_cost' => 'Purchase Cost', + 'purchase_date' => 'Purchase Date', + 'quantity' => 'Quantity', + 'requestable' => 'Requestable', + 'serial' => 'Serial Number', + 'supplier' => 'Supplier', + 'username' => 'Username', + 'department' => 'Department', +]; + +$accessories = [ + 'model_number' => 'Model Number', +]; + +$assets = [ + 'asset_tag' => 'Asset Tag', + 'asset_model' => 'Model Name', + 'checkout_class' => 'Checkout Type', + 'checkout_location' => 'Checkout Location', + 'image' => 'Image Filename', + 'model_number' => 'Model Number', + 'full_name' => 'Full Name', + 'status' => 'Status', + 'warranty_months' => 'Warranty Months', +]; + +$consumables = [ + 'item_no' => "Item Number", + 'model_number' => "Model Number", + 'min_amt' => "Minimum Quantity", +]; + +$licenses = [ + 'asset_tag' => 'Assigned To Asset', + 'expiration_date' => 'Expiration Date', + 'full_name' => 'Full Name', + 'license_email' => 'Licensed To Email', + 'license_name' => 'Licensed To Name', + 'purchase_order' => 'Purchase Order', + 'reassignable' => 'Reassignable', + 'seats' => 'Seats', +]; + +$users = [ + 'employee_num' => 'Employee Number', + 'first_name' => 'First Name', + 'jobtitle' => 'Job Title', + 'last_name' => 'Last Name', + 'phone_number' => 'Phone Number', + 'manager_first_name' => 'Manager First Name', + 'manager_last_name' => 'Manager Last Name', + 'activated' => 'Activated', + 'address' => 'Address', + 'city' => 'City', + 'state' => 'State', + 'country' => 'Country', +]; + +class ImporterFile extends Component +{ + public $activeFile; //should this get auto-filled? + public $customFields; + public $importTypes; + public $columnOptions; + public $importType; // too similar to 'TypeS'? + + private function getColumns($type) + { + global $general, $accessories, $assets, $consumables, $licenses, $users; + + $customFields = []; + foreach($this->customFields AS $field) { + $customFields[$field->id] = $field->name; + } + + switch($type) { + case 'asset': + $results = $general + $assets + $customFields; + break; + case 'accessory': + $results = $general + $accessories; + break; + case 'consumable': + $results = $general + $consumables; + break; + case 'license': + $results = $general + $licenses; + break; + case 'user': + $results = $general + $users; + break; + default: + $results = $general; + } + asort($results); // FIXME - this isn't sorting right yet. + return $results; + } + + public function mount() + { + $this->customFields = CustomField::all(); + + $this->importTypes = [ + 'asset' => 'Assets', // TODO - translate! + 'accessory' => 'Accessories', + 'consumable' => 'Consumables', + 'component' => 'Components', + 'license' => 'Licenses', + 'user' => 'Users' + ]; + Log::error("import types: ".print_r($this->importTypes,true)); + + $columnOptions = []; + $this->columnOptions[''] = $this->getColumns(''); //blank mode? I don't know what this is supposed to mean + foreach($this->importTypes AS $type => $name) { + $this->columnOptions[$type] = $this->getColumns($type); + } + } + + public function changeTypes() + { + Log::error("type changed!"); + } + + public function render() + { + return view('livewire.importer-file'); + } +} diff --git a/app/Models/Setting.php b/app/Models/Setting.php index fd02992f75..b0b4f2490f 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -217,7 +217,7 @@ class Setting extends Model * * @author Mogilev Arseny */ - public static function fileSizeConvert($bytes): string + public static function fileSizeConvert(int $bytes): string { $result = 0; $bytes = floatval($bytes); @@ -244,6 +244,7 @@ class Setting extends Model ], ]; + $result = $bytes; // handles the zero case foreach ($arBytes as $arItem) { if ($bytes >= $arItem['VALUE']) { $result = $bytes / $arItem['VALUE']; diff --git a/resources/assets/js/components/alert.vue b/resources/assets/js/components/alert.vue deleted file mode 100644 index 1a20334656..0000000000 --- a/resources/assets/js/components/alert.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - diff --git a/resources/assets/js/components/importer/importer-errors.vue b/resources/assets/js/components/importer/importer-errors.vue deleted file mode 100644 index adc6841d4d..0000000000 --- a/resources/assets/js/components/importer/importer-errors.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - diff --git a/resources/assets/js/components/importer/importer-file.vue b/resources/assets/js/components/importer/importer-file.vue deleted file mode 100644 index eeeed7c722..0000000000 --- a/resources/assets/js/components/importer/importer-file.vue +++ /dev/null @@ -1,325 +0,0 @@ - - - diff --git a/resources/assets/js/components/importer/importer.vue b/resources/assets/js/components/importer/importer.vue deleted file mode 100644 index 474f8f1451..0000000000 --- a/resources/assets/js/components/importer/importer.vue +++ /dev/null @@ -1,130 +0,0 @@ - - - diff --git a/resources/assets/js/vue.js b/resources/assets/js/vue.js index 65cd4393c1..a5b903e51c 100644 --- a/resources/assets/js/vue.js +++ b/resources/assets/js/vue.js @@ -26,10 +26,11 @@ Vue.component( require('./components/passport/PersonalAccessTokens.vue').default ); -Vue.component( - 'importer', - require('./components/importer/importer.vue').default -); +// This component has been removed and replaced with a Livewire implementation +// Vue.component( +// 'importer', +// require('./components/importer/importer.vue').default +// ); // This component has been removed and replaced with a Livewire implementation // Vue.component( diff --git a/resources/views/importer/import.blade.php b/resources/views/importer/import.blade.php index 950f4d73f6..0ec2137538 100644 --- a/resources/views/importer/import.blade.php +++ b/resources/views/importer/import.blade.php @@ -9,112 +9,20 @@ {{-- Page content --}} @section('content') {{-- Hide importer until vue has rendered it, if we continue using vue for other things we should move this higher in the style --}} - - -
- -
- @{{ alert.message }} - - -
-
-
-
- -
- -
-
-
- @{{ progress.statusText }} -
-
-
- -
- - - @if (!config('app.lock_passwords')) - - {{ trans('button.select_file') }} - - - - - @endif - -
- -
- - - -
-
-
- - - - - - - - - - - -
{{ trans('general.file_name') }}{{ trans('general.created_at') }}{{ trans('general.filesize') }}{{ trans('general.actions') }}
-
-
-
-
-
-
-

{{ trans('general.importing') }}

-

{!! trans('general.importing_help') !!}

-
- -
-
-
+THIS IS VUE STUFF ISNT IT? + --}} +@livewire('importer') {{-- Yes, this is stupid - we should be able to route straight over and not have this, but Livewire doesn't work in this app that way :/ --}} @stop @section('moar_scripts') - + --}} @endsection diff --git a/resources/views/livewire/importer-file.blade.php b/resources/views/livewire/importer-file.blade.php new file mode 100644 index 0000000000..3218648fee --- /dev/null +++ b/resources/views/livewire/importer-file.blade.php @@ -0,0 +1,207 @@ +{{-- --}} diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php new file mode 100644 index 0000000000..f998d6363f --- /dev/null +++ b/resources/views/livewire/importer.blade.php @@ -0,0 +1,212 @@ +
+ {{-- --}} {{-- like, this, here, that's a literal Vue directive --}} +
+ {{-- @{{ alert.message }} --}} + + +{{-- alert --}} + + + + {{-- errors thing that's built-in maybe? --}} + {{-- --}} + +
+
+
+
+ +
+ + + +
+ + + @if (!config('app.lock_passwords')) + + {{ trans('admin/importer/general.select_import_file') }} + + + + + @endif + +
+ +
+ + + +
+
+
+
+ + + + + + + + + + + {{-- --}} +
{{ trans('admin/importer/table.file') }}{{ trans('admin/importer/table.created') }}{{ trans('admin/importer/table.size') }}{{ trans('admin/importer/table.process') }}{{ trans('admin/importer/table.delete') }}
+
+
+
+
+
+
+

{{ trans('general.importing') }}

+

{!! trans('general.importing_help') !!}

+
+ +
+ {{--
--}} +
+@push('js') + +@endpush \ No newline at end of file