open from dropbox

pull/8/head
Antelle 2015-10-25 19:48:54 +03:00
parent b90b31297e
commit 2e6cc83ad7
5 changed files with 15 additions and 11 deletions

View File

@ -10,11 +10,12 @@
- [ ] switch view
- [ ] lock without closing
- [ ] merge
- [ ] dropbox keyfiles
- [ ] generation templates
- [ ] advanced search
- [ ] auto-type
- [ ] mobile
- [ ] file type associations
- [ ] auto-type
- [ ] secure fields
- [ ] audit
- [ ] entry templates

View File

@ -28,7 +28,7 @@ var OpenFileView = Backbone.View.extend({
fileData: null,
keyFileData: null,
passwordInput: null,
dropboxLoading: false,
dropboxLoading: null,
initialize: function () {
this.fileData = null;
@ -181,10 +181,10 @@ var OpenFileView = Backbone.View.extend({
},
openFromDropbox: function() {
this.dropboxLoading = true;
this.dropboxLoading = 'opening';
this.render();
DropboxLink.getFileList((function(err, files) {
this.dropboxLoading = false;
this.dropboxLoading = null;
if (err) { return; }
var buttons = [];
files.forEach(function(file) {
@ -205,9 +205,11 @@ var OpenFileView = Backbone.View.extend({
},
openDropboxFile: function(file) {
this.dropboxLoading = true;
var fileName = file.replace(/\.kdbx/i, '');
this.dropboxLoading = 'opening ' + fileName;
this.render();
DropboxLink.openFile(file, (function(err, data) {
this.dropboxLoading = false;
this.dropboxLoading = null;
if (err || !data || !data.size) {
this.render();
Alerts.error({ header: 'Failed to read file', body: 'Error reading Dropbox file: \n' + err });
@ -216,14 +218,14 @@ var OpenFileView = Backbone.View.extend({
Object.defineProperties(data, {
storage: { value: 'dropbox' },
path: { value: file },
name: { value: file.replace(/\.kdbx/i, '') }
name: { value: fileName }
});
this.setFile(data);
}).bind(this));
},
cancelOpenDropboxFile: function() {
this.dropboxLoading = false;
this.dropboxLoading = null;
this.render();
}
});

View File

@ -5,7 +5,6 @@ var Backbone = require('backbone'),
FeatureDetector = require('../../util/feature-detector'),
PasswordGenerator = require('../../util/password-generator'),
Alerts = require('../../comp/alerts'),
RuntimeInfo = require('../../comp/runtime-info'),
Launcher = require('../../comp/launcher'),
Links = require('../../const/links'),
DropboxLink = require('../../comp/dropbox-link'),
@ -115,6 +114,7 @@ var SettingsAboutView = Backbone.View.extend({
} else {
var blob = new Blob([data], {type: 'application/octet-stream'});
FileSaver.saveAs(blob, fileName);
this.passwordChanged = false;
this.model.saved();
}
},
@ -122,6 +122,7 @@ var SettingsAboutView = Backbone.View.extend({
saveToFileWithPath: function(path, data) {
try {
Launcher.writeFile(path, data);
this.passwordChanged = false;
this.model.saved(path, 'file');
if (!AppSettingsModel.instance.get('lastOpenFile')) {
AppSettingsModel.instance.set('lastOpenFile', path);
@ -177,6 +178,7 @@ var SettingsAboutView = Backbone.View.extend({
});
}
} else {
this.passwordChanged = false;
this.model.saved(fileName, 'dropbox');
this.render();
}

View File

@ -3,7 +3,6 @@
<div class="footer__db footer__db-item <%= file.get('open') ? '' : 'footer__db--dimmed' %>" data-file-id="<%= file.cid %>">
<i class="fa fa-<%= file.get('open') ? 'unlock' : 'lock' %>"></i> <%- file.get('name') %>
<% if (file.get('modified') && !file.get('syncing')) { %><i class="fa fa-circle footer__db-sign"></i><% } %>
<% if (file.get('syncing')) { %><i class="fa fa-refresh fa-spin footer__db-sign"></i><% } %>
</div>
<% }); %>
<div class="footer__db footer__db--dimmed footer__db--expanded footer__db-open"><i class="fa fa-plus"></i> Open / New</div>

View File

@ -15,7 +15,7 @@
<a class="open__file-link-open muted-color" <%= opening ? 'disabled' : '' %>>Open</a> / <a
class="open__file-link-new muted-color" <%= opening ? 'disabled' : '' %>>New</a><% if (supportsDropbox) { %> / <a
class="open__file-link-dropbox muted-color" <%= (opening || dropboxLoading) ? 'disabled' : '' %>
>Dropbox<%= dropboxLoading ? ' (Loading...)' : '' %></a><% } %> / <a
>Dropbox<%= dropboxLoading ? ' (' + dropboxLoading + '...)' : '' %></a><% } %> / <a
class="open__file-link-demo muted-color" <%= opening ? 'disabled' : '' %>>Demo</a>
<% } %>
</div>