Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1216 from modularsoftware/jyyblue
Browse files Browse the repository at this point in the history
Gedcom import improvements.
  • Loading branch information
curtisdelicata authored Jun 5, 2020
2 parents 7aa4526 + ec783e7 commit fa194f8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/Auth/ConfirmPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class ConfirmPasswordController extends Controller
{

use ConfirmsPasswords;

protected $redirectTo = RouteServiceProvider::HOME;
Expand Down
16 changes: 11 additions & 5 deletions app/Http/Controllers/Gedcom/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Person;
use App\Source;
use Asdfx\LaravelGedcom\Facades\GedcomParserFacade;
use Asdfx\LaravelGedcom\Utils\GedcomParser;
use Illuminate\Http\Request;

class Store extends Controller
Expand All @@ -19,18 +20,23 @@ class Store extends Controller
*/

public function __invoke(Request $request)
{
{
if ($request->hasFile('file')) {
if ($request->file('file')->isValid()) {
$request->file->storeAs('gedcom', 'file.ged');
GedcomParserFacade::parse($request->file('file'), true);
try{
$request->file->storeAs('gedcom', 'file.ged');
$parser = new GedcomParser();
$parser->parse($request->file('file'), true);

return ['File uploaded'];
return ['File uploaded'];
}catch(Exception $e){
return ['Not uploaded'];
}
}

return ['File corrupted'];
}

return ['Not uploaded'];
}
}
46 changes: 34 additions & 12 deletions client/src/js/pages/gedcom/Index.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<template>
<div>
<input
type="file"
style="display:none"
@change="selectedFile"
ref="fileInput">
<button @click="$refs.fileInput.click()">Select Gedcom File</button>
<button v-if="file" @click="uploadFile">Upload</button>
<div>
<input
type="file"
style="display:none"
@change="selectedFile"
ref="fileInput"
accept="GED"/>
<button @click="$refs.fileInput.click()">Select Gedcom File</button>
<button v-if="file" @click="uploadFile">Upload</button>
</div>
<div>
<progress
max="100"
:value.prop="uploadPercentage"
v-if="uploadPercentage"/>
</div>
</div>
</template>

Expand All @@ -15,29 +24,42 @@ export default {
data() {
return {
file: null,
uploadPercentage: 0,
};
},
computed: {
uploadLink() {
return window.location.origin + '/api/gedcom/store';
return '/api/gedcom/store';
},
},
created() {},
methods: {
selectedFile(event) {
this.file = event.target.files[0];
[this.file] = event.target.files;
this.uploadPercentage = 0;
// console.log(this.uploadPercentage);
},
uploadFile() {
const fd = new FormData();
fd.append('file', this.file, 'file.ged');
axios.post(this.uploadLink, fd).then(res => console.log(res));
axios
.post(this.uploadLink, fd, {
headers: {
'Content-Type': 'multipart/form-data',
},
onUploadProgress: function (progressEvent) {
const pe = Math.round((progressEvent.loaded / progressEvent.total) * 100);
this.uploadPercentage = parseInt(pe, 10);
}.bind(this),
})
.then()
.catch();
},
},
};
</script>

<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>

0 comments on commit fa194f8

Please sign in to comment.