mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-30 07:59:50 -08:00
6756dd193e
Cleaning up routes to match laravel-scim-server's recommended implementation Some actually *working* changes for SCIM support?! Whoops, forgot my route file Fix public SCIM routes Removed Ziggy, removed old generated file, yanked Ziggy references Resolves the first set of comments for SCIM Ensure all /api routes have baseUrl prepended Fix the parent:: call to be, uh, actually correct :P Clarify the route-ordering, as it is quite tricky This gets it so that users can actually be saved.. Work around the lack of callbacks with some inheritance Mapped a bunch more fields from SCIM into Snipe-IT's user table More baseUrl shenanigans since we yanked Ziggy :/ Properly map job title and work with some other necessary attributes Map more fields... Finalized basic mapping for core and enterprise namespaces Latest tuned settings for SCIM config to work with Azure (and others)
131 lines
4.6 KiB
Vue
131 lines
4.6 KiB
Vue
|
|
|
|
<script>
|
|
require('blueimp-file-upload');
|
|
var baseUrl = $('meta[name="baseUrl"]').attr('content');
|
|
export default {
|
|
/*
|
|
* The component's data.
|
|
*/
|
|
data() {
|
|
return {
|
|
files: [],
|
|
displayImportModal: false,
|
|
activeFile: null,
|
|
alert: {
|
|
type: null,
|
|
message: null,
|
|
visible: false,
|
|
},
|
|
importErrors: null,
|
|
progress: {
|
|
currentClass: "progress-bar-warning",
|
|
currentPercent: "0",
|
|
statusText: '',
|
|
visible: false
|
|
},
|
|
customFields: [],
|
|
};
|
|
},
|
|
|
|
mounted() {
|
|
window.eventHub.$on('importErrors', this.updateImportErrors);
|
|
this.fetchFiles();
|
|
this.fetchCustomFields();
|
|
let vm = this;
|
|
$('#fileupload').fileupload({
|
|
dataType: 'json',
|
|
done(e, data) {
|
|
vm.progress.currentClass="progress-bar-success";
|
|
vm.progress.statusText = "Success!";
|
|
vm.files = data.result.files.concat(vm.files);
|
|
console.log(data.result.header_row);
|
|
},
|
|
add(e, data) {
|
|
data.headers = {
|
|
"X-Requested-With": 'XMLHttpRequest',
|
|
"X-CSRF-TOKEN": Laravel.csrfToken
|
|
};
|
|
data.process().done( () => {data.submit();});
|
|
vm.progress.visible=true;
|
|
},
|
|
progress(e, data) {
|
|
var progress = parseInt((data.loaded / data.total * 100, 10));
|
|
vm.progress.currentPercent = progress;
|
|
vm.progress.statusText = progress+'% Complete';
|
|
},
|
|
fail(e, data) {
|
|
vm.progress.currentClass = "progress-bar-danger";
|
|
// Display any errors returned from the $.ajax()
|
|
vm.progress.statusText = data.jqXHR.responseJSON.messages;
|
|
}
|
|
})
|
|
},
|
|
|
|
methods: {
|
|
fetchFiles() {
|
|
this.$http.get(baseUrl + 'api/v1/imports')
|
|
.then( ({data}) => this.files = data, // Success
|
|
//Fail
|
|
(response) => {
|
|
this.alert.type="danger";
|
|
this.alert.visible=true;
|
|
this.alert.message="Something went wrong fetching files...";
|
|
});
|
|
},
|
|
fetchCustomFields() {
|
|
this.$http.get(baseUrl + 'api/v1/fields')
|
|
.then( ({data}) => {
|
|
data = data.rows;
|
|
data.forEach((item) => {
|
|
this.customFields.push({
|
|
'id': item.db_column_name,
|
|
'text': item.name,
|
|
})
|
|
})
|
|
});
|
|
},
|
|
deleteFile(file, key) {
|
|
this.$http.delete(baseUrl + 'api/v1/imports/' + file.id)
|
|
.then(
|
|
// Success, remove file from array.
|
|
(response) => {
|
|
this.files.splice(key, 1);
|
|
this.alert.type = response.body.status; // A failed delete can still cause a 200 status code.
|
|
this.alert.visible = true;
|
|
this.alert.message = response.body.messages;
|
|
},
|
|
(response) => {// Fail
|
|
// this.files.splice(key, 1);
|
|
this.alert.type="error";
|
|
this.alert.visible=true;
|
|
this.alert.message=response.body.messages;
|
|
}
|
|
);
|
|
},
|
|
toggleEvent(fileId) {
|
|
window.eventHub.$emit('showDetails', fileId)
|
|
},
|
|
updateAlert(alert) {
|
|
this.alert = alert;
|
|
},
|
|
updateImportErrors(errors) {
|
|
this.importErrors = errors;
|
|
},
|
|
},
|
|
|
|
computed: {
|
|
progressWidth() {
|
|
return "width: "+this.progress.currentPercent*10+'%';
|
|
}
|
|
},
|
|
|
|
components: {
|
|
alert: require('../alert.vue').default,
|
|
errors: require('./importer-errors.vue').default,
|
|
importFile: require('./importer-file.vue').default,
|
|
}
|
|
}
|
|
|
|
</script>
|