2016-11-10 05:56:23 +00:00
|
|
|
import * as db from '../common/database';
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-11-22 19:42:10 +00:00
|
|
|
export const name = 'Settings';
|
2016-10-02 20:57:00 +00:00
|
|
|
export const type = 'Settings';
|
|
|
|
export const prefix = 'set';
|
2017-03-23 22:10:42 +00:00
|
|
|
export const canDuplicate = false;
|
2016-11-22 19:42:10 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export function init () {
|
2016-11-10 01:15:27 +00:00
|
|
|
return {
|
2016-11-26 08:29:16 +00:00
|
|
|
showPasswords: false,
|
2016-10-02 20:57:00 +00:00
|
|
|
useBulkHeaderEditor: false,
|
2016-10-26 17:49:49 +00:00
|
|
|
followRedirects: true,
|
2017-04-21 04:30:52 +00:00
|
|
|
editorFontSize: 11,
|
|
|
|
editorIndentSize: 2,
|
2016-10-02 20:57:00 +00:00
|
|
|
editorLineWrapping: true,
|
2017-01-24 22:18:11 +00:00
|
|
|
editorKeyMap: 'default',
|
2016-10-02 20:57:00 +00:00
|
|
|
httpProxy: '',
|
|
|
|
httpsProxy: '',
|
2017-03-28 22:45:23 +00:00
|
|
|
proxyEnabled: false,
|
2016-10-02 20:57:00 +00:00
|
|
|
timeout: 0,
|
2016-10-21 17:20:36 +00:00
|
|
|
validateSSL: true,
|
2016-10-26 20:19:18 +00:00
|
|
|
forceVerticalLayout: false,
|
2017-05-17 16:35:44 +00:00
|
|
|
autoHideMenuBar: false,
|
2017-06-01 13:35:29 +00:00
|
|
|
theme: 'default',
|
|
|
|
disableAnalyticsTracking: false
|
2016-11-10 01:15:27 +00:00
|
|
|
};
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-11-22 19:42:10 +00:00
|
|
|
export function migrate (doc) {
|
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
2016-11-16 17:18:39 +00:00
|
|
|
export async function all () {
|
|
|
|
const settings = await db.all(type);
|
|
|
|
if (settings.length === 0) {
|
|
|
|
return [await getOrCreate()];
|
|
|
|
} else {
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export async function create (patch = {}) {
|
|
|
|
return db.docCreate(type, patch);
|
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
export async function update (settings, patch) {
|
2016-09-21 20:32:45 +00:00
|
|
|
return db.docUpdate(settings, patch);
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2016-09-21 20:32:45 +00:00
|
|
|
|
2017-06-01 13:50:15 +00:00
|
|
|
export async function getOrCreate (patch = {}) {
|
2016-10-02 20:57:00 +00:00
|
|
|
const results = await db.all(type);
|
|
|
|
if (results.length === 0) {
|
2017-06-01 13:50:15 +00:00
|
|
|
return await create(patch);
|
2016-10-02 20:57:00 +00:00
|
|
|
} else {
|
|
|
|
return results[0];
|
|
|
|
}
|
|
|
|
}
|