Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logic to import multiple files when prompted (fixes issues #31) #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 55 additions & 50 deletions main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -565,67 +565,72 @@

{ name: 'CAD formats', extensions: ['svg', 'dxf', 'cdr'] }

]}, function (fileName) {
],
properties:['openFile', 'multiSelections']

}, function (fileName) {
if(fileName === undefined){
importbutton.className = 'button import';
console.log("No file selected");
}
else{
var ext = path.extname(fileName[0]);
var filename = path.basename(fileName[0]);
fileName.forEach((file) => {
var ext = path.extname(file);
var filename = path.basename(file);

if(ext.toLowerCase() == '.svg'){
readFile(fileName[0]);
importbutton.className = 'button import';
}
else{
importbutton.className = 'button import spinner';

// send to conversion server
var url = config.getSync('conversionServer');
if(!url){
url = defaultConversionServer;
}

var req = request.post(url, function (err, resp, body) {
if(ext.toLowerCase() == '.svg'){
readFile(file);
importbutton.className = 'button import';
if (err) {
message('could not contact file conversion server', true);
} else {
if(body.substring(0, 5) == 'error'){
message(body, true);
}
else{
// expected input dimensions on server is points
// scale based on unit preferences
var con = null;
var dxfFlag = false;
if(ext.toLowerCase() == '.dxf'){
//var unit = config.getSync('units');
con = Number(config.getSync('dxfImportScale'));
dxfFlag = true;
console.log('con', con);

/*if(unit == 'inch'){
con = 72;
}
else{
importbutton.className = 'button import spinner';

// send to conversion server
var url = config.getSync('conversionServer');
if(!url){
url = defaultConversionServer;
}

var req = request.post(url, function (err, resp, body) {
importbutton.className = 'button import';
if (err) {
message('could not contact file conversion server', true);
} else {
if(body.substring(0, 5) == 'error'){
message(body, true);
}
else{
// expected input dimensions on server is points
// scale based on unit preferences
var con = null;
var dxfFlag = false;
if(ext.toLowerCase() == '.dxf'){
//var unit = config.getSync('units');
con = Number(config.getSync('dxfImportScale'));
dxfFlag = true;
console.log('con', con);

/*if(unit == 'inch'){
con = 72;
}
else{
// mm
con = 2.83465;
}*/
}
else{
// mm
con = 2.83465;
}*/

// dirpath is used for loading images embedded in svg files
// converted svgs will not have images
importData(body, filename, null, con, dxfFlag);
}

// dirpath is used for loading images embedded in svg files
// converted svgs will not have images
importData(body, filename, null, con, dxfFlag);
}
}
});
});

var form = req.form();
form.append('format', 'svg');
form.append('fileUpload', fs.createReadStream(fileName[0]));
}
var form = req.form();
form.append('format', 'svg');
form.append('fileUpload', fs.createReadStream(file));
}
});
}

});
Expand Down