keeweb/app/scripts/models/app-settings-model.js

92 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-09-17 19:50:42 +02:00
import { Model } from 'framework/model';
2019-09-15 14:16:32 +02:00
import { SettingsStore } from 'comp/settings/settings-store';
2015-10-17 23:49:24 +02:00
2019-09-17 19:50:42 +02:00
class AppSettingsModel extends Model {
constructor() {
super();
this.on('change', () => this.save());
}
2015-10-17 23:49:24 +02:00
2019-08-18 10:17:09 +02:00
load() {
return SettingsStore.load('app-settings').then(data => {
if (data) {
this.upgrade(data);
2019-08-16 23:05:39 +02:00
this.set(data, { silent: true });
}
});
2019-09-17 19:50:42 +02:00
}
2019-08-18 10:17:09 +02:00
upgrade(data) {
2017-01-28 23:36:30 +01:00
if (data.rememberKeyFiles === true) {
data.rememberKeyFiles = 'data';
}
2019-09-17 19:50:42 +02:00
}
2017-01-28 23:36:30 +01:00
2019-08-18 10:17:09 +02:00
save() {
2019-09-17 19:50:42 +02:00
SettingsStore.save('app-settings', this);
2015-10-17 23:49:24 +02:00
}
2019-09-17 19:50:42 +02:00
}
2019-09-20 20:31:19 +02:00
AppSettingsModel.defineModelProperties(
{
theme: 'fb',
locale: null,
expandGroups: true,
listViewWidth: null,
menuViewWidth: null,
tagsViewHeight: null,
autoUpdate: 'install',
clipboardSeconds: 0,
autoSave: true,
autoSaveInterval: 0,
rememberKeyFiles: false,
idleMinutes: 15,
minimizeOnClose: false,
tableView: false,
colorfulIcons: false,
useMarkdown: true,
2019-09-20 20:31:19 +02:00
directAutotype: true,
titlebarStyle: 'default',
lockOnMinimize: true,
lockOnCopy: false,
lockOnAutoType: false,
lockOnOsLock: false,
helpTipCopyShown: false,
templateHelpShown: false,
skipOpenLocalWarn: false,
hideEmptyFields: false,
skipHttpsWarning: false,
demoOpened: false,
fontSize: 0,
tableViewColumns: null,
generatorPresets: null,
generatorHidePassword: false,
cacheConfigSettings: false,
allowIframes: false,
useGroupIconForEntries: false,
2019-09-17 19:50:42 +02:00
2019-09-20 20:31:19 +02:00
canOpen: true,
canOpenDemo: true,
canOpenSettings: true,
canCreate: true,
canImportXml: true,
2019-09-25 23:24:38 +02:00
canImportCsv: true,
2019-09-20 20:31:19 +02:00
canRemoveLatest: true,
canExportXml: true,
canExportHtml: true,
canSaveTo: true,
2020-04-17 20:58:47 +02:00
canOpenStorage: true,
canOpenGenerator: true,
2019-09-17 19:50:42 +02:00
2019-09-20 20:31:19 +02:00
dropbox: true,
webdav: true,
gdrive: true,
onedrive: true
},
{ extensions: true }
);
2015-10-17 23:49:24 +02:00
2019-09-17 19:50:42 +02:00
const instance = new AppSettingsModel();
2015-10-17 23:49:24 +02:00
2019-09-17 19:50:42 +02:00
export { instance as AppSettingsModel };