import require password

This commit is contained in:
Mo Bitar
2017-01-08 14:15:33 -06:00
parent 93e3a72d30
commit ca3eff7f15
8 changed files with 166 additions and 43 deletions

View File

@@ -193,19 +193,39 @@ angular.module('app.frontend')
link.click();
}
this.performImport = function(data, password) {
apiController.importJSONData(data, password, function(success, response){
console.log("import response", success, response);
if(success) {
this.importData = null;
} else {
alert("There was an error importing your data. Please try again.");
}
}.bind(this))
}
this.submitImportPassword = function() {
this.performImport(this.importData.data, this.importData.password);
}
this.importFileSelected = function(files) {
this.importData = {};
var file = files[0];
var reader = new FileReader();
reader.onload = function(e) {
apiController.importJSONData(e.target.result, function(success, response){
console.log("import response", success, response);
if(success) {
// window.location.reload();
var data = JSON.parse(e.target.result);
$timeout(function(){
if(data.auth_params) {
// request password
this.importData.requestPassword = true;
this.importData.data = data;
} else {
alert("There was an error importing your data. Please try again.");
this.performImport(data, null);
}
})
}
}.bind(this))
}.bind(this)
reader.readAsText(file);
}