mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
Replace references to @this in importer
This commit is contained in:
parent
34595c266d
commit
8d924b60d7
|
@ -307,9 +307,9 @@
|
||||||
$('#fileupload').fileupload({
|
$('#fileupload').fileupload({
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
done: function(e, data) {
|
done: function(e, data) {
|
||||||
@this.progress_bar_class = 'progress-bar-success';
|
$wire.$set('progress_bar_class', 'progress-bar-success');
|
||||||
@this.progress_message = '<i class="fas fa-check faa-pulse animated"></i> {{ trans('general.notification_success') }}';
|
$wire.$set('progress_message', '<i class="fas fa-check faa-pulse animated"></i> {{ trans('general.notification_success') }}');
|
||||||
@this.progress = 100;
|
$wire.$set('progress', 100);
|
||||||
},
|
},
|
||||||
add: function(e, data) {
|
add: function(e, data) {
|
||||||
data.headers = {
|
data.headers = {
|
||||||
|
@ -317,17 +317,17 @@
|
||||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
|
||||||
};
|
};
|
||||||
data.process().done( function () {data.submit();});
|
data.process().done( function () {data.submit();});
|
||||||
@this.progress = 0;
|
$wire.$set('progress', 0);
|
||||||
@this.clearMessage();
|
$wire.clearMessage();
|
||||||
},
|
},
|
||||||
progress: function(e, data) {
|
progress: function(e, data) {
|
||||||
@this.progress = parseInt((data.loaded / data.total * 100, 10));
|
$wire.$set('progress', parseInt((data.loaded / data.total * 100, 10)));
|
||||||
@this.progress_message = '{{ trans('general.uploading') }}';
|
$wire.$set('progress_message', '{{ trans('general.uploading') }}');
|
||||||
},
|
},
|
||||||
fail: function() {
|
fail: function() {
|
||||||
@this.progress_bar_class = "progress-bar-danger";
|
$wire.$set('progress_bar_class', "progress-bar-danger");
|
||||||
@this.progress = 100;
|
$wire.$set('progress', 100);
|
||||||
@this.progress_message = '<i class="fas fa-exclamation-triangle faa-pulse animated"></i> {{ trans('general.upload_error') }}';
|
$wire.$set('progress_message', '<i class="fas fa-exclamation-triangle faa-pulse animated"></i> {{ trans('general.upload_error') }}');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -338,28 +338,28 @@
|
||||||
// we have to hook up to the `<tr id='importer-file'>` at the root of this display,
|
// we have to hook up to the `<tr id='importer-file'>` at the root of this display,
|
||||||
// because the #import button isn't visible until you click an import_type
|
// because the #import button isn't visible until you click an import_type
|
||||||
$('#upload-table').on('click', '#import', function () {
|
$('#upload-table').on('click', '#import', function () {
|
||||||
if(!@this.activeFile.import_type) {
|
if (!$wire.$get('activeFile.import_type')) {
|
||||||
@this.statusType='error';
|
$wire.$set('statusType', 'error');
|
||||||
@this.statusText= "An import type is required... "; //TODO: translate?
|
$wire.$set('statusText', "An import type is required... "); //TODO: translate?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@this.statusType ='pending';
|
$wire.$set('statusType', 'pending');
|
||||||
@this.statusText = '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('admin/hardware/form.processing_spinner') }}';
|
$wire.$set('statusText', '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('admin/hardware/form.processing_spinner') }}');
|
||||||
@this.generate_field_map().then(function (mappings_raw) {
|
$wire.generate_field_map().then(function (mappings_raw) {
|
||||||
var mappings = JSON.parse(mappings_raw)
|
var mappings = JSON.parse(mappings_raw)
|
||||||
// console.warn("Here is the mappings:")
|
// console.warn("Here is the mappings:")
|
||||||
// console.dir(mappings)
|
// console.dir(mappings)
|
||||||
// console.warn("Uh, active file id is, I guess: "+@this.activeFile.id)
|
// console.warn("Uh, active file id is, I guess: "+$wire.$set('activeFile.id'))
|
||||||
var this_file = @this.file_id; // okay, I actually don't know what I'm doing here.
|
var this_file = $wire.$get('file_id'); // okay, I actually don't know what I'm doing here.
|
||||||
$.post({
|
$.post({
|
||||||
{{-- I want to do something like: route('api.imports.importFile', $activeFile->id) }} --}}
|
{{-- I want to do something like: route('api.imports.importFile', $activeFile->id) }} --}}
|
||||||
url: "api/v1/imports/process/"+this_file, // maybe? Good a guess as any..FIXME. HARDCODED DUMB FILE
|
url: "api/v1/imports/process/"+this_file, // maybe? Good a guess as any..FIXME. HARDCODED DUMB FILE
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
'import-update': !!@this.update,
|
'import-update': !!$wire.$set('update'),
|
||||||
'send-welcome': !!@this.send_welcome,
|
'send-welcome': !!$wire.$set('send_welcome'),
|
||||||
'import-type': @this.activeFile.import_type,
|
'import-type': $wire.$set('activeFile.import_type'),
|
||||||
'run-backup': !!@this.run_backup,
|
'run-backup': !!$wire.$set('run_backup'),
|
||||||
'column-mappings': mappings
|
'column-mappings': mappings
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -367,19 +367,19 @@
|
||||||
}
|
}
|
||||||
}).done( function (body) {
|
}).done( function (body) {
|
||||||
// Success
|
// Success
|
||||||
@this.statusType="success";
|
$wire.$set('statusType', "success");
|
||||||
@this.statusText = "{{ trans('general.success_redirecting') }}";
|
$wire.$set('statusText', "{{ trans('general.success_redirecting') }}");
|
||||||
// console.dir(body)
|
// console.dir(body)
|
||||||
window.location.href = body.messages.redirect_url;
|
window.location.href = body.messages.redirect_url;
|
||||||
}).fail( function (jqXHR, textStatus, error) {
|
}).fail( function (jqXHR, textStatus, error) {
|
||||||
// Failure
|
// Failure
|
||||||
var body = jqXHR.responseJSON
|
var body = jqXHR.responseJSON
|
||||||
if((body) && (body.status) && body.status == 'import-errors') {
|
if((body) && (body.status) && body.status == 'import-errors') {
|
||||||
@this.emit('importError', body.messages);
|
$wire.$dispatch('importError', body.messages);
|
||||||
@this.import_errors = body.messages
|
$wire.$set('import_errors', body.messages);
|
||||||
|
|
||||||
@this.statusType='error';
|
$wire.$set('statusType', 'error');
|
||||||
@this.statusText = "Error";
|
$wire.$set('statusText', "Error");
|
||||||
|
|
||||||
// If Slack/notifications hits API thresholds, we *do* 500, but we never
|
// If Slack/notifications hits API thresholds, we *do* 500, but we never
|
||||||
// actually surface that info.
|
// actually surface that info.
|
||||||
|
@ -390,15 +390,15 @@
|
||||||
// notifications could be sent".
|
// notifications could be sent".
|
||||||
} else {
|
} else {
|
||||||
console.warn("Not import-errors, just regular errors - maybe API limits")
|
console.warn("Not import-errors, just regular errors - maybe API limits")
|
||||||
@this.message_type="warning"
|
$wire.$set('message_type', "warning");
|
||||||
if ((body) && (error in body)) {
|
if ((body) && (error in body)) {
|
||||||
@this.message = body.error ? body.error:"Unknown error - might just be throttling by notifications."
|
$wire.$set('message', body.error ? body.error : "Unknown error - might just be throttling by notifications.");
|
||||||
} else {
|
} else {
|
||||||
@this.message = "{{ trans('general.importer_generic_error') }}"
|
$wire.$set('message', "{{ trans('general.importer_generic_error') }}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@this.activeFile = null; //@this.set('hideDetails')
|
$wire.$set('activeFile', null); //$wire.$set('hideDetails')
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue