A free open source IT asset/license management system
Everything's all wired up; just need to clean up all the FIXME's and stuff
Brady Wetherington2f94bf96ffc9
diff --git a/FIXME.txt b/FIXME.txtindex 1a644d9b51..96fdaa9f26 100644--- a/FIXME.txt+++ b/FIXME.txt@@ -8,8 +8,10 @@ X - (fixed somehow?!) The Livewire.first() thing is still dumb (but Id o'nt knowX - Deletes need to work (I got this working before using $.ajax; it's not even hard)-Then mapping and so on.+X - Then mapping and so on.-Can we potentially delete whatever that this.$http thing? Or is that some side-effect of Vue.js that we don't get for free? (yes, it was that)+X - Can we potentially delete whatever that this.$http thing? Or is that some side-effect of Vue.js that we don't get for free? (yes, it was that)-I suspect the Alert section is not yet wired up - but should be. Doesn't seem too hard?\ No newline at end of file+X - I suspect the Alert section is not yet wired up - but should be. Doesn't seem too hard?++???? translations on the main import screen seem donked for some inexplicable reason? PRobably we newly-tranlsated them?\ No newline at end of filediff --git a/app/Http/Controllers/ImportsController.php b/app/Http/Controllers/ImportsController.phpdeleted file mode 100644index 342203846b..0000000000--- a/app/Http/Controllers/ImportsController.php+++ /dev/null@@ -1,22 +0,0 @@-<?php--namespace App\Http\Controllers;--use App\Http\Transformers\ImportsTransformer;-use App\Models\Asset;-use App\Models\Import;--class ImportsController extends Controller-{- /**- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View- * @throws \Illuminate\Auth\Access\AuthorizationException- */- public function index()- {- $this->authorize('import');- // $imports = (new ImportsTransformer)->transformImports(Import::latest()->get());-- return view('importer/import'); //->with('imports', $imports);- }-}diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.phpindex f72eae9855..ec8d6ac6f8 100644--- a/app/Http/Livewire/Importer.php+++ b/app/Http/Livewire/Importer.php@@ -30,10 +30,11 @@ class Importer extends Component'files.*.filesize' => 'required|integer'];- protected $listeners = ['hideDetails' => 'hideDetails', 'importError' => 'importError'];+ protected $listeners = ['hideDetails' => 'hideDetails', 'importError' => 'importError', 'alert' => 'alert'];public function mount(){+ //$this->authorize('import'); // FIXME - gotta do this somewhere!!!!!//$this->files = Import::all(); // this *SHOULD* be how it works, but...it doesn't? (note orderBy/get, below)//$this->forcerefresh = 0;$this->progress = -1; // '-1' means 'don't show the progressbar'@@ -52,6 +53,13 @@ class Importer extends Component$this->import_errors = $errors;}+ public function alert($obj)+ {+ \Log::info("Alert object received: ".print_r($obj,true));+ $this->message = $obj;+ $this->message_type = "danger"; // FIXME - when does this get reset? Only when you click the 'x'?+ }+public function toggleEvent($id){Log::error("toggled on: ".$id);@@ -84,6 +92,12 @@ class Importer extends Componentpublic function render(){$this->files = Import::orderBy('id','desc')->get(); //HACK - slows down renders.- return view('livewire.importer');+ return view('livewire.importer')+ ->extends('layouts.default')+ ->section('content')+ ->layoutData(['title', trans('general.import')]); /* return view('livewire.show-posts')+4 ->layout('layouts.base', ['title' => 'Show Posts'])+ ->section('body') // or whatever?+5 */}}diff --git a/app/Http/Livewire/ImporterFile.php b/app/Http/Livewire/ImporterFile.phpindex 052f5ba05d..7766e0b72d 100644--- a/app/Http/Livewire/ImporterFile.php+++ b/app/Http/Livewire/ImporterFile.php@@ -171,78 +171,6 @@ class ImporterFile extends Component$this->statusType = 'pending';$this->statusText = "Processing...";- axios.post('{{ route('api.imports.importFile', $activeFile->id) }}', {- 'import-update': [email protected],- 'send-welcome': [email protected]_welcome,- 'import-type': @this.activeFile.import_type,- 'run-backup': [email protected]_backup,- 'column-mappings': mappings // FIXME - terrible name- }).then( (body) => {- Log::warn("success!!!")- // Success- $this->statusType = "success";- $this->statusText = "Success... Redirecting.";- // FIXME - can we 'flash' an update here?- window.location.href = body.data.messages.redirect_url; // definite fixme here!- }, (body) => {- // Failure- console.warn("failure!!!!")- if(body.response.data.status == 'import-errors') {- //window.eventHub.$emit('importErrors', body.messages);- console.warn("import error")- console.dir(body)- @this.set('statusType','error');- @this.emit('importError', body.response.data.messages)- //@this.set('statusText', "Error: "+body.response.data.messages.join("<br>"));- } else {- console.warn("not import-errors, just regular errors")- console.dir(body)- @this.set('statusType','error');- @this.emit('importError',body.response.data.messages ? body.response.data.messages : {'import-type': ['Unknown error']})- @this.set('statusText',body.response.data.messages ? body.response.data.messages : 'Unknown error');- }- // @this.emit('hideDetails');- });- }-$(function () {- $('#import').on('click',function () {- console.warn("okay, click handler firing!!!")- postSave()- })- console.warn("JS click handler loaded!")- })-window.setTimeout(function() {- var what = @this.dinglefarts- console.warn("What is this: ",what)- },1000)-- $class = title_case($this->option('item-type'));- $classString = "App\\Importer\\{$class}Importer";- $importer = new $classString($filename);- $importer->setCallbacks([$this, 'log'], [$this, 'progress'], [$this, 'errorCallback'])- ->setUserId($this->option('user_id'))- ->setUpdating($this->option('update'))- ->setShouldNotify($this->option('send-welcome'))- ->setUsernameFormat($this->option('username_format'));-- // This $logFile/useFiles() bit is currently broken, so commenting it out for now- // $logFile = $this->option('logfile');- // \Log::useFiles($logFile);- $this->comment('======= Importing Items from '.$filename.' =========');- $importer->import();-- $this->bar = null;-- if (! empty($this->errors)) {- $this->comment('The following Errors were encountered.');- foreach ($this->errors as $asset => $error) {- $this->comment('Error: Item: '.$asset.' failed validation: '.json_encode($error));- }- } else {- $this->comment('All Items imported successfully!');- }- $this->comment('');-}public function changeTypes() // UNUSED?diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.phpindex 90520738d0..d5b10bde3a 100644--- a/app/Providers/RouteServiceProvider.php+++ b/app/Providers/RouteServiceProvider.php@@ -39,7 +39,7 @@ class RouteServiceProvider extends ServiceProvider{Route::group(['middleware' => 'web',- 'namespace' => $this->namespace,+// 'namespace' => $this->namespace, //okay, I don't know what this means, but somehow this might be a problem for us?], function ($router) {require base_path('routes/web/hardware.php');require base_path('routes/web/models.php');@@ -65,7 +65,7 @@ class RouteServiceProvider extends ServiceProvider{Route::group(['middleware' => 'auth:api',- 'namespace' => $this->namespace,+// 'namespace' => $this->namespace, // this might also be a problem? I don't really know :/'prefix' => 'api',], function ($router) {require base_path('routes/api.php');diff --git a/composer.json b/composer.jsonindex abcf675b1a..2f1007fa73 100644--- a/composer.json+++ b/composer.json@@ -127,6 +127,9 @@"sort-packages": true,"optimize-autoloader": true,"discard-changes": true,- "process-timeout": 3000+ "process-timeout": 3000,+ "allow-plugins": {+ "dealerdirect/phpcodesniffer-composer-installer": true+ }}}diff --git a/resources/views/importer/import.blade.php b/resources/views/importer/import.blade.phpdeleted file mode 100644index 22dd8e7c76..0000000000--- a/resources/views/importer/import.blade.php+++ /dev/null@@ -1,34 +0,0 @@-@extends('layouts/default')--{{-- Page title --}}-@section('title')-{{ trans('general.import') }}-@parent-@stop--{{-- 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 --}}- {{-- <style>- [v-cloak] {- display:none;- }--THIS IS VUE STUFF ISNT IT?- </style> --}}-- {{-- YET ANOTHER FIXME! argh. This file shouldn't exist. --}}-- @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')- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>--- {{-- <script nonce="{{ csrf_token() }}">- new Vue({- el: '#app'- });- </script> --}}-@endsectiondiff --git a/resources/views/livewire/importer-file.blade.php b/resources/views/livewire/importer-file.blade.phpindex e80783b281..cf4b6ff520 100644--- a/resources/views/livewire/importer-file.blade.php+++ b/resources/views/livewire/importer-file.blade.php@@ -94,7 +94,7 @@<div class="row"><div class="col-md-6 col-md-offset-2 text-right" style="padding-top: 20px;"><button type="button" class="btn btn-sm btn-default" wire:click="$emit('hideDetails')">Cancel</button>- <button type="submit" class="btn btn-sm btn-primary" id="import" wire:click="postSave">Import</button>+ <button type="submit" class="btn btn-sm btn-primary" id="import">Import</button><br><br></div></div><!-- /div row -->@@ -114,7 +114,57 @@</tr>{{-- </template> --}}<script>-$(function () {+ $('#import').on('click', function () {+ console.log('saving');+ console.log(@this.activeFile.import_type);+ if([email protected]_type) {+ @this.statusType='error';+ @this.statusText= "An import type is required... ";+ return;+ }+ @this.statusType='pending';+ @this.statusText = "Processing...";+ @this.getDinglefartsProperty().then(function (mappings_raw) {+ var mappings = JSON.parse(mappings_raw)+ console.warn("Here is the mappings:")+ console.dir(mappings)+ $.post({+ url: "{{ route('api.imports.importFile', $activeFile->id) }}",+ data: {+ 'import-update': [email protected],+ 'send-welcome': [email protected]_welcome,+ 'import-type': @this.activeFile.import_type,+ 'run-backup': [email protected]_backup,+ 'column-mappings': mappings // THE HARD PART.+ },+ headers: {+ "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')+ }+ }).done( function (body) {+ // Success+ @this.statusType="success";+ @this.statusText = "Success... Redirecting.";+ console.dir(body)+ window.location.href = body.messages.redirect_url;+ }).fail( function (jqXHR, textStatus, error) {+ // Failure+ var body = jqXHR.responseJSON+ if(body.status == 'import-errors') {+ @this.emit('importError', body.messages);+ @this.statusType='error';+ @this.statusText = "Error";+ } else {+ console.warn("Not import-errors, just regular errors")+ console.dir(body)+ @this.emit('alert', body.error)+ }+ @this.emit('hideDetails') // emit something ?+ });+ })+ return false;+ });++ $(function () {console.warn("Setting iCheck callbacks!")$('.iCheck').on('ifToggled', function (event) {console.warn("iCheck checked!")diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.phpindex efa30ac4cf..7ac8c495c3 100644--- a/resources/views/livewire/importer.blade.php+++ b/resources/views/livewire/importer.blade.php@@ -1,3 +1,7 @@+@section('title')+ {{ trans('general.import') }}+ @parent+@stop<div id="not-app">{{-- <importer inline-template v-cloak> --}} {{-- like, this, here, that's a literal Vue directive --}}<div class="row">@@ -22,7 +26,7 @@<div class="box"><div class="box-body"><div class="alert alert-warning">- <strong>Warning</strong> Some Errors occured while importing+ <strong>Warning</strong> Some Errors occurred while importing {{-- FIXME: hardcoded string --}}</div><div class="errors-table">diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.phpindex a0815b4666..dd98550f46 100755--- a/resources/views/users/edit.blade.php+++ b/resources/views/users/edit.blade.php@@ -699,7 +699,7 @@ $(document).ready(function() {data: {},headers: {"X-Requested-With": 'XMLHttpRequest',- "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')+ "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content') // TODO` - we should do this in ajaxSetup},dataType: 'json',diff --git a/routes/web.php b/routes/web.phpindex 4c52918f8e..9c2333bf83 100644--- a/routes/web.php+++ b/routes/web.php@@ -222,11 +222,16 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser||*/-Route::group(['prefix' => 'import', 'middleware' => ['auth']], function () {- Route::get('/',- [ImportsController::class, 'index']- )->name('imports.index');-});++//Route::group(['prefix' => 'import', 'middleware' => ['auth']], function () {+// Route::get('/',+// [ImportsController::class, 'index']+// )->name('imports.index');+//});++Route::get('/import',+ \App\Http\Livewire\Importer::class+)->middleware('auth')->name('imports.index');/*|--------------------------------------------------------------------------