add file import support for custom fields

This commit is contained in:
binsky 2021-03-24 12:54:05 +01:00
parent 72acc51f4b
commit 3c07c5edaf
4 changed files with 20 additions and 5 deletions

View file

@ -491,7 +491,8 @@
z-index: 1000; } z-index: 1000; }
.link { .link {
color: var(--color-primary); } color: var(--color-primary);
cursor: pointer; }
.link span { .link span {
cursor: pointer; } cursor: pointer; }

File diff suppressed because one or more lines are too long

View file

@ -44,7 +44,7 @@ var PassmanImporter = PassmanImporter || {};
PassmanImporter.passmanJson.readFile = async function (file_data) { PassmanImporter.passmanJson.readFile = async function (file_data) {
/** global: C_Promise */ /** global: C_Promise */
return new C_Promise(async function(){ return new C_Promise(async function(){
var parseCustomFields = function (customFields, credential){ var parseCustomFields = async function (customFields, credential){
if (customFields.length > 0) { if (customFields.length > 0) {
for (var cf = 0; cf < customFields.length; cf++) { for (var cf = 0; cf < customFields.length; cf++) {
if (customFields[cf].hasOwnProperty('clicktoshow')){ if (customFields[cf].hasOwnProperty('clicktoshow')){
@ -58,6 +58,19 @@ var PassmanImporter = PassmanImporter || {};
} }
); );
} else { } else {
if (customFields[cf].field_type === 'file'){
var _file = {
filename: customFields[cf].value.filename,
size: customFields[cf].value.size,
mimetype: customFields[cf].value.mimetype,
data: customFields[cf].value.file_data
};
var file_result = await FileService.uploadFile(_file);
delete file_result.file_data;
file_result.filename = EncryptService.decryptString(file_result.filename);
customFields[cf].value = file_result;
}
credential.custom_fields.push( credential.custom_fields.push(
{ {
'label': customFields[cf].label, 'label': customFields[cf].label,
@ -104,10 +117,10 @@ var PassmanImporter = PassmanImporter || {};
_credential.description = item.description; _credential.description = item.description;
//Check for custom fields //Check for custom fields
if (item.hasOwnProperty('customFields')) { if (item.hasOwnProperty('customFields')) {
_credential = parseCustomFields(item.customFields, _credential); _credential = await parseCustomFields(item.customFields, _credential);
} }
if (item.hasOwnProperty('custom_fields')) { if (item.hasOwnProperty('custom_fields')) {
_credential = parseCustomFields(item.custom_fields, _credential); _credential = await parseCustomFields(item.custom_fields, _credential);
} }
//Check for files //Check for files
if (item.hasOwnProperty('files')) { if (item.hasOwnProperty('files')) {

View file

@ -39,6 +39,7 @@
.link{ .link{
color:var(--color-primary); color:var(--color-primary);
cursor: pointer;
span { span {
cursor: pointer; cursor: pointer;
} }