1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

import via textarea

This commit is contained in:
Kyle Spearrin
2017-03-30 00:07:26 -04:00
parent 61cce7e8e7
commit 1db6d7f32b
3 changed files with 130 additions and 139 deletions

View File

@@ -1,9 +1,10 @@
angular
.module('bit.tools')
.controller('toolsImportController', function ($scope, $state, apiService, $uibModalInstance, cryptoService, cipherService, toastr, importService, $analytics, $sce) {
.controller('toolsImportController', function ($scope, $state, apiService, $uibModalInstance, cryptoService, cipherService,
toastr, importService, $analytics, $sce, validationService) {
$analytics.eventTrack('toolsImportController', { category: 'Modal' });
$scope.model = { source: 'bitwardencsv' };
$scope.model = { source: '' };
$scope.source = {};
$scope.options = [
@@ -202,10 +203,20 @@
};
$scope.setSource();
$scope.import = function (model) {
$scope.processing = true;
$scope.import = function (model, form) {
if (!model.source || model.source === '') {
validationService.addError(form, 'source', 'Select the format of the import file.', true);
return;
}
var file = document.getElementById('file').files[0];
importService.import(model.source, file, importSuccess, importError);
if (!file && (!model.fileContents || model.fileContents === '')) {
validationService.addError(form, 'file', 'Select the import file or copy/paste the import file contents.', true);
return;
}
$scope.processing = true;
importService.import(model.source, file || model.fileContents, importSuccess, importError);
};
function importSuccess(folders, logins, folderRelationships) {