From 156f9354981d1b8a27cd7fed90e0397c118735ec Mon Sep 17 00:00:00 2001 From: brantje Date: Mon, 26 Sep 2016 21:46:41 +0200 Subject: [PATCH 1/2] Update tag filter --- js/app/filters/tagfilter.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/app/filters/tagfilter.js b/js/app/filters/tagfilter.js index 1ee00496..1ba9b589 100644 --- a/js/app/filters/tagfilter.js +++ b/js/app/filters/tagfilter.js @@ -15,14 +15,16 @@ angular.module('passmanApp') if(tags.length > 0) { for (var ci = 0; ci < credentials.length; ci++) { var c = credentials[ci]; + var matches = 0; for (var ct = 0; ct < c.tags_raw.length; ct++) { var t = c.tags_raw[ct]; if(tags.indexOf(t.text) != -1){ - if(_credentials.indexOf(c) === -1){ - _credentials.push(c); - } + matches++; } } + if(matches === tags.length){ + _credentials.push(c); + } } } if(tags.length == 0){ From 4e6e6723f79cbcf24397a7f7a9adb1b604c67737 Mon Sep 17 00:00:00 2001 From: brantje Date: Mon, 26 Sep 2016 21:56:18 +0200 Subject: [PATCH 2/2] Generate 50 credentials, check if we have data --- js/importers/importer-randomdata.js | 72 ++++++++++++++++++----------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/js/importers/importer-randomdata.js b/js/importers/importer-randomdata.js index a9eb350a..08a4e9bd 100644 --- a/js/importers/importer-randomdata.js +++ b/js/importers/importer-randomdata.js @@ -7,7 +7,7 @@ PassmanImporter.randomData = { info: { name: 'Random data', id: 'randomData', - description: 'Create\'s 10 random credentials for testing purposes.' + description: 'Create\'s 50 random credentials for testing purposes.' } }; @@ -39,34 +39,52 @@ PassmanImporter.randomData.readFile = function (file_data, callback) { url: url, dataType: 'json', success: function (data) { - var _credential = PassmanImporter.newCredential(); - label = (Math.random() >= 0.5) ? data.domain : data.email_d + ' - ' + data.email_u; - _credential.label = label; - _credential.username = data.username; - _credential.password = data.password; - _credential.url = data.url; + if(data) { + var _credential = PassmanImporter.newCredential(); + label = (Math.random() >= 0.5) ? data.domain : data.email_d + ' - ' + data.email_u; + _credential.label = label; + _credential.username = data.username; + _credential.password = data.password; + _credential.url = data.url; - var tag_amount = Math.floor(Math.random() * 5); - for (var ta = 0; ta < tag_amount; ta++) { - var item = tags[Math.floor(Math.random() * tags.length)]; - var tag = { - text: item - }; - if (_credential.tags.indexOf(tag) === -1) { - _credential.tags.push(tag); + var tag_amount = Math.floor(Math.random() * 5); + var ta = 0; + var tags = []; + while (ta < tag_amount) { + var item = tags[Math.floor(Math.random() * tags.length)]; + var tag = { + text: item + }; + if (tags.indexOf(tag) === -1) { + tags.push(tag); + ta++ + } + } + + _credential.tags = tags.map(function (item) { + if (item) { + return {text: item} + } + + }).filter(function (item) { + return (item); + }); + + credential_list.push(_credential); + + if (i < max) { + var progress = { + percent: i / max * 100, + loaded: i, + total: max + }; + _this.call_progress(progress); + generateCredential(max, i + 1, callback) + } else { + callback(credential_list) } - } - credential_list.push(_credential); - if (i < max) { - var progress = { - percent: i / max * 100, - loaded: i, - total: max - }; - _this.call_progress(progress); - generateCredential(max, i + 1, callback) } else { - callback(credential_list) + generateCredential(max, i , callback) } } }); @@ -74,7 +92,7 @@ PassmanImporter.randomData.readFile = function (file_data, callback) { }; - generateCredential(350, 1, function (credential_list) { + generateCredential(50, 1, function (credential_list) { _this.call_then(credential_list); }); });