From 8e0bee1a92c68560445d16700524ef4e0739b9d4 Mon Sep 17 00:00:00 2001 From: Dario Del Piano Date: Mon, 11 Oct 2021 13:22:59 +0100 Subject: [PATCH] #1190 id and url generation --- .../configuration/VFBUploader/configuration.json | 3 ++- components/interface/VFBUploader/VFBUploader.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/configuration/VFBUploader/configuration.json b/components/configuration/VFBUploader/configuration.json index 66012764c..f6d335057 100644 --- a/components/configuration/VFBUploader/configuration.json +++ b/components/configuration/VFBUploader/configuration.json @@ -9,5 +9,6 @@ "dialogSubtitle" : "File should be swc", "blastButtonText" : "Generate a nblast query link", "dropZoneMessage" : "Click or Drag & Drop your file here", - "infoMessage" : "Generating a nblast query can take up to 30 min. Save this link to find the result of your query." + "infoMessage" : "Generating a nblast query can take up to 30 min. Save this link to find the result of your query.", + "queryType": "uploaderQuery" } \ No newline at end of file diff --git a/components/interface/VFBUploader/VFBUploader.js b/components/interface/VFBUploader/VFBUploader.js index 604efcce4..ef7fd09f8 100644 --- a/components/interface/VFBUploader/VFBUploader.js +++ b/components/interface/VFBUploader/VFBUploader.js @@ -25,6 +25,7 @@ import { withStyles } from "@material-ui/styles"; import axios from "axios"; import { DropzoneArea } from "material-ui-dropzone"; import UploadIcon from "../../configuration/VFBUploader/upload-icon.png"; +import { nanoid } from 'nanoid'; const styles = theme => ({ dropzoneArea: { minHeight: "20vh !important" }, @@ -115,11 +116,12 @@ class VFBUploader extends React.Component { handleNBLASTAction () { this.setState({ nblastEnabled: true }); - let unique_id = Math.floor(10000000 + Math.random() * 90000000).toString(); - unique_id = unique_id + "." + this.state.files[0].name.split(".")[1]; - let url = this.configuration.nblastURL.replace(UNIQUE_ID, unique_id); + let newId = "VFBu_" + nanoid(8); + let url = this.configuration.nblastURL.replace(UNIQUE_ID, this.state.templateSelected + "&" + newId); var formData = new FormData(); formData.append("file", this.state.files[0]); + formData.append("vfbID", newId); + formData.append("templateID", this.state.templateSelected); this.requestUpload(formData, url); } @@ -128,8 +130,10 @@ class VFBUploader extends React.Component { */ requestUpload (formData, url) { let self = this; + let _id = formData.get("vfbID"); + let newURL = window.location.origin + window.location.pathname + "&q=" + _id + "," + this.configuration.queryType; - this.setState({ fileNBLASTURL: url }); + this.setState({ fileNBLASTURL: newURL }); axios.put(url, formData, { headers: { 'Content-Type': this.configuration.contentType } }