mirror of https://github.com/BTCPrivate/copay.git
Improve restore forms
This commit is contained in:
parent
aa0ed193fd
commit
af4a11c26d
31
index.html
31
index.html
|
@ -176,7 +176,7 @@
|
||||||
<span ng-show="wallets.length">
|
<span ng-show="wallets.length">
|
||||||
<a ng-click="create()" ng-disabled="loading" loading="Creating">Create a new wallet</a> ·
|
<a ng-click="create()" ng-disabled="loading" loading="Creating">Create a new wallet</a> ·
|
||||||
</span>
|
</span>
|
||||||
<a ng-href="#import">Import from file</a>
|
<a ng-href="#import">Restore a backup</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- End !loading -->
|
</div> <!-- End !loading -->
|
||||||
|
@ -185,14 +185,27 @@
|
||||||
|
|
||||||
<script type="text/ng-template" id="import.html">
|
<script type="text/ng-template" id="import.html">
|
||||||
<div ng-controller="ImportController">
|
<div ng-controller="ImportController">
|
||||||
<h3>{{title}}</h3>
|
<div class="large-6 large-centered medium-6 medium-centered columns">
|
||||||
<div class="large-6 columns">
|
<h2>{{title}}</h2>
|
||||||
<input type="password" class="form-control" placeholder="Your wallet password" ng-model="password" autofocus required>
|
<form name="importForm" ng-submit="import(importForm)" novalidate>
|
||||||
<h6>Select a backup file</h6>
|
<fieldset>
|
||||||
<input type="file" class="form-control" placeholder="Select a backup file" ng-model="backupFile" ng-file-select>
|
<legend>Choose your backup file or paste plain text code</legend>
|
||||||
<h6>Or just paste the backup text here</h6>
|
<accordion>
|
||||||
<textarea class="form-control" ng-model="backupText"></textarea>
|
<accordion-group heading="Choose backup file from your computer" is-open="true">
|
||||||
<button class="button primary expand radius" ng-click="import()">Import backup</button>
|
<input type="file" class="form-control" placeholder="Select a backup file" name="backupFile" ng-model="backupFile" ng-file-select>
|
||||||
|
</accordion-group>
|
||||||
|
<accordion-group heading="Paste backup plain text code">
|
||||||
|
<textarea class="form-control" name="backupText" ng-model="backupText" rows="5"></textarea>
|
||||||
|
</accordion-group>
|
||||||
|
</accordion>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<label for="password">Password <small>Required</small></label>
|
||||||
|
<input type="password" class="form-control" placeholder="Your wallet password" name="password" ng-model="password" required>
|
||||||
|
<button type="submit" class="button primary radius" ng-disabled="importForm.$invalid" loading="Importing">
|
||||||
|
Import backup
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -21,13 +21,31 @@ angular.module('copay.import').controller('ImportController',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.import = function() {
|
$scope.import = function(form) {
|
||||||
if ($scope.password) {
|
if (form.$invalid) {
|
||||||
if ($scope.backupText) {
|
$rootScope.flashMessage = { message: 'There is an error in the form. Please, try again', type: 'error'};
|
||||||
_importBackup($scope.backupText);
|
return;
|
||||||
} else {
|
|
||||||
reader.readAsBinaryString($scope.file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var backupFile = $scope.file;
|
||||||
|
var backupText = form.backupText.$modelValue;
|
||||||
|
var password = form.password.$modelValue;
|
||||||
|
|
||||||
|
if (!backupFile && !backupText) {
|
||||||
|
$rootScope.flashMessage = { message: 'Please, select your backup file or paste the text', type: 'error'};
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.loading = true;
|
||||||
|
|
||||||
|
if (backupFile) {
|
||||||
|
reader.readAsBinaryString(backupFile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_importBackup(backupText);
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.loading = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue