Skip to content

Commit

Permalink
added feedback of row count and imported row count
Browse files Browse the repository at this point in the history
  • Loading branch information
goellner committed Jun 14, 2018
1 parent d5800a8 commit 27b7d99
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
18 changes: 16 additions & 2 deletions DataImporter/DataImporterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class DataImporterController extends Controller
*
* @return mixed
*/


private $imported_row_count = 0;

public function index()
{
return $this->view('index');
Expand All @@ -43,9 +47,11 @@ public function showdata()
}

$this->request->session()->put('uploaded_data_keys', $uploaded_data_keys);
$this->request->session()->put('uploaded_row_count', count($uploaded_data));

$data = [
'file' => $uploaded_data
'file' => $uploaded_data,
'row_count' => count($uploaded_data)
];
return $this->view('showdata', $data);
}
Expand Down Expand Up @@ -101,11 +107,18 @@ public function finalize()
$collection = $this->request->session()->get('selected_collection');
$this->save($entries, $collection, $mapping, $array_delimiter);

$data = [
'uploaded_row_count' => $this->request->session()->get('uploaded_row_count'),
'imported_row_count' => $this->imported_row_count
];

$this->request->session()->remove('uploaded_data');
$this->request->session()->remove('uploaded_row_count');
$this->request->session()->remove('selected_collection');
$this->request->session()->remove('selected_collection_fields');

return $this->view('finalize');

return $this->view('finalize', $data);
}

private function save($entries, $collection, $mapping, $array_delimiter)
Expand All @@ -124,6 +137,7 @@ private function save($entries, $collection, $mapping, $array_delimiter)
return $ret;
})->each(function ($entry) use ($collection, $self, $array_delimiter) {
$self->writeEntry($collection, $entry, $array_delimiter);
$this->imported_row_count++;
});
}

Expand Down
2 changes: 1 addition & 1 deletion DataImporter/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: DataImporter
version: "1.0"
version: "1.1.0"
description: Imports data from CSV to collection
developer: Stefan Göllner
developer_url: www.goellner.io
5 changes: 5 additions & 0 deletions DataImporter/resources/views/finalize.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

<div class="flexy mb-24">
<h1>Import done</h1>

</div>

<div class="flexy mb-24">
<p>From <strong>{{ $uploaded_row_count }}</strong> uploaded rows of data <strong>{{ $imported_row_count }}</strong> rows have been imported.</p>
</div>


Expand Down
2 changes: 1 addition & 1 deletion DataImporter/resources/views/showdata.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
<div class="card">
<p class="help-block">
This page shows the first five items of your data. If your data looks good, press continue.
This page shows the first five items of your data. If your data looks good, press continue. Your uploaded file contains <strong>{{ $row_count }}</strong> rows of data.
</p>
</div>
@for ($i = 0; $i < 5; $i++)
Expand Down

0 comments on commit 27b7d99

Please sign in to comment.