better frontend with dataset files

This commit is contained in:
Arno Kaimbacher 2018-11-05 16:44:25 +01:00
parent d788410cb5
commit 3b005f4555
13 changed files with 399 additions and 89 deletions

View file

@ -0,0 +1,44 @@
<script>
import Vue from "vue";
let dataset = new Vue({
data: function() {
return {
type: "",
state: "",
rights: null,
project_id: "",
creating_corporation: "GBA",
embargo_date: "",
belongs_to_bibliography: 0,
title_main: {
value: "",
language: ""
},
abstract_main: {
value: "",
language: ""
},
checkedAuthors: [],
checkedLicenses: [], // [],
files: [],
references: [],
checkedContributors: [],
checkedSubmitters: [],
persons: [],
contributors: [],
submitters: []
};
},
created() {
let json = JSON.stringify(this.$data);
this.reset = () => {
Object.assign(this.$data, JSON.parse(json));
};
}
});
export { dataset };
</script>

View file

@ -30,6 +30,7 @@ import axios from 'axios';
//Vue.component('my-autocomplete', require('./components/MyAutocomplete.vue'));
import MyAutocomplete from './components/MyAutocomplete.vue';
import VeeValidate from 'vee-validate';
import { dataset } from './components/Dataset';
// import { Validator } from 'vee-validate';
Vue.use(VeeValidate);
@ -46,41 +47,42 @@ const app = new Vue({
// { qty: 2, value: "Something else", language: 20, type: "additional", sort_order: 0 },
],
serrors: [],
uploadedFiles: [],
uploadError: null,
currentStatus: null,
uploadFieldName: 'photos',
uploadFieldName: 'photos',
fileCount: 0,
persons: [],
contributors: [],
submitters: [],
redirectLink : null,
step: 1,
dataset: {
type: '',
state: '',
rights: null,
project_id: '',
dataset : dataset
// dataset: {
// type: '',
// state: '',
// rights: null,
// project_id: '',
creating_corporation: "GBA",
embargo_date: '',
belongs_to_bibliography: 0,
// creating_corporation: "GBA",
// embargo_date: '',
// belongs_to_bibliography: 0,
title_main: {
value: '',
language: ''
},
abstract_main: {
value: '',
language: ''
},
checkedAuthors: [],
checkedLicenses: [],// [],
files: [],
references: [],
checkedContributors: [],
checkedSubmitters: [],
}
// title_main: {
// value: '',
// language: ''
// },
// abstract_main: {
// value: '',
// language: ''
// },
// checkedAuthors: [],
// checkedLicenses: [],// [],
// files: [],
// references: [],
// checkedContributors: [],
// checkedSubmitters: [],
// }
}
},
created: function () {
@ -121,6 +123,11 @@ const app = new Vue({
this.currentStatus = STATUS_INITIAL;
this.uploadedFiles = [];
this.uploadError = null;
this.dataset.reset();//reset methods will trigger property changed.
this.step = 1;
},
editNewDataset() {
window.location = this.redirectLink;
},
resetDropbox() {
// reset form to initial state
@ -128,7 +135,9 @@ const app = new Vue({
this.dataset.files = [];
},
save() {
// upload data to the server
var _this = this;
this.currentStatus = STATUS_SAVING;
this.serrors = [];
/*
Initialize the form data
@ -201,14 +210,15 @@ const app = new Vue({
// this.items = response.data;
//Vue.set(app.skills, 1, "test55");
_this.currentStatus = STATUS_SUCCESS;
if (response.data.redirect) {
window.location = response.data.redirect;
}
_this.redirectLink = response.data.redirect;
// if (response.data.redirect) {
// window.location = response.data.redirect;
// }
})
.catch((error) => {
// this.loading = false;
// console.log("test");
this.uploadError = error.response;
console.log('FAILURE!!');
let errorObject = JSON.parse(JSON.stringify(error));
// console.log(errorObject);
if (errorObject.response.data.errors) {
@ -254,6 +264,7 @@ const app = new Vue({
this.dataset.references.splice(key, 1);
},
filesChange(fieldName, fileList) {
this.fileCount = fileList.length
// this.dataset.files = this.$refs.files.files;
let uploadedFiles = fileList;
@ -275,24 +286,24 @@ const app = new Vue({
onAddAuthor(person) {
//if person is not in person array
//if (this.persons.includes(person) == false) {
if (this.persons.filter(e => e.id === person.id).length == 0) {
this.persons.push(person);
if (this.dataset.persons.filter(e => e.id === person.id).length == 0) {
this.dataset.persons.push(person);
this.dataset.checkedAuthors.push(person.id);
}
},
onAddContributor(person) {
//if person is not in contributors array
//if (this.contributors.includes(person) == false) {
if (this.contributors.filter(e => e.id === person.id).length == 0) {
this.contributors.push(person);
if (this.dataset.contributors.filter(e => e.id === person.id).length == 0) {
this.dataset.contributors.push(person);
this.dataset.checkedContributors.push(person.id);
}
},
onAddSubmitter(person) {
//if person is not in submitters array
//if (this.submitters.includes(person) == false) {
if (this.submitters.filter(e => e.id === person.id).length == 0) {
this.submitters.push(person);
if (this.dataset.submitters.filter(e => e.id === person.id).length == 0) {
this.dataset.submitters.push(person);
this.dataset.checkedSubmitters.push(person.id);
}
},

View file

@ -2,7 +2,7 @@
@section('content')
<h1 class="title">Documents</h1>
<h1 class="title">Datasets</h1>
<br><br>
@ -10,7 +10,7 @@
<thead>
<th>id</th>
<th>document type</th>
<th>dataset type</th>
<!-- <th>Category</th>
<th>Shelf</th> -->
@ -18,11 +18,13 @@
<tbody>
@foreach($documents as $document)
@foreach($documents as $dataset)
<tr>
<td>{{ $document->id }}</td>
<td>{{ $document->type }}</td>
<td>
<a href="{{ route('frontend.dataset.show', ['id' => $dataset->id]) }}"> {{ $dataset->id }} </a>
</td>
<td>{{ $dataset->type }}</td>
<!-- <td>
if($book->stock > 0)
Available

View file

@ -1,33 +1,70 @@
@extends('layouts.app')
@extends('layouts.app')
@section('content')
<div>
<div id="titlemain-wrapper">
<div class="frontdoor_pagination">
{{-- <a id="pagination-link-hitlist" href="{{ route('settings.document') }}">BACK</a> --}}
<a href="{{ route('frontend.datasets') }}" class="pure-button">
<span class="glyphicon glyphicon-chevron-left" ></span> BACK
</a>
</div>
@foreach ($document->titles as $title)
<h2 class="titlemain"> {{ $title->value }}</h2>
@endforeach
</div>
<section class="post">
<header class="post-header">
</header>
<div class="blog-meta">
created: <?= $dataset->created_at->toDayDateTimeString() ?>
</div>
<div class="post-description">
{{-- @foreach ($dataset->authors as $author)
<em>Author: {{ $author->full_name }}</em>
<br />
@endforeach --}}
@foreach ($dataset->titles as $title)
<em>Main Title: {{ $title->value }}</em>
<br />
@endforeach
@foreach ($dataset->abstracts as $abstract)
<em>Abstract: {{ $abstract->value }}</em>
<br />
@endforeach
@foreach ($authors as $author)
<em>Author: {{ $author->full_name }}</em>
<br />
@endforeach
@foreach ($contributors as $contributor)
<em>Contributor: {{ $contributors->full_name }}</em>
<br />
@endforeach
@foreach ($submitters as $submitter)
<em>Contributor: {{ $submitter->full_name }}</em>
<br />
@endforeach
<div id="result-data">
<div id="abstract">
<ul>
@foreach ($document->abstracts as $abstract)
<li class="abstract preserve-spaces"> {{ $abstract->value }}</p>
@endforeach
</ul>
</div>
<table id="items" class="pure-table pure-table-horizontal">
<thead>
<tr>
<th>Path Name</th>
<th>Label</th>
</tr>
</thead>
<tbody>
@foreach($dataset->files as $key => $file)
<tr>
<td>
@if($file->exists() === true)
<a href="{{ route('settings.file.download', ['id' => $file->id]) }}"> {{ $file->path_name }} </a>
@else
<span class="alert">missing file: {{ $file->path_name }}</span>
@endif
</td>
<td> {{ $file->label }} </td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</section>
</div>
</div>
@stop

View file

@ -16,7 +16,7 @@
<main class="steps pure-form" enctype="multipart/form-data">
{{ csrf_field() }}
<div v-if="step === 1" data-vv-scope="step-1">
<div v-if="step === 1 && isInitial" data-vv-scope="step-1">
<h1>Step One</h1>
<div class="form-group">
@ -71,7 +71,7 @@
</div>
</div>
<div v-if="step === 2" data-vv-scope="step-2">
<div v-if="step === 2 && isInitial" data-vv-scope="step-2">
<h1>Step Two</h1>
<fieldset id="fieldset-general">
<legend>General</legend>
@ -250,7 +250,7 @@
</div>
</div>
<div v-if="step === 3" data-vv-scope="step-3">
<div v-if="step === 3 && isInitial" data-vv-scope="step-3">
<h1>Select authors, contributors, submitters</h1>
<fieldset id="fieldset-general">
@ -263,7 +263,7 @@
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<div class="pure-control-group checkboxlist">
<label v-for="(person, index) in persons" :for="person.id" class="pure-checkbox">
<label v-for="(person, index) in dataset.persons" :for="person.id" class="pure-checkbox">
<input type="checkbox" name="persons" v-bind:value="person.id" v-model="dataset.checkedAuthors" class="form-check-input" data-vv-scope="step-3">
@{{ person.full_name }}
</label>
@ -284,7 +284,7 @@
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<div class="pure-control-group checkboxlist">
<label v-for="(contributor, index) in contributors" :for="contributor.id" class="pure-checkbox">
<label v-for="(contributor, index) in dataset.contributors" :for="contributor.id" class="pure-checkbox">
<input type="checkbox" name="contributors" v-bind:value="contributor.id" v-model="dataset.checkedContributors" class="form-check-input" data-vv-scope="step-3">
@{{ contributor.full_name }}
</label>
@ -303,7 +303,7 @@
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<div class="pure-control-group checkboxlist">
<label v-for="(submitter, index) in submitters" :for="submitter.id" class="pure-checkbox">
<label v-for="(submitter, index) in dataset.submitters" :for="submitter.id" class="pure-checkbox">
<input type="checkbox" name="submitters" v-bind:value="submitter.id" v-model="dataset.checkedSubmitters" class="form-check-input" data-vv-scope="step-3">
@{{ submitter.full_name }}
</label>
@ -327,7 +327,7 @@
</div>
</div>
<div v-if="step === 4" data-vv-scope="step-4">
<div v-if="step === 4 && (isInitial || isSaving)" data-vv-scope="step-4">
<h1>File Upload</h1>
<div class="dropbox">
@ -383,13 +383,36 @@
</div>
<div v-if="serrors.length > 0">
<b>Please correct the following server error(s):</b>
<ul class="alert validation-summary-errors">
<li style="margin-left:5px;" v-for="error in serrors">@{{ error }}</li>
<!--SUCCESS-->
<div v-if="isSuccess">
<h2>Uploaded @{{ dataset.files.length }} file(s) successfully.</h2>
<p>
<a href="javascript:void(0)" @click="reset()" class="pure-button button-small">Upload new Dataset</a>
</p>
<p>
<a href="javascript:void(0)" @click="editNewDataset()" class="pure-button button-small">@{{ redirectLink }}</a>
</p>
<ul class="list-unstyled">
{{-- <li v-for="item in uploadedFiles">
<img :src="item.url" class="img-responsive img-thumbnail" :alt="item.originalName">
</li> --}}
</ul>
</div>
<!--ERROR-->
<div v-if="isFailed">
<h2>Uploaded failed.</h2>
<p>
<a href="javascript:void(0)" @click="reset()">Try again</a>
</p>
<div v-if="serrors.length > 0">
<b>Please correct the following server error(s):</b>
<ul class="alert validation-summary-errors">
<li style="margin-left:5px;" v-for="error in serrors">@{{ error }}</li>
</ul>
</div>
</div>
</main>
{{-- <br/><br/>Debug:@{{ dataset }} --}}