From cb3b4fc0bf29197ff2066b8f6df5f0ce4d5c352f Mon Sep 17 00:00:00 2001 From: Rory Schadler Date: Fri, 18 Mar 2022 15:06:29 -0400 Subject: [PATCH 1/6] #24: Initial XML Uploader commit Converted vuetify to vue-material, added references to the reference store. --- .../nanomine/DatasetCreateOrSelect.vue | 367 ++++++++++++++++++ .../nanomine/xmlUploader/XmlUploader.vue | 8 + .../nanomine/xmlUploader/xmlUploader.html | 115 +++++- .../pages/nanomine/xmlUploader/xmlUploader.js | 157 +++++++- app/src/router/module/nanomine.js | 2 +- .../nanomine/referenceContainer/index.js | 12 + 6 files changed, 656 insertions(+), 5 deletions(-) create mode 100644 app/src/components/nanomine/DatasetCreateOrSelect.vue diff --git a/app/src/components/nanomine/DatasetCreateOrSelect.vue b/app/src/components/nanomine/DatasetCreateOrSelect.vue new file mode 100644 index 00000000..b2d648ac --- /dev/null +++ b/app/src/components/nanomine/DatasetCreateOrSelect.vue @@ -0,0 +1,367 @@ + + + + + diff --git a/app/src/pages/nanomine/xmlUploader/XmlUploader.vue b/app/src/pages/nanomine/xmlUploader/XmlUploader.vue index 060b1ef1..3ff8074c 100644 --- a/app/src/pages/nanomine/xmlUploader/XmlUploader.vue +++ b/app/src/pages/nanomine/xmlUploader/XmlUploader.vue @@ -1,2 +1,10 @@ + diff --git a/app/src/pages/nanomine/xmlUploader/xmlUploader.html b/app/src/pages/nanomine/xmlUploader/xmlUploader.html index 0a7338a2..e3111f29 100644 --- a/app/src/pages/nanomine/xmlUploader/xmlUploader.html +++ b/app/src/pages/nanomine/xmlUploader/xmlUploader.html @@ -1,5 +1,114 @@ -
-
-

File Upload

+
+
+ + + + + +
+

File Upload

+
+

Description

+

The simplest method to curate your sample into the database is by uploading an MS Excel spreadsheet. For each + sample, select or create a dataset for your sample group, upload a completed Excel template file using the + first uploading box and other supplementary image and raw data files using the second uploading box. The + master Excel template contains all possible fields for nanocomposite sample data and therefore many fields + will remain blank for your sample. Fill in only the parameters applicable to your sample. Customized templates + are available upon request, please contact the NanoMine team if + customization is required. +

+
+
+

Steps

+

+ NOTE: Filesets for samples are grouped into datasets. The files for a sample (images, auxiliary spreadsheet + data, completed Excel template, etc) are uploaded as a set called a fileset. Uploading multiple samples + requires multiple fileset uploads. +

+
    +
  1. + Create a new dataset for the control sample and its related files, then when uploading each additional + sample be sure to select the same dataset that was used for the control sample of the sample group. +
  2. +
  3. + Click here to download the blank MS Excel template (137 kB). (Click here to see an example, 263 kB) +
  4. +
  5. + Fill in the parameters for all applicable cells in the Excel template file. Prepare the supplementary + images and raw data files. +
  6. +
  7. + Select the completed Excel template file in the first uploading box. +
  8. +
  9. + Select the supplementary images and other raw data files in the second uploading box (press "Ctrl" or + "Command" when selecting multiple files), then click Submit to upload your data. +
  10. +
  11. + Wait for the feedback message. Please read the message and follow the instructions if an error message is + displayed. +
  12. +
+
+
+

Note

+
    +
  1. + We recommend you to upload your control sample first and remember its sample ID. +
  2. +
  3. + Upload one sample data at a time (one template Excel file along with supplementary files). +
  4. +
  5. + Rows or sections followed by a "#" sign in the template Excel file can be duplicated. Copy them into + additional rows if needed. +
  6. +
  7. + Acceptable image file format: JPG, PNG, TIF(F). Indicate the full image file name including the extensions + in the corresponding cells in the Excel template file. +
  8. +
+
+
+

Inputs

+
+ +
+
+

Select a completed Excel Template File + Browse + +

+

+ check_circle_outline {{ templateName }} +

+
+
+

+ Select Other Files (including raw data files and image files) + Browse + +

+ + + check_circle_outline + {{ file.fileName }} + + +
+ Submit + Go Back +
+
+ +
+
\ No newline at end of file diff --git a/app/src/pages/nanomine/xmlUploader/xmlUploader.js b/app/src/pages/nanomine/xmlUploader/xmlUploader.js index a6ec5a6d..6601a7e1 100644 --- a/app/src/pages/nanomine/xmlUploader/xmlUploader.js +++ b/app/src/pages/nanomine/xmlUploader/xmlUploader.js @@ -1,5 +1,160 @@ +import { JobMgr } from '@/modules/JobMgr.js' +// import { Auth } from '@/modules/Auth.js' +import ReferenceContainer from '@/components/nanomine/ReferenceContainer.vue' +import Dialog from '@/components/Dialog.vue' +import DatasetCreateOrSelect from '@/components/nanomine/DatasetCreateOrSelect.vue' +import { mapMutations, mapGetters } from 'vuex' + export default { - name: 'XmlUploader', + name: 'XMLUploader', + components: { + ReferenceContainer, + dialogBox: Dialog, + DatasetCreateOrSelect + }, + data: () => ({ + title: 'File Upload', + dialog: false, + templateName: '', + templateUrl: '', + template: null, + files: [], + filesDisplay: [], + templateUploaded: false, + jobId: '', + datasetOptions: { mineOnly: 'always' }, + datasetSelected: null, + references: [ + '10.1063/1.4943679', + '10.1063/1.5046839' + ], + auth: { + // AUTH MOCKED because auth is not yet implemented + isLoggedIn: () => false, + isTestUser: () => false + } + }), + computed: { + ...mapGetters({ + dialogBoxActive: 'dialogBox' + }) + }, + beforeMount: function () { + // this.auth = new Auth() + if (!this.auth.isLoggedIn()) { + this.renderDialog('Login Required', 'Login is required before uploading files.') + } + }, + methods: { + goBack () { + return window.history.go(-1) + }, + datasetSelectedHandler (dataset) { + this.datasetSelected = dataset + }, + setLoading: function () { + this.$store.commit('isLoading') + }, + resetLoading: function () { + this.$store.commit('notLoading') + }, + pickFile () { + this.$refs.myUpload.click() + }, + pickTemplate () { + this.$refs.myTemplate.click() + }, + resetTemplate: function () { + this.templateName = '' + this.templateUrl = '' + this.template = null + this.templateUploaded = false + }, + resetFiles: function () { + this.files = [] + this.filesDisplay = [] + }, + onTemplatePicked (e) { + this.resetTemplate() + const files = e.target.files + const file = {} + const f = files[0] + if (f !== undefined) { + this.templateName = f.name + file.fileName = this.templateName + const fr = new FileReader() + fr.readAsDataURL(f) + fr.addEventListener('load', () => { + this.templateUrl = fr.result + file.fileUrl = this.templateUrl + this.template = file + this.templateUploaded = true + }) + } else { + this.resetTemplate() + } + }, + onFilePicked (e) { + this.resetFiles() + const files = e.target.files + for (let i = 0; i < files.length; i++) { + const file = {} + const f = files[i] + if (f !== undefined) { + file.fileName = f.name + if (file.fileName.lastIndexOf('.') <= 0) { + return + } + const fr = new FileReader() + fr.readAsDataURL(f) + fr.addEventListener('load', () => { + file.fileUrl = fr.result + this.files.push(file) + this.filesDisplay.push(file) + }) + } + } + }, + successDlgClicked: function () { + this.$router.go(-1) // go back to previous page + }, + submit: function () { + if (this.template != null) { + this.files.unshift(this.template) + } else { + this.renderDialog('Upload Error', 'Missing Template File') + return + } + this.setLoading() + const jm = new JobMgr() + const vm = this + jm.setJobType('xmlconv') + jm.setJobParameters({ datasetId: this.datasetSelected._id, templateName: this.templateName }) + this.files.forEach(function (v) { + jm.addInputFile(v.fileName, v.fileUrl) + }) + return jm.submitJob(function (jobId) { + vm.jobId = jobId + vm.resetLoading() + vm.renderDialog('Uploader Job Submitted Successfully', `Your uploader job is: ${jobId} + You should receive an email with a link to the job output.`, vm.successDlgClicked) + }, function (errCode, errMsg) { + vm.renderDialog('Upload Error', `Error submitting files for upload: errCode: ${errCode} msg: ${errMsg}`) + vm.resetLoading() + }) + }, + ...mapMutations({ + toggleDialogBox: 'setDialogBox' + }), + renderDialog (title, content, closeHandler) { + this.dialog = { + title, + content, + closeHandler: closeHandler || this.toggleDialogBox + } + this.toggleDialogBox() + } + }, created () { this.$store.commit('setAppHeaderInfo', { icon: 'cloud_upload', name: 'Data Uploader' }) } diff --git a/app/src/router/module/nanomine.js b/app/src/router/module/nanomine.js index ca54b26a..0807f412 100644 --- a/app/src/router/module/nanomine.js +++ b/app/src/router/module/nanomine.js @@ -6,7 +6,7 @@ const nanomineRoutes = [ meta: { requiresAuth: false } }, { - path: '/xml-uploader', + path: 'xml-uploader', name: 'XmlUploader', component: () => import(/* webpackChunkName: "xmlupload" */ '@/pages/nanomine/xmlUploader/XmlUploader.vue'), meta: { requiresAuth: false } diff --git a/app/src/store/modules/nanomine/referenceContainer/index.js b/app/src/store/modules/nanomine/referenceContainer/index.js index d1d5769d..3733c2a3 100644 --- a/app/src/store/modules/nanomine/referenceContainer/index.js +++ b/app/src/store/modules/nanomine/referenceContainer/index.js @@ -100,6 +100,18 @@ export default { title: 'Smilesdrawer: parsing and drawing SMILES-encoded molecular structures using client-side javascript.', venue: 'Journal of chemical information and modeling 58.1 (2018): 1-7.', date: '2018' + }, + '10.1063/1.4943679': { + authors: 'Zhao, H., Li, X., Zhang, Y., Schadler, L. S., Chen, W., and Brinson, L. C.', + title: 'Perspective: NanoMine: A material genome approach for polymer nanocomposites analysis and design', + venue: 'APL Materials, 4(5), 053204', + date: '2016' + }, + '10.1063/1.5046839': { + authors: 'Zhao, H., Wang, Y., Lin, A., Hu, B., Yan, R., McCusker, J., and Brinson, L. C.', + title: 'NanoMine schema: An extensible data representation for polymer nanocomposites', + venue: 'APL Materials, 6(11), 111108', + date: '2018' } } } From 43fe5a0a10ec4244577a88b3601654e40d3e0709 Mon Sep 17 00:00:00 2001 From: Rory Schadler Date: Fri, 18 Mar 2022 15:39:46 -0400 Subject: [PATCH 2/6] #24: Fix old references to xml-uploader --- app/src/pages/nanomine/Home/Home.vue | 2 +- app/tests/unit/pages/nanomine/home.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/pages/nanomine/Home/Home.vue b/app/src/pages/nanomine/Home/Home.vue index b7f23dfd..3fe4d732 100644 --- a/app/src/pages/nanomine/Home/Home.vue +++ b/app/src/pages/nanomine/Home/Home.vue @@ -29,7 +29,7 @@