Skip to content

Commit

Permalink
#1190 id and url generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelpiano committed Oct 11, 2021
1 parent 048a54e commit 8e0bee1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion components/configuration/VFBUploader/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
12 changes: 8 additions & 4 deletions components/interface/VFBUploader/VFBUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down Expand Up @@ -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);
}

Expand All @@ -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 } }
Expand Down

0 comments on commit 8e0bee1

Please sign in to comment.