Pass urls to vue. Should fix subdirectory issues. (#4054)

This commit is contained in:
Daniel Meltzer 2017-09-28 19:03:04 -04:00 committed by snipe
parent af19e5d976
commit 0a4743210c
13 changed files with 45 additions and 105 deletions

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"version":3,"file":"css/AdminLTE.css","sources":[],"mappings":";;;;;;","sourceRoot":""} {"version":3,"file":"css/AdminLTE.css","sources":[],"mappings":";;;;;;A","sourceRoot":""}

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"version":3,"file":"css/app.css","sources":[],"mappings":";;;;;;;;","sourceRoot":""} {"version":3,"file":"css/app.css","sources":[],"mappings":";;;;;;;;A","sourceRoot":""}

File diff suppressed because one or more lines are too long

View file

@ -1,23 +1,12 @@
{ {
"/build/vue.js": "/build/vue.js",
"/mix.js": "/mix.js",
"/build/app.css": "/build/app.535d8af1016a2377e449920c617f0197.css",
"/build/AdminLTE.css": "/build/AdminLTE.3d8a2b2e33baa060b1b324363ad5e1c2.css",
"/build/overrides.css": "/build/overrides.617623c6a96be3e0cbd11c5d4039ec10.css",
"/css/all.css": "/css/all.css",
"/js/all.js": "/js/all.js",
"/css/app.css": "/css/app.css",
"/css/dist/all.css": "/css/dist/all.css",
"/js/dist/all.js": "/js/dist/all.js",
"/css/AdminLTE.css": "/css/AdminLTE.css",
"/css/overrides.css": "/css/overrides.css",
"/css/skin-blue.css": "/css/skin-blue.css",
"/vue.js": "/vue.js", "/vue.js": "/vue.js",
"/css/AdminLTE.css": "/css/AdminLTE.css",
"/css/app.css": "/css/app.css",
"/css/overrides.css": "/css/overrides.css",
"/vue.js.map": "/vue.js.map", "/vue.js.map": "/vue.js.map",
"/mix.js.map": "/mix.js.map",
"/css/AdminLTE.css.map": "/css/AdminLTE.css.map", "/css/AdminLTE.css.map": "/css/AdminLTE.css.map",
"/css/app.css.map": "/css/app.css.map", "/css/app.css.map": "/css/app.css.map",
"/css/overrides.css.map": "/css/overrides.css.map", "/css/overrides.css.map": "/css/overrides.css.map",
"public/css/dist/all.css": "public/css/dist/all.css", "/public/css/dist/all.css": "/public/css/dist/all.css",
"public/js/dist/all.js": "public/js/dist/all.js" "/public/js/dist/all.js": "/public/js/dist/all.js"
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

BIN
public/js/dist/all.js vendored

Binary file not shown.

View file

@ -67,7 +67,7 @@ tr {
<script> <script>
export default { export default {
props: ['file'], props: ['file', 'customFieldUrl', 'importProcessUrl'],
data() { data() {
return { return {
activeFile: this.file, activeFile: this.file,
@ -142,6 +142,12 @@ tr {
this.populateSelect2ActiveItems(); this.populateSelect2ActiveItems();
}, },
computed: { computed: {
processUrl() {
// Because we need to pass a parameter to the laravel route function
// We get a url 'http://localhost/api/v1/imports/process/DUMMYTEXT'
// But we want to customize that to /api/v1/imports/process/this_file
return this.importProcessUrl.replace('DUMMYTEXT', this.file.id)
},
columns() { columns() {
switch(this.options.importType) { switch(this.options.importType) {
case 'asset': case 'asset':
@ -156,7 +162,7 @@ tr {
}, },
methods: { methods: {
fetchCustomFields() { fetchCustomFields() {
this.$http.get('/api/v1/fields') this.$http.get(this.customFieldUrl)
.then( ({data}) => { .then( ({data}) => {
data = data.rows; data = data.rows;
data.forEach((item) => { data.forEach((item) => {
@ -169,22 +175,22 @@ tr {
}, },
postSave() { postSave() {
this.statusText = "Processing..."; this.statusText = "Processing...";
this.$http.post('/api/v1/imports/process/'+this.file.id, { this.$http.post(this.processUrl, {
'import-update': this.options.update, 'import-update': this.options.update,
'import-type': this.options.importType, 'import-type': this.options.importType,
'column-mappings': this.columnMappings 'column-mappings': this.columnMappings
}).then( (response) => { }).then( ({body}) => {
// Success // Success
this.statusText = "Success... Redirecting."; this.statusText = "Success... Redirecting.";
window.location.href = response.body.messages.redirect_url; window.location.href = body.messages.redirect_url;
}, (response) => { }, ({body}) => {
// Failure // Failure
if(response.body.status == 'import-errors') { if(body.status == 'import-errors') {
window.eventHub.$emit('importErrors', response.body.messages); window.eventHub.$emit('importErrors', body.messages);
this.statusText = "Error"; this.statusText = "Error";
} else { } else {
this.$emit('alert', { this.$emit('alert', {
message: response.body.messages, message: body.messages,
type: "danger", type: "danger",
visible: true, visible: true,
}) })

View file

@ -11,6 +11,8 @@ th {
<script> <script>
require('blueimp-file-upload'); require('blueimp-file-upload');
export default { export default {
props: ['importUrl'],
/* /*
* The component's data. * The component's data.
*/ */
@ -72,7 +74,7 @@ th {
methods: { methods: {
fetchFiles() { fetchFiles() {
this.$http.get('/api/v1/imports') this.$http.get(this.importUrl)
.then( ({data}) => this.files = data, // Success .then( ({data}) => this.files = data, // Success
//Fail //Fail
(response) => { (response) => {
@ -82,7 +84,7 @@ th {
}); });
}, },
deleteFile(file, key) { deleteFile(file, key) {
this.$http.delete("/api/v1/imports/"+file.id) this.$http.delete(this.importUrl+"/"+file.id)
.then((response) => this.files.splice(key, 1), // Success, remove file from array. .then((response) => this.files.splice(key, 1), // Success, remove file from array.
(response) => {// Fail (response) => {// Fail
this.alert.type="danger"; this.alert.type="danger";

View file

@ -16,7 +16,7 @@
{{-- Page content --}} {{-- Page content --}}
@section('content') @section('content')
<div id="app"> <div id="app">
<importer inline-template v-cloak> <importer inline-template import-url="{{route('api.imports.index')}}" v-cloak>
<div class="row"> <div class="row">
<alert v-show="alert.visible" :alert-type="alert.type" v-on:hide="alert.visible = false">@{{ alert.message }}</alert> <alert v-show="alert.visible" :alert-type="alert.type" v-on:hide="alert.visible = false">@{{ alert.message }}</alert>
<errors :errors="importErrors"></errors> <errors :errors="importErrors"></errors>
@ -62,7 +62,12 @@
<button class="btn btn-danger" @click="deleteFile(currentFile)"><i class="fa fa-trash icon-white"></i></button> <button class="btn btn-danger" @click="deleteFile(currentFile)"><i class="fa fa-trash icon-white"></i></button>
</td> </td>
</tr> </tr>
<import-file :key="currentFile.id" :file="currentFile" @alert="updateAlert(alert)"> <import-file
:key="currentFile.id"
:file="currentFile"
customFieldUrl="{{route('api.customfields.index')}}"
importProcessUrl="{{route('api.imports.importFile','DUMMYTEXT')}}"
@alert="updateAlert(alert)">
</import-file> </import-file>
</template> </template>
</tbody> </tbody>