Zip exported files #38

This commit is contained in:
kovacsv 2021-12-27 11:03:21 +01:00
parent 93358e2cd0
commit 536a384d4d
2 changed files with 12 additions and 40 deletions

View File

@ -96,12 +96,6 @@ div.ov_dialog div.ov_dialog_options
height: 50px;
}
div.ov_dialog div.ov_dialog_file_list
{
max-height: 105px;
overflow: auto;
}
div.ov_dialog div.ov_dialog_import_file_list
{
max-height: 300px;

View File

@ -90,45 +90,23 @@ OV.ModelExporterUI = class extends OV.ExporterUI
let file = files[0];
OV.DownloadArrayBufferAsFile (file.GetBufferContent (), file.GetName ());
} else if (files.length > 1) {
progressDialog.Hide ();
let filesDialog = this.ShowExportedFiles (files);
callbacks.onDialog (filesDialog);
OV.LoadExternalLibrary ('loaders/fflate.min.js').then (() => {
let filesInZip = {};
for (let file of files) {
filesInZip[file.name] = new Uint8Array (file.content);
}
let zippedContent = fflate.zipSync (filesInZip);
let zippedBuffer = zippedContent.buffer;
progressDialog.Hide ();
OV.DownloadArrayBufferAsFile (zippedBuffer, 'model.zip');
}).catch (() => {
progressDialog.Hide ();
});
}
}
});
});
}
ShowExportedFiles (files)
{
let dialog = new OV.ButtonDialog ();
let contentDiv = dialog.Init ('Exported Files', [
{
name : 'Close',
onClick () {
dialog.Hide ();
}
}
]);
let text = 'You can download your exported files here.';
OV.AddDiv (contentDiv, 'ov_dialog_section', text);
let fileListSection = OV.AddDiv (contentDiv, 'ov_dialog_section');
let fileList = OV.AddDiv (fileListSection, 'ov_dialog_file_list ov_thin_scrollbar');
for (let file of files) {
let fileLink = OV.AddDiv (fileList, 'ov_dialog_file_link');
OV.AddSvgIconElement (fileLink, 'file_download', 'ov_file_link_img');
OV.AddDiv (fileLink, 'ov_dialog_file_link_text', file.GetName ());
fileLink.addEventListener ('click', () => {
OV.DownloadArrayBufferAsFile (file.GetBufferContent (), file.GetName ());
});
}
dialog.Show ();
return dialog;
}
};
OV.ImageExporterUI = class extends OV.ExporterUI