d2800e10690b66bf2ab04804e124958459f0ff0d
chmalee
  Thu Nov 7 11:11:15 2024 -0800
Add a parentDir field to the hubSpace table and make an index on it

diff --git src/hg/js/hgMyData.js src/hg/js/hgMyData.js
index 4baf424..2c6c995 100644
--- src/hg/js/hgMyData.js
+++ src/hg/js/hgMyData.js
@@ -1,17 +1,18 @@
 /* jshint esnext: true */
 var debugCartJson = true;
+var hubNameDefault = "My First Hub";
 
 function prettyFileSize(num) {
     if (!num) {return "n/a";}
     if (num < (1000 * 1024)) {
         return `${(num/1000).toFixed(1)}kb`;
     } else if (num < (1000 * 1000 * 1024)) {
         return `${((num/1000)/1000).toFixed(1)}mb`;
     } else {
         return `${(((num/1000)/1000)/1000).toFixed(1)}gb`;
     }
 }
 
 // make our Uppy instance:
 const uppy = new Uppy.Uppy({
     debug: true,
@@ -929,31 +930,31 @@
                     }
                     // append the batch changes to the bottom of the file list, for some reason
                     // I can't append to the actual Dashboard-files, it must be getting emptied
                     // and re-rendered or something
                     let uppyFilesDiv = document.querySelector(".uppy-Dashboard-progressindicators");
                     if (uppyFilesDiv) {
                         uppyFilesDiv.insertBefore(batchSelectDiv, uppyFilesDiv.firstChild);
                     }
                 }
             }
 
             install() {
                 this.uppy.on("file-added", (file) => {
                     // add default meta data for genome and fileType
                     console.log("file-added");
-                    this.uppy.setFileMeta(file.id, {"genome": defaultDb(), "fileType": defaultFileType(file.name)});
+                    this.uppy.setFileMeta(file.id, {"genome": defaultDb(), "fileType": defaultFileType(file.name), "hubName": hubNameDefault});
                     if (this.uppy.getFiles().length > 1) {
                         this.addBatchSelectsToDashboard();
                     }
                 });
                 this.uppy.on("file-removed", (file) => {
                     // remove the batch change selects if now <2 files present
                     if (this.uppy.getFiles().length < 2) {
                         this.removeBatchSelectsFromDashboard();
                     }
                 });
 
                 this.uppy.on("dashboard:modal-open", () => {
                     // check if there were already files chosen from before:
                     if (this.uppy.getFiles().length > 2) {
                         this.addBatchSelectsToDashboard();
@@ -1000,57 +1001,70 @@
                     render: ({value, onChange}, h) => {
                         return h( 'select',
                             {onChange: e => {
                                 if (e.target.value === "Auto-detect from extension") {
                                     onChange(detectFileType(file.name));
                                 } else {
                                     onChange(e.target.value);
                                 }
                             }},
                             makeTypeSelectOptions().map( (typeObj) => {
                                 return h('option', typeObj, typeObj.label);
                             })
                         );
                     },
                 });
+                fields.push({
+                    id: 'hubName',
+                    name: 'Hub Name',
+                    render: ({value, onChange, required, form}, h) => {
+                        return h('input',
+                            {type: 'text',
+                             required: required,
+                             form: form,
+                             value: hubNameDefault,
+                            }
+                        );
+                    },
+                });
                 return fields;
             },
             restricted: {requiredMetaFields: ["genome", "fileType"]},
             closeModalOnClickOutside: true,
             closeAfterFinish: true,
             theme: 'auto',
             autoOpen: "metaEditor",
         };
         let tusOptions = {
             endpoint: getTusdEndpoint(),
             withCredentials: true,
             retryDelays: null,
         };
         uppy.use(Uppy.Dashboard, uppyOptions);
         uppy.use(Uppy.Tus, tusOptions);
         uppy.use(BatchChangePlugin, {target: Uppy.Dashboard});
         uppy.on('upload-success', (file, response) => {
             const metadata = file.meta;
             const d = new Date(metadata.lastModified);
             newReqObj = {
                 "uploadTime": Date.now(),
                 "lastModified": d.toJSON(),
                 "fileName": metadata.fileName,
                 "fileSize": metadata.fileSize,
                 "fileType": metadata.fileType,
                 "genome": metadata.genome,
-                "hub": ""
+                "hub": metadata.hubName,
             };
             addNewUploadedFileToTable(newReqObj);
         });
     }
     return { init: init,
              uiState: uiState,
            };
 }());
 
 
 
 // when a user reaches this page from the back button we can display our saved state
 // instead of sending another network request
 window.onpopstate = function(event) {
     event.preventDefault();