зеркало из https://github.com/nextcloud/passman.git
fix importer js
Signed-off-by: binsky <timo@binsky.org>
This commit is contained in:
Родитель
88fef6029b
Коммит
9c6e270f76
|
@ -1,10 +1,11 @@
|
|||
{
|
||||
"maxerr" : 50,
|
||||
"jquery" : true, // jQuery
|
||||
"esversion" : 8,
|
||||
"globals" : {
|
||||
"angular": true,
|
||||
"PassmanImporter": true,
|
||||
"OC": true,
|
||||
"window": true
|
||||
} // additional predefined global variables
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ module.exports = function (grunt) {
|
|||
eqeqeq: true,
|
||||
eqnull: true,
|
||||
browser: true,
|
||||
esversion: 8,
|
||||
globals: {
|
||||
"angular": true,
|
||||
"PassmanImporter": true,
|
||||
|
@ -406,4 +407,4 @@ module.exports = function (grunt) {
|
|||
grunt.registerTask('hint', ['jshint']);
|
||||
grunt.registerTask('build', ['sass', 'jshint', 'html2js', 'mkdir:dist', 'copy:dist', 'copy:fonts', 'replace:dist', 'uglify', 'concat:css', 'cssmin', 'clean:css', 'replace:strict', 'copy:settingsJs']);
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
if (row[k] !== undefined && (typeof row[k] === 'string' || row[k] instanceof String) && row[k].length > 1){
|
||||
try {
|
||||
row[k] = JSON.parse(row[k]);
|
||||
for(var i = 0; k < row[k].length; i++){
|
||||
for(let i = 0; k < row[k].length; i++){
|
||||
_credential.custom_fields.push({
|
||||
'label': row[k][i].label,
|
||||
'secret': row[k][i].secret,
|
||||
|
@ -128,7 +128,7 @@
|
|||
// console.error(e);
|
||||
}
|
||||
} else {
|
||||
for(var j = 0; j < row[k].length; j++){
|
||||
for(let j = 0; j < row[k].length; j++){
|
||||
if (row[k][j].field_type === 'file'){
|
||||
var _file = {
|
||||
filename: row[k][j].value.filename,
|
||||
|
@ -137,11 +137,7 @@
|
|||
data: row[k][j].value.file_data
|
||||
};
|
||||
|
||||
row[k][j].value = await FileService.uploadFile(_file).then(function (result) {
|
||||
delete result.file_data;
|
||||
result.filename = EncryptService.decryptString(result.filename);
|
||||
return result;
|
||||
});
|
||||
row[k][j].value = await FileService.uploadFile(_file).then(FileService.getEmptyFileWithDecryptedFilename);
|
||||
}
|
||||
_credential.custom_fields.push(row[k][j]);
|
||||
}
|
||||
|
@ -150,7 +146,7 @@
|
|||
if (row[k] !== undefined && (typeof row[k] === 'string' || row[k] instanceof String) && row[k].length > 1){
|
||||
try {
|
||||
row[k] = JSON.parse(row[k]);
|
||||
for(var i = 0; k < row[k].length; i++){
|
||||
for(let i = 0; k < row[k].length; i++){
|
||||
_credential.files.push({
|
||||
filename: row[k][i].filename,
|
||||
size: row[k][i].size,
|
||||
|
@ -162,17 +158,13 @@
|
|||
// console.error(e);
|
||||
}
|
||||
} else {
|
||||
for(var j = 0; j < row[k].length; j++){
|
||||
for(let j = 0; j < row[k].length; j++){
|
||||
_credential.files.push(await FileService.uploadFile({
|
||||
filename: row[k][j].filename,
|
||||
size: row[k][j].size,
|
||||
mimetype: row[k][j].mimetype,
|
||||
data: row[k][j].file_data
|
||||
}).then(function (result) {
|
||||
delete result.file_data;
|
||||
result.filename = EncryptService.decryptString(result.filename);
|
||||
return result;
|
||||
}));
|
||||
}).then(FileService.getEmptyFileWithDecryptedFilename));
|
||||
}
|
||||
}
|
||||
} else if(field === 'tags'){
|
||||
|
|
|
@ -114,7 +114,12 @@
|
|||
|
||||
/** global: URL */
|
||||
return URL.createObjectURL(bb);
|
||||
},
|
||||
getEmptyFileWithDecryptedFilename: function (file) {
|
||||
delete file.file_data;
|
||||
file.filename = EncryptService.decryptString(file.filename);
|
||||
return file;
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
}());
|
||||
|
|
|
@ -43,7 +43,8 @@ var PassmanImporter = PassmanImporter || {};
|
|||
|
||||
PassmanImporter.passmanJson.readFile = function (file_data) {
|
||||
/** global: C_Promise */
|
||||
return new C_Promise(async function(){
|
||||
return new C_Promise(
|
||||
async function(){
|
||||
var parseCustomFields = async function (customFields, credential){
|
||||
if (customFields.length > 0) {
|
||||
for (var cf = 0; cf < customFields.length; cf++) {
|
||||
|
@ -93,10 +94,14 @@ var PassmanImporter = PassmanImporter || {};
|
|||
mimetype: files[cf].mimetype,
|
||||
data: files[cf].file_data
|
||||
};
|
||||
var file_result = await FileService.uploadFile(_file);
|
||||
delete file_result.file_data;
|
||||
file_result.filename = EncryptService.decryptString(file_result.filename);
|
||||
credential.files.push(file_result);
|
||||
try {
|
||||
var file_result = await FileService.uploadFile(_file);
|
||||
delete file_result.file_data;
|
||||
file_result.filename = EncryptService.decryptString(file_result.filename);
|
||||
credential.files.push(file_result);
|
||||
} catch (e) {
|
||||
console.error("failed processing file: " + _file.filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
return credential;
|
||||
|
|
Загрузка…
Ссылка в новой задаче