importer fixes

This commit is contained in:
Kyle Spearrin 2017-01-02 21:37:20 -05:00
parent 711c8e63c1
commit e01a22de48
1 changed files with 37 additions and 26 deletions

View File

@ -684,6 +684,9 @@
folderRelationships = []; folderRelationships = [];
angular.forEach(results.data, function (value, key) { angular.forEach(results.data, function (value, key) {
value.Group = value.Group.startsWith('Root/') ?
value.Group.replace('Root/', '') : value.Group;
var groupName = value.Group && value.Group !== '' ? var groupName = value.Group && value.Group !== '' ?
value.Group.split('/').join(' > ') : null; value.Group.split('/').join(' > ') : null;
@ -712,7 +715,9 @@
name: value.Title && value.Title !== '' ? value.Title : '--', name: value.Title && value.Title !== '' ? value.Title : '--',
}; };
if (value.Title) {
sites.push(site); sites.push(site);
}
if (addFolder) { if (addFolder) {
folders.push({ folders.push({
@ -832,13 +837,17 @@
for (var i = 0; i < results.data.length; i++) { for (var i = 0; i < results.data.length; i++) {
var value = results.data[i]; var value = results.data[i];
if (!value.title) {
continue;
}
var site = { var site = {
favorite: false, favorite: false,
uri: null, uri: null,
username: null, username: null,
password: null, password: null,
notes: value.notesPlain && value.notesPlain !== '' ? value.notesPlain : '', notes: value.notesPlain && value.notesPlain !== '' ? value.notesPlain : '',
name: value.title && value.title !== '' ? value.title : null name: value.title && value.title !== '' ? value.title : '--'
}; };
for (var property in value) { for (var property in value) {
@ -858,22 +867,22 @@
site.uri = fixUri(urls[0]); site.uri = fixUri(urls[0]);
for (var j = 1; j < urls.length; j++) { for (var j = 1; j < urls.length; j++) {
if (notes !== '') { if (site.notes !== '') {
notes += '\n'; site.notes += '\n';
} }
notes += ('url ' + (j + 1) + ': ' + urls[j]); site.notes += ('url ' + (j + 1) + ': ' + urls[j]);
} }
} }
else if (property !== 'ainfo' && property !== 'autosubmit' && property !== 'notesPlain' && else if (property !== 'ainfo' && property !== 'autosubmit' && property !== 'notesPlain' &&
property !== 'ps' && property !== 'scope' && property !== 'tags' && property !== 'title' && property !== 'ps' && property !== 'scope' && property !== 'tags' && property !== 'title' &&
property !== 'uuid' && !property.startsWith('section:')) { property !== 'uuid' && !property.startsWith('section:')) {
if (notes !== '') { if (site.notes !== '') {
notes += '\n'; site.notes += '\n';
} }
notes += (property + ': ' + value[property]); site.notes += (property + ': ' + value[property]);
} }
} }
} }
@ -2064,7 +2073,7 @@
for (var i = 0; i < row.length - 2; i += 2) { for (var i = 0; i < row.length - 2; i += 2) {
var value = row[i + 2]; var value = row[i + 2];
var field = row[i + 1]; var field = row[i + 1];
if (!field || fields === '' || !value || value === '') { if (!field || field === '' || !value || value === '') {
continue; continue;
} }
@ -2134,9 +2143,9 @@
} }
for (var property in item.identifiers) { for (var property in item.identifiers) {
if (doc.hasOwnProperty(property)) { if (item.identifiers.hasOwnProperty(property)) {
var value = item.identifiers[property]; var value = item.identifiers[property];
if (property !== 'notes' || value === '' || value === null) { if (property === 'notes' || value === '' || value === null) {
continue; continue;
} }
@ -2146,12 +2155,12 @@
else if (property === 'password') { else if (property === 'password') {
site.password = value; site.password = value;
} }
else if (property !== 'notes') { else {
if (note.notes !== '') { if (site.notes !== '') {
note.notes += '\n'; site.notes += '\n';
} }
note.notes += (property + ': ' + value); site.notes += (property + ': ' + value);
} }
} }
} }
@ -2181,30 +2190,30 @@
var dataLines = data.split(/(?:\r\n|\r|\n)/); var dataLines = data.split(/(?:\r\n|\r|\n)/);
for (var i = 0; i < dataLines.length; i++) { for (var i = 0; i < dataLines.length; i++) {
var line = dataLines[i]; var line = dataLines[i];
var delimPosition = myString.indexOf(':'); var delimPosition = line.indexOf(':');
if (delimPosition < 0) { if (delimPosition < 0) {
continue; continue;
} }
var field = line.substring(0, delimPosition); var field = line.substring(0, delimPosition);
var value = line.substring(delimPosition); var value = line.length > delimPosition ? line.substring(delimPosition + 1) : null;
if (!field || field === '' || !value || value === '' || field === 'SecretType') { if (!field || field === '' || !value || value === '' || field === 'SecretType') {
continue; continue;
} }
var fieldLower = field.toLowerCase(); var fieldLower = field.toLowerCase();
if (field === 'user name') { if (fieldLower === 'user name') {
site.username = value; site.username = value;
} }
else if (field === 'password') { else if (fieldLower === 'password') {
site.password = value; site.password = value;
} }
else { else {
if (site.note === '') { if (site.notes !== '') {
site.note += '\n'; site.notes += '\n';
} }
site.note += (field + ': ' + value); site.notes += (field + ': ' + value);
} }
} }
} }
@ -2239,7 +2248,7 @@
} }
var site = { var site = {
favorite: value['Favorite'], favorite: value['Favorite'] && value['Favorite'] === '1' ? true : false,
uri: value['Secret URL'] && value['Secret URL'] !== '' ? fixUri(value['Secret URL']) : null, uri: value['Secret URL'] && value['Secret URL'] !== '' ? fixUri(value['Secret URL']) : null,
username: null, username: null,
password: null, password: null,
@ -2247,14 +2256,16 @@
name: value['Secret Name'] && value['Secret Name'] !== '' ? value['Secret Name'] : '--' name: value['Secret Name'] && value['Secret Name'] !== '' ? value['Secret Name'] : '--'
}; };
parseData(value['SecretData']); parseData(value['SecretData'], site);
parseData(value['CustomData']); parseData(value['CustomData'], site);
if (site.notes === '') { if (site.notes === '') {
site.notes = null; site.notes = null;
} }
if (value['Secret Name']) {
sites.push(site); sites.push(site);
}
if (addFolder) { if (addFolder) {
folders.push({ folders.push({