diff --git a/app/assets/images/icon_small/sequence-editor.svg b/app/assets/images/icon_small/sequence-editor.svg new file mode 100644 index 000000000..b528c6c3f --- /dev/null +++ b/app/assets/images/icon_small/sequence-editor.svg @@ -0,0 +1,10 @@ + diff --git a/app/assets/javascripts/i18n_bundle.js b/app/assets/javascripts/i18n_bundle.js new file mode 100644 index 000000000..04bbf3cf2 --- /dev/null +++ b/app/assets/javascripts/i18n_bundle.js @@ -0,0 +1,2 @@ +//= require i18n.js +//= require i18n/translations diff --git a/app/assets/javascripts/protocols/import_export/import.js b/app/assets/javascripts/protocols/import_export/import.js index 000031aa4..d1e98c722 100644 --- a/app/assets/javascripts/protocols/import_export/import.js +++ b/app/assets/javascripts/protocols/import_export/import.js @@ -58,12 +58,41 @@ function importProtocolFromFile( } function getAssetBytes(folder, stepGuid, fileRef) { - var stepPath = stepGuid ? stepGuid + '/' : ''; - var filePath = folder + stepPath + fileRef; - var assetBytes = zipFiles.files[cleanFilePath(filePath)].asBinary(); + const stepPath = stepGuid ? stepGuid + '/' : ''; + const filePath = folder + stepPath + fileRef; + const assetBytes = zipFiles.files[cleanFilePath(filePath)].asBinary(); return window.btoa(assetBytes); } + function getAssetPreview(folder, stepGuid, fileRef, fileName, fileType) { + if ($.inArray(fileType, ['image/png', 'image/jpeg', 'image/gif', 'image/bmp']) > 0) { + return { + fileName: fileName, + fileType: fileType, + bytes: getAssetBytes(folder, stepGuid, fileRef) + }; + } else { + const stepPath = stepGuid ? folder + stepGuid + '/' : folder; + let baseName; + baseName = fileRef.split('.'); + baseName.pop(); + baseName.join('.'); + let previewFileRef = zipFiles.file(new RegExp(stepPath + 'previews/' + baseName)); + if (previewFileRef.length > 0) { + const previewFileExt = previewFileRef[0].name.split('.').at(-1); + let previewFileName = fileName.split('.'); + previewFileName.splice(-1, 1, previewFileExt); + previewFileName.join('.'); + return { + fileName: previewFileName, + fileType: `image/${previewFileExt}`, + bytes: window.btoa(previewFileRef[0].asBinary()) + }; + } + } + return null; + } + /* Template functions */ function newPreviewElement(name, values) { @@ -82,14 +111,14 @@ function importProtocolFromFile( } function newAssetElement(folder, stepGuid, fileRef, fileName, fileType) { - var html = '