Fix import protocol [SCI-7915] (#4980)

This commit is contained in:
ajugo 2023-02-20 10:14:32 +01:00 committed by GitHub
parent c92faeb48c
commit 461d06dad9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,4 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-unused-vars, lines-around-comment, no-undef, no-alert */
/* eslint-disable no-use-before-define, no-restricted-globals */
//= require protocols/import_export/eln_table.js
@ -48,10 +49,18 @@ function importProtocolFromFile(
return (parseInt($(a).attr('position'), 10) - parseInt($(b).attr('position'), 10));
}
function cleanFilePath(filePath) {
if (filePath.slice(-1) === '.') {
filePath = filePath.substring(0, filePath.length - 1);
}
return filePath;
}
function getAssetBytes(folder, stepGuid, fileRef) {
var stepPath = stepGuid ? stepGuid + '/' : '';
var filePath = folder + stepPath + fileRef;
var assetBytes = zipFiles.files[filePath].asBinary();
var assetBytes = zipFiles.files[cleanFilePath(filePath)].asBinary();
return window.btoa(assetBytes);
}