Loading src/components/JamaUploadView.vue +53 −44 Original line number Diff line number Diff line Loading @@ -2,8 +2,18 @@ <v-container> <div ref="rootView"> <div v-if="!isUploading"> <template v-if="Object.keys(uncompletedUploads).length > 0"> <v-btn class="mr-2" small fab color="blue" title="Mettre à jour la liste" @click="updateUncompleteUploads()" > <v-icon>mdi-refresh</v-icon> </v-btn> <v-btn v-if="Object.keys(uncompletedUploads).length > 0" small fab color="warning" Loading @@ -12,6 +22,7 @@ > <v-icon>mdi-delete</v-icon> </v-btn> </template> <span v-else>Aucun upload en cours. </span> </div> <v-container v-else> Loading Loading @@ -39,7 +50,7 @@ v-for="(upload, hash) in uncompletedUploads" :key="'uncomplete-'+hash" > {{ upload.name }} : {{ Math.round(Number(upload.available_chunks.length)/Number(upload.nb_chunks) * 100) }}% {{ upload.name }} : {{ Math.min(Math.round(Number(upload.available_chunks.length)/Number(upload.nb_chunks) * 100),100) }}% <v-btn small class="ml-5" Loading Loading @@ -75,7 +86,6 @@ export default { return { isExpanded: false, isUploading: false, //uncompletedHash : [], uncompletedUploads: {}, progressMessage: '', progressValue: 0, Loading @@ -93,6 +103,7 @@ export default { beforeMount() { window.onbeforeunload = () => { localStorage.setItem(JAMA_LSTORAGE_INCOMPLETED_KEY, JSON.stringify(this.uncompletedUploads)); this.updateUncompleteUploads(); } }, Loading Loading @@ -136,41 +147,27 @@ export default { let upload = e.detail; upload.available_chunks = [];//unknown here this.uncompletedUploads[e.detail.hash] = upload; console.info(' -> added to uncompleted', e.detail.hash); }, endFileUploadEvent(e) { let chunkErrors = e.detail.errors.length > 0 ? e.detail.errors.map(x => Number(x.chunk) + 1).join('/') : null if (chunkErrors) { this.done ++; EventBus.$emit('JAMA_NOTIFICATION', { type: 'error', type: e.detail.ok ? 'success' : 'error', timeout: 2000, message: "Portions " + chunkErrors, message: e.detail.message, visible: true }) } else{ this.done ++ // EventBus.$emit('JAMA_NOTIFICATION', { // type: 'success', // timeout: 1000, // message: "Fichier "+e.detail.name+" téléversé", // visible: true // }) } this.$jamaClient.uploadInfos(e.detail.hash, this.currentProjectId).then((infos) => { if (infos.status === 'available') {//removes from uncompleted if upload complete console.info(' -> REMOVES from uncompleted ! ', e.detail.hash); console.log(Object.keys(this.uncompletedUploads).length); if(e.detail.status === 'available') { delete this.uncompletedUploads[e.detail.hash]; localStorage.setItem(JAMA_LSTORAGE_INCOMPLETED_KEY, JSON.stringify(this.uncompletedUploads)); } console.log(Object.keys(this.uncompletedUploads).length); console.log(Object.values(this.uncompletedUploads).map((u)=>console.log(u.name))); this.progressValue = 0; //this.isUploading = false; this.progressMessage=""; this.$forceUpdate(); }) }, chunkUploadEvent(e) { Loading @@ -195,8 +192,20 @@ export default { empty() { this.uncompletedUploads = {}; } }, async updateUncompleteUploads() { let hashes =Object.keys(this.uncompletedUploads); for(let i = hashes.length -1 ; i >=0 ;i--){ let hash = hashes[i]; let statusInfos = await this.$jamaClient.uploadInfos(hash, this.uncompletedUploads[hash].project); if(statusInfos.status === 'available'){ delete this.uncompletedUploads[hash]; } localStorage.setItem(JAMA_LSTORAGE_INCOMPLETED_KEY, JSON.stringify(this.uncompletedUploads)); this.$forceUpdate(); } } } } </script> Loading src/components/VueJama.vue +4 −0 Original line number Diff line number Diff line Loading @@ -694,6 +694,7 @@ export default { loadCollectionById(id) { this.fetchCollection(id).then(() => { console.log("will load collection", this.currentCollection); this.loadCollection(this.currentCollection); }) }, Loading Loading @@ -739,6 +740,7 @@ export default { }, async manageFilesUpload(files) { console.log("MANAGE FILE UPLOAD START", this.currentCollection); this.loading = true; await this.$store.dispatch('manageFilesUpload', { files: files, Loading @@ -746,11 +748,13 @@ export default { projectId: this.currentProjectId }); this.loading = false; console.log("MANAGE FILE UPLOAD END", this.currentCollection); this.reloadCurrentCollection(); this.$store.dispatch('fetchCollectionTree', this.currentCollection.id); }, reloadCurrentCollection() { console.log("reload current collection", this.currentCollection); this.loadCollectionById(this.currentCollection.id); }, Loading src/store/JamaStore.js +14 −13 Original line number Diff line number Diff line Loading @@ -318,6 +318,7 @@ export default new Vuex.Store({ async fetchCollection({commit}, id) { let collection = await JamaRPClient.collection(id); console.log("collection fetched", collection) commit('setCurrentCollection', collection); }, Loading Loading @@ -464,33 +465,33 @@ export default new Vuex.Store({ for (let i = 0; i < uploadResults.length; i++) { if (uploadResults[i].already_uploaded) { try { await JamaRPClient.addResourceToCollection(uploadResults[i].id, context.getters.currentCollection.id) await JamaRPClient.addResourceToCollection(uploadResults[i].id, context.getters.currentCollection.id); } catch (e) { console.log(e); console.log('cannot add ' + uploadResults[i].id) } } else { if (uploadResults[i].chunk_errors || uploadResults[i].status === 'bad_format') { errorMessages.push(uploadResults[i].error_message); errorMessages.push(uploadResults[i].message); } } } if (errorMessages.length > 0) { let onError = uploadResults.filter((ur) => !ur.ok); if(onError.length > 0 ) EventBus.$emit('JAMA_NOTIFICATION', { type: 'error', timeout: 3000, message: errorMessages.join('/'), message: `Upload terminé avec ${onError.length} fichier(s) en erreur : ` + onError.map((item) => item.name).join(', '), visible: true }) } else { else EventBus.$emit('JAMA_NOTIFICATION', { type: 'success', timeout: 2000, message: "Upload terminé avec succès", timeout: 3000, message: `Upload terminé avec succès : ${files.length} fichier(s)`, visible: true }) } return uploadResults; }, Loading src/utils/JamaClient.js +131 −1717 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/components/JamaUploadView.vue +53 −44 Original line number Diff line number Diff line Loading @@ -2,8 +2,18 @@ <v-container> <div ref="rootView"> <div v-if="!isUploading"> <template v-if="Object.keys(uncompletedUploads).length > 0"> <v-btn class="mr-2" small fab color="blue" title="Mettre à jour la liste" @click="updateUncompleteUploads()" > <v-icon>mdi-refresh</v-icon> </v-btn> <v-btn v-if="Object.keys(uncompletedUploads).length > 0" small fab color="warning" Loading @@ -12,6 +22,7 @@ > <v-icon>mdi-delete</v-icon> </v-btn> </template> <span v-else>Aucun upload en cours. </span> </div> <v-container v-else> Loading Loading @@ -39,7 +50,7 @@ v-for="(upload, hash) in uncompletedUploads" :key="'uncomplete-'+hash" > {{ upload.name }} : {{ Math.round(Number(upload.available_chunks.length)/Number(upload.nb_chunks) * 100) }}% {{ upload.name }} : {{ Math.min(Math.round(Number(upload.available_chunks.length)/Number(upload.nb_chunks) * 100),100) }}% <v-btn small class="ml-5" Loading Loading @@ -75,7 +86,6 @@ export default { return { isExpanded: false, isUploading: false, //uncompletedHash : [], uncompletedUploads: {}, progressMessage: '', progressValue: 0, Loading @@ -93,6 +103,7 @@ export default { beforeMount() { window.onbeforeunload = () => { localStorage.setItem(JAMA_LSTORAGE_INCOMPLETED_KEY, JSON.stringify(this.uncompletedUploads)); this.updateUncompleteUploads(); } }, Loading Loading @@ -136,41 +147,27 @@ export default { let upload = e.detail; upload.available_chunks = [];//unknown here this.uncompletedUploads[e.detail.hash] = upload; console.info(' -> added to uncompleted', e.detail.hash); }, endFileUploadEvent(e) { let chunkErrors = e.detail.errors.length > 0 ? e.detail.errors.map(x => Number(x.chunk) + 1).join('/') : null if (chunkErrors) { this.done ++; EventBus.$emit('JAMA_NOTIFICATION', { type: 'error', type: e.detail.ok ? 'success' : 'error', timeout: 2000, message: "Portions " + chunkErrors, message: e.detail.message, visible: true }) } else{ this.done ++ // EventBus.$emit('JAMA_NOTIFICATION', { // type: 'success', // timeout: 1000, // message: "Fichier "+e.detail.name+" téléversé", // visible: true // }) } this.$jamaClient.uploadInfos(e.detail.hash, this.currentProjectId).then((infos) => { if (infos.status === 'available') {//removes from uncompleted if upload complete console.info(' -> REMOVES from uncompleted ! ', e.detail.hash); console.log(Object.keys(this.uncompletedUploads).length); if(e.detail.status === 'available') { delete this.uncompletedUploads[e.detail.hash]; localStorage.setItem(JAMA_LSTORAGE_INCOMPLETED_KEY, JSON.stringify(this.uncompletedUploads)); } console.log(Object.keys(this.uncompletedUploads).length); console.log(Object.values(this.uncompletedUploads).map((u)=>console.log(u.name))); this.progressValue = 0; //this.isUploading = false; this.progressMessage=""; this.$forceUpdate(); }) }, chunkUploadEvent(e) { Loading @@ -195,8 +192,20 @@ export default { empty() { this.uncompletedUploads = {}; } }, async updateUncompleteUploads() { let hashes =Object.keys(this.uncompletedUploads); for(let i = hashes.length -1 ; i >=0 ;i--){ let hash = hashes[i]; let statusInfos = await this.$jamaClient.uploadInfos(hash, this.uncompletedUploads[hash].project); if(statusInfos.status === 'available'){ delete this.uncompletedUploads[hash]; } localStorage.setItem(JAMA_LSTORAGE_INCOMPLETED_KEY, JSON.stringify(this.uncompletedUploads)); this.$forceUpdate(); } } } } </script> Loading
src/components/VueJama.vue +4 −0 Original line number Diff line number Diff line Loading @@ -694,6 +694,7 @@ export default { loadCollectionById(id) { this.fetchCollection(id).then(() => { console.log("will load collection", this.currentCollection); this.loadCollection(this.currentCollection); }) }, Loading Loading @@ -739,6 +740,7 @@ export default { }, async manageFilesUpload(files) { console.log("MANAGE FILE UPLOAD START", this.currentCollection); this.loading = true; await this.$store.dispatch('manageFilesUpload', { files: files, Loading @@ -746,11 +748,13 @@ export default { projectId: this.currentProjectId }); this.loading = false; console.log("MANAGE FILE UPLOAD END", this.currentCollection); this.reloadCurrentCollection(); this.$store.dispatch('fetchCollectionTree', this.currentCollection.id); }, reloadCurrentCollection() { console.log("reload current collection", this.currentCollection); this.loadCollectionById(this.currentCollection.id); }, Loading
src/store/JamaStore.js +14 −13 Original line number Diff line number Diff line Loading @@ -318,6 +318,7 @@ export default new Vuex.Store({ async fetchCollection({commit}, id) { let collection = await JamaRPClient.collection(id); console.log("collection fetched", collection) commit('setCurrentCollection', collection); }, Loading Loading @@ -464,33 +465,33 @@ export default new Vuex.Store({ for (let i = 0; i < uploadResults.length; i++) { if (uploadResults[i].already_uploaded) { try { await JamaRPClient.addResourceToCollection(uploadResults[i].id, context.getters.currentCollection.id) await JamaRPClient.addResourceToCollection(uploadResults[i].id, context.getters.currentCollection.id); } catch (e) { console.log(e); console.log('cannot add ' + uploadResults[i].id) } } else { if (uploadResults[i].chunk_errors || uploadResults[i].status === 'bad_format') { errorMessages.push(uploadResults[i].error_message); errorMessages.push(uploadResults[i].message); } } } if (errorMessages.length > 0) { let onError = uploadResults.filter((ur) => !ur.ok); if(onError.length > 0 ) EventBus.$emit('JAMA_NOTIFICATION', { type: 'error', timeout: 3000, message: errorMessages.join('/'), message: `Upload terminé avec ${onError.length} fichier(s) en erreur : ` + onError.map((item) => item.name).join(', '), visible: true }) } else { else EventBus.$emit('JAMA_NOTIFICATION', { type: 'success', timeout: 2000, message: "Upload terminé avec succès", timeout: 3000, message: `Upload terminé avec succès : ${files.length} fichier(s)`, visible: true }) } return uploadResults; }, Loading
src/utils/JamaClient.js +131 −1717 File changed.Preview size limit exceeded, changes collapsed. Show changes