mirror of https://github.com/keeweb/keeweb.git
fix #220: option to preload webdav config
This commit is contained in:
parent
389101a70f
commit
31067d6bf3
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>KeeWeb</title>
|
||||
<meta name="kw-signature" content="">
|
||||
<meta name="kw-config" content="">
|
||||
<meta name="kw-config" content="(no-config)">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="theme-color" content="#6386EC">
|
||||
|
|
|
@ -83,7 +83,7 @@ $(() => {
|
|||
|
||||
function getConfigParam() {
|
||||
let metaConfig = document.head.querySelector('meta[name=kw-config]');
|
||||
if (metaConfig && metaConfig.content) {
|
||||
if (metaConfig && metaConfig.content && metaConfig.content[0] !== '(') {
|
||||
return metaConfig.content;
|
||||
}
|
||||
var match = location.search.match(/[?&]config=([^&]+)/i);
|
||||
|
|
|
@ -56,8 +56,12 @@ var AppModel = Backbone.Model.extend({
|
|||
this.appLogger.error('Error loading app config', xhr.statusText);
|
||||
return callback(true);
|
||||
}
|
||||
if (!xhr.response.settings) {
|
||||
this.appLogger.error('Invalid app config, no settings section', xhr.response);
|
||||
return callback(true);
|
||||
}
|
||||
this.appLogger.info('Loaded app config from', configLocation, this.appLogger.ts(ts));
|
||||
this.settings.set(xhr.response);
|
||||
this.applyUserConfig(xhr.response);
|
||||
callback();
|
||||
});
|
||||
xhr.addEventListener('error', () => {
|
||||
|
@ -66,6 +70,22 @@ var AppModel = Backbone.Model.extend({
|
|||
});
|
||||
},
|
||||
|
||||
applyUserConfig(config) {
|
||||
this.settings.set(config.settings);
|
||||
if (config.file && config.file.storage && config.file.name && config.file.path) {
|
||||
if (!this.fileInfos.getMatch(config.file.storage, config.file.name, config.file.path)) {
|
||||
var fileInfo = new FileInfoModel({
|
||||
id: IdGenerator.uuid(),
|
||||
name: config.file.name,
|
||||
storage: config.file.storage,
|
||||
path: config.file.path,
|
||||
opts: config.file.options
|
||||
});
|
||||
this.fileInfos.unshift(fileInfo);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addFile: function(file) {
|
||||
if (this.files.get(file.id)) {
|
||||
return false;
|
||||
|
@ -328,10 +348,10 @@ var AppModel = Backbone.Model.extend({
|
|||
} else if (!params.storage) {
|
||||
logger.info('Open file from cache as main storage');
|
||||
this.openFileFromCache(params, callback, fileInfo);
|
||||
} else if (fileInfo && fileInfo.get('rev') === params.rev && fileInfo.get('storage') !== 'file') {
|
||||
} else if (fileInfo && fileInfo.openDate && fileInfo.get('rev') === params.rev && fileInfo.get('storage') !== 'file') {
|
||||
logger.info('Open file from cache because it is latest');
|
||||
this.openFileFromCache(params, callback, fileInfo);
|
||||
} else if (!fileInfo || params.storage === 'file') {
|
||||
} else if (!fileInfo || !fileInfo.openDate || params.storage === 'file') {
|
||||
logger.info('Open file from storage', params.storage);
|
||||
var storage = Storage[params.storage];
|
||||
var storageLoad = function() {
|
||||
|
|
|
@ -5,7 +5,7 @@ Release notes
|
|||
`+` context menu
|
||||
`+` solarized themes
|
||||
`+` select field contents on search hotkey
|
||||
`+` option to preload default config
|
||||
`+` option to preload default config and file
|
||||
`+` save displayed table columns
|
||||
`-` fix app redraw in background
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"settings": {
|
||||
"theme": "fb",
|
||||
"expandGroups": true,
|
||||
"listViewWidth": null,
|
||||
"menuViewWidth": null,
|
||||
"tagsViewHeight": null,
|
||||
"autoUpdate": "install",
|
||||
"clipboardSeconds": 0,
|
||||
"autoSave": true,
|
||||
"rememberKeyFiles": false,
|
||||
"idleMinutes": 15,
|
||||
"minimizeOnClose": false,
|
||||
"tableView": false,
|
||||
"colorfulIcons": false,
|
||||
"lockOnMinimize": true,
|
||||
"lockOnCopy": false,
|
||||
"helpTipCopyShown": false,
|
||||
"skipOpenLocalWarn": false,
|
||||
"hideEmptyFields": false,
|
||||
"skipHttpsWarning": false,
|
||||
"demoOpened": false,
|
||||
"fontSize": 0,
|
||||
"tableViewColumns": null,
|
||||
|
||||
"dropbox": true,
|
||||
"dropboxFolder": null,
|
||||
"dropboxAppKey": null,
|
||||
|
||||
"webdav": true,
|
||||
|
||||
"gdrive": true,
|
||||
"gdriveClientId": null,
|
||||
|
||||
"onedrive": true,
|
||||
"onedriveClientId": null
|
||||
},
|
||||
"file": {
|
||||
"storage": "webdav",
|
||||
"name": "",
|
||||
"path": "",
|
||||
"options": { "user": "", "password": "" }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue